Solved 13 Oct. #LeetCode problem of the day:
632. Smallest Range Covering Elements from K Lists
in #Java using Priority Queue
Let's dive into the approach to find the smallest range that covers elements from each sorted list! (1/9)
@snitchindia This is ridiculous! Ordered 5 items worth ₹5804, returned all & paid ₹300 return charges - refund should be ₹5504. But you gave only ₹4911!
Why? Because you refunded a ₹1007 shirt twice (₹932 after charges) instead of refunding my ₹1600 shirt.
Your support is a joke - refused to check, called it “cancellation,” & ended the chat. This isn’t just about money - it’s about the wasted time, frustration, and sheer inconvenience you caused. Is this how you treat customers?
Solved 14 Oct. #LeetCode problem of the day:
2530. Maximal Score After Applying K Operations in #Java using Priority Queue
Let's dive into the approach to break down overlapping intervals into non-overlapping groups. (1/9)
Time Complexity:
The overall complexity is O(k log n), where n is the size of the array. This comes from the cost of heap operations for each of the k operations. (8/9)
Thinking Process:
By leveraging a max-heap to always grab the largest number and minimizing it after each operation, we ensure that the solution remains optimal within the given constraints. (9/9)
Priority Queue Approach:
We can maintain a priority queue to keep track of the smallest elements across all lists. Initially, we insert the first element of each list into the queue. (3/9)
Time Complexity:
The overall complexity is O(n log k), where n is the total number of elements across all lists, and k is the number of lists due to maintaining the priority queue. (8/9)
Thinking Process:
By leveraging the sorted order of each list and using a priority queue to track the smallest and largest elements, we efficiently narrow down the smallest possible range! (9/9)