Software Engineer

1000+ Software Engineer Interview Questions and Answers for Freshers

Updated 18 Feb 2025
search-icon

Q51. Longest Consecutive Sequence Problem Statement

You are provided with an unsorted array/list ARR of N integers. Your task is to determine the length of the longest consecutive sequence present in the array.

Expl...read more

Q52. Maximum Path Sum in a Matrix

Given an N*M matrix filled with integer numbers, determine the maximum sum that can be obtained from a path starting from any cell in the first row to any cell in the last row.

You ...read more

Q53. Maximum Subarray Sum Problem Statement

Given an array arr of length N consisting of integers, find the sum of the subarray (including empty subarray) with the maximum sum among all subarrays.

Explanation:

A sub...read more

Q54. Sort Linked List Based on Actual Values

Given a Singly Linked List of integers that are sorted based on their absolute values, the task is to sort the linked list based on the actual values.

The absolute value ...read more

Are these interview questions helpful?

Q55. Maximum Difference Problem Statement

Given an array ARR of N elements, your task is to determine the maximum difference between any two elements in ARR.

If the maximum difference is even, print EVEN. If the max...read more

Q56. Minimum Cost to Buy Oranges Problem Statement

You are given a bag of capacity 'W' kg and a list 'cost' of costs for packets of oranges with different weights. Each element at the i-th position in the list indic...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q57. Reverse Stack with Recursion

Reverse a given stack of integers using recursion. You must accomplish this without utilizing extra space beyond the internal stack space used by recursion. Additionally, you must r...read more

Q58. Write a program for Fibonacci series for n terms where n is the user input.

Ans.

Program for Fibonacci series for n terms with user input.

  • Take user input for n

  • Initialize variables for first two terms of Fibonacci series

  • Use a loop to generate the series up to n terms

  • Print the series

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

Q59. Cycle Detection in Undirected Graph Problem Statement

You are provided with an undirected graph containing 'N' vertices and 'M' edges. The vertices are numbered from 1 to 'N'. Your objective is to determine whe...read more

Q60. On a dark night, 4 people want to cross a bridge and they have only one torch. At a time at max 2 people can cross the bridge. The time required for each individual to cross the bridge is 1, 2, 5, and 10 minute...

read more
Ans.

4 people with different crossing times need to cross a bridge with one torch. Only 2 can cross at a time. What's the minimum time?

  • The person with the longest time should always be accompanied by someone else

  • The two fastest people should cross together to save time

  • The torch needs to be brought back to the starting side every time two people cross

  • The total time taken will be the sum of all individual crossing times

Q61. SpecialStack Design Problem

Design a stack that efficiently supports the getMin() operation in O(1) time with O(1) extra space. This stack should include the following operations: push(), pop(), top(), isEmpty(...read more

Q62. Unique Element In Sorted Array

Nobita wants to impress Shizuka by correctly guessing her lucky number. Shizuka provides a sorted list where every number appears twice, except for her lucky number, which appears...read more

Q63. Minimum Umbrellas Problem

You are provided with β€˜N’ types of umbrellas, where each umbrella type can shelter a certain number of people. Given an array UMBRELLA that indicates the number of people each umbrella...read more

Q64. Car Pooling Capacity Problem

You are a cab driver with a car that initially has 'C' empty seats. The car moves in a straight line towards the forward direction only. Your job is to determine if it is possible t...read more

Q65. Count Ways to Reach the N-th Stair Problem Statement

You are provided with a number of stairs, and initially, you are located at the 0th stair. You need to reach the Nth stair, and you can climb one or two step...read more

Frequently asked in, ,

Q66. Kth Smallest Element Problem Statement

You are provided with an array of integers ARR of size N and an integer K. Your task is to find and return the K-th smallest value present in the array. All elements in th...read more

Q67. Maximum of All Subarrays of Size K

You are provided with an array A containing N integers. Your task is to determine the maximum element in every contiguous subarray of size K as you move from left to right thr...read more

Q68. Subsequence Determination Problem

Your task is to verify if the given string STR1 is a subsequence of the string STR2. A subsequence means characters from STR2 are retained in their original order but some (or ...read more

Q69. LCA in a Binary Search Tree

You are given a binary search tree (BST) containing N nodes. Additionally, you have references to two nodes, P and Q, within this BST.

Your task is to determine the Lowest Common Anc...read more

Q70. Sum Between Zeroes Problem Statement

Given a singly linked list containing a series of integers separated by the integer '0', modify the list by merging nodes between two '0's into a single node. This merged no...read more

Q71. Triplets with Given Sum Problem

Given an array or list ARR consisting of N integers, your task is to identify all distinct triplets within the array that sum up to a specified number K.

Explanation:

A triplet i...read more

Frequently asked in,

Q72. Determine Pythagoras' Position for Parallelogram Formation

Euclid, Pythagoras, Pascal, and Monte decide to gather in a park. Initially, Pascal, Monte, and Euclid choose three different spots. Pythagoras, arrivi...read more

Q73. Reverse the String Problem Statement

You are given a string STR which contains alphabets, numbers, and special characters. Your task is to reverse the string.

Example:

Input:
STR = "abcde"
Output:
"edcba"

Input...read more

Ans.

The task is to reverse a given string containing lowercase letters, uppercase letters, digits, and special characters.

  • Iterate through the string from the last character to the first character and append each character to a new string.

  • Alternatively, you can use built-in string reversal functions or methods available in your programming language.

  • To solve the follow-up question with O(1) space complexity, you can use a two-pointer approach. Initialize two pointers, one at the be...read more

Q74. Kth Largest Element Problem Statement

Ninja enjoys working with numbers, and Alice challenges him to find the Kth largest value from a given list of numbers.

Input:

The first line contains an integer 'T', repre...read more

Q75. Middle of a Linked List

You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.

If there is an odd number of elements, return the middle ...read more

Q76. Connecting Ropes with Minimum Cost

You are given 'N' ropes, each of varying lengths. The task is to connect all ropes into one single rope. The cost of connecting two ropes is the sum of their lengths. Your obj...read more

Q77. Permutations Problem Statement

Given an array of distinct integers, find all possible permutations of the array.

Explanation:

A permutation is a mathematical way of determining the number of possible arrangemen...read more

Q78. Subtree of Another Tree Problem Statement

Given two binary trees, T and S, determine whether S is a subtree of T. The tree S should have the same structure and node values as a subtree of T.

Explanation:

A subt...read more

Q79. Sum Of Zeroes Coverage Calculation

You are provided with a binary matrix containing dimensions 'N * M', comprised only of 0s and 1s. Your task is to compute the aggregated sum of coverages for all the zeros in ...read more

Q80. Check if Two Trees are Mirror

Given two arbitrary binary trees, your task is to determine whether these two trees are mirrors of each other.

Explanation:

Two trees are considered mirror of each other if:

  • The r...read more

Q81. Kth Largest Element Problem

Given an array containing N distinct positive integers and a number K, determine the Kth largest element in the array.

Example:

Input:
N = 6, K = 3, array = [2, 1, 5, 6, 3, 8]
Output...read more

Q82. Geometric Progression Subsequences Problem Statement

Given an array of β€˜N’ integers, determine the number of subsequences of length 3 that form a geometric progression with a specified common ratio β€˜R’.

Explana...read more

Q83. Kruskal’s Minimum Spanning Tree Algorithm Problem Statement

You are given a connected undirected weighted graph. Your task is to determine the weight of the minimum spanning tree of this graph.

A minimum spanni...read more

Q84. Minimum Operations Problem Statement

Given an array ARR consisting of N positive integers, your task is to determine the minimum number of operations required to make all elements in the array equal. The operat...read more

Q85. Rectangle Area Calculation

Given a list of rectangles, where each rectangle is represented by an array of four integers indicating its bottom-left and top-right corners, calculate the total area covered by all ...read more

Q86. Remove Invalid Parentheses

Given a string containing only parentheses and letters, your goal is to remove the minimum number of invalid parentheses to make the input string valid and return all possible valid s...read more

Q87. Reverse Alternate K Nodes Problem Statement

You are given a singly linked list of integers along with a positive integer 'K'. The task is to modify the linked list by reversing every alternate 'K' nodes of the ...read more

Q88. String Transformation Problem

Given a string (STR) of length N, you are tasked to create a new string through the following method:

Select the smallest character from the first K characters of STR, remove it fr...read more

Q89. You have a cuboid (m*n*p) each block of the cuboid is having a metallic ball. Now we are passing X-ray from front face and getting a bool matrix1 of m*p the elements are set if there is a black spot.(as we are...

read more
Ans.

Yes, it is possible to get the accurate result from the given data.

  • The coordinates (i,j,k) where metallic balls are present can be determined by finding the set elements in both matrix1 and matrix2.

  • Additional data is not required as the given data is sufficient to determine the coordinates.

  • The coordinates can be obtained by iterating through the elements of matrix1 and matrix2 and checking for set elements.

Q90. Subarray With Given Sum Problem Statement

Given an array ARR of N integers and an integer S, determine if there exists a contiguous subarray within the array with a sum equal to S. If such a subarray exists, re...read more

Q91. Find the Kth Row of Pascal's Triangle Problem Statement

Given a non-negative integer 'K', determine the Kth row of Pascal’s Triangle.

Example:

Input:
K = 2
Output:
1 1
Input:
K = 4
Output:
1 4 6 4 1

Constraints...read more

Q92. Intersection of Linked List Problem

You are provided with two singly linked lists containing integers, where both lists converge at some node belonging to a third linked list.

Your task is to determine the data...read more

Frequently asked in,

Q93. Minimum Subset Sum Difference Problem

Given an array of non-negative integers, your task is to partition this array into two subsets such that the absolute difference between the sums of the subsets is minimize...read more

Q94. Pair Sum Problem Statement

You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.

Note:

Each pa...read more

Q95. Ninja's Pattern with Powers of 2

Ninja, who loves playing with numbers, sets out to arrange numbers within 'N' rows. The unique arrangement follows these rules: the first row contains 1 number, the second row c...read more

Q96. Print Series Problem Statement

Given two positive integers N and K, your task is to generate a series of numbers by subtracting K from N until the result is 0 or negative, then adding K back until it reaches N ...read more

Q97. Word Occurrence Counting

Given a string 'S' of words, the goal is to determine the frequency of each word in the string. Consider a word as a sequence of one or more non-space characters. The string can have mu...read more

Q98. Increase Number By 1 Problem Statement

Given an array of integers NUM that consists of N elements, where the array represents the digits of a number, your task is to add 1 to this number. The number is positive...read more

Q99. there are 2 processors each executing a separate program- processor 1 int a=10 int *ptr = &a; ptr is written into file1 processor sleeps for 10sec printf("%d",a); processor 2 int *p; file1 is read and contents...

read more
Ans.

The output will be 5.

  • Processor 1 initializes variable 'a' with a value of 10 and creates a pointer 'ptr' pointing to 'a'.

  • Processor 1 writes the value of 'ptr' into 'file1' and then sleeps for 10 seconds.

  • Processor 2 reads the contents of 'file1' and saves it in pointer 'p'.

  • Processor 2 assigns the value 5 to the memory location pointed by 'p'.

  • When Processor 1 wakes up and executes the printf statement, it will print the updated value of 'a', which is 5.

Q100. two puzzles: 1. how can you cut a cake in 8 pieces in minimum number of cuts(answered) ,2.make 4 equilateral triangles using 6 matchsticks(answered)

Ans.

1. Cut cake in 8 pieces in minimum cuts. 2. Make 4 equilateral triangles using 6 matchsticks.

  • 1. Cut cake in half horizontally and vertically. Cut each quarter diagonally.

  • 2. Use 3 matchsticks to form a triangle. Use the other 3 to connect the centers of each triangle.

  • Both puzzles require creative thinking and problem-solving skills.

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.6k 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
3.5
Β β€’Β 613 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