dsa2 min read
Partition Labels [Medium] — Greedy Last Occurrence
Partition a string into the maximum number of parts where each letter appears in at most one part, using last occurrence mapping.
Read →
1575 articles
Partition a string into the maximum number of parts where each letter appears in at most one part, using last occurrence mapping.
Calculate minimum CPU intervals for tasks with cooldown using a greedy formula based on the most frequent task count.
Find the minimum arrows needed to burst all balloons arranged as intervals using a greedy sort-by-end approach.
Maximize a number by making at most one swap, using a last-occurrence map to find the optimal swap greedily.
Find a peak element in O(log n) by binary searching on the slope direction — always move toward the higher neighbor.