Software Engineer

1000+ Software Engineer Interview Questions and Answers for Freshers

Updated 18 Feb 2025
search-icon

Q101. Divide Chocolates Problem Statement

Ninja bought chocolate consisting of several chunks, and the sweetness of each chunk is represented in an array ARR. He wants to divide the chocolate into K + 1 parts (cuts),...read more

Q102. Find Duplicates in an Array

Given an array ARR of size 'N', where each integer is in the range from 0 to N - 1, identify all elements that appear more than once.

Return the duplicate elements in any order. If n...read more

Ans.

Find duplicates in an array of integers within a specified range.

  • Iterate through the array and keep track of the count of each element using a hashmap.

  • Identify elements with count greater than 1 as duplicates.

  • Return the duplicate elements as the output.

  • Handle edge cases like empty array or no duplicates found.

Frequently asked in,

Q103. Given 2 game scenarios for basketball, and given p as the probability of making a basket in an attempt, I have to understand the condition where game1 would be preferable over game2. In first game, I have one t...

read more
Ans.

Comparing 2 basketball game scenarios with different number of trials and baskets required to win

  • Calculate the probability of winning in each game scenario using binomial distribution formula

  • Compare the probabilities to determine which game scenario is preferable

  • In game1, the probability of winning is p. In game2, the probability of winning is the sum of probabilities of making 2 or 3 baskets

  • If p is high, game1 is preferable. If p is low, game2 is preferable

  • For example, if p ...read more

Q104. Palindrome Partitioning II Problem Statement

Given a string ‘str’, find the minimum number of partitions needed such that every segment of the string is a palindrome.

The task is to make cuts in the string to p...read more

Are these interview questions helpful?

Q105. Remove Nodes with Specific Value from Linked List

You are provided with a singly linked list consisting of integer values and an integer 'K'. Your task is to eliminate all nodes from the linked list that have a...read more

Ans.

Remove nodes with specific value from a singly linked list.

  • Traverse the linked list and remove nodes with value equal to 'K'.

  • Update the references of the previous node to skip the removed node.

  • Handle edge cases like removing the head node or multiple nodes with the same value.

  • Return the modified linked list after removal.

Q106. Write a C code to delete a node from circular doubly linked list where you cannot delete the head node.. (At the last i was very eager to know the answers to the questions he asked me, But he refused to answer...

read more
Ans.

C code to delete a node from circular doubly linked list without deleting the head node.

  • Start from the head node and traverse the list until the desired node is found.

  • Update the next and previous pointers of the adjacent nodes to skip the node to be deleted.

  • Free the memory allocated for the node to be deleted.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q107. Bit Set Problem Statement

You are provided with a string, termed as DIGIT_PATTERN, which consists solely of digits. The objective is to identify the first digit that repeats in the sequence. If there's no repea...read more

Ans.

Identify the first repeating digit in a given string of digits.

  • Iterate through the string and keep track of seen digits using a set.

  • Return the first digit that repeats, or -1 if no digit repeats.

  • Time complexity: O(n), where n is the length of the input string.

Q108. Chocolate Distribution Problem

You are given an array/list CHOCOLATES of size 'N', where each element represents the number of chocolates in a packet. Your task is to distribute these chocolates among 'M' stude...read more

Frequently asked in,

Software Engineer Jobs

Software Engineer- Golang/Kubernetes 3-7 years
Red Hat India Pvt Ltd
4.3
Bangalore / Bengaluru
Software Engineer 2-5 years
Red Hat India Pvt Ltd
4.3
Pune
Software Engineer 1-3 years
Red Hat India Pvt Ltd
4.3
Pune

Q109. Find Nodes at a Specific Distance from Target in a Binary Tree

Given a binary tree, a target node within this tree, and an integer K, identify and return all nodes that are exactly K edges away from the target ...read more

Q110. Find the Second Largest Element

Given an array or list of integers 'ARR', identify the second largest element in 'ARR'.

If a second largest element does not exist, return -1.

Example:

Input:
ARR = [2, 4, 5, 6, ...read more

Q111. First Non-Repeating Character Problem Statement

You are given a string consisting of English alphabet characters. Your task is to identify and return the first character in the string that does not repeat. If e...read more

Q112. Maximum Non-Crossing Ropes Problem

In a village with a river at its center, there are ‘N’ houses on each bank of the river. The northern bank’s houses have distinct X-coordinates given by an array A[1], A[2], ....read more

Q113. Shortest Substring with All Characters

Determine the shortest substring of the string S that includes every character from S at least once. If multiple shortest substrings exist, return the one that starts the ...read more

Q114. Sort an Array in Wave Form

You are given an unsorted array ARR. Your task is to sort it so that it forms a wave-like array.

Input:

The first line contains an integer 'T', the number of test cases.
For each test ...read more

Q115. Are you okay to learn front end and back end technologies to ensure you are a complete developer in the longer run? Would you be able to learn the concepts if a timeline is given?? If yes, explain your learning...

read more
Ans.

Yes, I am willing to learn front end and back end technologies and have a learning strategy in place.

  • I believe in continuous learning and growth as a developer.

  • I have experience in learning new technologies quickly and efficiently.

  • My learning strategy involves breaking down concepts into smaller parts and practicing regularly.

  • I also utilize online resources and seek guidance from experienced colleagues.

  • Examples of technologies I have learned include React, Node.js, and MongoD...read more

Q116. Determine the Left View of a Binary Tree

You are given a binary tree of integers. Your task is to determine the left view of the binary tree. The left view consists of nodes that are visible when the tree is vi...read more

Q117. Max Length of Same Indexed Subarrays Problem

Given two integer arrays A and B, and an integer C, the goal is to determine the maximum possible length K of the same indexed subarrays. The condition is that the s...read more

Q118. MergeSort Linked List Problem Statement

You are given a Singly Linked List of integers. Your task is to sort the list using the 'Merge Sort' algorithm.

Input:

The input consists of a single line containing the ...read more

Q119. Problem: Permutations of a String

Given a string STR consisting of lowercase English letters, your task is to return all permutations of the given string in lexicographically increasing order.

Explanation:

A st...read more

Q120. Subarray with Equal Occurrences Problem Statement

Given an array ARR consisting of 0s and 1s only, your task is to determine the number of non-empty subarrays where the number of 0s and 1s are equal.

Input:

The...read more

Q121. Diagonal Traversal of a Binary Tree

Given a binary tree of integers, find its diagonal traversal. Refer to the example for clarification on diagonal traversal.

Example:

Explanation:
Consider lines at an angle o...read more

Q122. Minimum Number of Swaps to Sort an Array

Find the minimum number of swaps required to sort a given array of distinct elements in ascending order.

Input:

T (number of test cases)
For each test case:
N (size of the...read more

Q123. All Root to Leaf Paths in Binary Tree

You have a binary tree containing 'N' nodes labeled from 1 to 'N'. Your objective is to enumerate every path from the root to each leaf.

A leaf is defined as a node with no...read more

Ans.

The task is to print all the root to leaf paths of an arbitrary binary tree.

  • Traverse the binary tree using depth-first search (DFS) algorithm

  • Maintain a current path list to keep track of the nodes in the current path

  • When reaching a leaf node, add the current path to the result list

  • Recursively explore the left and right subtrees

  • Remove the last node from the current path after exploring each subtree

Q124. Count Diagonal Paths

You are given a binary tree. Your task is to return the count of the diagonal paths to the leaf of the given binary tree such that all the values of the nodes on the diagonal are equal.

Inp...read more

Q125. Distinct Subsequences Problem Statement

Given two strings S and T consisting of lowercase English letters, the task is to count the distinct occurrences of T in S as a subsequence.

Explanation

A subsequence is ...read more

Q126. Group Anagrams Problem Statement

Given an array or list of strings called inputStr, your task is to return the strings grouped as anagrams. Each group should contain strings that are anagrams of one another.

An...read more

Q127. Minimum Falling Path Sum Problem Statement

Given a square array VEC of integers with N rows and N columns, you need to determine the minimum sum of a falling path through this square array. The array has equal ...read more

Q128. Segregate Even and Odd Nodes in a Linked List

You are given the head node of a singly linked list head. Your task is to modify the linked list so that all the even-valued nodes appear before all the odd-valued ...read more

Q129. Tic-Tac-Toe Design Problem

Design a 2-player Tic-Tac-Toe game played on an N * N grid where Player 1 uses ‘X’ and Player 2 uses ‘O’. A move is always valid and occupies an empty spot.

If a player places N of th...read more

Q130. Construct Complete Binary Tree Problem Statement

Given an array or list 'ARR' containing values for 'N' nodes of a binary tree, your task is to construct a complete binary tree in a level order fashion. The ele...read more

Q131. Count Subsequences Problem Statement

Given an integer array ARR of size N, your task is to find the total number of subsequences in which all elements are equal.

Explanation:

A subsequence of an array is derive...read more

Q132. Design a Constant Time Data Structure

Create a data structure that maintains mappings between keys and values, supporting the following operations in constant time:

1. INSERT(key, value): Add or update the inte...read more

Q133. Distinct Subsets Count

Given an array arr of N integers that may include duplicates, determine the number of subsets of this array containing only distinct elements.

The result should be returned modulo 109 + 7...read more

Q134. Factorial Calculation Problem

Given an integer N, determine the factorial value of N. The factorial of a number N is the product of all positive integers from 1 to N.

Input:

First line of input: An integer 'T',...read more

Q135. Given a list of words. Given three operations find out the minimum steps to reach from source string to destination string. Basically, -----/ this is the problem with some modification. For this question I said...

read more
Ans.

The question is about finding the minimum steps to reach from a source string to a destination string using three operations.

  • BFS and DFS are graph traversal techniques that can be used to solve this problem.

  • BFS is typically used when finding the shortest path or exploring all possible paths in a graph.

  • DFS is useful when searching for a specific path or exploring deeply into a graph.

  • In this case, BFS can be used to find the minimum steps to reach the destination string.

  • Create ...read more

Q136. Ninja Technique Problem Statement

Implement a function that determines whether a given numeric string contains any substring whose integer value equals the product of two consecutive integers. The function shou...read more

Q137. Process p1 & p2. p1 writes to an address & sleeps...p2 writes another value to the same address & terminates. Now p1 wakes up & reads value of that address. He asked me the output.What is Role of OS in this...

read more
Ans.

The output of p1 depends on the synchronization mechanism used by the operating system.

  • If the OS uses a lock or semaphore to synchronize access to the shared address, p1 will read the value written by p2.

  • If the OS does not provide any synchronization mechanism, the output of p1 is unpredictable and may vary.

  • The role of the OS is to manage the execution of processes, provide synchronization mechanisms, and ensure data integrity.

Q138. Reverse a Linked List Problem Statement

You are given a Singly Linked List of integers. Your task is to reverse the Linked List by changing the links between nodes.

Input:

The first line of input contains a sin...read more

Q139. Rotate Array Problem Statement

The task is to rotate a given array with N elements to the left by K steps, where K is a non-negative integer.

Input:

The first line contains an integer N representing the size of...read more

Q140. Serialization and Deserialization of an N-ary Tree

Given an N-ary tree where each node has at most 'N' child nodes, the task is to serialize the tree into a sequence of bits and then deserialize it back to reco...read more

Q141. What is associative mapping ? What is difference between associative mapping and direct mapping ? What is set associative mapping? (After hearing last question I cursed myself for not reading AMP book for MST.....

read more
Ans.

Associative mapping is a cache mapping technique where a memory block can be placed in any cache location. Direct mapping is a technique where each memory block is mapped to a specific cache location. Set associative mapping is a combination of both.

  • Associative mapping allows flexibility in placing memory blocks in cache.

  • Direct mapping assigns a specific cache location for each memory block.

  • Set associative mapping combines the flexibility of associative mapping with the struc...read more

Q142. 22. You are given two hourglasses, one of 11 minutes and the other of 7 minutes. How will you measure 4 minutes using it?

Ans.

To measure 4 minutes using two hourglasses of 11 and 7 minutes, start both hourglasses simultaneously and flip the 7-minute hourglass when it runs out. When the 11-minute hourglass runs out, 4 minutes will have passed.

  • Start both hourglasses simultaneously

  • When the 7-minute hourglass runs out, flip it

  • When the 11-minute hourglass runs out, 4 minutes will have passed

Q143. Orange Rotting Problem Statement

Consider a grid containing oranges. Each cell in this grid can hold one of three integer values:

  • Value 0: Represents an empty cell.
  • Value 1: Represents a fresh orange.
  • Value 2:...read more
Ans.

The task is to determine the minimum time required for all fresh oranges to become rotten in a grid.

  • Create a queue to store the rotten oranges and their time of rotting.

  • Iterate through the grid to find the initial rotten oranges and add them to the queue.

  • Perform BFS by popping each rotten orange from the queue, rot adjacent fresh oranges, and add them to the queue with updated time.

  • Continue until the queue is empty, keeping track of the maximum time taken to rot all oranges.

  • I...read more

Q144. 1. Write a C program to print only the even numbers from the fibonacci series(optimization techniques such as dynamic programming expected) 2. What is the difference between .lib and .dll files in Windows or .a...

read more
Ans.

A C program to print even numbers from the Fibonacci series using dynamic programming.

  • Use dynamic programming to store previously calculated Fibonacci numbers.

  • Iterate through the Fibonacci series and check if each number is even.

  • Print the even numbers found.

Q145. Distributing Coins in a Binary Tree

You are provided with the root of a binary tree that consists of 'N' nodes. Each node in this tree contains coins, and the total number of coins across all nodes is equal to ...read more

Q146. Replace 0s Problem Statement

You are given a matrix where every element is either a 1 or a 0. The task is to replace 0 with 1 if it is surrounded by 1s. A 0 (or a set of 0s) is considered to be surrounded by 1s...read more

Q147. Anagram Substring Search

Given two strings 'STR' and 'PTR', identify all starting indices of 'PTR' anagram substrings in 'STR'. Two strings are anagrams if one can be rearranged to form the other.

Input:

First ...read more

Q148. Binary Search Tree Insertion

Given the root node of a binary search tree and a positive integer, you need to insert a new node with the given value into the BST so that the resulting tree maintains the properti...read more

Q149. Candies Distribution Problem Statement

Prateek is a kindergarten teacher with a mission to distribute candies to students based on their performance. Each student must get at least one candy, and if two student...read more

Q150. Given two sides of a river having the same cities labeled in characters. Bridges are to be drawn from one side to another that can connect the same labels but the bridges shudnt cross each other. Find the max n...

read more
Ans.

The maximum number of bridges that can be connected between two sides of a river without crossing each other.

  • This is a dynamic programming problem.

  • Create a 2D array to store the maximum number of bridges that can be connected at each position.

  • Initialize the first row and column of the array with 0.

  • Iterate through the sides of the river and compare the labels.

  • If the labels match, update the value in the array by adding 1 to the diagonal element.

  • If the labels don't match, take ...read more

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

Interview experiences of popular companies

3.7
 • 10.5k Interviews
3.8
 • 8.2k Interviews
3.6
 • 7.7k Interviews
3.7
 • 5.7k Interviews
3.8
 • 5.6k Interviews
3.7
 • 4.8k Interviews
3.5
 • 3.9k Interviews
3.5
 • 3.8k Interviews
3.8
 • 3k 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 Engineer 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

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