NPCI OA
There are two questions:

1st: Reduce the number n to 1 with the minimum number of operations.
Operations:
i) Reduce n by 1
ii) Divide n by any number x, i.e., x < n

Approach: Use simple recursion with two conditions and apply dynamic programming (DP) for larger values of n.

2nd: Longest increasing consecutive sequence in a grid, considering up, down, left, and right (horizontal and vertical moves).

Constraints: n*n grid where n < 100.

Approach: I used DFS + DP to optimize the result. Start at every (i,j) position to find the longest sequence and store it in the DP table at (i,j).

Both questions are not that hard.
Given time was: 40 minutes
I was able to solve both in 20-22 minutes with acceptance.

image
Interview Experience
Interested people can join for updates on
leetcode daily problem and contest discussion : group

Comments (0)