Interview questions
Sde interview questions – page 3
112 questions. Tap “Show answer” to check yourself.
-
Detail discussion on virtual functions
-
Some puzzles like weighing problem..N Balls given all of same weight except one..What is the max value of N so that u can figure out the ball with less weight in 2 rounds or 3 rounds
-
Make a data structure such that it can store an image dynamically
-
Copy fixed no of bytes from source to destination and its test cases( ex: copy(source, destination,bytes) so now command copy(a,a+3,8) will not give correct results in some cases and copy(a,a-4,8) will not give correct result in some cases , so their solutions)
-
Merge two double linked list. What will be the difference if they are singly linked list
-
Find top 10 selling product given the count of sales of each product
-
What happens when you type amazon.com in browser
-
Given a tree populate the sibiling of the tree node with the next node in same level.space complexity-O(1)
-
Given a stack output a sorted stack.(hint use recursion)
-
Given a tree construct a mirror tree and return root of mirror tree
-
Level order traversal of a tree
-
Given an array and a sum s find all pairs of numbers which whoose sum=s
-
Advantages of heaps over arrays
-
Find 2nd min element from given array
-
ind the first occurrence of 1 in a sorted infinite binary tree
-
Remove duplicated from a string in O(n) without using hash
-
Find top 10 trending words inserted by users in sites like twitter. Only algorithm
-
Write an efficient code to find the first occurrence of 1 in a sorted binary array
-
Given an in-order traversal of a special binary tree having property that the node is always greater than its left and right child. Construct the tree and write code
-
You will be given the number of pairs of parenthesis. Find out the total possible valid unique combinations and there should not be any duplicity. Write code
-
In a binary tree, a random pointer is given in each node. If this pointer pointing other than any successor of the node then set it as NULL. Otherwise let it remain untouched. Write code
-
Print a matrix diagonally. (http://www.geeksforgeeks.org/print-matrix-diagonally/)
-
DFS of binary tree, n-ary tree
-
Given a sorted array which can have repeated elements, find the occurrence of an element. (Most optimal solution is O(logn) – Using binary search to find start and end occurrence)
-
Make a data structure and implement an algorithm to print all the files in a directory. (the root directory can have sub-directories too.) I used an n-ary tree and BFS to print files. It can also be done using Stack
-
Why do I want to leave my current company on such a short interval of 5 months
-
Find the second largest element in an array. (http://www.geeksforgeeks.org/to-find-smallest-and-second-smallest-element-in-an-array/)
-
Explain the approach of LRU cache and implement using object oriented language
-
Connect Sibling pointers. I gave a Level Order Traversal solution. He asked to do it in O(1) space complexity. I explained the approach but messed up In writing the working code for that
-
Design a system for finding the costliest element always whenever we pick up an element from a box.(concept of Max Heap)