Posts

Let's begin at the beginning

Image
One of the biggest hurdle for any newbie is the entire setup before you can say "Hello, World!" I always believed in the power of cloud, even before there was such a thing as cloud. Hence, my biggest objection to entire programming paradigm was installing an IDE (interactive development environment). Have no fear! We live in the world of cloud now. There must be myriad of places where you can code on the fly. On the phone. Right in the browser. I know of one - leetcode.com. You can choose any language you want and you can code away. Here are the easy steps. 1. Go to leetcode.com 2. Click problems. 3. Click on any problem. (I clicked "Add Two Numbers) 4. Click on "debug code in playground" (see below image) 5. Add this line 6. Run code 7. See the output from your program. Voila!! It is that simple. In 7 easy steps, you have written your first program without knowing much. Now you can save it. 8. Click on the pencil icon. ...

Linked Lists Gotchas

Linked lists in Python are strange concept. Here are some tips, tricks, and pitfalls. 1. Once you traverse it, say to print it, you have lost your ability to go back to the beginning. In other words, you can only print it once. You can not print it ever again. Unless you plan ahead to save the head. # Definition for singly-linked list. # class ListNode(object): #     def __init__(self, x): #         self.val = x #         self.next = None class Solution(object):         def mergeTwoLists(self, l1, l2):         """         :type l1: ListNode         :type l2: ListNode         :rtype: ListNode         """                 dummy_head = tail = ListNode                 dummy_l1_head = l1       ...