Commit graph

12 commits

Author SHA1 Message Date
William Carroll
93d7b5d8ea Solve a few String questions
Valid Anagram

This one is a classic: `sorted(a) == sorted(b)`

Group Anagrams

Using product of prime numbers to create a key for anagrams is much faster than
sorting the characters in each word. It is also satisfyingly simple.

Encode and Decode Strings

My initial implementation was clumsy and prone to fail for edge-cases. A more
elegant solution is using something like:

```python
def encode(words):
  return "".join("{}:{}".format(len(x), x) for x in words)
```
2020-12-25 03:52:54 +00:00
William Carroll
c34a3e2e97 Tread lightly into the Dynamic Programming section
After solving this, I was immediately stumped by the other DP questions, so I'm
taking a break.
2020-12-25 03:52:13 +00:00
William Carroll
4732a7456b Solve Binary "Sum of Two Integers"
This is tricky because Python has variable-width integers, so relying on two's
complement to support the sum of negative numbers results in infinite
recursion. I know three ways to combat this:
  1. Use Java.
  2. Conditionally branch and handle either addition or subtraction accordingly.
  3. Use a mask to enforce fixed-width integers in Python.
2020-12-25 03:50:18 +00:00
William Carroll
c389b46ecf Solve additional Tree problems
Only three more to go!
2020-12-22 18:22:40 +00:00
William Carroll
23b5dd754e Solve additional Matrix problems
Looks like "Rotate Image" is the only Matrix problem that remains. It was nice
to learn more about "Backtracking" -- a term I often encounter -- while
attempting to solve "Word Search".

From my current understanding, it is like Brute Force but with
short-circuiting. It also seems quite similar to Depth First Search, and I'm
currently unaware of how DFS and Backtracking differ. I'm hoping to learn more
though.
2020-12-22 03:03:11 +00:00
William Carroll
983b0fb276 Solve the Linked List questions
I did these during my flight from LON->NYC without wifi. I managed to get both
correct on the first attempt although I did not find the *optimal* solution for
"Reorder List". IMO "Reorder List" is the best Linked List question I've seen
because it covers a few essential Linked List tricks.
2020-12-18 19:55:18 +00:00
William Carroll
039e712656 Nest URLs beneath TODO entries
Tidying things up.
2020-12-18 14:41:26 +00:00
William Carroll
fd6029db69 Update remaining LC questions
Looks like I should prioritize the following topics:
- Dynamic Programming
- String
- Graph

Although I'm not sure how common DP questions are in interviews, DP is a useful
dragon to slay IMO.
2020-12-18 09:43:54 +00:00
William Carroll
9610ae5f5b Update Linked List LC questions
Snapshot my progress with Linked Lists...
2020-12-18 09:40:05 +00:00
William Carroll
88a22aba3d Update LC String questions
Looks like I have a few string questions to solve before closing that chapter.
2020-12-18 09:38:23 +00:00
William Carroll
262a0b45fb Mark LC Tree questions as done
Making sure that this document closely approximates the state of my LC
progress.
2020-12-18 09:36:28 +00:00
William Carroll
a30bc0f21d Create offline, org file from TeamBlind LC questions
TeamBlind.com hosts a curated list of DS&As questions from LeetCode.com that the
author claims appropriately samples the topics worth exploring. I'm creating an
offline list so that I can track my progress and work while I'm traveling.
2020-12-18 09:31:50 +00:00