일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- 마니토바
- machine learning
- LV1
- 조지아텍
- LAA
- 머신러닝
- 주정부이민
- cpp
- 딥러닝
- 개발자
- Plotting
- 선형대수
- 기본
- 코딩테스트
- 프로그래머스
- zeros
- EOI
- 방통대
- omscs
- 알고리즘
- 방송통신대학교
- mpnp
- 컴퓨터과학과
- leetcode
- 온라인석사
- 매트랩
- MATLAB
- C++
- 캐나다 영주권
- Deep learning
Archives
- Today
- Total
Krononberg
763. Partition Labels.cpp 본문
class Solution {
public:
vector<int> partitionLabels(string s) {
vector<int>res;
vector<int>last(26,0);
for(int i =0; i<s.size();i++){
last[s[i]-'a'] = i;
}
int maxidx =-1; int start = 0;
for(int i =0; i<s.size();i++){
maxidx = max(maxidx,last[s[i]-'a']);
if(maxidx ==i){
res.push_back(maxidx-start+1);
start = i +1;
}
}
return res;
}
};
'개발 로그 > 알고리즘' 카테고리의 다른 글
1863. Sum of All Subset XOR Totals.cpp (0) | 2021.10.04 |
---|---|
1382. Balance a Binary Search Tree.cpp (0) | 2021.10.04 |
1605. Find Valid Matrix Given Row and Column Sums.cpp (0) | 2021.10.03 |
1252. Cells with Odd Values in a Matrix.cpp (0) | 2021.10.02 |
1725. Number Of Rectangles That Can Form The Largest Square.cpp (0) | 2021.10.02 |