SDE

200+ SDE Interview Questions and Answers

Updated 26 Feb 2025

Q101. Find a equilibrium index in array

Ans.

Find an index in array where sum of elements on left side is equal to sum of elements on right side.

  • Loop through array and calculate sum of all elements

  • Then loop through array again and check if sum of elements on left side is equal to sum of elements on right side

  • Return the index if found, else return -1

Q102. Print RIght view of a binary tree, create a tree, and run all possible test cases.

Ans.

Print the right view of a binary tree and create a tree.

  • Traverse the tree using DFS and keep track of the maximum level seen so far.

  • Print the node value whenever a new level is reached.

  • Create a binary tree by defining a Node class with left and right child pointers.

  • Test cases: single node, complete binary tree, skewed tree, null tree.

Q103. What is the difference between frameworks and libraries

Ans.

Frameworks provide a structure for building applications, while libraries provide pre-written code for specific tasks.

  • Frameworks provide a skeleton where the application code is implemented, while libraries are collections of reusable code.

  • Frameworks dictate the flow of control, while libraries are called by the code.

  • Frameworks are more complex and have a higher level of abstraction compared to libraries.

  • Examples of frameworks include Angular, React, and Django, while example...read more

Q104. Explain me what is advantage of using Nextjs

Ans.

Next.js provides advantages such as server-side rendering, automatic code splitting, and easy deployment.

  • Server-side rendering improves SEO and initial page load times

  • Automatic code splitting reduces bundle size and improves performance

  • Easy deployment with built-in support for static site generation and serverless functions

Are these interview questions helpful?

Q105. What is oops and its applications and types of oops

Ans.

OOPs stands for Object-Oriented Programming. It is a programming paradigm based on the concept of objects, which can contain data and code.

  • OOPs allows for the organization of code into reusable components called objects.

  • Encapsulation, inheritance, and polymorphism are key principles of OOPs.

  • Examples of OOPs languages include Java, C++, and Python.

Q106. first and last occurrence of an element in a sorted array

Ans.

Find the first and last occurrence of an element in a sorted array.

  • Use binary search to find the first occurrence of the element.

  • Modify binary search to find the last occurrence of the element.

  • Handle cases where the element is not found in the array.

Share interview questions and help millions of jobseekers 🌟

man-with-laptop

Q107. make a dynamic counter which run after ever 1 sec

Ans.

Create a dynamic counter that increments every 1 second.

  • Use setInterval function in JavaScript to run a function every 1 second.

  • Inside the function, increment a counter variable and display it.

  • Example: setInterval(() => { counter++; console.log(counter); }, 1000);

Q108. How DNS works and how a website functions

Ans.

DNS translates domain names to IP addresses, allowing users to access websites.

  • DNS stands for Domain Name System

  • When a user enters a domain name in a browser, DNS translates it to an IP address to locate the website's server

  • DNS servers store records like A (IPv4 address), AAAA (IPv6 address), CNAME (canonical name), MX (mail exchange), etc.

  • Websites function by hosting files on a server, which are accessed by users through their browsers

SDE Jobs

SDE 0-7 years
Amazon India Software Dev Centre Pvt Ltd
4.1
Hyderabad / Secunderabad
SDE 3-10 years
Amazon India Software Dev Centre Pvt Ltd
4.1
Chennai
SDE 3-5 years
First Meridian Business Services
3.7
Bangalore / Bengaluru

Q109. Practical application of a linked list

Ans.

A linked list is used to store and manipulate a collection of data elements in a linear order.

  • Linked lists are commonly used in computer science for implementing data structures like stacks, queues, and hash tables.

  • They are also used in operating systems for managing memory allocation.

  • For example, a linked list can be used to implement a music playlist where each song is a node and the links between nodes represent the order of the songs.

  • Another example is a spell checker tha...read more

Q110. mention 4 IPCs used in user level process in linux

Ans.

4 IPCs used in user level process in Linux

  • Message Queues - allows processes to exchange data through messages

  • Shared Memory - allows processes to share a portion of memory

  • Semaphores - used for synchronization between processes

  • Pipes - allows communication between two related processes

Q111. How i can design a login system for client?

Ans.

Designing a login system for clients involves creating secure authentication methods and user management.

  • Implement secure password hashing algorithms like bcrypt to store passwords securely.

  • Use HTTPS to encrypt data transmission between client and server.

  • Implement multi-factor authentication for added security.

  • Utilize session management to keep track of user login status.

  • Consider implementing account lockout mechanisms to prevent brute force attacks.

Q112. find number whose frequency is greater than n/2

Ans.

Use Boyer-Moore Majority Vote Algorithm to find number with frequency greater than n/2.

  • Iterate through array, keeping track of candidate and count

  • If count becomes 0, update candidate to current element

  • Increment count if current element is candidate, decrement otherwise

  • Verify candidate's frequency at the end to ensure it is greater than n/2

Q113. what is cors policy?how do you set

Ans.

CORS (Cross-Origin Resource Sharing) policy is a security feature implemented by browsers to restrict resources from being requested from a different domain.

  • CORS policy is used to prevent malicious websites from making unauthorized requests to a different domain.

  • To set CORS policy, the server needs to include specific HTTP headers in the response.

  • Common CORS headers include Access-Control-Allow-Origin, Access-Control-Allow-Methods, and Access-Control-Allow-Headers.

  • For example...read more

Q114. Describe ACID properties in detail

Ans.

ACID properties ensure reliability and consistency in database transactions.

  • ACID stands for Atomicity, Consistency, Isolation, and Durability.

  • Atomicity ensures that a transaction is treated as a single unit of work, either all or none of its operations are executed.

  • Consistency ensures that a transaction brings the database from one valid state to another.

  • Isolation ensures that concurrent transactions do not interfere with each other, providing a sense of isolation.

  • Durability ...read more

Q115. Implement a stack using a linked list

Ans.

Implement a stack using a linked list

  • Create a Node class with data and next pointer

  • Create a Stack class with top pointer

  • Push new nodes to the top of the stack

  • Pop nodes from the top of the stack

  • Check if the stack is empty before popping

Q116. Print a matrix diagonally. (-----/)

Ans.

Print a matrix diagonally.

  • Start from the top left corner and print the diagonal elements

  • Move down and right to print the next diagonal

  • Repeat until all diagonals are printed

Q117. program to check if a tree is a BST

Ans.

Program to check if a binary tree is a BST

  • Traverse the tree in-order and check if the values are in ascending order

  • Use a min-max range for each node to check if it satisfies the BST property

  • Recursively check if the left and right subtrees are BSTs

Q118. How do alarm clock work in phones

Ans.

Alarm clocks in phones work by triggering a pre-set notification at a specific time to alert the user.

  • Alarm clock app is programmed to trigger a notification at a specific time set by the user

  • The phone's system clock is used to track the current time and compare it to the set alarm time

  • When the alarm time matches the current time, the phone plays the selected alarm sound or vibration

  • Users can customize alarm settings such as sound, snooze duration, and repeat options

Q119. What is OOPs? And its properties

Ans.

OOPs stands for Object-Oriented Programming. It is a programming paradigm based on the concept of objects.

  • Encapsulation: Bundling data and methods that operate on the data into a single unit.

  • Inheritance: Ability of a class to inherit properties and behavior from another class.

  • Polymorphism: Ability to present the same interface for different data types.

  • Abstraction: Hiding the complex implementation details and showing only the necessary features.

Q120. DFS of binary tree, n-ary tree

Ans.

DFS is a traversal algorithm used to visit all nodes of a tree or graph. It can be applied to binary as well as n-ary trees.

  • DFS stands for Depth First Search.

  • In DFS, we start from the root node and visit its children recursively until we reach a leaf node.

  • There are two types of DFS: Preorder (root, left, right) and Postorder (left, right, root).

  • DFS can be implemented using recursion or a stack data structure.

  • Example: In a binary tree with nodes 1, 2, 3, 4, 5, 6, 7, a preorder...read more

Q121. what is binder in android?

Ans.

Binder is a mechanism for inter-process communication in Android.

  • Binder allows different processes to communicate with each other.

  • It is used for implementing Android's IPC (Inter-Process Communication) system.

  • Binder uses a client-server model where the client sends requests to the server and the server responds with the requested data.

  • It is used for sharing data between different components of an Android application.

  • Binder is implemented using kernel-level drivers and user-le...read more

Q122. how to find middel element of linked list

Ans.

To find the middle element of a linked list, use the slow and fast pointer technique.

  • Initialize two pointers, slow and fast, at the head of the linked list.

  • Move the slow pointer by one step and the fast pointer by two steps until the fast pointer reaches the end of the list.

  • The position of the slow pointer will be the middle element of the linked list.

Q123. How you can optimise reversal process in a tree

Ans.

To optimize reversal process in a tree, use iterative post-order traversal with a stack.

  • Implement iterative post-order traversal using a stack to efficiently reverse the tree.

  • Start by pushing the root node onto the stack.

  • While the stack is not empty, pop a node, push its children onto the stack in reverse order, and then push the node itself.

  • Repeat this process until all nodes have been visited and reversed.

  • This method avoids recursion and can be more efficient for large tree...read more

Q124. WHATIS YOUR FAV SUB IN DB,DBBMS,OS,DS,OOPS

Ans.

My favorite subject in DB, DBMS, OS, DS, and OOPs is Database Management Systems (DBMS).

  • DB - Database Management Systems are essential for storing, managing, and retrieving data efficiently.

  • DBMS - Understanding database concepts like normalization, indexing, and query optimization is crucial for efficient data management.

  • OS - Operating Systems play a vital role in managing hardware resources and providing a platform for running applications.

  • DS - Data Structures are fundamenta...read more

Q125. what is the work flow of an api

Ans.

API workflow involves request, processing, and response.

  • Client sends a request to the API endpoint

  • API processes the request and performs necessary actions

  • API sends a response back to the client

  • API may also authenticate and authorize the request

  • API may also log the request and response for future reference

Q126. Why Mern Stack and what are its features

Ans.

MERN stack is popular for full-stack development using MongoDB, Express, React, and Node.js.

  • MERN stack includes MongoDB for database, Express for backend, React for frontend, and Node.js for server-side logic.

  • It allows developers to build dynamic web applications efficiently.

  • MERN stack provides a seamless integration between frontend and backend technologies.

  • It is widely used in building single-page applications (SPAs) and progressive web apps (PWAs).

Q127. How does facebook chat work

Ans.

Facebook chat is a real-time messaging service that allows users to communicate with each other through the Facebook website or mobile app.

  • Facebook chat uses XMPP (Extensible Messaging and Presence Protocol) to enable real-time communication between users.

  • Messages are sent and received through Facebook's servers, which act as intermediaries between users.

  • Users can see when their friends are online and available to chat, and can also send messages to offline friends that will ...read more

Q128. find minimum no. of increment operations to make array unique

Ans.

To make an array of strings unique, count the number of duplicate elements and increment them accordingly.

  • Iterate through the array and keep track of the frequency of each element.

  • For each duplicate element, increment it to make the array unique.

  • Return the total number of increment operations needed.

Q129. write code for bfs and dfs.. explain prims algorithm

Ans.

BFS and DFS are graph traversal algorithms, while Prim's algorithm is used for finding minimum spanning tree in a weighted graph.

  • BFS (Breadth First Search) visits nodes level by level, using a queue. Example: 1->2->3->4

  • DFS (Depth First Search) explores as far as possible along each branch before backtracking. Example: 1->2->4->3

  • Prim's algorithm finds the minimum spanning tree by starting from an arbitrary node and adding the closest edge at each step. Example: A->B, B->C, C->...read more

Q130. Explain your personal project on Java, Spring Boot (code walk-through)

Ans.

Developed a web application using Java and Spring Boot for managing personal finances.

  • Implemented user authentication and authorization using Spring Security.

  • Utilized Spring Data JPA for database operations.

  • Integrated with third-party APIs for real-time stock market data.

  • Implemented RESTful APIs for frontend communication.

Q131. Fibonacci series using dp and recursion

Ans.

Fibonacci series can be generated using dynamic programming and recursion.

  • Dynamic programming involves storing the values of previous calculations to avoid redundant calculations.

  • Recursion involves calling the function within itself to generate the series.

  • DP solution has O(n) time complexity while recursive solution has O(2^n) time complexity.

  • DP solution uses an array to store the values while recursive solution uses function calls.

  • Example DP solution: int fib[n+1]; fib[0]=0,...read more

Q132. What is inheritance, Call backs, event loop etc

Ans.

Inheritance is a mechanism in object-oriented programming where a class inherits properties and behaviors from another class.

  • Inheritance allows a class to reuse code from another class, promoting code reusability and reducing redundancy.

  • Subclasses can extend the functionality of the superclass by adding new methods or overriding existing ones.

  • Callbacks are functions that are passed as arguments to other functions and are executed at a later time or in response to an event.

  • Eve...read more

Q133. what is storage differnece for files in ram

Ans.

Files in RAM are stored temporarily for quick access by the CPU.

  • RAM (Random Access Memory) is volatile memory used for temporary storage of data and instructions.

  • Files stored in RAM are accessed much faster than files stored on a hard drive.

  • RAM is cleared when the computer is turned off, so files stored in RAM are not persistent.

  • Examples of files stored in RAM include open applications, running processes, and cached data.

Q134. DB Schema and API design of my internship work.

Ans.

Designed DB schema and API for internship project

  • Created normalized database schema to store user information, orders, and products

  • Implemented RESTful API endpoints for CRUD operations on user data

  • Used authentication and authorization mechanisms to secure API endpoints

  • Optimized queries for efficient data retrieval and processing

Q135. Find 2nd min element from given array

Ans.

Find the 2nd minimum element from an array.

  • Sort the array and return the second element.

  • Use a loop to find the minimum and second minimum elements.

  • Initialize two variables to store the minimum and second minimum elements.

Q136. Level order traversal of a tree

Ans.

Level order traversal of a tree is a method to visit all the nodes of a tree level by level.

  • Use a queue to store the nodes of the tree

  • Start with the root node and enqueue it

  • While the queue is not empty, dequeue a node and visit it

  • Enqueue the left and right child of the visited node if they exist

  • Repeat until all nodes are visited

Q137. major training Future plans n all

Ans.

I have completed my major training in computer science and have future plans to specialize in software development.

  • Completed major training in computer science

  • Future plans to specialize in software development

  • Continuously learning and updating skills

  • Attending relevant workshops and conferences

  • Building personal projects to enhance practical knowledge

Q138. tell the workflow of data preprocessing

Ans.

Data preprocessing involves cleaning, transforming, and organizing raw data before analysis.

  • 1. Data cleaning: Removing or correcting errors in the data, handling missing values.

  • 2. Data transformation: Normalizing, scaling, encoding categorical variables.

  • 3. Data reduction: Dimensionality reduction techniques like PCA.

  • 4. Data integration: Combining data from multiple sources.

  • 5. Feature engineering: Creating new features from existing data.

  • 6. Splitting data: Dividing data into t...read more

Q139. Instagram clone with bonus functionalities for like comment

Ans.

Develop an Instagram clone with additional features for liking and commenting.

  • Implement a like button for users to like posts

  • Allow users to leave comments on posts

  • Include notifications for likes and comments

  • Implement a search functionality to find specific posts or users

Q140. what is babel?how compiler knows

Ans.

Babel is a JavaScript compiler that converts modern ECMAScript code into backwards-compatible versions.

  • Babel allows developers to write code using the latest JavaScript features without worrying about browser compatibility.

  • It uses plugins to transform code, such as converting arrow functions to regular functions or adding polyfills for missing features.

  • Babel can be configured to target specific browsers or environments for optimized output.

  • Example: Babel can convert ES6 code ...read more

Q141. Print all permutations of string

Ans.

The answer provides a solution to print all permutations of a given string.

  • Use recursion to generate all possible permutations

  • Swap characters at different positions to generate different permutations

  • Use a set to avoid duplicates

Q142. What is a BST?

Ans.

BST stands for Binary Search Tree, a data structure used for efficient searching and sorting operations.

  • BST is a tree-like data structure where each node has at most two children.

  • The left child of a node contains a value less than the parent node, while the right child contains a value greater than the parent node.

  • BST allows for efficient searching and sorting operations with a time complexity of O(log n).

  • Examples of applications of BST include dictionary, spell checker, and ...read more

Q143. difference between c nd cpp what is java

Ans.

C and C++ are programming languages, while Java is a programming language known for its platform independence.

  • C is a procedural programming language, while C++ is an object-oriented programming language.

  • C does not support classes and objects, while C++ does.

  • Java is a high-level programming language known for its platform independence, as it can run on any device with a Java Virtual Machine (JVM).

Q144. what is annotation in spring boot

Ans.

Annotations in Spring Boot are used to provide metadata about the application's components, helping Spring to understand how to manage them.

  • Annotations are used to configure Spring Boot components such as controllers, services, repositories, etc.

  • Annotations help Spring Boot to automatically detect and configure beans based on the annotations used.

  • Examples of annotations in Spring Boot include @RestController, @Service, @Repository, @Autowired, @Component, etc.

Q145. what is the linear data structure

Ans.

Linear data structure is a data structure where elements are arranged in a sequential order.

  • Elements are accessed in a linear order

  • Examples include arrays, linked lists, stacks, and queues

Q146. what is the non linear data structure

Ans.

Non-linear data structures are data structures where elements are not arranged in a sequential manner.

  • Non-linear data structures do not have elements stored in a sequential order like arrays or linked lists.

  • Examples include trees, graphs, and heaps.

  • In trees, each element can have multiple children, unlike linear structures where each element has only one successor.

  • Graphs consist of nodes connected by edges, allowing for complex relationships between elements.

  • Heaps are binary ...read more

Q147. Variation of repeating DNA sequences LC question.

Ans.

Repeating DNA sequences can lead to genetic disorders.

  • Repeating DNA sequences can cause genetic disorders such as Huntington's disease.

  • These repeats can expand in size over generations, leading to more severe symptoms.

  • PCR and DNA sequencing techniques can be used to detect and analyze these repeats.

Q148. explain device tree concepts in linux

Ans.

Device tree is a data structure used to describe hardware components in a system and their interconnections.

  • Device tree is used in embedded systems to provide a standardized way of describing hardware components.

  • It is written in a language called Device Tree Source (DTS) and compiled into a binary format called Device Tree Blob (DTB).

  • The device tree is loaded by the bootloader and used by the kernel to configure the hardware.

  • It allows for easy configuration of hardware compon...read more

Q149. Can there be multiple index on a table?

Ans.

Yes, multiple indexes can be created on a table to improve query performance.

  • Multiple indexes can be created on a table to speed up data retrieval for different types of queries.

  • Each index can be created on one or more columns of the table.

  • Indexes can be unique or non-unique, depending on the requirements.

  • Examples: creating separate indexes on 'name' and 'age' columns of a 'users' table.

Q150. FIND THE LOOP IN LINKED LIST

Ans.

To find a loop in a linked list, use Floyd's Tortoise and Hare algorithm.

  • Use two pointers, slow and fast, to traverse the linked list.

  • If there is a loop, the two pointers will eventually meet at the same node.

  • To find the start of the loop, reset one pointer to the head and move both pointers at the same pace.

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

Interview experiences of popular companies

3.7
 • 10.4k Interviews
3.8
 • 8.1k Interviews
3.6
 • 7.5k Interviews
4.1
 • 5k Interviews
4.0
 • 1.3k Interviews
3.7
 • 846 Interviews
4.4
 • 822 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 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