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, 22886 Search Bots | 90 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1414 Views, 22886 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, 22886 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: Find the k-th Largest Element in a List
- Plus One
- Find Pythagorean Triplets
- Daily Interview Problem: Validate Binary Search Tree
- 56 Bytes
- Daily Interview Problem: Maximum Profit From Stocks
- Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals
- Palindrome Integers
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Daily Interview Problem: Arithmetic Binary Tree
©2006~2024 SteakOverCooked - 0.0068 Seconds(s) - 7956.032 KB/s - 39 Online Memory: 516.65 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="noindex, 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 !