Bharti Airtel
Jagdamba Trailers Interview Questions and Answers
Q1. Longest Common Prefix After Rotation
You are given two strings 'A' and 'B'. While string 'A' is constant, you may apply any number of left shift operations to string 'B'.
Explanation:
Your task is to calculate ...read more
Calculate the minimum number of left shift operations needed to achieve the longest common prefix between two strings.
Apply left shift operations to string B to find the longest common prefix with string A
Count the number of left shifts needed to achieve the longest common prefix
Return the minimum number of left shift operations for each test case
Q2. Longest Subarray with Zero Sum
Ninja enjoys working with numbers, and as a birthday challenge, his friend provides him with an array consisting of both positive and negative integers. Ninja is curious to identi...read more
Find the length of the longest subarray with zero sum in an array of integers.
Iterate through the array and keep track of the running sum using a hashmap.
If the running sum is seen before, the subarray between the current index and the previous index with the same sum is a subarray with zero sum.
Update the length of the longest subarray with zero sum as you iterate through the array.
Example: For arr1 = [1, -1, 3, 2, -2, -3, 3], the longest subarray with zero sum is [3, 2, -2,...read more
Q3. Character Frequency Problem Statement
You are given a string 'S' of length 'N'. Your task is to find the frequency of each character from 'a' to 'z' in the string.
Example:
Input:
S : abcdg
Output:
1 1 1 1 0 0 ...read more
Given a string, find the frequency of each character from 'a' to 'z' in the string.
Create an array of size 26 to store the frequency of each character from 'a' to 'z'.
Iterate through the string and increment the count of the corresponding character in the array.
Print the array of frequencies as the output for each test case.
Q4. Stack using Two Queues Problem Statement
Develop a Stack Data Structure to store integer values using two Queues internally.
Your stack implementation should provide these public functions:
Explanation:
1. Cons...read more
Implement a stack using two queues to store integer values with specified functions.
Create a stack using two queues internally
Implement functions for push, pop, top, size, and isEmpty
Handle edge cases such as empty stack or invalid data
Ensure the stack functions work correctly and efficiently
Test the implementation with sample inputs and outputs
Q5. Longest Consecutive Sequence Problem Statement
You are provided with an unsorted array/list ARR
of N
integers. Your task is to determine the length of the longest consecutive sequence present in the array.
Expl...read more
Find the length of the longest consecutive sequence in an unsorted array of integers.
Iterate through the array and store each element in a set for constant time lookup.
For each element, check if it is the start of a sequence by looking for its previous number in the set.
Update the length of the current consecutive sequence and track the longest sequence found so far.
Return the length of the longest consecutive sequence.
Example: Input [9,5,4,9,10,10,6], Output: 3 (Longest cons...read more
Q6. Trapping Rain Water Problem Statement
You are given a long type array/list ARR
of size N
, representing an elevation map. The value ARR[i]
denotes the elevation of the ith
bar. Your task is to determine the tota...read more
Calculate the total amount of rainwater that can be trapped between given elevations in an elevation map.
Iterate through the array to find the maximum height on the left and right of each bar.
Calculate the amount of water that can be trapped above each bar by taking the minimum of the maximum heights on the left and right.
Sum up the trapped water above each bar to get the total trapped water for the elevation map.
Q7. Left View of a Binary Tree
Given a binary tree, your task is to print the left view of the tree. The left view of a binary tree contains the nodes visible when the tree is viewed from the left side.
Input:
The ...read more
Print the left view of a binary tree, containing nodes visible from the left side.
Traverse the tree in a level order manner and print the first node at each level.
Use a queue to keep track of nodes at each level.
Handle null nodes represented by -1 in the input.
SQL query to find the second highest salary
Use the ORDER BY clause to sort the salaries in descending order
Use the LIMIT clause to limit the result to the second row
Use a subquery to exclude the highest salary from the result
Q9. How to optimise fetching 1 lakh entries from db
Use pagination, indexing, caching, and query optimization to fetch 1 lakh entries efficiently from the database.
Implement pagination to fetch data in smaller chunks
Create indexes on columns frequently used in queries
Use caching to store frequently accessed data
Optimize queries by avoiding unnecessary joins and using appropriate indexes
Consider using database-specific optimizations like query hints or stored procedures
Interview Process at Jagdamba Trailers
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month