SDE-2
50+ SDE-2 Interview Questions and Answers for Freshers
Ninja is given an array of integers that contain numbers in random order. He needs to write a program to find and return the number which occurs the maximum times in the given input. He ...read more
You are given an infinite supply of coins of each of denominations D = {D0, D1, D2, D3, ...... Dn-1}. You need to figure out the total number of ways W, in which you can make a change fo...read more
You are given a string 'STR' consisting of lower and upper case characters. You need to remove the consecutive duplicates characters, and return the new string.
Exampl...read more
The task is to remove consecutive duplicate characters from a given string and return the new string.
Iterate through the characters of the string
Compare each character with the next character
If they are the same, skip the next character
If they are different, append the current character to the new string
Ninja got a test problem in which he was given an integer and he had to find the sum of even digits and odd digits separately.
Ninja is very weak in studies and didn’t know much about odd and e...read more
You are trying to cook an egg for exactly fifteen minutes, but instead of a timer, you are given two ropes which burn for exactly 1 hour each. The ropes, however, are of uneven densities – i e , half the ...read more
You are given a 2-dimensional array/list having N rows and M columns, which is filled with ones(1) and zeroes(0). 1 signifies land, and 0 signifies water.
A cell is said to be connected to...read more
Share interview questions and help millions of jobseekers 🌟
Given that integers are read from a data stream. Your task is to find the median of the elements read so far.
Median is the middle value in an ordered integer list. If the size of the list is ...read more
You are given the list of costs of pants in an array “pants”, shirts in an array “shirts”, shoes in an array “shoes”, and skirts in an array “skirts”. You are also given a budget amount ‘X’ to s...read more
SDE-2 Jobs
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
You are given an array of N elements. This array represents the digits of a number. In an operation, you can swap the value at any two indices. Your task is to find the maximum number by using ope...read more
A noticeable aspect in this puzzles is the fact that there’s a circular misplacement, which implies if apple is wrongly labelled as Apple, Apple can’t be labelled as Orange, i.e., it has to be labe...read more
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
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
You are given a Singly Linked List of integers. You need to reverse the Linked List by changing the links between nodes.
Input Format :
The first line of input contains a single integer T, re...read more
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
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
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
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
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
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
You are given an array/list ARR consisting of N integers. Your task is to find all the distinct triplets present in the array which adds up to a given number K.
An array is said to have a...read more
Given a string (STR) of length N, you have to create a new string by performing the following operation:
Take the smallest character from the first 'K' characters of STR, remove it from STR...read more
You have been given an integer array/list(ARR) of size N which contains numbers from 0 to (N - 2). Each number is present at least once. That is, if N = 5, the array/list constitutes values rangin...read more
Ninja is stuck in a city with ‘N’ colonies, and each colony contains ‘K’ houses. Ninja is currently at the house number “sourceHouse” present in the colony with colony number “sourceColony”. He wants ...read more
You are given a binary tree. Apart from the left and right child pointers, each node in the given binary tree points to a random node in the given binary tree. You are s...read more
You have been given ‘N’ courses and some courses may have prerequisites. Now consider a matrix ‘PREREQUISITES’ of size 'M' x 2 which represents that you must complete course 'PREREQUISITES[i][...read more
You are given an M X N matrix of integers ARR. Your task is to find the maximum sum rectangle.
Maximum sum rectangle is a rectangle with the maximum value for the sum of integers present wi...read more
You have been given a binary tree of integers with N number of nodes. Your task is to check if that input tree is a BST (Binary Search Tree) or not.
A binary search tree (BST) is a binary tree data ...read more
You are given an array 'ARR' of 'N' positive integers. You need to find the minimum number of operations needed to make all elements of the array equal. You can perform addition, multiplicatio...read more
Given a binary tree and the value of two nodes, find the distance between the given two nodes of the Binary Tree.
Distance between two nodes is defined as the minimum number ...read more
You are given two strings 'S' and 'T' of lengths 'N' and 'M' respectively. Find the "Edit Distance" between the strings.
Edit Distance of two strings is the minimum number of steps required to make...read more
Write a SQL query to print the highest salary of each department in a employee table that contains employee details - department to which employee belong, salary of employee.
Given two numbers represented by linked lists. Your task is find the sum list and return the head of the sum list.
The sum list is a linked list representation of addition of two numbers.
Input ...read more
1. Whats polymorphism - compile time and run time.
2. What are exceptions in Java - Since my primary language was C++, I explained exception in C++ only.
3. What are collections in Java- list, ...read more
Exception handling in C++ in detail.
What do mean by OOPS.
What is inheritance.
Create a database to store the information of employees and their salaries (just explain)
What are insertion, delet...read more
What is a basic form of GRANT statement?
Calculate the result of the following prefix expression: +,-,*,8,4,/,6,2,5
If a new node is added into a red-black tree, which statements are true ?
What...read more
This was taken by an SDE III guy, who again asked me about my projects for like 10 mins and then moved on to a low level design question.He asked me to design the HackerRank platform.
Again I ...read more
What is the difference between drop and truncate?
How would you sort and display a column of table in descending order?
Create a table with primary key.
Set the marks of student to 50 whose address i...read more
Design Facebook API. (Question was vague)
Given a basic interface and the list of functionality that need to implement.
And basic test cases were there again the operations.
Design Facebook API
Define the basic interface for the API
Implement functionality for user authentication and authorization
Create endpoints for posting, retrieving, and deleting posts
Include features for liking, commenting, and sharing posts
Implement a search functionality for users, posts, and hashtags
Design a notification system for user interactions
Consider scalability and performance optimizations
Why tcs?
What are your expectations?
Where do you see yourself in 5 years?
How to prevent breaking of singleton pattern using reflections?
1) A table was shown to me and I was asked to write a query for displaying unique elements.
2) What is RDBMS ?
3) Difference between MySql & NoSql.
Started with brief intro about both(5 mins), then he jumped into LP's(25 mins). This was very difficult since there was no video and he was grilling me real hard on this, so many...read more
Only java was allowed. Parent class was given and asked to write code for child classes and function overloading.
Design an app like Practo.
Explain oops concepts with real life examples.
Explain the concept of normalisation and types.
System design a live video broadcast platform.
Design LRU cache.
Explain ACID properties
Top Interview Questions for SDE-2 Related Skills
Interview experiences of popular companies
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
Reviews
Interviews
Salaries
Users/Month