Post

[Programmers] #181845 - 문자열로 변환 [Java][C++][Python]

[Programmers] #181845 - 문자열로 변환 [Java][C++][Python]

문제 링크


1. 아이디어

주어진 정수 n을 문자열로 변환하는 간단한 문제로 내장 라이브러리를 활용하면 된다.


2. 복잡도

접근시간공간
풀이$O(D)$$O(D)$

($D$ = n의 자릿수 $\approx \log_{10} n$)


3. 코드

풀이 [Java][C++][Python]

1
2
3
4
5
class Solution {
    public String solution(int n) {
        return String.valueOf(n);
    }
}
1
2
3
4
5
6
#include <bits/stdc++.h>
using namespace std;

string solution(int n) {
    return to_string(n);
}
1
2
def solution(n):
    return str(n)

This post is licensed under CC BY 4.0 by the author.