프로그래머스 120904 숫자 찾기

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;
}