File: root - text - article - 2020 - 02 - plus-one.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1414 Views, 22893 Search Bots | 90 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1414 Views, 22893 Search Bots | 90 Words
| Browse | Archive
Hi, here's your problem today. This problem was recently asked by LinkedIn:
Given a non-empty array where each element represents a digit of a non-negative integer, add one to the integer. The most significant digit is at the front of the array and each element in the array contains only one digit. Furthermore, the integer does not have leading zeros, except in the case of the number '0'.
Example:
Input: [2,3,4]
Output: [2,3,5]
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 1414 Views, 22893 Search Bots | 90 Words Given a non-empty array where each element represents a digit of a non-negative integer, add one to the integer. The most significant digit is at the front of the array and each element in the array contains only one digit. Furthermore, the integer does not have leading zeros, except in the case of the number '0'.
Example:
Input: [2,3,4]
Output: [2,3,5]
class Solution():
def plusOne(self, digits):
# Fill this in.
num = [2, 9, 9]
print(Solution().plusOne(num))
# [3, 0, 0]
Related Articles
- Daily Interview Problem: Min Stack
- Daily Interview Problem: Room scheduling
- Daily Interview Problem: Full Binary Tree
- [Daily Problem] Longest Increasing Subsequence
- Design Tic-Tac-Toe
- Daily Interview Problem: Largest BST in a Binary Tree
- A trick for getting good at coding interviews FASTER
- Daily Interview Problem: Decode String
- Daily Interview Problem: Deepest Node in a Binary Tree
- Daily Interview Problem: Queue Using Two Stacks
©2006~2024 SteakOverCooked - 0.01256 Seconds(s) - 1541.953 KB/s - 67 Online Memory: 492.34 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="index, follow">
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !