Amazon
600+ IDZ Digital Interview Questions and Answers
Given an integer array, find the longest subsequence with adjacent numbers having a digit in common. Eg: 1 12 44 29 33 96 89 . The longest subsequence here is { 1 12 29 96 89} an...read more
Given a sequence of ‘N’ space-separated non-negative integers A[1],A[2],A[3],......A[i]…...A[n]. Where each number of the sequence represents the height of the line drawn at point 'i'. ...read more
Given a sequence of non-negative integers representing the height of lines on a cartesian plane, find two lines that form a container with the maximum area of water.
Use two pointers approach to find the maximum area
Start with the widest container and gradually move the pointers towards each other
Calculate the area at each step and update the maximum area
The area is calculated as the minimum height of the two lines multiplied by the distance between them
There were few basic SQL questions for DBMS.
1. I was asked to describe a join to a non-technical person.
2. There was a question to write query for how to select all customers who purchased minimu...read more
Given two strings, 'S' and 'T' with lengths 'M' and 'N', find the length of the 'Longest Common Subsequence'.
For a string 'str'(per se) of length K, the subsequences are the strings c...read more
Q105. In question 2 when there are ‘n’ in the String whose position shouldn’t get affected during the swapping process
Explaining how to handle 'n' in a string during swapping process
Identify the positions of 'n' in the string
Exclude those positions from the swapping process
Use a temporary variable to swap the characters
Ensure the swapped characters are not 'n'
Return the modified string
You are given character matrix of dimension N * M. Then you are given 'Q' queries, each query consists of a word 'W', and you have to tell whether it is possible to form word 'W' by choosing some adj...read more
Given a singly linked list of integers. Your task is to return the head of the reversed linked list.
For example:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL. Then the reverse linked li...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
Given a number n, find the smallest number that has same set of digits as n and is greater than n. If n is the greatest possible number with its set of digits, then pr...read more
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to return the list of all pairs of elements such that each sum of elements of each pair equals 'S'.
Note:
Each pair shou...read more
Given an array and a target sum, find all pairs of elements in the array that add up to the target sum.
Create an empty list to store the pairs
Iterate through the array and for each element, check if there is a complement (target sum minus the current element) in the array
If a complement is found, add the pair (current element, complement) to the list
Sort the list of pairs in non-decreasing order of their first value
If two pairs have the same first value, sort them based on th...read more
You are given a sorted array 'ARR' and a number 'X'. Your task is to count the number of occurrences of 'X' in 'ARR'.
Note :
1. If 'X' is not found in the array, return 0. 2. The give...read more
The task is to count the number of occurrences of a given number in a sorted array.
Use binary search to find the first and last occurrence of the given number in the array.
Subtract the indices of the first and last occurrence to get the count.
Handle the case when the number is not found in the array.
Count number of occurrences (or frequency) in a sorted array
Given a sorted array arr[] and a number x, write a function that counts the occurrences of x in arr[].
Examples:
Inpu...read more
You are given an array “A” of N integers. Your task is to find the maximum element in all K sized contiguous subarrays from left to right.
For Example:
If A = [3, 2, 3], and K ...read more
You have been given two integers ‘NUM1’ and ‘NUM2’ as a string. Your task is to print the sum of both the numbers.
Input Format:
The first line contains a single integer ‘T’ representing the ...read more
You are given an array ‘ARR’ consisting of ‘N’ strings. Your task is to find the longest common prefix among all these strings. If there is no common prefix, you have to return an empty str...read more
You are given an array of integers ARR[] of size N consisting of zeros and ones. You have to select a subset and flip bits of that subset. You have to return the count of maximum one’s that you can obt...read more
You have been given a matrix of ‘N’ rows and ‘M’ columns filled up with integers where every row is sorted in non-decreasing order. Your task is to find the overall median of the matrix i.e if all ...read more
You have been given an integer ‘X’ and a non-decreasing sorted doubly linked list with distinct nodes.
Your task is to return t...read more
There are ‘N’ people at a party. Each person has been assigned a unique id between 0 to 'N' - 1(both inclusive). A celebrity is a person who is known to everyone but does not know anyone at...read more
You are given a Singly Linked List which contains a series of integers separated by ‘0’.
Between two zeroes, you have to merge all the nodes lying between them into a single node which contain...read more
Q121. A String was given with a lot of words in it and I had to reverse all the words
Reverse all the words in a given string
Split the string into an array of words
Loop through the array and reverse each word
Join the reversed words back into a string
Ninjaland is a country having 'N' states numbered from 1 to 'N'. These 'N' states are connected by 'M' bidirectional roads. Each road connects to different states and has some cost to travel ...read more
The task is to select 'N' - 1 roads in a country with 'N' states, such that the tourist bus can travel to every state at least once at minimum cost.
The problem can be solved using a minimum spanning tree algorithm, such as Kruskal's algorithm or Prim's algorithm.
Create a graph representation of the country using the given roads and their costs.
Apply the minimum spanning tree algorithm to find the minimum cost roads that connect all the states.
Print the selected roads and thei...read more
You are given an infinite supply of coins of each of denominations D = {D0, D1, D2, D3, ...... Dn-1}. You need to figure out the total number of ways W, in which you can make a change fo...read more
Given an array A of size N containing 0s, 1s, and 2s; you need to sort the array in ascending order. You can scan the array only once.
You have been given a 9 X 9 2D matrix 'MATRIX' with some cells filled with digits(1 - 9), and some empty cells (denoted by 0).
You need to find whether there exists a way to fill all the empty cells...read more
The task is to determine if a given 9x9 matrix can be filled with digits 1-9 to form a valid Sudoku solution.
Iterate through each cell in the matrix.
For each empty cell, try filling it with a digit from 1-9 and check if it satisfies the Sudoku conditions.
Use helper functions to check if the digit is valid in the current row, column, and sub-matrix.
If a valid digit is found, recursively fill the next empty cell.
If all cells are filled and the Sudoku conditions are satisfied, r...read more
Given a linked list having two pointers in each node. The first one points to the next node of the list, however, the other pointer is random and can point to any node of th...read more
Ninja likes to travel a lot, but at the same time, he wants to save as much money as possible. There are ‘N’ Stations connected by ‘M’ Trains. Each train that he boards starts from station ‘A’ and r...read more
You are given a Singly Linked List of integers which is sorted based on absolute value.
You have to sort the Linked List based on actual values.
The absolute value of a real number x, denoted |x...read more
Given two binary trees T and S, check whether tree S has exactly the same structure and node values with a subtree of T, i.e., check if tree S is a subtree of the tree T.
A subtree of a t...read more
You are given a sorted doubly linked list of distinct nodes that means no two nodes present in the list have the same data. You...read more
You are given a string 'STR' of lowercase English alphabets. You need to find the repeated character present first in the string.
Example:
If the string is: “abccba”, then the first repe...read more
You have been given an integer array/list (ARR) of size N. You have to return an array/list PRODUCT such that PRODUCT[i] is equal to the product of all the elements of ARR except ARR...read more
Given a Binary Tree, Print the corner nodes at each level. The node at the leftmost and the node at the rightmost.
For example, output for following is 15, 10, ...read more
Given an array of positive and negative integers, print x if +x and -x are present in the array.
For a given integer array/list 'ARR' of size 'N', find the total number of 'Inversions' that may exist.
An inversion is defined for a pair of integers in the array/list when the following two co...read more
The task is to count the number of inversions in an array.
Iterate through the array and for each element, compare it with all the elements that come after it.
If the current element is greater than any of the elements that come after it, increment the inversion count.
Return the inversion count as the result.
You are present at point ‘A’ which is the top-left cell of an M X N matrix, your destination is point ‘B’, which is the bottom-right cell of the same matrix. Your task is to find the total num...read more
You are given a string 'STR' containing lowercase English letters from a to z inclusive. Your task is to find all non-empty possible subsequences of 'STR'.
A Subsequence of a string is the...read more
You had a sequence of consecutive nonnegative integers. You appended all integers at the end of each other to form a string ‘S’ without any...read more
The task is to find the missing number in a string of consecutive nonnegative integers.
Iterate through the string and check if each substring can form a valid number
If a substring forms a valid number, check if it is consecutive with the previous number
If a substring does not form a valid number or is not consecutive, it is the missing number
Handle edge cases such as multiple missing numbers or all numbers already present
You have been given a string 'S' containing only three types of characters, i.e. '(', ')' and '*'.
A Valid String is defined as follows:
1. Any left parenthesis '(' must have a corresponding right p...read more
You are given a path to a file/directory in Unix-style of length N, In a Unix-style file system, a dot(.) refers to the current directory. A double dot(..) refers to the previous directory...read more
The task is to simplify a given Unix-style directory path and determine the final destination.
Replace multiple slashes with a single slash
Handle dot (.) by ignoring it
Handle double dot (..) by removing the previous directory from the path
Ensure the simplified path starts with a slash and does not have a trailing slash
Ninjas are often known for their stealth execution and accuracy to get the job done right. While honing their art of moving through dense forests stealthily, they need the maximum number of conti...read more
It was a kind of situational problem which I had to solve using optimum data structures.Questions was a bit of like event scheduling based but was a practical scenario based.
Given an array 'ARR'' of 'N' integers and an integer 'target', your task is to find three integers in 'ARR' such that the sum is closest to the target.
Note
In the case of two closest sums, print the...read more
Given a binary tree, modify the tree satisfying the following constrains :
Value at root must be the sum of left child and right child (not subtrees).
You can’t reduce the value at any node. You can only increase...read more
Find an MST from a given graph by using Kruskal algorithm.
Q146. What do you know about risk management?
Risk management involves identifying, assessing, and prioritizing risks to minimize their impact on an organization.
Risk management is a process of identifying potential risks and taking steps to mitigate them.
It involves assessing the likelihood and impact of risks, and prioritizing them based on their severity.
Risk management strategies may include risk avoidance, risk reduction, risk transfer, or risk acceptance.
Examples of risks that may be managed include financial risks...read more
You have been given a non-empty grid ‘MAT’ with 'N' rows and 'M' columns consisting of only 0s and 1s. All the rows are sorted in ascending order.
Your task is to find the index of the row t...read more
Given an array/list of integer numbers 'CHOCOLATES' of size 'N', where each value of the array/list represents the number of chocolates in the packet. There are ‘M’ number of students and the t...read more
Ninja is assigned a task to reach the last stone by his master. These stones are numbered with some value and in the form of an array. He is allowed to jump either odd-numbered jumps or even-numbere...read more
You are given a list of “N” strings A. Your task is to check whether you can form a given target string using a combination of one or more strings of A.
Note :
You can use any string of A multiple tim...read more
You are given string S of length N, and an integer K. Your task is to find the length of the longest substring that contains at most K distinct characters.
I...read more
You have been given a string STR. Your task is to find the total number of palindromic substrings of STR.
Example :
If the input string is "abbc", then all the possib...read more
You are given a 2 - D grid having ‘N’ rows and ‘M’ columns. Each cell of the grid has an integer value written on it which denotes the cost it takes to pass through that cell. You are ...read more
You are given a Singly Linked List of integers. You need to reverse the Linked List by changing the links between nodes.
Input Format :
The first line of input contains a single integer T, re...read more
What is deadlock? How to recover from the deadlock and how to prevent them?
Explain the main differences between thread and process?
How would you solve the problem of critical section(apart from using semaphores)
Difference between multiprogramming and multitasking.
What is Kernel and types of Kernel
Convert a given number into words for news reading by a device.
Example :
If the given input is 62, the output should be 'Sixty two' (without quotes).
You are given an array consisting of N elements and you need to find a subsequence consisting of three elements such that the elements, in the subsequence, are in strictly increasing...read more
You have been given a number of stairs. Initially, you are at the 0th stair, and you need to reach the Nth stair. Each time you can either climb one step or two steps. You are...read more
What is deadlock? How to recover from them? How to prevent them?
Difference between thread and process?
You are given an N x N chessboard and a knight. On a chessboard, the knight can supposedly move in 8 different positions from its original position i.e. if the knight is original...read more
Given a binary tree, print its bottom view from left to right. Assume, the left and the right child make a 45-degree angle with the parent.
A binary tree is a tree in which each parent...read more
You are given a graph with ‘N’ nodes and ‘M’ unidirectional edges. Your task is to find the number of nodes reachable from node ‘i’, where 0 <= ‘i’ <= ‘N’ - 1.
Note: A node ‘u’ is said to be reac...read more
The given Database was having some records. The database was having the details about speed of bowlers and other details. Top 5 bowlers with maximum speed were to be identified by reading the record...read more
Given that integers are read from a data stream. Your task is to find the median of the elements read so far.
Median is the middle value in an ordered integer list. If the size of the list is ...read more
You are given a 2-dimensional array/list having N rows and M columns, which is filled with ones(1) and zeroes(0). 1 signifies land, and 0 signifies water.
A cell is said to be connected to...read more
The task is to find the number of islands present in a 2-dimensional array filled with ones and zeroes.
Iterate through each cell in the array
If the cell is land (1) and not visited, perform a depth-first search to find all connected land cells
Increment the count of islands for each connected component found
You are given a circular array 'ARR' of size 'N', consisting of positive and negative integers. For each index 'i', if ARR[i] is positive then move ARR[i] steps in clockwise direction else mo...read more
Which tech-stack did you use and why?
What are improvements that can be done to this project and how?
You are given the list of costs of pants in an array “pants”, shirts in an array “shirts”, shoes in an array “shoes”, and skirts in an array “skirts”. You are also given a budget amount ‘X’ to s...read more
You are given an array of integers 'ARR' containing N elements. Each integer is in the range [1, N-1], with exactly one element repeated in the array.
Your task is to find the duplicate e...read more
You are given an array “arr'' of integers. Your task is to find the contiguous subarray within the array which has the largest product of its elements. You have to report this maximum pr...read more
You are given a Singly Linked List of integers. You have to find if the given linked list is palindrome or not.
A List is a palindrome if it reads the same from the left to the...read more
You are given an array consisting of N positive integers, and your task is to sort the array in decreasing order of count of set bits in the binary representation...read more
You are given a singly Linked List of integers. Your task is to return true if the given singly linked list is a palindrome otherwise returns false.
For example:
The given linked list is 1...read more
Given a binary tree of integers, you are supposed to modify the given binary tree to a sum tree where each node value is replaced by the sum of the values of both left and r...read more
Ninja has recently studied operators ‘AND’ and ‘XOR’. His teacher gave him an assignment related to the two operators but Ninja is taking a lot of time to compute it and he is afraid he would...read more
Producer consumer problem
What is virtual memory
What is garbage collector, thread vs process.
Given a string S, remove consecutive duplicates from it.
Converting a min heap to a max heap. There can be multiple max heaps possible. Any max heap will be good.
Implement a data structure that can perform insertion, deletion, searching in constant time.
You are given an array/list ‘ARR’ of ‘N’ integers. You have to generate an array/list containing squares of each number in ‘ARR’, sorted in increasing order.
For example :
Input: ‘ARR’ ...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 s...read more
Q183. Who many types in shopping ?
There are several types of shopping including online, in-store, grocery, luxury, thrift, and impulsive.
Online shopping - buying products through the internet
In-store shopping - physically going to a store to purchase products
Grocery shopping - buying food and household items at a grocery store
Luxury shopping - purchasing high-end, expensive items
Thrift shopping - buying second-hand items at a lower cost
Impulsive shopping - making unplanned purchases on a whim
What is virtual memory. What are its uses. Different OS related problems, Indexing
Explain the functionality of DML Compiler
What do you mean by asymmetric clustering
You have been given a Binary Search Tree (BST). Your task is to flatten the given BST to a sorted list. More formally, you have to make a right-skewed BST from the given BST, i.e., t...read more
Given 3 Strings, check whether the 3rd string contains all the characters of string 1 and 2 in any order. If all the characters are present, print "YES" otherwise print "NO".
There should not be ...read more
You are given D dice, each having F faces numbered 1 to F, both inclusive. The task is to find the possible number of ways to roll the dice together such that the sum of face-up numbers equal the giv...read more
You are given an N * N matrix of integers where each row and each column is sorted in increasing order. You are given a target integer 'X'. Find the position of...read more
You have been given a Binary Search Tree and a target value. You need to find out whether there exists a pair of node values in the BST, such that their sum is equal to the target value.
A binar...read more
Given a snake and ladder board, find the minimum number of dice throws required to reach the destination or last cell from source or 1st cell. Basically, the player has total control over the ou...read more
A noticeable aspect in this puzzles is the fact that there’s a circular misplacement, which implies if apple is wrongly labelled as Apple, Apple can’t be labelled as Orange, i.e., it has to be labe...read more
You are given an array ‘ARR’ of size ‘N’ and an integer ‘K’. Your task is to find the total number of distinct elements present in every ‘K’ sized window of the arr...read more
Nobita wants to impress Shizuka by guessing her lucky number.
Shizuka gave Nobita a sorted list of ‘N’ numbers such that every number occurred twice in the list except Shizuka’s lu...read more
You are given a number N. You need to return the position of the rightmost set bit.
For example:
If the given number is 10 with the binary representation: 1010 The rightmost set bi...read more
You are given a 2D matrix (containing either ‘0’ or ‘1’) of size N x M, where each row is in sorted order. Find the 0-based index of the first row that has the maximum number of...read more
You are given a network with ‘N’ system nodes [0 to N - 1] and ‘M’ connection. Your task is to find out all critical connections in a given network.
Note: A connection between node ‘u’ and ‘v...read more
Implement a Trie data structure and write functions to insert and search for a few words in it.
To find the maximum difference between a node and its descendent in the same path in the binary tree.
Q200. Given n coins for two players playing a game. Each player picks coins from the given n coins in such a way that he can pick 1 to 5 coins in one turn and the game continues for both the players. The player who p...
read moreThe player who picks the last coin loses the game.
The game starts with n coins.
Each player can pick 1 to 5 coins in one turn.
The player who picks the last coin loses the game.
Determine if the given n coins will result in a win or loss for the starting player.
More about working at Amazon
Top HR Questions asked in IDZ Digital
Interview Process at IDZ Digital
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month