Goldman Sachs
20+ BT Business Interview Questions and Answers
Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m, n) from (0, 0). Each cell of the matrix represents a cost to...read more
You have been given a linked list of integers. Your task is to write a function that deletes a node from a given position, 'POS'.
Note :
Assume that the Indexing for the linked lis...read more
Given two strings str1 and str2 and below operations that can performed on str1. Find minimum number of edits (operations) required to convert ‘str1’ into ‘str2’.
Insert
Remove
Replace
All of the abov...read more
You are Harshad Mehta’s friend. He told you the price of a particular stock for the next ‘N’ days. You can either buy or sell a stock. Also, you can only complete at most 2-transactions. Find ...read more
Given an array A[] consisting of N integers, the task is to find the total number of subsequence which contain only one distinct number repeated throughout the subsequence.
Examples:
Input: A[...read more
Given a decimal number as N, the task is to convert N into an equivalent irreducible fraction.
An irreducible fraction is a fraction in which numerator and denominator a...read more
Given an undirected and disconnected graph G(V, E), containing 'V' vertices and 'E' edges, the information about edges is given using 'GRAPH' matrix, where i-th edge is between GRAPH[i][0] and GRAP...read more
You are given a 'M' x 'N' matrix of characters, 'CHARACTER_MATRIX' and a string 'WORD'. Your task is to find and print all occurrences of the string in the given character matrix. You are a...read more
Given an integer N as input, the task is to print the Magical Pattern as given below:
N . . 3 2 1 2 3 . . N
. . . . . . . . . . .
3 3 3 3 2 1 2 3 3 3 3
2 2 2 2 2 1 2 2 2 2 2
1 1 1 1 1 1 1 1 1 1 1
2 2 ...read more
You are given a string of length N representing the morse code(s). You have to convert this code into the corresponding alphanumeric code containing small case english alphabet[a-z] and di...read more
You are given a directed graph consisting of 'V' vertices and 'E' edges. You need to find whether a vertex i is reachable from all other vertices j for all pairs of vertices ...read more
Write an efficient program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.
Given a node, how long will it take to burn a whole binary tree?
There is a room with a door (closed) and three light bulbs. Outside the room, there are three switches, connected to the bulbs. You may manipulate the switches as you wish, but once you open the door you ...read more
Q15. randN function : which generates random number in [1,2,3..N] with equal probability. Given rand5, write a code for rand7 using rand5
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
What is the difference between SQL and NoSQL databases?
How does the variable declaration and the corresponding data type allotment done in Javascript?
Q17. Print all nodes at a distance k from a given node in binary tree?
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
Q18. Puzzle: Using all(8,8,3,3) and only operators(*,/,-,+), make 24
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
Q19. Write down function to select pivot element randomly in Quick Sort
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
Q20. How do you implement LRU cache?
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
Q21. What is inheritance in java?
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.
Q22. Difference between OOP and POP
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
More about working at Goldman Sachs
Interview Process at BT Business
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month