Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

sibling search java program

  public int[] getSiblings(int[] arr, int x) {
    int pos = 0;
    for (int i = 0; i < arr.length; i++) {
      if(arr[i]==x) pos = i+1;
    }
    int start = Integer.highestOneBit(pos); // get max power of 2
    int end = start*2-1 >= arr.length ? arr.length: start*2-1;
    return IntStream.range(start-1, end).map(i -> arr[i]).filter(v -> v!=x).toArray();
  }
Comment

PREVIOUS NEXT
Code Example
Java :: is type java 
Java :: exception(string message throwable cause) 
Java :: private void loadmaze(string mazefile) 
Java :: how to create gravity in Java 
Java :: springBoot ConditionalOnMissingBean 
Java :: java private keyword 
Java :: error message pushes button down 
Java :: how to get address of object in java 
Java :: sudoku generator java code 
Java :: io fole scanner object syntax 
Java :: how to reinstall nginuity 
Java :: java reverse nodes with single node 
Java :: codegrepper java instanceof 
Java :: android studio enum usage 
Java :: Java Implement SAM with anonymous classes in java 
Java :: java replace nans with 0 csv line 
Java :: using handler runnable for refresh android 
Java :: hippo get a node via id 
Java :: alternatives jdk1.8 rhel6 
Java :: fibonacci numbers using recursion in java 
Java :: java schleifendurchläufe zählen 
Java :: java i/o streams 
Java :: prevent creating instance of singleton from thread 
Java :: compiling and running program in terminal 
Java :: webmvctest vs springboottest 
Java :: springboot body 
Java :: menuitemcompat getactionview is deprecated in android 
Java :: httpsession vs cookie servlet 
Java :: Which package contains the Math classin java? 
Java :: why use var in java 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =