1class Solution {2public List<Integer> partitionLabels(String s) {34List<Integer> lr = new ArrayList<>();56HashMap<Character, Boolean> mp = new HashMap<>();78int count = 0;910for (int i = 0; i < s.length(); i++) {1112if (!mp.containsKey(s.charAt(i)) && s.lastIndexOf(Character.toString(s.charAt(i))) != i) {13mp.put(s.charAt(i), true);14} else if (mp.containsKey(s.charAt(i))15&& s.lastIndexOf(Character.toString(s.charAt(i))) == i) {1617mp.remove(s.charAt(i));18}1920if (mp.isEmpty()) {21lr.add(count + 1);22count = 0;23} else {24count++;25}26}2728return lr;29}30}