Software Developer

7000+ Software Developer Interview Questions and Answers

Updated 13 Jan 2025
search-icon
Q251. Find a value whose XOR with a given value is maximum.

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

Q252. Longest Decreasing Subsequence

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

Q253. Maximum Consecutive Ones

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

Q254. Merge sort

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
Are these interview questions helpful?
Q255. XOR Query

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

Ans.

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.

Q256. Check If The String Is A Palindrome

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

Ans.

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 🌟

man-with-laptop
Q257. Count triplets in a sorted doubly linked list whose sum is equal to a given value x

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

Q258. Find the top view of the tree.

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

Software Developer _ AI/ML 2-5 years
IBM India Pvt. Limited
4.1
Hyderabad / Secunderabad
Software Developer 5-8 years
S&P Global Inc.
4.2
Gurgaon / Gurugram
Engineer I, Software Development 2-3 years
S&P Global Inc.
4.2
Hyderabad / Secunderabad
Q259. Flip Equivalent Binary Tree

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

Ans.

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.

Ans.

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

Q261. K Largest Element

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
Q262. Longest Consecutive Sequence

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

Q263. Longest Palindromic Subsequence

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

Ans.

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

Q264. Longest Palindromic Substring

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

Q265. Loot House

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

Q266. Next greater Element

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

Q267. Pythagorean Triplets

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

Q268. Aptitude Question

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

Q269. Avoiding Traps

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

Q270. Check If One String Is A Rotation Of Another String

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

Q271. First and Last Position of an Element In Sorted Array

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

Q272. Flipping Coins

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

Q273. Longest Palindromic Substring

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

Frequently asked in,
Q274. Make all elements of the array distinct.

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

Q275. Merge Point Of Two Linked Lists

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

Q276. Multilevel Inheritance

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

Q277. Ninja And The Dance Competetion

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

Q278. NINJA ATTACK

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

Q279. Nodes In Complete Binary Tree

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

Q280. Power of 2

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

Q281. Reverse the Linked List

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
Q282. Shortest Unique Prefix

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

Q283. Trapping Rainwater

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

Q284. Count Distinct Element in Every K Size Window

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

Q285. Count Set Bits

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

Ans.

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

Q286. Delete Kth node From End

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
Q287. Design a stack that supports getMin() in O(1) time and O(1) extra space

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

Q288. Digits Decoding

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

Q289. Increasing Path In Matrix

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

Q290. Longest Mountain Subarray

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

Q291. LRU Cache Implementation

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
Frequently asked in,
Q292. Make Maximum Number

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
Q293. Minimum time to burn a Tree starting from a Leaf node

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

Q294. Ninja And The Triangle

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

Q295. Occurrence of X in a Sorted Array

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
Q296. Palindromic Sub-strings

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 more
Ans.

The 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.

Q298. Strongly Connected Components (Tarjan’s Algorithm)

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

Q299. Sub Sort

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

Ans.

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

Q300. Subtree of Another Tree

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

Previous
3
4
5
6
7
8
9
Next
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.2k Interviews
3.9
 • 8k Interviews
3.7
 • 7.5k Interviews
3.7
 • 5.5k Interviews
3.8
 • 5.5k Interviews
4.1
 • 4.9k Interviews
3.8
 • 4.7k Interviews
3.5
 • 1.3k Interviews
3.8
 • 522 Interviews
4.3
 • 501 Interviews
View all

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

Software Developer Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions
Get AmbitionBox app

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter