Answer: Deloitte, Recent Online Assessment (30th August 2023) | Position of Number in a

Answer · Posted Sep 2023

QUESTION -1 SOLUTION : -  int ans = -1; for(int i=0;i<arr.size();i++){ if(arr[i]==x){ ans = i+1; } } return ans; }   Time complexity :- O(n) Space Complexity :- O(1)   QUESTION -2 SOLUTION : - int sum = 0; for(int i=0;i<arr.size();i++){ if(pow(2,i)-1<arr.size()){ sum+=arr[pow(2,i)-1]; }  } return sum; } Time complexity :- O(n) Space Complexity :- O(1)

The full answer & interview discussion are available to premium members.

Log in Create a free account