-
Auth 101
Work in progress! Auth scheme An authentication scheme is a method or recipe to pass credentials from a user to an authenticating system. Authorization: <authentication type> <credential as base64> Example: Authorization: Basic <name:password> Authorization: Bearer <oauth token> HTTP Basic Authentication More about this flow here: https://en.wikipedia.org/wiki/Basic_access_authentication#Protocol OAuth Access a resource with a token instead of […]
-
Keyed hashing vs salted hashing
Sha256(myText + saltValue) vs HMAC(myText, myPrivateKey) The main difference is that the salt is not assumed unknown to the attacker, but the key is. An additional difference is that salts are supposed to vary; if you hash three passwords within the same system, then you should use three distinct salt values, whereas keys are to […]
-
Hashing function
Hashing is one way, it’s irreversible (you cannot “de-hash” a hash to get back the original text). As opposed to encrypting which is revisable (by decrypting). A hash function is any function that can be used to map data of arbitrary size to data of fixed size. The values returned by a hash function are […]
-
Hashtables
Java: Hashmap (Hashtable class is deprecated). C#: Dictionary (Hashtable class is deprecated too). /!\ A hash table does not guarantee that the order will remain constant over time. Hashmap in Java final Map<String, String> myLookupTable = new HashMap(); myLookupTable.put(“key”, “value”); myLookupTable.get(“key”); myLookupTable.getOrDefault(key, defaultValueIfDoesNotExist); myLookupTable.isEmpty(); One of the efficient ways to iterate over a HashMap object […]
-
Are Strings Anagrams?
Anagram = all letters can be reused to create another word. Approaches Approach 1: sorting (nonintuitive to me) An anagram is produced by rearranging the letters. Sort the letters alphabetically for the two strings. The sorted strings should be equal! public boolean isAnagram(String s, String t) { if (s.length() != t.length()) { return false; } […]
-
Consistent hashing
Before diving into consistent hashing, let’s understand the naive approach first. Naive: Distributed hashtable based on modulo Sharding can be achieved via a simple modulo shardNumber = hash(key) % TOTAL_SHARDS The hash function might differ based on expected properties of the key. If the key is an auto-incremental user_id, then hash(key) = key hashing might […]
-
Facebook friends
This question is similar to the “Route Between Nodes” from this book. Problem Consider a popular social networking website, Facebook for example. People can create their own profile and add friends. Given two Facebook profiles, I want to find out how to get from profile A to profile B starting from A’s friends. Output all […]
-
Validate BST
My usual mistake for this problem: You can not just compare node.left.value < node.value < node.right.value. This does not handle edge cases such as: 10 / \ 5 20 \ 20 20 is > 5 but it should be lower than 10! You have to make sure the left one is lower than all the […]
-
Arrays
A way of organizing data that enables efficient storage, retrieval, and use. An array is just a sequence of elements stored linearly. See Contiguous allocation. Languages such as C# and Java have fixed-length arrays, not Python though. Arrays vs Lists? An array is useful when you know the data is fixed length, or unlikely to […]
-
Understanding Unconscious Bias
Because interviewees are tomorrow’s interviewers. When working with different members of your team, it’s essential to keep in mind that they come from a variety of backgrounds and experiences. Some of which will be different from your own. Let’s talk about unconscious bias and how it might impact your life, your work and your relationships […]
Comments are closed.
Disclaimer
Note that authors and interviewers on Mocki.co and Mocki Blog do not represent the companies mentioned in the posts and pages. Their statements are their own opinions.
Mock interviews
Mocki.co. Practice makes perfect. Have mock interviews with engineers from top companies. Find mentors and tutors.