Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike

1 Answer

0 like 0 dislike

Today I had my coderpad round with GS. We dived straight into the code. This was the first question:

 

A string was given. I needed to find the first non-repeating counter. If there is no such character, return 0.

 

Input:
asubsebusapd

 

Output:
e

 

Input:
aabbcc

 

Output:
0

 

Pretty straight-forward.

 

  • Used a hashmap to count the frequency.
  • Traverse the array to find the first element with frequency = 1 and return it.
  • If there is no such element, return 0.

 

The interviewer did not ask me to optimize it. If anyone has any idea, please comment.

 

Second question:
https://leetcode.com/discuss/interview-question/1837465/Goldman-Sachs-or-Coderpad-or-Find-the-maximum-gold-that-can-be-collected

 

Third question:
https://leetcode.com/discuss/interview-question/1837497/Goldman-Sachs-or-Coderpad-or-Find-the-largest-tree

 

Thanks!

by Expert (30,360 points)