Goldman Sachs
300+ PTC Interview Questions and Answers
Q101. How many ways can a king go from one end of the chessboard to the diagonally opposite square(The king can move only towards the corner and not diagonally)
The king can move only towards the corner and not diagonally. How many ways can a king go from one end of the chessboard to the diagonally opposite square?
The king can only move towards the corner, so there are limited options for each move
The total number of moves required to reach the opposite corner is 14
Using combinatorics, the total number of ways the king can reach the opposite corner is 3432
Q102. 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
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.
Q103. How to create a uniform distribution from 1 to 200 using an ubiased coin?
To create a uniform distribution from 1 to 200 using an unbiased coin, we can use the rejection sampling method.
Divide the range into equal parts based on the number of outcomes of the coin toss.
Toss the coin and select the corresponding part of the range.
If the selected number is outside the desired range, reject it and repeat the process.
Repeat until a number within the desired range is obtained.
Example: If the coin has 2 outcomes, divide the range into 2 parts of 100 each....read more
Q104. Two and Four Wheeler Roads Problem Statement
There is a country with N
cities and M
bidirectional roads of 3 types:
Type 1: Two Wheeler Road - Only vehicles with two wheels can use this road. Type 2: Four Wheel...read more
Determine the maximum number of roads that can be removed while ensuring a path exists for every pair of cities for two-wheeler and four-wheeler vehicles.
Identify the type of road (two-wheeler, four-wheeler, or both) and its impact on the connectivity between cities.
Consider the constraints provided in the input to optimize the solution.
Remove roads strategically to maximize the number of roads removed while maintaining connectivity.
If not all cities can be reached, return -1...read more
Q105. Count Pairs with Given Sum
Given an integer array/list arr
and an integer 'Sum', determine the total number of unique pairs in the array whose elements sum up to the given 'Sum'.
Input:
The first line contains ...read more
Count the total number of unique pairs in an array whose elements sum up to a given value.
Use a hashmap to store the frequency of each element in the array.
Iterate through the array and for each element, check if (Sum - element) exists in the hashmap.
Increment the count of pairs if the complement exists in the hashmap.
Q106. LCA in a Binary Search Tree
You are given a binary search tree (BST) containing N nodes. Additionally, you have references to two nodes, P and Q, within this BST.
Your task is to determine the Lowest Common Anc...read more
Find the Lowest Common Ancestor (LCA) of two nodes in a Binary Search Tree (BST).
Traverse the BST from the root node to find the LCA of nodes P and Q.
Compare the values of nodes P and Q with the current node's value to determine the LCA.
If both nodes are on the same side of the current node, move to that side; otherwise, the current node is the LCA.
Handle cases where one node is the ancestor of the other or when one of the nodes is the current node.
Q107. Minimum Number of Swaps to Sort an Array
Find the minimum number of swaps required to sort a given array of distinct elements in ascending order.
Input:
T (number of test cases)
For each test case:
N (size of the...read more
The minimum number of swaps required to sort a given array of distinct elements in ascending order.
Use a graph-based approach to find cycles in the array
Count the number of swaps needed to fix each cycle
Sum up the swaps needed for all cycles to get the total minimum swaps
Q108. An IT sector company wants to increase the number of BPOs in India. Devise a metric that will help it rank cities according to their favourability to host this BPO
A metric to rank Indian cities for BPOs
Consider factors like availability of skilled workforce, infrastructure, cost of living, and government policies
Weight each factor based on its importance to the company
Collect data on each factor for different cities and assign scores
Rank cities based on their total score
Examples of factors: number of universities, quality of transportation, cost of office space, tax incentives
Regularly update the metric to reflect changes in the busine...read more
Q109. Given two arrays of size n each, describe an algorithm to find the largest common subarray of the two arrays
Algorithm to find largest common subarray of two arrays of size n
Create a 2D array to store the lengths of common subarrays
Traverse both arrays and fill the 2D array with lengths of common subarrays
Find the maximum length and its corresponding ending index in the 2D array
Use the ending index to retrieve the largest common subarray from either of the arrays
Q110. Consecutive Sum Representation of a Number
Find the number of ways the given number 'N' can be expressed as the sum of two or more consecutive natural numbers.
Example:
Input:
N = 9
Output:
2
Explanation:
The n...read more
Find the number of ways a given number can be expressed as the sum of two or more consecutive natural numbers.
Use a sliding window approach to iterate through all possible consecutive sums.
Keep track of the sum of the current window and adjust the window size accordingly.
Count the number of valid consecutive sum representations of the given number.
Example: For N = 9, valid representations are 2 + 3 + 4 and 4 + 5, so the output is 2.
Q111. Variants of using random number generators/Monte Carlo Simulations to generate value of Pi and other quantities
Random number generators and Monte Carlo simulations can be used to estimate the value of Pi and other quantities.
Monte Carlo simulations involve generating random numbers to estimate a value or solve a problem
To estimate Pi, random points are generated within a square and the ratio of points inside a circle to total points is used
Other quantities can be estimated using similar principles, such as estimating the area under a curve or the value of an integral
Q112. Problem Statement: Minimize the Maximum
You are given an array of integers and an integer K
. For each array element, you can adjust it by increasing or decreasing it by a value of K
. Your goal is to minimize th...read more
The goal is to minimize the difference between the maximum and minimum elements of an array by adjusting each element by a given value.
Iterate through each test case and calculate the minimum possible difference between the maximum and minimum elements after modifications.
For each element in the array, consider increasing or decreasing it by the given value K to minimize the overall difference.
Return the calculated minimum difference for each test case.
Q113. Row sorted and column sorted matrix problem of finding an element.
The problem involves finding an element in a matrix that is sorted both row-wise and column-wise.
Start from the top-right corner of the matrix
Compare the target element with the current element
If the target is smaller, move left; if larger, move down
Repeat until the target is found or the matrix boundaries are crossed
Q114. Minimum Number of Platforms Needed Problem Statement
You are given the arrival and departure times of N trains at a railway station for a particular day. Your task is to determine the minimum number of platform...read more
The minimum number of platforms needed at a railway station to avoid train waiting times is determined based on arrival and departure times.
Sort the arrival and departure times in ascending order.
Iterate through the times and keep track of the number of platforms needed at any given time.
Update the minimum number of platforms needed as you iterate through the times.
Return the minimum number of platforms needed.
Q115. Counting Rectangles in a Grid
Given a grid with 'M' rows and 'N' columns, determine the total number of unique rectangles that can be formed using the rows and columns of this grid.
Input:
The first line contai...read more
The total number of unique rectangles that can be formed in a grid with M rows and N columns.
The total number of unique rectangles can be calculated using the formula: (M * (M + 1) / 2) * (N * (N + 1) / 2)
Each rectangle can be formed by selecting two rows and two columns from the grid
For example, for a grid with 3 rows and 4 columns, the total number of unique rectangles is 60
Q116. Check if Two Trees are Mirror
Given two arbitrary binary trees, your task is to determine whether these two trees are mirrors of each other.
Explanation:
Two trees are considered mirror of each other if:
- The r...read more
Check if two binary trees are mirrors of each other based on specific criteria.
Compare the roots of both trees.
Check if the left subtree of the first tree is the mirror of the right subtree of the second tree.
Verify if the right subtree of the first tree is the mirror of the left subtree of the second tree.
Q117. Rat in a Maze Problem Statement
You need to determine all possible paths for a rat starting at position (0, 0) in a square maze to reach its destination at (N-1, N-1). The maze is represented as an N*N matrix w...read more
The task is to find all possible paths for a rat to navigate through a maze from start to finish.
Use backtracking algorithm to explore all possible paths in the maze.
Keep track of visited cells to avoid infinite loops.
Generate paths by moving in all possible directions (up, down, left, right) until reaching the destination.
Return the list of valid paths sorted in alphabetical order.
Q118. Middle of a Linked List
You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.
If there is an odd number of elements, return the middle ...read more
Return the middle element of a singly linked list, or the one farther from the head if there are even elements.
Traverse the linked list with two pointers, one moving twice as fast as the other
When the fast pointer reaches the end, the slow pointer will be at the middle
If there are even elements, return the one that is farther from the head node
Handle edge cases like linked list of size 1 or empty list
Q119. Rearrange Odd and Even Places
Given the head of a singly linked list, your task is to group all the nodes with odd indices together followed by the nodes with even indices, and then return the reordered list's ...read more
Rearrange nodes in a singly linked list by grouping odd and even indices together while maintaining relative order.
Create two separate linked lists for odd and even nodes
Traverse the original list and append nodes to respective odd/even lists
Connect the last node of odd list to the head of even list
Return the head of the rearranged list
Q120. Excel Sheet Column Number Problem Statement
You are provided with a string STR
representing a column title in an Excel Sheet. Your task is to determine the corresponding column number.
Example:
A typical exampl...read more
Given a string representing an Excel column title, determine the corresponding column number.
Iterate through the characters of the string from right to left
Calculate the corresponding value of each character based on its position and multiply by 26^position
Sum up all the values to get the final column number
Q121. 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
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.
Q122. Given a matrix containing several positive numbers find max path from bottom left to top right using only up and right steps
Find max path from bottom left to top right in a matrix using only up and right steps.
Start from bottom left corner and move towards top right corner.
At each step, choose the maximum value between the cell above and the cell to the right.
Keep track of the sum of values in the chosen path.
The final sum is the maximum possible sum of values in a path from bottom left to top right.
Q123. Different efficient ways to implement product and summation of n numbers. And limitations
Efficient ways to implement product and summation of n numbers with limitations.
For summation, use a loop or built-in functions like sum() or reduce().
For product, use a loop or built-in functions like prod() or reduce().
Limitations include overflow errors for large numbers and memory constraints for very large arrays.
Using parallel processing or vectorization can improve efficiency.
Consider using data structures like binary trees or prefix sums for faster calculations.
Q124. Beautiful City Problem Statement
Ninja plans to visit a city where each house is connected via roads in a binary tree structure. Each level of the tree can have at most 2^K houses. Houses at the same level cann...read more
The task is to connect houses at the same level in a binary tree structure using 'next' pointers.
Traverse the binary tree level by level using BFS
Connect nodes at the same level using 'next' pointers
Use a queue to keep track of nodes at each level
Q125. If You have an infinite array then how many ways to sort it and also tell the complexities
There are infinite ways to sort an infinite array with varying complexities.
Sorting algorithms like QuickSort, MergeSort, HeapSort, etc. can be used to sort the array.
The time complexity of sorting algorithms varies from O(n log n) to O(n^2).
The space complexity also varies depending on the algorithm used.
Sorting an infinite array is not practical, so it is usually done in chunks or using parallel processing.
The sorting order can be ascending or descending based on the requir...read more
Q126. Design Problem: You have a database of million records, that needs to be acessed for each operation. That database is updated very rarely. And there are multiple processes that queries the database and operates...
read moreImplement a caching mechanism to optimize database access for multiple processes.
Implement a caching layer to store frequently accessed records in memory
Use a cache eviction policy to remove least recently used records from the cache
Update the cache whenever the database is updated
Consider using a distributed cache if the processes are running on different machines
Q127. Maximize Stock Trading Profit
You are given an array prices
, representing stock prices over N consecutive days. Your goal is to compute the maximum profit achievable by performing multiple transactions (i.e., b...read more
To maximize stock trading profit, find maximum profit achievable by buying and selling shares multiple times.
Iterate through the array of stock prices and find all increasing sequences of prices.
Calculate profit by buying at the start of each increasing sequence and selling at the end.
Sum up all profits to get the maximum profit achievable.
Q128. Minimum Depth of a Binary Tree Problem Statement
Given a Binary Tree of integers, determine the minimum depth of the Binary Tree. The minimum depth is defined as the number of nodes present along the shortest p...read more
The minimum depth of a Binary Tree is the number of nodes along the shortest path from the root node to the nearest leaf node.
Traverse the Binary Tree using BFS (Breadth First Search) to find the minimum depth
Keep track of the level of each node while traversing
Stop the traversal as soon as a leaf node is encountered and return the level as the minimum depth
Q129. Arithmetic Progression Queries Problem Statement
Given an integer array ARR
of size N
, perform the following operations:
- update(l, r, val):
Add (val + i)
to arr[l + i]
for all 0 ≤ i ≤ r - l
.
- rangeSum(l, r):...read more
The problem involves updating and calculating the sum of elements in an array based on given operations.
Implement update(l, r, val) to add (val + i) to arr[l + i] for all i in range [0, r - l].
Implement rangeSum(l, r) to return the sum of elements in the array from index l to r.
Handle queries using 1-based indexing and output the sum of arr[l..r] for each rangeSum operation.
Q130. Matrix Rank Calculation
Given a matrix ARR
of dimensions N * M
, your task is to determine the rank of the matrix ARR
.
Explanation:
The rank of a matrix is defined as:
(a) The maximum number of linearly independ...read more
Calculate the rank of a matrix based on the number of linearly independent column or row vectors.
Determine the rank of the matrix by finding the maximum number of linearly independent column vectors or row vectors.
Check for linear independence by verifying if there is a nontrivial linear combination that equates to the zero vector.
Implement a function that takes the matrix dimensions and elements as input and returns the rank of the matrix.
Q131. Number of Triangles in an Undirected Graph
Determine how many triangles exist in an undirected graph. A triangle is defined as a cyclic path of length three that begins and ends at the same vertex.
Input:
The f...read more
Count the number of triangles in an undirected graph using adjacency matrix.
Iterate through all possible triplets of vertices to check for triangles.
For each triplet, check if there are edges between all three vertices.
Increment the count if a triangle is found.
Return the total count of triangles for each test case.
Q132. Maximum Value of an Equation Problem Statement
Given an array/list of integers points
containing coordinates (x, y) of N points in a 2D plane, sorted by x-values in non-decreasing order. You need to determine t...read more
Find the maximum value of an equation involving coordinates of points in a 2D plane.
Iterate through all pairs of points and calculate the equation value
Keep track of the maximum value encountered
Consider the constraint |xi - xj| ≤ K while calculating the equation value
Q133. Prime Numbers Identification
Given a positive integer N
, your task is to identify all prime numbers less than or equal to N
.
Explanation:
A prime number is a natural number greater than 1 that has no positive d...read more
Identify all prime numbers less than or equal to a given positive integer N.
Iterate from 2 to N and check if each number is prime
Use the Sieve of Eratosthenes algorithm for efficient prime number identification
Optimize by only checking up to the square root of N for divisors
Q134. Design problem: You have a socket connection on client side. And that socket connection receives million ticks per second for every stocks. Suppose you have 50 stocks. So the value of each stock is changing 10,...
read moreEfficiently design a GUI to display real-time stock data and statistics for 50 stocks receiving million ticks per second.
Use a high-performance GUI framework like Qt or JavaFX to handle real-time updates efficiently.
Implement a data structure to store and update stock values in real-time, such as a priority queue or a circular buffer.
Calculate Mean, Median, Highest, and Lowest values in real-time using efficient algorithms like quickselect or maintaining a sorted list.
Conside...read more
Q135. What do you know about options?
Options are financial contracts that give the buyer the right, but not the obligation, to buy or sell an underlying asset at a predetermined price.
Options can be used for hedging or speculation
There are two types of options: call options and put options
Call options give the buyer the right to buy the underlying asset at a predetermined price, while put options give the buyer the right to sell the underlying asset at a predetermined price
Options have expiration dates and strik...read more
Q136. Puzzle: You have two train carriages situated at a different point on a infinite train track. The carriage can move up and down , and given that they can only know whether the other train has started from this...
read moreQ137. Design a game (Automaton) for a betting scenario. Bet is either doubled or lost completely depending on whether you win or lose. Suppose you bet on team A constantly in a 2 team game, how much money you need in...
read moreQ138. Problem: Search In Rotated Sorted Array
Given a sorted array that has been rotated clockwise by an unknown amount, you need to answer Q
queries. Each query is represented by an integer Q[i]
, and you must determ...read more
Search for integers in a rotated sorted array efficiently.
Use binary search to find the pivot point where the array is rotated.
Based on the pivot point, apply binary search on the appropriate half of the array.
Return the index of the integer if found, else return -1.
Example: For input N=5, A=[4, 5, 6, 7, 0, 1, 2], Q=3, Q[i]=[0, 3, 6], output should be 4, -1, 2.
Q139. What do you understand in KYC, KYC documents? In your previous organisation what did you learn? Can you tel something about what solution have you solve and what are the outcomes? Questions based on process imp...
read moreKYC refers to the process of verifying the identity of customers and assessing their potential risks.
KYC stands for Know Your Customer
KYC documents include identity proof, address proof, and other relevant documents
In my previous organization, I learned about the importance of verifying customer identities to prevent fraud and financial crimes
I have implemented process improvements to streamline the KYC process and reduce turnaround time
The outcomes of these solutions were im...read more
Q140. Rearrange Words in a Sentence
You are provided with a sentence 'TEXT'. Each word in the sentence is separated by a single space, and the sentence starts with a capital letter. Your task is to rearrange the word...read more
Rearrange words in a sentence based on increasing order of their length.
Split the sentence into words and calculate the length of each word.
Sort the words based on their lengths, keeping the original order for words with the same length.
Join the sorted words back into a sentence.
Q141. First Non-Repeating Character Problem Statement
You are given a string consisting of English alphabet characters. Your task is to identify and return the first character in the string that does not repeat. If e...read more
Given a string, find and return the first non-repeating character. If none exists, return the first character of the string.
Create a dictionary to store the count of each character in the string.
Iterate through the string and populate the dictionary.
Iterate through the string again and return the first character with count 1.
If no such character exists, return the first character of the string.
Q142. Find K-th Smallest Element in BST
Given a binary search tree (BST) and an integer K
, the task is to find the K-th smallest element in the BST.
Example:
Input:
BST: Order of elements in increasing order is { 2, ...read more
To find the K-th smallest element in a BST, perform an in-order traversal and return the K-th element encountered.
Perform in-order traversal of the BST to get elements in increasing order
Keep track of the count of elements visited and return the K-th element
Time complexity can be optimized by maintaining a count of nodes in each subtree
Q143. Excel Column Number Conversion
Given a column title as it appears in an Excel sheet, your task is to return its corresponding column number.
Example:
Input:
S = "AB"
Output:
28
Explanation:
The sequence is as f...read more
Convert Excel column title to corresponding column number.
Map each letter to its corresponding value (A=1, B=2, ..., Z=26)
Iterate through the input string from right to left, calculate the value of each letter based on its position and add it to the result
Multiply the result by 26 for each additional letter to the left
Q144. A person can climb 1 or 2 stairs. Find the number of ways to jump n stairs
Number of ways to jump n stairs if a person can climb 1 or 2 stairs.
Use dynamic programming to solve the problem.
The number of ways to jump n stairs is equal to the sum of ways to jump n-1 stairs and ways to jump n-2 stairs.
Base cases: if n=0, return 1 and if n=1, return 1.
Q145. Given a 2d matrix sorted row and column wise, search an element
Searching an element in a sorted 2D matrix
Start from the top-right corner or bottom-left corner
Compare the target element with the current element
Move left or down if the target is smaller or move right or up if the target is larger
Q146. Efficient algorithms on calculating Fibonacci’s Sequence
Efficient algorithms for calculating Fibonacci's sequence
Use dynamic programming to avoid redundant calculations
Implement matrix exponentiation to reduce time complexity to O(log n)
Use memoization to store previously calculated values
Iterative approach using constant space complexity
Binet's formula for direct calculation of nth Fibonacci number
Q147. Ninja's Apartment Problem Statement
Ninja plans to build an apartment in the shape of a rectangle. The goal is to determine the length and breadth of this rectangle such that the length is greater than the brea...read more
Given the area of a rectangle, find the length and breadth such that the length is greater than the breadth and the difference between them is minimized.
Iterate through possible combinations of length and breadth
Calculate the area for each combination and check if length is greater than breadth
Select the combination with minimal difference between length and breadth
Q148. You have a rod of length 7 and you have to give a part of rod of length of one everyday to a person. so what is the minimum number of cuts you will do , so that you can give him required number of lengths every...
read moreThe minimum number of cuts required is 6.
To give a part of rod of length one everyday, we need to divide the rod into 7 equal parts.
Each cut will create two new lengths, so we need 6 cuts to obtain 7 equal parts.
The cuts can be made at any point along the rod, as long as the resulting lengths are equal.
Q149. How would you code a linked list? Show the code
A linked list is a data structure where each element contains a reference to the next element.
Create a Node class with data and next pointer
Create a LinkedList class with head pointer
Implement methods like insert, delete, search, etc.
Q150. What is one key ratio you would look at for upstream companies ? (reserve replacement ratio for oil & gas)
The reserve replacement ratio is a key ratio to evaluate the ability of upstream companies to replace the reserves they produce.
The reserve replacement ratio compares the amount of reserves added to the amount of reserves produced in a given period.
A ratio above 100% indicates that the company is replacing more reserves than it is producing.
A ratio below 100% indicates that the company is producing more reserves than it is replacing.
The reserve replacement ratio is important ...read more
Q151. How would you design an elevator system for a building?
Designing an elevator system for a building involves considering factors like capacity, speed, safety, and efficiency.
Determine the number of floors and the expected traffic flow in the building
Calculate the required capacity and speed of the elevators
Consider safety features such as emergency stop buttons, fire-resistant materials, and backup power supply
Implement efficient algorithms for elevator scheduling to minimize waiting time
Incorporate user-friendly features like cle...read more
Q152. What platforms have you used for this process in the past?
I have used platforms such as Excel, Tableau, and Power BI for data analysis in the past.
Excel
Tableau
Power BI
Q153. Excel Column Number Problem Statement
Given a column title as it appears in an Excel sheet, return its corresponding column number.
Example:
Input:
"AB"
Output:
28
Explanation:
Column title "AB" corresponds to ...read more
Convert Excel column title to corresponding column number
Iterate through the characters in the column title from right to left
Calculate the corresponding value of each character using its position in the alphabet
Multiply the value by 26 raised to the power of its position from right
Sum up all the values to get the final column number
Q154. Puzzle: there are two candles and each candle take 30 minutes to burn. How will you measure 45 minutes? You dont have any instruments with you
Q155. What is the probability of a 8 bit string to have no more than 2 consecutive 1's. This might seem like a probability question :p. But it is actually dynamic programming.
Probability of an 8 bit string with no more than 2 consecutive 1's using dynamic programming.
Use dynamic programming to calculate the probability of a string with no more than 2 consecutive 1's
Create a 2D array to store the probabilities of each bit position and number of consecutive 1's
Use recurrence relation to calculate the probability for each bit position based on the previous bit position
Sum up the probabilities for all possible combinations of the last bit position and...read more
Q156. what is virtual memory? Will we need virtual memory even if we have infinite amount of RAM?
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
Q157. 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
Q158. Given an array, Find out maximum length of subarray where max of subarray <= 2*min of subarray
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)
Data modeling is the process of creating a visual representation of data structures and relationships within a database.
Data modeling involves identifying entities, attributes, and relationships in a database.
It helps in organizing data in a way that is easy to understand and use.
Examples of data modeling tools include ER diagrams and UML diagrams.
Q160. You are given ROE for 2 IT companies? how would you find out which is undervalued & overvalued?
Compare ROE of 2 IT companies to determine undervalued and overvalued.
Calculate the average ROE for the industry to use as a benchmark
Compare the ROE of the two companies to the industry average
Consider other factors such as growth potential, debt levels, and market share
Use valuation methods such as P/E ratio and discounted cash flow analysis
Undervalued company will have lower ROE than industry average and lower valuation metrics
Overvalued company will have higher ROE than i...read more
Q161. What is the difference between OOP and procedural programming?
OOP focuses on objects and their interactions, while procedural programming focuses on procedures and functions.
OOP organizes code into objects that encapsulate data and behavior.
Procedural programming uses functions to manipulate data.
OOP supports concepts like inheritance, polymorphism, and encapsulation.
Procedural programming is more straightforward and linear in nature.
OOP promotes code reusability and modularity.
Procedural programming is often used for small-scale projec...read more
The ER Model is a conceptual data model that describes the data and relationships in a system using entities and their attributes.
ER Model stands for Entity-Relationship Model
It is used to represent the logical structure of a database
Entities are objects or concepts in the real world that are represented in the database
Attributes are properties that describe the entities
Relationships define how entities are related to each other
Example: In a library database, 'Book' is an ent...read more
Q164. How to merge multiple sorted arrays into one sorted array
Merge multiple sorted arrays into one sorted array
Iterate through each array and merge them into a single array
Use a priority queue or heap data structure to efficiently merge the arrays
Implement a merge sort algorithm to combine the arrays into one sorted array
Q165. How will you mane a LRU Cache
An LRU cache can be made using a doubly linked list and a hash map.
Create a doubly linked list to store the cache items.
Create a hash map to store the key-value pairs.
When a new item is added, check if the cache is full. If it is, remove the least recently used item from the linked list and hash map.
When an item is accessed, move it to the front of the linked list.
When an item is removed, remove it from both the linked list and hash map.
Q166. you have been given a tree(not binary tree), and the last level of the tree is doubly linked list(i.e. first node of that level connected to last node and adjacent to it and similarly for all nodes of that leve...
read morePerform DFS on a tree with last level as a doubly linked list.
Start DFS from the root node and traverse each node recursively.
When reaching a node with a doubly linked list as the last level, traverse the linked list as well.
Use a stack to keep track of nodes to visit next.
Example: Tree with last level as doubly linked list - 1 -> 2 -> 3 <-> 4 <-> 5
Example: DFS traversal order - 1, 2, 3, 4, 5
Q167. Find integer solutions of x^y=y^x.
Find integer solutions of x^y=y^x.
If x=y, then x^y=y^x=1
If x
If x>y, then x^y>y^x
Only solution is (2,4) and (4,2)
Use logarithms to prove
Q168. difference between hedge funds and private equity
Hedge funds are actively managed investment funds that use various strategies to generate high returns, while private equity firms invest in private companies and aim to increase their value.
Hedge funds are open to a wider range of investors than private equity funds
Hedge funds use leverage to increase returns, while private equity firms use debt to finance acquisitions
Hedge funds have a shorter investment horizon than private equity firms
Private equity firms typically take a...read more
Q169. Write code for implementing Tower of Hanoi problem. What data structures you will use? How will you implement the Move function(that moves the disc)
Tower of Hanoi is a mathematical puzzle that involves moving a stack of disks from one peg to another peg.
Tower of Hanoi problem involves three pegs and a number of disks of different sizes.
The goal is to move all the disks from the source peg to the destination peg, using the auxiliary peg.
The Move function can be implemented recursively by following the steps:
1. Move n-1 disks from source to auxiliary peg.
2. Move the nth disk from source to destination peg.
3. Move the n-1 d...read more
Q170. What is chargeback and explain the chargeback cycle?
Chargeback is a transaction reversal made by a bank or credit card issuer, usually due to fraud or disputed charges.
Chargeback occurs when a customer disputes a charge and the bank or credit card issuer reverses the transaction.
The merchant is notified of the chargeback and can either accept it or dispute it.
If the chargeback is accepted, the merchant loses the sale and may be charged a fee.
If the chargeback is disputed, the bank or credit card issuer investigates and makes a...read more
Q171. Write an algorithm which will make the train carriages meet. The same algorithm should run on both the carriages
Algorithm to make train carriages meet
Use a two-pointer approach
Start with two pointers at opposite ends of the array
Move the pointers towards each other until they meet
Q172. Given a list of numbers give an algorithm that to find 2 numbers that add up to 600. He asked me to improve the complexity with every attempt I made finally got it down to complexity of O(N)
Algorithm to find 2 numbers that add up to 600 from a list of numbers with O(N) complexity.
Use a hash table to store the difference between each number and 600.
Iterate through the list and check if the difference is in the hash table.
If the difference is in the hash table, return the current number and the difference.
A website similar to Instagram for travelers, allowing users to share photos and stories from their trips.
Include features like geotagging to show where photos were taken
Allow users to create travel itineraries and share tips with others
Implement a rating system for destinations and accommodations
Enable users to connect with fellow travelers and plan trips together
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.
Q175. When a message arrives at network interface card what exactly happens after that, and what is Operating system’s role in it?
When a message arrives at network interface card, the operating system processes it by handling the data transfer and routing.
The network interface card (NIC) receives the message from the network
The operating system's network stack processes the message, including error checking and routing
The operating system then delivers the message to the appropriate application or service
Examples: Windows uses TCP/IP stack for network communication, Linux uses kernel networking stack
Q176. N door puzzle. ith user changes state of doors which are multiples of i. Calculate number of doors opened in the end
The number of doors opened in the end can be calculated by finding the number of perfect squares less than or equal to N.
The number of doors opened will be the square root of N, rounded down to the nearest whole number.
For example, if N is 100, the number of doors opened will be 10 (square root of 100).
Q177. Fiscal Deficit crowds out private investment – True or False. Why?
True. Fiscal deficit leads to higher interest rates, reducing private investment.
Fiscal deficit leads to higher government borrowing, increasing demand for credit
Higher demand for credit leads to higher interest rates
Higher interest rates make borrowing expensive for private investors
Expensive borrowing reduces private investment
Examples: India's fiscal deficit led to high interest rates, reducing private investment in 2013-14
Q178. What is the effect in case fiscal deficit increases on exchange rate?
Increase in fiscal deficit leads to depreciation of exchange rate.
Fiscal deficit means government spending exceeds revenue, leading to increased borrowing.
This increases the supply of domestic currency, leading to depreciation.
Investors may demand higher interest rates to compensate for increased risk, further depreciating the exchange rate.
Examples include India's rupee depreciation due to high fiscal deficit in 2013 and Argentina's peso depreciation in 2018.
Q179. 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
Q180. How can you refine your Graph traversing solution?
Refine graph traversing solution by optimizing algorithms and data structures.
Use efficient algorithms like Dijkstra's or A* for shortest path traversal.
Implement data structures like priority queues or heaps for faster traversal.
Consider using parallel processing or distributed computing for large graphs.
Optimize memory usage by using compressed data structures like succinct graphs.
Use caching to avoid redundant computations and improve performance.
SDLC stands for Software Development Life Cycle, which is a process used by software development teams to design, develop, and test high-quality software.
SDLC is a structured process that consists of several phases such as planning, analysis, design, implementation, testing, and maintenance.
Each phase of the SDLC has its own set of activities and deliverables that contribute to the overall success of the software project.
Examples of SDLC models include Waterfall, Agile, Scrum...read more
Q182. Which one is greater, (Pie power e ) or (e power pie) ?
e^π is greater than π^e.
e^π ≈ 23.14
π^e ≈ 22.46
e^π > π^e
Q183. Design a newspaper subscription system
Design a newspaper subscription system
Create a user registration system
Allow users to select subscription plan and payment method
Provide options for delivery frequency and start/end dates
Send reminders for subscription renewal
Allow users to modify or cancel subscription
Track subscription history and payment records
Q184. Given an excel sheet with column names mapped to column numbers as follows :A-1 , B-2…..Z-26,AA-27…….AZ-52 and so on.Now write a function to return the column name for a given column number
Function to return column name for a given column number in Excel sheet.
Divide the given column number by 26 and get the quotient and remainder.
Convert the remainder to the corresponding column name letter.
Repeat the above steps with the quotient until quotient is zero.
Join the column name letters in reverse order to get the final column name.
Q185. Different types of collection in C# and difference between hashmap and hashtable and their internal implementation
Different types of collections in C# include List, Dictionary, HashSet, Stack, Queue. Hashtable and HashMap are similar but HashMap is thread-safe.
List: dynamic array, allows duplicates
Dictionary: key-value pairs, fast lookup
HashSet: unique elements, no duplicates
Hashtable: non-generic, thread-safe
HashMap: generic, not thread-safe
Q186. When would Java be used over C/C++?
Java is used over C/C++ when platform independence, ease of use, and security are important.
Java is platform independent, meaning it can run on any operating system or hardware that has a Java Virtual Machine (JVM). C/C++ code needs to be compiled separately for each platform.
Java has automatic memory management, reducing the risk of memory leaks and making it easier to write and maintain code. C/C++ requires manual memory management.
Java has built-in security features, such ...read more
Q187. Explain what is Binary Search Tree
Binary Search Tree is a data structure where each node has at most two children, with left child less than parent and right child greater.
Nodes have at most two children - left and right
Left child is less than parent, right child is greater
Allows for efficient searching, insertion, and deletion of elements
Q188. What is the determinant of an n*n matrix with diagonal elements all 'a' and off-diagonal elements all 1
The determinant of the given matrix is (a^(n-1))*(a-n)
The determinant of an n*n matrix with diagonal elements all 'a' and off-diagonal elements all 1 is calculated as (a^(n-1))*(a-n)
For example, for a 3*3 matrix with diagonal elements 'a' and off-diagonal elements 1, the determinant would be (a^2)*(a-3)
Q189. What is lazy loading? Advantages and disadvantages of the same
Lazy loading is a design pattern where resources are loaded only when needed.
Advantages: faster initial loading time, reduced bandwidth usage, improved user experience
Disadvantages: potential for slower loading of content when accessed, increased complexity in implementation
Example: Lazy loading images on a webpage to improve loading speed
Q190. Can can change in working capital be negative?
Yes, change in working capital can be negative.
A negative change in working capital means that current liabilities have increased more than current assets.
This can happen when a company pays off short-term debt or reduces its inventory levels.
Negative working capital can also indicate that a company is experiencing financial difficulties.
However, it is important to analyze the reasons behind the negative change in working capital before drawing conclusions.
Negative working ca...read more
Q191. You have the co-ordinates of two rectangles. Find in minimum number of comparisons, if they are overlapping or not
To determine if two rectangles are overlapping, compare the coordinates of their corners.
Compare the x-coordinates of the rightmost corner of the first rectangle and the leftmost corner of the second rectangle.
Compare the x-coordinates of the leftmost corner of the first rectangle and the rightmost corner of the second rectangle.
Compare the y-coordinates of the topmost corner of the first rectangle and the bottommost corner of the second rectangle.
Compare the y-coordinates of...read more
Q192. What is Asset Management
Asset management is the process of managing and optimizing a company's assets to maximize their value and minimize risk.
Asset management involves identifying, tracking, and evaluating assets
It includes developing strategies to optimize asset performance and minimize risk
Examples of assets that can be managed include financial investments, real estate, and equipment
Asset management can be done in-house or outsourced to a third-party firm
Q193. what is custodian banking
Custodian banking involves holding and safeguarding financial assets on behalf of clients.
Custodian banks provide services such as asset safekeeping, settlement of trades, and corporate actions processing.
They also offer reporting and analytics to clients on their holdings and transactions.
Examples of custodian banks include State Street, BNY Mellon, and J.P. Morgan.
Custodian banking is important for institutional investors such as pension funds, mutual funds, and hedge funds...read more
Q194. Does outlook .pst or .ost files get corrupt, if does how do you plan to recover same.
Yes, Outlook .pst or .ost files can get corrupt. Recovery can be done using scanpst.exe or third-party tools.
Corruption can occur due to various reasons such as sudden shutdown, virus attack, or oversized file.
Scanpst.exe is a built-in tool in Outlook that can be used to repair minor corruption issues.
For major corruption issues, third-party tools like Stellar Repair for Outlook can be used.
It is important to regularly backup .pst or .ost files to avoid data loss.
Q195. What is trade life cycle
Trade life cycle refers to the stages involved in a trade from initiation to settlement.
Trade initiation - Trade is proposed and agreed upon by parties involved
Trade execution - Trade is executed on the exchange or over-the-counter market
Trade confirmation - Parties confirm the details of the trade
Trade settlement - Payment and transfer of securities occur
Trade reconciliation - Ensuring all details match between parties
Q196. Which one is more efficient a Join operation or a nested query
Q197. 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
Q198. How ajax works? Difference between angular js and jquery
Q199. The classic puzzle to find where is the 1 rupee when 3 friends visit a restaurant and pay 10 Rs each
The 1 rupee is with the restaurant, as the friends paid a total of 30 Rs but the bill was only 25 Rs.
Each friend paid 10 Rs, totaling 30 Rs.
The bill was only 25 Rs, so the remaining 5 Rs is with the restaurant.
Therefore, the 1 rupee is with the restaurant.
Q200. Given a file with business Date and contents. Extract the date(Validate it) and count all the other records in the file
Extract and validate business date, count other records in file
Use regular expressions to extract and validate the business date
Count all other records in the file excluding the business date record
Handle different date formats and edge cases
Consider using a programming language like Python or Java for efficient parsing
More about working at Goldman Sachs
Top HR Questions asked in PTC
Interview Process at PTC
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month