PLEASE FILE AN ISSUE IN CASE OF A BUG OR ADD A COMMENT. Feel free to email me: techpanja@gmail.com with issues or new problems.
I have a cloned repo https://github.com/techpanja/interviewproblemspublic which is open for contribution. Feel free to email me if you want to be a contributor.
A COMPILATION OF COMMON INTERVIEW QUESTIONS AND SOLUTIONS.
-
Given +ve numbers in an array.Put the even #s to the left of the array and the odd to the right side of the array . Don't use extra array. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/allevennumberstoleft/AllEvensToLeftandOddsToRight.java
-
Given a sequence of non-negative integers find a subsequence of length 3 having maximum product with the numbers of the subsequence being in ascending order. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/ascsubsequencemaxproduct/SubsequenceProduct.java
-
Shift array of integers circularly given input array and shift size. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/circularshiftintarray/CircularShiftArray.java
-
Check if a sub-array exists in parent array. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/findarray/FindArrayImpl.java
-
Find duplicates count in sorted array. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/findduplicatecountsortedarray/DuplicatesCountInSortedArray.java
-
Write a program takes array input{1,0,2,3} and num = 3 and provides output {1,2}{0,3}{2,1}{3,0} sum equals the num. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/findpairsequaltosum/FindPairsEqualToSum.java
-
Find the contiguous subarray which has the largest sum. Kadane's algorithm. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/maxsubarray/FindMaxSubArray.java
-
Given two sorted (ascending) arrays of integers, find the minimum difference between two integers in that array. Link:
-
Print numbers with frequency. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/numberfrequency/PrintNumbersWithFrequency.java
-
Find Number with Highest frequency in sorted array. Link: https://github.com/techpanja/interviewproblems/blob/master/src/arrays/numberwithhighestfreq/FindNumberWithHighestFreq.java
-
Find cartesian of lists. Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/cartesianproblem/CartesianOfLists.java
-
Find the common elements accross sorted sets/lists. Link:
-
Implement custom linked list. Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/customlinkedlist/LinkedListImpl.java
-
Check if a linked list has loops. Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/customlinkedlist/LinkedListImpl.java
-
Find nth element from end of the linked list. Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/findNTHlastelement/FindNthLastElement.java
-
Find the loop starting point in a LinkedList if it contains loop. Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/customlinkedlist/LinkedListImpl.java
-
Flatten a nested list. Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/nestedliststring/NestedList.java
-
Given a nested list of integers, returns the sum of all integers in the list weighted by their depth. Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/nestedlistsum/NestedListSum.java
-
Remove duplicate links from LinkedList. Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/removeduplicatesfromlinkedlist/RemoveDuplicatesFromLinkedList.java
-
Reverse a linked list. (In-place and using stack.) Link: https://github.com/techpanja/interviewproblems/blob/master/src/collections/customlinkedlist/LinkedListImpl.java
- Implement custom iterator. Link: https://github.com/techpanja/interviewproblems/blob/master/src/customiterator/AnimalIterator.java
-
Breadth First Search Link: https://github.com/techpanja/interviewproblems/blob/master/src/graphs/breadthfirstsearch/BFS.java
-
Depth First Search Link:
-
File Dependency Resolution Link: https://github.com/techpanja/interviewproblems/blob/master/src/graphs/graph/AbstractGraph.java
-
Max Heaps Link: https://github.com/techpanja/interviewproblems/blob/master/src/heaps/heap/MaxHeap.java
-
Min Heaps Link: https://github.com/techpanja/interviewproblems/blob/master/src/heaps/heap/MinHeap.java
-
Custom HashMap implementation. Link: https://github.com/techpanja/interviewproblems/blob/master/src/maps/customhashmap/CustomHashMapImpl.java
-
Least Recently Used (LRU) cache implementation. Link: https://github.com/techpanja/interviewproblems/blob/master/src/maps/lrucache/LRUCache.java
-
Concatenate two numbers. for e.g. 123, 0456 = 1230456 Link: https://github.com/techpanja/interviewproblems/blob/master/src/numberproblems/concatenatenumbers/ConcatenateNumbers.java
-
Convert string to number. Link: https://github.com/techpanja/interviewproblems/blob/master/src/numberproblems/convertstringtonumber/ConvertStringToNum.java
-
Find exponential of a number in fastest time. Link: https://github.com/techpanja/interviewproblems/blob/master/src/numberproblems/exponentialnumber/ExponentialOfNumber.java
-
Find factorial of a number. Link: https://github.com/techpanja/interviewproblems/blob/master/src/numberproblems/factorial/Factorial.java
-
Find no. of trailing zeroes in a factorial of number. Link: https://github.com/techpanja/interviewproblems/blob/master/src/numberproblems/factorial/FactorialNoOfTrailingZeroes.java
-
Find missing number in stream of numbers. Link: https://github.com/techpanja/interviewproblems/blob/master/src/numberproblems/findmissingnumber/FindMissingNumber.java
-
Check if a number is odd or even without using / % * + - operators. Link:
-
Swap Numbers. Link: https://github.com/techpanja/interviewproblems/blob/master/src/numberproblems/swapnumbers/SwapNumbers.java
-
Cloning example (Linked List). Link: https://github.com/techpanja/interviewproblems/blob/master/src/objects/cloning/linkedlistclone/LinkedListCloning.java
-
Implement an Immutable class. Link: https://github.com/techpanja/interviewproblems/blob/master/src/objects/immutableclass/ImmutableClass.java
-
Pass by value example. Link: https://github.com/techpanja/interviewproblems/blob/master/src/objects/passbyvalue/PassByValue.java
-
Implement a singleton class. (Double-check Locking and Static) Link: https://github.com/techpanja/interviewproblems/tree/master/src/objects/singleton
-
Bubble Sort. Link: https://github.com/techpanja/interviewproblems/blob/master/src/sorting/algorithms/BubbleSort.java
-
Insertion Sort. Link: https://github.com/techpanja/interviewproblems/blob/master/src/sorting/algorithms/InsertionSort.java
-
Merge Sort. Link: https://github.com/techpanja/interviewproblems/blob/master/src/sorting/algorithms/MergeSort.java
-
Quick Sort. Link: https://github.com/techpanja/interviewproblems/blob/master/src/sorting/algorithms/QuickSort.java
-
Selection Sort. Link: https://github.com/techpanja/interviewproblems/blob/master/src/sorting/algorithms/SelectionSort.java
-
Shell Sort. Link: https://github.com/techpanja/interviewproblems/blob/master/src/sorting/algorithms/ShellSort.java
-
Check if opening parenthesis pattern matches closing parenthesis pattern. Link:
-
Implement a queue using stack. Link: https://github.com/techpanja/interviewproblems/blob/master/src/stackqueues/queueusingstack/QueueUsingStack.java
-
Sort a stack using only one additional stack and no other data structure. Link:
-
Check string palindrome. Link:
-
Find common prefix for a given list of strings. Link:
-
Find duplicate strings in list of strings. Link:
-
Find latest version problem. Link:
-
Find Longest Common Subsequence. Link:
-
Find Longest Palindrome in a string. Link:
-
Print permutations of all characters in a string. Link:
-
Find total number of palindromes in a String. Link:
-
Find first non-repeated character. Link:
-
Given two (dictionary) words as Strings, determine if they are isomorphic. Link:
-
Given s string, Find max size of a sub-string, in which no duplicate chars present. Link:
-
Find min substring that contains all the char of target string. Link:
-
Print diamonds on basis of input size. Link:
-
Identify all the 'n' (n will be input) letter-long sequences that occur more than once in any given input string. OR Find repeating sequence of specified length in given DNA chromosome sequence. Link:
-
Reverse a string. Link:
-
Find all dictionary words in a given string. Link:
-
Return true if stringA is subsequence of stringB. Link:
-
Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring. Link:
-
Check if a string has all unqiue characters. Link:
-
Count word occurrence in a large text file. Link:
-
Implement blocking queue. Link: https://github.com/techpanja/interviewproblems/blob/master/src/threads/blockingqueue/BlockingQueue.java
-
Simulate a deadlock. Link: https://github.com/techpanja/interviewproblems/blob/master/src/threads/simulatedeadlock/DeadLockOreilly.java
-
Check Balanced Tree. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/checkbalancedtree/CheckBalancedTree.java
-
Check if a tree is Subtree of parent tree. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/checksubtree/CheckSubtree.java
-
Find common ancestor of two nodes in a binary tree (not necessarily BST). Link:
-
Find diameter Of Tree. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/diameteroftree/DiameterOfTree.java
-
Find All Paths Equal To Sum. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/findallpathsequaltosum/FindAllPathsEqualToSum.java
-
Find Sum Of All Nodes Except Leaf. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/findsumofallnodesexceptleaf/FindSumOfAllNodesExceptLeaf.java
-
Check is a given tree is binary search tree. (recursive and non recursive) Link:
-
Find least common ancestor (LCA) of a binary search tree given two nodes. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/leastcommonancestorbst/FindLeastCommonAncestorBST.java
-
Left View of a Tree. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/leftviewofatree/LeftViewOfATree.java
-
Mirror Given Tree. Link:
-
Check if a tree is Mirror of another Tree. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/mirrortree/MirrorTree.java
-
Print Nary Tree With Levels. Link: https://github.com/techpanja/interviewproblems/blob/master/src/trees/printnarytreewithlevels/PrintNaryTreeWithLevels.java
-
Given a sorted array, create a balanced tree. Link:
*** NOTE: Some problems might be in-complete. I have added TODO for such problems. ***