Software Developer
7000+ Software Developer Interview Questions and Answers
We have a collection of 'N' stones, each stone has a positive integer weight.
On each turn, we choose the two heaviest stones and smash them together. Suppose the stones have weights 'x' and 'y...read more
This question is about finding the weight of the last stone after repeatedly smashing the two heaviest stones together.
Sort the array of stone weights in descending order.
Repeatedly smash the two heaviest stones together until there is at most 1 stone left.
If there is 1 stone left, return its weight. Otherwise, return 0.
You are given a matrix ‘ARR’ with ‘N’ rows and ‘M’ columns. Your task is to find the maximum sum rectangle in the matrix.
Maximum sum rectangle is a rectangle with the maximum value for the...read more
Ninja is organizing a meeting in an office that starts at a time ‘0’ and will end at a time ‘LAST’. There are ‘N’ presentations that are going to take place in that meeting whose start and end times are ...read more
Given a cost matrix cost[][] and a position (m, n) in cost[][], write a function that returns cost of minimum cost path to reach (m, n) from (0, 0). Each cell of the matrix represents a cost to...read more
Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element on the right side of x in array. Elements for w...read more
You are given an array 'ARR' of 'N' positive integers. Your task is to find if we can partition the given array into two subsets such that the sum of elements in both subsets is equal....read more
Share interview questions and help millions of jobseekers 🌟
You are given an array of integers. You need to sort the array in ascending order using quick sort.
Quick sort is a divide and conquer algorithm in which we choose a pivot point and partition the arr...read more
You have been given a sorted array/list ARR consisting of ‘N’ elements. You are also given an integer ‘K’.
Now the array is rotated at some pivot point unknown to you. For example,...read more
Software Developer Jobs
You have been given an array/list ARR consisting of ‘N’ elements. Each element in the array is either 0, 1 or 2.
Now, your task is to sort this array/list in increasing order. For ...read more
You are given a 2-D array 'MATRIX' of dimensions N x M, of integers. You need to return the spiral path of the matrix.
Example Of Spiral Path:
Input Format:
The first line contains an integer 'T' ...read more
I was given two tables one was employee table and other was a department table. On basis of these tables I was asked few questions :-
1. Write a query to find the max salary of any employee .
2. Writ...read more
Q212. A ball is left from a height of 10 meters. After bouncing first time it looses 10% of its previous height the next time it bounces. Write a code to calculate the number of bounces the ball goes through until it...
read moreCode to calculate number of bounces a ball goes through until it comes to rest.
Use a loop to simulate the bounces until the ball stops bouncing
Calculate the height of each bounce using the given formula
Keep track of the number of bounces in a counter variable
Given two 1-dimensional arrays containing strings of lowercase alphabets, print the elements that are common in both the arrays i.e. the strings that are present in both the arrays.
Note:
An elem...read more
Write a program to do basic string compression. For a character which is consecutively repeated more than once, replace consecutive duplicate occurrences with the count of repetitions.
Exampl...read more
We are suffering from the Second wave of Covid-19. The Government is trying to increase its vaccination drives. Ninja wants to help the Government to plan an effective method to help increase v...read more
You have been given a linked list of integers. Your task is to write a function that deletes a node from a given position, 'POS'.
Note :
Assume that the Indexing for the linked lis...read more
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:
Given ...read more
You have to implement an iterator for ‘FLATTEN_2D’ to flatten a two-dimensional array ‘ARR_2D’ into a one-dimensional array ‘ARR_1D’. The iterator should support the following two operations:
You are given three strings 'A', 'B' and 'C'. Check whether 'C' is formed by an interleaving of 'A' and 'B'.
'C' is said to be interleaving 'A' and 'B', if the length of 'C' is equal to ...read more
Given a string input of length n, find the length of the longest substring without repeating characters i.e return a substring that does not have any repeating characters.
Substring is t...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
Given an array/list of integers of length ‘N’, there is a sliding window of size ‘K’ which moves from the beginning of the array, to the very end. You can only see the ‘K’ nu...read more
You are given ‘N’ pairs of integers in which the first number is always smaller than the second number i.e in pair (a,b) -> a < b always. Now we define a pair chain as the continuous ar...read more
You are given two sorted linked lists. You have to merge them to produce a combined sorted linked list. You need to return the head of the final linked list.
Note:
The given lin...read more
You are given an array arr of length N. You have to return a list of integers containing the NGE(next greater element) of each element of the given array. The NGE for an element X is the fir...read more
You have been given a grid containing some oranges. Each cell of this grid has one of the three integers values:
Chintu has a long binary string ‘str’. A binary string is a string that contains only 0 and 1. He considers a string ‘beautiful’ if and only if the number of 0's and 1's in the string are equ...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
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 number of...read more
You are given an undirected and disconnected graph G(V, E) having V vertices numbered from 0 to V-1 and E edges. Your task is to print its BFS traversal starting from the 0th vertex.
BFS or Breadth-...read more
Bubble Sort is one of the sorting algorithms that works by repeatedly swapping the adjacent elements of the array if they are not in sorted order.
You are given an unsorted array consisting of N non-...read more
You have been given a text message. You have to return the Run-length Encoding of the given message.
Run-length encoding is a fast and simple method of encoding strings. The basic idea is to r...read more
You are given an array/list 'ARR' consisting of N integers, which contains elements only in the range 0 to N - 1. Some of the elements may be repeated in 'ARR'. Your task is to find all ...read more
There is a cache that can hold up to ‘N’ elements. Initially, it is empty. There are two types of operations:-
Operation 1: [ 1 ‘U_ID’ ‘VAL’ ] - where 1 represent...read more
You are given with an array of integers and an integer K. You have to find and print the count of all such pairs which have difference K.
Note: Take absolute difference between the elemen...read more
Given a maze in the form of a binary rectangular matrix of size M*N, where each element can either be 0 or 1, the task is to find the length of the shortest path in a maze from a g...read more
You have been given an integer array/list(ARR) of size N that contains only integers, 0 and 1. Write a function to sort this array/list. Think of a solution which scans the array/list only once and don'...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 an array 'ARR' of N integers. Each integer represents the height of a balloon. So, there are N balloons lined up.
Your aim is to destroy all these balloons. Now, a balloon can onl...read more
You are given an N*M binary matrix, considering for every 0-cell(cell with value = 0) the distance from this cell to its nearest 1-cell(cell with value = 1) is 'di', you need to find the max...read more
Ninja is a boy who lives in ninjaland. Every day, during the morning he gets 1 coin from his mother. He wants to buy exactly ‘N’ candies. Each of the candies cost 2 coins usually and 1 coin if ...read more
You are given a string S of words. Your task is to count the occurrence of each word present in the string S. A word is a sequence of one or more non-space characters, and there can be m...read more
You are given an arbitrary binary tree, a node of the tree, and an integer 'K'. You need to find all such nodes which have a distance K from the given node and return ...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
The 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 are in BRR. For the elements not present in BRR, append them in the last in sorted order.
Create a frequency map of elements in ARR
Iterate through BRR and for each element, append it to the result array the number of times it appears in ARR
Iterate through the frequency map and for each element not present in BRR, append it to the result array
Sort the resul...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 are given an arbitrary binary tree. A binary tree is called special if every node of this tree has either zero or two children. You have to determine if the given binary tree is special ...read more
You are given an integer, ‘MAXVAL’. Your task is to determine the total number of special numbers present in the range, 1 to ‘MAXVAL’.
Note:
A special number is a number, which when rotated 180 d...read more
Q248. Q1. Why is String Immutable? What is String Pool? How to create a String which is not stored in String Pool? What is REST Web Service? Life Cycle of a thread? If Rest is Stateless How do you maintain Sessions? ...
read moreWhat is the difference between abstract class and interface?
Abstract class can have both abstract and non-abstract methods, while interface can only have abstract methods.
A class can implement multiple interfaces, but can only extend one abstract class.
Abstract classes can have constructors, while interfaces cannot.
Interfaces are used to achieve multiple inheritance in Java.
Example: Abstract class - Animal, Interface - Flyable
Example: Abstract class - Shape, Interface - Drawa...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
You have been given 'N' ropes of different lengths, we need to connect these ropes into one rope. The cost to connect two ropes is equal to sum of their lengths. We need to conn...read more
Interview Questions of Similar Designations
Top Interview Questions for Software Developer Related Skills
Interview experiences of popular companies
Calculate your in-hand salary
Confused about how your in-hand salary is calculated? Enter your annual salary (CTC) and get your in-hand salary
Reviews
Interviews
Salaries
Users/Month