Rank Open Businesses
Each business candidate is represented as [score, distance, isOpen], where isOpen is 1 for open and 0 for closed. Return the indices of the top k open businesses.
Open businesses should be sorted by descending score. If two businesses have the same score, the one with the smaller distance comes first. If both score and distance are tied, keep the smaller original index first.
1Example 1
Candidate 1 is closed. Candidates 2 and 0 tie on score, so the smaller distance comes first.
2Example 2
All open stores are returned because fewer than five stores are available.
Constraints
Limits and guarantees your solution can rely on.
Closed businesses must not appear in the result. If fewer than k businesses are open, return all open businesses in ranked order.