Skip to main content

Command Palette

Search for a command to run...

Day 10 in Bangalore

Published
โ€ข2 min read
Day 10 in Bangalore
๐Ÿ‘‹
Hi, I'm Pranay Sinha, a 3rd year B.Tech student with a keen interest in the tech industry and a passion for learning.

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 10 (09/07/24)

  • Today's LeetCode question was another medium 1701. Average Waiting Time

    Just like yesterday's question this one is also simulation related. Here's my solution:

      class Solution:
          def averageWaitingTime(self, customers: List[List[int]]) -> float:
              total_time = 0
              curr_time = 1
              for customer in customers:
                  if curr_time < customer[0]:
                      curr_time = customer[0]
                  curr_time += customer[1]
                  total_time += curr_time - customer[0]
    
              return total_time/len(customers)
    

    I use two variables to keep track of the total waiting time of all the customers and the current time. Then we iterate over the customers list and for each customer we will just add their order's preparation time to the current_time variable. And then we would calculate the waiting time of the current customer by subtracting the current time by the customer's arrival time. We'll then add this value to the total_time. At the end of the loop we will return the average waiting time for all the customers.
    One thing that I had to adjust for was that if the cook was sitting idle while no customers arrived, When the next customer arrives I've to set the current time to the customer's arrival time.

  • After that I did a couple questions from Striver's sheet and I revised binary search by implementing a few questions on the topic.

  • Watched the complete 3rd season of Mob Psycho in one go. It felt like it was longer than it needed to be, some episodes were just dragging the story. I liked the final few episodes but the conclusion was kind of weird. Nevertheless great show 7/10.

That's about it! See ya! ๐Ÿ˜

Bangalore Tech Diaries

Part 8 of 12

I will be documenting the journey through my days in Bangalore, starting from June 30th. No frills, just honest documentation of what I manage to accomplish each dayโ€”minus the procrastination!

Up next

Day 11 in Bangalore

๐Ÿ‘‹ Hi, I'm Pranay Sinha, a 3rd year B.Tech student with a keen interest in the tech industry and a passion for learning. 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 ...