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

Goldman Sachs

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

10+ Goldman Sachs Software Developer Interview Questions and Answers

Updated 13 Jun 2024

Q1. Delete a Node from a Linked List

You are provided with a linked list of integers. Your task is to implement a function that deletes a node located at a specified position 'POS'.

Input:

The first line contains a...read more
Ans.

Implement a function to delete a node from a linked list at a specified position.

  • Traverse the linked list to find the node at the specified position.

  • Update the pointers of the previous and next nodes to skip the node to be deleted.

  • Handle edge cases such as deleting the head or tail of the linked list.

  • Ensure to free the memory of the deleted node to avoid memory leaks.

Add your answer
right arrow

Q2. Matrix Word Search Problem

Explanation: You are given an 'M' x 'N' matrix of characters named CHARACTER_MATRIX and a string WORD. Your task is to identify and list all the occurrences of the string within the m...read more

Ans.

Matrix Word Search Problem - Find occurrences of a given word in all eight possible directions within a matrix.

  • Iterate through each cell in the matrix and check for the starting character of the word.

  • For each occurrence of the starting character, check all eight directions for the complete word.

  • Keep track of the coordinates of each character in the word for each occurrence found.

  • Ensure boundaries are not crossed while searching in all directions.

  • Output the coordinates of each...read more

Add your answer
right arrow

Q3. Buy and Sell Stock Problem Statement

Imagine you are Harshad Mehta's friend, and you have been given the stock prices of a particular company for the next 'N' days. You can perform up to two buy-and-sell transa...read more

Ans.

The task is to determine the maximum profit that can be achieved by performing up to two buy-and-sell transactions on a given set of stock prices.

  • Iterate through the array of stock prices and calculate the maximum profit that can be achieved by buying and selling at different points.

  • Keep track of the maximum profit after the first transaction and the maximum profit overall by considering different combinations of buy and sell points.

  • Ensure to sell the stock before buying agai...read more

Add your answer
right arrow

Q4. Morse Code to English Problem Statement

You are provided with a string of morse code(s) of length N. Your task is to convert this morse code into the corresponding alphanumeric code consisting of lowercase Engl...read more

Ans.

Convert Morse code to alphanumeric code using a predefined table.

  • Iterate through the morse code string and convert each morse code to its corresponding alphanumeric character using the given table.

  • Join the converted characters to form the final alphanumeric string.

  • Handle spaces between morse code characters by adding a space in the final alphanumeric string.

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

Q5. DFS Traversal Problem Statement

Given an undirected and disconnected graph G(V, E), where V is the number of vertices and E is the number of edges, the connections between vertices are provided in the 'GRAPH' m...read more

Ans.

DFS traversal problem to find connected components in an undirected and disconnected graph.

  • Use Depth First Search (DFS) algorithm to traverse the graph and find connected components

  • Maintain a visited array to keep track of visited vertices

  • Iterate through all vertices and perform DFS on unvisited vertices to find connected components

Add your answer
right arrow

Q6. Transitive Closure of Directed Graph Problem Statement

Given a directed graph with 'V' vertices and 'E' edges, determine if a vertex i is reachable from vertex j for all pairs of vertices (i, j). A vertex j is ...read more

Ans.

Determine reachability between all pairs of vertices in a directed graph.

  • Use Floyd Warshall algorithm to find transitive closure of the graph.

  • Initialize a V x V matrix with 1s on the diagonal and 0s elsewhere.

  • Update matrix by checking if there is a path from i to j through k.

  • Repeat the process for all vertices to get the transitive closure matrix.

Add your answer
right arrow
Are these interview questions helpful?

Q7. randN function : which generates random number in [1,2,3..N] with equal probability. Given rand5, write a code for rand7 using rand5

Ans.

Code for rand7 using rand5 function

  • Use rand5 twice to generate a number in [1,25] with equal probability

  • If the number is greater than 21, discard and try again

  • Otherwise, return (number mod 7) + 1

View 1 answer
right arrow
Q8. Write an efficient program to find the sum of the contiguous subarray within a one-dimensional array of numbers that has the largest sum.
Ans.

Efficient program to find sum of largest contiguous subarray within a one-dimensional array.

  • Use Kadane's algorithm to find the maximum sum subarray in O(n) time complexity.

  • Initialize max_sum and current_sum to 0, iterate through array updating current_sum and max_sum.

  • Return max_sum as the result.

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

Q9. Print all nodes at a distance k from a given node in binary tree?

Ans.

Print all nodes at a distance k from a given node in binary tree

  • Use Depth First Search (DFS) to traverse the tree

  • Maintain a variable to keep track of the distance from the given node

  • Print the nodes when the distance is equal to k

View 1 answer
right arrow

Q10. Puzzle: Using all(8,8,3,3) and only operators(*,/,-,+), make 24

Ans.

Using 8,8,3,3 and only *, /, -, + operators, make 24.

  • Start with 8+8=16

  • Divide 3 by 3 to get 1

  • Multiply 16 by 1 to get 16

  • Add 8 to 16 to get 24

Add your answer
right arrow

Q11. Write down function to select pivot element randomly in Quick Sort

Ans.

Function to randomly select pivot element in Quick Sort

  • Generate a random index within the range of the array

  • Return the element at the randomly generated index as the pivot

Add your answer
right arrow

Q12. How do you implement LRU cache?

Ans.

LRU cache is implemented using a doubly linked list and a hash map.

  • Create a doubly linked list to keep track of the order of elements in the cache.

  • Create a hash map to store the key-value pairs of the cache.

  • When a new element is added, check if the cache is full. If it is, remove the least recently used element from the linked list and the hash map.

  • When an element is accessed, move it to the front of the linked list to mark it as the most recently used.

  • When an element is remo...read more

Add your answer
right arrow

Q13. What is inheritance in java?

Ans.

Inheritance in Java allows a class to inherit properties and behavior from another class.

  • Inheritance allows for code reusability and promotes a hierarchical relationship between classes.

  • Subclasses can access the methods and fields of their superclass.

  • Example: class Dog extends Animal {} - Dog inherits properties and behavior from Animal class.

Add your answer
right arrow

Q14. Difference between OOP and POP

Ans.

OOP focuses on objects and classes, while POP focuses on procedures and functions.

  • OOP emphasizes data encapsulation and inheritance

  • POP emphasizes sequential execution of procedures

  • Example of OOP: Java, C++

  • Example of POP: C, Pascal

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 Developer

based on 9 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 Developer Interview Questions from Similar Companies

Practo Logo
3.2
 • 35 Interview Questions
Mobikwik Logo
3.7
 • 17 Interview Questions
View all
Recently Viewed
INTERVIEWS
Sub-K IMPACT Solutions
No Interviews
SALARIES
Aditya Birla Housing Finance
SALARIES
Aditya Birla Housing Finance
SALARIES
Aditya Birla Housing Finance
SALARIES
Aditya Birla Housing Finance
SALARIES
Indus Towers
SALARIES
Aditya Birla Housing Finance
No Salaries
SALARIES
Aditya Birla Housing Finance
No Salaries
INTERVIEWS
Goldman Sachs
20 top interview questions
SALARIES
Aditya Birla Housing Finance
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