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 | 1413 Views, 22865 Search Bots | 90 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 1413 Views, 22865 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 | 1413 Views, 22865 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 Puzzle: Falling Dominoes
- How to Play WAV music under DOS?
- Daily Interview Problem: Largest BST in a Binary Tree
- Algorithm Interview: Lowest Common Ancestor of 2 Nodes in Binary Tree
- Daily Interview Problem: Word Ordering in a Different Alphabetical Order
- Algorithm Interview: String Compression
- Daily Interview Question: Edit Distance
- 56 Bytes
- Sorting a list with 3 unique numbers
- Daily Interview Problem: Minimum Removals for Valid Parenthesis
©2006~2024 SteakOverCooked - 0.00779 Seconds(s) - 2514.241 KB/s - 293 Online Memory: 492.53 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 !