HashedIn by Deloitte
100+ Nuvama Wealth Management 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
Find the maximum number of chocolates that can be collected by two friends moving in a grid.
Start from the top-left and top-right corners, move diagonally down to collect chocolates
Calculate the total chocolates collected by each friend and sum them up for the final result
Consider all possible paths for both friends to maximize the total chocolates collected
Q2. 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
Given an encrypted string with repeated substrings represented by counts, find the K'th character of the decrypted string.
Parse the encrypted string to extract substrings and their counts
Iterate through the substrings and counts to build the decrypted string
Track the position in the decrypted string to find the K'th character
Q3. 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.
Q4. 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
Reverse a singly linked list of integers in O(N) time and O(1) space complexity.
Iterate through the linked list, reversing the pointers to point to the previous node instead of the next node.
Use three pointers to keep track of the current, previous, and next nodes while reversing the list.
Update the head of the reversed linked list as the last node encountered during the reversal process.
Example: Given 1 -> 2 -> 3 -> 4 -> NULL, reverse it to get 4 -> 3 -> 2 -> 1 -> NULL with ...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
Identify all the leaders in a sequence of numbers, where a leader is greater than all elements to its right.
Iterate through the sequence from right to left, keeping track of the maximum element encountered so far.
If an element is greater than the maximum element encountered so far, it is a leader.
Add the leaders to a result sequence while maintaining the original order.
The rightmost element is always a leader.
Q6. 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
Count the number of trailing zeros in the factorial of a given number.
Trailing zeros are created by pairs of 2 and 5 in the factorial.
Count the number of 5s in the prime factorization of N to find the trailing zeros.
For example, for N=10, there are 2 trailing zeros as there are two 5s in the prime factorization of 10.
Q7. Count Ways to Reach the N-th Stair Problem Statement
You are provided with a number of stairs, and initially, you are located at the 0th stair. You need to reach the Nth stair, and you can climb one or two step...read more
The problem involves finding the number of distinct ways to climb N stairs by taking 1 or 2 steps at a time.
Use dynamic programming to solve the problem efficiently.
The number of ways to reach the Nth stair is the sum of the number of ways to reach the (N-1)th stair and the (N-2)th stair.
Handle base cases for N=0 and N=1 separately.
Consider using modulo operation to avoid overflow for large values of N.
Q8. 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
Find the sum of the subarray with the maximum sum among all subarrays in a given array.
Iterate through the array and keep track of the maximum sum subarray seen so far.
At each index, decide whether to include the current element in the subarray or start a new subarray.
Update the maximum sum subarray if the current sum is greater than the previous maximum sum.
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
Given an array of unique integers with two missing numbers, find and return the missing numbers.
Iterate through the array and mark the presence of each number in a separate boolean array.
Iterate through the boolean array to find the missing numbers.
Return the missing numbers in increasing order.
Q10. 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
Convert a given integer number into its corresponding word representation.
Implement a function that converts the given number into words by breaking it down into its individual digits and mapping them to their word representation.
Handle special cases like numbers less than 20, multiples of 10, and numbers in the hundreds and thousands place.
Ensure that there is a space between every two consecutive words and all characters are in English lowercase letters.
Q11. 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
Convert a binary tree into its mirror tree by interchanging left and right children of non-leaf nodes.
Traverse the binary tree in a recursive manner.
Swap the left and right children of each non-leaf node.
Continue this process until all nodes are visited.
Example: Input binary tree: 1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1, Output mirror tree: 1 3 2 6 5 4 -1 -1 -1 -1 -1 7 -1 -1 -1
Q12. 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
Santa needs to find the quickest path to deliver gifts in Ninja town by jumping over buildings with least travel time.
Santa starts at (0, 0) and needs to deliver gifts to (N-1, M-1) on Christmas Eve.
Santa can jump to (x+1, y+1), (x+1, y), or (x, y+1) from any cell (x, y) within grid boundaries.
Travel time between two buildings equals the absolute difference in their heights.
Find the quickest path with least travel time using dynamic programming or Dijkstra's algorithm.
Q13. Tic-Tac-Toe Design Problem
Design a 2-player Tic-Tac-Toe game played on an N
* N
grid where Player 1 uses ‘X’ and Player 2 uses ‘O’. A move is always valid and occupies an empty spot.
If a player places N
of th...read more
Design a 2-player Tic-Tac-Toe game on an N x N grid where players place their marks to win by getting N marks in a row.
Create a 2D array to represent the game board.
Implement a function to check for a win after each move.
Handle player moves and update the board accordingly.
Return the result of each move (0, 1, or 2) based on the game state.
Consider horizontal, vertical, and diagonal win conditions.
Q14. 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
The task is to determine if there exist four distinct numbers in an array that sum up to a given target value.
Iterate through all possible combinations of four distinct numbers in the array.
Use a nested loop to check all combinations efficiently.
Keep track of the sum of each combination and compare it with the target value.
Return 'Yes' if a valid combination is found, otherwise return 'No'.
Q15. 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
Detect and remove loop in a singly linked list in place with O(n) time complexity and O(1) space complexity.
Use Floyd's Tortoise and Hare algorithm to detect the loop in the linked list.
Once the loop is detected, find the start of the loop using the same algorithm.
Adjust the pointers to remove the loop and return the modified linked list.
Example: For input 5 2 and elements 1 2 3 4 5, output should be 1 2 3 4 5.
Q16. 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
Find the lowest common ancestor of two nodes in a Binary Search Tree.
Traverse the BST from the root to find the LCA of the given nodes.
Compare the values of the nodes with the values of P and Q to determine the LCA.
Handle cases where one node is the ancestor of the other or when one of the nodes is the root.
Use recursion to efficiently find the LCA in the BST.
Consider edge cases such as when the nodes are not present in the BST.
Q17. 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
Merge K sorted arrays into a single sorted array.
Create a min-heap to store the first element of each array along with the array index.
Pop the smallest element from the heap and add it to the result array.
If the array from which the element was popped has more elements, add the next element to the heap.
Repeat until all elements are merged into a single sorted array.
Q18. 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
Given an array of integers and a target, find all pairs of elements that add up to the target.
Iterate through the array and for each element, check if the target - element exists in a hash set.
If it exists, add the pair to the result. If not, add the element to the hash set.
Handle cases where the same element is used twice to form a pair.
Return (-1, -1) if no pair is found.
Q19. 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
Find two lines to form a container with maximum water holding capacity.
Use two pointers approach to find the maximum area by calculating the area between the lines and moving the pointers based on the height of the lines.
Keep track of the maximum area found so far.
The area is calculated as the minimum of the two line heights multiplied by the distance between the lines.
Example: For input A = [1,8,6,2,5,4,8,3,7], the maximum area is 49 between lines at indices 1 and 8.
Q20. 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
Group anagrams in an array of strings based on character frequency.
Iterate through each string in the input array
For each string, sort the characters and use the sorted string as a key in a hashmap to group anagrams
Return the grouped anagrams as output
Q21. Increase Number By 1 Problem Statement
Given an array of integers NUM
that consists of N
elements, where the array represents the digits of a number, your task is to add 1 to this number. The number is positive...read more
Given an array representing digits of a number, add 1 to the number.
Iterate through the array from right to left, starting with the least significant digit.
Add 1 to the current digit and check if it becomes 10. If so, set it to 0 and carry over to the next digit.
Handle the case where the most significant digit needs to be incremented by creating a new array with an extra digit.
Q22. 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
Sort an array of 0s, 1s, and 2s in linear time complexity.
Use three pointers to keep track of 0s, 1s, and 2s while iterating through the array.
Swap elements based on the values encountered to sort the array in-place.
Time complexity should be O(N) and space complexity should be O(1).
Q23. 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
Determine the minimum number of platforms needed at a railway station based on arrival and departure times of trains.
Sort the arrival and departure times in ascending order.
Use two pointers to keep track of overlapping schedules.
Increment the platform count when a new train arrives before the previous one departs.
Return the maximum platform count needed.
Q24. 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
The Lowest Common Ancestor (LCA) problem involves finding the lowest node in a tree that is an ancestor of two given nodes.
LCA is the lowest node in a tree that is an ancestor of both given nodes.
The tree is rooted at node 1 for each test case.
Paths from each node to the root are considered to find the LCA.
Constraints include the number of test cases, nodes, queries, and node values.
Time limit for the solution is 1 second.
Q25. 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
Find the weight of the last stone remaining after smashing stones together.
Sort the stones in descending order.
Simulate the smashing process by repeatedly smashing the two heaviest stones until only one stone is left.
Return the weight of the last stone, or 0 if no stone is left.
Q26. 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
Detect if a singly linked list forms a cycle by checking if a node's next points back to a previous node.
Use Floyd's Tortoise and Hare algorithm to detect a cycle in the linked list.
Maintain two pointers, slow and fast, where slow moves one step at a time and fast moves two steps at a time.
If there is a cycle, the fast pointer will eventually meet the slow pointer.
If the fast pointer reaches the end of the list (null), there is no cycle.
Time complexity: O(N), Space complexity...read more
Q27. 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
Check if two strings are anagrams of each other by comparing their sorted characters.
Sort the characters of both strings and compare them.
Use a dictionary to count the frequency of characters in each string and compare the dictionaries.
Ensure both strings have the same length before proceeding with the comparison.
Example: For input 'str1 = "spar", str2 = "rasp"', the output should be True.
Q28. 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
Find the length of the longest mountain subarray in an array of integers.
Identify peaks in the array where the elements transition from ascending to descending order.
Calculate the length of the mountain subarray starting from each peak.
Track the length of the longest mountain subarray found so far.
Consider edge cases like when there are no mountains in the array.
Q29. 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
The task is to find all distinct triplets in an array that sum up to a specified number.
Iterate through all possible triplets using three nested loops.
Check if the sum of the triplet equals the target sum.
Print the triplet if found, else print -1.
Q30. 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
Remove duplicates from a string of lowercase English letters.
Use a set to keep track of unique characters seen so far.
Iterate through the string and add each character to the set if it hasn't been seen before.
Construct a new string by appending characters that are not in the set.
Q31. 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.
Iterate through each character in the input string
Calculate the corresponding value of each character based on its position in the alphabet
Multiply the value by 26 raised to the power of its position from the right in the input string
Sum up all the values to get the final column number
Q32. 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
Determine if a given string is a palindrome considering only alphanumeric characters.
Remove non-alphanumeric characters from the input string.
Compare characters from start and end of the string to check for palindrome.
Handle edge cases like empty string or single character input.
Q33. Minimum Count of Balls in a Bag Problem Statement
You are given an integer array ARR
of size N
, where ARR[i]
represents the number of balls in the i-th
bag. Additionally, you have an integer M
, which indicates ...read more
Find the minimum possible value of the maximum number of balls in a bag after performing a given number of operations.
Iterate through the bags and split them to minimize the maximum number of balls.
Keep track of the maximum number of balls after each operation.
Return the minimum possible value of the maximum number of balls.
Q34. 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
Find the length of the longest strictly increasing subsequence in an array of integers.
Use dynamic programming to solve this problem efficiently.
Initialize an array to store the length of the longest increasing subsequence ending at each index.
Iterate through the array and update the length of the longest increasing subsequence for each element.
Return the maximum value in the array as the result.
Q35. Optimize the code for job scheduling written in the first round
Optimize job scheduling code
Use priority queue to efficiently schedule jobs
Implement dynamic programming to optimize job sequence
Consider parallel processing to reduce overall time
Use efficient data structures to store job information
Q36. Find Duplicate in Array Problem Statement
You are provided with an array of integers 'ARR' consisting of 'N' elements. Each integer is within the range [1, N-1], and the array contains exactly one duplicated el...read more
Find the duplicate element in an array of integers.
Iterate through the array and keep track of the frequency of each element using a hashmap.
Return the element with a frequency greater than 1 as the duplicate.
Time complexity should be O(n) and space complexity should be O(n).
Yes, I was given a schema and asked to write SQL queries based on it.
I was given a schema for a database that included tables, columns, and relationships between them.
I had to write SQL queries to retrieve specific data from the database based on the schema provided.
For example, I was asked to write a query to retrieve all customers who made a purchase in the last month.
I had to understand the schema to correctly write the queries and ensure they returned the desired results.
Q38. Binary Palindrome Check
Given an integer N
, determine whether its binary representation is a palindrome.
Input:
The first line contains an integer 'T' representing the number of test cases.
The next 'T' lines e...read more
Check if the binary representation of an integer is a palindrome.
Convert the integer to binary representation
Check if the binary representation is a palindrome by comparing it with its reverse
Return true if it is a palindrome, false otherwise
Q39. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
The task is to find the total number of ways to make change for a specified value using given denominations.
Create a dynamic programming table to store the number of ways to make change for each value up to the target value.
Iterate through each denomination and update the table accordingly.
The final answer will be the value in the table at the target value.
Consider edge cases such as when the target value is 0 or when there are no denominations available.
Example: For N=3, D=[...read more
Q40. Pair Sum Problem Statement
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.
Note:
Each pa...read more
Given an array and a target sum, find pairs of elements that add up to the target sum.
Iterate through the array and for each element, check if the complement (target sum - current element) exists in a hash set.
If the complement exists, add the pair to the result list.
Sort the result list based on the first element of each pair, with tiebreakers based on the second element.
Designing a social media platform with friend requests and posts.
Implement user profiles with friend request functionality.
Allow users to create and share posts on their profiles.
Include news feed to display posts from friends.
Implement notifications for friend requests and post interactions.
Include privacy settings for posts and friend requests.
Consider implementing features like comments, likes, and shares for posts.
Q42. Convert Binary Tree to Mirror Tree
Convert a given binary tree into its mirror tree, where the left and right children of all non-leaf nodes are interchanged.
Input:
An integer ‘T’ denoting the number of test c...read more
Convert a binary tree into its mirror tree by interchanging left and right children of non-leaf nodes.
Traverse the tree in postorder fashion and swap the left and right children of each node.
Recursively call the function on the left and right subtrees.
Modify the tree in place without creating a new tree.
Example: For input 1 2 3 4 -1 5 6 -1 7 -1 -1 -1 -1 -1 -1, the output should be 7 4 2 1 6 3 5.
Q43. Palindrome Permutation - Problem Statement
Determine if a permutation of a given string S
can form a palindrome.
Example:
Input:
string S = "aab"
Output:
"True"
Explanation:
The permutation "aba" of the string ...read more
Check if a permutation of a string can form a palindrome.
Create a frequency map of characters in the string.
Count the number of characters with odd frequencies.
If there is at most one character with an odd frequency, the string can form a palindrome.
Q44. 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
A banking system is a software application that allows customers to perform financial transactions, manage accounts, and access banking services.
The system should have user authentication and authorization mechanisms to ensure security.
It should support various types of accounts such as savings, checking, and loans.
The system should allow customers to deposit, withdraw, transfer funds, and view transaction history.
It should have features like bill payment, account statements,...read more
Design a music player similar to Spotify.
Implement user authentication for personalized playlists and recommendations
Create a user-friendly interface with features like search, shuffle, repeat, and create playlists
Integrate a recommendation system based on user listening history and preferences
Q47. Optimize the code for generating prime numbers
Use Sieve of Eratosthenes algorithm to optimize prime number generation.
Implement Sieve of Eratosthenes algorithm to eliminate non-prime numbers
Use boolean array to mark non-prime numbers
Start with 2 and mark all its multiples as non-prime, then move to next unmarked number
Stop at square root of the upper limit to optimize performance
Q48. 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
Q49. What is CRFS? The experience around working with it.
CRFS stands for Continuous Randomized Feedback System. It is a method used in clinical trials to collect data from patients.
CRFS is a way to collect data from patients in clinical trials in real-time.
It involves randomizing questions and collecting feedback from patients at various intervals.
The data collected through CRFS can help researchers make informed decisions about the efficacy of a treatment.
CRFS can be implemented through various methods such as mobile apps, web-bas...read more
Q50. Architecture Design for an e2e system that takes input from user to the response shown to the user
An e2e system architecture design for user input to response output
Identify user requirements and define system goals
Choose appropriate technologies and frameworks
Design system components and their interactions
Ensure scalability, reliability, and security
Test and validate the system before deployment
Q51. Give a solution to store newspapers of a company
Store newspapers of a company
Create a database to store newspaper information
Use a unique identifier for each newspaper
Include fields for date, title, author, and content
Implement a search function for easy retrieval
Consider implementing a backup system for data security
Q52. Aws services and how to create and launch EC2 instances
AWS services include EC2 for virtual servers. To create and launch EC2 instances, use the AWS Management Console, CLI, or SDK.
Access the AWS Management Console and navigate to the EC2 dashboard
Click on 'Launch Instance' to choose an Amazon Machine Image (AMI), instance type, and configure instance details
Review and launch the instance, selecting key pair for SSH access
Use AWS CLI or SDK to create and launch EC2 instances programmatically
Database design for a ticket booking system like BookMyShow involves tables for users, events, bookings, and venues.
Create a table for users with columns like user_id, name, email, phone_number, etc.
Create a table for events with columns like event_id, name, date, time, venue_id, etc.
Create a table for bookings with columns like booking_id, user_id, event_id, booking_date, status, etc.
Create a table for venues with columns like venue_id, name, address, capacity, etc.
Use relat...read more
Q54. 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.
Q55. What is difference between Python and Node.JS?
Python is a general-purpose language while Node.JS is a JavaScript runtime environment.
Python is used for web development, data analysis, artificial intelligence, and scientific computing.
Node.JS is used for building scalable network applications and real-time web applications.
Python is slower than Node.JS in terms of performance.
Python has a larger standard library than Node.JS.
Python is easier to learn and has a simpler syntax than Node.JS.
Q56. What is the difference between SQL and NoSQL?
SQL is a relational database management system while NoSQL is a non-relational database management system.
SQL databases are table-based while NoSQL databases are document-based, key-value pairs, graph databases, or column-based.
SQL databases are structured while NoSQL databases are unstructured.
SQL databases use SQL (Structured Query Language) for querying and managing data while NoSQL databases use different query languages like MongoDB uses JSON-like documents.
SQL databases...read more
Q57. Implement a min stack using a single stack
Implement a min stack using a single stack
Create a stack to hold the elements and another stack to hold the minimum values
When pushing an element, check if it's smaller than the current minimum and push it to the minimum stack if it is
When popping an element, check if it's the current minimum and pop it from the minimum stack if it is
To get the minimum value, return the top element of the minimum stack
Q58. Monolith vs Microservices difference? which is better and why?
Monolith is a single, large application while microservices are smaller, independent services. Microservices are better for scalability and flexibility.
Monolith is a single, large application where all components are tightly coupled. Microservices are smaller, independent services that communicate with each other through APIs.
Monoliths are easier to develop and deploy initially but become harder to maintain and scale as they grow. Microservices allow for better scalability an...read more
Q59. 1. Describe your projects in depth. 2. Database schema design of Codechef. 3. SQL queries related to that. 4. Questions on CN
Answering questions on projects, database schema design of Codechef, SQL queries, and CN.
Projects involved developing a web application for managing employee data and a mobile app for tracking expenses.
Database schema design of Codechef involved creating tables for users, problems, submissions, and contests.
SQL queries related to Codechef included retrieving user details, problem submissions, and contest rankings.
Questions on CN covered topics such as network protocols, OSI m...read more
Q60. Q1 - Pre order traversal without recursion. Q2 - Reverse a linked list.
Q1 - Pre order traversal without recursion. Q2 - Reverse a linked list.
Q1: Use a stack to keep track of nodes. Start with root, push it to stack. Pop top node, print it, push right and left children to stack.
Q2: Traverse the linked list and change the direction of the pointers. Set the head of the reversed list as the last node of the original list.
Q61. 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
Q62. Q1 - Sort the string according to frequency of characters
Sort a string based on the frequency of its characters.
Create a hash table to store the frequency of each character.
Sort the characters based on their frequency using a sorting algorithm.
Reconstruct the string based on the sorted characters and their frequency.
Q63. Difference between a semaphore and mutex
Semaphore is used to control access to a resource with limited capacity while mutex is used to synchronize access to a shared resource.
Semaphore allows multiple threads to access a resource simultaneously up to a certain limit while mutex allows only one thread to access a shared resource at a time.
Semaphore can be used to solve the producer-consumer problem while mutex can be used to solve the critical section problem.
Semaphore can be binary or counting while mutex is always...read more
Q64. What are threads? What is the purpose?
Threads are lightweight processes that enable multitasking within a single process.
Threads allow multiple tasks to be executed concurrently within a single process.
They share the same memory space and resources of the parent process.
Threads can improve performance by utilizing available CPU resources more efficiently.
Examples include web servers handling multiple requests simultaneously and video games rendering graphics while processing user input.
Q65. What are CORS? How to handle them?
CORS stands for Cross-Origin Resource Sharing. It is a security feature implemented in web browsers to restrict web pages from making requests to a different domain.
CORS is used to prevent malicious websites from accessing sensitive data from other websites.
To handle CORS, the server needs to include specific headers in the response to allow the browser to make requests from a different domain.
The most common header used to handle CORS is 'Access-Control-Allow-Origin'. It spe...read more
Q66. 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.
Q67. Why you want to join Hashedin?
I am excited to join Hashedin because of its reputation for innovative solutions and collaborative work culture.
Hashedin has a strong track record of delivering cutting-edge technology solutions for clients across various industries.
I am impressed by the company's focus on collaboration and teamwork, which aligns with my own work style.
I am excited about the opportunity to work with a talented and diverse team of professionals at Hashedin.
Hashedin's commitment to employee gro...read more
Q68. 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.
Designing an app similar to Practo for healthcare services.
Create user-friendly interface for patients to book appointments with doctors
Implement search functionality for patients to find doctors based on specialty, location, availability, etc.
Include features for doctors to manage their schedules, patient records, and prescriptions
Incorporate secure payment gateway for online consultations and appointments
Develop a rating and review system for patients to provide feedback on...read more
Q70. What is sharding and how it can be implemented.
Sharding is a database partitioning technique to improve performance and scalability.
It involves dividing a large database into smaller, more manageable parts called shards.
Each shard contains a subset of the data and can be stored on a separate server.
Sharding can be implemented using different strategies such as range-based, hash-based, or round-robin.
It requires careful planning and coordination to ensure data consistency and availability.
Examples of sharding in popular da...read more
Q71. High Level Design for a Reddit type application
A Reddit-like application for sharing and discussing content
User authentication and authorization
Post creation and voting system
Commenting system
Subreddit creation and management
Search functionality
Real-time updates using websockets
Q72. Why should one use Node.JS?
Node.js is a powerful and efficient server-side JavaScript runtime environment.
Node.js is fast and scalable, making it ideal for building real-time applications.
It uses an event-driven, non-blocking I/O model, which makes it lightweight and efficient.
Node.js has a large and active community, with many useful libraries and modules available.
It allows for easy sharing of code between the server and client, using JavaScript on both sides.
Node.js is cross-platform, meaning it can...read more
Q73. 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
Q74. Take several types of data in an array and print only numbers from there - Programming Hands-on (Java)
Q75. Why Hashedin
Hashedin is a leading software development company with a focus on delivering innovative solutions.
Expertise in cutting-edge technologies
Proven track record of successful project delivery
Strong emphasis on client satisfaction
Collaborative and agile approach to development
Dedicated team of experienced professionals
Q76. What are OS processes?
OS processes are instances of a program that are being executed by the operating system.
Processes are managed by the operating system's scheduler.
Each process has its own memory space and system resources.
Processes can communicate with each other through inter-process communication (IPC).
Examples of processes include web browsers, media players, and text editors.
Q77. 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.
Q78. 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
Q79. 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
Q80. Why HashedIn ? How was your interview experience? Have will you handle difference of opinion With a team ? Share an experience where you resolved a critical issue ?
I chose HashedIn for its innovative projects and collaborative work culture.
Innovative projects attracted me to HashedIn
I value the collaborative work culture at HashedIn
I appreciate the opportunities for growth and learning at HashedIn
I was impressed by the team's technical expertise during the interview process
Q81. Performance Testing by Postman? Status codes, usage of PUT & POST
Q82. Explain the deadlock condition
Deadlock is a situation where two or more processes are unable to proceed because they are waiting for each other to release resources.
Occurs in multi-process systems
Processes hold resources and wait for others to release resources
Can lead to system freeze or crash
Prevented by proper resource allocation and scheduling
Example: Two trains on a single track, each waiting for the other to pass first
Q83. 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.
Q84. Maximum subarray sum Length of Binary tree Merge Two sorted Linked List
The maximum subarray sum problem involves finding the contiguous subarray within a one-dimensional array of numbers which has the largest sum.
Use Kadane's algorithm to find the maximum subarray sum efficiently.
Consider all possible subarrays and calculate their sums to find the maximum.
Dynamic programming can be used to solve this problem efficiently.
Example: For array [-2, 1, -3, 4, -1, 2, 1, -5, 4], the maximum subarray sum is 6 (from index 3 to 6).
Q85. Minimum Deletions to make a String Palindrome
Q86. Open W3School and find Xpath for search button manually - Hands-on
Q87. Low Level Design for Authentication
Low level design for authentication
Define authentication requirements
Choose appropriate authentication mechanism
Design authentication flow
Implement secure storage of credentials
Consider multi-factor authentication
Include error handling and logging
Q88. 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
Q89. 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
Q90. Count occurence of element in an array
Count occurrence of element in an array of strings
Use a loop to iterate through the array
Use a dictionary to store the count of each element
Increment the count for each element encountered
Q91. System design of snake and ladder
System design for the game of Snake and Ladder
Create a board with 100 cells and mark the positions of snakes and ladders
Implement a player class with a current position on the board
Roll a dice to move the player and check for snakes and ladders
Keep track of player scores and winner at the end of the game
Q92. How you can handle the pressure
I handle pressure by prioritizing tasks, staying organized, seeking support when needed, and practicing stress-relief techniques.
Prioritize tasks based on deadlines and importance
Stay organized with to-do lists and calendars
Seek support from colleagues or supervisors when feeling overwhelmed
Practice stress-relief techniques such as deep breathing or exercise
Maintain a positive attitude and focus on problem-solving
Q93. Different types of Waits in Selenium? POM ?Relative/Absolute Xpath
Q94. What are assymptotic notation
Asymptotic notation is a way to describe the performance of an algorithm in terms of its input size.
Asymptotic notation is used to analyze the efficiency of algorithms by focusing on how they behave as the input size approaches infinity.
Common notations include O (Big O), Ω (Big Omega), and Θ (Big Theta), which represent the worst-case, best-case, and average-case time complexity respectively.
For example, if an algorithm has a time complexity of O(n^2), it means that the algo...read more
Q95. How do you handle Spark Memory management
Spark Memory management involves configuring memory allocation, monitoring memory usage, and optimizing performance.
Set memory allocation parameters in Spark configuration (e.g. spark.executor.memory, spark.driver.memory)
Monitor memory usage using Spark UI or monitoring tools like Ganglia
Optimize performance by tuning memory allocation based on workload and cluster resources
Use techniques like caching and persistence to reduce memory usage and improve performance
Q96. 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
Q97. 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.
Q98. 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.
Q99. 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.
Q100. System design + Projects that you worked on
I have experience in designing and implementing scalable systems for various projects.
Designed and implemented a microservices-based architecture for a healthcare platform
Developed a distributed system for real-time data processing using Apache Kafka and Spark
Optimized database schema and queries for a high-traffic e-commerce website
Implemented caching and load balancing strategies for a social media platform
Designed and developed a RESTful API for a mobile application
Top HR Questions asked in Nuvama Wealth Management
Interview Process at Nuvama Wealth Management
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month