Interview questions

Sde interview questions – page 3

112 questions. Tap “Show answer” to check yourself.

  1. Detail discussion on virtual functions

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

  3. Make a data structure such that it can store an image dynamically

  4. 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)

  5. Merge two double linked list. What will be the difference if they are singly linked list

  6. Find top 10 selling product given the count of sales of each product

  7. What happens when you type amazon.com in browser

  8. Given a tree populate the sibiling of the tree node with the next node in same level.space complexity-O(1)

  9. Given a stack output a sorted stack.(hint use recursion)

  10. Given a tree construct a mirror tree and return root of mirror tree

  11. Level order traversal of a tree

  12. Given an array and a sum s find all pairs of numbers which whoose sum=s

  13. Advantages of heaps over arrays

  14. Find 2nd min element from given array

  15. ind the first occurrence of 1 in a sorted infinite binary tree

  16. Remove duplicated from a string in O(n) without using hash

  17. Find top 10 trending words inserted by users in sites like twitter. Only algorithm

  18. Write an efficient code to find the first occurrence of 1 in a sorted binary array

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

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

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

  22. Print a matrix diagonally. (http://www.geeksforgeeks.org/print-matrix-diagonally/)

  23. DFS of binary tree, n-ary tree

  24. 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)

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

  26. Why do I want to leave my current company on such a short interval of 5 months

  27. Find the second largest element in an array. (http://www.geeksforgeeks.org/to-find-smallest-and-second-smallest-element-in-an-array/)

  28. Explain the approach of LRU cache and implement using object oriented language

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

  30. Design a system for finding the costliest element always whenever we pick up an element from a box.(concept of Max Heap)

Companies that ask Sde questions