Topics and questions for coding challenges
- Big O
- Algorithms and Data Structures
- System design
- Object Oriented design questions
- Research the following topics (read on wikipedia):
- Top 10 algorithms or algorithmic concepts for coding interviews - by Techlead and algoexpert
- 1. depth first search -
- 2. breadth first search -
- 3. matching brackets problems
- 4. making use of hashtables
- 5. how to manipulate multiple variables or pointers at once:
- 6. reversing a linked list
- 7. sorting fundamentals
- 8. recursion
- 9. knowing how to construct custom datastructures.
- 10. binary search
- What is a list of data structures that a competitive programmer must know?
- Binary Search
- Quicksort
- Merge Sort
- Suffix Array
- Knuth-Morris-Pratt Algorithm (KMP)
- Rabin-Karp Algorithm
- Tries
- Depth First Traversal of a Graph
- Breadth First Traversal of a Graph
- Dijkstra’s Algorithm
- Binary Indexed Tree
- Segment Tree (with lazy propagation)
- Z algorithm
- Floyd Warshall Algorithm
- Sparse Table (LCP, RMQ)
- Heap / Priority Queue / Heapsort
- Modular Multiplicative Inverse
- Binomial coefficients (nCr % M)
- Suffix Automaton
- Lowest Common Ancestor
- Counting Inversions
- Euclid’s Extended Algorithm
- Suffix Tree
- Dynamic Programming
- Basic Data Structures
- Logarithmic Exponentiation
- Graphs
- Minimum Spanning Tree
- Efficient Prime Factorization
- Combinatorics
- Union Find/Disjoint Set
- Knapsack problem
- Aho-Corasick String Matching Algorithm
- Strongly Connected Components
- Bellman Ford algorithm
- Heavy-light Decomposition
- Convex Hull
- Line Intersection
- Sieve of Erastothenes
- Interval Tree
- Counting Sort
- Probabilities
- Matrix Exponentiation
- Network flow
- K-d tree
- Deque
- Binary Search Tree
- Quick Select
- Treap/Cartesian Tree
- Game Theory
- STL (C++)
- Maximum Bipartite Matching
- Manacher’s Algorithm
- Miller-Rabin Primality Test
- Stable Marriage Problem
- Hungarian Algorithm
- Sweep line Algorithm
- LCP
- Gaussian Elimination
- Pollard Rho Integer Factorization
- Topological Sorting
- Detecting Cycles in a Graph
- Geometry
- Backtracking
- Eulerian and Hamiltonian Paths
- Graph Coloring
- Meet in the Middle
- Arbitrary Precision Integer(BigInt)
- Radix Sort
- Bucket Sort
- Johnson’s Algorithm
- Maximal Matching in a General Graph
- Recursion
- Inclusion and Exclusion Principle
- Co-ordinate Compression
- Sqrt-Decomposition
- Link-Cut Tree
- Euler’s Totient Function
- Burnside Lemma
- Edit/Levenshtein Distance
- Branch and Bound
- Math for Competitive Programming
- Mo’s Algorithm
- Interview Questions
- Implementations for ADTs
- Data Abstraction & Problem Solving with C++
- Top 75 Programming Interview Questions Answers to Crack Any Coding Job Interview
- Top 50 Coding Interview Questions for Programmers
- Top 75 Essential Programming Interview Questions to Crack Any Coding Interview
- 100+ Coding Interview Questions for Programmers
- Data Structures for Coding Interviews in Java
- Catalog
Big O
https://www.bigocheatsheet.com/
Big O Basic Concepts
O(1): Constant Time
- Doesn’t depend on the size of the data set.
- Example: Accessing an array element by its index.
O(log n): Logarithmic Time
- Splits the data in each step (divide and conquer).
- Example: Binary search.
O(n): Linear Time
- Directly proportional to the data set size.
- Example: Looping through an array.
O(n log n): Linearithmic Time
- Splits and sorts or searches data.
- Example: Merge sort, quick sort.
O(n2): Polynomial Time
- Nested loops for each power of n.
- Example: Bubble sort (O(n2)).
Omega (Ω) – Best Case
- What it means: Omega (Ω) describes the best-case scenario for an algorithm.
- In simple terms: It tells you the fastest an algorithm can run in the best circumstances.
Theta (Θ) - Average Case
- In simple terms: It tells you what to generally expect in terms of time complexity.
Big O (O) - Worst Case
- What it means: Big O (O) describes the worst-case scenario for an algorithm.
- In simple terms: It tells you the slowest an algorithm can run in the worst circumstances.
Drop Constants
- O(2n) simplifies to O(n).
Drop Non-Dominant Terms
- In O(n^2 + n), focus on O(n^2) as it will dominate for large n.
Algorithms and Data Structures
- Data Structures
- Data types
- Trees
- Searching algorithms
- Sorting algorithms
- Bitwise operations
- Greatest Common Divisor (GCD)
- Least Common Multiple (LCM)
- Logarithms and Exponentials
- Divide, Conquer and Combine paradigm
- Permutations
System design
- design a distributed datastore for a movie recommendation site.
- Could you design an analytics tracking system to monitor all of the orders going through the site? How about building a flow so users can upload videos?
- How does Twitter or Facebook Messenger work? What are the underlying technologies?
The coolest part is that many companies share details of how they designed parts of their systems. Uber, for example, has tons of great articles on their engineering blog (LINK) about how they built out different pieces of technology.
This first step is very much a research process. Google “facebook messenger technology” or check out sites like Gainlo where he breaks down these sorts of design problems.
Object Oriented design questions
- What classes they would define.
- What methods go in each class (including signatures).
- What the class constructors are responsible for.
- What data structures the class will have to maintain.
- Whether any Design Patterns are applicable to this problem.
Design a deck of cards that can be used for different card game applications.
Likely classes: a Deck, a Card, a Hand, a Board, and possibly Rank and Suit. Drill down on who’s responsible for creating new Decks, where they get shuffled, how you deal cards, etc. Do you need a different instance for every card in a casino in Vegas?
Model the Animal kingdom as a class system, for use in a Virtual Zoo program.
Possible sub-issues: do they know the animal kingdom at all? (I.e. common sense.) What properties and methods do they immediately think are the most important? Do they use abstract classes and/or interfaces to represent shared stuff? How do they handle the multiple-inheritance problem posed by, say, a tomato (fruit or veggie?), a sponge (animal or plant?), or a mule (donkey or horse?)
Create a class design to represent a filesystem.
Do they even know what a filesystem is, and what services it provides? Likely classes: Filesystem, Directory, File, Permission. What’s their relationship? How do you differentiate between text and binary files, or do you need to? What about executable files? How do they model a Directory containing many files? Do they use a data structure for it? Which one, and what performance tradeoffs does it have?
Design an OO representation to model HTML.
How do they represent tags and content? What about containment relationships? Bonus points if they know that this has already been done a bunch of times, e.g. with DOM. But they still have to describe it.
The following commonly-asked OO design interview questions are probably too involved to be good phone-screen weeders:
Design a parking garage.
Design a bank of elevators in a skyscraper.
Model the monorail system at Disney World.
Design a restaurant-reservation system.
Design a hotel room-reservation system. See https://github.com/zeevolution/hotel-reservation
Research the following topics (read on wikipedia):
- Birthday problem
- Self-organizing list
- Self-balancing binary search tree
- Locality of reference
- CPU Cache
- Dynamic perfect hashing
- Fusion tree
- Cunningham’s law
- MonteCarlo simulation
- The Hungarian algorithm
- Luhn algorithm - https://www.geeksforgeeks.org/luhn-algorithm/
- staircase problem - make it generic. any combination of steps that can be taken to get to the top.
- The traveling salesman problem
Top 10 algorithms or algorithmic concepts for coding interviews - by Techlead and algoexpert
1. depth first search -
graph traversal or tree traversal
tree structures - getting to the leaf nodes and backtracking.
e.g. binary tree structure with letters in a string
2. breadth first search -
e.g. take a tree and print it level by level
difference between 1 and 2 it the order of traversal.
3. matching brackets problems
is it valid?
what is the next bracket to be added?
using stacks
other ways are possible but not very straightforward
4. making use of hashtables
e.g. 2D matrix - visit the matrix but somehow keep track of the elements that are already visited.
e.g. largest amount of zeroes that are next to each other.
use hashtable to make sure yu don’t revisit grid coordinates that are already visited.
e.g. nth fibonacci number
5. how to manipulate multiple variables or pointers at once:
e.g. using two pointers for a string
e.g. using two pointers to traverse a linked list and each of them are going at different speeds from one another.
e.g. longest palindromic substring in a string. for every letter, start two pointers going in the opposite directions.
6. reversing a linked list
e.g. are there duplicates in a linked list
e.g. remove the duplicates in a linked list
creating a class for the node and then using it for traversals
7. sorting fundamentals
quick sort, merge sort, insertion sort, heap sort, bubble sort
not to memorize them but understand them fundamentally.
know the runtimes for these sorts.
8. recursion
9. knowing how to construct custom datastructures.
e.g. suffix tree like datastructure.
capture a bunch of strings in a datastructure.
10. binary search
quick sort works similar to binary search.
What is a list of data structures that a competitive programmer must know?
Reference: https://qr.ae/pNLa3S
Sameer Gulati · Updated August 12, 2019 Competitive Programming · International Master at Codeforces
This is a comprehensive list of Data Structures and Algorithms used in Competitive Programming with tutorials, implementations and problems. Use this list in conjunction with this strategy (Sameer Gulati’s answer to What made you good at competitive programming?). I originally posted this list on the Codechef Discuss Forum. Moving forward I will be keeping this list updated here on Quora:
Binary Search
- Tutorial, Problems - https://www.topcoder.com/community/data-science/data-science-tutorials/binary-search/
- Tutorial, Implementation - https://geeksquiz.com/binary-search/
- Problem -https://www.spoj.com/problems/AGGRCOW/
Quicksort
- Tutorial, Implementation - http://geeksquiz.com/quick-sort/
- Tutorial - https://www.topcoder.com/community/competitive-programming/tutorials/sorting
Merge Sort
- Tutorial, Implementation - http://geeksquiz.com/merge-sort/
- Tutorial - https://www.topcoder.com/community/competitive-programming/tutorials/sorting
Suffix Array
- Tutorial - http://web.stanford.edu/class/cs97si/suffix-array.pdf
- Tutorial, Implementation - http://discuss.codechef.com/questions/21385/a-tutorial-on-suffix-arrays
- Tutorial, Implementation - http://apps.topcoder.com/forums/%3Bjsessionid%3DBC99925E58CB2628CA9AA3AFC13F6593?module=Thread&threadID=627379&start=0
- Problem - http://www.spoj.com/problems/SUBST1/
- Problem - http://www.codechef.com/problems/MOU1H
Knuth-Morris-Pratt Algorithm (KMP)
- Tutorial - https://www.topcoder.com/community/data-science/data-science-tutorials/introduction-to-string-searching-algorithms/
- Tutorial, Implementation - http://www.geeksforgeeks.org/searching-for-patterns-set-2-kmp-algorithm/
- Tutorial - http://keithschwarz.com/interesting/code/?dir=knuth-morris-pratt
- Problem - http://www.codechef.com/problems/TASHIFT
Rabin-Karp Algorithm
- Tutorial, Implementation - http://www.geeksforgeeks.org/searching-for-patterns-set-3-rabin-karp-algorithm/
- Tutorial - https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-string-searching-algorithms/
- Problem - http://www.codechef.com/problems/SSTORY
- Problem - http://codeforces.com/problemset/problem/271/D
Tries
- Tutorial, Problems - https://www.topcoder.com/community/competitive-programming/tutorials/using-tries/
- Tutorial :
- Tutorial - https://www.quora.com/q/threadsiiithyderabad/Tutorial-on-Trie-and-example-problems
- Problem -http://www.spoj.com/problems/SUBXOR/
- Problem - https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&category=345&page=show_problem&problem=2683
- Problem - http://www.codechef.com/problems/EST
Depth First Traversal of a Graph
- Tutorial, Implementation - http://www.geeksforgeeks.org/depth-first-traversal-for-a-graph/
- Tutorial, Problems - https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-graphs-and-their-data-structures-section-2/
- Problem - http://www.spoj.com/problems/PARADOX/
- Problem - http://www.spoj.com/problems/BUGLIFE/
- Problem -http://www.spoj.com/problems/PT07Z/
Breadth First Traversal of a Graph
- Tutorial, Implementation - http://www.geeksforgeeks.org/breadth-first-traversal-for-a-graph/
- Tutorial Problems - https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-graphs-and-their-data-structures-section-2/
- Problem - http://www.codechef.com/problems/DIGJUMP
- Problem - http://www.spoj.com/problems/ONEZERO/
- Problem - http://www.spoj.com/problems/NAKANJ/
- Flood Fill - http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=findSolution#floodfill
Dijkstra’s Algorithm
- Tutorial, Problems - https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-graphs-and-their-data-structures-section-3/
- Problem - http://www.codechef.com/problems/REN2013G
- Tutorial(greedy) - http://e-maxx.ru/algo/dijkstra
- Tutorial (with heap) - https://e-maxx.ru/algo/dijkstra_sparse
- Implementation - http://zobayer.blogspot.in/2009/12/dijkstras-algorithm-in-c.html
- Problem - http://www.spoj.com/problems/EZDIJKST/
- Problem - http://www.spoj.com/problems/SHPATH/
Binary Indexed Tree
- Tutorial, Problems - http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=binaryIndexedTrees
- Tutorial - http://codeforces.com/blog/entry/619
- Original Paper - http://citeseerx.ist.psu.edu/viewdoc/download%3Bjsessionid%3DAB3AEBC0736E52FA815A3D4C633DE52F?doi=10.1.1.14.8917&rep=rep1&type=pdf
- Tutorial - http://sanugupta.wordpress.com/2014/08/29/binary-indexed-tree-fenwick-tree/
- Tutorial - http://cs.stackexchange.com/a/10541
- Problem - http://www.spoj.com/problems/HORRIBLE/
- Problem - http://www.spoj.com/problems/YODANESS/
- Problem - http://www.spoj.com/problems/INVCNT/
- Problem -http://www.spoj.com/problems/NICEDAY/
- Problem - http://www.spoj.com/problems/CTRICK/
- Problem - http://www.spoj.com/problems/DQUERY/
- Problem - http://www.spoj.com/problems/MCHAOS/
Segment Tree (with lazy propagation)
- Tutorial, Implementation - http://se7so.blogspot.in/2012/12/segment-trees-and-lazy-propagation.html
- Tutorial - http://se7so.blogspot.in/2012/12/segment-trees-and-lazy-propagation.html
- Tutorial, Problems, Implementation - http://letuskode.blogspot.in/2013/01/segtrees.html
- Tutorial, Implementation and Various Uses - http://e-maxx.ru/algo/segment_tree
- Persistent Segment Tree: -
- problems same as BIT,
- Problem - http://www.spoj.com/problems/HORRIBLE/
- Problem - http://www.codechef.com/problems/IDOLS HLD is used as well
Z algorithm
- Tutorial, Problem - http://codeforces.com/blog/entry/3107
- Tutorial - https://www.cs.umd.edu/class/fall2011/cmsc858s/Lec02-zalg.pdf
- Tutorial - https://ivanyu.me/blog/2013/10/15/z-algorithm/
- problems same as KMP -
Floyd Warshall Algorithm
- Tutorial, Implementation - http://www.geeksforgeeks.org/dynamic-programming-set-16-floyd-warshall-algorithm/
- Problem - http://www.spoj.com/problems/AMR11F/
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=2356
Sparse Table (LCP, RMQ)
- Tutorial, Problems - https://www.topcoder.com/community/data-science/data-science-tutorials/range-minimum-query-and-lowest-common-ancestor/
- Tutorial, Implementation(C++) - http://mayanknatani.wordpress.com/2013/07/15/range-minimum-query/
- Java implementation - https://sites.google.com/site/indy256/algo/sparse_table_rmq
Heap / Priority Queue / Heapsort
- Implementation, Explanation - http://www.sourcetricks.com/2011/06/c-heaps.html#.U9z8J_mSzfc
- Tutorial - http://pages.cs.wisc.edu/~vernon/cs367/notes/11.PRIORITY-Q.html
- Implementation - http://www.cprogramming.com/tutorial/computersciencetheory/heapcode.html
- Problem - http://www.codechef.com/problems/REVERSE
- Chapter from CLRS -
Modular Multiplicative Inverse
Binomial coefficients (nCr % M)
- Tutorial - http://discuss.codechef.com/questions/3869/best-known-algos-for-calculating-ncr-m
- Tutorial - http://fishi.devtail.io/weblog/2015/06/25/computing-large-binomial-coefficients-modulo-prime-non-prime/
- Paper - https://www.dropbox.com/s/h7665pcqto17pl4/BinCoeff.pdf (Link Not Working),
- Problem -https://www.codechef.com/problems/SANDWICH
Suffix Automaton
- Detailed Paper - http://www.cs.nyu.edu/~mohri/pub/nfac.pdf
- Tutorial, Implementation (I) - http://www.geeksforgeeks.org/searching-for-patterns-set-5-finite-automata/
- Tutorial, Implementation (II) - http://www.geeksforgeeks.org/pattern-searching-set-5-efficient-constructtion-of-finite-automata/
- Problem - http://www.codechef.com/problems/SUBQUERY
- Problem - http://www.codechef.com/problems/TSUBSTR
- Problem - http://www.codechef.com/problems/SSTORY
- Problem - http://www.codechef.com/problems/MOU1H
- Tutorial, Implementation - http://e-maxx.ru/algo/suffix_automata
Lowest Common Ancestor
- Tutorial, Problems - http://www.topcoder.com/tc?d1=tutorials&d2=lowestCommonAncestor&module=Static
- Paper - http://www14.informatik.tu-muenchen.de/konferenzen/Jass08/courses/1/moufatich/El_Moufatich_Paper.pdf
- Paper - http://ab.inf.uni-tuebingen.de/people/fischer/lsa.pdf
- Problem - https://www.codechef.com/LTIME14/problems/TALCA
- Problem - https://www.spoj.com/problems/LCA/
- Problem - https://www.codechef.com/problems/TRIPS
Counting Inversions
- Divide and Conquer - http://www.geeksforgeeks.org/counting-inversions/
- Segment Tree, - https://www.quora.com/How-to-count-inversions-using-Segment-Tree-of-a-given-array
- Fenwick Tree - http://pavelsimo.blogspot.in/2012/09/counting-inversions-in-array-using-BIT.html
- Problem - http://www.codechef.com/problems/DYNAINV
Euclid’s Extended Algorithm
Suffix Tree
- Tutorial - http://stackoverflow.com/questions/9452701/ukkonens-suffix-tree-algorithm-in-plain-english
- Tutorial - http://marknelson.us/1996/08/01/suffix-trees/
- Intro - http://www.geeksforgeeks.org/pattern-searching-set-8-suffix-tree-introduction/
- Construction :
- Implementation - http://marknelson.us/attachments/1996/suffix-trees/stree2006.cpp
- Implementation - http://www.sanfoundry.com/cpp-program-implement-suffix-tree/
- Problem - http://www.spoj.com/problems/LCS/
- Problem - http://www.codechef.com/OCT11/problems/REPSTR
- Problem - http://www.spoj.com/problems/BEADS/
- Problem - http://www.codechef.com/problems/TASTR
Dynamic Programming
- Chapter from CLRS(essential),
- Tutorial, Problems - https://www.topcoder.com/community/competitive-programming/tutorials/dynamic-programming-from-novice-to-advanced/
- Problem - http://www.codechef.com/problems/LEPAINT
- Problem - http://www.codechef.com/problems/COINS
- Problem - http://www.codechef.com/problems/MARCHA1
- Problem - http://discuss.codechef.com/questions/47239/frogv-editorial
- Tutorial - https://www.quora.com/Are-there-any-good-resources-or-tutorials-for-dynamic-programming-DP-besides-the-TopCoder-tutorial
- Problem - http://www.codechef.com/problems/TSHIRTS
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=11566
- Problem - http://www.spoj.com/problems/SOCOLA/
- Longest Increasing Subsequence - http://www.geeksforgeeks.org/longest-monotonically-increasing-subsequence-size-n-log-n/
- Bitmask DP - http://codeforces.com/blog/entry/337
- Bitmask DP - http://www.ugrad.cs.ubc.ca/~cs490/sec202/notes/dp/DP%202.pdf
- Optimization - http://codeforces.com/blog/entry/8219
- Problem - http://www.spoj.com/problems/TRSTAGE/
- Problem - http://www.spoj.com/problems/LAZYCOWS/
- Problem - http://www.spoj.com/problems/HIST2/
- Problem - http://www.spoj.com/problems/MKPAIRS/
- Problem - http://www.spoj.com/problems/NKLEAVES/
- Problem - http://www.spoj.com/problems/DRAGON2/
- Problem - http://codeforces.com/contest/461/problem/B
- DP on Trees :
Basic Data Structures
- Tutorial - https://www.topcoder.com/community/competitive-programming/tutorials/data-structures/
- Stack Implementation - https://www.cs.bu.edu/teaching/c/stack/array/
- Queue Implementation, - http://geeksquiz.com/queue-set-1introduction-and-array-implementation/
Logarithmic Exponentiation
Graphs
- Definition, Representation - http://discuss.codechef.com/questions/17801/introduction-to-graphs-definitions-traversal-depth-first-search
- Definition, Representation - https://www.topcoder.com/community/competitive-programming/tutorials/introduction-to-graphs-and-their-data-structures-section-1/
- Problem - http://www.codechef.com/problems/DRGHTS
- Problem - http://www.codechef.com/problems/DIREL
Minimum Spanning Tree
- Tutorial - https://www.ics.uci.edu/~eppstein/161/960206.html
- Tutorial, Kruskal’s Implementation - http://www.geeksforgeeks.org/greedy-algorithms-set-2-kruskals-minimum-spanning-tree-mst/
- Prim’s Implementation - http://www.geeksforgeeks.org/greedy-algorithms-set-5-prims-minimum-spanning-tree-mst-2/
- Problem - http://www.spoj.com/problems/MST/
- Problem - http://www.spoj.com/problems/CSTREET/
- Problem - http://www.spoj.com/problems/BLINNET/
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=7921&rd=10765
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=7643&rd=12058
Efficient Prime Factorization
Combinatorics
- Tutorial, Problems - https://www.topcoder.com/community/competitive-programming/tutorials/basics-of-combinatorics/
- Problem - http://www.codechef.com/problems/BINTOUR
- Tutorial - http://apps.topcoder.com/forums/?module=Thread&threadID=334598&start=0&mc=13#335550
Union Find/Disjoint Set
- Tutorial - http://www.cs.cornell.edu/~wdtseng/icpc/notes/graph_part4.pdf
- Tutorial, Problems - http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=disjointDataStructure
- Problem - http://www.codechef.com/problems/DISHOWN
- Problem - http://www.spoj.com/problems/BLINNET/
- Problem - http://www.spoj.com/problems/CHAIN/
Knapsack problem
Solution, Implementation - http://www.geeksforgeeks.org/dynamic-programming-set-10-0-1-knapsack-problem/
Aho-Corasick String Matching Algorithm
- Tutorial - http://www.cs.sun.ac.za/~lvzijl/courses/rw778/autappl/crous-hw2.pdf
- Implementation -https://gist.github.com/andmej/1233426
- Problem - http://www.codechef.com/problems/FAVNUM
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=11514&rd=14544
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=6017
- Problem -http://www.spoj.com/problems/WPUZZLES/
Strongly Connected Components
- Tutorial, Implementation - http://www.geeksforgeeks.org/strongly-connected-components/
- Tutorial -http://www.cs.berkeley.edu/~vazirani/s99cs170/notes/lec12.pdf
- Problem - https://www.spoj.com/problems/BOTTOM/
- Problem - https://www.spoj.com/problems/BREAK/
- Problem - https://community.topcoder.com/stat?c=problem_statement&pm=8488&rd=11125
Bellman Ford algorithm
- Tutorial, Implementation - http://www.geeksforgeeks.org/dynamic-programming-set-23-bellman-ford-algorithm/
- Tutorial, Implementation - http://compprog.wordpress.com/2007/11/29/one-source-shortest-path-the-bellman-ford-algorithm/
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=10580
- Problem - http://codeforces.com/problemset/problem/346/D
Heavy-light Decomposition
- Tutorial, Problems - http://e-maxx.ru/algo/heavy_light
- Tutorial, Implementation -http://blog.anudeep2011.com/heavy-light-decomposition/
- Tutorial - http://wcipeg.com/wiki/Heavy-light_decomposition
- Implementation - http://apps.topcoder.com/forums/?module=Thread&threadID=796128&start=0&mc=8
- Implementation - http://pastie.org/private/ozpqitws20ylrj8a57tog
- Problem - http://www.spoj.com/problems/QTREE6/
- Problem - http://www.codechef.com/problems/PUSHFLOW
- Problem - http://www.codechef.com/problems/GERALD2
Convex Hull
- Tutorial, Jarvis Algorithm Implementation - http://www.geeksforgeeks.org/convex-hull-set-1-jarviss-algorithm-or-wrapping/
- Tutorial with Graham scan - http://www.geeksforgeeks.org/convex-hull-set-2-graham-scan/
- Tutorial - https://www.topcoder.com/community/data-science/data-science-tutorials/geometry-concepts-line-intersection-and-its-applications/
- Implementation - http://stanford.edu/~liszt90/acm/notebook.html#file8
- Problem - https://www.topcoder.com/stat?c=problem_statement&pm=3996&rd=7224
- Problem - http://codeforces.com/problemset/problem/166/B
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=1960&rd=4670
- Problem - http://acm.timus.ru/problem.aspx?space=1&num=1185
- Problem - http://www.spoj.com/problems/BSHEEP/
Line Intersection
- Tutorial, Implementation - http://www.geeksforgeeks.org/check-if-two-given-line-segments-intersect/
- Tutorial, Problems - https://www.topcoder.com/community/competitive-programming/tutorials/geometry-concepts-line-intersection-and-its-applications/
Sieve of Erastothenes
Interval Tree
- Tutorial, Implementation - http://www.geeksforgeeks.org/interval-tree/
- Problem - http://www.codechef.com/problems/FLIPCOIN/
- Problem - https://www.spoj.com/problems/THRBL/
- Problem - https://www.spoj.com/problems/LITE/
- Problem - https://www.spoj.com/problems/FREQUENT/
- Problem - http://www.spoj.com/problems/GSS1/
- Problem - http://www.spoj.com/problems/GSS3/
- Tutorial - http://www.dgp.toronto.edu/people/JamesStewart/378notes/22intervals/
Counting Sort
Probabilities
Matrix Exponentiation
- Tutorial - http://discuss.codechef.com/questions/2335/building-up-the-recurrence-matrix-to-compute-recurrences-in-ologn-time
- Tutorial - http://zobayer.blogspot.in/2010/11/matrix-exponentiation.html
Network flow
- (Max Flow)Tutorial :
- Max Flow(Ford-Fulkerson) Tutorial, Implementation - https://www.geeksforgeeks.org/ford-fulkerson-algorithm-for-maximum-flow-problem/
- (Min Cut) Tutorial, Implementation - http://www.geeksforgeeks.org/minimum-cut-in-a-directed-graph/
- (Min Cost Flow)Tutorial :
- I, - http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=minimumCostFlow1
- II - https://www.topcoder.com/community/competitive-programming/tutorials/minimum-cost-flow-part-two-algorithms/
- III - https://www.topcoder.com/community/competitive-programming/tutorials/minimum-cost-flow-part-three-applications/
- Dinic’s Algorithm with Implementation - http://e-maxx.ru/algo/dinic
- Max flow by Edmonds Karp with Implementation - http://e-maxx.ru/algo/edmonds_karp
- Problem - http://www.codechef.com/problems/TWOCOMP
- Problem - http://www.codechef.com/problems/LONGART
- Problem - http://www.codechef.com/problems/ANUBTT
- Problem - http://www.codechef.com/problems/ORDERAAM
- Problem - http://www.codechef.com/problems/PARADE
- Problem - http://www.codechef.com/problems/CAKE2AM
- Problem - http://www.spoj.com/problems/EN/
- Problem - http://www.spoj.com/problems/POTHOLE/
- Problem - http://www.spoj.com/problems/SCITIES/
- Problem - http://www.spoj.com/problems/GREED/
- Problem - http://www.spoj.com/problems/TOURS/
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=1931&rd=4709
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=2852&rd=5075
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=3530&rd=6535
K-d tree
- Tutorial - http://web.stanford.edu/class/cs106l/handouts/assignment-3-kdtree.pdf
- Tutorial - http://www.autonlab.org/autonweb/14665/version/2/part/5/data/moore-tutorial.pdf?branch=main&language=en
- Implementation - http://rosettacode.org/wiki/K-d_tree
- Problem - http://www.spoj.com/problems/GANNHAT/
Deque
Binary Search Tree
- Tutorial, Implementation - http://www.sourcetricks.com/2011/06/binary-search-trees-in-c.html#.U--wAvmSzfc
- Searching and Insertion - http://geeksquiz.com/binary-search-tree-set-1-search-and-insertion/
- Deletion - http://geeksquiz.com/binary-search-tree-set-2-delete/
Quick Select
- Implementation - http://www.sourcetricks.com/2011/06/quick-select.html#.U_CQ0_mSzfc
- Implementation - http://rosettacode.org/wiki/Quickselect_algorithm#C.2B.2B
Treap/Cartesian Tree
- Tutorial(detailed) - http://habrahabr.ru/post/101818/
- Tutorial, Implementation - http://e-maxx.ru/algo/treap
- Uses and Problems - http://codeforces.com/blog/entry/3767
- Problem - http://www.codechef.com/problems/CARDSHUF/
- Problem - http://www.codechef.com/problems/CHEFC
Game Theory
- Detailed Paper - http://www.math.ucla.edu/~tom/Game_Theory/comb.pdf
- Tutorial, Problems - http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=algorithmGames
- Grundy Numbers - http://letuskode.blogspot.ch/2014/08/grundy-numbers.html
- Tutorial with example problems -
- I, - http://www.thelearningpoint.net/home/mathematics/an-introduction-to-game-theory
- II, - http://www.thelearningpoint.net/home/mathematics/a-totorial-on-extensive-games-with-problems-and-solutions
- III, - http://www.thelearningpoint.net/home/mathematics/bayesian-games---games-with-incomplete-information
- IV - http://www.thelearningpoint.net/home/mathematics/repeated-games---tutorial-and-solved-problems
- Tutorial, Problems - http://www.codechef.com/wiki/tutorial-game-theory
- Problem - http://www.spoj.com/problems/NGM/
- Problem - http://www.spoj.com/problems/MCOINS/
- Problem - http://www.spoj.com/problems/QCJ3/
- Problem - http://www.spoj.com/problems/RESN04/
- Problem - http://www.spoj.com/problems/MMMGAME/
- Problem - http://www.spoj.com/problems/PEBBMOV/
- Problem - http://www.codechef.com/problems/CHEFBRO
- Problem - http://www.spoj.com/problems/HUBULLU/
- Problem - http://www.codechef.com/problems/BIGPIZA
- Problem - http://codeforces.com/contest/87/problem/C
- Problem - http://www.spoj.com/problems/CRSCNTRY/
- Nim - http://codeforces.com/blog/entry/3657
STL (C++)
- I - https://www.topcoder.com/community/competitive-programming/tutorials/power-up-c-with-the-standard-template-library-part-1/
- II - https://www.topcoder.com/community/competitive-programming/tutorials/power-up-c-with-the-standard-template-library-part-2/
- Crash Course - http://community.topcoder.com/tc?module=Static&d1=features&d2=082803
Maximum Bipartite Matching
Manacher’s Algorithm
- Implementation - http://leetcode.com/2011/11/longest-palindromic-substring-part-ii.html
- Tutorial - http://tarokuriyama.com/projects/palindrome2.php
- Tutorial, Implementation - http://tristan-interview.blogspot.in/2011/11/longest-palindrome-substring-manachers.html
- Tutorial, Implementation - http://e-maxx.ru/algo/palindromes_count
- Problem - http://acm.timus.ru/problem.aspx?space=1&num=1937
- Problem - http://www.spoj.com/problems/LPS/
- Problem - http://www.spoj.com/problems/MSUBSTR/
Miller-Rabin Primality Test
- http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=primalityTesting
- Code - http://rosettacode.org/wiki/Miller-Rabin_primality_test#C
Stable Marriage Problem
Hungarian Algorithm
- http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=hungarianAlgorithm
- Tutorial - https://math.uc.edu/~halpern/Linear.progr.folder/Handouts.lp.02/Hungarian.algorithm.pdf
Sweep line Algorithm
- I - https://www.topcoder.com/tc?module=Static&d1=tutorials&d2=lineSweep
- II - http://www.geeksforgeeks.org/given-a-set-of-line-segments-find-if-any-two-segments-intersect/
LCP
- Tutorial, Implementation - http://codeforces.com/blog/entry/12796#comment-175287
- Tutorial, Implementation - http://e-maxx.ru/algo/suffix_array#7
Gaussian Elimination
Pollard Rho Integer Factorization
- http://www.cs.colorado.edu/~srirams/classes/doku.php/pollard_rho_tutorial
- problem - http://www.spoj.com/problems/FACT1/
Topological Sorting
Detecting Cycles in a Graph
- Directed -
- Undirected : http://www.geeksforgeeks.org/detect-cycle-undirected-graph/
Geometry
- Basics - https://www.topcoder.com/community/competitive-programming/tutorials/geometry-concepts-basic-concepts/
- Tutorial - http://web.stanford.edu/class/cs97si/09-computational-geometry.pdf
Backtracking
- N queens problem - http://www.geeksforgeeks.org/backtracking-set-3-n-queen-problem/
- Tug of War - http://www.geeksforgeeks.org/tug-of-war/
- Sudoku - http://www.geeksforgeeks.org/backtracking-set-7-suduku/
Eulerian and Hamiltonian Paths
- Tutorial - http://www.cs.sfu.ca/~ggbaker/zju/math/euler-ham.html#ham
- Tutorial - http://www.csd.uoc.gr/~hy583/papers/ch14.pdf
- (Eulerian Path and Cycle)Implementation - http://www.geeksforgeeks.org/eulerian-path-and-circuit/
- (Hamiltonian Cycle)Implementation - http://www.geeksforgeeks.org/backtracking-set-7-hamiltonian-cycle/
Graph Coloring
- Tutorial, Implementation - http://algorithm.daqwest.com/search?search=Coloring%20algorithm
Meet in the Middle
- Tutorial - http://www.infoarena.ro/blog/meet-in-the-middle
- Implementation - https://sites.google.com/site/indy256/algo/meet-in-the-middle
Arbitrary Precision Integer(BigInt)
Radix Sort
Bucket Sort
Johnson’s Algorithm
- Tutorial - http://www.geeksforgeeks.org/johnsons-algorithm/
- Tutorial - http://en.wikipedia.org/wiki/Johnson%27s_algorithm
- Implementation - https://gist.github.com/ashleyholman/6793360
Maximal Matching in a General Graph
- Blossom/Edmond’s Algorithm, Implementation - http://e-maxx.ru/algo/matching_edmonds
- Tutte Matrix - http://e-maxx.ru/algo/tutte_matrix
- Problem - http://www.codechef.com/problems/SEAGRP
Recursion
- I, - http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=recursionPt1
- II - http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=recursionPt2
- Towers of Hanoi - http://geeksquiz.com/c-program-for-tower-of-hanoi/
- with explanation - http://en.wikipedia.org/wiki/Tower_of_Hanoi#Recursive_solution
Inclusion and Exclusion Principle
- I - http://apps.topcoder.com/forums/?module=Thread&threadID=685138&start=0
- II - http://e-maxx.ru/algo/inclusion_exclusion_principle
Co-ordinate Compression
Sqrt-Decomposition
- Tutorial - http://e-maxx.ru/algo/sqrt_decomposition
- Tutorial - http://sysmagazine.com/posts/138946/
- Problem - http://www.spoj.com/problems/RACETIME/
- Problem - http://www.codechef.com/problems/GERALD07
Link-Cut Tree
- Tutorial - http://www.cs.cmu.edu/~sleator/papers/dynamic-trees.pdf
- Wiki - http://en.wikipedia.org/wiki/Link/cut_tree
- Tutorial, Implementation - http://www.cs.cmu.edu/~avrim/451f12/lectures/lect1009-linkcut.txt
- Problem - http://www.codechef.com/problems/QTREE6
- Problem - http://www.spoj.com/problems/DYNACON1/
- Problem - http://www.spoj.com/problems/DYNALCA/
- Problem - http://codeforces.com/contest/117/problem/E
Euler’s Totient Function
- Explanation, Implementation, Problems - http://e-maxx.ru/algo/euler_function
- Explanation, Problems - http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=primeNumbers
Burnside Lemma
- Tutorial - http://e-maxx.ru/algo/burnside_polya
- Tutorial -http://petr-mitrichev.blogspot.in/2008/11/burnsides-lemma.html
- Problem - http://community.topcoder.com/stat?c=problem_statement&pm=9975
Edit/Levenshtein Distance
- Tutorial - https://web.stanford.edu/class/cs124/lec/med.pdf
- Introduction - http://en.wikipedia.org/wiki/Wagner%E2%80%93Fischer_algorithm
- Tutorial - http://www.csse.monash.edu.au/~lloyd/tildeAlgDS/Dynamic/Edit/
- Problem - http://www.codechef.com/problems/SEATSR
- Problem - http://www.spoj.com/problems/EDIST/
Branch and Bound
Math for Competitive Programming
Mo’s Algorithm
- Tutorial and Problems - http://blog.anudeep2011.com/mos-algorithm/
Interview Questions
- https://shirsh94.medium.com/top-100-interview-programming-questions-that-asks-many-times-5c5bf36449ab
- https://javaconceptoftheday.com/java-interview-programs-with-solutions/
- https://codeburst.io/review-these-50-questions-to-crack-your-java-programming-interview-69d03d746b7f
- https://www.java67.com/2017/08/difference-between-abstract-class-and-interface-in-java8.html
- https://javarevisited.blogspot.com/2014/07/default-defender-or-extension-method-of-Java8-example-tutorial.html
- https://javarevisited.blogspot.com/2015/01/how-to-use-lambda-expression-in-place-anonymous-class-java8.html
- https://www.java67.com/2021/01/spring-data-jpa-interview-questions-answers-java.html
- https://javarevisited.blogspot.com/2017/12/10-things-java-programmers-should-learn.html#axzz5atl0BngO
- https://javarevisited.blogspot.com/2021/02/spring-security-interview-questions-answers-java.html
- https://www.java67.com/2021/01/spring-cloud-interview-questions-with-answers-java.html
- https://www.java67.com/2021/02/microservices-interview-questions-answers-java-spring.html
- https://javarevisited.blogspot.com/2021/02/-spring-boot-testing-interview-questions-answers-java.html
- https://javarevisited.blogspot.com/2021/03/spring-aop-interview-questions-answers.html
- https://javarevisited.blogspot.com/2015/10/133-java-interview-questions-answers-from-last-5-years.html
- https://javarevisited.blogspot.com/2014/07/top-50-java-multithreading-interview-questions-answers.html
- https://javarevisited.blogspot.com/2021/03/top-dynamic-programming-problems-for-coding-interviews.html
- https://www.java67.com/2016/02/top-20-hibernate-interview-questions.html
- https://www.baeldung.com/java-collections-interview-questions
- https://www.baeldung.com/java-type-system-interview-questions
- https://www.baeldung.com/java-concurrency-interview-questions
- https://www.baeldung.com/java-classes-initialization-questions
- https://www.baeldung.com/java-memory-management-interview-questions
- https://www.baeldung.com/java-generics-interview-questions
- https://www.baeldung.com/java-flow-control-interview-questions
- https://www.baeldung.com/java-exceptions-interview-questions
- https://www.baeldung.com/java-annotations-interview-questions
- https://www.baeldung.com/spring-interview-questions
- https://medium.com/@wdn0612
- https://www.careermatch.com/job-prep/interviews/10-essential-java-interview-questions-and-answers/#:~:text=Tell%20me%20about%20yourself.,-This%20is%20typically&text=A%20sample%20answer%20could%20be,skilled%20at%20working%20in%20teams.
- https://www.simplilearn.com/java-8-interview-questions-and-answers-article
- https://www.interviewbit.com/java-8-interview-questions/
- https://www.interviewbit.com/spring-boot-interview-questions/
Implementations for ADTs
Look at the implementations for various topics in the following books: These books explain some very good concepts in a very good way.
- Algorithhms by Robert Sedgewick, Kevin Wayne
- ArrayResizing
- ReverseArrayIterator
- FixedCapacityStackOfStrings
- ResizingArrayStack
Data Abstraction & Problem Solving with C++
Here is the table of contents from Data Abstraction and Problem Solving with C++
- Link based implementations
- Recursion as a problem solving technique
- Stacks
- Stack implementations
- Lists
- List implementations
- Algorithm efficiency
- Sorting algorithms and their efficiency
- Sorted lists and their implementations
- Queues and priority queues
- Queue implementation
- Trees
- Tree implementations
- Heaps
- Dictionaries and their implementations
- Balanced Search Trees
- Graphs
Getting good at ADTs (abstract data types) will eventually get us ready for solving a lot of other problems like bracket balancing, etc. It will also lay a good foundation for trees and graphs.
Find an efficient implementation for generating a Fibonacci sequence - do not pay too much attention to the language - language doesn’t matter.
Top 75 Programming Interview Questions Answers to Crack Any Coding Job Interview
Hello guys, if you are preparing for your next Programming Job interview and looking for some frequently asked Coding or Programming questions to practice then you have come to the right place. In this article, I am going to share some of the most commonly asked Coding questions from Programming Job interviews (https://javarevisited.blogspot.com/2011/06/top-programming-interview-questions.html). In order to do well on the Coding interview you need practice, you just can’t go there and try to solve the coding problems in limited time, that’s actually one of the most common reasons to fail your programming Job interviews. Sometimes, the interviewer also asks a little bit easier coding questions on a telephonic interview like revering array in place (https://javarevisited.blogspot.com/2015/03/how-to-reverse-array-in-place-in-java.html#axzz5ajxLp4iD) or reversing a string in place (https://www.java67.com/2016/06/how-to-reverse-string-in-place-in-java.html).
Sometimes, when you hear these popular coding questions first time on the interview, you stumble because of nervousness and lack of preparation and that’s where knowledge of popular coding questions is important before going for any programming job interviews.
Most of the coding questions are based upon data structures (https://hackernoon.com/50-data-structure-and-algorithms-interview-questions-for-programmers-b4b1ac61f5b0) like an array, string, linked list, binary tree, etc, but sometimes you also get algorithmic, tricky, logical and scenario-based questions like how to swap two integers without using a temp variable or how to check if two rectangles overlap on each other or not.
That’s why I have divided this list of coding problems into five categories, I mean array-based coding questions, string-based questions, linked list questions, binary tree questions, and others miscellaneous questions, where you will find questions on bit manipulation, design (https://www.java67.com/2018/05/top-20-system-design-interview-questions-answers-programming.html), tricky, logical and other miscellaneous topics.
Btw, good knowledge of Data Structure and Algorithm is essential and even though you will learn a lot of new concepts by solving these questions, I suggest you first refresh your knowledge of Data Structure and Algorithm before attempting these questions by joining a comprehensive course like Data Structures and Algorithms: Deep Dive Using Java on Udemy.
There is no point in attempting these questions if you don’t have sufficient knowledge of data structure and Algorithms.
Top 50 Coding Interview Questions for Programmers
Here is my list of some of the most popular coding questions to crack any programming job interviews.
The questions are more like you find in the popular book Cracking the Coding Interview by Gayle Lakmann Mcdowell, one of the essential books to do well on a Job interview, but more focus on Data Structure and Coding rather than touching every single possible topic required for a programming job interview like SQL (https://www.java67.com/2013/04/10-frequently-asked-sql-query-interview-questions-answers-database.html), UNIX (https://www.java67.com/2012/09/10-linux-and-unix-interview-questions-answers-wipro-tcs-capegemini.html), Database (https://javarevisited.blogspot.com/2018/05/top-5-sql-and-database-courses-to-learn-online.html#axzz5h5DWdBCL), Networking (https://javarevisited.blogspot.com/2014/08/socket-programming-networking-interview-questions-answers-Java.html), etc, for that, you need to read books and you can find many good titles here (https://www.java67.com/2017/06/10-books-to-prepare-technical-coding-job-interviews.html).
We’ll start the list by first exploring array based questions e.g. finding pairs whose sum is given a number and then move to string-based questions, linked list based questions, binary tree questions, and finally tackler other topics.
1. Array-based Programming Interview Questions
If you ask me just one topic to prepare really well for coding interviews, I would pick the array. It’s one of the essential data structures and favorite darling of coding interviews. There are so many popular coding interview questions (https://javarevisited.blogspot.com/2015/02/50-programmer-phone-interview-questions-answers.html) that are based upon the array, some of them are easy and some are tough but you can be sure that you will see some questions based upon array in your next programming job interview.
If you don’t know, an array is a data structure that holds other objects like String, int, float, etc. It holds them in a contiguous location in memory which makes it easily searchable and retrieval in O(1) time using the index.
Insertion and deletion of an array are tough because you cannot change the size of an array once created and you need to create a new array and copy elements from old to new.
Anyway, here are some of the most popular array based coding interview questions for your preparation:
-
How to find the missing number in a given integer array of 1 to 100? (https://javarevisited.blogspot.com/2014/11/how-to-find-missing-number-on-integer-array-java.html)
-
How to find the duplicate number on a given integer array? (https://javarevisited.blogspot.com/2014/01/how-to-remove-duplicates-from-array-java-without-collection-API.html)
-
How to find the largest and smallest number in an unsorted integer array? (https://www.java67.com/2014/02/how-to-find-largest-and-smallest-number-array-in-java.html)
-
How to find all pairs of integer array whose sum is equal to a given number? (https://javarevisited.blogspot.com/2014/08/how-to-find-all-pairs-in-array-of-integers-whose-sum-equal-given-number-java.html)
-
How to find duplicate numbers in an array if it contains multiple duplicates? (https://javarevisited.blogspot.com/2014/03/3-ways-to-find-first-non-repeated-character-String-programming-problem.html)
-
How to remove duplicates from a given array in Java? (https://javarevisited.blogspot.com/2014/01/how-to-remove-duplicates-from-array-java-without-collection-API.html)
-
How to sort an integer array in place using QuickSort algorithm? (https://javarevisited.blogspot.com/2014/08/quicksort-sorting-algorithm-in-java-in-place-example.html)
-
How to remove duplicates from an array in place? (https://javarevisited.blogspot.com/2014/01/how-to-remove-duplicates-from-array-java-without-collection-API.html)
-
How to reverse an array in place in Java? (https://javarevisited.blogspot.com/2013/03/how-to-reverse-array-in-java-int-String-array-example.html)
-
How to find multiple missing numbers in given integer array with duplicates? (https://javarevisited.blogspot.com/2018/04/how-to-find-k-missing-numbers-in-array-java.html#axzz5E2uHdG3w)
I have linked to all the solution but you should try to solve them by yourself before looking at the solution, especially if you have time. That’s the only sure way to learn to program by solving these coding questions.
If you find these questions difficult to solve then once again I suggest you first refresh your knowledge of fundamental data structures like an array by going through a comprehensive course. If you need recommendations, Algorithms, and Data Structures Part 1 and Part 2 by Robert Horvick are two of the best course to start with (https://javarevisited.blogspot.com/2018/11/top-5-data-structures-and-algorithm-online-courses.html#axzz5YFaOvjsh). You will also learn about Big(O) notation and how to calculate time and space complexity.
Array based Programming Interview Questions Answers
If you think these 10 questions from the array are not enough and you are interested in solving more array-based programming problems then you can also check out these 30 array-based coding questions (https://javarevisited.blogspot.com/2015/06/top-20-array-interview-questions-and-answers.html) for more practice.
2. String-based Coding Interview Questions
After array, String is the next popular topic on Programming job interviews, but if you have a good understanding of array then you can easily deal with String programming questions (https://www.java67.com/2018/04/21-string-programming-and-coding-interview-questions-answers.html) because String is nothing but a character array.
The string is implemented differently in a different programming language like in C it’s a NULL-terminated character array but in Java, it’s an object. Though, you can still get access to the underlying array to apply your logic.
Here is a list of some of the frequently asked coding questions which are based on String. Though some of them are quite old, you can still expect this in your programming job interview:
-
How to Print duplicate characters from String? (https://www.java67.com/2014/03/how-to-find-duplicate-characters-in-String-Java-program.html)
-
How to print first non repeated character from String? (https://javarevisited.blogspot.com/2014/03/3-ways-to-find-first-non-repeated-character-String-programming-problem.html)
-
How to reverse a given String using recursion? (https://javarevisited.blogspot.com/2012/01/how-to-reverse-string-in-java-using.html)
-
How to check if a String contains only digits? (https://javarevisited.blogspot.com/2012/10/regular-expression-example-in-java-to-check-String-number.html)
-
How to find duplicate characters in a String? (https://www.java67.com/2014/03/how-to-find-duplicate-characters-in-String-Java-program.html)
-
How to count a number of vowels and consonants in a given String? (https://www.java67.com/2013/11/how-to-count-vowels-and-consonants-in-Java-String-word.html)
-
How to count the occurrence of a given character in String? (https://javarevisited.blogspot.com/2012/12/how-to-count-occurrence-of-character-in-String.html)
-
How to find all permutations of String? (https://javarevisited.blogspot.com/2015/08/how-to-find-all-permutations-of-string-java-example.html)
-
How to reverse words in a given sentence without using any library method? (https://www.java67.com/2015/06/how-to-reverse-words-in-string-java.html)
-
How to check if two String is a rotation of each other? (https://www.java67.com/2017/07/string-rotation-in-java-write-program.html)
-
How to check if given String is Palindrome? (https://www.java67.com/2015/06/how-to-check-is-string-is-palindrome-in.html)
If you want to get most of this article, you better solve these questions without looking at the answers. Only when you stuck and running out-of-time, you can look at the solution.
And, if you find these frequently asked String problems difficult to solve, maybe it’s time to go back to the drawing board and learn the fundamentals of String data structure again. If you need resources then Data Structures and Algorithms Specialization on Coursera is one of the best online resources you can use to make your foundations rock solid.
You can also learn from it by comparing your solution with the solution I have given. It’s not necessarily to be the same but you can learn a lot by comparing them and if you need more practice, here is another list of 20 String algorithm questions (https://javarevisited.blogspot.com/2015/01/top-20-string-coding-interview-question-programming-interview.html).
3. Linked list based Programming Interview Questions
Along with array and string, a linked list is another popular data structure in the programming world as well as on coding interviews. You will find a lot of questions on a linked list like reversing a linked list (https://javarevisited.blogspot.com/2017/03/how-to-reverse-linked-list-in-java-using-iteration-and-recursion.html), adding a new element, removing an element from the middle, etc.
It’s also the counterpart of an array data structure. While array stores elements on contiguous memory location, the linked list stored them at different locations and find them by storing there address. a linked list is made of nodes, an internal data structure which holds the value as well as the address of the next node.
Because of its structure, it’s easier to add and remove elements from the linked list (https://www.java67.com/2016/01/how-to-implement-singly-linked-list-in-java-using-generics-example.html) like on O(1) time if you are adding or removing from the head but the search is equally difficult and takes O(n) time, as you have to literally walk through each element.
Anyway, here is a collection of some of the simple and tricky linked list based coding question for your practice:
-
How to find the middle element of a singly linked list in one pass? (javarevisited.blogspot.sg/2012/12/how-to-find-middle-element-of-linked-list-one-pass.html)
-
How to check if a given linked list contains a cycle? How to find the starting node of the cycle? (https://javarevisited.blogspot.com/2013/05/find-if-linked-list-contains-loops-cycle-cyclic-circular-check.html)
-
How to reverse a linked list? (https://www.java67.com/2016/07/how-to-reverse-singly-linked-list-in-java-example.html)
-
How to reverse a singly linked list without recursion? (https://javarevisited.blogspot.com/2017/03/how-to-reverse-linked-list-in-java-using-iteration-and-recursion.html)
-
How to remove duplicate nodes in an unsorted linked list? (??)
-
How to find the length of a singly linked list? (https://javarevisited.blogspot.com/2016/05/how-do-you-find-length-of-singly-linked.html)
-
How to find the 3rd node from the end in a singly linked list? (https://javarevisited.blogspot.com/2016/07/how-to-find-3rd-element-from-end-in-linked-list-java.html)
-
How do you find the sum of two linked lists using Stack? (https://javarevisited.blogspot.com/2017/07/top-50-java-programs-from-coding-Interviews.html)
You should only look them once you solved the problem on your own or you feel stuck.
A key to solving the linked list is a good understanding of recursion because a linked list is a naturally recursive data structure, for example, if you take one node out of the linked list, the result is another linked list, but many programmers struggle to understand recursion.
That was the case with me as well but after practice and visualizing how recursion really works, I overcome that deficiency. If you are on the same boat, I strongly suggest you go through a visual course like Visualizing Data Structures and Algorithms in Java to learn Recursion and data structure. That will help you a lot in your thought process and problem-solving skills.
Top 75 Programming Interview Questions and Solutions
Once you understand recursion, most of the linked list based problems have an easy recursive solution than their iterative version. And if you need more practice, here is another list of 30 linked list programming questions (https://javarevisited.blogspot.com/2017/07/top-10-linked-list-coding-questions-and.html) for your reference.
4. Binary Tree based Coding Interview Questions
A tree is another popular data structure in the programming world and coding interviews. Unlike array (https://javarevisited.blogspot.com/2016/02/6-example-to-declare-two-dimensional-array-in-java.html) and linked list (https://javarevisited.blogspot.com/2013/07/difference-between-array-and-linked-list-java.html), which are considered linear data structure, a tree is considered a hierarchical data structure and used to arrange information in hierarchical order.
There are a lot of different types of tree e.g. a binary tree, binary search tree, AVL tree, Red-Black tree, etc but Binary and Binary search trees are also known as BST are two of most popular ones and most of the question are based upon them.
Some questions are also based upon theoretical knowledge of tree data structure e.g. finding the height of the tree, finding leaf nodes, checking if the tree is balanced or not, etc, hence you should also spend some time learning the basics, along with practicing coding questions.
Anyway, here is a list of a popular binary tree and binary search tree based coding question to practice before your job interview:
-
Can you write a program to implement a binary search tree? (https://javarevisited.blogspot.com/2015/10/how-to-implement-binary-search-tree-in-java-example.html#axzz4wnEtnNB3)
-
How do you perform Pre-order traversal in a given binary tree? (https://javarevisited.blogspot.com/2016/07/binary-tree-preorder-traversal-in-java-using-recursion-iteration-example.html#axzz5ArdIFI7y)
-
Write a Program to traverse a given binary tree in Pre-order without recursion (https://www.java67.com/2016/07/binary-tree-preorder-traversal-in-java-without-recursion.html)
-
How to perform an In order traversal in a given binary tree? (https://www.java67.com/2016/08/binary-tree-inorder-traversal-in-java.html)
-
How to print all nodes of given binary tree using inorder traversal without recursion (https://www.java67.com/2016/08/binary-tree-inorder-traversal-in-java.html)
-
How to implement a Post-order traversal algorithm? (https://www.java67.com/2016/10/binary-tree-post-order-traversal-in.html)
-
How to traverse a binary tree in Postorder traversal without recursion (https://www.java67.com/2017/05/binary-tree-post-order-traversal-in-java-without-recursion.html)
-
How to Print all leaves of a binary search tree? (https://www.java67.com/2016/09/how-to-print-all-leaf-nodes-of-binary-tree-in-java.html)
-
How to count a number of leaf nodes in a given binary tree? (https://javarevisited.blogspot.com/2016/12/how-to-count-number-of-leaf-nodes-in-java-recursive-iterative-algorithm.html)
-
How to perform a binary search in a given array? (https://javarevisited.blogspot.com/2015/10/how-to-implement-binary-search-tree-in-java-example.html#axzz4wnEtnNB3)
Like an array, linked list, and string questions, I have also linked to all solutions for binary tree questions but you should only look them once you have tried it yourself.
One trick I would like to share with you while solving tree questions is to remember that, similar to a linked list, the tree is also a recursive data structure and most of the tree based problems has an easy recursive solution.
For example, a subtree is also a tree which means you can apply the same steps to subtree can devise a recursive solution. In the above list, many popular tree algorithms e.g. pre-order, post-order, in-order are implemented recursively as well as iterative.
If you don’t feel confident to solve these problems and want to refresh your knowledge of binary tree and other data structure before attempting these questions, then you should check out Data Structures and Algorithms: Deep Dive Using Java from Udemy.
Top 75 Essential Programming Interview Questions to Crack Any Coding Interview
- Miscellaneous Programming Interview Questions
Even though data structure-based questions make the bulk of the Coding Interview, there are always some questions from topics like sorting algorithms, bit manipulation, software design (https://www.java67.com/2016/07/top-5-object-oriented-design-interview-questions.html), Dynamic Programming (https://www.freecodecamp.org/news/these-are-the-best-free-courses-to-learn-data-structures-and-algorithms-in-depth-4d52f0d6b35a/), and other logical and tricky questions.
In this list below, you will find most of the common searching and sort questions as well as a couple of design and bit manipulation questions.
-
How to implement the Bubble Sort algorithm? (https://javarevisited.blogspot.com/2014/08/bubble-sort-algorithm-in-java-with.html#axzz5ArdIFI7y)
-
How to implement Iterative QuickSort Algorithm? (https://javarevisited.blogspot.com/2016/09/iterative-quicksort-example-in-java-without-recursion.html#axzz5ArdIFI7y)
-
How to implement the Insertion Sort Algorithm? (https://www.java67.com/2014/09/insertion-sort-in-java-with-example.html)
-
How to implement Merge Sort Algorithm? (https://www.java67.com/2018/03/mergesort-in-java-algorithm-example-and.html)
-
How to implement the Bucket Sort Algorithm? (https://javarevisited.blogspot.com/2017/01/bucket-sort-in-java-with-example.html)
-
How to implement the Counting Sort Algorithm? (https://www.java67.com/2017/06/counting-sort-in-java-example.html)
-
How to implement Radix Sort Algorithm? (https://www.java67.com/2018/03/how-to-implement-radix-sort-in-java.html)
-
How to swap two numbers without using the third variable? See SwapIntegersWithoutUsingATempVariable.java
-
How to check if two rectangles overlap with each other? (https://javarevisited.blogspot.com/2016/10/how-to-check-if-two-rectangle-overlap-in-java-algorithm.html)
-
How to check if a given number is a Palindrome? See IntegerPalindrome.java (http://javarevisited.blogspot.sg/2012/12/how-to-check-if-number-is-palindrome-or-not-example.html)
-
How do you check if a given number is an Armstrong number? (https://www.java67.com/2012/07/java-program-to-find-armstrong-numbers.html)
-
How do you find all prime factors of a given number? (https://javarevisited.blogspot.com/2014/05/how-to-find-prime-factors-of-integer-number-java.html#axzz5E2uHdG3w)
-
How do you check if a given number is positive or negative in Java? (https://javarevisited.blogspot.com/2013/01/how-to-check-if-number-is-positive-or-negative-java-example.html#axzz5E2uHdG3w)
-
How to find the largest prime factor of a given integral number? (https://javarevisited.blogspot.com/2015/03/how-to-find-largest-prime-factor-of.html#axzz5E2uHdG3w)
-
Write a Program to print all prime numbers up to a given number? (https://javarevisited.blogspot.com/2012/04/java-program-to-print-prime-numbers-in.html#axzz5E2uHdG3w)
-
Write a Program to print Floyd’s triangle? (https://javarevisited.blogspot.com/2014/12/how-to-print-floyds-triangle-in-java.html)
-
Write a Program to print Pascal’s triangle? (https://www.java67.com/2016/06/how-to-print-pascal-triangle-in-java.html)
-
How to calculate the square root of a given number? (https://javarevisited.blogspot.com/2016/10/how-to-find-square-root-of-number-in-java-algorithm.html#axzz5E2uHdG3w)
-
How to check if the given number is a prime number? (https://www.java67.com/2014/01/how-to-check-if-given-number-is-prime.html)
-
How to implement the Sieve of Eratosthenes Algorithm? (https://javarevisited.blogspot.com/2015/05/sieve-of-Eratosthenes-algorithm-to-generate-prime-numbers-in-java.html)
-
How to add two numbers without using the plus operator in Java? (https://javarevisited.blogspot.com/2013/06/how-to-add-two-integer-numbers-without-plus-arithmetic-operator-java-example.html)
-
Write a Program to subtract two binary numbers? (https://www.java67.com/2018/03/java-program-to-subtract-two-binary-numbers.html)
-
Write a Program to transpose a Matrix? (https://www.java67.com/2016/10/how-to-transpose-matrix-in-java-example.html)
-
Write a Program to add or subtract two Matrices? (https://www.java67.com/2016/10/how-to-add-and-subtract-two-matrices-in-java.html)
-
Write a Program to multiply two Matrices in Java? (https://www.java67.com/2016/10/how-to-multiply-two-matrices-in-java.html)
-
How to calculate the average of all numbers in a given array? (https://www.java67.com/2016/10/how-to-calculate-average-of-all-numbers-in-given-array-java.html)
-
How to check if a given number is even/odd without using an Arithmetic operator? (https://www.java67.com/2012/07/how-to-find-even-and-odd-number-in-java-program.html)
-
Write a Program to find GCD of two numbers using Euclid’s Algorithm? (https://www.java67.com/2012/08/java-program-to-find-gcd-of-two-numbers.html)
-
How to find the number of 1s (the Set bit) in a given Bit Sequence? (https://www.java67.com/2016/01/how-to-count-number-of-1s-in-given-bit-sequence-in-java.html)
-
Write a Program to given Pyramid structure? (https://www.java67.com/2015/10/how-to-print-pyramid-pattern-in-java-example.html)
-
How to find the highest repeating world from a given file in Java? (https://www.java67.com/2015/10/java-program-to-find-repeated-words-and-count.html)
-
How to reverse given Integer in Java? (https://www.java67.com/2015/08/how-to-reverse-integer-in-java-leetcode-solution.html)
-
How to convert a decimal number to binary in Java? (https://www.java67.com/2014/03/decimal-to-binary-conversion-in-java.html)
-
How to check if a given year is a leap year in Java? (https://www.java67.com/2012/12/how-to-check-leap-year-in-java-program.html)
Like previous topics, I have provided links to a solution but you should only look them once you tried to solve the questions yourself. That’s important for learning.
That’s all about some of the essential Programming and Coding Interview questions to crack any programming Job interviews. This list covers the most important topics like an array, string, linked list, binary tree, and several others.
Once you have gone through all these coding questions, you can not only solve them when you see them in the interview but also develop the coding sense and problem-solving ability which will help you to solve new and slightly modified versions of these questions on real programming interview.
AnonymousJuly 26, 2020 at 1:22 AM
This is a great list of problems, but I believe readers should look elsewhere for correct solutions. I haven’t opened all of them, but some of them (e.g. “remove duplicate chars from string”, “find square root of a number”) have some pretty bizarre solutions.
100+ Coding Interview Questions for Programmers
-
How is a bubble sort algorithm implemented? (http://javarevisited.blogspot.sg/2014/08/bubble-sort-algorithm-in-java-with.html#axzz5ArdIFI7y)
-
How is a merge sort algorithm implemented? (http://www.java67.com/2018/03/mergesort-in-java-algorithm-example-and.html)
-
How do you count the occurrence of a given character in a string? (http://javarevisited.blogspot.sg/2012/12/how-to-count-occurrence-of-character-in-String.html)
-
How do you print the first non-repeated character from a string? (http://javarevisited.blogspot.sg/2014/03/3-ways-to-find-first-non-repeated-character-String-programming-problem.html)
-
How do you convert a given String into int like the atoi()? (https://javarevisited.blogspot.com/2011/08/convert-string-to-integer-to-string.html)
-
How do you implement a bucket sort algorithm? (http://javarevisited.blogspot.sg/2017/01/bucket-sort-in-java-with-example.html)
-
How do you implement a counting sort algorithm? (http://www.java67.com/2017/06/counting-sort-in-java-example.html)
-
How do you remove duplicates from an array in place? (http://javarevisited.blogspot.com/2014/01/how-to-remove-duplicates-from-array-java-without-collection-API.html)
-
How do you reverse an array in place in Java? (http://javarevisited.blogspot.com/2013/03/how-to-reverse-array-in-java-int-String-array-example.html)
-
How are duplicates removed from an array without using any library? (http://javarevisited.blogspot.sg/2014/01/how-to-remove-duplicates-from-array-java-without-collection-API.html)
-
How is a radix sort algorithm implemented? (http://www.java67.com/2018/03/how-to-implement-radix-sort-in-java.html)
-
How do you swap two numbers without using the third variable? See SwapIntegersWithoutUsingATempVariable.java
-
How do you check if two rectangles overlap with each other? (http://javarevisited.blogspot.sg/2016/10/how-to-check-if-two-rectangle-overlap-in-java-algorithm.html)
-
How do you find the missing number in a given integer array of 1 to 100? (http://javarevisited.blogspot.com/2014/11/how-to-find-missing-number-on-integer-array-java.html)
-
How do you find the duplicate number on a given integer array? (http://javarevisited.blogspot.com/2014/01/how-to-remove-duplicates-from-array-java-without-collection-API.html)
-
How do you find duplicate numbers in an array if it contains multiple duplicates? (http://javarevisited.blogspot.com/2014/03/3-ways-to-find-first-non-repeated-character-String-programming-problem.html)
-
Difference between a stable and unstable sorting algorithm? (https://javarevisited.blogspot.com/2017/06/difference-between-stable-and-unstable-algorithm.html)
-
How is an iterative quicksort algorithm implemented? (http://javarevisited.blogspot.sg/2016/09/iterative-quicksort-example-in-java-without-recursion.html#axzz5ArdIFI7y)
-
How do you find the largest and smallest number in an unsorted integer array? (http://java67.blogspot.com/2014/02/how-to-find-largest-and-smallest-number-array-in-java.html)
-
How do you find all pairs of an integer array whose sum is equal to a given number? (http://javarevisited.blogspot.com/2014/08/how-to-find-all-pairs-in-array-of-integers-whose-sum-equal-given-number-java.html)
-
How do you implement an insertion sort algorithm? (http://www.java67.com/2014/09/insertion-sort-in-java-with-example.html)
-
How are duplicates removed from a given array in Java? (http://javarevisited.blogspot.com/2014/01/how-to-remove-duplicates-from-array-java-without-collection-API.html)
-
how to remove the duplicate character from String? (https://javarevisited.blogspot.com/2016/06/how-to-remove-duplicate-characters-from-String-Java.html)
-
How to find the maximum occurring character in given String? (http://javarevisited.blogspot.com/2012/12/how-to-count-occurrence-of-character-in-String.html)
-
How is an integer array sorted in place using the quicksort algorithm? (http://javarevisited.blogspot.com/2014/08/quicksort-sorting-algorithm-in-java-in-place-example.html)
-
How do you reverse a given string in place? (http://www.java67.com/2016/06/how-to-reverse-string-in-place-in-java.html)
-
How do you print duplicate characters from a string? (http://java67.blogspot.sg/2014/03/how-to-find-duplicate-characters-in-String-Java-program.html)
-
How do you find all the permutations of a string? (http://javarevisited.blogspot.com/2015/08/how-to-find-all-permutations-of-string-java-example.html)
-
How can a given string be reversed using recursion? (http://javarevisited.blogspot.sg/2012/01/how-to-reverse-string-in-java-using.html)
-
How do you check if a given string is a palindrome? (http://java67.blogspot.com/2015/06/how-to-check-is-string-is-palindrome-in.html)
-
How do you find the length of the longest substring without repeating characters?
-
How do you find the longest palindromic substring in str?
-
How do you check if a string contains only digits? (http://javarevisited.blogspot.sg/2012/10/regular-expression-example-in-java-to-check-String-number.html)
-
How to convert a sorted list to a binary search tree? (https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/solution/)
-
How do you find duplicate characters in a given string? (http://java67.blogspot.sg/2014/03/how-to-find-duplicate-characters-in-String-Java-program.html)
-
How do you count a number of vowels and consonants in a given string? (http://java67.blogspot.sg/2013/11/how-to-count-vowels-and-consonants-in-Java-String-word.html)
-
How do you reverse words in a given sentence without using any library method? (http://java67.blogspot.com/2015/06/how-to-reverse-words-in-string-java.html)
-
How do you check if two strings are a rotation of each other? (http://www.java67.com/2017/07/string-rotation-in-java-write-program.html)
-
How to convert a byte array to String? (https://javarevisited.blogspot.com/2014/08/2-examples-to-convert-byte-array-to-String-in-Java.html)
-
How do you remove a given character from String? (http://java67.blogspot.com/2013/03/how-to-replace-string-in-java-character-example.html)
-
How is a binary search tree implemented? (http://javarevisited.blogspot.sg/2015/10/how-to-implement-binary-search-tree-in-java-example.html#axzz4wnEtnNB3)
-
How do you perform preorder traversal in a given binary tree? (http://javarevisited.blogspot.sg/2016/07/binary-tree-preorder-traversal-in-java-using-recursion-iteration-example.html#axzz5ArdIFI7y)
-
How do you traverse a given binary tree in preorder without recursion? (http://www.java67.com/2016/07/binary-tree-preorder-traversal-in-java-without-recursion.html)
-
How do you perform an inorder traversal in a given binary tree? (http://www.java67.com/2016/08/binary-tree-inorder-traversal-in-java.html)
-
How do you print all nodes of a given binary tree using inorder traversal without recursion? (http://www.java67.com/2016/08/binary-tree-inorder-traversal-in-java.html)
-
How do you implement a postorder traversal algorithm? (http://www.java67.com/2016/10/binary-tree-post-order-traversal-in.html)
-
How do you traverse a binary tree in postorder traversal without recursion? (http://www.java67.com/2017/05/binary-tree-post-order-traversal-in-java-without-recursion.html)
-
How are all leaves of a binary search tree printed? (http://www.java67.com/2016/09/how-to-print-all-leaf-nodes-of-binary-tree-in-java.html)
-
How do you count a number of leaf nodes in a given binary tree? (http://javarevisited.blogspot.sg/2016/12/how-to-count-number-of-leaf-nodes-in-java-recursive-iterative-algorithm.html)
-
How do you perform a binary search in a given array? (http://javarevisited.blogspot.sg/2015/10/how-to-implement-binary-search-tree-in-java-example.html#axzz4wnEtnNB3)
-
How to Swap two numbers without using the third variable? (http://www.java67.com/2015/08/how-to-swap-two-integers-without-using.html)
-
How to check if two rectangles overlap with each other? (http://javarevisited.blogspot.sg/2016/10/how-to-check-if-two-rectangle-overlap-in-java-algorithm.html)
-
How to check if a given number is a Palindrome? (http://javarevisited.blogspot.sg/2012/12/how-to-check-if-number-is-palindrome-or-not-example.html)
-
How to check if a given number is an Armstrong number? (http://www.java67.com/2012/07/java-program-to-find-armstrong-numbers.html)
-
How to find all prime factors of a given number? (http://javarevisited.blogspot.com/2014/05/how-to-find-prime-factors-of-integer-number-java.html#axzz5E2uHdG3w)
-
How to check if a given number is positive or negative in Java? (http://javarevisited.blogspot.sg/2013/01/how-to-check-if-number-is-positive-or-negative-java-example.html#axzz5E2uHdG3w)
-
How to find the largest prime factor of a given integral number? (http://javarevisited.blogspot.sg/2015/03/how-to-find-largest-prime-factor-of.html#axzz5E2uHdG3w)
-
How to print all prime numbers up to a given number? (http://javarevisited.blogspot.sg/2012/04/java-program-to-print-prime-numbers-in.html#axzz5E2uHdG3w)
-
How to print Floyd’s triangle? (http://javarevisited.blogspot.sg/2014/12/how-to-print-floyds-triangle-in-java.html)
-
How to print Pascal’s triangle? (http://www.java67.com/2016/06/how-to-print-pascal-triangle-in-java.html)
-
How to calculate the square root of a given number? (http://javarevisited.blogspot.sg/2016/10/how-to-find-square-root-of-number-in-java-algorithm.html#axzz5E2uHdG3w)
-
How to check if the given number is a prime number? (http://www.java67.com/2014/01/how-to-check-if-given-number-is-prime.html)
-
How to add two numbers without using the plus operator in Java? (http://javarevisited.blogspot.sg/2013/06/how-to-add-two-integer-numbers-without-plus-arithmetic-operator-java-example.html)
-
How to check if a given number is even/odd without using Arithmetic operator? (http://www.java67.com/2012/07/how-to-find-even-and-odd-number-in-java-program.html)
-
How to print a given Pyramid structure? (http://www.java67.com/2015/10/how-to-print-pyramid-pattern-in-java-example.html)
-
How to find the highest repeating world from a given file in Java? (http://www.java67.com/2015/10/java-program-to-find-repeated-words-and-count.html)
-
How to reverse given Integer in Java? (http://www.java67.com/2015/08/how-to-reverse-integer-in-java-leetcode-solution.html)
-
How to convert a decimal number to binary in Java? (http://www.java67.com/2014/03/decimal-to-binary-conversion-in-java.html)
-
How to check if a given year is a leap year in Java? (http://www.java67.com/2012/12/how-to-check-leap-year-in-java-program.html)
-
Can you implement a Binary search Algorithm without recursion? (https://javarevisited.blogspot.com/2018/06/binary-search-in-java-without-recursion.html)
-
Difference between a stable and unstable sorting algorithm? (https://javarevisited.blogspot.com/2017/06/difference-between-stable-and-unstable-algorithm.html)
-
What is Depth First Search Algorithm for a binary tree?
-
How is an iterative quicksort algorithm implemented? (http://javarevisited.blogspot.sg/2016/09/iterative-quicksort-example-in-java-without-recursion.html#axzz5ArdIFI7y)
-
How do you implement an insertion sort algorithm? (http://www.java67.com/2014/09/insertion-sort-in-java-with-example.html)
-
How is a merge sort algorithm implemented? (http://www.java67.com/2018/03/mergesort-in-java-algorithm-example-and.html)
-
What is the difference between Comparison and Non-Comparison Sorting Algorithms? (https://javarevisited.blogspot.com/2017/02/difference-between-comparison-quicksort-and-non-comparison-counting-sort-algorithms.html)
-
How do implement Sieve of Eratosthenes Algorithms for Prime Number? (https://javarevisited.blogspot.com/2015/05/sieve-of-Eratosthenes-algorithm-to-generate-prime-numbers-in-java.html)
https://www.geeksforgeeks.org/must-coding-questions-company-wise/?ref=leftbar-rightbar
https://www.geeksforgeeks.org/practice-for-cracking-any-coding-interview/?ref=leftbar-rightbar
Link based implementations - mathematical induction
Try to go with topic in geeks for geeks instead of picking problems from all over the place and many websites at random.
- // Self-Balancing Binary Search Tree
- https://www.geeksforgeeks.org/sliding-window-maximum-maximum-of-all-subarrays-of-size-k/
- https://www.geeksforgeeks.org/sum-of-all-subsequences-of-length-k/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/minimum-group-flips-to-make-binary-array-elements-same/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/longest-sub-array-with-maximum-gcd/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/check-if-an-array-is-sorted-and-rotated-using-binary-search/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/split-the-given-string-into-primes-digit-dp/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/efficiently-merging-two-sorted-arrays-with-o1-extra-space-and-onlogn-mlogm/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/minimum-number-of-swaps-required-to-sort-an-array-of-first-n-number/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/minimize-the-maximum-difference-between-adjacent-elements-in-an-array/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/calculate-the-sum-of-gcd-over-all-subarrays/?ref=leftbar-rightbar
- https://www.geeksforgeeks.org/egg-dropping-puzzle-dp-11/
- https://www.geeksforgeeks.org/eggs-dropping-puzzle-binomial-coefficient-and-binary-search-solution/
- https://www.geeksforgeeks.org/program-print-array-pendulum-arrangement/
- geeksforgeeks - Towers of Hanoi concept
- geeksforgeeks - Tree traversals.
http://www-igm.univ-mlv.fr/~lecroq/string/ - EXACT STRING MATCHING ALGORITHMS
Write your own logic for MooshakCatchingCheese.java
Practice:
- Write a small Java application that uses the String class to input one word at a time and
outputs a complete sentence when a terminating punctuation mark is entered.
- Write an application similar to the one in exercise 1, but output the words in the sentence in
reverse order.
- Write the same application using a single StringBuffer object passed to the input
method to collect the words in the sentence.
- Write a class MutableInteger similar to the Java core class Integer but with the
capability to change the value of the integer. (The Integer class, like the String class, is immutable after it is initialized.)
- https://algorithms.tutorialhorizon.com/
- https://algorithms.tutorialhorizon.com/reverse-a-stack-using-recursion-in-place-without-using-extra-memory/
- https://algorithms.tutorialhorizon.com/sort-a-given-stack-using-temporary-stack/
- https://algorithms.tutorialhorizon.com/sort-a-given-stack-using-recursion/
- https://algorithms.tutorialhorizon.com/depth-first-search-dfs-in-2d-matrix-2d-array-iterative-solution/
- https://algorithms.tutorialhorizon.com/depth-first-search-dfs-in-2d-matrix-2d-array-recursive-solution/
- https://algorithms.tutorialhorizon.com/smallest-number-after-removing-k-digits/
- https://algorithms.tutorialhorizon.com/topological-sort/
- https://algorithms.tutorialhorizon.com/valid-brackets-part-2-stack-method/
- https://algorithms.tutorialhorizon.com/convert-prefix-to-infix-expression/
- https://algorithms.tutorialhorizon.com/convert-infix-to-postfix-expression/
- https://algorithms.tutorialhorizon.com/valid-multiple-parentheses/
Data Structures for Coding Interviews in Java
-
Complexity Measures
- Comparing Algorithms
- Example 1: Measuring Time Complexity of a Single Loop Algorithm
- Example 2: Time Complexity of an Algorithm With Nested Loops
- Introduction to Asymptotic Analysis and Big O
- Other Common Asymptotic Notations and Why Big O Trumps Them
- Useful Formulae
- Common Complexity Scenarios
- Challenge 1: Big (O) of Nested Loop with Addition
- Solution Review: Big O of a Nested Loop with Addition
- Challenge 2: Big (O) of Nested Loop with Subtraction
- Solution Review: Big O of a Nested Loop with Subtraction
- Challenge 3: Big O of Nested Loop with Multiplication
- Solution Review: Big O of Nested Loop with Multiplication
- Challenge 4: Nested Loop with Multiplication (Basic)
- Solution Review: Nested Loop with Multiplication (Basic)
- Challenge 5: Nested Loop with Multiplication (Intermediate)
- Solution Review: Nested Loop with Multiplication (Intermediate)
- Challenge 6: Nested Loop with Multiplication (Advanced)
- Solution Review: Nested Loop with Multiplication (Advanced)
- Challenge 7: Nested Loop with Multiplication (Pro)
- Solution Review: Nested Loop with Multiplication (Pro)
- Complexity Interview Questions
-
Arrays
- What is an Array?
- Two Dimensional Arrays
- Challenge 1: Remove Even Integers from an Array
- Solution Review: Remove Even Integers from an Array
- Challenge 2: Merge Two Sorted Arrays
- Solution Review: Merge Two Sorted Arrays
- Challenge 3: Find Two Numbers that Add up to “n”
- Solution Review: Find Two Numbers that Add up to “n”
- Challenge 4: Array of Products of All Elements Except Itself
- Solution Review: Array of Products of All Elements Except Itself
- Challenge 5: Find Minimum Value in Array
- Solution Review: Find Minimum Value in an Array
- Challenge 6: First Non-Repeating Integer in an Array
- Solution Review: First Non-Repeating Integer in an Array
- Challenge 7: Find Second Maximum Value in an Array
- Solution Review: Find Second Maximum Value in an Array
- Challenge 8: Right Rotate the Array by One Index
- Solution Review: Right Rotate the Array by One Index
- Challenge 9: Re-arrange Positive & Negative Values
- Solution Review: Re-arrange Positive & Negative Values
- Challenge 10: Rearrange Sorted Array in Max/Min Form
- Solution Review: Re-arrange Sorted Array in Max/Min Form
- Array Interview Questions
-
Linked Lists
- What is the Singly Linked List (SLL)?
- Basic Linked List Operations
- Insertion in a Singly Linked List
- Challenge 1: Insertion in a Singly Linked List (insert at End)
- Solution Review: Insertion in a Singly Linked List(insert at End)
- Insertion in Singly Linked List (Insert After)
- Challenge 2: Search in Singly Linked List
- Solution Review: Search in a Singly Linked List
- Singly Linked List Deletion (Implementation)
- Challenge 3: Deletion in Singly Linked List(Delete by Value)
- Solution Review: Deletion in Singly Linked List
- Linked Lists vs. Arrays
- What is a Doubly Linked List (DLL)?
- Linked List with Tail
- Challenge 4: Find the Length of a Linked List
- Solution Review: Find the Length of a Linked List
- Challenge 5: Reverse a Linked List
- Solution Review: Reverse a Linked List
- Challenge 6: Detect Loop in a Linked List
- Solution Review: Detect Loop in a Linked List
- Challenge 7: Find the Middle Value of a Linked List
- Solution Review: Find the Middle Value of a Linked List
- Challenge 8: Remove Duplicates from a Linked List
- Solution Review: Remove Duplicate from a Linked List
- Challenge 9: Union & Intersection of Lists
- Solution Review: Union & Intersection of Lists
- Challenge 10: Return the Nth node from End
- Solution Review: Return the Nth node from End
- Challenge 11: Find if Doubly Linked-list is a Palindrome
- Solution: Find if a Doubly Linked-list is a Palindrome
- Linked list Interview Questions
-
Stack/Queues
- What is a Stack?
- Stack (Implementation)
- What is a Queue?
- Queue (Implementation)
- Challenge 1: Generate Binary Numbers from 1 to n using a Queue
- Solution Review: Generate Binary Numbers from 1 to n using Queue
- Challenge 2: Implement Two Stacks using one Array
- Solution Review: Implement Two Stacks using one Array
- Challenge 3: Reversing the First k Elements of a Queue
- Solution Review: Reversing the First k Elements of a Queue
- Challenge 4: Implement Queue using Stack
- Solution Review: Implement Queue using Stack
- Challenge 5: Sort the Values in a Stack
- Solution Review: Sort the Values in a Stack
- Challenge 6: Evaluate Postfix Expressions using Stacks
- Solution Review: Evaluate Postfix Expressions using Stacks
- Challenge 7: Next Greater Element using Stack
- Solution Review: Next Greater Element using Stack
- Challenge 8: Solve a Celebrity Problem using a Stack
- Solution Review: Solve a Celebrity Problem using a Stack
- Challenge 9: Check for Balanced Parentheses using a Stack
- Solution Review: Check for Balanced Parentheses using a Stack
- Challenge 10: Create Stack where min() gives minimum in O(1)
- Solution Review: Create Stack where min() gives minimum in O(1)
- Stack/Queue Interview Questions
-
Graphs
- What is a Graph?
- Representation of Graphs
- Graph Implementation
- Complexities of Graph Operations
- What is a Bipartite Graph?
- Graph Traversal Algorithms
- Challenge 1: Implement Breadth First Search
- Solution Review: Implement Breadth First Search
- Challenge 2: Implement Depth First Search
- Solution Review: Implement Depth First Search
- Challenge 3: Cycle Detection in a Directed Graph
- Solution Review: Cycle Detection in a Directed Graph
- Challenge 4: Find “Mother Vertex” in a Directed Graph
- Solution Review: Find “Mother Vertex” in a Directed Graph
- Challenge 5: Count the Number of Edges in an Undirected Graph
- Solution Review: Count the number of Edges in an Undirected Graph
- Challenge 6: Check if a Path Exists Between Two Vertices
- Solution Review: Check if a Path Exists Between Two Vertices
- Challenge 7: Check if a Directed Graph is Tree or not
- Solution Review: Check if a Directed Graph is Tree or not
- Challenge 8: Find Length of Shortest Path between Two Vertices
- Solution Review: Find the Shortest Path between Two Vertices
- Challenge 9: Remove Edge from a Directed Graph
- Solution Review: Remove Edge from a Directed Graph
- Graph Interview Questions
-
Trees
- What is a Tree?
- Types of Trees
- What Makes a Tree Balanced?
- What is a Binary Tree?
- More on Complete Binary Trees
- Skewed Binary Tree
- What is a Binary Search Tree (BST)?
- Insertion in Binary Search Trees
- Insertion in BST (Complete Implementation)
- Search in Binary Search Trees (Implementation)
- Deletion in Binary Search Trees
- Deletion in Binary Search Trees (Implementation)
- Pre-Order Traversal in Binary Search Trees
- In-Order Traversal in Binary Search Trees
- Post-Order Traversal in Binary Search Tree
- What is an AVL Tree?
- AVL Insertion
- AVL Deletion
- What is a Red-Black Tree?
- Red-Black Tree Insertion
- Red-Black Tree Deletion
- What is a 2-3 Tree?
- 2-3 Insertion
- 2-3 Deletion (Case #1)
- 2-3 Deletion (Case #2)
- 2-3-4 Trees
- Overview of Trees
- Challenge 1: Find the Minimum Value in a Binary Search Tree
- Solution Review: Find the Minimum Value in a Binary Search Tree
- Challenge 2: Find kth Maximum Value in a Binary Search Tree
- Solution Review: Find kth Maximum Value in a Binary Search Tree
- Challenge 3: Find Ancestors of Given Node in Binary Search Tree
- Solution Review: Find Ancestors of a Given Node in a Binary Tree
- Challenge 4: Find the Height of a Binary Search Tree
- Solution Review: Find the Height of a Binary Search Tree
- Challenge 5: Find Nodes at “k” Distance from the Root
- Solution Review: Find Nodes at “k” Distance from the Root
- Tree Interview Questions
-
Trie (Advanced Trees)
- What is a Trie?
- The Structure of a Trie
- Insertion in a Trie
- Search in a Trie
- Deletion in a Trie
- Challenge 1: Total Number of Words in a Trie
- Solution Review: Total Number of Words in a Trie
- Challenge 2: Find All of the Words in a Trie
- Solution Review: Find All of the Words in a Trie
- Challenge 3: Sort the Elements of an Array using a Trie.
- Solution Review: Sort the Elements of an Array using a Trie.
- Challenge 4: Word Formation from a Given Dictionary using a Trie
- Solution Review: Word Formation from Given Dictionary using Trie
- Trie Interview Questions
-
Heaps
- What is a Heap
- Why Use Heaps?
- Heap Representation in Arrays
- Max Heap: Introduction
- Max Heap (Implementation)
- Min Heap: An Introduction
- Min Heap (Implementation)
- Challenge 1: Convert a Max-Heap to a Min-Heap
- Solution Review: Convert a Max-Heap to a Min-Heap
- Challenge 2: Find the k Smallest Elements in an Array
- Solution Review: Find the k Smallest Elements in an Array
- Challenge 3: Find the k Largest Elements in an Array
- Solution Review: Find the k Largest Elements in an Array
- Heap Interview Questions
-
Hash Tables
- What is a Hash Table?
- Hash Functions
- Collisions in Hash Tables
- Building a Hash Table from Scratch
- Add/Remove & Search in a Hash Table (Implementation)
- Complete Implementation of Hash Tables
- Trie vs Hash Table
- HashMap vs HashSet
- Challenge 1: Find whether an array is a subset of another array
- Solution Review: Find whether an array is a subset of another array
- Challenge 2: Check if the given arrays are disjoint
- Solution Review: Check if the given arrays are disjoint
- Challenge 3: Find symmetric pairs in an Array
- Solution Review: Find symmetric pairs in an Array
- Challenge 4: Trace the complete path of a journey
- Solution Review: Trace the complete path of a journey
- Challenge 5: Find two pairs in an Array such that a+b = c+d
- Solution Review: Find two pairs in an Array such that a+b = c+d
- Challenge 6: Find If a Subarray with a Sum Equal to 0 Exists
- Solution Review: Find if a subarray with a sum equal to 0 exists.
- Challenge 7: First Non-Repeating Integer in an Array
- Solution Review: First Non-Repeating Integer in an Array
- Challenge 8: Remove Duplicate from a Linked List using Hashing
- Solution Review: Remove Duplicate from Linked List using Hashing
- Challenge 9: Union and Intersection of Lists using Hashing
- Solution Review: Union and Intersection of Lists using Hashing
- Challenge 10: Find Two Numbers that Add up to “n”
- Solution Review: Find Two Numbers that Add up to “n”
- Hashing Interview Questions
-
Summary of Data Structures
- Overview of Linear & Non-Linear Data Structures
- Conclusion
Catalog
Topic | Name of the challenge | Java | Go | Rust | Haskell |
---|---|---|---|---|---|
Abstract data types | Implement Bag Using LinkedList | yes | |||
Implement Queue Using LinkedList | yes | ||||
Implement Stack Using DoubleLinkedList | yes | ||||
Implement Stack Using LinkedList | yes | ||||
Queue using Stacks - https://www.geeksforgeeks.org/dsa/queue-using-stacks/ | |||||
Implement Stack using Queues - https://www.geeksforgeeks.org/dsa/implement-stack-using-queue/ | |||||
Implement k stacks in an array - https://www.geeksforgeeks.org/dsa/efficiently-implement-k-stacks-single-array/ | |||||
Implement a stack using single queue - https://www.geeksforgeeks.org/dsa/implement-a-stack-using-single-queue/ | |||||
Implement stack using priority queue or heap? - https://www.geeksforgeeks.org/dsa/implement-stack-using-priority-queue-or-heap/ | |||||
Implement Stack and Queue using Deque - https://www.geeksforgeeks.org/dsa/implement-stack-queue-using-deque/ | |||||
Stack using two queues - https://www.geeksforgeeks.org/problems/stack-using-two-queues/1 | |||||
Evaluate Postfix Expressions or Reverse Polish Notation (RPN) | yes | ||||
ExpressionEvaluation | yes | ||||
FixedCapacityStack | yes | ||||
FullyParenthesizedArithmeticExpressionEvaluation | yes | ||||
ResizingArrayStack | yes | ||||
ReverseAGivenStack | yes | ||||
ReverseUsingStack.java | yes | ||||
Array | ArrayCyclicRotation | yes | |||
OddNumberOfAnArray | yes | ||||
ArrayResizing | yes | ||||
BirthdayCakeCandles | yes | ||||
DropFirstNElementsOfAnArray | yes | ||||
EquilibriumIndexOfArray | yes | ||||
KadanesAlgorithm.pdf | |||||
LargestSumSubarray | yes | ||||
MaximumAndMinimumElementsInAnArray | yes | ||||
MaximumContiguousSubarraySumProblems.pdf | |||||
MoveNegativeElementsToTheLeft | yes | ||||
SearchForANumberInAnArray | yes | ||||
SequentialParallelAlgorithms4MaxSubarrayProblem | yes | ||||
SimpleArraySum | yes | yes | |||
SmallestIndexInAnArrayThatHasAllTheElements | yes | ||||
SubarraysWithNegativeSum | yes | ||||
SumOfNaturalNumbersUptoN | yes | ||||
SwapElementsToMakeSumEqual | yes | ||||
Two Sum | yes | yes | yes | ||
TwoSumFromTwoDifferentArrays | yes | ||||
TwoSumInputArrayIsSorted | yes | ||||
UniqueNumbersInAnArray | yes | ||||
VeryBigArraySum | yes | ||||
WriteArrayBackwards | yes | ||||
Compute number of inversion in an array | |||||
Polygon concavity index | |||||
Flood depth | |||||
Slalom skiing | |||||
Array recovery | |||||
Binary Search | Min Max Division | ||||
Nailing Planks | |||||
CaterpillarMethod | absolute distinct count of this array | ||||
count distinct slices | |||||
count triangles | |||||
minimal absolute value of a sum of two elements | |||||
Counting elements | Frog river one | ||||
Max counters | |||||
Permutation check | |||||
smallest positive number missing from array | |||||
Dynamic programming | Min Abs Sum | ||||
Number Solitaire | |||||
Euclidean algorithm | GCD | ||||
Chocolates by numbers | |||||
Common prime divisors | |||||
Fibonacci numbers | Fib Frog | ||||
Ladder | |||||
Fibonacci Sequence until N | yes | ||||
Fibonacci number at position N | yes | ||||
EvenFibonacciSequence | yes | yes | yes | ||
Fractions | CropRatio.java | yes | |||
PlusMinus.java | yes | ||||
Greedy algorithms | max non overlapping segments | ||||
tie ropes | |||||
Hacker Rank | 3DSurfaceArea.pdf | ||||
AbsolutePermutation.pdf | |||||
ACM-ICPC-Team.pdf | |||||
AlmostSorted.pdf | |||||
AngryProfessor | yes | ||||
AppendAndDelete.pdf | |||||
AppleAndOrange.pdf | yes | yes | |||
BeautifulDaysAtTheMovies.java | |||||
BeautifulTriplets.pdf | |||||
BetweenTwoSets | yes | yes | |||
BiggerIsGreater.pdf | |||||
BirthdayChocolate.pdf | |||||
BonAppetit.pdf | |||||
BreakingTheRecords.pdf | yes | ||||
CatsAndAMouse.pdf | |||||
CavityMap.pdf | |||||
ChocolateFeast.pdf | |||||
CircularArrayRotation.pdf | |||||
ClimbingTheLeaderboard.pdf | |||||
CountingValleys.pdf | |||||
CutTheSticks.pdf | |||||
DayOfTheProgrammer.pdf | yes | ||||
DesignerPdfViewer.pdf | |||||
DivisibleSumPairs.pdf | yes | ||||
DrawingBook.pdf | |||||
ElectronicsShop.pdf | |||||
EmasSupercomputer.pdf | |||||
Encryption.pdf | |||||
EqualiseTheArray.pdf | |||||
ExtraLongFactorials.pdf | |||||
FairRations.pdf | |||||
FindDigits.pdf | |||||
FlatlandSpaceStations.pdf | |||||
FormingAMagicSquare.pdf | |||||
GradingStudents.pdf | yes | yes | |||
HalloweenSale.pdf | |||||
HappyLadybugs.pdf | |||||
JumpingOnTheClouds.pdf | |||||
JumpingOnTheCloudsRevisited.pdf | |||||
Kangaroo.pdf | yes | ||||
LarrysArray.pdf | |||||
LibraryFine.pdf | |||||
LisasWorkbook.pdf | |||||
ManasaAndStones.pdf | |||||
MatrixLayerRotation.pdf | |||||
MigratoryBirds.pdf | yes | ||||
MinimumDistances.pdf | |||||
ModifiedKaprekarNumbers.pdf | |||||
NonDivisibleSubset.pdf | |||||
OrganizingContainersOfBalls.pdf | |||||
PickingNumbers.pdf | |||||
QueensAttack2.pdf | |||||
RepeatedString.pdf | |||||
SaveThePrisoner.pdf | |||||
SequenceEquation.pdf | |||||
ServiceLane.pdf | |||||
SherlockAndSquares.pdf | |||||
SimpleArraySum | yes | ||||
SockMerchant.pdf | yes | ||||
StrangeCounter.pdf | |||||
TaumAndBday.pdf | |||||
TheBombermanGame.pdf | |||||
TheGridSearch.pdf | |||||
TheHurdleRace.pdf | |||||
TheTimeInWords.pdf | |||||
UtopianTree.pdf | |||||
VeryBigArraySum | yes | yes | |||
ViralAdvertising.pdf | |||||
Higher order functions | 11EtaConversion.org | yes | |||
12ANoteAboutListEfficiency.org | yes | ||||
13CurriedFunctions.hs | yes | ||||
14SomeHigherOrderismIsInOrder.hs | yes | ||||
15MapsAndFilters.hs | yes | ||||
16Lambdas.hs | yes | ||||
17Folds.hs | yes | ||||
18Scans.hs | yes | ||||
19FunctionApplicationWith$.org | yes | ||||
20FunctionComposition01.org | yes | ||||
21FunctionComposition.hs | yes | ||||
Hash Maps | IteratingAHashMap | yes | |||
Hash Tables | ChainingHashTableClient | yes | |||
IteratingAHashTable | yes | ||||
LinearProbingHashTableClient | yes | ||||
SimpleHashTable_Chaining | yes | ||||
SimpleHashTable_LinearProbing | yes | ||||
Heap | Heap | yes | |||
HeapClient | yes | ||||
PriorityQueueClient | yes | ||||
Iterations | Binary gap | yes | |||
Linked list (jdk) | JdkLinkedListClient | yes | |||
Linked list (singly linked list) | Sorted Integer LinkedList | yes | |||
Employee Single Linked List | yes | ||||
Reverse a linked list in place | |||||
Add an element at the middle of the linked list | |||||
Sort a linked list in Java (http://www.java67.com/2016/02/how-to-sort-linkedlist-in-java-example.html) | |||||
Remove Nth Node from the end of a linked list (https://leetcode.com/problems/remove-nth-node-from-end-of-list/solution/) | |||||
Merge two sorted linked list | |||||
Find the middle element of a singly linked list in one pass? (http://javarevisited.blogspot.sg/2012/12/how-to-find-middle-element-of-linked-list-one-pass.html) | |||||
Check if a given linked list contains a cycle? How do you find the starting node of the cycle? (http://javarevisited.blogspot.sg/2013/05/find-if-linked-list-contains-loops-cycle-cyclic-circular-check.html) | |||||
Reverse a linked list? (http://www.java67.com/2016/07/how-to-reverse-singly-linked-list-in-java-example.html) | |||||
Reverse a singly linked list without recursion? (http://javarevisited.blogspot.sg/2017/03/how-to-reverse-linked-list-in-java-using-iteration-and-recursion.html) | |||||
Remove duplicate nodes from an unsorted linked list? (https://www.geeksforgeeks.org/remove-duplicates-from-an-unsorted-linked-list/) | |||||
Remove duplicates from a sorted linked list? (https://leetcode.com/problems/remove-duplicates-from-sorted-list/solution/) | |||||
Find the length of a singly linked list? (http://javarevisited.blogspot.sg/2016/05/how-do-you-find-length-of-singly-linked.html) | |||||
Find the third node from the end in a singly linked list? (http://javarevisited.blogspot.sg/2016/07/how-to-find-3rd-element-from-end-in-linked-list-java.html) | |||||
Find the sum of two linked lists using Stack? (https://www.geeksforgeeks.org/sum-of-two-linked-lists/) | |||||
Find the node at which the intersection of two singly linked lists begins. (https://leetcode.com/problems/intersection-of-two-linked-lists/solution/) | |||||
Given a linked list and a value , partition it such that all nodes less than x come before nodes greater than or equal to x. (https://leetcode.com/problems/partition-list/solution/) | |||||
Check if a given linked list is a palindrome? | |||||
AddTwoNumbersAsALinkedList.txt | |||||
DetectLinkedListCycle.txt | |||||
DetermineIfLinkedListIsPalindrome.txt | |||||
IntersectionOfLinkedLists.txt | |||||
MergeKSortedLinkedLists.txt | |||||
RemoveDuplicateFromLinkedList.txt | |||||
RemoveDuplicatesFromSortedList.txt | |||||
RemovekthLastElementFromLinkedList.txt | |||||
ReverseALinkedList.txt | |||||
RotateLinkedList.txt | |||||
SwapEveryTwoNodesInALinkedList.txt | |||||
Remove all elements from a linked list of integers which matches with given value? | |||||
Linked list (doubly linked list) | Employee Double LinkedList | yes | |||
Lists | CompareTriplets | yes | |||
IteratingAnArrayList | yes | ||||
List Ranges | yes | ||||
Infinite Lists | yes | ||||
List comprehensions | yes | ||||
Tuples | yes | ||||
CountFrequencyOfElementsInAList | yes | ||||
EveryNthElementInAList | yes | ||||
FindFirstDuplicate | yes | ||||
GetTheMiddleElementsOfAList | yes | ||||
IsListSymmetric | yes | ||||
LengthOfAList | yes | ||||
MaxAndMinElementsInAListAndTheirIndices | yes | ||||
RemoveDuplicatesFromList | yes | ||||
UniqueElementsInAList | yes | ||||
Maps | Bag Of Words | yes | |||
Top K Frequent Words | yes | ||||
Matrix | Diagonal Difference | yes | |||
Absolute difference between the sums of its diagonals in a square matrix | yes | ||||
Mooshak Catching Cheese | yes | ||||
There are a lot of helpful methods for matrices here : | |||||
https://introcs.cs.princeton.edu/java/95linear/Matrix.java.html | |||||
Numbers | Collatz Sequences | yes | |||
FindOddNumbersBetweenLAndR.java | yes | ||||
GCDOfNumbersInAnArray.java | yes | ||||
GCDOfTwoNumbersUsingEuclideanAlgorithm.java | yes | ||||
Integer Palindrome | yes | ||||
LargestNumberUnderNDivisibleByAGivenNumber.java | yes | ||||
LCMOfNumbersInAnArray.java | yes | ||||
LCMOfTwoNumbers.java | yes | ||||
MiniMaxSum.java | yes | ||||
ReverseInteger.java | yes | ||||
RightTriange.java | yes | ||||
SumOfAllOddSquaresSmallerThanN.java | yes | ||||
SwapIntegersWithoutUsingATempVariable.java | yes | ||||
Absolute | yes | ||||
AddTwoNumbers | yes | ||||
CalculateEndTimeByStartTimeAndDuration | yes | ||||
CollatzSequences | yes | ||||
Convert list to decimal number | yes | ||||
Double all numbers in a list of integers | yes | yes | |||
Check if number is even or odd | yes | ||||
Generate a list of even Numbers Till N | yes | yes | yes | ||
Generate a list of First N Even Numbers | yes | yes | yes | ||
Generate a list of N even numbers from a given number | yes | ||||
FibonacciSequence | yes | yes | yes | ||
GenerateAListOfAllEvenNumbersTillN | yes | yes | |||
GenerateAListOfFirstNEvenNumbers | yes | yes | |||
Largest number under n divisible by a given number | yes | ||||
LeapYear | yes | ||||
Primes | yes | ||||
RightTriangle | yes | ||||
SumOfAllEvenNumbersInAListOfIntegers | yes | ||||
SumOfAllOddSquaresSmallerThanN | yes | ||||
SumOfEvenValuedFibonacciTermsLessThanMaxValue | yes | ||||
SumOfFirstNMultiplesOf3Or5 | yes | ||||
SumOfIntegersInAList | yes | ||||
SumOfMultiplesOf3Or5SmallerThanN | yes | ||||
SumSquareDifference | yes | ||||
NumberLineJumps.pdf | NumberLineJumps.hs | yes | |||
Numbers.NumeralSystems | Roman To Decimal | yes | |||
Numbers.NumeralSystems | Decimal To Roman | yes | |||
Leader | Dominator | ||||
EquiLeader | |||||
Maximum Slice problem | max double slice sum | ||||
max double slice sum | |||||
max profit | |||||
max slice sum | |||||
Prefix sums | CountDiv | yes | |||
GenomicRangeQuery | yes | ||||
CountDiv | yes | ||||
GenomicRangeQuery | yes | ||||
MaxOrMinAvgSubArrayOfSpecifiedSize | yes | ||||
MinAvgTwoSlice2 | yes | ||||
MinAvgTwoSlice3 | yes | ||||
MinAvgTwoSlice | yes | ||||
MinAvgTwoSliceProof.pdf | yes | ||||
MushroomPicker | yes | ||||
PassingCars | yes | ||||
PrefixSums | yes | ||||
PrimeAndCompositeNumbers | CountFactors | ||||
Flags | |||||
MinPerimeterRectangle | |||||
Peaks | |||||
Shunting yard algorithm | TransformAnInfixExpressionToPostfixNotation.java | yes | |||
Determine if string with multiple parentheses types is properly nested | |||||
Number of fish alive | |||||
Determine if string with single parentheses type is properly nested | |||||
Minimum number of blocks needed to build a wall | |||||
SieveOfEratosthenes | CountNonDivisible | ||||
CountSemiprimes | |||||
CountNonDivisible | |||||
Sorting | Distinct | ||||
MaxProductOfThree | |||||
NumberOfDiscIntersections | |||||
Triangle | |||||
Strings | symmetry point of a string | ||||
depth of a peculiarly represented tree | yes | yes | |||
reverse characters in a string (for loop) | yes | ||||
reverse characters in a string using linked list (See String Palindrome) | yes | ||||
reverse characters in a string using queue (See String Palindrome) | yes | ||||
longest password | |||||
dwarfs rafting | |||||
BalancedParanthesis | yes | ||||
FizzBuzz | yes | yes | yes | ||
FizzBuzzMultithreaded | yes | ||||
MostCommonCharacterInString | yes | ||||
Permutations | yes | ||||
ReverseWordsInASentence | yes | ||||
Staircase | yes | ||||
StringPalindrome | yes | yes | |||
StringReversal | yes | ||||
TimeConversion | yes | ||||
ToCamelCase | yes | ||||
AddLineNumbersToSourceCode.hs | yes | ||||
Anagram.hs | yes | ||||
Angles Of A Clock | yes | ||||
AssessMovies.hs | yes | ||||
CaesarCipher.hs | yes | ||||
CheckIfAllCharsOfAStringAreInAnotherString.hs | yes | ||||
ConvertAStringToLowerCase.hs | yes | ||||
ExamScoreProcessing.hs | yes | ||||
FizzBuzz.hs | yes | ||||
GeneralizedFibonacciSelector.hs | yes | ||||
GetTheMiddleCharactersOfAString.org | yes | ||||
GroupNamesByAlphabets.hs | yes | ||||
ISBNVerifier.hs | yes | ||||
LongestCommonSubsequenceBetweenTwoStrings.hs | yes | ||||
Pagination.hs | yes | ||||
Pangram.hs | yes | ||||
RailFenceCipher.hs | yes | ||||
RemoveSubstringFromAString.hs | yes | ||||
Count the number of words in a file | WordCount.hs | ||||
Count the number of characters in a file | WordCount.hs | ||||
Recursion | ChoosingKOutOfNThings | yes | |||
Factorial | yes | yes | |||
FindTheKthSmallestValueOfAnArray | yes | ||||
MultiplyingRabbits | yes | ||||
OrganizingAParade | yes | ||||
ProductOfFirstNRealNumbersInArrayUsingRecurson | yes | ||||
ProductOfIntegersInArrayUsingRecursion | yes | ||||
TowersOfHanoi | yes | ||||
Search | BinarySearch | yes | |||
LinearSearch | yes | ||||
Sorting | BubbleSort | yes | |||
BucketSort | yes | ||||
CountingSort | yes | ||||
HeapSort | yes | ||||
InsertionSort | yes | ||||
MergeSort | yes | ||||
Quicksort | yes | yes | |||
RadixSort | yes | ||||
SelectionSort | yes | ||||
ShellSort | yes | ||||
LinearTimeSort | yes | ||||
Sorting by enums | Person.java | yes | |||
PersonRole.java | yes | ||||
Sorting objects | ArraysAndListsComparator.java | yes | |||
Fruit.java | yes | ||||
NameComparator.java | yes | ||||
QuantityComparator.java | yes | ||||
RatingAndNameComparator.java | yes | ||||
RatingComparator.java | yes | ||||
Time complexity | Frog jumps | ||||
Perm missing element | |||||
Tape equilibrium | |||||
Trees | BinaryTree_ArithmeticBT.txt | ||||
BinaryTree_BreadthFirstTreeTraversal_ListsByLevel.txt | |||||
BinaryTree_BreadthFirstTreeTraversal.txt | |||||
BinaryTree_BuildBinarySearchTree.txt | |||||
BinaryTree_CeilingOfAGivenElement.txt | |||||
BinaryTree_ChangeSortedListOfNumbersIntoBalancedBinarySearchTree.txt | |||||
BinaryTree_CheckIfItIsValidBST.txt | |||||
BinaryTree_ConvertBinaryTreeToFullBinaryTree.txt | |||||
BinaryTree_CountFullNodesInABinaryTree.txt | |||||
BinaryTree_CountNumberOfNodesInACompleteBinaryTree.txt | |||||
BinaryTree_CountNumberOfNodesInAFullBinaryTree.txt | |||||
BinaryTree_DeleteAnElementFromATree.txt | |||||
BinaryTree_DepthFirstTreeTraversal.txt | |||||
BinaryTree_FindAllDuplicateSubtrees.txt | |||||
BinaryTree_FindIfASubtreeExistsInATree.txt | |||||
BinaryTree_FindTheDeepestNode.txt | |||||
BinaryTree_Flatten.txt | |||||
BinaryTree_FloorOfAnElementInABT.txt | |||||
BinaryTree_HeightAndDepth.txt | |||||
BinaryTree_HeightBalancedBT.txt | |||||
Binary Tree - In-order traversal using O1 space.txt | |||||
BinaryTree_Invert a binary tree in place.txt | |||||
BinaryTree_LargestBSTInABinaryTree.txt | |||||
BinaryTree_LargestPathFromRootToLeaf.txt | |||||
BinaryTree_LevelOfTreeWithMaximumSum.txt | |||||
BinaryTree_LevelOfTreeWithMinimumSum.txt | |||||
BinaryTree_MaximumAndMinimumElementsInATree.txt | |||||
BinaryTree_MinimumPathSumFromRootToLeaf.txt | |||||
BinaryTree_NumberOfCousinsInLevelOrder.txt | |||||
BinaryTree_PathsFromRootToAllLeaves.txt | |||||
BinaryTree_PrintNodesInBoustrophedonOrder.txt | |||||
BinaryTree_PruneByLeafNodeValues.txt | |||||
BinaryTree_ReconstrunctBinaryTreeFromPreorderAndInorderTraversals.txt | |||||
BinaryTree_RemoveNodesToMakeAFullBT.txt | |||||
BinaryTree_ReturnNodeValuesAtAGivenHeight.txt | |||||
BinaryTree_RootToLeafNumbersSummed.txt | |||||
BinaryTree_SearchForAnElementInATree.txt | |||||
BinaryTree_TargetSumFromRootToLeaf.txt | |||||
BinaryTree_UnivalSubtrees.txt | |||||
BinaryTree_ZigZagBinaryTree.txt | |||||
Build a Huffman Tree.txt | |||||
CartesianTree.txt | |||||
Cartesian Tree With a Sequence.txt | |||||
CloneTrees.txt | |||||
Cousins for all nodes in a tree.txt | |||||
CousinsForAllNodes.txt | |||||
GenerateAFiniteTreeInConstantTime.txt | |||||
Horizontal Distance of each node in a tree and Bottom View of the tree with and without horizontal distance.txt | |||||
ImplementLockingInABinaryTree | |||||
LeafSimilarTrees.txt | |||||
Level of the tree with minimum sum.txt | |||||
MakingAHeightBalancedBinarySearchTree.txt | |||||
MaximumPathSumInBinaryTree.txt | |||||
Merge trees by adding nodes at the same positions.txt | |||||
MergeTwoBinaryTreesBasedOnCriteria.txt | |||||
MinimumDepthOfNodesInBinaryTree.txt | |||||
MostFrequentSubtreeSum.txt | |||||
PrintATreeLevelByLevelWithLineBreaks.txt | |||||
RemoveEdgesInATree.txt | |||||
SplitABinarySearchTree.txt | |||||
SymmetricKaryTree.txt | |||||
TreeSerialization.txt | |||||
Unidentified | Hilbert maze | ||||
Rectangle builder greater area | |||||
Tree product | |||||
Diamonds count | |||||
Socks laundering | |||||
Tennis tournament | |||||
PersonalizedCoupons | yes | ||||
Geometry (Cube) | yes | ||||
Geometry (Cuboid) | yes | ||||
Geometry (Sphere) | yes | ||||
Algebraic Data Types | yes | ||||
10RecursiveDataStructure.hs | yes | ||||
Association Lists | yes | ||||
Pattern matching | yes | ||||
Guards | yes | ||||
Object Oriented and System Design examples | LRU Cache (Hash map and double linked list) | yes | |||
Vending machine | yes | ||||
Design a Lift system | |||||
Design a Trade Position Aggregator or Portfolio Manager | |||||
Design a Traffic Controller System for a Junction | |||||
Design a URL shortener service |
TODO
- AbsolutePath.txt
- AddDigits.txt
- Angry Professor.txt
- AnIntroToBacktracking.txt
- Autocompletion.txt
- Balanced Parantheses Quesions.txt
- Between two sets.txt
- BuddyStrings.txt
- Calculate the fractions positive, negative, and zero elements in an array.txt
- CharacterMap.txt
- Rearrange String to make it a palindrome.txt
- Check if an array is a permutation.txt
- ChoosingKOutOfNThings.txt
- CircleOfChainedWords.txt
- CitySkyline.txt
- ClosestPointsToOrigin.txt
- ClosestTo3Sum.txt
- CollatzSequences.txt
- CommonCharacters.txt
- CompareVersionNumbers.txt
- Compute number of integers divisible by a number.txt
- ConcatenatedWords.txt
- ConnectedColorsInAGrid.txt
- ConsecutiveOnes.txt
- ConstructAllPossibleBSTs.txt
- ContiguousSubArrayWithMaximumSum.txt
- ConvertDecimalNumeralsToRoman.txt
- ConvertFractionToDecimal.txt
- ConvertRomanNumeralsToDecimal.txt
- ConvertToBaseTwo.txt
- ConvertToHexadecimal.txt
- CoursePrerequisites.txt
- CreateASimpleCalculator.txt
- DecodeString.txt
- DeepCopyGraph.txt
- DesignTicTacToe.txt
- DetermineIfNumber.txt
- DistributeBonuses.txt
- Earliest time when a frog can jump to the other side of a river.txt
- EditDistance.txt
- Equilibrium index of an array.txt
- Evaluate expression.txt
- EvaluatePostfixExpression.txt
- Even Fibonacci Numbers.txt
- FallingDominoes.txt
- FindClosestPoints.txt
- FindCyclesInAGraph.txt
- FindDuplicates.txt
- FindKthLargestElementInAList.txt
- FindNonDuplicateNumber.txt
- FindTheKthLargestNumber.txt
- FindTheKthSmallestValueOfAnArray.txt
- FindTheNumberOfIslands.txt
- FindTheSingleElementInAnArrayOfDuplicates.txt
- FirstAndLastIndicesOfAnElementInSortedArray.txt
- FirstMissingPositiveInteger.txt
- FirstRecurringCharacter.txt
- FixBrackets.txt
- Split string into parts with equal number of opening and closing brackets.txt
- FixedCapacityStack.txt
- FixedPoint.txt
- FizzBuzzMultithreaded.txt
- FizzBuzz.txt
- FlattenDictionary.txt
- Frog jumps.txt
- FullyParenthesizedArithmeticExpressionEvaluation.txt
- GenerateAllIPAddresses.txt
- Genomic Range Query.txt
- HIndex.txt
- HowToPickARandomElementFromAnInfiniteStream.txt
- HowToSolveAHardProgrammingInterviewQuestion.txt
- IndexOfLargestNextNumber.txt
- InorderSuccessor.txt
- IntersectionOfLists.txt
- IntersectionOfTwoArrays.txt
- JumpToTheEnd.txt
- KaprekarsConstant.txt
- KClosestElements.txt
- LargestProductOfThreeElements.txt
- list.txt
- LongestCommonPrefix.txt
- LongestConsecutiveSequence.txt
- LongestIncreasingSubsequenct.txt
- LongestPalindromicSubstring.txt
- LongestSubstringWithKDistinctCharacters.txt
- LongestSubstrWithoutRepeatingCharacters.txt
- LookAndSaySequence.txt
- LowestCommonAncestorOfTwoGivenNodes.txt
- MajorityElement.txt
- MakeTheLargestNumber.txt
- MakingChange.txt
- MaxAndMinWithMinimumComparisons.txt
- MaximumInAStact.txt
- MaximumNonAdjacentSum.txt
- MaximumProfitFromStocks.txt
- Max Or Min Avg SubArray Of Specified Size.txt
- MazePaths.txt
- MergeListOfNumberIntoRanges.txt
- MergeOverlappingIntervals.txt
- Minimal average of any slice containing at least two elements.txt
- MinimumNumberOfOperations.txt
- MinimumRemovalsForValidParanthesis.txt
- MinimumSizeSubarraySum.txt
- MinRangeNeededToSort.txt
- MinStack.txt
- Missing element in a permutation.txt
- MissingRanges.txt
- MostCommonCharacterInString.txt
- MoveZeroes.txt
- MultiplyingRabbits.txt
- Multiply.txt
- Multitasking.txt
- MyStory.txt
- NearestPoints.txt
- Next smallest integer from a sorted array.txt
- NoAdjacentRepeatingCharacters.txt
- NonDecreasingArrayWithSingleModification.txt
- NthFibbonacciNumber.txt
- NumberOf1Bits.txt
- NumberOfConnectedComponents.txt
- NumberOfMeetingRooms.txt
- NumberOfWaysToClimbStairs.txt
- OptimizedListSum.txt
- OrganizingAParade.txt
- PartitionAList.txt
- PascalsTriangle.txt
- Passing cars.txt
- PerfectNumber.txt
- PermutationsOfNumbers.txt
- PhoneNumbers.txt
- PickingUpChange.txt
- PlusOne.txt
- PostorderTraversal.txt
- PowerFunction.txt
- Print a staircase of size N.txt
- ProductOfArrayExceptSelf.txt
- PythagoreanTriplets.txt
- QueensOnAChessboard.txt
- QueueUsingTwoStacks.txt
- RangeSearchingInASortedList.txt
- RansonNote.txt
- RectangleIntersection.txt
- RemoveAdjacentDuplicateCharacters.txt
- RemoveCharacterToCreatePalindrome.txt
- RemoveConsecutiveNodesThatSumToZero.txt
- RemoveOneLayerOfParanthesis.txt
- ReshapingMatrix.txt
- ResizingArrayStack.txt
- ReverseADirectedGraph.txt
- ReverseBits.txt
- Reverse digits of an integer.txt
- ReverseInteger.txt
- ReversePolishNotationCalculator.txt
- ReverseWordsInASentence.txt
- ReverseWordsInAString.txt
- ReverseWords.txt
- RoomScheduling.txt
- Root to leaf path that sums up to k.txt
- RotateArray.txt
- RotateMatrix.txt
- RunningMedian.txt
- ScheduleTasks.txt
- SemanticVersionComparator.txt
- ShiftedString.txt
- ShortestDistanceToCharacter.txt
- ShortestUniquePrefix.txt
- SmallestNumberThatIsNotASumOfASubsetOfList.txt
- Smallest positive number missing from a series.txt
- SortAListWithThreeUniqueNumbers.txt
- SortAPartiallySortedList.txt
- SortColors.txt
- SortedSquareNumbers.txt
- SortingWindowRange.txt
- SpiralTraversalOfGrid.txt
- SpreadsheetColumns.txt
- SpreadsheetColumnTitle.txt
- Squareroot.txt
- StayingOnAChessBoard.txt
- StringCompression.txt
- StringToInteger.txt
- SubArrayWithTargetSum.txt
- SudokuCheck.txt
- SumBinaryNumbers.txt
- Sum of all odd squares that are smaller than 10,000.txt
- SumOfSquares.txt
- SwapBits.txt
- SwapElementsToMakeSumEqual.txt
- SwapIntegersWithoutUsingATempVariable.txt
- Tape Equilibrium.txt
- TheBiggestMistakeInTheCodingInterviewsCandidatesMake.txt
- TheRealSecretToGettingAJobAtATopCompany.txt
- ThreeSum.txt
- TopKFrequenntWords.txt
- TransformAnInfixExpressionToPostfixNotation.txt
- TransposeMatrix.txt
- TrappingRainwater.txt
- ValidMountainArray.txt
- WaysToTraverseAGrid.txt
- Welcome.txt
- WhyPython.txt
- WitnessOfTheTallPeople.txt
- WordConcatenation.txt
- WordOrderingInADifferentAlphabeticalOrder.txt
- WordSearch.txt
- Print array as table.txt
- Substrings of size K with K distinct chars.txt
- Find the first circular tour that visits all petrol pumps.txt