- Think about if a system needs to be read-heavy or write-heavy. Something like twitter is much heavier on read operations.
- An index is placed on a specific column in a table so that you can perform lookups on that column more quickly. It's not the primary key, although you can think of the PK as an index if you know the ID, because that's the search val. More generally, it allows an indexed column to be sorted efficiently on the backend, so that lookup is binary search (logn) instead of n. The downside: this extra data takes space.
- Think of it like a dictionary (an actual physical book with word). Indexing it would mean adding pages for each letter in the appropriate place, with little tabs that jut out. You can find your section much faster, but they take a little space.
- PUT will update the data in that spot or create it if it isn't there. It's idempotent. POST just passes data to the service. The service can do whatever it wants with it. It's not idempotent. It's more generic.
- Citadel interview got a callback for onsites. Call tomorrow for scheduling.
- YAML is a superset of JSON. Can do more, but is bigger. Looks better, too.
- Testing pyramid: unit -> integrated -> e2e.
- Netflix phone interview.
- Great convo. Took a one-pager of notes. Just phone, no coding. 1hr.
- Discussed the INTERNET SHIELD, market viability in the future of streaming, attrition, culture.
- Her team directly aligns with my automation tools / devops / autotest / sx-setuptools experience.
- Next steps: take-home assignment, build an app. I said I'd submit by Saturday.
- DHCP for dynamic IP allocation.
- Perf is a main linux profiler.
- "Computers perform tasks. Machines should be solving problems."
- Practice problems:
- Remember runbooks for ops/support. All stacks/apps should have a list of common tasks or inquiries, each with an explicit set of steps to respond with.
- Slight tweaks to my resume. I still like my abridged resume more, although nobody else does. It's just so concise: 20 bullet points to summarize my life so far.
- TSLA is absolutely skyrocketing. Hit ~500 today. Its market cap is now 85b, which the highest for any american car company in history. I bought 2 shares on margin just to have fun with it. The emotional roller coaster is worth it, regardless of final profit/loss (since I jumped in ON a surge woohoooooo).
- Remember margin trading on RH is interest-free up to 1k, then 5% after that.
- Watched a lot of this guy's channel on system design: https://www.youtube.com/channel/UCRPMAqdtSgd0Ipeef7iFsKw. I like em.
- Athletes say a lot of dumb stuff on social media. It seems easiest to critique them for poor decisionmaking/tact, but in reality it's probably closer to: giving a huge stage to people on a career path where stage presence is not a required skill.
- Jeop GOAT day twoooo.
- Google phone interview.
- Was 45m. The guy was cold, didn't really reply to anything or change tone. Accent was tough over the phone.
- Didn't introduce himself or the team, jumped straight into a coding question on the google doc.
- We did a 2 subsequence comparison question. I solved it, but still had a bad taste in my mouth.
- We didn't discuss previous experience, scaling services, managing projects, writing apps.
- Big turnoff for Google, when my interactions with all other folks from Amazon/Netflix/BMW/Citadel/GitLab/Disney have been very positive.
Wednesday, January 8, 2020
Tuesday, January 7, 2020
- There's an online shazaam service called acrcloud. https://www.acrcloud.com/identify-songs-music-recognition-online#record-div.
- That old ACB call order which expired would not have broken even if it were filled. Coo.
- Dis is still about the same plateau after the d+ surge, when I sold. Coo.
- Was digging this article until they starting talking about "electromagnetic radiation" affecting your sleep, suggesting that you ground yourself before bed. Then on to light therapy and all sorts of good stuff: https://medium.com/swlh/sleep-like-a-pro-whats-the-deal-with-deep-sleep-and-how-to-get-more-46dad5da233d.
- Interesting discussion in a drug from KRTX against alzheimers: https://www.reddit.com/r/investing/comments/elclxc/im_a_physician_and_im_long_krtx_dd_inside/. This sector is crazy, I like it. Being in the industry seems to provide a ton of inside info, more than relative to being inside others even.
- Ricky Gervais' opening monologue for the golden globes was great.
- Practice problems:
- https://leetcode.com/problems/longest-valid-parentheses/. Back to try a few leetcode. Much shorter problem statements, love it.
- Convertible arbitrage: taking a long position in a convertible security and a short position in the underlying stock. It's a hedge tactic.
- Coding interview with citadel. 1hr. Phone and coderpad. Prepped. Took a lot of notes during. 2 behavioral questions, 2 coding questions. Overall impression: good in both directions.
- Said "see ya later" to hang up without even thinking twice about it, like I always do. Had some regret later; might have been interpreted as overconfidence or something. Need to pay attention to details, even ones this small.
- Created a doc with all the resources I've used over the past month for interviews.
- Generalized definition of a greedy algorithm/problem: start small and build the problem up, taking the (new) local optimum each time.
- Went back over everything in gdrive/Notes/Career/*. Some fantastic refresher content in there. Mostly technical software, some workplace environment, some interview logistics. Being diligent about documentation my whole life has paid off.
- Quicksort/mergesort/heapsort nlogn. Heapsort constant mem, others linear. Bubble slower time, const mem. Radix/bucket can be faster than the main 3 if n is small.
- Anything hashable can be used as keys. All the immutable python built-ins qualify, including tuples (whereas lists don't).
- QR = quantitative researcher.
- CDS = credit default swap. Kinda like an insurance policy on credit card debt, can get it backed by another investor for a price.
- Supercontest.
- Changed the home page (the root route /) to the leaderboard instead of your weekly picks.
- Scheduled haircut for friday, before onsites.
- First day of jeopardy GOAT tournament.
- Explored http://highscalability.com/.
- Looked up a BUNCH of resources on system design. I feel pretty good about behavioral and algorithm/datastructure questions now - system design is the last piece. Took a bunch of notes, did a few examples. Will focus on more in-depth ones over the next few days for on-sites, but I feel ready enough for the brevity of phones.
- Went over 27 common "tell us about a time..." questions and wrote responses to each. I then tried a ~60s spontaneous response to each. There are definite overlaps. A good core of 10 responses can apply/stretch to all 30.
- I did generics, and then I did concretes for Amazon's leadership principles. They're obviously the same set/class of responses, just need to have them in the toolbox ready to connect.
- Pubsub research. Not great in consistency. Latency means timing-related transactions are not great. Subscribers might receive messages at different times. Better for event-driven architectures like games.
- JSON serialization/deserialization gets less efficient as the size gets larger and larger. This is where you might pick another data transport for your API, like protobuf. You can have an endpoint return a protobuf object instead of a json object. Very similar.
- Typically, use json when talking to a browser. Use protobuf when talking to a service.
Monday, January 6, 2020
- Practice problems.
- https://www.hackerrank.com/challenges/max-array-sum/problem. DP. Iterate through the array and notice patterns. What info do you need to hold on to? What are the possible answers? Keep track of the max by index and just walk through.
- https://www.hackerrank.com/challenges/abbr/problem. Easy to get most the cases, but hard to get all. Remember for DP you can sometimes build a 2D matrix of 1s and 0s and traverse it (like longest common substring/subsequence).
- https://www.hackerrank.com/challenges/candies/problem. An interesting one. Iterate through an array, once forward, once backward, and count the rising edges. Match them by index and take the max.
- https://www.hackerrank.com/challenges/decibinary-numbers/problem. Didn't do it. Wrapped my head around it, but didn't implement.
- https://www.hackerrank.com/challenges/min-max-riddle/problem. A cool problem. What mapping do you need to solve this? Can find the INVERSE of that mapping?. Swapping keys/values in a dict is easy.
- https://www.hackerrank.com/challenges/castle-on-the-grid/problem. Used a graph. Build an adjacency matrix of the 4 cardinal directions from each node and remove the ones that are off the grid or on an X. Then it's simply a shortest-path problem. Use BFS (queue).
- https://www.hackerrank.com/challenges/poisonous-plants/problem. Got the easy solution.
- https://www.hackerrank.com/challenges/ctci-bfs-shortest-reach/problem. When using BFS for shortest path, remember to slice the list for each neighbor, so you're not overwriting the root path. And just logically think through everything. Created visited set() and queue deque(). while queue. Get path. Get node. If node == end, exit. If node in visited, continue. Else, lookup the next nodes in the adjacency matrix, add to path, then append to queue.
- https://www.hackerrank.com/challenges/find-the-nearest-clone/problem. Getting good at the graph problems. It was a less-experienced topic for me before this.
- https://www.hackerrank.com/challenges/ctci-connected-cell-in-a-grid/problem. Could do DFS or recursion or iteration.
- https://www.hackerrank.com/challenges/matrix/problem. Fun problem. There's actually a bug in a unittest in this one.
- Done with the hackerrank kit. I've probably done 100 practice problems not in total across the platforms.
- Confirmed the phone interviews this week.
- Dijkstra's algorithm is used to find the shortest path between two nodes in a graph with weighted edges. If you assigned no weights to edges (such that they're all the same, 1), it reduces to plain old BFS!
- BFS is exponential (based on how many neighbors each node has) in time and memory. It's great for small problems, but solving something with a state space like a rubik's cube is huge.
- Sets and lists are unhashable in python. For most problems, you can just convert the (i, j) coordinates to a string or something similar.
- collections.deque is faster. This whole package is great for performance. defaultdict is awesome. Counter is also really useful for counting stuff (like frequency of char in str, or others).
- When using BFS for shortest path, put PATHS (lists of nodes) instead of nodes into the queue.
- Append the new nodes to the right of a queue or a stack. But in a queue, pop the node off the left to search next. In a stack, pop the node off the right.
- Run, pull, sauna, meditate.
- Checked the snail mail. Probably 100 items. Everything was complete garbage except for 1 dmv registration. The signal to noise ratio is laughable (and wasteful of paper / people resources).
- Renewed the BMW registration. $150 total. The DMV charges a 2.1% fee for online processing. Fuck them. It should be a discount for online logistics, which have significantly reduced overhead.
- Even if it's Elavon, you need to front that.
- For number systems, the exponents always increase from 0 to n-1. This is known.
- For binary, the base is 2, so the digits in the number (the constants before the base-exponents) can only be those 2:
- [0, 1]
- For decimal, the base is 10, so the digits in the number (the constants before the base-exponents) can only be those 10:
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- I had thought about the base/exponent before, but never the limited range of digit values.
- For previous-project questions, use STAR: Situation, Task, Action, Result.
- My Amazon interview is actually at the Santa Monica location, which is more convenient! The hiring managers can pass offers between sites after, if need be.
- Took a ton of "give an example of ..." notes. Moved gdrive docs around, cleaned.
- Database partitioning. Horizontal partitioning is when you keep the table the same and split groups of rows across different machines. Each is usually called a shard. Vertical partitioning is when you split columns off into a new table. Both improve performance, making it distributed (but more complex).
- Collections.deque is pronounced "deck" - it stands for double ended queue.
- Of course threads in a process have their own stacks but share heap. Separate processes get their own stack and heap.
- Disjoint sets. Another useful data structure. Usually implemented as trees. Two operations: find() and union().
Sunday, January 5, 2020
- Promise. Async object that will return a value in the future.
- If you call an async function, the promise is returned immediately (synchronously) but in a pending state. Later it will become fulfilled or rejected and do something else.
- Can attach a callback to handle the return.
- .then() returns a promise.
- Functional vs OOP.
- Functional uses (wait for it) functions - pure, no shared state, no global mutation. It's based around actions, and is better if you expect your project to scale by adding actions.
- Object oriented is usually based classes that interact. They share. It's based around things, and is better if you expect your project to scale by adding things.
- Function composition. Could be decorators (chained functions) or simply meshing the results of multiple returns today. Straightforward.
- Class inheritance vs prototype inheritance.
- The class is a template, not an object. Gives you a template for your subclass.
- The prototype is an actual object. You create clones or slightly different children of it.
- General composition vs inheritance.
- Does B want ALL features of A? Inherit. Only want some? Compose.
- I generally agree with this: https://medium.com/inc./amazon-uses-a-secret-process-for-launching-new-ideas-and-it-will-transform-the-way-you-work-aec5c9121ae.
- Work backward from the customer, not forward from the product.
- Start with the problem and find the solution, don't create something and then check what it helps.
- Couldn't find a decent ebook download, so I ordered a hardcover for the first time in years. The man who solved the market, jim simons, rentech. Excited to read, but will probably wait until after interviews.
- NFC wild card games. Vikings and Seahawks advance.
- Divisional games: Ravens/Titans, Chiefs/Texans, Niners/Vikings, Packers/Seahawks.
- The overtime rules are so dumb. The percentage of a goalie blocking a pk in a shootout is about 30%. That's about the same ballpark as the probability of getting a touchdown on a drive. Imagine if the soccer game ended when the goalie blocked the first kick.
- Made 12 new powders.
- Caught up with Spencer. Slater's on the pier. Miss him! Bomb nashville chicken sandwich.
- Talked interviews, personal projects, SpaceX, software, life, investing.
- Rewriting the autotest ui and other frontends in python with transcrypt.
- Buying stock in a company is not directly financially enabling them, the stock pool is mostly set. It's just changing hands. Buying a vote in investors meetings. It does increase volume and other things that make the company seem more valuable.
- Certification got convoluted. Half is encryption, the other half is identification. They should be separate.
- Practice problems.
- I'm gold for problem solving. https://www.hackerrank.com/scoring.
- https://www.hackerrank.com/challenges/friend-circle-queries/problem. Wrote a solution in 10min that passed half the tests. You can optimize further with disjoint sets, but I feel comfortable with my non-fancy solution.
- https://www.hackerrank.com/challenges/maximum-xor/problem. Solved the brute force way, O(mn). To get it in linear time instead of quadratic, you have to use something called a Trie, which is basically a binary tree with 0s and 1s. https://en.wikipedia.org/wiki/Trie.
- https://www.hackerrank.com/challenges/insert-a-node-at-a-specific-position-in-a-linked-list/problem. Standard linked list insert into position. I always have to think for a minute about the while loop. Manage your own index, keep track of prev/next, and make a few things conditional on index == 0. You can simplify it if you create an entirely new list, but the in-place version is better for space situations.
- https://www.hackerrank.com/challenges/insert-a-node-into-a-sorted-doubly-linked-list/problem. I wrote the long-winded solution, which worked. HOWEVER. You can do these ll problems with recursion. It's way more concise, it's just a bit harder to conceptualize imo.
- https://www.hackerrank.com/challenges/reverse-a-doubly-linked-list/problem. Same thing. Try to thing about the recursive solution. If it's too complicated, fall back to iterative.
- https://www.hackerrank.com/challenges/find-the-merge-point-of-two-joined-linked-lists/problem. Looped through both. Quadratic solution, which passed all tests, but there is an O(n) algorithm on the discussion page. It's just less intuitive.
- https://www.hackerrank.com/challenges/ctci-linked-list-cycle/problem. Check if there's a cycle in a linked list. Easy. The key here is knowing that you can store objects as keys in a hash table. Then simply loop through the ll and bookkeep them. If you ever already have one, there's a cycle. The hash lookup is constant time.
- https://www.hackerrank.com/challenges/binary-search-tree-lowest-common-ancestor/problem. Tree problems make me think for a bit longer. Remember it's like a linked list, but you each node has two pointers instead of one. This yields two calls in recursion, or two expansions in iteration. This particular one could be solved with math, because you're given a binary search tree that's already balanced, but you could walk it all the same to find the answer.
- https://www.hackerrank.com/challenges/ctci-is-binary-search-tree/problem. Walk through a BST. I solved it both iteratively and recursively. An additional note: a binary search tree is valid if the inorder traversal is sorted properly.
- https://www.hackerrank.com/challenges/tree-huffman-decoding/problem. Very easy question. Solved it quickly, but the wording was overly complicated.
- https://www.hackerrank.com/challenges/balanced-forest/problem. Didn't try. This problem is too long.
- https://www.hackerrank.com/challenges/torque-and-development/problem. Build an adjacency dict of {node: {neighboring nodes}}. Then traverse it and group them.
- https://www.hackerrank.com/challenges/find-the-nearest-clone/problem. For BFS, literally just pop from the from of the queue instead of the end of the stack. The graph problems have been longwinded for me.
- https://www.hackerrank.com/challenges/ctci-fibonacci-numbers/problem. Recursive fibonacci. Easy as pie. Remember it's 2^n (exponential) without dp, and down to O(n) with memoization.
- https://www.hackerrank.com/challenges/ctci-recursive-staircase/problem. The staircase problem with 1/2/3 hops. This is the same as fibonacci with 3 numbers in the sequences, and the 3 exit conditions in order are 1/2/4. Remember these get much faster with a cache. Check if n is in the cache, and only recurse if it's not.
- https://www.hackerrank.com/challenges/recursive-digit-sum/problem. Easy. Recurse.
- https://www.hackerrank.com/challenges/crossword-puzzle/problem. Thought about it for about 20min, but then didn't take the time to solve. A very straightforward problem, but tedious. This is like a simpler version of the 5squared puzzle I've solved (programmatically).
- https://www.hackerrank.com/challenges/balanced-brackets/problem. Easy. Just run a stack for open/close. Few small corner cases.
- https://www.hackerrank.com/challenges/ctci-queue-using-two-stacks/problem. Lol what a silly question. Just implement the methods of a queue using a python list, enqueue/dequeue/peek.
- https://www.hackerrank.com/challenges/largest-rectangle/problem. Same as the leetcode one. Use two pointers coming in from both sides.
- 11 left. Will do tomorrow.
- XOR of two integers is just the XOR of the bit representations of the integers. In python ^ is the operator for XOR. For example, 2 ^ 1 = 3.
- In python it's set.add vs list.append.
- In python sets are implemented with hash tables, so lookup is basically the same as a dict (extremely fast).
Saturday, January 4, 2020
- Practice problems.
- https://www.hackerrank.com/challenges/ctci-bubble-sort/problem. Just implement a bubble sort. One loop through n-1, check if bigger than next, swap if so. Then simply wrap the whole thing in a blind loop to run n times, which guarantees it'll be sorted when finished.
- https://www.hackerrank.com/challenges/mark-and-toys/problem. Basic sort.
- https://www.hackerrank.com/challenges/ctci-comparator-sorting/problem. Write a comparator method of a class. Pass two objects, do whatever logic, then return -1 if obj1 goes before obj2 or 1 if opposite. Then you can pass the Class.comparator function as a key to a sort call, or whatever.
- https://www.hackerrank.com/challenges/fraudulent-activity-notifications/problem. Tougher, but I really enjoyed this one. Success rate was low, in the 30s. Sliding window for median, remember you can access it by index (middle if n odd, (middle + middle-1) if n even). To remove/insert in the sliding window, use the bisect module for speed.
- https://www.hackerrank.com/challenges/ctci-merge-sort/problem. Brainstormed this one for about 30m and then chose not to implement. The question is basically "write you own merge sort". O(nlogn). This allows you to count the inversions. No thanks.
- https://www.hackerrank.com/challenges/ctci-making-anagrams/problem. Simple. My solution was cool.
- https://www.hackerrank.com/challenges/alternating-characters/problem. The easy ones are easy.
- https://www.hackerrank.com/challenges/sherlock-and-valid-string/problem. Little more complicated, but in syntax. Nothing algorithmically special here.
- https://www.hackerrank.com/challenges/special-palindrome-again/problem. Tired of palindromes. I don't like these problems.
- https://www.hackerrank.com/challenges/common-child/problem. Didn't care to do this one either. Don't like longest common subsequence problems. Remember the table of 1s and 0s, slowly sum as you move down and right.
- https://www.hackerrank.com/challenges/minimum-absolute-difference-in-an-array/problem. Nice change of pace. GREEDY algorithms. If you find yourself facing a quadratic solution, just sort! See if that helps.
- https://www.hackerrank.com/challenges/luck-balance/problem. Simple.
- https://www.hackerrank.com/challenges/greedy-florist/problem. Solved, but dumb question. It's worded very ambiguously, and I had to modify the footer because the main function was completely missing a required argument (first time I've seen this on hackerrank).
- https://www.hackerrank.com/challenges/angry-children/problem. Easy. Fast. Don't forget outside of this section; consider a sort!
- https://www.hackerrank.com/challenges/reverse-shuffle-merge/problem. Not gonna touch this one. Not worth my time, since it's limited. Trying to understand the problem description alone took 10 minutes.
- https://www.hackerrank.com/challenges/ctci-ice-cream-parlor/problem. Find a pair within 1d array, so iterate through it once, build a complement map.
- https://www.hackerrank.com/challenges/swap-nodes-algo/problem. Didn't do. This question takes 30 minutes to read.
- https://www.hackerrank.com/challenges/triple-sum/problem. One you have to think about, doesn't fit a standard pattern. Solve an easy case and you'll see you're best off approaching along a specific dimension (q).
- https://www.hackerrank.com/challenges/minimum-time-required/problem. An interesting one as well. Basically implement your own binary search. Find best and worst case for lower and upper bounds, bisect them, calc the result, then shift one bound depending upon what the produced value is. Put this all in a loop `while lower_bound < upper_bound`.
- https://www.hackerrank.com/challenges/maximum-subarray-sum/problem. <30% solve rate. Took a stab at it. Started with ~30m of whiteboarding. Reached the conclusion that the module of the sum is the modulo of (the sum of the modulos of the individuals). This is the key piece.
- https://www.hackerrank.com/challenges/making-candies/problem. Not really a search problem, just walk through the simulation. My solution was the right complexity (passed 35/49 tests), just needed smaller optimizations here and there.
- https://www.hackerrank.com/challenges/flipping-bits/problem. "Flipping bits" is just subtracting from the max size. So if you flip bits on a 32bit unsigned integer x, the result is 2^32-1-x.
- https://www.hackerrank.com/challenges/ctci-big-o/problem. Check if a number is prime. To do so, iterate only over odd numbers (because even divides by 2), and only up to square root of x. Every pair of factors, if it exists, has one number below the sqrt and one above, so you only need to check up to the integer at floor(sqrt(x)).
- Only 30 problems left. The average difficulty is a little on the easier side, too. The hardest is like 40% pass rate. I'll try to do most tomorrow so that I can focus on the open-ended questions monday. Behavioral, design, etc.
- To switch two items in an array in python in one operation, just do:
- list[index1], list[index2] = list[index2], list[index1]
- Instead of doing quotient = math.floor(num/den) and rem = num % den, get both with quotient, rem = divmod(num, den).
- Oh shit. You can also get the quotient directly with // in py3. 11 // 2 results in 5. Don't need math.floor everywhere.
- If n is given for a problem to be 10^9, you probably need a linear solution. If 10^5, try to find an nlogn algorithm. If 10^4, quadratic is ok.
- Red-black trees are colored to preserve balance.
- Push, meditate.
- Ordered more preferred stock.
- AFC playoffs. Texans and Titans moving on.
- Supercontest. Disabled the emailer during the offseason.
- The machine was out of disk space, so I sshed in and ran docker system prune -af to free up 17.89GB. Remember to create the network and restart the nginx-proxy containers as well after this operation.
Friday, January 3, 2020
- Took the BMW online test. 8 questions. Each was a 1-3m video recording of my answer.
- All had unlimited time to think - I was kinda hoping they'd be restricted in time and in #takes (could shine more I guess).
- The whole test was java heavy.
- JDK/JRE/JVM. Generics.
- Creational design patterns. Prototype, factory, singleton.
- JEE APIs. JavaMail - like flask-mail. Persistence - like sqlalchemy. Security API - like flask-user and flask-admin.
- Join differences.
- I know these, just typing out for refresher:
- Inner. Normal, condition matches in both tables.
- Left. Return the full left table with matching records from the right, and null otherwise.
- Right. Return the full right table with matching records from the left, and null otherwise.
- Full. Return both left and right (basically stitch both tables together and fill null with nothing).
- Good summary: http://www.sql-join.com/sql-join-types.
- Flash will not be supported on chrome at the end of 2020. I'm still amazed Amazon's conference room requires it.
- Apple TV+, Disney+, Hulu, Showtime, HBO, Netflix, Peacock (NBC) coming soon.
- Smoked a pork shoulder. Handpressed tacos with maseca.
- Cooked a couple pounds of garbanzo beans.
- Turns out that the IR lamp in the terrarium isn't dead, I simply had the outlet disabled.
- Supercontest.
- Had to decide to implement an offseason explicitly or simply extend week 17 to last through the remainder of the year. The latter is much easier, so I did that. The former bleeds into g.current_week, current_season, and downstream into is_paid_user, leagues, and much more. It's more proper, but much more complicated and unnecessary at this point. If I need an offseason-specific view in the future, I can add this.
- Fixed and deployed.
- Practice problems.
- Whiteboard most of these. Transferred to computer to check syntax.
- Another thing above leetcode that's superior to hackerrank: it reports time and mem usage, as well as your percentile.
- https://www.hackerrank.com/challenges/counting-valleys/problem.
- https://www.hackerrank.com/challenges/jumping-on-the-clouds/problem.
- https://www.hackerrank.com/challenges/repeated-string/problem.
- https://www.hackerrank.com/challenges/2d-array/problem.
- https://www.hackerrank.com/challenges/ctci-array-left-rotation/problem.
- https://www.hackerrank.com/challenges/new-year-chaos/problem. This was started to get a little tougher. Write down a few simple cases, reason through the logic.
- https://www.hackerrank.com/challenges/minimum-swaps-2/problem. This one is dumb. Hacker rank has some pretty misleading/bad questions.
- https://www.hackerrank.com/challenges/crush/problem.
- Sometimes a problem has two dimensions that you can iterate over, say N and M, and it’s worth putting an IF statement in your whole algorithm to dictate which you do.
- https://www.hackerrank.com/challenges/ctci-ransom-note/problem. Remember hash tables are faster lookup than arrays. If you’re going to access more than once later, it’s usually worth iterating over the array a single time creating a dict with word counts, and then accessing that later, rather than finding the word in the original array.
- https://www.hackerrank.com/challenges/two-strings/problem. Hash for lookup speed!
- https://www.hackerrank.com/challenges/sherlock-and-anagrams/problem. Dumb questions. Worded with zero clarity. Accepts a brute force O(n!) solution, but indicates nothing of such constraints.
- https://www.hackerrank.com/challenges/count-triplets-1/problem. Remember remember. For COUNTING problems, your gut should tell you to use a hashtable for fast lookup. I got a general solution that passed most the tests, but the final answer that passes all is VERY elegant. Was cool to read.
- https://www.hackerrank.com/challenges/frequency-queries/problem. Crushed it. Defaultdicts, tested with int, list, and dict. Kinda cool to have a defaultdict whose default is a nested dict.
- Went through the 4 basic "approach" videos as well: https://www.hackerrank.com/interview/interview-preparation-kit/tips-and-guidelines/videos.
- A factorial multiplies each integer's product, but in some cases for combinations you need to add them, like the sum of all integers from n to 1. This is called the binomial coefficient, and it's n(n+1)/2. It always yields an integer. This comes up in regular life way more often than you might think; pay attention for it.
- In python, collections.defaultdict(int) will make the default zero. Similarly, (list) will make the default an empty list. This is very useful to avoid the annoying "check if key exists, append if so, create if not" clauses.
- defaultdict is a little faster than Counter, as well.
Thursday, January 2, 2020
- Double Irish, Dutch Sandwich = some big companies avoid taxes by shifting money overseas to irish/dutch subsidiaries. Google has done this with over 20 billion annually since 2017, tax free.
- A JIT compiler is close to a regular old interpreter, in that both execute at runtime. The one difference is that the compiler will still compile the code all the way down to machine language. An interpreter usually runs the code directly or some middleground (like python's bytecode pyc).
- Python has one called Numba, which tries to compile everything down to c. This gives you nice warnings for situations where you might be doing something python-specific (like a dynamic array with ints and strings) which can't compile.
- Numba also gives you the ability to write python code which executes almost as fast as c. Very useful for compute-intense tasks.
- Current portfolio shot up to an easy 52wk high. My return so far: 23.5% in 6wks. S&P500 rose ~3.5% in the same time frame. +20 alpha, even in this weirdly bullish time.
- Fresh order.
- Backed the puzzle.
- Turned the soil in the terrarium to keep fresh, need to replace after move.
- Watched Winchester. Shiv from succession is in it.
- In order to enter the amazon chatroom, I had to install flash player and enable. Huge no-no.
- Add the canonical repository. Apt install.
- Within chrome, change to "ask" instead of "block all flash" - annoying.
- Ultimately got in at 12:30, not 12. Will have to join next week.
- Whiteboard arrived. Practiced a few problems handwritten instead of typed.
- Due to all the problems with internal political activism, google has banned politics at work: https://medium.com/enrique-dans/suddenly-at-google-its-get-on-the-program-or-get-out-5ce19930f554.
- Brainstormed open-ended answers to the generic question "how could you speed this up?" Got 12 good ones so far.
- Armin Ronacher's open-source group is call pocoo. Sphinx, flask/werkzeug/jinja, click.
- His blog: https://lucumr.pocoo.org/. Posts erratically, maybe 1/mo average.
- Remember jupyter is convenient for early development. Say you're writing a script/module for the first time. The notebook gives you the editor/ide to build the script AND the terminal to run the script all in one. Check outputs, inspect vars, etc. Bonus: you can add text/plots/documentation as well.
- Started the garbanzo bean soak for tomorrow. Probably won't make hummus, just keep as a side for the smoked meat.
- Made sushi. Rice, seaweed, tuna, hot sauce. Slowly clearing out the random kitchen items for the move.
- Cleaned the kitchen, getting rid of ~8 old pots/pans/lids.
- BMW set up an interview.
- Sparkhire is an online video interview platform.
- Submitted. Was allowed to record responses to questions. Time-limited.
- Bought sirloin steak and a pork butt. Brined.
- Vons has way worse meat than costco. Twice the price, half the quality.
- The pork shoulder was bloody (had been frozen) and didn't smell nearly fresh.
- Cleaned and reseasoned the old cast iron pan.
- Steamed crab, panfried sirloin, baked potato, asparagus.
- Redeemed Eric's christmas lotto tickets. Paid $5 total, won $15 total.
- Pull.
- Settled up the big bear trip in splitwise, $320.
- Bootstrap headings, bold and opinionated: display-1 through display-4.
- Supercontest.
- Handled the offseason ticket.
- Investigated. Found 7 issues.
- The standard disweb dashflo shard for widgetbot is broken again. I'm not going to touch it again until next year, and hope they stabilize their DOS issues by then.
- Fixed 2 of the 7 issues, will finish the rest tomorrow.
Wednesday, January 1, 2020
- Interesting. Would have expected more:
- Pure function = doesn't affect any global state, a call can be swapped out for its result without effect.
- Home from big bear nye/beans. 2020.
- Practice problems:
- https://leetcode.com/problems/remove-element/submissions/. Another delete-in-place, constant memory problem. While loop, use your own index, del that val or increment. This allows in-place, because you're not iterating over the array while you modify it; you're iterating under your own volition and then simply accessing the array by index as needed.
- https://leetcode.com/problems/implement-strstr. Find index of substr. Not as simple as keep a running total, you have to do it for (possibly) n times, because a new instance of the match might begin WITHIN another search. Think mississippi, looking for issip - can't fail after the first one because the actual answer starts DURING it. Instead of iterating over the haystack char by char, check the whole needle with each matching first char.
- https://leetcode.com/problems/divide-two-integers/. This one was a nice change. Write a divide function without using mult, abs, etc. You basically have to loop and treat all multiplications as additions, then use comparators for less/greater than. It's constant in time and space, at whatever number the max size the integers can be (2^32).
- https://leetcode.com/problems/substring-with-concatenation-of-all-words. Sliding windows. Reduce the problem from words to chars, then simply find permutations.
- https://www.hackerrank.com/challenges/sock-merchant/problem.
- I like hackerrank's organization of different problems into groups (these are recursion, dp, dicts, sorting, searching, etc). But it's still terrible in that function input/output is by FILE. It clutters up your solution space.
- Man I love data:

- (bool func 1) != (bool func 2) is XOR in python. Makes clean one-liners.
- Checked supercontest.
- The end of 2019 week 17 was at 5pm. Throughout the season I put in handlers to disable picking, show passive data, etc in the offseason. I never tested it.
- There are a few small bugs. I'll hit them tomorrow. Created the ticket. https://gitlab.com/bmahlstedt-group/supercontest/issues/141.
- Remember float('inf') in python.
- Haven't checked zyme in a while, but up to ~45.50.
- https://leetcode.com/problems/merge-two-sorted-lists.
- It's often more convenient to make the recursive call within the function, not in the return clause. Often you want to manipulate the data, or append to the list, or do something before returning the specifics.
- https://leetcode.com/problems/merge-k-sorted-lists. first_iter = True useful in recursion also.
- https://leetcode.com/problems/generate-parentheses. Create all exponential (2^n) permutations, then run verification on them.
- https://leetcode.com/problems/swap-nodes-in-pairs/. Reversing pointer pairs in a linked list. Can't modify values.
- https://leetcode.com/problems/reverse-nodes-in-k-group/. Same, but with general k instead of k=2, alternating every pair.
- https://leetcode.com/problems/remove-duplicates-from-sorted-array/. In-place deduplication in a sorted (thankfully) array. Can't create secondary array, must be constant space complexity.
Monday, December 30, 2019
- Hash tables high space fast speed.
- S&P has almost quintupled since the low of the 08-09 crisis.
- I know the # in a URL, but its formal name is anchor or fragment identifier, the subsection to focus to.
- Escape room up in Big Bear.
- Among the bay friends, final percentages and rankings were:
- frank 58.8
- nick 58.8
- david 57.1
- quique 56.0
- art 55.9
- diego 55.7
- brian 51.2
- omar 47.5
- Approximate payouts:
- 1st $730
- 2nd $325
- 3rd $180
- 4th $140
- 5th $115
- 6th $90
- 7th $80
- 8th $70
- 9th $60
- 10th $50
- 1st place comparison:
- Westgate Supercontest: 59 pts, 58-2-25, 69.4%.
- South Bay Supercontest: 53 pts, 52-2-31, 62.4%
- Would have tied for 25th in the full contest.
- The 9 people who tied for 26th last year each got a payout of $14,844.65.
- Brainstormed a few more return questions.
- Practice problems:
- Improved the 2sum solution. Much faster.
- https://leetcode.com/problems/remove-nth-node-from-end-of-list.
- https://leetcode.com/problems/3sum. 3 sum solution, got it down to O(n^2). Basically solving n 2sum problems.
- There's another one "3SumClosest" where instead of summing to 0, you're finding the triplet that sums closest to an input target. Instead of keeping matches, keep ALL in a hash table then just return the max. Same O(n^2).
- Another: https://leetcode.com/problems/4sum/. 4sum is the same, just wrap the 3sum solution with another loop around n, the input list. It doesn't matter if you're targeting zero or another explicit number with the sum. The general algo is O(n^(k-1)), where k is the number of items in the sum.
- https://leetcode.com/problems/valid-parentheses. Just tracking opening and closing characters. Easy. Use a stack, loop through once.
Sunday, December 29, 2019
- M Night Shyamalan's Servant is pretty good.
- Paid Jan rent, full.
- Called Grayson for his 5th.
- CFB national championship is gonna be LSU Clemson.
- MapReduce used to be pretty popular for big data; take a large problem and split it into tasks for a distributed system (map) and then recombine them logically after whatever operations have been performed (reduce).
- Practice problems:
- https://leetcode.com/problems/longest-common-prefix/. Easy.
- Started the array-sum problems. 2sum, 3sum, 4sum, and variations. Will finish later.
- Drove to big bear for NYE/brobeans.
- Petty 1st place sbsc lol (62.4%). I finished the season at 51.2%, better than last year at 45.9.
- Niners beat the seahawks, 1st place NFC.
- A few requests were deadlocked. It can self-detect, and sentry notifies. Could restart, or just wait for nginx to kill the thread workers.
Saturday, December 28, 2019
- Practice leetcode problems.
- https://leetcode.com/problems/string-to-integer-atoi. Nothing specially really, just checking lot of corner cases.
- https://leetcode.com/problems/palindrome-number. Very easy.
- https://leetcode.com/problems/regular-expression-matching/. They need to be clearer than the wildcard will only be in the second position. I was about to program the true way to do it.
- https://leetcode.com/problems/container-with-most-water. Nailed this one.
- https://leetcode.com/problems/roman-to-integer/. Easy. Remember, while loops allow you to iterate in desynced fashion, which is common (rather than just `for ind, item in enumerate(array):`. A while loop allows you to jump around in the array, skip 2 items, control your own index for each step, etc. This occurs pretty frequently in logic problems.
- https://leetcode.com/problems/integer-to-roman. More roman numerals!
- Went back over the leadership principles, making examples and memorizing each.
- Watched the second season of You. Loved how much they made fun of LA actors.
- Remember python's compound operators. You use += but you can did it with basically everything else, like *= or %= (modulo then define). They're all the same as x = x * 5, with whatever operator and number you need.
Friday, December 27, 2019
- Transcrypt is a python/js compiler. https://www.transcrypt.org/. You can put python in your html, javascript in your backend, etc. Weird.
- The vip terminal at lax costs about 5k/yr for membership and >3k/flight. https://theprivatesuite.com/.
- Bought a straightener. The boar's hair brush works a bit better for shorter beards. Needs to be ~2" for this to shine.
- Nasdaq index is mostly tech focused (unlike dj/spy).
- Hit up spencer, bonus alex is visiting la in a couple days.
- Skipped amazon fresh and buying/brining/smoking meat, gonna be in big bear for the next half week.
- Made this:
- Added phil and raj to the paid league.
- select * from users where email like '%WORD%';
- insert into league_user_association values (<league_id>, <user_id>);
- Coke has the same acidity as lemon juice.
- Run pull sauna meditate.
- 1000p motorcycle puzzle. 4hrs maybe?
- The coriolis effect causes large-scale fluids (eg oceans/hurricanes, not toilets/baths) to rotate clockwise in the southern hemisphere and counterclockwise in the northern hemisphere (closer to equator = moving faster).
- Lynch definitely running for seahawks on sunday. Awesome. AB is apparently working on signing with the saints as well. Terrible. Man needs mental help.
Thursday, December 26, 2019
- Placed some small limit orders for option calls. They didn't execute.
- Eric got me the athleanx inferno size program, started looking through the website.
- Supercontest.
- Odds:
- 0: 1/32
- 1: 5/32
- 2: 10/32
- 3: 10/32
- 4: 5/32
- 5: 1/32
- Obviously a coin flip is a binomial distribution, just like a dice roll. As n gets large, this approximates Gaussian (normal).
- Standard deviation of coin flip = 1/(2*sqrt(n))
- Created ticket: https://gitlab.com/bmahlstedt-group/supercontest/issues/140.
- Push sauna meditate.
- Scheduled amazon onsite for mon jan 13.
- Flew SFO LAX.
- Ashish called about the NCL telem site.
Wednesday, December 25, 2019
- Committed lines, submitted picks.
- Final week 17, we'll know the season winner on Sunday.
- This week was a pain in the ass. The iframe table format was completely different for the lines. Different order, different column, etc. The autofetcher didn't know how to understand any of it. I entered the lines manually.
- [[u'TITANS', u'TEXANS*', u'SUNDAY, DECEMBER 29, 2019 1:25 PM', u'3.5'], [u'BROWNS', u'BENGALS*', u'SUNDAY, DECEMBER 29, 2019 10:00 AM', u'2.5'], [u'VIKINGS*', u'BEARS', u'SUNDAY, DECEMBER 29, 2019 10:00 AM', u'1'], [u'COLTS', u'JAGUARS*', u'SUNDAY, DECEMBER 29, 2019 1:25 PM', u'3.5'], [u'FALCONS', u'BUCCANEERS*', u'SUNDAY, DECEMBER 29, 2019 10:00 AM', u'0'], [u'COWBOYS*', u'REDSKINS', u'SUNDAY, DECEMBER 29, 2019 1:25 PM', u'11'], [u'SAINTS', u'PANTHERS*', u'SUNDAY, DECEMBER 29, 2019 10:00 AM', u'13'], [u'EAGLES', u'GIANTS*', u'SUNDAY, DECEMBER 29, 2019 1:25 PM', u'4.5'], [u'STEELERS', u'RAVENS*', u'SUNDAY, DECEMBER 29, 2019 1:25 PM', u'2'], [u'BILLS*', u'JETS', u'SUNDAY, DECEMBER 29, 2019 10:00 AM', u'1.5'], [u'PATRIOTS*', u'DOLPHINS', u'SUNDAY, DECEMBER 29, 2019 10:00 AM', u'15.5'], [u'PACKERS', u'LIONS*', u'SUNDAY, DECEMBER 29, 2019 10:00 AM', u'12.5'], [u'CHIEFS*', u'CHARGERS', u'SUNDAY, DECEMBER 29, 2019 10:00 AM', u'8.5'], [u'RAMS*', u'CARDINALS', u'SUNDAY, DECEMBER 29, 2019 1:25 PM', u'3'], [u'49ERS', u'SEAHAWKS*', u'SUNDAY, DECEMBER 29, 2019 5:20 PM', u'3.5'], [u'BRONCOS*', u'RAIDERS', u'SUNDAY, DECEMBER 29, 2019 1:25 PM', u'3']]
- dbsession.commits._commit_lines(week_id=34, lines=lines)
- core.scores.commit_scores()
- util.email.email_picks_open(season=2019, week=17)
Tuesday, December 24, 2019
- Happy Hollow Park/Zoo in San Jose.
- LAMP = linux apache mysql php. I always forget this one. It's old.
- Rivian, big ev company.
- Power rankings (nfl and espn) have the niners 3rd after the saints and ravens.
- FF ESPN: 5-7. 11/12 PF. 11/12 final rank.
- FF Yahoo: 5-8. 7/10 PF. 10/10 final rank.
- Worked with amazon to schedule the date of the onsite. Suggested the second week of Jan.
- Went over their documentation of the onsite process: https://www.amazon.jobs/en/landing_pages/in-person-interview.
- Confirmed the citadel coding challenge for Jan 7.
- Ordered a whiteboard ($18) to practice. My old one was stained/dry.
- STAR = situation task action result.
Monday, December 23, 2019
- Received results for the amazon coding test, passed, got invited for a day of onsites.
- Markets.
- Boeing fired their CEO.
- S&P up 3.5% in the past month. Record highs. Such a strange time, with every indicator shouting bear years ago.
- Pivotal went public last year, 2018-04-20. Earnings tomorrow.
- TSLA hit $420, and rising. People are so weird.
- More practice problems. Mostly leetcode.
- Getting better and faster with every one.
- Writing out a couple BASIC examples of the iteration/recursion, like the first two loops/stacks, is extremely helpful for developing the algorithm. Makes it much easier to extrapolate if the whole problem is too complex to wrap your head around in code or thought.
- Reversing an array is obviously O(n). Same for linked list.
- When you see a problem that expects a logn solution, expect something like a binary search where you're halving the problem space each time.
- Started looking on redfin. 1-2br, 1bath, garage, $1m. There are some options in places like south city, rwc, epa, santa clara.
- Marshawn Lynch might play for the seahawks next week against us. So conflicted.
- Lunch at little lucca's. They were out of dutch crunch.
- Updated the banner so I wouldn't have to on christmas. Redeployed.
- German bar with all the kids from the block.
Sunday, December 22, 2019
- Did some leetcode problems to practice.
- When doing something with only two elements (like check to see which two items in an array add to a target sum), you might be tempted to check the permutations of the remaining array, with each iteration. This is not the fastest. You can get it down to O(n) time by storing a complement map as you move through the array, then you can compare each to the complements to see if it fits.
- Pretty much finished all my specific prep for interviews. Now it's just going through the generic problem repositories, practicing a few each day:
- Hackerrank. Leetcode. Careercup (CtCI). Glassdoor. Youtube.
- So far I think I like leetcode the best.
- 5 directly-interview-relevant docs in gdrive. 1 for general process/approach, and then 4 from book notes:
- Structure and Interpretation of Computer Programs, Algorithms and Data Structures, Programming Interviews Exposed, Cracking the Coding Interview.
- Reminder of great youtube channel for interview questions: https://www.youtube.com/channel/UCNc-Wa_ZNBAGzFkYbAHw9eg/videos.
- Alpha = how much you outperform a generic benchmark, usually the S&P500. If that rises 5% in a year and you rose 15%, your alpha is +10.
- Beta = how much more volatile than a generic benchmark. If your stock gained 3% in a day and the S&P500 lost 1%, your beta is -3.
- Manacher's algorithm is O(n) for longest palindromic substring: https://en.wikipedia.org/wiki/Longest_palindromic_substring. Fantastic.
- Longest common subsequence = a common problem. Look it up.
- When palindromes are mentioned, you can reverse the string and then it becomes a longest common subsequence problem (check indices tho).
- An 8yr youtuber who reviews toys made $26m last year.
- Helped dad backup/update his iphone 6.
- Did the amazon coding interview (90m). Each question basically has 20 unittests, 2 of which are shown and 18 are hidden.
- On the practice exam, I got 20/20 and 20/20, and finished in 35m.
- On the real exam, I got 19/20 and 2/20, and finished in 90m. The first one was good, but something was up with the second one. It passed both visible testcases and then showed "passed 0 of 18 for the invisible testcases" - not sure what happened, but my program was correct so who knows.
- Was also possible to have another computer googling the problems and copying the answers. I did it honestly, so I worry about the bar I'll be compared to. I much prefer a voice/video call, for both authenticity and the ability to prove comprehension verbally.
- Went to sunnyvale, madras and fam.
Saturday, December 21, 2019
- Walked 4 miles around Atherton.
- Chan Sung Jung knocked out Frankie Edgar (38), and now there isn't an event for the next 4 weeks until McGregor Cerrone.
- All presents wrapped and ready. Dec 21st. World record.
- SCORE_DAYS was the nominal th/sun/mon. I had to add saturday for these week 16 games. Deployed the supercontest change. Recompiled reqs.
- Did a few hackerrank problems:
- https://www.hackerrank.com/challenges/tree-height-of-a-binary-tree.
- https://www.hackerrank.com/challenges/tree-level-order-traversal.
- https://www.hackerrank.com/challenges/balanced-brackets.
- https://www.hackerrank.com/challenges/contacts.
- https://www.hackerrank.com/challenges/find-the-running-median.
- Side note: hackerrank has a terrible problemsolving interface. The inputs are given via stdin with line separations lol, and the outputs are compared to stdout. This is probably laziness to accommodate multiple languages, but it's shrouded and detracting.
- The difficulty is also widely variant. I finished some "medium" level questions in (literally) 60 seconds, and some "easy" questions took my 20 minutes to read the problem statement and 40m to answer.
- Some complexity notes.
- Recursion with 2 recursive calls is exponential in time complexity.
- Binary trees require 2 recursive calls to traverse, one to walk the left edge and one for the right.
- Fibonacci sequences require two recursive calls as well, but you can memoize each one to reduce it from exponential to linear.
- For iteration problems, usually just run a while loop and add items to array, or do something else to keep track as you traverse.
Friday, December 20, 2019
- There are so many python dep managers out there now, like my sx-setuptools. Poetry: https://github.com/python-poetry/poetry.
- Awesome js recap: https://2019.stateofjs.com/. Typescript/express/react/redux/graphql still king. Jasmine is no where near the top for testing frameworks (jest is #1).
- Ear buds died. Ordered 2 more. I still continue to be impressed. Great quality, people around can't hear, only $7.
- I always forget amortization: pay off periodically.
- Permutations > combinations. Combos don't care about order.
- Finished CtCI. Went through some of the problems.
- Flew LAX -> SFO.
Subscribe to:
Posts (Atom)

