Phone Screen
Anonymous User
1557

Was asked a question to find the largest k digit number , where number is to be choosen from the given array maintaing the order For example:

Arr=[4,9,0,2] k=2
Largest Number: 92

[4,0,2,9], K=2
Largest Number: 49

I started with brute force recursion followed by DP on this , i optimised it further using heap and final time complexity was O(nlogn)

Wrote the code for heap solution

Comments (14)