SDE Intern
40+ SDE Intern Interview Questions and Answers
Q1. Given a string of containing lower case letters and upper case characters. Find the number of occurrences of each character. The question was further modified to include the special characters as well. I was as...
read moreCount the occurrences of each character in a given string including special characters.
Create test cases for empty string
Test for string with only one character
Test for string with all characters being the same
Test for string with all characters being different
Test for string with special characters
Q2. Find the square root of a number using only 4 basic arithmetic operations (+,-,*,/) without using a power operator and inbuilt libraries. For numbers that are not perfect squares, print the integer part of the ...
read moreFind square root of a number using basic arithmetic operations without power operator and inbuilt libraries.
Use binary search to find the integer part of the square root
Use long division method to find the decimal part of the square root
Repeat the above steps until desired accuracy is achieved
Handle edge cases like negative numbers and numbers less than 1
SDE Intern Interview Questions and Answers for Freshers
Q3. Remove duplicate characters from a given string keeping only the first occurrences (i.e order should not change). For ex- if the input is ‘bananas’ the output will be ‘bans’. -----/ (second method)
Remove duplicate characters from a string while preserving order.
Create an empty string to hold the result.
Iterate through each character in the input string.
If the character is not already in the result string, add it.
Return the result string.
Q4. What is caching and why do we need to do caching
Caching is the process of storing frequently accessed data in a temporary storage to improve performance.
Caching reduces the need to fetch data from the original source, improving response time.
It helps in reducing network traffic and server load.
Caching can be done at various levels like browser caching, CDN caching, and server-side caching.
Examples of caching include browser caching of website assets, CDN caching of static content, and database query result caching.
Q5. Given a Y- linked list. Find the node at the intersection point
Given a Y-linked list, find the node at the intersection point.
Traverse both branches of the Y-linked list and compare nodes.
Use a hash table to store visited nodes and check for intersection.
If one branch is longer, traverse it until it matches the length of the other branch.
Q6. how do you change permission for a particular file?
To change permissions for a file, you can use the chmod command in the terminal.
Use the chmod command followed by the permission code and the file name
Permission codes include 'u' for user, 'g' for group, and 'o' for others, along with 'r' for read, 'w' for write, and 'x' for execute
For example, to give read and write permissions to the user for a file named 'example.txt', you can use 'chmod u+rw example.txt'
Share interview questions and help millions of jobseekers 🌟
Q7. 1. Describe your projects in depth. 2. Database schema design of Codechef. 3. SQL queries related to that. 4. Questions on CN
Answering questions on projects, database schema design of Codechef, SQL queries, and CN.
Projects involved developing a web application for managing employee data and a mobile app for tracking expenses.
Database schema design of Codechef involved creating tables for users, problems, submissions, and contests.
SQL queries related to Codechef included retrieving user details, problem submissions, and contest rankings.
Questions on CN covered topics such as network protocols, OSI m...read more
Q8. Addition of two linked lists, and finallt return the result as a linked list
Addition of two linked lists and return the result as a linked list.
Traverse both linked lists simultaneously
Add corresponding nodes and carry over the sum
Create a new linked list with the sum
Q9. Projects and tech stack used
I have worked on various projects using different tech stacks including Java, Python, and JavaScript.
Developed a web application using Java Spring Boot framework
Created a data analysis tool using Python libraries such as Pandas and NumPy
Built a real-time chat application using JavaScript and Node.js
Implemented machine learning algorithms using Python's scikit-learn library
Worked on a mobile application using React Native framework
Q10. Write sql quary for bu Transport system which will pick and drop passenger
SQL query to manage pick and drop of passengers in a transport system
Create a table for passengers with columns like passenger_id, name, pick_up_location, drop_off_location, etc.
Create a table for transport vehicles with columns like vehicle_id, driver_name, capacity, etc.
Use JOIN to link the two tables based on pick_up_location and drop_off_location.
Consider adding a table for routes and scheduling for better organization.
Example: SELECT * FROM passengers p JOIN vehicles v O...read more
Q11. What is multithreading in Javascript?
Multithreading is not natively supported in JavaScript, but can be achieved through Web Workers.
JavaScript is a single-threaded language, meaning it can only execute one task at a time.
Web Workers allow for multithreading in JavaScript by running scripts in the background.
Web Workers can communicate with the main thread using message passing.
Examples of tasks that can benefit from multithreading include heavy computations and long-running processes.
Q12. Why Meta? What do you know about Meta in AI space?
Meta is a leading company in AI space with a focus on developing innovative technologies and solutions.
Meta (formerly Facebook) is known for its advanced AI research and development.
Meta uses AI for various applications such as content moderation, personalized recommendations, and virtual assistants.
Meta's AI technologies power products like facial recognition, language translation, and image recognition.
Q13. Find the missing number in an array, , given the array conatins numbers form 1 to n and one number is missing
Find the missing number in an array containing numbers from 1 to n.
Iterate through the array and calculate the sum of all numbers from 1 to n.
Calculate the sum of all numbers in the given array.
Subtract the sum of array from the sum of all numbers to find the missing number.
Q14. Find leaf nodes in a binary tree ,followed by printing path to leaf nodes.
Find leaf nodes in a binary tree and print path to each leaf node.
Traverse the binary tree using depth-first search (DFS)
When reaching a leaf node, store the path from root to that leaf node
Repeat the process for all leaf nodes in the tree
Q15. Create function for insert and delete and print linked list
Function to insert, delete, and print a linked list
Create a Node class with data and next pointer
Implement insert function to add a new node at the end of the linked list
Implement delete function to remove a node by value
Implement print function to display all elements in the linked list
Q16. Deepest left node in binary tree
Find the deepest left node in a binary tree.
Traverse the tree recursively and keep track of the depth and whether the current node is a left node.
If the current node is a leaf node and its depth is greater than the deepest left node found so far, update the deepest left node.
Return the deepest left node found.
Example: For the binary tree with root node 1, left child 2, and left child of 2 being 4, the deepest left node is 4.
Example: For the binary tree with root node 1, left ...read more
Q17. optimization the written code and estimating the time complexity
Optimizing code and estimating time complexity
Identify bottlenecks in the code and optimize them
Use efficient data structures and algorithms
Analyze the code to determine its time complexity
Consider worst-case, best-case, and average-case scenarios
Use Big O notation to express the time complexity
Q18. Search an element in a sorted(row and column wise) matrix.
Use binary search to efficiently search for an element in a sorted matrix.
Start from the top right corner of the matrix
If the target is greater than the current element, move down
If the target is less than the current element, move left
Repeat until the target is found or all elements are checked
Q19. What is virtual DOM?
Virtual DOM is a lightweight copy of the actual DOM used for efficient updates.
Virtual DOM is a concept used in modern web development frameworks like React.
It is a lightweight copy of the actual DOM that is used to track changes and update the actual DOM efficiently.
When a change is made to the virtual DOM, it is compared with the previous version to identify the minimum number of changes required to update the actual DOM.
This approach reduces the number of updates required ...read more
Q20. Rotate matrix element with k position left
Rotate matrix elements with k positions left
Create a temporary array to store the first k elements of each row
Shift the remaining elements in each row to the left by k positions
Replace the last k elements in each row with the elements from the temporary array
Q21. Difference between single way and two way bindings.
Single way binding updates the view when the model changes, while two way binding updates both the view and the model.
Single way binding updates the view when the model changes, but not vice versa.
Two way binding updates both the view and the model when either changes.
Single way binding is commonly used in frameworks like AngularJS, while two way binding is used in frameworks like Vue.js.
Q22. what and expalin java hibernate working
Java Hibernate is an ORM (Object-Relational Mapping) framework that simplifies database operations in Java applications.
Hibernate maps Java classes to database tables and vice versa
It provides automatic generation of SQL queries based on Java objects
Hibernate handles the mapping of Java data types to SQL data types
It supports caching mechanisms to improve performance
Hibernate simplifies complex database operations like transactions and queries
Q23. What is lazy loading in react?
Lazy loading in React is a technique used to improve performance by loading components only when they are needed.
Lazy loading helps reduce the initial load time of a web application by splitting the code into separate bundles.
It allows components to be loaded asynchronously, improving the overall user experience.
Lazy loading is commonly used for optimizing the loading of images, videos, or heavy components in React applications.
Q24. Count occurrences in sorted array
Count occurrences of a given element in a sorted array.
Use binary search to find the first and last occurrence of the element.
Subtract the indices to get the count.
Handle edge cases like element not present in the array.
Q25. Impact of Make In India Initiative
Make In India initiative aims to boost manufacturing sector, create jobs, and attract foreign investment.
Promotes domestic manufacturing and reduces dependency on imports
Encourages foreign companies to set up manufacturing units in India
Generates employment opportunities for the local population
Boosts economic growth and contributes to GDP
Enhances skill development and technology transfer
Examples: Apple manufacturing iPhones in India, Samsung setting up production units
Q26. Detect a loop in the linked list
Use Floyd's Tortoise and Hare algorithm to detect a loop in a linked list.
Initialize two pointers, slow and fast, at the head of the linked list.
Move slow pointer by one step and fast pointer by two steps.
If they meet at any point, there is a loop in the linked list.
Q27. What is prop drilling?
Prop drilling is the process of passing data through multiple layers of components in a React application.
Prop drilling involves passing props from a parent component to multiple levels of nested child components.
It can lead to code that is harder to maintain and understand, as props need to be passed through intermediary components that do not actually use the data.
One way to avoid prop drilling is by using context or Redux to manage state and make it accessible to any compo...read more
Q28. Write a program on stack operations
A program for stack operations
Create a stack using an array or linked list
Implement push() and pop() functions
Check for stack overflow and underflow
Implement peek() function to view top element
Example: stack.push(5), stack.pop(), stack.peek()
Q29. Implement Min-stack using O(N) space .
Min-stack is implemented using O(N) space by keeping track of minimum value at each element.
Use two stacks - one to store the actual elements and another to store the minimum value at each step.
When pushing an element, check if it is smaller than the current minimum and update the minimum stack accordingly.
When popping an element, also pop from the minimum stack if the popped element is the current minimum.
Q30. System design of whatsapp
WhatsApp is a messaging app that allows users to send text messages, voice messages, images, and videos.
End-to-end encryption for secure communication
Message delivery status indicators
Group chat functionality
Media sharing capabilities
Online/offline status indicators
Q31. difference between array and arraylist
Array is a fixed-size data structure while ArrayList is a dynamic-size data structure in Java.
Array is a static data structure with a fixed size, while ArrayList is a dynamic data structure that can grow or shrink in size.
Arrays can hold primitive data types and objects, while ArrayList can only hold objects.
Arrays use square brackets [] for declaration, while ArrayList is a class in Java's collection framework.
Arrays are faster than ArrayList for accessing elements, but Arra...read more
Q32. right view of a binary tree
The right view of a binary tree shows the nodes that are visible when viewing the tree from the right side.
The right view of a binary tree can be obtained by performing a level order traversal and keeping track of the rightmost node at each level.
Nodes that are visible from the right side are the ones that are the rightmost at their respective levels.
For example, in the binary tree: 1 / \ 2 3 / \ / \ 4 5 6 7 the right view would be [1, 3, 7].
Q33. What is Event Loop?
Event Loop is a mechanism that allows JavaScript to perform non-blocking operations by handling asynchronous tasks.
Event Loop is a part of JavaScript runtime that continuously checks the call stack and the callback queue.
It processes tasks in the callback queue only when the call stack is empty.
Event Loop helps in handling asynchronous operations like setTimeout, AJAX requests, and event listeners.
Q34. What is Node JS?
Node.js is a runtime environment that allows you to run JavaScript code outside of a web browser.
Node.js is built on Chrome's V8 JavaScript engine.
It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.
Node.js is commonly used for building server-side applications and APIs.
It has a large ecosystem of open-source libraries available through npm (Node Package Manager).
Q35. Implementation of Min Stack
Implement a stack that supports push, pop, top, and retrieving the minimum element in constant time.
Use two stacks - one to store the actual elements and another to store the minimum values.
When pushing an element, check if it is smaller than the current minimum and push it to the min stack if so.
When popping an element, check if it is the current minimum and pop from the min stack if so.
Top operation can be implemented by returning the top element of the main stack.
GetMin op...read more
Q36. left view of binary tree
Left view of a binary tree is the set of nodes visible when the tree is viewed from the left side.
Traverse the tree level by level from left to right
At each level, add the first node encountered to the result array
Continue this process until all levels are traversed
Q37. Sliding Window Problem.
Sliding Window Problem involves finding a subarray of fixed size k with the maximum sum.
Use a sliding window approach to iterate through the array and keep track of the sum of elements within the window.
Slide the window by removing the first element and adding the next element in each iteration.
Keep track of the maximum sum found so far and update it if a new maximum is found.
Q38. Create linked list
Create a linked list
Define a Node class with data and next pointer
Create a LinkedList class with methods like insert, delete, search
Initialize head pointer to null and update it as nodes are added
Q39. Rod cutting problem
Rod cutting problem involves finding the optimal way to cut a rod into pieces to maximize profit.
Identify the lengths at which the rod can be cut.
Calculate the maximum profit that can be obtained by cutting the rod at different lengths.
Use dynamic programming to solve the problem efficiently.
Example: Given a rod of length 8 and prices for different lengths as [1, 5, 8, 9, 10, 17, 17, 20], the maximum profit is 22 by cutting the rod into pieces of length 2 and 6.
Q40. Reverse a Linked List
Reverse a linked list by changing the direction of pointers
Start with three pointers: prev, current, next
Iterate through the list, updating pointers to reverse the direction
Update the head of the list to be the last node
Q41. Dutch National Algorithm
Dutch National Algorithm is a sorting algorithm that partitions an array into three sections based on a pivot element.
Choose a pivot element
Partition the array into three sections: elements less than the pivot, elements equal to the pivot, and elements greater than the pivot
Recursively apply the algorithm to the subarrays
Q42. Reverse the array
Reverse the array of strings
Create a new array and iterate through the original array in reverse order, adding each element to the new array
Alternatively, you can use the reverse() method on the array itself
Q43. Explain projects
Projects are tasks or assignments undertaken to achieve specific goals within a set timeframe.
Projects involve planning, execution, and monitoring of tasks to achieve a desired outcome.
They typically have defined objectives, timelines, and resources allocated.
Examples include developing a mobile app, implementing a new software system, or conducting a research study.
Q44. Kadane Algorithm
Kadane's Algorithm is used to find the maximum subarray sum in an array of integers.
Iterate through the array and keep track of the maximum sum ending at each index.
If the current element is greater than the sum ending at the previous index, start a new subarray.
Return the maximum sum found.
Example: For array [-2, 1, -3, 4, -1, 2, 1, -5, 4], the maximum subarray sum is 6 (from index 3 to 6).
Top Interview Questions for SDE Intern 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