avatar_url

Sandesh Rana | Python

I'm a developer from Himalayas, with a passion for crafting efficient and elegant code, with creativity and precision.

Greedy Algorithm

21 Aug 2024 » programming, algorithm

Greedy Algorithm: Easy to Hard Problems

Easy

  1. Assign Cookies (Assigns cookies to children to maximize the number of satisfied children)
  2. Best Time to Buy and Sell Stock (Finds the best time to buy and sell stock for maximum profit)
  3. Gas Station (Finds the starting gas station that allows a complete circuit)
  4. Can Place Flowers (Determines if a flower can be planted in a garden with given constraints)
  5. Minimum Absolute Difference (Finds the minimum absolute difference between any two elements)

Medium

  1. Partition Labels (Partitions a string into as many parts as possible with unique characters)
  2. Non-overlapping Intervals (Finds the minimum number of intervals to remove so that no intervals overlap)
  3. Job Scheduling with Deadlines (Schedules jobs to maximize profit considering deadlines)
  4. Activity Selection Problem (Selects the maximum number of activities that don’t overlap)
  5. Interval Partitioning (Finds the minimum number of resources required to schedule all activities)

Hard

  1. Minimum Number of Arrows to Burst Balloons (Finds the minimum number of arrows required to burst all balloons)
  2. Optimal Account Balancing (Minimizes the number of transactions required to settle accounts)
  3. Reconstruct Itinerary (Reconstructs the itinerary from a list of tickets)
  4. Huffman Encoding (Creates an optimal prefix code for data compression using Huffman coding)
  5. Minimum Cost to Merge Stones (Finds the minimum cost to merge stones into a single pile)