Goldman Sachs | Coderpad | First non-repeating character
Anonymous User
6696
Mar 10, 2022
Mar 10, 2022
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!
Comments (6)


