Adobe Noida | CS1

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2022-09-09Added By Anonymous
Source: Link

round 1, 7th sept


Very bad experience.


Contrary to what people say that they also ask leetcode medium easy, its not true.


They asked me this:

https://leetcode.com/problems/jump-game-ii/


First after thinking for sometime I gave him, backtracking approach. He said give me better.


Then I told about DP solution, he said he me more better but agreed that this will work.


Then after thinking a lot, I couldnt come up with more better solution then asked him to give him a produciton level code for it using dp.


1int getMinSteps(vector<int> &step) { 2 int len = step.size(); 3 if(len ==0) return -1; 4 if(len<2) return 0; 5 vector<int> dp(len, INT_MAX); 6 if(step[0] !=0) dp[0] = 0; 7 for(int i=0; i<len; i++) { 8 for(int j=i+1; j<len && j<= (i+step[i]); j++) { 9 if(step[j] !=0) dp[j] = min(dp[j], dp[i]+1); 10 } 11 } 12 return dp[len-1]==INT_MAX ? -1 : dp[len-1]; 13 } 14
•In solution to him I intialized with INT_MAX, which will overflow. it should have been INT_MAX-1
•otherwise it worked
•he wasnt agreeing for it later on agreed.
•one hr got over in this, so no further questions
•got feedback a day after next that I wasnt shortlisted.


Comments