Grokking the coding interview_ patterns for coding questions github
The Ultimate Go Study Guide eBook version →
Join my mailing list to get the latest updates here →
I am building a database of most frequently appeared coding interview problems that I think are the most valuable and productive to spend time on. For each one, I am including my thoughts of process on how to approach and solve it, adding well-documented solutions with test cases, time and space complexity analysis. My goal is to help you get good algorithms and data structures so that you can prepare better for your next coding interviews.
These resources that I am looking at are:
If you’re interested in getting updates for this, feel free to join my mailing list here →
Table of Contents
Count the number of questions:
Clean up, lint source files, run tests and be ready for a push:
Test and report:
For more information:
Stargazers over time
grokking machine learning interview github
Copper Leaf Apartments Olympia, How To Change Your Village In Shindo Life, University Of Pittsburgh Bs/md Program College Confidential, Asst Medical Abbreviation, Islander Inn Ocean Isle Beach, Pearl High School Baseball Roster, Homestuck Candy Timeline, Similarities Of Needs, Wants And Demands, Ashland University Blackboard, Florida Turnpike Number, Bbtv Vancouver Office, Turner And Porter Funeral Home Mississauga Obituaries,
Amidst the lockdown the entire country is experiencing, most of you guys might be thinking what to do and what not during this time. Since there is a great possibility that your 2-month long summer vacations may get reduced, we thought it is the right time for you to start your placement/internship preparation. Hence, we are sharing the preparation resources as follows.
This year's CC and Avishkar classes material is available here: https://cc-mnnit.github.io/2019-20-Classes/
Important things to focus on -
𝟭. 𝗗𝗮𝘁𝗮 𝗦𝘁𝗿𝘂𝗰𝘁𝘂𝗿𝗲𝘀 & 𝗔𝗹𝗴𝗼𝗿𝗶𝘁𝗵𝗺𝘀 [𝗠𝗼𝘀𝘁 𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁]
- Practice interview related problems at LeetCode, InterviewBit, GeeksforGeeks
- Continue practicing on competitive programming sites and participate in as many contests as you can
- Keep participating in Google Kickstart rounds
- Also you should know the underlying data structures behind the collection classes in Java or containers in C++ STL (for eg. set in C++ implemented using Red Black Tree)
𝟮. 𝗥𝗲𝘀𝘂𝗺𝗲 [𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁]
- It is important to build a strong and yet elegant resume (1-2 pages)
- Add only those skills for which you feel confident that you can answer any questions if asked from them
- Single page resume recommended
- You can use the format provided by TPO
- To fit all the relevent details on a single page you can also create a single page resume at platforms like overleaf.com using latex
- Focus on these areas
1. Technical skills & languages known
2. Projects (atleast 1)
𝟯. 𝗢𝗢𝗣𝗦 𝗰𝗼𝗻𝗰𝗲𝗽𝘁𝘀 [𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁]
- Master atleast one object oriented programming language
- If you do not know any OOP language as of now, you can start maybe with Java (You can refer the Java Class material at cc github repo or GFG / Javatpoint)
- Keep real life examples ready for explaining the important OOPS concepts like abstraction, encapsulation, inheritance, polymorphism etc.
𝟰. 𝗦𝘆𝘀𝘁𝗲𝗺 𝗗𝗲𝘀𝗶𝗴𝗻 [𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁]
- Important from the point of view of placements
- Awesome course available at educative.io
https://www.educative.io/courses/grokking-the-system-design-interview [Paid Course]
Free course available here - https://coursehunters.online/t/educative-io-design-gurus-grokking-the-system-design-interview-part-1/579/3
- Many youtube videos available on system design problems
- Sometimes basic design problems may be asked in internship interviews as well like designing autocomplete feature in Google Search, designing a chess bot etc
𝟱. 𝗧𝗵𝗲𝗼𝗿𝘆 𝘀𝘂𝗯𝗷𝗲𝗰𝘁𝘀 [𝗜𝗺𝗽𝗼𝗿𝘁𝗮𝗻𝘁]
- Basics for all the core CS theory subjects should be clear
- OS - Processes and threads, multithreading, virtual memory etc - Class course / GFG
- DBMS - Anomalies, Normalization, Indexing, SQL/NoSQL databases etc - Korth / Class course / GFG
- Networking - All TCP/IP layers, DNS, TLS etc - Kurose and Ross / Class course / GFG
- Unix - GFG - Knowledge of basic system calls and concepts (eg. fork, exec, inodes, softlink hardlink etc)
- Important for placements - Companies might not focus much on theory for internship candidates!
𝟲. 𝗔𝗽𝘁𝗶𝘁𝘂𝗱𝗲, 𝗣𝘂𝘇𝘇𝗹𝗲𝘀, 𝗛𝗥 𝗾𝘂𝗲𝘀𝘁𝗶𝗼𝗻𝘀
- Aptitude - Indiabix / GFG
- Puzzles - GFG / InterviewBit
- MCQs - Indiabix / Sanfoundry / GFG
- Have a look at the interview experiences available at GFG/leetcode
- Practice writing code on paper
- Have good communication skills - conduct mock interviews with seniors/friends to get rid of nervousness
- Refer the following blog for interview preparation tips and placement stories of your seniors
- Inter IIT Placement Question Bank - https://docs.google.com/document/d/e/2PACX-1vRrEqBNm5jh7DCc_6JI4ZbDmvZvnQqEC8_kfc2r8ULikjz6GH4A5sKBjedEoFoCLvhWvzsI9aKRxuYc/pub
Patterns github interview_ grokking coding questions for the coding
Grokking the Coding Interview in 16 Patterns
Pattern 1: Sliding Window
In many problems dealing with an array (or a LinkedList), we are asked to find or calculate something among all the contiguous subarrays (or sublists) of a given size. For example, take a look at this problem:
Given an array, find the average of all contiguous subarrays of size ‘K’ in it.
Let’s understand this problem with a real input:
A brute-force algorithm will calculate the sum of every 5-element contiguous subarray of the given array and divide the sum by ‘5’ to find the average.
The efficient way to solve this problem would be to visualize each contiguous subarray as a sliding window of elements. This means that we will slide the window by one element when we move on to the next subarray. To reuse the sum from the previous subarray, we will subtract the element going out of the window and add the element now being included in the sliding window. This will save us from going through the whole subarray to find the sum and, as a result, the algorithm complexity will reduce to .
Pattern 2: Two Pointer
In problems where we deal with sorted arrays (or LinkedLists) and need to find a set of elements that fulfill certain constraints, the Two Pointers approach becomes quite useful. The set of elements could be a pair, a triplet or even a subarray. For example, take a look at the following problem:
Given an array of sorted numbers and a target sum, find a pair in the array whose sum is equal to the given target.
To solve this problem, we can consider each element one by one (pointed out by the first pointer) and iterate through the remaining elements (pointed out by the second pointer) to find a pair with the given sum. The time complexity of this algorithm will be where is the number of elements in the input array.
Given that the input array is sorted, an efficient way would be to start with one pointer in the beginning and another pointer at the end. At every step, we will see if the numbers pointed by the two pointers add up to the target sum. If they do not, we will do one of two things:
- If the sum of the two numbers pointed by the two pointers is greater than the target sum, this means that we need a pair with a smaller sum. So, to try more pairs, we can decrement the end-pointer.
- If the sum of the two numbers pointed by the two pointers is smaller than the target sum, this means that we need a pair with a larger sum. So, to try more pairs, we can increment the start-pointer.
Pattern 3: Fast & Slow pointers
The Fast & Slow pointer approach, also known as the Hare & Tortoise algorithm, is a pointer algorithm that uses two pointers which move through the array (or sequence/LinkedList) at different speeds. This approach is quite useful when dealing with cyclic LinkedLists or arrays.
By moving at different speeds (say, in a cyclic LinkedList), the algorithm proves that the two pointers are bound to meet. The fast pointer should catch the slow pointer once both the pointers are in a cyclic loop.
One of the famous problems solved using this technique was Finding a cycle in a LinkedList. Let’s jump onto this problem to understand the Fast & Slow pattern.
Pattern 4: Merge Intervals
This pattern describes an efficient technique to deal with overlapping intervals. In a lot of problems involving intervals, we either need to find overlapping intervals or merge intervals if they overlap.
Given two intervals ( and ), there will be six different ways the two intervals can relate to each other:
- and do not overlap
- and overlap, ends after
- completely overlaps
- and overlap, ends after
- completly overlaps
- and do not overlap
Understanding the above six cases will help us in solving all intervals related problems.
Pattern 5: Cyclic Sort
This pattern describes an interesting approach to deal with problems involving arrays containing numbers in a given range. For example, take the following problem:
You are given an unsorted array containing numbers taken from the range 1 to ‘n’. The array can have duplicates, which means that some numbers will be missing. Find all the missing numbers.
To efficiently solve this problem, we can use the fact that the input array contains numbers in the range of to . For example, to efficiently sort the array, we can try placing each number in its correct place, i.e., placing at index , placing at index , and so on. Once we are done with the sorting, we can iterate the array to find all indices that are missing the correct numbers. These will be our required numbers.
Pattern 6: In-place Reversal of a LinkedList
In a lot of problems, we are asked to reverse the links between a set of nodes of a LinkedList. Often, the constraint is that we need to do this in-place, i.e., using the existing node objects and without using extra memory.
In-place Reversal of a LinkedList pattern describes an efficient way to solve the above problem.
Pattern 7: Tree Breadth First Search
This pattern is based on the Breadth First Search (BFS) technique to traverse a tree.
Any problem involving the traversal of a tree in a level-by-level order can be efficiently solved using this approach. We will use a Queue to keep track of all the nodes of a level before we jump onto the next level. This also means that the space complexity of the algorithm will be , where is the maximum number of nodes on any level.
Pattern 8: Depth First Search (DFS)
This pattern is based on the Depth First Search (DFS) technique to traverse a tree.
We will be using recursion (or we can also use a stack for the iterative approach) to keep track of all the previous (parent) nodes while traversing. This also means that the space complexity of the algorithm will be , where is the maximum height of the tree.
Pattern 9: Two Heaps
In many problems, where we are given a set of elements such that we can divide them into two parts. To solve the problem, we are interested in knowing the smallest element in one part and the biggest element in the other part. This pattern is an efficient approach to solve such problems.
This pattern uses two Heaps to solve these problems; A Min Heap to find the smallest element and a Max Heap to find the biggest element.
Pattern 10: Subsets
A huge number of coding interview problems involve dealing with Permutations and Combinations of a given set of elements. This pattern describes an efficient Breadth First Search (BFS) approach to handle all these problems.
Pattern 11: Modified Binary Search
As we know, whenever we are given a sorted Array or LinkedList or Matrix, and we are asked to find a certain element, the best algorithm we can use is the Binary Search.
Pattern 12: Bitwise XOR
XOR is a logical bitwise operator that returns (false) if both bits are the same and returns (true) otherwise. In other words, it only returns if exactly one bit is set to out of the two bits in comparison.
Pattern 13: Top 'K' Elements
Any problem that asks us to find the top/smallest/frequent ‘K’ elements among a given set falls under this pattern.
The best data structure that comes to mind to keep track of ‘K’ elements is Heap. This pattern will make use of the Heap to solve multiple problems dealing with ‘K’ elements at a time from a set of given elements.
Pattern 14: K-way merge
Pattern 15: 0/1 Knapsack (Dynamic Programming)
Pattern 16: Topological Sort (Graph)
GitHub Actions supports Node.js, Python, Java, Ruby, PHP, Go, Rust, .NET, and more. Build, test, and deploy applications in your language of choice.
See your workflow run in realtime with color and emoji. It’s one click to copy a link that highlights a specific line number to share a CI/CD failure.
Built-in secret store
Automate your software development practices with workflow files embracing the Git flow by codifying it in your repository.
Test your web service and its DB in your workflow by simply adding some to your workflow file.
You will also like:
- Ford focus spi engine
- Apple iphone black wallpaper
- Sara masterchef australia
- Earth river paddle board
- Exhaust pipe bulk
- Industrial basement bar
- Fashionable hairstyles 2016
Brown saw me happily wagging his tail while shaking all his folds. But noticing the guys, he approached them and sniffed them, barked for decency something like: Bow. And probably realizing that no one was frightened of him, and did not pay attention, he went forward as if showing where to go.