[Java][Greedy][LeetCode] PartitionLabels #763
You are given a string
s. We want to partition the string into as many parts as possible so that each letter appears in at most one part.
Return a list of integers representing the size of these parts.
Input: s = "ababcbacadefegdehijhklij"
The partition is "ababcbaca", "defegde", "hijhklij".
This is a partition so that each letter appears in at most one part.
A partition like "ababcbacadefegde", "hijhklij" is incorrect, because it splits s into less parts.
Array fast than HashMap.
Recording the last position of every letter and saving in Array or HashMap.
Sweeping string of input again. setting the end point is the maximum. when the index position is equal to the end point, it means that an interval ends. calculate the difference with start point and end point.