Tip 1 : Codeforces 1600+ rating
Tip 2 : practice standard problems and puzzles
Tip 3 : They work with java , so java knowledge may come in handy
Tip 1 : Have some projects on resume
Tip 2 : Having good problem solving skills
Timing ( Morning 11 am )
We cannot use the element at a given index twice.
Try to do this problem in O(N) time complexity.
Choose 'l', 'r' (1 <= 'l' <= 'r' <='N') and reverse the subarray from 'l' to 'r'.
Let 'N' = 5, 'K' = 3, 'A' = [4, 2, 1, 2, 2].
We can reverse the subarray from index 3 to 4 (1-based indexing).
Array becomes [4, 2, 2, 1, 2].
Our answer is 8.
push(X, M): Pushes an element X into the Mth stack. Returns true if the element is pushed into the stack, otherwise false.
pop(M): Pops the top element from Mth Stack. Returns -1 if the stack is empty, otherwise, returns the popped element.
Type 1: for push(X, M) operation.
Type 2: for pop(M) operation.
Evening
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
How many times will the loop execute? for(int i = 0; i < 5; i++)