அல்கோரிதம்greedy check

Greedy check

TT
Testlaa Team
May 14, 20261 min read

Candidate — linear validate.

Try this in Python

def valid(order, deadlines):
    t = 0
    for job, d in zip(order, deadlines):
        t += job
        if t > d:
            return False
    return True

print(valid([2, 1], [3, 3]))

Key takeaways

  • Validate early.
  • Stress test.
  • Split construct/check.

Tags:

GreedyPythonமாணவர்கள்