BackJoon Algorithm 수 이어 쓰기 1515 (Java)

업데이트:
최대 1 분 소요

BackJoon Algorithm - Java

alt

문제

alt

풀이

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Back_1515 {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        int pointer = 0;
        int count = 0;

        while(count++ <= 30000){
            String temp = String.valueOf(count);
            for(int i = 0 ; i< temp.length(); i++){
                if(temp.charAt(i) == str.charAt(pointer)){
                    pointer ++;
                }
                if(pointer == str.length()){
                    System.out.println(count);
                    return;
                }
            }
        }
        br.close();
    }
}


댓글남기기