-
3. Plus OneProblem Solving 2022. 8. 24. 03:02728x90
https://leetcode.com/problems/plus-one/
Plus One - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
숫자를 하나씩 떼서 리스트에 넣은 걸 input으로,
리스트에 있는 숫자를 하나씩 붙인 다음 +1 한 걸 다시 list로 출력하기
class Solution: def plusOne(self, digits: List[int]) -> List[int]: a = "" for i in digits: a = a + str(i) b = int(a) + 1 newdigits = [j for j in str(b)] return newdigits
inline for loop를 예제 안 찾고 하다가 에러남
for 앞에서 콤마 쓰는 건 줄 알았음...ㅎㅎ.. 쉬운 문제로도 하나씩 파이썬 문법에 익숙해져 가는 중
'Problem Solving' 카테고리의 다른 글
6. 문자열 내 p와 y의 개수 (0) 2022.08.27 5. 스킬트리 (0) 2022.08.26 4. 나누어 떨어지는 숫자 배열 (0) 2022.08.25 2. Pascal's Triangle (2) 2022.08.23 1. Assign Cookies (2) 2022.08.22