In Codechef Round 194 Div 4, there was one particular question that completely shattered my confidence. After failing to solve it during the contest, my brain froze — and I couldn’t think clearly for the remaining problems. But after calming myself d...
Introduction Algorithms are fundamental to computer science and play a very important role in designing efficient solutions for various problems. Understanding algorithms, dating back to ancient civilisations, is essential for anyone interested in ma...
🚀 What I Learned Today Today, I explored one of the classic greedy algorithm problems — the Activity Selection Problem. This problem taught me how to use the greedy approach to solve scheduling tasks efficiently. 💡 Problem Statement You are given ...
Problem Link LeetCode Version Let’s be honest—“Best Time to Buy and Sell Stock” sounds like something you’d Google after watching The Wolf of Wall Street at 2 a.m. and convincing yourself you’re a financial genius. The good news? There’s a greedy a...
In the previous blog, I mentioned I would create a separate blog on the Greedy Algorithm, and here it is. This is the blog! Let's get started! What is Greedy Algorithm? Imagine a pile of both good bricks and broken pieces. Now, you are told to build ...
You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position. Return true if you can reach the last index, or false otherwise. Example...
// Input list of process execution times const input = [4, 3, 7, 1, 2]; // Function to calculate the average waiting time using SJF function averageWaitingTimeSJF(processTimes) { // Sort the process times in ascending order const sortedTimes...
At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills). Each customer will only buy one lemonade and pay with either a $5, $10, or $20 bill. You must pr...
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor g[i], which is the minimum size of a cookie that the child will be content with; and eac...
Hello, Welcome to my July Challenge of Problem Solving and finding solutions to Leetcode's Data Structures and Algorithm questions. Here, I choose a question daily and try to solve it, and finally pen down my process of flow in solving the question. ...