I'm on a mission to master programming and tackle any coding challenge that comes my way. In this series, you'll find my daily journal entries, presented as simple bullet points. Nothing fancy—just my honest thoughts and experiences from each day. So, please, no judgment! 😂
Join me as I document my tech journey in Bangalore. Let's dive in!
Day 5 (04/07/24)
As usual started off with today's LeetCode question 2181. Merge Nodes in Between Zeros
This one was fun to solve! It probably took me around 4-5 minutes. I just had to traverse the list, and if I encountered a non-zero node, I added its value to
curr_sum
and removed that node from the list. I repeated this process until I reached a zero node. Upon reaching the zero node, I addedcurr_sum
to the zero node's value and resetcurr_sum
to 0. At the end, I just returned the second node as the new head of the modified list.# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def mergeNodes(self, head: Optional[ListNode]) -> Optional[ListNode]: prev = head curr = head.next curr_sum = 0 while curr: if curr.val != 0: curr_sum += curr.val prev.next = curr.next curr = curr.next else: curr.val += curr_sum curr_sum = 0 prev = curr curr = curr.next return head.next
Watched some Django tutorials and practiced concurrency patterns in Go.
Other than that, I didn't really do anything tech-related today. I watched a couple of movies and some episodes of Mob Psycho. I really like the vibe—I'm definitely gonna complete it soon.
That's about it! See ya tomorrow! 😄