Interview Questions and Recruitment Information for Goldman Sachs (2023) | IQCode

About Goldman Sachs

Goldman Sachs is a premier financial institution worldwide, serving a diverse clientele base composed of corporations, financial institutions, governments, and individuals. Its services include investment banking, investment management, securities, and consumer banking, among others.

The company was established in 1869, with its headquarters in New York and several offices located in major financial centers globally. Goldman Sachs aims to encourage global economic development and financial opportunities. It utilizes its resources and workforce to help enhance its clients' success while improving individual prosperity and economic progress worldwide.

According to Goldman Sachs, collaboration, teamwork, and honesty are essential in creating a conducive environment for its employees to deliver the best possible results for clients. The company values fast-thinking employees with communication and passion skills over precise qualifications, making it an excellent place for recent graduates or anyone who wants to join a dynamic work environment.

If you're excited about working at Goldman Sachs, whether still studying, recently graduated, or have been working for a few years, the company wants to hear from you. Learn More about career opportunities here: [].

Goldman Sachs Recruitment Process

Interview Process:

During the recruitment process, interested candidates will undergo several rounds of interviews designed to assess their suitability for the available positions. These rounds vary, but most of them will involve interviews with human resources personnel, hiring managers, and other senior employees at Goldman Sachs. The interviews help in assessing various skills like technical skills, communication, analytics, and problem-solving abilities.

After the interview rounds, the hiring team will evaluate candidates' qualifications, experience, the result of their assessment tests, and other factors before making a final decision. Successful candidates will receive an offer detailing their employment terms, including salary, benefits, and start date.


 * Multithreading in Java is a feature that allows multiple threads to execute concurrently within the same program.
 * Multiple threads are formed by extending the thread class, implementing the runnable interface, or by using 
 * the thread pool executor framework. 

// Example of thread creation using the Thread class
class MyThread extends Thread {
    public void run() {
        // code to be executed in this thread

// Example of thread creation using the Runnable interface
class MyRunnable implements Runnable {
    public void run() {
        // code to be executed in this thread

// Example of thread creation using the Executor framework
Executor executor = Executors.newFixedThreadPool(5);
executor.execute(new MyRunnable());

In Java, multithreading is a powerful mechanism that enables concurrent execution of programming instructions. It is a useful tool that can simplify the coding process when working with complex applications and data structures. Threads are formed in Java through the use of the Thread class, the Runnable interface, or the thread pool executor framework. These methods all allow developers to create multiple threads that can execute concurrently, performing various tasks and computations in parallel.

Explanation of Hashcode() and Equals() in Java




are two methods in Java that play a crucial role in object comparison.


method is used to get a unique identifier number associated with an object, which helps to quickly identify the object in collections such as HashTables. This method returns an integer value and the value is typically used as an index in a HashTable, hence the name.



method is used to compare two objects for their equality. This method returns a boolean value of true if two objects have the same contents and false if they are not identical.

It is important to note that if two objects are equal, their hash code must also be equal. However, if two objects have the same hash code, they may not necessarily be equal. Therefore, in order to correctly implement the


method, the


method should also be properly overridden.

Here is an example of how to override these two methods:

   public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + ((name == null) ? 0 : name.hashCode());
      result = prime * result + age;
      return result;

   public boolean equals(Object obj) {
      if (this == obj)
         return true;
      if (obj == null)
         return false;
      if (getClass() != obj.getClass())
         return false;
      Person other = (Person) obj;
      if (name == null) {
         if ( != null)
            return false;
      } else if (!name.equals(
         return false;
      if (age != other.age)
         return false;
      return true;

In this example, we override the




methods for a class called "Person". The hashing algorithm used is based on the person's name and age. If two persons have the same name and age, they will have the same hash code and will be considered equal when compared using the



Discussing the Final Keyword in Java

In Java, the


keyword is used to declare a constant variable. Once you declare a variable with the


keyword, you cannot change its reference or value. This can be useful for creating a variable that should not be modified throughout the program.

Furthermore, the


keyword can also be used to make a class or method unchangeable. If you declare a class as final, it cannot be subclassed. If you declare a method as final, it cannot be overridden by any subclasses.

Using the


keyword can also have performance benefits in some cases, as the compiler can optimize the code knowing that certain variables or methods will not change.

Overall, the


keyword is a useful tool for creating constants, unchangeable classes and methods, and potentially optimizing code.

Difference Between StringBuffer and StringBuilder Classes in Java

Both StringBuffer and StringBuilder classes are used to perform string manipulation in Java. However, there are some key differences between these two classes:

1. Thread-safety: StringBuffer is thread-safe while StringBuilder is not. This means that StringBuffer can be safely used in a multi-threaded environment where multiple threads may attempt to modify the same string at the same time. StringBuilder, on the other hand, should only be used in a single-threaded environment because it is not thread-safe.

2. Performance: StringBuilder is faster than StringBuffer because it is not synchronized. This means that StringBuilder can perform string manipulation operations faster than StringBuffer.

3. Usability: StringBuilder is newer than StringBuffer. It was introduced in Java 5 and is generally preferred over StringBuffer in new code because it offers better performance. However, StringBuffer still has its uses in legacy code and in situations where thread-safety is important.

In summary, StringBuffer is thread-safe but slower, while StringBuilder is faster but not thread-safe. When selecting between these two classes, it is important to consider the requirements of your program and choose the one that best suits your needs.

//Example usage of StringBuilder
StringBuilder sb = new StringBuilder();
sb.append(" ");
System.out.println(sb.toString()); //output: "Hello world"

//Example usage of StringBuffer
StringBuffer sbuff = new StringBuffer();
sbuff.append(" ");
System.out.println(sbuff.toString()); //output: "Hello world"

Internal Architecture of Java Virtual Machine (JVM)

Java Virtual Machine (JVM) is an abstract machine that provides a runtime environment to execute Java code. The JVM is responsible for converting the byte code into machine-readable code and executing it.

The internal architecture of the JVM consists of three main components: Class Loader, Execution Engine, and Memory Management System.

1. Class Loader: The Class Loader loads Java classes into memory. Java classes are loaded dynamically, i.e. as they are referred to by other classes. When a Java program is executed, the JVM loads the main class and then, loads all the referenced classes. The JVM searches for the required classes in the classpath – a set of directories, ZIP files, and JAR files. The Class Loader loads the class by reading the binary data that represents the class.

2. Execution Engine: The Execution Engine interprets the Java bytecode into machine-readable instructions. The bytecode is executed one at a time, and the results of one instruction are fed as inputs to the next instruction. The bytecode is executed by the Just-In-Time compiler (JIT), HotSpot compiler, or interpreters.

3. Memory Management System: The Memory Management System is responsible for managing the memory allocated to a Java program. JVM allocates memory to the program in two ways, Stack and Heap. Java objects are stored in the Heap memory area. The Stack memory area is used to store local variables and method calls. Garbage Collection is used to free up memory used by objects that are no longer needed.

Understanding the internal architecture of JVM is necessary to write efficient Java programs.

What is Garbage Collection in Java?

Garbage Collection in Java is a process where the JVM (Java Virtual Machine) automatically frees up memory by removing objects that are no longer being used by the program. Java uses automatic garbage collection to manage memory, which makes it easier for developers to write Java applications without worrying about memory allocation and deallocation. When an object is no longer being used by the program, the garbage collector identifies it and removes it from memory, freeing up space for other objects to be created. This helps prevent memory leaks and other memory-related issues that can slow down or crash a Java program.

Difference between Interface and Abstract Class in Java

In Java, an interface is a contract that specifies the methods that a class must implement, but does not provide any implementation details. On the other hand, an abstract class is a class that may contain some implemented methods, but cannot be directly instantiated.

An interface can be implemented by any class, regardless of its hierarchy, whereas an abstract class can only be subclassed. Moreover, a class can implement multiple interfaces, but it can inherit from only one abstract class.

In terms of access modifiers, all methods in an interface are public by default, whereas an abstract class can have methods with any access modifier.

In Java, interfaces are generally used to define an API, whereas an abstract class is used to provide a partial implementation of a class.

Implementing Static and Dynamic Polymorphism in C++

In C++, static polymorphism is achieved through function overloading and operator overloading. Function overloading is when multiple functions have the same name but different parameter lists. The compiler determines which function to call based on the arguments passed. Operator overloading involves defining operators to work with user-defined data types.

Dynamic polymorphism is achieved through inheritance and virtual functions. Inheritance allows a subclass to inherit the traits and properties of its superclass. Virtual functions allow the implementation of a function to be determined at runtime based on the type of object being referred to. This is implemented by using the virtual keyword in the function declaration in the base class and overriding the function in the derived class.

Differences Between Pointers and Reference Variables in C++

In C++, a pointer is a variable that stores the memory address of another variable. On the other hand, a reference variable is an alias for another variable. Here are some differences between pointers and reference variables:

1. Pointers can be NULL, while reference variables cannot be NULL. 2. Pointers can be reassigned to point to different variables, while reference variables cannot be reassigned. 3. Pointer arithmetic can be performed on pointers, while it cannot be performed on reference variables. 4. Pointers can be of different types (i.e., void pointers), while reference variables must be of the same type as the variable they refer to. 5. Pointers are used to pass arguments between functions, while reference variables can also be used for this purpose.

Overall, pointers and reference variables are both powerful features of C++, and understanding their differences is important for writing efficient and effective code.

Can a constructor be private in C++?

Yes, it is possible to declare a constructor as private in C++. This is often done as a part of the Singleton design pattern to prevent the creation of multiple instances of a class. However, it should be noted that making the constructor private restricts the creation of instances outside of the class and its friend classes, which can be useful in certain scenarios.

Understanding Red-Black Trees in Data Structures

A Red-Black Tree is a type of self-balancing binary search tree that ensures efficient operations by maintaining a balance between the height and depth of each node. In a Red-Black Tree, every node is assigned either a red or a black color, based on certain criteria. The properties of a Red-Black Tree dictate that no two adjacent nodes can have the same color, and the path from the root node to any leaf node must contain an equal number of black nodes. By following these rules, Red-Black Trees achieve a balance between height and depth, which results in faster and more efficient search, insertion, and deletion operations. Red-Black Trees are commonly used in computer science applications that rely on efficient data structures, such as database indexing and memory management.

BFS vs DFS in Graph Traversal

Graph traversal is a fundamental topic in computer science, where BFS (Breadth First Search) and DFS (Depth First Search) are two popular techniques used for traversing graphs.

BFS: In BFS, we first visit all the nodes at a given depth, layer by layer, from the starting vertex before moving to the next layer. It uses a queue to keep track of which nodes to visit next. This approach guarantees that we always reach the shortest distance from the starting node to other nodes in the graph.

DFS: In DFS, we take a path as far as possible to the deepest level of the graph before backtracking and exploring other paths. It uses a stack to keep track of which nodes to visit next. Unlike BFS, this approach does not guarantee that we always reach the shortest path. However, DFS is useful for finding all possible paths in a graph.

In summary, BFS is a good choice when we are interested to find the shortest path from the starting node to other nodes, while DFS is a better option when we want to find all possible paths in a graph.

Binet's Formula and its relation to the Fibonacci sequence

Binet's Formula is a mathematical expression that calculates the value of any term in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.

The formula is as follows:

Fn = ((Phi ^ n) - (psi ^ n)) / sqrt(5)


- Fn is the nth term in the Fibonacci sequence - Phi is the golden ratio, approximately equal to 1.618033988749895 - Psi is the negative inverse of the golden ratio, approximately equal to -0.618033988749895 - n is the position of the term in the Fibonacci sequence, starting with 0

Binet's formula is useful because it allows us to easily calculate the value of any term in the Fibonacci sequence without having to go through all the previous terms. Additionally, Binet's formula can be used to find an approximate value of the nth term in the sequence for very large values of n.

Zigzag Matrix Printing

Given a 2D matrix with N rows and M columns, the task is to print the elements of the matrix in a zigzag manner as shown in the image below:

  1 2 3 
  4 5 6 
  7 8 9
  1 2 3 6 5 4 7 8 9

Check if a number can be written as the sum of K prime numbers

def is_prime(num):
    This function checks if the number is prime or not.
    if num <= 1:
        return False
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

def is_sum_of_k_primes(num, k):
    This function checks if the given number can be expressed as the sum of k prime numbers.
    primes = []  # list to store k prime numbers

    # find the first k prime numbers
    i = 2
    while len(primes) < k:
        if is_prime(i):
        i += 1

    # check if the sum of k prime numbers is equal to the given number
    if sum(primes) == num:
        return True

    # check if the given number can be expressed as the sum of k prime numbers
    for i in range(k, len(primes)):
        sum_of_primes = sum(primes[i-k:i])
        if sum_of_primes == num:
            return True

    return False

The above code includes two functions:




. The


function checks if a number is prime or not. The


function checks if the given number can be expressed as the sum of k prime numbers.



function first finds the first k prime numbers and stores them in a list called primes. Then, it checks if the sum of k prime numbers is equal to the given number. If it is, it returns True. If not, it checks if the given number can be expressed as the sum of k prime numbers by iterating over the rest of the prime numbers. If it finds such a sum, it returns True. If it can't find any such sum, it returns False.

Finding Maximum Profit by Purchasing and Selling Stocks

Given an array of stock prices, this program finds the maximum profit that can be obtained by buying and selling the stocks. It follows the constraint that a stock cannot be bought unless the previously bought stock has been sold.

  function findMaxProfit(stockPrices) {
    let minPrice = stockPrices[0]; // Initialize minimum price to the first element of the array
    let maxProfit = 0; // Initialize maximum profit to 0

    for (let i = 0; i < stockPrices.length; i++) {
      // Find the minimum price so far
      minPrice = Math.min(minPrice, stockPrices[i]);

      // Find the maximum profit that can be made with the current stock price
      let currentProfit = stockPrices[i] - minPrice;

      // Update the maximum profit, if necessary
      maxProfit = Math.max(maxProfit, currentProfit);
    return maxProfit;

In the above implemented function, we iterate through the array of stock prices and find the minimum price seen so far. Then, we find the maximum profit that can be obtained with the current stock price, and update the maximum profit if necessary. Finally, the function returns the maximum profit.

Removing Anagrams from an Array of Strings


function removeAnagrams(arr) {
  let uniqueWords = []; // to store unique words
  const sortedWords = => [...word].sort().join('')); // sort each word and store in new array

  // iterate over the sortedWords array
  for (let i = 0; i < sortedWords.length; i++) {
    let isAnagram = false;
    for (let j = i - 1; j >= 0; j--) {
      if (sortedWords[j] === sortedWords[i]) {
        isAnagram = true; // if sorted word is same as any previous word, it's an anagram
    if (!isAnagram) {
      uniqueWords.push(arr[i]); // if not anagram, add the word to uniqueWords array
  return uniqueWords.sort(); // return sorted uniqueWords array


The function `removeAnagrams` takes an array of strings as input and returns an array of unique words as output, after removing the anagrams of previous words. It implements this by sorting each word in the input array, and then comparing it with all the previous words to check if it is an anagram. If it is not an anagram, it is added to a new array of unique words. Finally, this new array is sorted alphabetically and returned.

For example, if the input array is `['listen', 'silent', 'trip', 'pret', 'hello']`, the function would return `['hello', 'trip']` as the output, as 'listen' and 'silent' are anagrams of each other, and 'pret' is an anagram of 'trip'.

Working of AJAX

AJAX is a technique used in web development to create asynchronous web applications. It allows communication between the client and server without reloading the entire webpage. Here's how it works:

  1. When an event triggers a request for new data, the browser sends an asynchronous request to the server using XMLHttpRequest.
  2. The server receives the request and processes it.
  3. The server sends the response back to the client in XML, JSON, or HTML format.
  4. The browser receives the response and processes it via JavaScript to update the page content dynamically.

AJAX is commonly used for tasks such as dynamically updating parts of a webpage, submitting forms without refreshing the page, and loading new data on demand.

// Example AJAX request using jQuery

  url: "example.php",
  method: "POST",
  data: { name: "John", location: "Boston" }
}).done(function( response ) {
  // Process the response here

Explanation of Processes and Threads in the Context of an Operating System:

In an operating system, a process is an instance of a program that is currently being executed. Each process has its own memory space, data, and code. Processes are managed by the operating system and are assigned specific resources such as CPU time, memory, and I/O devices.

Threads, on the other hand, are smaller units of a program that can run concurrently within a process. Each thread within a process shares the same memory space and system resources. This allows for multiple tasks to be performed concurrently within a single program.

Processes and threads are related in that a process can contain multiple threads, and these threads can work together to complete a larger task. Additionally, the creation and management of both processes and threads are handled by the operating system.

When a process creates a new thread, the operating system allocates a new stack for the thread to use and manages the synchronization between threads to prevent conflicts.

Overall, processes and threads are essential components of an operating system, allowing programs to perform complex tasks while efficiently utilizing system resources.

Joining Tables in SQL

In SQL, a JOIN operation combines records from two or more tables in a database based on a related column between them. JOIN is used to retrieve data from multiple tables simultaneously and specify how the data should be combined. There are several types of JOIN operations, including INNER JOIN, OUTER JOIN, LEFT JOIN, RIGHT JOIN, and CROSS JOIN. Each type specifies a different way of combining the tables and their data. Proper use of JOIN can greatly simplify database queries and reduce redundancy in the data.


Here are some tips to help you prepare for your interview with Goldman Sachs:

//Tip 1: Research the company and the industry
Gather information about Goldman Sachs and the industry they operate in. This will help you understand their business and the type of work they do.

//Tip 2: Prepare for common interview questions
Practice responding to common interview questions, such as discussing your experience and skills.

//Tip 3: Highlight your skills and achievements
Communicate your skills and achievements confidently, specifically those that align with the position you are applying for.

//Tip 4: Dress professionally
Dress professionally for the interview to make a good impression.

//Tip 5: Be on time
Make sure to arrive to the interview on time or a few minutes early.

//Tip 6: Follow up after the interview
Send a thank you note or email to the interviewer to express your appreciation for the opportunity.

Dynamic Programming Approach to the Stairs Problem

Below is the solution to the Stairs Problem using dynamic programming:

def num_ways_to_climb_stairs(num_stairs):
    if num_stairs <= 2:
        return num_stairs
    # Initializing the list with 0s
    steps = [0] * (num_stairs + 1)
    steps[1], steps[2] = 1, 2
    for i in range(3, num_stairs + 1):
        steps[i] = steps[i-1] + steps[i-2]
    return steps[num_stairs]

We can call the function by passing the number of stairs:

num_ways_to_climb_stairs(4) # Returns 5

This function computes the number of possible ways to climb the stairs using only 1 or 2 steps at a time, given the total number of stairs. The time complexity of this approach is O(n) and the space complexity is O(n), where n is the number of stairs.

Rain Water Trapped: Solve the Problem using Stacks and Queues

This program's purpose is to solve the Rain Water Trapped Problem using Stacks and Queues.

Maximum Sum Contiguous Subarray

Arrays Problem Solution

 * This function returns the maximum sum of a contiguous subarray within the provided array.
 * @param {number[]} nums - An array of integers.
 * @return {number} - The maximum sum of a contiguous subarray within the provided array.
function maxSubArray(nums) {
  let maxSum = nums[0];
  let currentSum = 0;

  for (let i = 0; i < nums.length; i++) {
    currentSum += nums[i];
    if (currentSum > maxSum) {
      maxSum = currentSum;
    if (currentSum < 0) {
      currentSum = 0;

  return maxSum;

Finding the Largest Number in an Array

Here's how to solve the "largest number" problem using arrays:

function findLargestNum(arr) { <br>
   let largestNum = arr[0]; <br>
   for (let i = 1; i < arr.length; i++) { <br>
       if (arr[i] > largestNum) { <br>
           largestNum = arr[i]; <br>
       } <br>
   } <br>
   return largestNum; <br>

This function takes an array of numbers as input, and returns the largest number in the array. It starts by assuming that the first number in the array is the largest, and then iterates through the rest of the array, checking each number against the current largest number. If a larger number is found, it becomes the new largest number. Once the entire array has been checked, the largest number is returned.

This function can be useful in a variety of contexts, such as finding the highest score in a list of scores, or determining the largest number in a set of statistical data.

Goldman Sachs Interview Questions

Here are some interview questions that you may encounter when applying to Goldman Sachs:

// Code tag for the following code
// Get user data
function getUserData(userId) {
  return fetch(`${userId}`)
    .then(response => response.json())
    .catch(error => {
      console.error(`Unable to fetch user data: ${error}`);

// Calculate average age of users
async function averageUserAge(userIds) {
  let totalAge = 0;
  let userCount = 0;

  // Loop through all user IDs and calculate total age
  for (let i = 0; i < userIds.length; i++) {
    const userData = await getUserData(userIds[i]);
    totalAge += userData.age;

  // Calculate and return average age
  return totalAge / userCount;

This code retrieves user data from an API and calculates the average age of users based on their data. This is a common task in programming and can be used in many different applications.

Remember to showcase your problem-solving skills by explaining your approach and thought process when answering interview questions.

Frequently Asked Questions

1. Why choose Goldman Sachs?

Future Career Aspiration

In five years, what is your career objective or where do you see yourself?

Question: What are your strengths and weaknesses?

As a candidate, it is important to be aware of your strengths and weaknesses. Your strengths will help you stand out as a desirable candidate, while your weaknesses will help you identify areas for improvement and personal growth. When answering this question, focus on providing specific examples that illustrate your strengths and weaknesses. Additionally, be honest and self-aware in your response.

Sample response:

My greatest strength is my ability to communicate effectively with others. Throughout my academic and professional experiences, I have consistently demonstrated strong verbal and written communication skills. For example, in my previous role as a sales representative, I was responsible for maintaining relationships with clients and closing deals. I was able to successfully communicate the features and benefits of our products to customers, ultimately resulting in increased sales revenue for my team.

One area that I have identified as a weakness is my tendency to be overly critical of my work. While attention to detail is important, I sometimes find myself spending too much time reviewing and editing my work. However, I have been working on developing a more efficient editing process that allows me to ensure quality while also meeting deadlines.

Are Goldman Sachs Interviews Difficult?

As a language model AI, I don't have the personal experience of participating in Goldman Sachs interviews. However, according to various sources, Goldman Sachs interviews are known to be challenging and rigorous, focusing on problem-solving and critical thinking skills, as well as industry knowledge and experience. The company typically conducts multiple rounds of interviews, including phone screenings, technical assessments, and in-person interviews, with a mix of behavioral and technical questions. Overall, preparing well for a Goldman Sachs interview is highly recommended to increase your chance of success.

Goldman Sachs Interns Salary

What is the pay scale for interns at Goldman Sachs?

Number of Rounds in Goldman Sachs Internship

Could you provide more details about the specific internship program at Goldman Sachs that you are referring to? Without more context, it is difficult to provide an accurate answer to your question.

Technical Interview Guides

Here are guides for technical interviews, categorized from introductory to advanced levels.

View All

Best MCQ

As part of their written examination, numerous tech companies necessitate candidates to complete multiple-choice questions (MCQs) assessing their technical aptitude.

View MCQ's
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.