Home

This is essentially what a program was, a love letter from the programmer to the hardware, full of the intimate details known only to partners in an affair. Michael Marcotty

LeetCode Problems

Goal:

To become proficient in coding; a coding rockstart, by improving both on problem solving as well as coding fluency

Terms and Definitions:

Term Definition
Substring A substring is a contiguous sequence of characters within the string.
Subsequence Subsequence has order but not continuity. Similar to subarray but need not be contiguous but maintains order.
Palindrome A string is a palindrome when it reads the same backward as forward.
Kadene’s Algorithm Method to identify maximum subarray in O(N)
Subarray Subarray has order and continuity. A subarray is a contiguous part of array. An array that is inside another array. For example, consider the array [1, 2, 3, 4], There are 10 non-empty sub-arrays. The subarrays are (1), (2), (3), (4), (1,2), (2,3), (3,4), (1,2,3), (2,3,4) and (1,2,3,4). In general, for an array/string of size n, there are n*(n+1)/2 non-empty subarrays/substrings.
Subset Subset has neither order or continuity.

Approaches:

  • Spend time to think about the problem instead of trying to recollect hazy solution based on similar problem solved in the past
  • Improve thinking ability. When faced with same problem in future, one may not remember the solution and is likely to think the same way as done earlier.

Templates:

  • Divide and Conquer

    • Divide, Gather, and Combine. The work can happen either in divide phase or in the combine phase. Pay attention to the problem and accordingly pick the template.
  • Decrease and Conquer

    • The problem space can be decreased from one end or both ends. It can be decreased in one step or multi step. Array problems are typical candidates
    • Dynamic Programming is a special type of decrease and conquer
  • Transform and Conquer

    • The input can be transformed before processing to either heap or binary search tree or other forms where lookup is fast or constant. Check if the problem requires transformation. Array problems are typical candidates
  • Enhance and Conquer

  • Recursion Template

  • Backtracking

Problem Exploration:

  • Does the input contain only positive numbers?
  • What is the maximum input size?
  • Would the input contain duplicates?
  • String contains unicode or just ascii?

Edge Case Exploration:

  • For arrays, think of empty array, out of index, out of value
  • For linked list, think of empty list, last node, first node, broken list etc.

Complexity Quick Reference:

References:

Omkar’s Slides:

Interview Books:

https://www.digitalocean.com/community/conceptual%5Farticles/s-o-l-i-d-the-first-five-principles-of-object-oriented-design https://www.amazon.com/Head-First-Design-Patterns-Brain-Friendly/dp/0596007124 https://interviewing.io https://www.interviewcake.com https://docs.google.com/presentation/d/1qSOwBrjEmZTXQqNqB9XRAV7QsB6SJrLZ4pZBCkpvzyA/edit#slide=id.g1048181035e%5F0%5F37 Amazon Leadership: https://igotanoffer.com/blogs/tech/amazon-behavioral-interview#questions https://www.amazon.jobs/en/software-development-interview-prep?cmpid=ECOTOT700005B#/lessons/fxggI6Y3AxoOjvF9oKV%5Fgky-TSFACjCu Amazon Interview Meta Infrastrcuture Scribe ML Story patterns book Best Practice questions for coding Grind 75 ALgo Monster

Machine Learning resources [[https://www.youtube.com/watch?v=iVmsJJYjgNs][ Interfaces, Abstract Classes and Factory Design Pattern: https://www.amazon.com/Cracking-Coding-Interview-Programming-Questions/dp/0984782850/ref=sr%5F1%5F3?dchild=1&keywords=cracking+coding+interview&qid=1623709878&sr=8-3

Next