Monday, January 18, 2021

Learning Environment

 Learn in a relaxed environment. The best recall occurs when brainwave patterns show a relaxed state.

Learn in a multi-sensory environment by involving visual, auditory and kinesthetic activities.

Use color! This stimulates the right brain and helps recall.

Make sure you take breaks every hour.

Try to relate what you are learning to a bigger picture.

Reinforce what you have learned through practice and review.

Saturday, January 16, 2021

Remove whitespace from file names in Unix/Mac

 Go to the folder where the files are located and run:

for f in *; do mv "$f" `echo $f | tr ' ' '_'`; done

Thursday, January 14, 2021

Upload File to S3

 require 'aws-sdk-s3'  # v2: require 'aws-sdk'



REGION_ID = "us-east-1"

BUCKET_NAME = "bucket-name"

def uploadS3

  credentials =




  s3 =

                          region: REGION_ID,

                          credentials: credentials



  #Upload export/, export/

  for file_name in ['', '']

    name = File.join('export', file_name)

    # Upload, 'rb') do |file|

      puts "start uploading #{file_name} to s3"

      resp = s3.put_object(bucket: BUCKET_NAME, acl: "public-read", key: file_name, body: file)

      puts resp


    puts "File should be available at https://#{BUCKET_NAME}{file_name}"



Thursday, January 07, 2021

Law of Success

  1. Fall in love with the process.
  2. Do it every single day.
  3. Celebrate your commitment.
  4. Track your metrics and data.
  5. Master your craft.

Tommy Baker. “The 1% Rule: How to Fall in Love with the Process and Achieve Your Wildest Dreams.” 

Wednesday, January 06, 2021

Live Coding 175 Session Recordings Now Available

We have now over 175+ live coding recordings for Leetcode live coding sessions. That is over 200 hours of discussions on coding problems. We are a group of developers preparing for FANG interviews. We meet everyday and work collaboratively on solving one medium Leetcode problem via Zoom.

This is NOT a study group. We flip the classroom. You study whatever resources you find useful before the meeting. We only focus on PRACTICE and FEEDBACK during the Zoom calls. We share tips and the peer to peer learning has worked really well so far.

I started the daily live coding sessions on July 25th, 2020. I have learned in just two months as much as I have learned in one year when I was studying and practicing by myself. Members requested me to record the sessions so they can watch any sessions that they miss.

We don't rush into coding. We analyze the problem, create a model of the problem and use the model to answer questions. We then brainstorm alternate approaches to solve the problem starting with brute-force and eventually code the optimal solution by the end of the session.

This is not passive learning like watching videos. The paid courses ask you to pause the video and think. But no one teaches how to think and ask questions to solve problem from scratch. We code the solution to problems from scratch.

Our group hates memorizing and we focus on gaining deep understanding of the concepts. Join Leetcode Live Coding Telegram group:

You will also get access to the Zoom cloud recordings. You will develop insights on how to approach coding problems and you don't have to memorize anything. You will learn how visualizing the key aspects of well known algorithms can make it easier to understand the algorithms at a deeper level. 

Tuesday, January 05, 2021

Topic Wise or Random Practice ?

 Topic wise practice if fine when you are learning the basics of data structures and algorithms. You basically can be operating in either Learning Mode or Practice Mode. When you are in learning mode, it's ok to practice by topic otherwise you should not be practicing by topic. Because, you have to develop the ability to recognize what data structure and algorithm to use just like a real interview.

Leetcode Live Coding Thread Discussion Link

Thursday, December 31, 2020

Optimal Algorithm for a Problem

 “The ultimate goal in designing algorithms and data structures is to find an optimal algorithm for a problem, that is, an algorithm whose worst-case runtime complexity matches the intrinsic complexity of the problem it solves.”

Martin Erwig. “Once Upon an Algorithm: How Stories Explain Computing.” 

Problem Simplification

 “Problem simplification is often a crucial step toward solving a problem.”

Martin Erwig. “Once Upon an Algorithm: How Stories Explain Computing.” 

Relationship Between the Complexity of the Problem and Solution

 The distinction between the complexity of a problem and the complexity of its solutions helps us understand the notion of an optimal solution.

 Martin Erwig. “Once Upon an Algorithm: How Stories Explain Computing.” 


 In this case, even if the sorting takes linearithmic time, it is worth the effort, since it saves precious class time. This is an example of precomputing, where some data needed for an algorithm is computed before the algorithm is executed.

“This strategy of computing information ahead of time is called precomputation.”

“The crucial aspect of precomputation is that computational effort is expended at one time and the computed result is used at a later time. The precomputed result is preserved in a data structure”

“Situations in which one can expect to make use of a data structure repeatedly provide a strong incentive to expend the precomputing effort because the cost can be amortized over several uses.”

“ There are many situations, however, when it’s not clear whether the precomputation effort will pay off.”

“In cases like these, the value of acting early, or precomputing, is called into question by uncertainty about the future. Since the benefit of precomputation depends on a specific outcome of future events, it reflects a rather optimistic computation attitude with a confident outlook on the future.”

“A skeptical attitude toward the future calls for a radically different strategy for scheduling computation, namely, a strategy that tries to delay costly operations as much as possible until they cannot be avoided anymore. The hope or expectation is that something might happen that makes the costly operation obsolete and thus saves its runtime (and potentially other resources). In real life this behavior would be called procrastination; in computer science it is called lazy evaluation. ”

“Lazy evaluation can save computation effort whenever the information that would have been obtained by the saved computation is not needed anymore.”

“While lazy evaluation seems attractive in its promise to not waste effort, it is problematic when an action that becomes unavoidable takes longer than it would have under precomputing, or worse, longer than there is time available. In particular, when several delayed actions become due at the same time, this might present a serious resource problem. Therefore, an overall more sensible strategy is to distribute work evenly over time. While this might waste some effort on precomputing, it avoids crises that a lazy evaluation strategy might bring on.”

Martin Erwig. “Once Upon an Algorithm: How Stories Explain Computing.”