웅재의 코딩세상
[프로그래머스] 접미사인지 확인하기 본문
- 풀이
#include <string>
#include <vector>
using namespace std;
int solution(string my_string, string is_suffix) {
int answer = 0;
int n=0;
if(is_suffix.size() > my_string.size()) return 0;
for(int i= is_suffix.size()-1; i >= 0; i--){
n++;
if(is_suffix[i] != my_string[my_string.size()-n]) return 0;
}
return 1;
}
반응형
'코딩테스트 > 프로그래머스 - LV 0' 카테고리의 다른 글
[프로그래머스] 문자열을 정수로 변환하기 (0) | 2024.01.25 |
---|---|
[프로그래머스] n보다 커질 때까지 더하기 (0) | 2024.01.25 |
[프로그래머스] 정수 찾기 (0) | 2024.01.25 |
[프로그래머스] 조건에 맞게 수열 변환하기 1 (0) | 2024.01.25 |
[프로그래머스] 수 조작하기 1 (1) | 2024.01.25 |