Semaphore Validity (Simulation)

JavaScript Medium 4 views
Back to Questions

Problem Description

You have capacity C and a list of events: ACQ or REL. ACQ means one async job started, REL means one finished. If at any time active goes above C or REL happens at active=0, print INVALID else VALID.

Input Format

Line1: C n. Next n lines: ACQ/REL.

Output Format

VALID or INVALID.

Sample Test Case

Input:
2 5 ACQ ACQ REL ACQ REL
Output:
VALID

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next