Amazon
600+ Kangeya Labs Interview Questions and Answers
You are given an array of positive integers. Find the GCD(Greatest Common Divisor) of a pair of elements such that it is maximum among all possible pairs. GCD(a, b) is the ...read more
You have been given a singly linked list in which nodes are present in increasing order. Your task is to construct a Balanced Binary Search Tree with the same data elements as ...read more
You have been given a Snake and Ladder Board with 'N' rows and 'N' columns with the numbers written from 1 to (N*N) starting from the bottom left of the board, and alternating direction each row...read more
You have been given a binary tree with an integer value associated to each node. You are supposed to choose a subset of these nodes such ...read more
You have been given an array/list 'ARR' consisting of 'N' integers. Your task is to find the majority element in the array. If there is no majority element present, print -1.
Note:
A majority el...read more
Given an undirected graph of V vertices and E edges. Your task is to find all the bridges in the given undirected graph. A bridge in any graph is defined as an edge which, when removed, makes...read more
You are given a positive integer ‘N’ denoting the number of tasks you need to finish. You can directly start performing any task, but some tasks have some prerequisites, i.e. to perform some ta...read more
You have been given a Binary Search Tree of integers. You are supposed to convert it to a greater sum tree such that the value of every node in the given BST is replaced with ...read more
You have been given an array/list ARR of length N consisting of 0s and 1s only. Your task is to find the number of subarrays(non-empty) in which the number of 0s and 1s are equal....read more
Given a binary tree and the value of two nodes, find the distance between the given two nodes of the Binary Tree.
Distance between two nodes is defined as the minimum numb...read more
You have been given a binary tree of 'N' unique nodes and a Start node from where the tree will start to burn. Given that the Start node will always exist in the tree, your task is to print the...read more
Q212. Given an Infix expression, how to evaluate its answer
Infix expression can be evaluated using the concept of operator precedence and associativity.
Convert the infix expression to postfix expression using stack data structure
Evaluate the postfix expression using stack data structure
Use operator precedence and associativity rules to determine the order of evaluation
Parentheses can be used to override the default order of evaluation
You have been given a non-empty grid consisting of only 0s and 1s. You have to find the number of islands in the given grid.
An island is a group of 1s (representing land) connected horizontall...read more
You are given an unsorted array/list 'ARR' of 'N' integers. Your task is to return the length of the longest consecutive sequence.
The consecutive sequence is in the form ['NUM', 'NU...read more
You are given an array/list ‘BINARYNUMS’ that consists of ‘N’ distinct strings which represent all integers from 0 to N in binary representation except one integer. This integer between 0 to ‘N’ w...read more
Design and implement a data structure which supports the following operations:
insert(X): Inserts an element X in the data structure and returns true if the ...read more
You have been given a Binary Search Tree of integers. You are supposed to convert it to a greater sum tree such that the value of every node in the given BST is replaced with th...read more
You are given a sorted array of 'N' integers. You have to generate the power set for this array where each subset of this power set is individually sorted.
A set is a well-defined collection of distinc...read more
You have been given an array of integers 'ARR' and an integer ‘K’. You need to find the first negative integer in each window of size ‘K’.
Note :
If a window do...read more
You are given a positive integer ‘N’. Your task is to find the total number of ‘1’ in the binary representation of all the numbers from 1 to N.
Since the count of ‘1’ can be huge, you are required...read more
A fishmonger wants to bring his goods from port to the market. On his route, he has to traverse an area with many states. He has to pay a toll at each border.
He is a good businessman. He wants to cho...read more
You are given two strings STR1 and STR2. You need to check whether STR2 can be formed from the characters of STR1. Both the strings can ...read more
You are given an array 'ARR' of integers of length N. Your task is to find the next smaller element for each of the array elements.
Next Smaller Element for an array element is the first ele...read more
You have been given a sorted (lexical order) dictionary of an alien language. Write a function that finds the order of characters in the alien language. This dictionary will be given to you in ...read more
You are a student of Netaji Subhas Institute of Technology. You have to take ‘N’ number of courses labelled from 1 to N to complete your B.Tech Degree.
Some courses may have prerequisites, for ex...read more
You are given a Directed Acyclic Graph (DAG) with ‘E’ edges and ‘V’ vertices. A DAG is a type of graph with no directed cycles.
You have been given a source vertex ‘S’. Your task is to find the dist...read more
You are having a stack "ARR" of size 'N+1', your task is to delete the middlemost element so that the size of resulting stack is 'N'.
A stack is a linear data structure where both i...read more
You are given the root node of a binary tree consisting of ‘N’ nodes. Your task is to return its postorder traversal. The postorder traversal of a binary tree is defined as a process of trav...read more
You are given a positive integer N. Return a list of integers of size 2N containing all the integers from 1 to N (both inclusive) twice arranged according to Langford pairing. If no such pairing...read more
Q230. How to implement word suggestions like that in Eclipse
Word suggestions in Eclipse can be implemented using algorithms like Trie or N-gram models.
Use Trie data structure to store the dictionary of words
Implement auto-complete feature using Trie
Use N-gram models to suggest words based on context
Train the N-gram model on a large corpus of text data
Combine both approaches for better accuracy
Consider user's typing speed and frequency of words for better suggestions
What is ACID, explain with examples. Questions on join queries.
You're given a sorted array that has now been rotated 'K' times, which is unknown to you. Rotation here means that every element is shifted from its position to right in each rotation and the last ...read more
You are given the head node of a singly linked list ‘head’. Your task is to modify the linked list in such a way that all the even valued nodes appear before the all...read more
You’re given an array/lits 'ARR' of size 'N' and an integer 'K'. Your task is to split 'ARR' into 'K' sub-arrays such that the maximum sum achieved from the 'K' subarrays ...read more
What is javascript, its uses, server client problems.
You have been given the Inorder Traversal and Level Order Traversal of a Binary Tree of integers. Your task is to calculate the height of the Binary tree without constructing it.
The he...read more
Kevin has ‘N’ buckets each consisting of some fruits. Kevin wants to eat at least ‘M’ fruits and so, he decided to set a marker (integer) as maximum as possible such that if he eats “number ...read more
‘N’ people are standing in a circle numbered from ‘1’ to ‘N’ in clockwise order. First, the person numbered 1 will proceed in a clockwise direction and will skip K-1 persons including itself and will ki...read more
You are given two arbitrary binary trees consisting of N and M number of nodes respectively, your task is to check whether the two trees are mirror of each other or not.
Two trees a...read more
You’re given a square matrix 'MAT' of order N. Your task is to find the number of non-empty sub-matrices such that the sum of all the elements inside the submatrix is zero.
NOTE:
1. T...read more
Checking the basic communtication skills and confidence.
Ninja has been given a matrix ‘MAT’ of integers having size ‘N’ x ‘M’ i.e. N rows and M columns. Ninja has to find the maximum sum submatrix in it. In other words, he has to find the maximum sum ov...read more
Q245. Wich programming languages do you use in your work
I primarily use Java and Python in my work as a Customer Service Associate.
I use Java for developing and maintaining our internal tools and systems.
I use Python for data analysis and automation tasks.
I also have experience with SQL for querying databases.
Additionally, I have some knowledge of HTML, CSS, and JavaScript for troubleshooting website issues.
You are given an integer 'N'. For a given 'N' x 'N' chessboard, find a way to place 'N' queens such that no queen can attack any other queen on the chessboard.
A queen can be killed when it lies in the ...read more
You are given an array consisting of N integers. You need to find the number of k-element subsequences of the given array where the bitwise AND of the subsequence's elements is maximal. ...read more
You are given a string 'Str' consisting of 'N' lowercase Latin letters. You have to find the longest substring of the given string without repeating characters.
String ‘B’ is a substrin...read more
You are given a bag of size 'W' kg and provided with the costs of packets with different weights of oranges as a list/array with the name 'cost'. Every i-th position in the cost denot...read more
Q250. What is customer service, how do we deal with customer service
Customer service is the assistance and support provided to customers before, during, and after a purchase or interaction.
Customer service involves addressing customer inquiries, concerns, and complaints.
It includes providing information, resolving issues, and ensuring customer satisfaction.
Effective communication, empathy, and problem-solving skills are essential in customer service.
Examples of customer service include answering phone calls, responding to emails, and assistin...read more
One of my projects involved managing a site, so he asked me, how would I handle if my site got huge traffic and I had to manage a lot of data, I told him how I’ll manage the database using i...read more
You have been given a square chessboard of size ‘N x N’. The position coordinates of the Knight and the position coordinates of the target are also given.
Your task is t...read more
You have been given an array/list of integers, let’s say ‘PRE’, which represents the preorder traversal of a strict binary tree and an array/list ‘TYPENL’ which has only two possi...read more
Let there be ‘N’ battalions of soldiers and ‘M’ tanks. You are also given an array/list of length ‘N’ whose i-th index denotes the number of soldiers in the i-th battalion. You are supposed ...read more
Aahad and Harshit always have fun by solving problems. Harshit took a sorted array and rotated it clockwise by an unknown amount. For example, he took a sorted array = [1, 2, 3, 4,...read more
You have given a m*n matrix filled with "1" and "0"."1" means you can use the cell and "0" means the cell is blocked. You can move in 4 directions left, right, top, bottom. Every time...read more
Q257. There is a big file containing numbers and we have to sort all of them
We can use any sorting algorithm like quicksort, mergesort, heapsort, etc.
Choose the appropriate sorting algorithm based on the size of the file and the range of numbers
Implement the chosen algorithm in the programming language of choice
Read the numbers from the file into an array or list
Apply the sorting algorithm to the array or list
Write the sorted numbers back to the file
Check if two strings are anagram or not.
1) Explain DNS
2) What is DHCP
3) What is SIP protocol
4) Difference between TCP/UDP
5) Difference between HTTP/HTTPs
6) What is proxy server.
7) Some basics Linux commands
8) What is BCNF in DBMS.
You have been given a binary tree of integers. You are supposed to find the diagonal traversal(refer to Example) of the given binary tree.
Example:
Consider lines at an angle...read more
You are given an array of positive integers. Find the GCD(Greatest Common Divisor) of a pair of elements such that it is maximum among all possible pairs. GCD(a, b) is the maximum number x such that...read more
You are given a starting position for a rat which is stuck in a maze at an initial point (0, 0) (the maze can be thought of as a 2-dimensional plane). The maze would be given in the form of a squar...read more
You are given a N x M matrix of integers, return the spiral path of the matrix
Example Of Spiral Path
Input Format:
The first line contains an integer 'T' which denotes the number of test cases or...read more
The Ultimate Ninja Ankush was bored, so his friend Ninja Nikhil decided to give him a puzzle to keep him entertained. Nikhil gave Ankush ‘N’ integers and asked how many groups of sizes 2 and 3 can be f...read more
Q265. A stream of data is coming. Maintain records in a page and mechanism to see previous and next page. (Concept of Doubly Linked List) (It is always advisable to ask questions in design questions. The interviewers...
read moreA thread is a unit of execution within a process that can run independently and concurrently with other threads.
Threads allow for concurrent execution of tasks within a program.
Threads share the same memory space and resources of the process they belong to.
Threads can communicate and synchronize with each other through shared data structures like locks and semaphores.
Threads can improve performance by utilizing multiple CPU cores or by handling I/O operations asynchronously.
E...read more
Q266. Given a sorted array of integers, find the frequency of 2 in the array in log(n) time.
Find frequency of 2 in sorted array of integers in log(n) time.
Use binary search to find first and last occurrence of 2 in array.
Calculate frequency by subtracting last index from first index and adding 1.
Time complexity is O(log(n)).
Define ACID and explain with examples. There were few questions on join queries. These were of medium complexity.
Compiler design related questions, differences between Python and C in very depth.
Low level vs High level language, kernel related questions
You are given an arbitrary binary tree with N nodes, whose nodes have their values in the range of integers. You are given two nodes x, y from the tree. You have to print the least common a...read more
You are given a 2D array with dimensions ‘N*M’. You need to read the array elements row-wise and return a linear array that stores the elements like a wave i.e the 1st-row elements are stored from ...read more
Given 'N' number of intervals, where each interval contains two integers denoting the boundaries of the interval. The task is to merge all the overlapping intervals and return the lis...read more
Ninja is stuck in a city with ‘N’ colonies, and each colony contains ‘K’ houses. Ninja is currently at the house number “sourceHouse” present in the colony with colony number “sourceColony”. He wants ...read more
Q273. A stream of numbers are coming and I have to keep track of the kth largest number in it
Keep track of kth largest number in a stream of numbers.
Use a min-heap of size k to keep track of kth largest number.
For each incoming number, compare it with the root of the heap.
If it is larger than the root, replace the root with the new number and heapify.
The root of the heap will always be the kth largest number.
You have been given an integer array/list(arr) and a number 'Sum'. Find and return the total number of pairs in the array/list which when added, results equal to the 'Sum'.
Note:
G...read more
Q275. How do you limit distraction
To limit distractions, I prioritize tasks, create a dedicated workspace, and use time management techniques.
Prioritize tasks by creating a to-do list and focusing on important tasks first
Create a dedicated workspace free from distractions like noise and clutter
Use time management techniques such as the Pomodoro Technique or time blocking
Minimize interruptions by turning off notifications or using focus apps
Practice self-discipline and set boundaries to avoid getting distracte...read more
Running median of input stream.
He asked me what does an auto variable mean, how map sorts its keys, difference between map and unordered map’s working, and write down output for each iteration, then later he asked time com...read more
You have been given a binary tree of integers. Your task is to print the boundary nodes of this binary tree in Anti-Clockwise direction starting from the root node.
NOTE:...read more
You have been given ‘N’ courses and some courses may have prerequisites. Now consider a matrix ‘PREREQUISITES’ of size 'M' x 2 which represents that you must complete course 'PREREQUISITES[i][...read more
You have been given a binary tree of integers with N number of nodes. Your task is to check if that input tree is a BST (Binary Search Tree) or not.
A binary search tree (BST) is a binary tree data ...read more
You are given a binary tree. Apart from the left and right child pointers, each node in the given binary tree points to a random node in the given binary tree. You are s...read more
Ninja is in the mood for a walk over the city, but being a ninja he prefers jumping over building roofs instead of walking through the streets.
The height of the buildings in his ...read more
Given a string ‘S’ comprising of some brackets. You need to print the number of every bracket.
For Example:
If S = (pq)() Then the output will be 1 1 2 2. First pair of opening and closing bracket...read more
Given a directed graph, check whether the graph contains a cycle or not. Your function should return true if the given graph contains at least one cycle, else return false.
Inpu...read more
You are given an equation of the addition of two numbers. One number among the two operands is missing in the given equation and is denoted by ‘x’. You have to find this missing number and return...read more
Given a binary tree, return the zigzag level order traversal of the nodes' values of the given tree. Zigzag traversal means starting from left to right, then right to left for the ne...read more
You need to implement the Stack data structure using a Singly Linked List.
Create a class named 'Stack' which supports the following operations(all in O(1) time):
getSize: Retur...read more
Given two arrays ‘ARR’ and ‘BRR’ of size ‘N’ and ‘M’ respectively. Your task is to sort the elements of ‘ARR’ in such a way that the relative order among the elements will be the same as those a...read more
Q289. there is an infinite stair case and there are n rounds. in i'th round we can jump i steps at one or discard them. it is given that k'th step is broken , find the max height we can reach with out stepping on the...
read moreGiven an infinite staircase with a broken kth step, find the maximum height we can reach in n rounds of jumping i steps.
We can start by jumping the maximum number of steps in each round until we reach the broken step.
After reaching the broken step, we can discard the i steps that would land us on the broken step and jump the remaining steps.
We can continue this pattern until we reach the maximum height we can reach without stepping on the broken step.
You are given two integer arrays ARR1 and ARR2 of length N and M respectively. You have to return true if ARR2 is a subset of ARR1, otherwise, return false.
For Example:
If the given arrays are [1, ...read more
You have given a singly linked list and two integers 'N' and 'M'. Delete 'N' nodes after every 'M' node, or we can say more clearly that traverse the linked list suc...read more
For a given two-dimensional integer array/list ‘ARR’ of size (N x M), print the ‘ARR’ in a sine wave order, i.e., print the first column top to bottom, next column bottom to top, and so on.
For...read more
Q295. Given a Binary Tree, if it is a BST or not
Check if a Binary Tree is a Binary Search Tree (BST)
A BST has the property that all nodes in the left subtree of a node have values less than the node's value, and all nodes in the right subtree have values greater than the node's value
We can traverse the tree in-order and check if the resulting sequence is sorted
Alternatively, we can recursively check if each node satisfies the BST property
Given 'K' sorted linked lists, each list is sorted in increasing order. You need to merge all these lists into one single sorted list. You need to return the head of the final linked list.
I...read more
You have been given an unsorted array ‘ARR’.
Your task is to sort the array in such a way that the array looks like a wave array.
Example:
If the given sequence ‘ARR’ has ‘N’ elements ...read more
Design YouTube/Netflix (a global video streaming service)
Design Search Typeahead
Sushant is learning about palindromes. One day his teacher gave him a string ‘STR’ consisting of only the lowercase letters and asked him to modify the string in such a way that the st...read more
You are given an M X N matrix of integers ARR. Your task is to find the maximum sum rectangle.
Maximum sum rectangle is a rectangle with the maximum value for the sum of integers present wi...read more
More about working at Amazon
Top HR Questions asked in Kangeya Labs
Interview Process at Kangeya Labs
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month