상위 150개 인터뷰쉬움

플러스원

'Plus One' 문제에 대한 자세한 가이드 및 Python 구현입니다.

문제 설명

쉬움

정수 배열 숫자로 표시되는 큰 정수가 제공됩니다. 여기서 각 숫자[i]는 정수의 i번째 숫자입니다. 숫자는 왼쪽에서 오른쪽 순서로 가장 중요한 것부터 가장 중요한 것까지 정렬됩니다. 큰 정수에는 선행 0이 포함되지 않습니다.

큰 정수를 1만큼 증가시키고 결과 숫자 배열을 반환합니다.

plusOne(digits: list) -> list 함수를 구현하세요.

제약
  • 1 <= digits.length <= 100
  • 0 <= digits[i] <= 9
  • digits does not contain any leading 0's

Example 1
Input
[1,2,3]
Output
[1,2,4]
Explanation

The array represents the integer 123. Incrementing by one gives 124.

Example 2
Input
[4,3,2,1]
Output
[4,3,2,2]
Explanation

The array represents the integer 4321. Incrementing by one gives 4322.

Example 3
Input
[9]
Output
[1,0]
Explanation

The array represents the integer 9. Incrementing by one gives 10, which is [1,0].

Need a Hint?
세트나 힙과 같은 수학 및 기하학 관련 데이터 구조를 사용해 보세요.
Edge Cases to Watch
  • 빈 입력 구조
  • 단일 요소 입력
  • 큰 수치 범위

해결할 준비가 되셨나요?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

편집기에서 열기
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

권장 Python 리소스

관련 대화형 튜토리얼, 치트 시트, 코드 비교를 통해 지식을 확장하세요.