Answer: Goldman Sachs OA Question 2024 June | HashMap & Strings | on-campus
Answer · Posted Jun 2026
Solution: Longest Palindrome — Character Count Map Approach To construct a palindrome, characters must appear in pairs (one on the left side, one on the right). At most one character can have an odd count, which can be placed in the very center of the palindrome. We can solve this problem in O(N) time by counting the frequencies of all characters in the string: For each character, if its count is even, we can use all of its occurrences in ...
The full answer & interview discussion are available to premium members.
Log in Create a free account