Software Developer
7000+ Software Developer Interview Questions and Answers
You are given an integer 'X' and your task is to find an integer 'Y' such that the bitwise XOR of the integers 'X' and 'Y' give the maximum possible value. T...read more
You are given an array/list ARR consisting of N integers. Your task is to find the length of the longest decreasing subsequence.
A subsequence is a sequence of numbers obtained by ...read more
Given a binary array 'ARR' of size 'N', your task is to find the longest sequence of continuous 1’s that can be formed by replacing at-most 'K' zeroes by ones. Return the length of this ...read more
Given a sequence of numbers ‘ARR’. Your task is to return a sorted sequence of ‘ARR’ in non-descending order with help of the merge sort algorithm.
Example :
Merge Sort Algorithm - Merge sort is a Di...read more
You are given a tree(root 0) with N vertex having N - 1 edges. You are also given an array ‘QUERY’ of size ‘Q’, where each query consists of an integer that denotes a node. You have to print the xor of...read more
This question is about finding the XOR of all values of nodes in the sub-tree of a given node in a tree.
Read the input values for the number of test cases, number of nodes, and number of queries.
Construct the tree using the given edges.
For each query, traverse the sub-tree of the given node and calculate the XOR of all node values.
Print the XOR values for each query.
You are given a string 'S'. Your task is to check whether the string is palindrome or not. For checking palindrome, consider alphabets and numbers only and ignore the symbols ...read more
The task is to check whether a given string is a palindrome or not, considering only alphabets and numbers and ignoring symbols and whitespaces.
Convert the string to lowercase and remove all symbols and whitespaces.
Reverse the modified string and compare it with the original string.
If they are equal, then the string is a palindrome.
If not, then the string is not a palindrome.
Share interview questions and help millions of jobseekers 🌟
You are given a sorted doubly linked list of distinct nodes that means no two nodes present in the list have the same data. Yo...read more
Given a binary tree, print the top view of it. The output nodes can be printed in any order. Expected time complexity is O(n)
1
/ \
2 3
/ \ / \
4 5 6 7
Top view of the above binar...read more
Software Developer Jobs
You have been given the root of two binary trees ‘ROOT1’ and ‘ROOT2’. You need to find if the two trees are flip equivalent or not after performing some flip operations on ‘TREE1’.
A ...read more
The problem is to determine if two binary trees are flip equivalent after performing flip operations on one of the trees.
Perform a depth-first search (DFS) on both trees simultaneously
At each node, check if the values are equal and the left and right subtrees are either both null or both not null
If the above conditions are met, recursively check the flip equivalence of the left and right subtrees
If any of the conditions fail at any node, the trees are not flip equivalent
Q260. Given a 10 digit number, sort the individual digits of the number.
Sort the individual digits of a 10 digit number.
Convert the number to a string to access individual digits
Use a sorting algorithm to sort the digits
Convert the sorted digits back to a number
You are given an unsorted array containing ‘N’ integers. You need to find ‘K’ largest elements from the given array. Also, you need to return the elements in non-decreasing order.
Input Format...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', 'N...read more
You have been given a string ‘A’ consisting of lower case English letters. Your task is to find the length of the longest palindromic subsequence in ‘A’.
A subsequence is a sequen...read more
The task is to find the length of the longest palindromic subsequence in a given string.
A subsequence is a sequence generated from a string after deleting some or no characters of the string without changing the order of the remaining string characters.
A string is said to be palindrome if the reverse of the string is the same as the actual string.
Find the longest palindromic subsequence by considering all possible subsequences of the given string.
Use dynamic programming to ef...read more
You are given a string ('STR') of length 'N'. Find the longest palindromic substring. If there is more than one palindromic substring with the maximum length, return the one with th...read more
Find maximum possible stolen value from houses
There are n houses build in a line, each of which contains some value in it. A thief is going to steal the maximal value of these houses, but he can’t ste...read more
For a given array/list of integers of size N, print the Next Greater Element(NGE) for every element. The Next Greater Element for an element X is the first element on the right side of X in ...read more
You are given an array of n integers (a1, a2,....,an), you need to find if the array contains a pythagorean triplet or not.
An array is said to have a pythagorean triplet if there exists thr...read more
There are 3 gallons A B C.
Gallon A having max capacity of 8 liters is currently filled with 5 liters of Water.
Gallon B having max capacity of 5 liters is currently filled with 3 liters of Water...read more
Given an array of 'N' elements 'OBSTACLES', where each element represents the coordinate of the obstacle on a straight line. We start jumping from point 0 and we need to reach the end of the line ...read more
You are given two Strings 'P' and 'Q' of equal length. Your task is to check whether String 'P' can be converted into String 'Q' by cyclically rotating it to t...read more
You have been given a sorted array/list ARR consisting of ‘N’ elements. You are also given an integer ‘K’.
Now, your task is to find the first and last occur...read more
Gary has N coins placed in a straight line. Some coins have head side up, and others have the tail side up.
Convention:
1 denotes the HEAD side is up. 0 denotes the TAIL side is up.
Now, Gary wan...read more
You are given a string (STR) of length N.
Your task is to find the longest palindromic substring. If there is more than one palindromic substring with the maximum length, return the...read more
You have been given an array/list ‘ARR’ of integers consisting of ‘N’ integers. In one operation you can increase an element by 1. Your task is to return the minimum numb...read more
To find the merging point of link list(Given pointers to the head nodes of 2 linked lists that merge together at some point, find the Node where the two lists merge. It is guarant...read more
Create a class GrandFather that has a parameterized constructor and a grandFatherName attribute.
Create another class Father that inherits the property of GrandFather and has a parameteriz...read more
Ninja has been asked to organize a dance competition. Ninja decided that he will take individual entries and then will divide them into pairs. As part of the entry, he asked the p...read more
Ninja has built his team of ninjas to fight with the enemies in his city. Ninja made a plan of attacking all his enemies. In his team, every ninja has his own range of hitting and they had secretly ...read more
You are given the root of a complete binary tree, you need to calculate the number of nodes in the given complete binary tree.
A complete binary tree is a tree in which all the leve...read more
You are given an integer ‘N’. We can reorder the digits in any order (including the original order) such that the leading digit is not zero.
Return true if and only if we can do this so that the resul...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...read more
You are given an array containing ‘N’ words. For each word, you need to find its shortest prefix which can uniquely identify it. For example “abcd” and “abdc” both have the prefix “ab” in ...read more
You have been given a long type array/list 'ARR' of size 'N'. It represents an elevation map wherein 'ARR[i]' denotes the elevation of the 'ith' bar. Print the total amount of rainwater that c...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
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
The task is to count the total number of '1' in the binary representation of all numbers from 1 to N.
Convert each number from 1 to N into its binary representation
Count the number of '1' bits in each binary representation
Sum up the counts of '1' bits for all numbers
Return the sum modulo 1e9+7
You have been given a singly Linked List of 'N' nodes with integer data and an integer 'K'. Your task is to remove the Kth node from the end of the given Linked List.
For example:
The gi...read more
Implement a SpecialStack Data Structure that supports getMin() in O(1) time and O(1) extra space along with push(), pop(), top(), isEmpty()...read more
A few days back, Ninja encountered a string containing characters from ‘A’ to ‘Z’ which indicated a secret message. For security purposes he encoded each character of the string to its numeric va...read more
You are given a 2-D matrix ‘mat’, consisting of ’N’ rows and ‘M’ columns. The element at the i-th row and j-th column is ‘mat[i][j]’.
From mat[i][j], you can move to mat[i+1][j] if mat[...read more
You are given an array of 'N' integers denoting the heights of the mountains. You need to find the length of the longest subarray which has the shape of a mountain.
A mountain subarray ...read more
Design and implement a data structure for Least Recently Used (LRU) cache to support the following operations:
1. get(key) - Return the value of the key if the key exists in the cache, o...read more
Given a linked list such that each node represents a digit. Construct the maximum number possible from the given digits.
You just need to print the maximum Integer that can be formed
Input fo...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...read more
Ninja has been given ‘N’ stars. Ninja has to make a triangle using these stars. The ‘i’th’ level of a triangle contains a ‘i’ number of stars.
Can you help Ninja to make a triangle as larg...read more
You have been given a sorted array/list of integers of size N and an integer X. Find the total number of occurrences of X in the array/list.
Input Format
The first line of the ...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 possible palindromic substr...read more
Q297. pirates of different ages have a treasure of 100 gold coins. On their ship, they decide to split the coins using this scheme: The oldest pirate proposes how to share the coins, the OTHER pirates (not including ...
read moreThe oldest pirate proposes to keep 98 coins for himself and give 1 coin to each of the other pirates.
The oldest pirate will propose to keep the majority of the coins for himself to ensure the vote passes.
The other pirates will vote in favor of the proposal to avoid being thrown overboard.
The proposed distribution will be 98 coins for the oldest pirate and 1 coin for each of the other pirates.
You are given an unweighted directed graph of 'V' vertices and 'E' edges. Your task is to print all the strongly connected components (SCCs) present in the grap...read more
You are given an integer array ‘ARR’. You have to find the length of the shortest contiguous subarray such that, if you sort this subarray in ascending order, then the whole array will be sorted in asce...read more
The task is to find the length of the shortest contiguous subarray that needs to be sorted in order to sort the entire array.
Iterate through the array from left to right and find the first element that is out of order.
Iterate through the array from right to left and find the first element that is out of order.
Find the minimum and maximum elements within the subarray defined by the above two elements.
Expand the subarray to include any additional elements that are out of order ...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
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