"crazy helix hackerrank solution" Code Answer's

You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "crazy helix hackerrank solution" answered properly. Developers are finding an appropriate answer about crazy helix hackerrank solution related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like crazy helix hackerrank solution. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on crazy helix hackerrank solution. 

crazy helix hackerrank solution

By Calm CobraCalm Cobra on May 22, 2020
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;
		}
    }

Source: www.hackerrank.com

Add Comment

0

crazy helix hackerrank solution

By Calm CobraCalm Cobra on May 22, 2020
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int main()
{
int n,q,x,y,z,t;
scanf("%d %d",&n,&q);
int a[n];
for(int i=0;i<n;i++)
{
    a[i]=i+1;
}
for(int j=0;j<q;j++)
{
    scanf("%d",&x);
    if(x==1)
    {
        int temp=0;
        scanf("%d",&y);
        scanf("%d",&z);
        t=z-y+1;
        y--;
        z--;

            for(int j=0;j<t/2;j++)
            {
                 temp=a[y+j];
                a[y+j]=a[z-j];
                a[z-j]=temp;
            }

    else if(x==2)
        {
            int t=0;
           scanf("%d",&y); 
          for(int i=0;i<n;i++)
          {
              if(a[i]==y)
              {
                  t=i;
                  break;
              }
          }
          printf("element %d is at position %d\n",y,t+1);
        }
     else
        {
           scanf("%d",&y); 
            printf("element at position %d is %d \n",y,a[y-1]);
        }

}
return 0;

Source: www.hackerrank.com

Add Comment

0

crazy helix hackerrank solution

By Calm CobraCalm Cobra on May 22, 2020
n,queries=map(int,input().split())
num=[i+1 for i in range(n)]
for i in range(queries):
    l=list(map(int,input().split()))
    if len(l)==3:
        if l[1]==1:
            num=num[:l[1]-1]+num[l[2]-1::-1]+num[l[2]:]//1
        else:
            num=num[:l[1]-1]+num[l[2]-1:l[1]-2:-1]+num[l[2]:]//1
    elif l[0]==2:
        print("element {0} is at position {1}".format(l[1],num.index(l[1])+1))//2
    else:
        print("element at position {0} is {1}".format(l[1],num[l[1]-1]))

Source: www.hackerrank.com

Add Comment

0

All those coders who are working on the Whatever based application and are stuck on crazy helix hackerrank solution can get a collection of related answers to their query. Programmers need to enter their query on crazy helix hackerrank solution related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about crazy helix hackerrank solution for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of crazy helix hackerrank solution while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "crazy helix hackerrank solution". Visit this developer's friendly online web community, CodeProZone, and get your queries like crazy helix hackerrank solution resolved professionally and stay updated to the latest Whatever updates. 

Whatever answers related to "crazy helix hackerrank solution"

View All Whatever queries

Whatever queries related to "crazy helix hackerrank solution"

Browse Other Code Languages

CodeProZone