Software Developer

7000+ Software Developer Interview Questions and Answers

Updated 13 Jan 2025
search-icon
Q201. Last Stone Weight

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

Ans.

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.

Q202. Maximum Sum Rectangle

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

Q203. Meeting

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

Q204. Minimum Cost Path

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

Are these interview questions helpful?
Q205. Next Greater Element

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

Q206. Partition Equal Subset Sum

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 🌟

man-with-laptop
Q207. Quick Sort

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

Q208. Search In Rotated Sorted Array

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

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
Q209. Sort An Array of 0s, 1s and 2s

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

Q210. Spiral Matrix

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:

Spiral path of a matrix

Input Format:
The first line contains an integer 'T' ...read more
Q211. SQL Questions

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

Code 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

Q213. Common Elements

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
Q214. Compress the String

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
Q215. Covid Vaccination

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

Q216. Delete a Node from Linked List

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
Q217. Find Pair Sum equal to K.

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
Q218. Flatten 2D array

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:
  • ‘...read more
  • Q219. Interleaving Two Strings

    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

    Q220. Longest Unique Substring

    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

    Q221. Max GCD Pair

    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

    Q222. Maximum In Sliding Windows Of Size K

    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

    Q223. Maximum length pair chain

    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

    Q224. Merge two sorted lists (in-place)

    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
    Q225. Next Greater Element

    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

    Q226. Rotten oranges problem

    You have been given a grid containing some oranges. Each cell of this grid has one of the three integers values:

  • Value 0 - representing an empty cell.
  • Value 1 - representing a fresh ora...read more
  • Q227. Split Binary String

    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

    Q228. Two Sum in a BST

    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

    Q229. Unique Paths

    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

    Q230. BFS in Graph

    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

    Q231. Bubble Sort

    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

    Q232. Encode the Message

    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

    Q233. Find Duplicates In Array

    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

    Frequently asked in,
    Q234. Find the elements value if present in the cache.

    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

    Q235. Pairs with difference K

    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

    Q236. Shortest Path In A Binary Maze

    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

    Q237. Sort 0 1

    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

    Q238. Word Break

    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
    Q239. Bursting Balloons

    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

    Q240. Maximum 0-1 Distance

    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

    Q241. Ninja And Candies

    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

    Q242. Occurrence of Each Word

    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

    Q243. Print Nodes at Distance K From a Given Node

    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

    Q244. Relative Sorting

    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

    Ans.

    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

    Q245. Snake and Ladder

    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

    Q246. Special Binary Tree.

    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

    Q247. Special Numbers

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

    What 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

    Q249. Clone Linked List with Random Pointer

    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

    Q250. Connect N Ropes With Minimum Cost

    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

    Previous
    2
    3
    4
    5
    6
    7
    8
    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.6
     • 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