Problem list for interview

Sorting Binary search tree Linked List Arrays Graphs Dynamic Programming String
Matrix Heaps Miscellaneous

Sorting algorithms

1. Merge sort algorithm (Divide and Conquer) Solution   images18
2. Quick sort algorithm (Divide and Conquer) Solution images18
3. Heap sort algorithm Solution images18

Binary search tree related questions

1. Check if binary tree is balanced or not Solution images18
2. Zig Zag order traversal of tree. Solution images18
3. Prune all nodes of tree which are outside a range min and max. Solution images18
4. Find least common ancestor. Solution images18
5. Replace node with sum of children. Solution images18
6. Convert tree to DLL. Solution images18
7. Print last K nodes of binary search tree. Solution images18
8. Find pair of nodes with given sum. Solution images18
9. Level order traversal of tree. Solution images18
10.Build tree from given pre-order and inroder traversal. Solution images18
11. Tree traversals without recursion. Solution images18
12. Find paths in binary search tree of given sum. Solution images18
13. Calculate number of trees with N nodes. Solution images18
14. Print right view of binary search tree. Solution images18
15. Vertical sum of binary search tree. Solution images18

Array related questions

1. Find missing missing number in an array. Solution images18
2. Find repeated number in an array. Solution images18
3. Find all duplicate numbers in an array. Solution images18
4. Find One missing and one repeated number in an array. Solution  images18
5. Smallest missing numbers in sorted array. Solution images18
6. Find element in first increasing and then decreasing array. Solution images18
7. Balanced subarray and zero sum sub array Solution images18
8. Rotate an array. Solution images18
9. Find element in rotated array. Solution images18
10.Sum of two numbers in array equal to K. Solution images18
11.In array of 0 and 1, find first occurrence of 1. Solution images18
12. Count sort. Solution images18
13. Find median of two sorted arrays. Solution images18
14. Find Kth smallest element in two sorted arrays. Solution images18
15. Find Kth smallest element in an array Solution images18

Matrix related questions

1. Traverse a matrix in spiral order. Solution images18
2.  Make row and column 1 if there is 1 in it. Solution images18
3. Search an element in matrix of sorted rows and columns. Solution images18
4. Rotate a matrix by 90 degree. Solution images18
5. Find maximum sub matrix with all ones. Solution images18

Dynamic programming questions

1. Longest increasing subsequence. Solution images18
2. Longest common subsequence Solution images18
3. Subset sum problem Solution images18
4. Largest sum contiguous sub array. Solution images18
5. Minimum Jumps to reach end Solution images18
6. Coin change Solution images18
7. Minimum Number of coins for change. Solution images18
8. Matrix multiplication Solution images18
9. Edit distance Solution images18
10. Longest palindrome substring Solution images18
11. Longest palindrome subsequence Solution images18
12. Check if string in interleaved of two strings. Solution images18

String related questions

1. Encoding of a string. Solution images18
2. Removal of duplicate characters. Solution images18
3. Find first duplicate character. Solution images18
4. Tokenize a string based on delimiter. Solution images18
5. Remove a particular combination of characters from string. Solution images18
6. Reverse words in a string. Solution images18
7. Check if string is combination of two strings. Solution images18
8. Break a string in meaningful dictionary words Solution images18
9. First non repeating character in stream of characters. Solution images18
10. Check if two strings are anagrams. Solution images18
11. Check if any anagram of string is palindrome. Solution images18
12. Print all anagrams together. Solution images18

Linked list related questions

1. Find if there is loop in linked list. Solution images18
2. Add two numbers represented by linked lists. Solution images18
3. Merge two linked list. Solution images18
4. Find Nth node from end. Solution images18
5. Flatten a generic linked list. Solution images18
6. Delete a node from linked list. Solution images18
7. Check if linked list is palindrome. Solution images18
8. Clone linked list with arbitrary pointer. Solution images18

Heaps

1. Merge K sorted arrays in one sorted array. Solution images18
2. Find K minimum elements in unsorted array. Solution images18
3. Find median in continuous stream of integers. Solution images18
4. Sliding window problem. Solution images18
5. Heaps basics. Solution
images18
6. Find median of running stream of integers. Solution images18

Graphs

1.Depth First Search. Solution images18
2. Breadth First Search. Solution images18
3. Topological sorting. Solution images18
4. Minimum spanning tree: Prim’s algorithm. Solution images18
5. Minimum spanning tree: Kruskal’s algorithm. Solution images18
6. Shortest Path algorithm: Dijkstra’s algorithm. Solution images18
7. Word ladder problem. Solution images18
8. Find connected components of graph. Solution images18
9. Detecting cycle in undirected graph. Solution images18

Miscellaneous

1. Convert string to int, int to string. Solution images18
2. Find the next palindrome number. Solution images18
3. Print last N lines of file. Solution images18
4. Convert a string to equivalent number. Solution images18
5. Eight queen problem. Solution images18

  • rkpawan

    Greatly appreciate all the effort that you have put up in maintaining this site. Any plans of increasing the “Interview problems” section by adding more problems under each of the listed category? Also any thoughts of co-hosting code snippets in Java/C# along with C++ code?

    • http://algorithmsandme.in/ Jitendra Sangar

      Thanks a lot for your appreciation. Yes, this list is dynamic and will be updated. I have started to learn C# and will probably start coding in C#. If you feel that you can contribute with C#, please let me know, we can workout some way.

      • rkpawan

        Sure, I can help you in porting C++ code to C#. Let me know the github repo(either existing or new) where you want to maintain the source code. I will initiate pull requests containing C# implementation of the codebase.

        • http://algorithmsandme.in/ Jitendra Sangar

          Cool! That would be a help. Presently I am using gists for code snippets. We can create anew git hub repo and start working. Please mail me on email provided and we can talk further.

  • A. Singh

    Great effort Jitendra ! Very useful collection of altgorithms. Keep it up !

  • Shubham

    sir the link is not available for this question under “Array related questions”

    “Find element in first increasing and then decreasing array.”

    • http://algorithmsandme.in/ Jitendra Sangar

      Yes. I still need to write post for that 🙂 If you have some code, you can send me or I can give you author write, you can also write that.

  • Shubham Pendharkar

    Code for ” Convert a string to equivalent number”

    #include
    using namespace std;

    int main()
    {
    char arr[10];

    int num=0,flag=0;

    cout<>arr;

    for(int i=0;arr[i]!=”;i++)

    {

    if(arr[i]’9′) //To check if the input is valid or not.

    {

    flag=1;

    break;

    }

    int n=arr[i]-‘0’;

    num=num*10+n;

    }

    if(flag)

    cout<<"Wrong input" ;

    else

    cout<<"Number is: "<<num;

    }

    • http://algorithmsandme.in/ Jitendra Sangar

      Thanks Subham for the code. If you want I can give you write access to blog, you can write a post on int to string and string to int conversion.

      • Shubham Pendharkar

        Yes sir,I would love to do it.

  • Hafeez

    Page not found ‘http://algorithmsandme.in/2014/04/prune-nodes-of-binary-search-tree.html’ under Binary Search Tree questions..

  • Hafeez

    Page not found ‘http://algorithmsandme.in/2014/04/prune-nodes-of-binary-search-tree.html’ under Binary Search Tree questions..

  • Hafeez
    • http://algorithmsandme.com/ Jitendra Sangar

      Done. Thank you very much for all your efforts and pointing out missing links!

    • http://algorithmsandme.com/ Jitendra Sangar

      Link has been corrected.

  • Faceless

    http://algorithmsandme.in/2013/11/heaps.html Heap sort algorithm link is broken.

    • http://algorithmsandme.com/ Jitendra Sangar

      Fixed. Thanks for pointing out

  • Dhanaraj D

    Longest palindrome substring
    Longest palindrome subsequence both taking to the same link