Like a lot of people, I subscribe to Daily Coding Problem. I also read reddit and other sites and sometimes do the interview problem or puzzle just to see if I can.
This repo collects links to other repos of mine that contain solutions to interview questions and puzzles.
- Binary tree problems.
This repo contains a number of problems,
and a tree package (it's in Go) to make
solving the problems less repetitious.
- Invert a binary tree
- Breadth-first traverse
- Return the maximum depth and/or the deepest node
- Reconstruct original tree from pre-order and in-order traversals
- Find all paths from root to leaves
- Print tree nodes' values in boustrophedon order
- Print "cousin" nodes of a given node
- Prune a tree so all subtrees that have a 0-valued node are removed
- Minimum-height binary search tree from a sorted array
- Find lowest-common ancestor of a given node. Assume pointer to parent node
- Count nodes in a "complete" binary tree in less than linear time
- Determine whether a binary tree is height-balanced
- Return the "inorder successor" (next biggest node) of a given node in a binary tree
- Find the "bottom view" of a binary tree
- Given a binary tree, find a minimum path sum from root to a leaf
- Find nodes of a tree with values inside a given range
- Implement locking in a binary tree. Weird locking, but locking.
- Count "unival subtrees" in a binary tree
- Merge two binary trees
- Find the largest sub-tree having the binary search tree property of a tree
- Serialize/deserialize a binary tree
- Generate a finite, but arbitrarily large binary tree in O(1) time
- Find the second-largest value in a binary search tree
- Flatten a binary tree into linked list in place, pre-order-traverse-order
- Find the level of a binary tree with the minimum sum
- Find the most frequent sum of subtree node's values
- k-ary tree symmetry determine whether a tree with arbitrary number of children is symmetric.
- Linked list problems.
This repo contains solutions to several interview questions,
all in Go,
and a Go linked list package to make solving problems less repetitious.
- Build a stack from a linked list
- Implement a queue using two stacks. This is an old standby.
- Merge two sorted linked lists
- Find the middle item of a linked list
- Merge K sorted linked lists
- Reverse a linked list in place. Another old, familiar face.
- Is a singly-linked list palindromic?
- The classic "XOR next and previous pointers", harder to do in type safe Go.
- Remove kth Last element of a list
- Rotate a list by k elements
- Swap every two nodes of a list
- Determine if a doubly-linked list is a palindrome
- Add two numbers, each represented as a linked list of single place values
- Partition a linked list, given a partition value
- Sort a linked list numerically by node values
- Remove consecutive list nodes whose value sums to zero
- Remove a node in the middle of the list
- Find intersection of 2 non-cyclical linked lists
- Floyd's and Brent's algorithms to find cycle in list
- Deep copy a list with an extra pointer to another, randomly-chosed list node
- RPN calculator Reverse polish notation calculator.
- Collatz conjecture question.
- Array rotation algorithms, these come up a lot.
- List manipulation problem, do 2 numbers in a list add to a given sum.
- Reverse a string, a silly problem, but it has depths if it's a Unicode string.
- Print a string zig-zag
- Estimate Pi using a Monte Carlo method. People have done this in the real world.
- Find if a string could be a palindrome anagram
- Recreate binary search tree from a post-order traversal I think this algorithm is unique.
- AVL binary search trees. This would be an advanced interview question indeed.
- String representation of binary tree. You may not get what you are looking for.
- Great Tree List Recursion Problem, Go
- Great Tree List Recursion Problem, C
- Pour water from jug to jug just to get a non-jugful amount.
- Kaprekar's Constant
- Flipping N fair coins, eliminating all that come up tails, then repeating.
- Soundex algorithm, Soundex in Go.
- Roman numerals to decimal
- Sort list using only an array-reverse operation.
- Boggle-like game find a word according to Boggle-game rules
- Balanced parens/brackets/braces
- Run-length encoding
- Job scheduler
- Markov chain
- Make a stack from a heap
- Reverse bits of an integer
- Decipher single-byte-XORed ciphertext
- Write a function which alternately adds and subtracts curried arguments
- String representation of numbers
- Swap even/odd bits
- Bitwise AND all numbers between M and N inclusive. Bad question.
- randomly-chosen knight's moves that stay on chessboard
- Normalize Unix-style path name
- Gray Code for arbitrary number of bits
- Variant Singleton pattern, very cognitively dissonant
- Generalized N-Queens
- Knight's Tour
- James Tanton's twitter puzzle
- Make one random distribution out of another, random5 out of random7, and vice versa
- Flatten nested dictionary
- Probability Club membership fee
- Find next biggest number with same number of 1-bits as input
- One of those freaky do an if with bitwise operations problems
- Sieve of Eratosthenes
- Given cons function in Python, implement car, cdr
- LRU cache
- Bitwise operations and arithmethic combo puzzle
- Match sub-trees
- Integer division without most numerical operators
- Classic word frequency problem
- Array element manipulation
- Greatest common denominator of a set of numbers
- Backtracking balanced parentheses
- Max stack
- Reservoir sampling
- UTF-8 byte stream validation
- Arithmetic expression evaluator
- Huffman encoding
- Decoding a scrambled URL
- Words between delimiters
- Look and say sequence
- Balancing dice problem, a subset sum problem
- Word game helper
- Generate IPv4 Addresses from a string of digits
- Unusual string reversal
- letter order from sorted words
- find min, max array values, question demands bizarre optimizations
- flip characters in a string to coerce string to meet a criterion
- count valid heaps that could be created from a collection of integers
- Find palindromes by concatenating strings from a list of strings
I've tried to either solve them in a unique or lesser-known fashion, or explore them more fully with alternate solutions. I've also tried to include an analysis of the question, from the point of view of what an interviewer could legitimately expect from a developer, and what a developer could do with a problem.
My takeaway after looking at all of these interview questions is that Daily Coding Problem doesn't rate a problem very accurately. Even non-Daily Coding Problem interview questions are often outlandish, answers are required in an unreasonably short time frame. Job candidates simply can't feel bad if an interviewer asks what they consider an "easy" problem, and the candidate can't solve it. A lot of these problems require insight that might not arrive in the stress of an interview. The flip side of this is that the interviewer should have some solution in mind, a solution appropriate for the job in question, and the seniority of the candidate. The interviewer might not get what they're interested in from any given candidate.
Article on interview questions, from a JavaScript point of view.