Skip to content

Latest commit

 

History

History
91 lines (64 loc) · 6.72 KB

Notes.md

File metadata and controls

91 lines (64 loc) · 6.72 KB

This is a note of the various things related to competitive programming / doing interviews that I've gathered so far.

Things to do

Useful resources

LeetCode & co.

System Design

Interview

Helpful point

For prep i used 3 paid resources.

  • Coding ninjas (Started here, and i would still start here, considering the 24*7 doubt support )
  • Algoexpert ( Good question set)
  • LC Premium (Used for assessments)

See also buildyourownx GitHub profile which is great.

Ref: My Salary For the past 7 years. From 3.5 LPA , to 4L per month (Excluding Stocks) : r/developersIndia

Helpful advice about changing lifestyle

A good twitter thread that deeply resonates with me: Akshaya Sivaraman on Twitter: "How did I go from a busily scheduled life to one with substantial unstructured time?

Misc. notes

Hashtable / HashMap

  • Initial capacity and load factor affect the performance of hash table / map.
  • It is open: in the case of a "hash collision", a single bucket stores multiple entries.
  • Iterators returned by "collection view methods" are fail-fast: i.e., they throw ConcurrentModificationException if they detect a concurrent modification of the underlying hashtable. This is not fool-proof / guaranteed. So, implementations should not depend on the same.
  • Hashtable is synchronized. HashMap is not. For thread safe usage, a ConcurrentHashMap is recommended.

References

Solving algorithmic problems

7 Steps to Solve Algorithm Problems

  1. Listen - Listen carefully to the problem. Every detail is necessary to solve that problem.
  2. Example - Come up with a good example. Make examples larger and avoid special cases.
  3. Come up with a brute-force algorithm - It's better to start off with a slow and terrible algorithm than to start of with nothing at all. Don't code the brute-force algorithm. Just state the brute-force algorithm and it's runtime and then go into optimizing it.
  4. Optimize
  5. Walk through your algorithm - Don't code prematurely. Take a step back and verify that the algorithm is correct.
  6. Start coding - For whiteboard: write the line straight, use space wisely; Whiteboard or computer: coding style matters, consistent coding style, naming is important for good style (ask the interviewer if you could abbreviate them the next time), MODULARIZE
  7. Start testing - analyse, double check things that look weird/risky, small test first, special cases next and if time permits large test cases. Remember: Think as you test. Don't go through the code like a bot. Test your code and not the algorithm!. When you find a bug, don't panic! Give some thought about fixing the bug.

3 techniques to solving algorithm problems

  1. B.U.D - Bottleneck, Unnecessary, Duplicates - walk through the brute force (to identity bottlenecks, unnecessary and duplicated code)
  2. Space-time tradeoffs - you can almost always save some time by trading off some space. Think about Hash tables.
  3. Do it yourself - use a large generic example and try to solve it yourself. You'll identify some nice ways to optimize when solving the problem for a large test case.

Activity log

  • 18/Sep/2024 - Continue working on the optimal solution for the Two sum problem.
  • 17/Sep/2024 - Worked on the Two sum problem. Completed the brute-force solution. Was working on optimizing the solution and was reading up on HashMap / HashTable a bit.