SDE-2

40+ SDE-2 Interview Questions and Answers for Freshers

Updated 20 Jan 2023
search-icon

Q1. Maximum Frequency Number Problem Statement

Given an array of integers with numbers in random order, write a program to find and return the number which appears the most frequently in the array.

If multiple elem...read more

Q2. Ways To Make Coin Change

Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more

Frequently asked in,

Q3. Remove Consecutive Duplicates from String

Given a string STR consisting of both lower and upper case characters, your task is to remove consecutive duplicate characters and return the newly formed string.

Input...read more

Ans.

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

Q4. Sum of Even & Odd Digits

You need to determine the sum of even digits and odd digits separately from a given integer.

Input:

The first line of input is an integer T representing the number of test cases. Each t...read more

Are these interview questions helpful?

Q5. Median in a Stream Problem Statement

Your task is to determine the median of integers as they are read from a data stream. The median is the middle value in the ordered list of numbers. If the list length is ev...read more

Q6. Number of Islands Problem Statement

You are provided with a 2-dimensional matrix having N rows and M columns, containing only 1s (land) and 0s (water). Your goal is to determine the number of islands in this ma...read more

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q7. Shopping Options Problem Statement

Given arrays representing the costs of pants, shirts, shoes, and skirts, and a budget amount 'X', determine the total number of valid combinations that can be purchased such t...read more

Q8. Maximum Number With Single Swap

You are given an array of N elements that represent the digits of a number. You can perform one swap operation to exchange the values at any two indices. Your task is to determin...read more

Q9. Sliding Window Maximum Problem Statement

You are given an array/list of integers with length 'N'. A sliding window of size 'K' moves from the start to the end of the array. For each of the 'N'-'K'+1 possible wi...read more

Q10. Find All Pairs Adding Up to Target

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 the Target.

Input:

The first line conta...read more
Frequently asked in,

Q11. Maximum Depth of a Binary Tree Problem Statement

Given the root node of a binary tree with N nodes, where each node contains integer values, determine the maximum depth of the tree. The depth is defined as the ...read more

Q12. Reverse Linked List Problem Statement

Given a Singly Linked List of integers, your task is to reverse the Linked List by altering the links between the nodes.

Input:

The first line of input is an integer T, rep...read more

Q13. Prime Time Again Problem Statement

You are given two integers DAY_HOURS and PARTS. The integer 'DAY_HOURS' represents the number of hours in a day, and the day can be divided into 'PARTS' equal parts. Your task...read more

Q14. Maximum Product Subarray Problem Statement

Given an array of integers, determine the contiguous subarray that produces the maximum product of its elements.

Explanation:

A subarray can be derived from the origin...read more

Q15. Equilibrium Index Problem Statement

Given an array Arr consisting of N integers, your task is to find the equilibrium index of the array.

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

Q16. Max Submatrix Problem Statement

You are provided with a matrix MAT consisting of integers, with dimensions N x M (i.e., N rows and M columns). Your objective is to determine the maximum sum submatrix within thi...read more

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

Q18. Group Anagrams Together

Given an array/list of strings STR_LIST, group the anagrams together and return each group as a list of strings. Each group must contain strings that are anagrams of each other.

Example:...read more

Q19. 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,

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

Q21. Find the Duplicate Number Problem Statement

Given an integer array 'ARR' of size 'N' containing numbers from 0 to (N - 2). Each number appears at least once, and there is one number that appears twice. Your tas...read more

Q22. The Ninja Port Problem

Ninja is in a city with 'N' colonies, where each colony contains 'K' houses. He starts at house number "sourceHouse" in colony number "sourceColony" and wants to reach house number "desti...read more

Q23. Clone a Binary Tree with Random Pointers

Given a binary tree where each node has pointers to its left, right, and a random node, create a deep copy of the binary tree.

Input:

The first line contains an integer ...read more

Q24. Course Schedule II Problem Statement

You are provided with a number of courses 'N', some of which have prerequisites. There is a matrix named 'PREREQUISITES' of size 'M' x 2. This matrix indicates that for ever...read more

Q25. Maximum Sum Rectangle Problem

Given an M x N matrix of integers ARR, your task is to identify the rectangle within the matrix that has the greatest sum of its elements.

Input:

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

Q26. Validate Binary Search Tree (BST)

You are given a binary tree with 'N' integer nodes. Your task is to determine whether this binary tree is a Binary Search Tree (BST).

BST Definition:

A Binary Search Tree (BST)...read more

Q27. Minimum Operations Problem Statement

You are given an array 'ARR' of size 'N' consisting of positive integers. Your task is to determine the minimum number of operations required to make all elements in the arr...read more

Q28. Distance Between Two Nodes in a Binary Tree

Given a binary tree and the values of two distinct nodes, determine the distance between these two nodes in the tree. The distance is defined as the minimum number of...read more

Q29. Edit Distance Problem Statement

Given two strings S and T with lengths N and M respectively, your task is to find the "Edit Distance" between these strings.

The Edit Distance is defined as the minimum number of...read more

Q30. Add Two Numbers Represented by Linked Lists

Your task is to find the sum list of two numbers represented by linked lists and return the head of the sum list.

Explanation:

The sum list should be a linked list re...read more

Q31. How can you prevent the breaking of the singleton pattern using reflections?
Q32. Design an application similar to Practo.
Q33. Can you explain the concepts of Object-Oriented Programming (OOP) with real-life examples?
Q34. Can you explain the concept of normalization and its types?
Q35. Design a live video broadcast platform.
Q36. Design an LRU (Least Recently Used) cache.
Q37. Can you explain the ACID properties in the context of database management systems?

Q38. Indexing in database and SQL vs NO SQL

Ans.

Indexing is important for efficient data retrieval. SQL databases use traditional indexing while NoSQL databases use various indexing techniques.

  • SQL databases use B-tree indexing while NoSQL databases use hash-based, inverted index, or full-text search indexing

  • SQL databases are better suited for structured data while NoSQL databases are better suited for unstructured or semi-structured data

  • SQL databases have strict schema requirements while NoSQL databases are schema-less

  • Exam...read more

Q39. Connection pooling in databases

Ans.

Connection pooling is a technique used to improve performance and scalability of database applications.

  • Connection pooling allows multiple clients to reuse a single database connection, reducing the overhead of creating and tearing down connections.

  • It helps in improving the performance of the application by reducing the time taken to establish a new connection.

  • Connection pooling can be implemented at the application level or at the database level.

  • Examples of connection pooling...read more

Q40. Event loop in javascript

Ans.

Event loop is a mechanism in JavaScript that allows asynchronous code to be executed.

  • Event loop continuously checks the call stack and the task queue.

  • If the call stack is empty, it takes the first task from the queue and pushes it to the call stack.

  • If the task is an asynchronous operation, it is pushed to the Web API and a callback function is registered.

  • Once the operation is complete, the callback function is pushed to the task queue.

  • The event loop then takes the callback fu...read more

Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Interview experiences of popular companies

3.7
 • 10.5k Interviews
4.1
 • 5.1k Interviews
4.0
 • 1.4k Interviews
3.8
 • 408 Interviews
3.9
 • 211 Interviews
3.4
 • 143 Interviews
3.5
 • 88 Interviews
3.6
 • 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

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