Problem Solving
3. Plus One
굥깡
2022. 8. 24. 03:02
728x90
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 앞에서 콤마 쓰는 건 줄 알았음...ㅎㅎ.. 쉬운 문제로도 하나씩 파이썬 문법에 익숙해져 가는 중