Springworks
10+ Tiger Analytics Interview Questions and Answers
Q1. Number of Islands Problem Statement
You are provided with a 2-dimensional matrix having N
rows and M
columns, containing only 1s (land) and 0s (water). Your goal is to determine the number of islands in this ma...read more
Count the number of islands in a 2D matrix of 1s and 0s.
Use Depth First Search (DFS) or Breadth First Search (BFS) to traverse the matrix and identify connected groups of 1s.
Maintain a visited array to keep track of visited cells to avoid counting the same island multiple times.
Increment the island count each time a new island is encountered during traversal.
Consider edge cases such as when the matrix is empty or when all cells are water (0s).
Q2. Implementing Queue with Two Stacks
Your task is to implement a queue using two stacks. You are provided with ‘Q’ queries and need to handle them, where each query falls under one of these two operations:
- Enque...read more
Implement a queue using two stacks with enqueue and dequeue operations.
Use two stacks to simulate a queue - one for enqueue and one for dequeue.
For enqueue operation, push elements onto the enqueue stack.
For dequeue operation, if dequeue stack is empty, pop all elements from enqueue stack and push onto dequeue stack.
Return true for successful enqueue and -1 for empty dequeue.
Example: Enqueue 10, enqueue 20, dequeue (returns 10), enqueue 30, dequeue (returns 20).
Q3. Paint House Problem Statement
You have been given a set of 'N' houses, each house can be painted using one of three colors: green, red, or yellow. A cost matrix is provided with dimensions 'N' * 3, where each e...read more
Find the minimum total cost to paint all houses such that no two adjacent houses have the same color.
Use dynamic programming to keep track of the minimum cost of painting each house with each color while ensuring no two adjacent houses have the same color.
At each house, calculate the minimum cost of painting it with each color based on the previous house's colors.
Keep updating the minimum cost for each color at each house until reaching the last house.
Return the minimum cost ...read more
Q4. Inorder Traversal of Binary Tree
You are provided with a Binary Tree composed of 'N' nodes, each holding integer values. Your task is to compute the Inorder traversal of this binary tree.
Example:
For the given...read more
The task is to find the in-order traversal of a given binary tree.
Implement a recursive function to perform in-order traversal of the binary tree
Start from the left subtree, then visit the root node, and finally visit the right subtree
Use an array to store the values of the nodes in the in-order traversal
Q5. Search in a Row-wise and Column-wise Sorted Matrix Problem Statement
You are given an N * N matrix of integers where each row and each column is sorted in increasing order. Your task is to find the position of ...read more
Given a sorted matrix, find the position of a target integer in the matrix.
Iterate through each row and column of the matrix
Compare the target integer with the current element
If the target integer is found, return the position
If the target integer is not found, return {-1, -1}
Q6. Maximum Product Subarray Problem Statement
Given an array of integers, determine the contiguous subarray that produces the maximum product of its elements.
Explanation:
A subarray can be derived from the origin...read more
Find the contiguous subarray with the maximum product of elements in an array.
Iterate through the array and keep track of the maximum and minimum product ending at each index.
Update the maximum product by taking the maximum of current element, current element * previous maximum, and current element * previous minimum.
Update the minimum product by taking the minimum of current element, current element * previous maximum, and current element * previous minimum.
Return the maximu...read more
Q7. Divide String Problem Statement
You are given a string WORD
consisting of lowercase alphabets. Your task is to divide WORD
into N
strings of equal length.
Input:
The first line contains an integer 'T' represent...read more
Divide a given string into N equal parts and return the divided strings as an array of strings.
Calculate the length of each part by dividing the length of the string by N.
Iterate through the string and extract substrings of the calculated length.
Return the array of divided strings.
Handle cases where it is not possible to divide the string into N equal parts.
Q8. Painting Fences Problem Statement
You are given ‘N’ fences. Your task is to compute the total number of ways to paint these fences using only 2 colors, such that no more than 2 adjacent fences have the same col...read more
The task is to find the total number of ways to paint fences using 2 colors such that at most 2 adjacent fences have the same color.
Use dynamic programming to solve the problem
Create a 2D array to store the number of ways to paint the fences
Initialize the base cases for the first two fences
Use recurrence relation to calculate the number of ways for the remaining fences
Return the result modulo 10^9 + 7
Q9. Linear Probing in Hashing
Hashing is a technique to map large non-negative integers to smaller indices using a hash function. In the context of collision resolution in hash tables, 'Linear Probing' is employed,...read more
Linear Probing in Hashing is a technique to resolve collisions in hash tables by linearly searching for the next available slot.
Implement a function that takes an array of non-negative integers and returns the corresponding hash table using linear probing.
Use the given hash function H(X) = X mod N to map elements to indices in the hash table.
Handle collisions by linearly probing for the next available slot in the hash table.
Ensure the constraints are met: 1 <= T <= 10, 1 <= N...read more
Q10. Internet Address Problem
You are given the task of reconstructing the address of an Internet resource from a given format.
Explanation:
The address format is:
is either "http" or "ftp".
is a non-em...read more
The task is to extract and print the internet resource address from a given string.
The internet resource address has a specific format:
:// .ru[/ ] The
can be either 'http' or 'ftp' The
is a non-empty string of lowercase English letters The
may or may not be present, and if present, it is a non-empty string of lowercase English letters If
is not present, the address has either two '/' characters (before the domain) or three (an extra one in front of the context)
Q11. M-Coloring Problem Statement
Given an undirected graph as an adjacency matrix and an integer M
, determine whether you can color the vertices of the graph using at most M
colors such that no two adjacent vertice...read more
The problem is to determine if it is possible to color the vertices of an undirected graph using at most M colors such that no two adjacent vertices have the same color.
The input consists of the number of test cases, the number of vertices and colors, and the adjacency matrix of the graph.
For each test case, check if it is possible to assign colors to the vertices such that no adjacent vertices have the same color.
Use a backtracking or graph coloring algorithm to solve the pr...read more
Q12. Matrix Chain Multiplication Problem
Given 'N' 2-dimensional matrices and an array ARR
of length N + 1
, where the first N
integers denote the number of rows in each matrix and the last integer represents the num...read more
The task is to find the minimum number of multiplication operations required to multiply a series of matrices together.
Use dynamic programming to solve the problem efficiently.
Create a 2D array to store the minimum number of operations needed to multiply matrices.
Iterate through different combinations of matrices to find the optimal solution.
Consider the dimensions of matrices and their compatibility for multiplication.
Calculate the minimum number of operations by considering...read more
Q13. Pair Sum Problem Statement
You are given an array of integers 'ARR' with a length 'N' and a specific integer 'Target'. Your objective is to determine and return all pairs of elements within the array whose sum ...read more
Given an array of integers and a target sum, find pairs of elements that add up to the target.
Iterate through the array and for each element, check if the complement (target - current element) exists in a hash set.
If the complement exists, add the pair to the result. If not, add the current element to the hash set.
Handle edge cases like duplicates and negative numbers appropriately.
Return pairs in any order as (a, b) or (b, a).
Q14. Roman Numeral to Integer Conversion
Convert a string representing a Roman numeral into its integer equivalent and return the result.
Explanation:
Roman numerals are represented by seven different symbols: I, V,...read more
Convert a Roman numeral string to its integer equivalent.
Create a mapping of Roman numeral symbols to their integer values.
Iterate through the input string and add the corresponding integer values.
Handle cases where a smaller value precedes a larger value (e.g., IV = 4).
To join multiple models in a DBMS, use SQL JOIN statements based on common keys.
Identify common keys between the models
Use SQL JOIN statements (INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL JOIN) to combine the models based on the common keys
Specify the columns to be selected in the SELECT statement
The inner join operation combines rows from two tables based on a common column (key).
Use the JOIN keyword in the SQL query to perform an inner join.
Specify the common column (key) in the ON clause of the join.
The result will contain only the matching rows from both tables.
Interview Process at Tiger Analytics
Top Software Developer Intern Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month