Filter interviews by
2 JS logic based problems
Top trending discussions
I applied via Company Website and was interviewed before Jun 2021. There were 2 interview rounds.
I applied via Campus Placement and was interviewed before Nov 2021. There were 3 interview rounds.
Numerical and logical aptitude test
There are 5 rounds on datastructure and algorithm
posted on 16 Sep 2021
I appeared for an interview before Sep 2020.
Round duration - 1 hour
Round difficulty - Medium
You are provided with an integer array ARR
of length 'N'. Your objective is to determine the first missing positive integer using linear time and constant space. T...
Find the smallest positive integer missing from an array of integers.
Iterate through the array and mark positive integers as visited by changing the sign of the corresponding index.
After marking all positive integers, iterate again to find the first positive integer with a positive value.
Return the index of the first positive integer found plus one as the answer.
Tip 1 : During an interview, never say that you don't know the answer, keep trying and the interviewer will help you himself.
Tip 2 : Keep speaking up the approach going on in your mind, they want to judge your approaches much more than whether the answer is right or wrong.
Tip 3 : Be confident, cheerful, keep smiling, and continue making eye contact with the interviewer, this leaves a positive impression.
Tip 4 : Search and practice questions specific to the company, questions are repeated several times.
Tip 5 : A sound knowledge of Microsoft Azure Services and cloud computing will be an icing on the cake, and increase your chances to get selected.
Tip 6 : Keep giving contests on coding platforms, it will help you to stay motivated and check your stand.
Tip 7 : Keep a daily goal of number of questions instead of the time duration.
Tip 1 : Everything mentioned on the resume should be thoroughly known to you since if they catch you being dishonest, pretty good coding skills also might not help.
Tip 2 : Have projects related to the same field you are trying to apply for mentioned in your resume, this shows you are already experienced in the field.
Tip 3 : Adding references of some experienced people of the same field might help you gain their trust.
Tip 4 : Do not keep your resume too long, and do not mention irrelevant details, keep it short and crisp.
Tip 5 : Some experience in the field of operations and management or some positions of responsibility will really help you score extra points since it shows you have leadership qualities and are familiar with the market along with super coding skills.
posted on 14 Sep 2021
I appeared for an interview in Sep 2020.
Round duration - 45 Minutes
Round difficulty - Easy
Had some small chit-chat regarding how Work from Home is going on for him and me. Later he introduced himself and asked the same.
Coming to technical questions, he asked me the algorithm and also asked me to code the questions mentioned below. Discussed the time complexities and edge cases.
You are given a N x M
matrix of integers. Your task is to return the spiral path of the matrix elements.
The first line contains an integer 'T' which denotes the nu...
The task is to return the spiral path of elements in a given matrix.
Iterate over the matrix in a spiral path by keeping track of the boundaries.
Print the elements in the spiral path as you traverse the matrix.
Handle cases where the matrix is not a square matrix separately.
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 anoth...
Group anagrams in an array of strings based on character frequency.
Create a hashmap to store sorted strings as keys and corresponding anagrams as values.
Iterate through the input strings, sort each string, and add it to the hashmap.
Return the values of the hashmap as grouped anagrams.
Round duration - 45 Minutes
Round difficulty - Medium
This round started without any introduction, and he directly jumped into the question. Asked me about the algorithm, and later coded it and ran it. And then he asked me to optimize it. Finally, he asked me if I had any questions.
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 ...
Design a 2-player Tic-Tac-Toe game on an N x N grid where players take turns placing their marks, and the first player to get N marks in a row wins.
Implement a function move(row, col, player) to handle each player's move and check for a win condition.
Keep track of the board state and update it after each move.
Check for winning conditions horizontally, vertically, and diagonally after each move.
Return the result (0 for ...
Tip 1 : Solve as many questions as you can
Tip 2 : Practice Quantitate aptitude.
Tip 3 : Don't lie on your resume.
Tip 1 : Have some good projects.
Tip 2 : Don't lie on your resume.
posted on 16 Sep 2021
I appeared for an interview in Nov 2020.
Round duration - 90 minutes
Round difficulty - Medium
This round was conducted in Hackerrank portal for a total duration of 95 minutes and was divided into 4 sections.
1st Section : Aptitude Section : 14 questions , 28 minutes
2nd Section : Technical Section : 12 questions , 17 minutes
3rd Section :1 coding Questions : 20 minutes+30 minutes
You are provided with an array ARR
of positive integers. Each integer represents the number of liters of water in a bucket. The goal is to make the liters of water in ...
Given an array of water buckets, find the minimum liters of water to remove to make all buckets contain the same amount of water.
Iterate through the array to find the most common amount of water in the buckets.
Calculate the total liters of water that need to be removed to equalize all buckets to the most common amount.
Return the total liters of water to be removed.
You need to determine all possible paths for a rat starting at position (0, 0) in a square maze to reach its destination at (N-1, N-1). The maze is represented as an N*N ma...
Find all possible paths for a rat in a maze from source to destination.
Use backtracking to explore all possible paths in the maze.
Keep track of visited cells to avoid revisiting them.
Explore all possible directions (up, down, left, right) from each cell.
Add the current direction to the path and recursively explore further.
If the destination is reached, add the path to the list of valid paths.
Round duration - 120 Minutes
Round difficulty - Medium
This was an Online F2F Technical Round conducted on CodePair : Hackerrank. So, Basically You have to Run and Submit ( Pass All Test cases) in the Interview Round also (Like normal Coding Test) in Codepair : Hackerrank & along with that You should have to explain your Code and Approach to the Interviewers.
The Interviewers were helpful and didn't hesitate in giving hints.
Timing - 10:00 A.M to 12:00 P.M
In this problem, you have a one-dimensional garden of length 'N'. Each position from 0 to 'N' has a fountain that can provide water to the garden up to a certain range...
Find the minimum number of fountains to activate to water the entire garden.
Iterate through the array to find the coverage of each fountain.
Keep track of the farthest coverage reached by activating fountains.
Activate the fountain that covers the farthest point not yet covered.
Repeat until the entire garden is watered.
You are provided with a list of 'transactions' involving 'n' friends who owe each other money. Each entry in the list contains information about a receiver, sender, and the tran...
Minimize cash flow problem among friends by optimizing transactions.
Create a graph where nodes represent friends and edges represent transactions.
Calculate net amount each friend owes or is owed by summing up all transactions.
Use a recursive algorithm to minimize cash flow by settling debts between friends.
Update the graph and repeat the process until all debts are settled.
Round duration - 120 Minutes
Round difficulty - Hard
A lot of Variants based on Constraints were asked in this Round. They will ask you to write the final code for every question before Submitting it(run all test cases) so you won’t get any hints after running test cases in the IDE. ( So don’t Submit your code before dry running it on a lot of Test Cases on pen & paper , they allow to use pen & blank paper at the time of Interviews) .The Interviewers tried to trick in case of time complexities even if you gave the best one. So try to be confident.
Imagine you are Harshad Mehta's friend, and you have been given the stock prices of a particular company for the next 'N' days. You can perform up to two buy-and-sell ...
The task is to determine the maximum profit that can be achieved by performing up to two buy-and-sell transactions on a given set of stock prices.
Iterate through the array of stock prices and keep track of the maximum profit that can be achieved by buying and selling at different points.
Maintain variables to store the maximum profit after the first transaction, the maximum profit after the second transaction, and the m...
Round duration - 30 minutes
Round difficulty - Easy
This was HR Round. The HR was friendly and asked basic questions.
The timing was 2:00 PM to 2:30 PM.
Tip 1 : Make sure that you are thorough with CS concepts beforehand.
Tip 2 : Even when you are explaining the approach to a question, try to parallelly think about how you would code it.
Tip 3 : Read the previous interview experiences. It would give a fair idea of the kind of questions one should expect.
Tip 4 : For position like Microsoft SDE-1, practicing medium difficulty level coding questions would be the way to go.
Tip 5 : Practice atleast 200 questions from coding platforms like CodeZen, LeetCode, Interviewbit as they contain common interview questions.
Tip 1 : Mention Projects and past work experience as it sets good impression.
Tip 2 : Keep your resume up to date for the role you are applying.
Tip 3 : Try to keep your resume of 1 Page.
posted on 15 Sep 2021
I appeared for an interview before Sep 2020.
Round duration - 90 minutes
Round difficulty - Easy
This round was the online coding test conducted on the platform Mettl. The languages allowed were C, C++, Java and Python. There were three questions. One was of graphs (Depth-first search), other was a big integer problem and the third was a string problem.
You are provided with a graph consisting of N
vertices, numbered from 1 to N
, and M
edges. Your task is to color the graph using two colors, Blue and Red, such that no two...
Given a graph with vertices and edges, determine if it can be colored using two colors without adjacent vertices sharing the same color.
Check if the graph is bipartite using graph coloring algorithm like BFS or DFS.
If the graph is bipartite, return 'Possible' with a valid coloring assignment.
If the graph is not bipartite, return 'Impossible'.
Write a program to perform basic string compression. For each character that repeats consecutively more than once, replace the consecutive duplicate occurrences with t...
Write a program to compress a string by replacing consecutive duplicate characters with the character followed by the number of repetitions.
Iterate through the string and count consecutive occurrences of each character
Append the character and its count to a new string
Return the compressed string if it is shorter than the original, else return the original string
Handle edge cases like single characters or when compresse...
Round duration - 60 minutes
Round difficulty - Easy
This was a pen and paper subjective interview round. You were expected to write full code on paper. Make sure you use proper names for the variables and write comments explaining very clearly what the code does. Also, try writing code in good handwriting which can be understood by the interviewer.
Count total palindromic substrings in a given string.
Iterate through each character in the string and consider it as the center of a palindrome. Expand outwards to find all palindromic substrings.
Use dynamic programming to efficiently check if a substring is a palindrome.
Consider both odd-length and even-length palindromes.
Example: Input 'ababa', output 7 (a, b, a, b, a, aba, aba)
Round duration - 45 minutes
Round difficulty - Easy
The interview took place in the morning and the interviewer was very friendly.
Let A[0 ... n-1]
be an array of n
distinct positive integers. An inversion of A
is a pair of indices (i, j)
such that i < j
and A[i] > A[j]
. Given an integer array...
Count the number of inversions in an array of distinct positive integers.
Use merge sort algorithm to count inversions efficiently.
Divide the array into two halves and recursively count inversions in each half.
Merge the two sorted halves while counting split inversions.
Time complexity can be optimized to O(n log n) using merge sort.
Example: For input A = [2, 4, 1, 3, 5], the output should be 3.
Transform a given binary tree into a sum tree where each node is replaced by the sum of its immediate children's values. Leaf nodes should be replaced with 0. Then, p...
Convert a binary tree into a sum tree by replacing each node with the sum of its children's values, and return the preorder traversal.
Traverse the tree recursively and replace each node with the sum of its children's values
Leaf nodes should be replaced with 0
Perform a preorder traversal on the transformed sum tree to get the final result
Round duration - 30 minutes
Round difficulty - Easy
The HR Interview round was held in the morning and it was right after my technical interview.
Just be confident during interview and if you are stuck in between any question, then ask for a hint from the interviewer. The practice is key for success, so practice hard for Data Structures and Algorithms coding problems on Coding ninjas as it is the best platform for coding. Also you may practice on Geeks For Geeks or any other interview portal.
Application resume tips for other job seekersMention all internships which you have done, as it increases your chances of shortlisting your resume. Also just write that skills which you are pretty confident about.
Final outcome of the interviewSelectedposted on 16 Sep 2021
I appeared for an interview before Sep 2020.
Round duration - 90 minutes
Round difficulty - Easy
This round consists of 3 coding questions with a total time limit of 90 minutes. The first two questions were of easy level and the third question was of medium level. No two candidates had the same set of questions, the distribution of questions was random. The test was conducted on mettl platform with both audio and video on for monitoring on the candidate.
Given a stream of integers, calculate and print the median after each new integer is added to the stream.
Output only the integer part of the median.
N = 5
Stre...
Calculate and print the median after each new integer is added to the stream.
Use two heaps - a max heap to store the smaller half of the numbers and a min heap to store the larger half.
Keep the sizes of the two heaps balanced to efficiently calculate the median.
If the total number of elements is odd, the median will be the top element of the max heap.
If the total number of elements is even, the median will be the avera...
You are given 'n' fruit trees planted along a road, numbered from 0 to n-1. Each tree bears a fruit type represented by an uppercase English alphabet. A Ninja walking ...
The Ninja must collect fruits from trees in consecutive order, maximizing the number of fruits in two baskets.
Iterate through the trees while keeping track of the types of fruits collected in each basket.
Use a sliding window approach to find the maximum number of fruits collected.
Keep track of the count of each fruit type encountered to handle the condition of only two types of fruits in each basket.
You are given D
dice, each having F
faces numbered from 1 to F
. The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up num...
The task is to determine the number of possible ways to roll all the dice such that the sum of the face-up numbers equals the given 'target' sum.
Use dynamic programming to solve the problem efficiently.
Create a 2D array to store the number of ways to achieve each sum with the given number of dice.
Iterate through the dice and faces to calculate the number of ways to reach each sum.
Return the result modulo 10^9 + 7.
Optim...
Round duration - 50 miutes
Round difficulty - Medium
This was my first interview and I was a bit nervous. The interview was conducted on Microsoft Team. He told me to share my screen and write the pseudo code on notepad. The interviewer was very friendly and also gave me hints for the question. However, he mostly focused on optimization of the code. At the end of the question, few questions related to Operating Systems were asked.
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 anoth...
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 arrays of strings
Round duration - 45 minutes
Round difficulty - Medium
The second round consisted questions related to concepts of object oriented programming and databases. At the end of the interview he asked me to explain any one good project. The interview lasted for 45 minutes. The interviewer was friendly and good.
You are given a sequence of numbers, ARR
. Your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
The Merge Sort...
Implement Merge Sort algorithm to sort a given sequence of numbers in non-descending order.
Divide the input array into two halves recursively until each array has only one element.
Merge the sorted halves to produce a completely sorted array.
Time complexity of Merge Sort is O(n log n).
Round duration - 30 minutes
Round difficulty - Easy
This was my last round and I was a bit tensed. It was an HR round. The interviewer was very professional. He discussed and asked questions about my various achievements, my interests apart from the technical field and also asked about my projects. I made sure to answer all the questions confidently and calmly.
Tip 1 : Having a grip over Data Structures and Algorithms is very important. Have your concepts crystal clear and then pick one coding platform( for example, leetcode, InterviewBit, CodeZen, GeeksForGeeks) and try to practice around 7-10 questions everyday with varying difficulty and different topics. I completed around 200+ questions on leetcode, 200+ questions on geeks for geeks and around 30-40 problems on InterviewBit.
Tip 2 : After writing code for a particular question try to analyze its time and space complexity. Think about how you can optimize your code further. Also refer to the editorials and compare your solution with it. Interviewers ask a lot about further code optimization. Hence, instead of trying to solve more and more problems, try to analyze a question completely and understand the concept behind them.
Tip 3 : Along with coding, study about OOPS. Coding Ninja's Data Structures and Algorithms course helped a lot in preparing the OOPS concepts specifically. Also, OS and DBMS must also be studied. You can refer to GeekForGeeks articles for these topics.
Tip 4 : Keep participating in coding contests. It helps you increase your speed. I participated in almost every Leetcode Weekly Contest which helped me keeping the track of my improvement.
Tip 1 : Do not fake any skills, projects or achievements. The interviewer gets to know about it by asking questions to you.
Tip 2 : You do need to have a long list of projects. Any 1 good project with proper knowledge of it will also do good. Similarly, you do need to have many skills to be listed down. Few skills but with proper knowledge is great.
Tip 3 : Try to write achievements which proves your technical skills, communication skills, leadership quality or teamwork.
I appeared for an interview before Nov 2020.
Round duration - 45 minutes
Round difficulty - Medium
The interview was with a Korean employee.
Given an undirected graph with V vertices and E edges, your task is to find all the bridges in this graph. A bridge is an edge that, when removed, increases the number of...
Find all the bridges in an undirected graph.
Use Tarjan's algorithm to find bridges in the graph.
A bridge is an edge whose removal increases the number of connected components.
Check for bridges by removing each edge and checking the number of connected components.
Return the edges that are bridges in non-decreasing order.
Round duration - 45 Minutes
Round difficulty - Medium
Interviewer was an Indian employee.
You are provided with a string STR
of length N
. The goal is to identify the longest palindromic substring within this string. In cases where multiple palind...
Identify the longest palindromic substring in a given string.
Iterate through the string and expand around each character to find palindromes
Keep track of the longest palindrome found
Return the longest palindrome with the smallest start index
Round duration - 45 Minutes
Round difficulty - Hard
Interviewer was an Indian employee.
You are provided with a sorted dictionary (by lexical order) in an alien language. Your task is to determine the character order of the alien language from this dictiona...
Given a sorted alien dictionary in an array of strings, determine the character order of the alien language.
Iterate through the words in the dictionary to build a graph of character dependencies.
Perform a topological sort on the graph to determine the character order.
Return the character order as a list of characters.
Round duration - 45 Minutes
Round difficulty - Hard
Interviewer was an Indian employee.
The Ninja has a robot which navigates an infinite number line starting at position 0 with an initial speed of +1. The robot follows a set of instructions which includes ‘A’ (Acceler...
Determine the minimum length of instruction sequence for a robot to reach a given target on an infinite number line.
Start at position 0 with speed +1, update position and speed based on 'A' and 'R' instructions
For each test case, find the shortest sequence of instructions to reach the target
Consider both positive and negative positions for the robot
Tip 1 : Do competitive coding in 1st and 2nd year.
Tip 2 : Practice basic questions before starting complex problem.
Tip 3 : Start doing mock interviews from the end of 5th semester. It gives a lot of confidence.
Tip 1 : Adding competitive programming ranks add value.
Tip 2 : You should have some good project which you can explain nicely.
posted on 25 May 2022
I appeared for an interview before May 2021.
Round duration - 60 Minutes
Round difficulty - Medium
It was a hiring drive for women. Interviewer was experienced person.
Given the preorder and inorder traversal sequences of a binary tree, your task is to construct the binary tree using these traversals.
Th...
Yes, it is possible to achieve a solution with O(N) time complexity using a hashmap to store the indices of elements in the inorder traversal.
Use a hashmap to store the indices of elements in the inorder traversal for quick lookup.
Recursively build the binary tree by selecting the root node from the preorder traversal and finding its index in the inorder traversal.
Divide the inorder traversal into left and right subtre...
Round duration - 60 Minutes
Round difficulty - Medium
You are presented with a list of financial transactions among ‘n’ friends, where each transaction specifies who pays whom and how much. The objective is to minimize the cash...
The problem involves minimizing cash flow among friends by reorganizing debts through direct transfers or reducing total transactions.
Given a list of financial transactions among 'n' friends, where each transaction specifies who pays whom and how much.
Objective is to minimize the cash flow among the friends by reorganizing debts through direct transfers or reducing total transactions.
Output a 2-D matrix showing the opt...
Round duration - 60 Minutes
Round difficulty - Medium
Given a positive integer N
, your task is to determine the number of strings of length N
that can be created using only the characters 'a', 'b', and 'c'. The strings must a...
The problem involves determining the number of strings of length N that can be created using only the characters 'a', 'b', and 'c', with constraints on the number of 'b' and 'c' allowed.
Use dynamic programming to count the number of valid strings for each length N.
Consider the constraints on the number of 'b' and 'c' allowed in each string.
Implement a function to calculate the result modulo 1000000007.
For N = 2, valid ...
Round duration - 60 Minutes
Round difficulty - Medium
Ninja is exploring the data structure of trees and while learning about Binary Search Trees (BST), she created her own. However, she unknowingl...
Identify and reverse the swap in a Binary Search Tree to recover the original structure.
Identify the two nodes that are swapped in the Binary Search Tree.
Swap the two nodes to restore the Binary Search Tree integrity.
Ensure that the left subtree of a node contains only nodes with data less than the node's data, and the right subtree contains only nodes with data greater than the node's data.
Round duration - 60 Minutes
Round difficulty - Medium
Hiring manager round
Given the schedule of N meetings with their start time Start[i]
and end time End[i]
, you need to determine which meetings can be organized in a single meeting room such ...
Given N meetings with start and end times, find the maximum number of meetings that can be organized in a single room without overlap.
Sort the meetings based on their end times.
Iterate through the sorted meetings and select the first meeting that doesn't overlap with the previous one.
Repeat the process until all meetings are considered.
Return the selected meetings in the order they are organized.
Tip 1 : Practice leetcode
Tip 2 : Study low level and high level design properly by working on some real examples
Tip 1 : Be concrete on the projects and experience
Tip 2 : Mention all languages and frameworks you have worked on so far
based on 1 interview experience
Software Engineer
6
salaries
| ₹9.5 L/yr - ₹25.8 L/yr |
Software Developer
5
salaries
| ₹6.5 L/yr - ₹20 L/yr |
Engineering Manager
5
salaries
| ₹70 L/yr - ₹85 L/yr |
Full Stack Developer
5
salaries
| ₹9 L/yr - ₹24 L/yr |
Software Development Engineer 1
5
salaries
| ₹10 L/yr - ₹12 L/yr |
24/7 Customer
Microsoft Corporation
SAP