crazy helix hackerrank solution
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int q = in.nextInt();
int[] arr = new int[n];
for(int ar_i = 0; ar_i < n; ar_i++){
arr[ar_i] = ar_i+1;
}
for(int ind=1;ind<=q+1;ind++){
int a = in.nextInt();
if(1==a){
reverseSubArray(arr, in.nextInt()-1, in.nextInt()-1);
}else if(2==a){
int b = in.nextInt();
for(int i=0;i<arr.length;i++){
if(arr[i]==b){
System.out.println("element "+ b +" is at position "+ (i+1));
break;
}
}
}else if(3==a){
int b = in.nextInt();
System.out.println("element at position " + b + " is " + arr[b-1]);
}
}
}
static void reverseSubArray(int arr[], int i, int j){
if(i>=j) return;
for(;i<j;i++,j--){
int temp = arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}