
Gainsight


20+ Gainsight Interview Questions and Answers
Q1. A matrix consists of integers. A bomb has to be dropped at a cell in the matrix and its impact will get cascaded to the all the adjacent (top, bottom, right, left) cells if the adjacent cell has value 1 greater...
read moreFind minimum bombs to clear matrix by cascading impact to adjacent cells with value 1 greater than the bombed cell.
Create a 2D matrix of integers
Iterate through each cell and drop a bomb, then check its adjacent cells
If an adjacent cell has value 1 greater than the bombed cell, drop a bomb on that cell as well
Repeat until no more cells can be bombed
Count the number of bombs dropped to clear the matrix
Q2. Print the nodes which are at the boundaries of a binary tree. (Leaf Nodes + Top view)
Print the nodes at the boundaries of a binary tree (leaf nodes + top view).
Traverse the tree in pre-order and keep track of the level of each node
Add the leftmost and rightmost nodes of each level to the result
For top view, traverse the tree in level-order and add the first node of each level to the result
Q3. Connecting Ropes with Minimum Cost
You are given 'N' ropes, each of varying lengths. The task is to connect all ropes into one single rope. The cost of connecting two ropes is the sum of their lengths. Your obj...read more
The problem is to connect N ropes of different lengths into one rope with minimum cost.
Sort the array of rope lengths in ascending order.
Initialize a variable to keep track of the total cost.
While there are more than one rope remaining, take the two shortest ropes and connect them.
Add the cost of connecting the two ropes to the total cost.
Replace the two shortest ropes with the connected rope.
Repeat the above steps until only one rope remains.
Return the total cost as the mini...read more
Q4. Ninja and Substrings Problem Statement
Ninja has to determine all the distinct substrings of size two that can be formed from a given string 'STR' comprising only lowercase alphabetic characters. These substrin...read more
The task is to find all the different possible substrings of size two that appear in a given string as contiguous substrings.
Iterate through the string and extract substrings of size two
Store the substrings in an array
Return the array of substrings
Q5. Bipartite Graph Problem Statement
Determine if a given graph is bipartite. A graph is bipartite if its vertices can be divided into two independent sets, 'U' and 'V', such that every edge ('u', 'v') connects a ...read more
The function checks whether a given graph is bipartite or not.
A bipartite graph can be divided into two independent sets such that every edge connects a vertex from one set to the other.
We can use graph coloring algorithm to check if the graph is bipartite.
Start by coloring the first vertex with one color and all its neighbors with the other color.
Continue coloring the remaining vertices, making sure that no adjacent vertices have the same color.
If at any point, we find that ...read more
Q6. 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
The question asks to print the DFS traversal of an undirected and disconnected graph.
Implement a Depth First Search (DFS) algorithm to traverse the graph.
Use a visited array to keep track of visited vertices.
For each unvisited vertex, start a DFS traversal and print the connected component.
Sort the vertices of each connected component in ascending order before printing.
Q7. Dependency Injection & IOC in Spring
Dependency Injection & IOC in Spring
Dependency Injection is a design pattern that allows objects to be loosely coupled and easily testable
In Spring, IOC (Inversion of Control) is used to manage dependencies and inject them into objects at runtime
IOC container in Spring is responsible for creating and managing objects and their dependencies
Spring supports different types of dependency injection such as constructor injection, setter injection, and field injection
Calling a function using the new keyword creates a new instance of the function's constructor.
Creates a new empty object
Binds 'this' to the new object
Adds a property to the new object called '__proto__' which points to the constructor function's prototype object
Returns the new object
Q9. merge sort explanation
Merge sort is a divide and conquer algorithm that divides the input array into two halves, sorts them recursively, and then merges them back together in sorted order.
Divide the array into two halves
Recursively sort each half
Merge the sorted halves back together
Q10. Buy stock sell problem
The Buy stock sell problem involves finding the maximum profit that can be obtained by buying and selling stocks.
Iterate through the array of stock prices
Keep track of the minimum price seen so far
Calculate the profit by subtracting the minimum price from the current price
Update the maximum profit if the calculated profit is greater
Return the maximum profit
You can import all exports of a file as an object in JavaScript using the 'import * as' syntax.
Use the 'import * as' syntax followed by the object name and 'from' keyword to import all exports of a file as an object.
For example: import * as myExports from './myFile.js';
You can then access the exports using dot notation, like myExports.myFunction().
Q12. 1. Find triplet in an array to sum up to a given number?
Find triplet in an array to sum up to a given number.
Sort the array in ascending order.
Iterate through the array and fix the first element.
Use two pointers approach to find the other two elements that sum up to the given number.
The 'this' operator in JavaScript refers to the current context or object.
Refers to the current object or context in which a function is being executed
Can be used to access properties and methods of the current object
The value of 'this' is determined by how a function is called
Observables are streams that can emit multiple values over time, while promises can only emit a single value.
Observables can emit multiple values over time, while promises can only emit a single value.
Observables are cancellable, while promises are not.
Observables support operators like map, filter, and reduce for transforming data streams, while promises do not.
Observables are lazy, meaning they do not run until they are subscribed to, while promises start executing as soon ...read more
Q15. SQL query of finding aggregate salary for the division
SQL query to find aggregate salary for a division
Use the GROUP BY clause to group the employees by division
Use the SUM function to calculate the total salary for each division
Include the division column in the SELECT statement
Example: SELECT division, SUM(salary) AS total_salary FROM employees GROUP BY division
Arrow functions are a concise way to write functions in JavaScript.
Arrow functions are defined using the '=>' syntax.
They have a shorter syntax compared to traditional function expressions.
They do not have their own 'this' keyword, instead they inherit it from the parent scope.
Example: const add = (a, b) => a + b;
AOT compilation in Angular stands for Ahead-of-Time compilation, which compiles Angular templates and components during the build process.
AOT compilation improves the performance of Angular applications by pre-compiling the templates and components before the browser downloads and runs them.
It detects template errors during the build process rather than at runtime, leading to faster rendering and reduced bundle size.
AOT compilation eliminates the need for the Angular compiler...read more
Q18. Difference between Abstract class vs Interface?
Abstract class is a class that can have both abstract and non-abstract methods while Interface only has abstract methods.
Abstract class can have constructors while Interface cannot.
A class can implement multiple interfaces but can only inherit from one abstract class.
Abstract class can have instance variables while Interface cannot.
Abstract class can provide default implementation for some methods while Interface cannot.
Example of Abstract class: Animal class with abstract me...read more
Q19. 2. Print a star pattern?
Printing a star pattern using loops in programming.
Use nested loops to print the pattern
The outer loop controls the number of rows
The inner loop controls the number of stars to be printed in each row
Use string concatenation to build the pattern
Example: for a pattern with 5 rows, the first row will have 1 star, the second row will have 2 stars, and so on
Q20. Implementation of queue using stack
Implement a queue using two stacks
Use two stacks - one for enqueue operation and one for dequeue operation
For enqueue operation, push elements into the first stack
For dequeue operation, if the second stack is empty, pop all elements from the first stack and push into the second stack, then pop from the second stack
Example: Enqueue 1,2,3 -> Stack1: [1,2,3], Dequeue -> Stack2: [3,2,1], Dequeue -> 1
Q21. What is self interdection
Self-intersection occurs when a curve or surface intersects itself at a point.
Self-intersection can occur in computer graphics when rendering complex shapes.
It can also occur in geometry when analyzing curves and surfaces.
Self-intersection can lead to rendering artifacts or inaccuracies in calculations.
Q22. What is the phython
Python is a high-level programming language known for its simplicity and readability.
Python is an interpreted language, meaning code is executed line by line.
It supports multiple programming paradigms like procedural, object-oriented, and functional programming.
Python has a large standard library and a thriving community with many third-party libraries available.
It is widely used in web development, data science, artificial intelligence, and more.
Example: print('Hello, World!...read more
Q23. Why this in python
Python is a versatile, easy-to-read language with a large community and extensive libraries.
Python has a simple syntax that makes it easy to learn and read.
Python has a large community of developers, making it easy to find support and resources.
Python has a wide range of libraries and frameworks for various applications, such as web development, data analysis, and machine learning.
Q24. Why the codeing
Coding allows me to solve complex problems, create innovative solutions, and continuously learn and improve my skills.
Coding enables me to automate tasks and processes, increasing efficiency and productivity.
It provides a creative outlet for problem-solving and allows me to build practical applications.
Coding opens up opportunities for collaboration with other developers and working on exciting projects.
It is a valuable skill in today's technology-driven world, with high dema...read more
Q25. DSA stack problem
Implement a stack using arrays with push, pop, and peek operations.
Create an array to store the elements of the stack
Implement push operation by adding elements to the end of the array
Implement pop operation by removing the last element from the array
Implement peek operation by returning the last element of the array without removing it
Q26. SOC processes and techniques
SOC processes and techniques involve monitoring, detecting, and responding to cybersecurity threats.
Continuous monitoring of network traffic and system logs
Utilizing security information and event management (SIEM) tools
Implementing threat intelligence feeds for proactive defense
Incident response planning and execution
Regular security assessments and penetration testing
More about working at Gainsight

Interview Process at Gainsight

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

