프로그래머스 120904 숫자 찾기

Jmnote (토론 | 기여)님의 2023년 11월 26일 (일) 12:51 판
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

프로그래머스 120904 숫자 찾기

2 C++[ | ]

#include <string>
#include <vector>

using namespace std;

int solution(int num, int k) {
    string str = to_string(num);
    int len = str.length();
    for(int i=0; i<len; i++) {
        if(str[i] == '0'+k) {
            return i+1;            
        }
    }
    return -1;
}