Josh Technology | SDE interview Round 3 Question | Help me to find solution

I want to share my interview experience and looking for the solution of interview question , my main LC account is https://leetcode.com/u/aditya2802singh/ .
My first interview in josh technology , which is about 1.5 hour , in which they asked Flattening of Linked List and a binary Tree Question (I don't remember the ques.) .

  • I solved and optimized both questions.

My second interview which is almost 2 hour and 15 minutes in which they asked a Tree question [ i used DFS to solve this], and secound is binary search question , in which the odd indexed elements are shuffled and i have to search for an element in O(log N) time.

  • I solved and optimized both questions.

My third interview started just after 30 minutes of 2nd interview , in which i was asked only one question.

Q. Create all unique N-size subarrays where the sum is M without repetitions.
(here repeatations of numbers are allowed but not repeated elements subarrays.)
i have to directly print those subarrays, so space complexity should be O(1)

Ex . if N = 4 and M = 10. the solution should be
[1,1,1,7], [1,1,2,6], [1,1,3,5], [1,1,4,4] , ( [1,1,5,3] is not allowed because it is same as [1,1,3,5])
[1,2,3,4], [1,2,2,5], [1,3,3,3],[2,2,2,4],

my first approach by recursive tree , but as i can't use a hashset , i stopped thinking about this
secondary approach is using recursion but it is not optimized .
i should not form all combinations.
i have to directly print the subarrays , which much calculations ( using recursion etc.)
So,i got confused here and not able to optimize this question and got rejected.

Comments (6)