Add office photos
Goldman Sachs logo
Employer?
Claim Account for FREE

Goldman Sachs

3.5
based on 1.2k Reviews
Filter interviews by
Software Engineer
Fresher
Skills
Clear (1)

10+ Goldman Sachs Software Engineer Interview Questions and Answers

Updated 5 Feb 2024

Q1. Serialization and Deserialization of an N-ary Tree

Given an N-ary tree where each node has at most 'N' child nodes, the task is to serialize the tree into a sequence of bits and then deserialize it back to reco...read more

Ans.

Serialization and deserialization of an N-ary tree involves converting the tree into a sequence of bits and reconstructing the original tree from this format.

  • Serialize the N-ary tree by traversing it in level order and representing each node and its children using a space-separated sequence of integers.

  • Deserialize the serialized tree by parsing the input sequence and reconstructing the tree structure based on the provided format.

  • Use a queue data structure for deserialization ...read more

Add your answer
right arrow

Q2. Design a Constant Time Data Structure

Create a data structure that maintains mappings between keys and values, supporting the following operations in constant time:

1. INSERT(key, value): Add or update the inte...read more
Ans.

Design a constant time data structure for key-value mappings with operations like INSERT, DELETE, SEARCH, GET, GET_SIZE, and IS_EMPTY.

  • Use a hash table to achieve constant time complexity for operations.

  • Implement INSERT, DELETE, SEARCH, GET, GET_SIZE, and IS_EMPTY functions.

  • Ensure key is a string and value is a positive integer.

  • Return appropriate results based on the operation type.

  • Handle edge cases like key not found or data structure being empty.

Add your answer
right arrow
Goldman Sachs Software Engineer Interview Questions and Answers for Freshers
illustration image

Q3. Simplify Directory Path Problem Statement

You are provided with a directory path in Unix-style notation, and your task is to simplify it according to given rules.

In a Unix-style file system:

  • A dot (.) refers ...read more
Ans.

Given a Unix-style directory path, simplify it by following certain rules and return the simplified path.

  • Use a stack to keep track of directories while iterating through the input path.

  • Handle cases for '.', '..', and multiple slashes appropriately.

  • Return the simplified path by joining the directories in the stack with '/' separator.

Add your answer
right arrow

Q4. LRU Cache Design Problem Statement

Design and implement a data structure for a Least Recently Used (LRU) cache that supports the following operations:

  • get(key) - Retrieve the value associated with the specifie...read more
Ans.

Design and implement a Least Recently Used (LRU) cache data structure that supports get and put operations with a specified capacity.

  • Implement a doubly linked list to keep track of the order of keys based on their usage.

  • Use a hashmap to store key-value pairs for quick access and updates.

  • When a key is accessed or updated, move it to the front of the linked list to mark it as the most recently used.

  • When the cache reaches its capacity, evict the least recently used item from the...read more

Add your answer
right arrow
Discover Goldman Sachs interview dos and don'ts from real experiences

Q5. Maximum of All Subarrays of Size K

Given an array of non-negative integers and an integer K representing the length of a subarray, your task is to determine the maximum elements for each subarray of size K.

Exa...read more

Ans.

Find the maximum elements for each subarray of size K in a given array.

  • Iterate through the array and maintain a deque to store the indices of elements in decreasing order.

  • Pop elements from the deque that are out of the current window.

  • Keep track of the maximum element in each subarray of size K.

  • Return the maximum elements for each subarray.

Add your answer
right arrow

Q6. what is virtual memory? Will we need virtual memory even if we have infinite amount of RAM?

Ans.

Virtual memory is a memory management technique that allows a computer to use more memory than it physically has.

  • Virtual memory uses a combination of RAM and hard disk space to store data.

  • It allows programs to use more memory than is physically available.

  • If a program tries to access memory that is not currently in RAM, it will be swapped in from the hard disk.

  • Even if we had infinite RAM, virtual memory would still be necessary for certain tasks such as memory isolation and pr...read more

Add your answer
right arrow
Are these interview questions helpful?

Q7. Given an array, Find out maximum length of subarray where max of subarray <= 2*min of subarray

Ans.

Find maximum length of subarray where max <= 2*min.

  • Iterate through array and keep track of max and min values.

  • Update max length when condition is met.

  • Time complexity: O(n)

Add your answer
right arrow
Q8. What is virtual memory?
Ans.

Virtual memory is a memory management technique that allows a computer to compensate for physical memory shortages by temporarily transferring data from RAM to disk storage.

  • Virtual memory allows programs to use more memory than is physically available on the system.

  • It helps in multitasking by allowing multiple programs to run simultaneously without running out of memory.

  • Virtual memory uses a combination of RAM and disk space to store data that is not currently in use by progr...read more

Add your answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. Create BST from incoming stream of nodes

Ans.

Create a Binary Search Tree (BST) from an incoming stream of nodes.

  • Start with an empty BST

  • For each incoming node, compare it with the root node and insert it accordingly

  • Repeat the process until all nodes are inserted

Add your answer
right arrow

Q10. Implement LRU cache.

Ans.

Implement LRU cache

  • LRU stands for Least Recently Used

  • It is a cache eviction policy that removes the least recently used item

  • It can be implemented using a doubly linked list and a hash map

  • Newly accessed items are moved to the front of the list

  • When the cache is full, the item at the end of the list is removed

Add your answer
right arrow

Q11. Trapping rainwater problem

Ans.

Trapping rainwater problem

  • The problem involves calculating the amount of rainwater that can be trapped between bars in an elevation map

  • Use two pointers approach to calculate the water trapped at each bar

  • Keep track of the maximum height on the left and right of each bar to calculate the trapped water

Add your answer
right arrow

Q12. Serach in sorted n*n matrix

Ans.

Search for a target value in a sorted n*n matrix.

  • Start from the top-right corner or bottom-left corner of the matrix.

  • Compare the target value with the current element and move left or down accordingly.

  • Repeat until the target value is found or the boundaries of the matrix are crossed.

Add your answer
right arrow

More about working at Goldman Sachs

Back
HQ - New York, New York, United States (USA)
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at Goldman Sachs Software Engineer

based on 5 interviews
1 Interview rounds
Coding Test Round
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Software Engineer Interview Questions from Similar Companies

Accenture Logo
3.8
 • 101 Interview Questions
Info Edge Logo
3.9
 • 50 Interview Questions
HCL Group Logo
3.6
 • 20 Interview Questions
Xoriant Logo
4.1
 • 15 Interview Questions
View all
Recently Viewed
SALARIES
Concentrix Catalyst
SALARIES
HCL Infosystems
SALARIES
Persistent Systems
SALARIES
DXC Technology
DESIGNATION
INTERVIEWS
Incedo
10 top interview questions
SALARIES
DXC Technology
SALARIES
HCL Infosystems
SALARIES
NTT Data
SALARIES
Ernst & Young
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter