Day 10 in Bangalore

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_timevariable. 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 thetotal_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! ๐




