SDE-2

300+ SDE-2 Interview Questions and Answers

Updated 7 Nov 2024
Q51. Find all distinct palindromic substrings of a given string

Ninja did not do homework. As a penalty, the teacher has given a string ‘S’ to ninja and asked him to print all distinct palindromic substrings of the g...read more

Q52. Median of Two Sorted Arrays

You are given two sorted arrays 'A' & 'B' of sizes 'N' & 'M'. You need to find the median of the two arrays when merged. If the total number of elements i.e., N + M is even then the m...read more

Q53. System Design Question

Tagging system across all Atlassian products (Jira, Confluence, Bitbucket). Tag addition/update/delete in one product should reflect across all other products. Design DB schema and High le...read more

Ans.

Design a tagging system across Atlassian products for seamless tag synchronization.

  • Create a centralized tag management service

  • Design a database schema to store tags and their associations with products

  • Implement event-driven architecture to propagate tag changes across products

  • Use a message broker for asynchronous communication between services

  • Ensure data consistency and handle conflicts during tag updates

  • Consider scalability and performance requirements

Q54. Two Sum

You are given an array of integers 'ARR' of length 'N' and an integer Target. Your task is to return all pairs of elements such that they add up to Target.

Note:

We cannot use the element at a given inde...read more
Frequently asked in,
Are these interview questions helpful?
Q55. Convert binary tree to mirror tree

Given a binary tree, convert this binary tree into its mirror tree.

A binary tree is a tree in which each parent node has at most two children.

Mirror of a Tree: Mirror of a Bi...read more

Q56. Maximum Depth Of A Binary Tree

You are given the root node of a binary tree with N nodes, whose nodes have integer values. Your task is to find the maximum depth of the given Binary tree.

Depth of a binary tree...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop
Q57. Pair Chain - Maximum Length

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

Q58. There is a 12 km road and a contractor who is in-charge of repairing it. Contractor updates you about the work which is done in patches. Like “Road between 3.2 km to 7.9 km repaired ”, “Road between 1.21 km to ...

read more
Ans.

Find longest continuous patch on a 12 km road with updates in patches

  • Maintain a variable to keep track of current patch length

  • Update the variable whenever a new patch is added

  • Maintain a variable to keep track of longest patch so far

  • Compare current patch length with longest patch length and update if necessary

  • Use a sorted data structure like a binary search tree to store the patches for efficient search

  • Time complexity: O(nlogn) where n is the number of updates by the contracto...read more

SDE-2 Jobs

SDE-1 and SDE-2 (React Native) 1-6 years
Licious
3.7
Kochi
SDE-2 2-4 years
Simplilearn
3.2
₹ 7 L/yr - ₹ 12 L/yr
Bangalore / Bengaluru
SDE-2 Frontend 4-6 years
Hiverhq
4.1
Bangalore / Bengaluru
Q59. Top View of the Binary Tree

You have been given a Binary Tree of integers. You are supposed to return the top view of the given binary tree.

Top view of the binary tree is the set of nodes which are visible when...read more

Q60. Check if String has Valid parenthesis ()[]{}

You're given string ‘STR’ consisting solely of “{“, “}”, “(“, “)”, “[“ and “]” . Determine whether the parentheses are balanced.

Input Format:
The first line contains...read more
Q61. Find K Closest Elements

You are given a sorted array 'A' of length 'N', two integers 'K' and 'X'. Your task is to print 'K' integers closest to 'X', if two integers are at the same distance return the smaller on...read more

Q62. Number Of Pairs With Given Sum

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:
G...read more
Q63. Reverse Linked List
Input Format :
The first line of input contains a single integer T, re...read more
Q64. Word Break

You are given a non-empty string containing no spaces (say sentence) and a dictionary of list of non-empty strings (say the list of words). You are supposed to construct and return all possible sente...read more

Q65. Balanced parentheses

Given an integer ‘N’ representing the number of pairs of parentheses, Find all the possible combinations of balanced parentheses with the given number of pairs of parentheses.

Note :

Conditi...read more
Q66. Find Kth row of Pascal's Triangle

You are given a non-negative integer 'K'. Your task is to find out the Kth row of Pascal’s Triangle.

In Mathematics, Pascal's triangle is a triangular array where each entry of ...read more

Q67. Word Ladder

You are given two strings BEGIN and END and an array of strings DICT. Your task is to find the length of the shortest transformation sequence from BEGIN to END such that in every transformation you c...read more

Q68. Loot Houses

A thief wants to loot houses. He knows the amount of money in each house. He cannot loot two consecutive houses. Find the maximum amount of money he can loot.

Input Format :
The first line of input c...read more
Q69. 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

Q70. Minimum Jumps

Bob lives with his wife in a city named Berland. Bob is a good husband, so he goes out with his wife every Friday to ‘Arcade’ mall.

‘Arcade’ is a very famous mall in Berland. It has a very unique t...read more

Q71. Prime time again

You have been given two integers ‘DAY_HOURS’ and ‘PARTS’. Where ‘DAY_HOURS’ is the number of hours in a day and a day can be divided into ‘PARTS’ equal parts. Your task is to find total instanc...read more

Q72. Print Permutations - String

You are given an input string 'S'. Your task is to find and return all possible permutations of the input string.

Note:
1. The input string may contain the same characters, so there w...read more
Q73. Time to Burn Tree

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 the tree, your task is to print the...read more

Q74. Maximum Product Subarray

You are given an array “arr'' of integers. Your task is to find the contiguous subarray within the array which has the largest product of its elements. You have to report this maximum pr...read more

Q75. Minimum steps to reach target by a Knight

You have been given a square chessboard of size ‘N x N’. The position coordinates of the Knight and the position coordinates of the target are also given.

Your task is t...read more

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

Q77. Reverse Only Letters

You are given a string, ‘S’. You need to reverse the string where characters that are not an alphabet stay in the same place, and the rest reverse their positions.

Eg: “a-bcd” becomes “d-cba...read more

Q78. Equilibrium Index

You are given an array Arr consisting of N integers. You need to find the equilibrium index of the array.

An index is considered as an equilibrium index if the sum of elements of the array to t...read more

Q79. Find Peak Element

Given an array of ‘n’ integers arr. Find the Peak element of the array. The peak element of an array is defined as that element which is greater than both of its neighbours. I.e if arr[i] is th...read more

Q80. Left View Of Binary Tree

Given a binary tree. Print the Left View of the Tree.

Example :
If the input tree is as depicted in the picture: 

alt text

The Left View of the tree will be: 2 35 2 
Input format :
Elements in t...read more
Q81. Max Submatrix

Ninja has been given a matrix ‘MAT’ of integers having size ‘N’ x ‘M’ i.e. N rows and M columns. Ninja has to find the maximum sum submatrix in it. In other words, he has to find the maximum sum ov...read more

Q82. Rat In a Maze All Paths

You are given a 'N' * 'N' maze with a rat placed at 'MAZE[0][0]'. Find and print all paths that rat can follow to reach its destination i.e. 'MAZE['N' - 1]['N' - 1]'. Rat can move in any ...read more

Q83. Two Teams (Check whether graph is bipartite or not)

You are given an undirected graph of ‘N’ nodes and ‘M’ edges. Your task is to print 1 if this graph can be divided into exactly two disjoint cliques. Else, you...read more

Q84. Minimum Cost To Connect Sticks

You are given an array/list ‘ARR’ of ‘N’ positive integers where each element describes the length of the stick. You have to connect all sticks into one. At a time, you can join an...read more

Q85. Minimum Operations To Make Array Equal

You are given an array ‘ARR’ of length ‘N’ which is filled with the values such that ARR[i] = (2*i + 1). You have to perform operations on the ‘ARR’ to make all elements of...read more

Q86. Rain Water Trapping Problem

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 rainwat...read more

Q87. Trailing Zeros in Factorial

You are given an integer N, you need to find the number of trailing zeroes in N! (N factorial).

Note:

1. Trailing zeros in a number can be defined as the number of continuous suffix z...read more
Q88. Algorithm to find best insert position in sorted array

You are given a sorted array 'A' of length 'N' with distinct integers and a target integer 'M'. You need to return the position of 'M' if it existed in the ...read more

Q89. Course Schedule

You are a student of Netaji Subhas Institute of Technology. You have to take ‘N’ number of courses labelled from 1 to N to complete your B.Tech Degree.

Some courses may have prerequisites, for ex...read more

Q90. Find middle node of a Linked List

Given the head node of the singly linked list, return a pointer pointing to the middle of the linked list.

If there are an odd number of elements, return the middle element if t...read more

Q91. House robber

Mr. X is a professional robber planning to rob houses along a street. Each house has a certain amount of money hidden. All houses along this street are arranged in a circle. That means the first hou...read more

Q92. Minimum Cost of Reducing Array

You are given an array 'ARR' consisting of 'N' positive integers, and you need to reduce the size of the array to 1 by performing an operation several number of times. In a single ...read more

Q93. Rearrange linked list with child and next pointers into a single linked list.

You are given a multi-level linked list of 'N' nodes, each node has a next and child pointer which may or may not point to a separate...read more

Q94. Subarray With Given Sum

Given an array ARR of N integers and an integer S. The task is to find whether there exists a subarray(positive length) of the given array such that the sum of elements of the subarray eq...read more

Q95. Maximize the sum

You are given two sorted arrays of distinct integers, ‘ARR1’ and ‘ARR2’. If you find a common element in both arrays, you can switch from one array to another.

Your task is to find a path throug...read more

Q96. Ninja and the bulbs

Ninja owns an electronic shop. In the shop, Ninja has 'N' bulbs. To sell these bulbs, Ninja has to check if they are of good quality. To check bulbs, Ninja uses a unique technique.

In this te...read more

Q97. Arithmetic Progression Queries

Given an integer array(ARR) of size N, the following operations need to be performed:

update(l, r, val) : Add (val + i) to arr[l + i] where, 0 <= i <= r - l. rangeSum(l, r): return...read more
Q98. Binary Tree - Replace every node with Sum of nodes Greater than that node

Given a binary tree with 'N' number of nodes, convert it to a Greater Tree such that data of every node of the original BST is changed to...read more

Q99. Group Anagrams Together

You have been given an array/list of strings 'STR_LIST'. You are supposed to return the strings as groups of anagrams such that strings belonging to a particular group are anagrams of one...read more

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

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
 • 10k Interviews
4.1
 • 4.9k Interviews
4.0
 • 1.3k Interviews
3.9
 • 390 Interviews
3.9
 • 202 Interviews
3.8
 • 198 Interviews
3.4
 • 140 Interviews
3.7
 • 77 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

SDE-2 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