HashedIn by Deloitte
50+ Syrma SGS Technologies Interview Questions and Answers
Q1. Chocolate Pickup Problem
Ninja has a 'GRID' of size 'R' x 'C'. Each cell of the grid contains some chocolates. Ninja has two friends, Alice and Bob, and he wants to collect as many chocolates as possible with t...read more
Q2. Reverse the Linked List
Given a singly linked list of integers, your task is to return the head of the reversed linked list.
Input:
The first line of input contains an integer 'T' representing the number of tes...read more
Q3. Maximum Subarray Sum Problem Statement
Given an array arr
of length N
consisting of integers, find the sum of the subarray (including empty subarray) with the maximum sum among all subarrays.
Explanation:
A sub...read more
Q4. Find K'th Character of Decrypted String
You are given an encrypted string where repeated substrings are represented by the substring followed by its count. Your task is to find the K'th character of the decrypt...read more
Q5. Leaders in an Array Problem Statement
Given a sequence of numbers, the task is to identify all the leaders within this sequence. An element is considered a leader if it is strictly greater than all the elements...read more
Q6. Detect and Remove Loop in Linked List
For a given singly linked list, identify if a loop exists and remove it, adjusting the linked list in place. Return the modified linked list.
Expected Complexity:
Aim for a...read more
Q7. Lowest Common Ancestor in a BST Problem Statement
You're provided with a Binary Search Tree (BST) containing 'N' nodes with integer values and two specific nodes, 'P' and 'Q'.
Your task is to identify the lowes...read more
Q8. Trailing Zeros in Factorial Problem
Find the number of trailing zeroes in the factorial of a given number N
.
Input:
The first line contains an integer T
representing the number of test cases.
Each of the followi...read more
Q9. Find Two Missing Numbers Problem Statement
Given an array of unique integers where each element is in the range [1, N], and the size of the array is (N - 2), there are two numbers missing from this array. Your ...read more
Q10. Longest Increasing Subsequence Problem Statement
Given an array of integers with 'N' elements, determine the length of the longest subsequence where each element is greater than the previous element. This subse...read more
Q11. Merge K Sorted Arrays Problem Statement
Given 'K' different arrays that are individually sorted in ascending order, merge all these arrays into a single array that is also sorted in ascending order.
Input
The f...read more
Q12. Convert Binary Tree to Mirror Tree Problem Statement
Given a binary tree, convert this binary tree into its mirror tree. A binary tree is a tree in which each parent node has at most two children. The mirror of...read more
Q13. Min Jumps Problem Statement
In Ninja town, represented as an N * M
grid, people travel by jumping over buildings in the grid's cells. Santa is starting at cell (0, 0) and must deliver gifts to cell (N-1, M-1) o...read more
Q14. Convert a Number to Words
Given an integer number num
, your task is to convert 'num' into its corresponding word representation.
Input:
The first line of input contains an integer ‘T’ denoting the number of tes...read more
Q15. Sort 0 1 2 Problem Statement
Given an integer array arr
of size 'N' containing only 0s, 1s, and 2s, write an algorithm to sort the array.
Input:
The first line contains an integer 'T' representing the number of...read more
Q16. 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
Q17. Anagram Pairs Verification Problem
Your task is to determine if two given strings are anagrams of each other. Two strings are considered anagrams if you can rearrange the letters of one string to form the other...read more
Q18. Longest Mountain Subarray Problem Statement
Given an array of integers denoting the heights of the mountains, find the length of the longest subarray that forms a mountain shape.
A mountain subarray is defined ...read more
Q19. Triplets with Given Sum Problem
Given an array or list ARR
consisting of N
integers, your task is to identify all distinct triplets within the array that sum up to a specified number K
.
Explanation:
A triplet i...read more
Q20. Cycle Detection in a Singly Linked List
Determine if a given singly linked list of integers forms a cycle or not.
A cycle in a linked list occurs when a node's next
points back to a previous node in the list. T...read more
Q21. Find All Pairs Adding Up to Target
Given an array of integers ARR
of length N
and an integer Target
, your task is to return all pairs of elements such that they add up to the Target
.
Input:
The first line conta...read more
Q22. Container With Most Water Problem Statement
Given a sequence of ‘N’ non-negative integers, A[1], A[2], ..., A[i], ..., A[N]
, where each number represents the height of a vertical line drawn at position 'i'. On ...read more
Q23. Group Anagrams Problem Statement
Given an array or list of strings called inputStr
, your task is to return the strings grouped as anagrams. Each group should contain strings that are anagrams of one another.
An...read more
Q24. String Palindrome Verification
Given a string, your task is to determine if it is a palindrome considering only alphanumeric characters.
Input:
The input is a single string without any leading or trailing space...read more
Q25. Four Sum Problem Statement
You are provided with an array/list 'ARR' consisting of 'N' integers and an integer 'TARGET'. The task is to determine if there exist four distinct numbers in 'ARR' such that their su...read more
Q26. Lowest Common Ancestor (LCA) Problem Statement
Understanding the concept of Lowest Common Ancestor (LCA) in graph theory and computer science is essential.
Consider a rooted tree ‘T’ containing ‘N’ nodes. The L...read more
Q27. Remove Duplicates from String Problem Statement
You are provided a string STR
of length N
, consisting solely of lowercase English letters.
Your task is to remove all duplicate occurrences of characters in the s...read more
Q28. Last Stone Weight Problem Statement
We have a set collection of N
stones, and each stone has a given positive integer weight. On each turn, select the two stones with the maximum weight and smash them together....read more
Q30. Write code to find max length subarray matching the given sum
Code to find max length subarray matching the given sum
Use a sliding window approach to iterate through the array
Keep track of the current sum and the maximum length subarray
If the current sum exceeds the given sum, move the window's left pointer
If the current sum matches the given sum, update the maximum length subarray
Return the maximum length subarray
Q33. Write an SQL query to given an output from given tables
SQL query to retrieve output from given tables
Identify the tables and their relationships
Determine the columns to be selected
Use appropriate join and filter conditions
Group and aggregate data if required
Q34. Designing of APIs, SQL query to find second largest value
Designing APIs and finding second largest value in SQL query.
For API design, consider RESTful principles and use clear and concise naming conventions.
For finding second largest value in SQL, use ORDER BY and LIMIT clauses.
Consider edge cases such as duplicates and null values.
Test thoroughly to ensure correct functionality.
Q36. Write CLI snake and ladders game code
CLI snake and ladders game code
Create a board with 100 cells using a 10x10 array
Define snakes and ladders positions as an array of tuples
Use a loop to alternate player turns and move them based on dice roll
Check for snakes and ladders and update player position accordingly
Print the board after each turn and declare winner when a player reaches cell 100
Q37. Sort an array of 0s,1s,2s in O(n) time.
Sort an array of 0s, 1s, 2s in linear time.
Use three pointers to keep track of the positions of 0s, 1s, and 2s.
Traverse the array once and swap elements based on their values.
The final array will have 0s, 1s, and 2s grouped together in that order.
Q38. Find if pair sum exists in array
Check if there exists a pair of numbers in the array that add up to a given sum.
Iterate through the array and for each element, check if the difference between the sum and the element exists in the array using a hash table.
Alternatively, sort the array and use two pointers to traverse from both ends towards the middle, adjusting the pointers based on the sum of the current pair.
Q39. Why do you want to join hashedin.
I want to join Hashedin because of its reputation for innovative projects and collaborative work environment.
Reputation for innovative projects
Collaborative work environment
Opportunities for growth and learning
Q40. Method overloading vs Method overriding
Method overloading is having multiple methods with the same name but different parameters. Method overriding is having a subclass method with the same name and parameters as a superclass method.
Method overloading is used to provide different ways of calling the same method with different parameters.
Method overriding is used to provide a specific implementation of a method in a subclass that is already defined in a superclass.
Method overloading is resolved at compile-time base...read more
Q41. Kth smallest element in array
Finding the Kth smallest element in an array.
Sort the array and return the Kth element.
Use a min heap to find the Kth smallest element.
Use quickselect algorithm to find the Kth smallest element.
Divide and conquer approach using binary search.
Use selection algorithm to find the Kth smallest element.
Q42. rotate a array k times
Rotate an array of strings k times
Create a temporary array to store elements that will be rotated
Use modulo operator to handle cases where k is greater than array length
Update the original array with elements from the temporary array
Q43. what is abstraction and encapsulation
Abstraction is the concept of hiding complex implementation details and showing only the necessary information. Encapsulation is bundling data and methods that operate on the data into a single unit.
Abstraction focuses on what an object does rather than how it does it
Encapsulation restricts access to some of an object's components, protecting the object's integrity
Abstraction allows for creating simple interfaces for complex systems
Encapsulation helps in achieving data hiding...read more
Q44. 2 sum using linked list
Use a hash table to find two numbers in a linked list that add up to a target sum.
Traverse the linked list and store each node's value in a hash table along with its index.
For each node, check if the difference between the target sum and the current node's value exists in the hash table.
If it does, return the indices of the two nodes.
Example: Given linked list 2 -> 4 -> 3 -> 5 and target sum 7, return indices 1 and 2.
Q45. Design a database for instagram
Database design for Instagram platform
Create tables for users, posts, comments, likes, followers, and hashtags
Use primary and foreign keys to establish relationships between tables
Include fields such as user_id, post_id, comment_id, like_id, follower_id, and hashtag_id
Implement indexes for faster data retrieval
Consider scalability and performance optimization techniques
Q46. what is multiple inheritance
Multiple inheritance is a feature in object-oriented programming where a class can inherit attributes and methods from more than one parent class.
Allows a class to inherit attributes and methods from multiple parent classes
Can lead to the Diamond Problem where ambiguity arises if two parent classes have a method with the same name
Languages like C++ support multiple inheritance
Q47. Code transpose of matrix
Transpose a matrix by swapping rows with columns
Iterate through each row and column and swap the elements
Create a new matrix with swapped rows and columns
Ensure the new matrix has the correct dimensions
Q48. Implement swap method.
Implement a swap method for two variables.
Create a temporary variable to store the value of one variable.
Assign the value of the second variable to the first variable.
Assign the value of the temporary variable to the second variable.
Q49. Depth of a binary tree
The depth of a binary tree is the number of edges on the longest path from the root node to a leaf node.
Depth of a binary tree can be calculated recursively by finding the maximum depth of the left and right subtrees and adding 1.
The depth of a binary tree with only one node (the root) is 0.
Example: For a binary tree with root node A, left child B, and right child C, the depth would be 1.
Q50. Middle of linked list.
To find the middle element of a linked list, use two pointers - one moving at double the speed of the other.
Use two pointers - slow and fast, with fast moving at double the speed of slow.
When fast reaches the end of the list, slow will be at the middle element.
Top HR Questions asked in Syrma SGS Technologies
Interview Process at Syrma SGS Technologies
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month