Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Algorithm
- 항해플러스
- Get
- 프로그래머스
- java
- createSlice
- 테코테코
- Python
- C++
- json-server
- 알고리즘
- useDispatch
- redux-saga
- maeil-mail
- axios
- 이코테
- JavaScript
- redux-toolkit
- SW
- 항해99
- react
- react-redux
- redux
- 매일메일
- programmers
- 자바
- 코딩테스트합격자되기
- 리액트
- react-router
- sw expert academy
Archives
- Today
- Total
Binary Journey
[프로그래머스] 문자열을 정수로 바꾸기 본문
반응형
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges
** Javascript
초간단!
function solution(s) {
return Number(s);
}
근데 굳이 Number 쓰지 않고도 숫자 변환을 할 수 있다.
function solution(s) {
return parseInt(s);
}
function solution(s) {
return s * 1;
}
function solution(s) {
return +s;
}
function solution(s) {
return s / 1;
}
네 가지 풀이 중에서는 +s 를 사용하는 게 가장 빠르다.
** Python
def solution(s):
return int(s)
** Java
class Solution {
public int solution(String s) {
return Integer.parseInt(s);
}
}
반응형
'프로그래머스 > level 1' 카테고리의 다른 글
[프로그래머스] 서울에서 김서방 찾기 (0) | 2021.08.23 |
---|---|
[프로그래머스] 수박수박수박수박수박수? (0) | 2021.08.23 |
[프로그래머스] 약수의 합 (0) | 2021.08.14 |
[프로그래머스] 이상한 문자 만들기 (0) | 2021.08.14 |
[프로그래머스] 자릿수 더하기 (0) | 2021.08.14 |