var partitionLabels = function(s) { let map = newMap() for(let i=0;i<s.length;i++){ map.set(s[i],i) } let result = [] let left=0,right=0 for(let i=0;i<s.length;i++){ right = Math.max(right,map.get(s[i])) // 找到分割点的标志。 if (right === i){ result.push(right-left+1) left = i+1 } } return result };