Java
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
resources Add image for hashmap Jul 1, 2017
src
.gitignore
LICENSE
README.md
pom.xml

README.md

Preparations for coding interviews

Hash Tables

A hash table is a data structure that maps keys to values for efficient lookup.

Implementation details

There are many ways to implement hash tables. The most common is to use an array of a linked lists and a hash code function.



Image source

Inserting into map (key and value)
  1. Compute the key's hash code, which will usually be an int or long. Note that two different keys could have the same hash code, as there may be an infinite number of keys and a finite number of ints.
  2. Map the hash code to an index in the array. This could be done with something like hash(key) % array_length. Two different hash codes could, of course, map to the same index (finding a correct bucket).
  3. At this index, there is a linked list of keys and values. Store the key and value in this index. We must use a linked list because of collisions: you could have two different keys with the same hash code, or two different hash codes that map to the same index.
Retrieving value by its key (key and value)

To retrieve the value by its key, we need to repeat the process.

  1. Compute the hash code from the key.
  2. Compute the index from the hash code (find a bucket on picture).
  3. Search through the linked list for the value with this key. If the number of collisions is very high, the worst case runtime is O(N), where N is the number of keys. Generally we assume a good implementation that keeps collisions to a minimum, in which case the lookup time is O(1).

Note: A bucket is used to store key value pairs. A bucket can have multiple key-value pairs. In hash map, bucket used simple linked list to store objects.

Mock Interview / preparations

Mark Description
πŸ†“ Fully free.
πŸ†“ / πŸ’° Many free content, but has some premium content for extra money.
πŸ’° / πŸ†“ Mainly paid content, but has some free.
πŸ’° Fully paid content.

Coding Interview University (GitHub) πŸ†“

Coding-interview-university. Good resource, have very long list of advices on what to read and how to prepare for your coding AND System Design interview.

InterviewBit πŸ†“

InterviewBit. Self paced tutorial like resource on preparation for coding, system design AND have a mock interview feature. Contains many problems for different companies.

LeetCode πŸ†“ / πŸ’°

LeetCode. Many challenges, problems for solving. Have a bonus system. You could spend money and buy a premium subscription for mock interviews and premium problems.

InterviewCake πŸ’° / πŸ†“

InterviewCake. This resource is about coding practice, but it differs from others. The main focus here is to give you a basic intuition on how to address to the particular problem.

System Design Primer (GitHub) πŸ†“

System Design Primer. Great resource on how to deal with system design interviews. Contains different use cases and real world experience. Highly recommend to review it.

HiredInTech πŸ†“

HiredInTech Guys are doing great job on advices and use cases for system design interviews. Definitely recommend to spend some time here.

Technical Mock Interview πŸ’°

Technical Mock Interview. The main focus is mock interviews and with detailed feedback.
Pricing: $80 per session OR $340 for 5 session package.

Gainlo πŸ’°

Gainlo. The main focus is mock interviews. Also, they have good blog on general advices on how to deal with interviews. Pricing: $50-$130 per interview based on the interviewer, interview type, industry, etc.

System Design Interview πŸ’°

System Design Interview. Very concentrated course. Many use cases, examples. Highly recommend it before preparation. After a couple of years of design you will definitely find something new for you.
Pricing: whole course for ~ $79.

Arrays