LeetCode OJ 系列之66 Plus One --Python
来源:互联网 发布:左耳最后说了什么 知乎 编辑:程序博客网 时间:2024/05/17 22:31
Problem:
Given a non-negative number represented as an array of digits, plus one to the number.
The digits are stored such that the most significant digit is at the head of the list.
Answer:class Solution(object): def plusOne(self, digits): """ :type digits: List[int] :rtype: List[int] """ carry_bit = 1 for i in range(len(digits)-1,-1,-1): if digits[i]+carry_bit>9: digits[i] = 0 else : digits[i] = digits[i]+carry_bit carry_bit = 0 if carry_bit == 1: digits.insert(0,1) return digits
0 0
- LeetCode OJ 系列之66 Plus One --Python
- LeetCode OJ:Plus One
- LeetCode OJ Plus One
- 【Leetcode】【python】Plus One
- <LeetCode OJ> 66. Plus One
- LeetCode OJ 之 Plus One (加一)
- leetcode之Plus One
- LeetCode 之 Plus One
- LeetCode之Plus One
- leetcode之Plus One
- LeetCode之Plus One
- leetcode之plus one
- leetcode之Plus One
- leetcode之plus One
- leetcode之Plus One
- 【Leetcode】之Plus One
- 【Leetcode长征系列】Plus One
- 【LeetCode with Python】 Plus One
- mac androidstudio 无法连接魅蓝手机进行调试
- Parcelable接口的使用
- 监听器(Listener)学习
- LeetCode OJ 系列之118 Pascal's Triangle --Python
- LeetCode OJ 系列之73 Set Matrix Zeroes --Python
- LeetCode OJ 系列之66 Plus One --Python
- 多图片平均法降噪
- LeetCode OJ 系列之65 Valid Number --Python
- LeetCode OJ 系列之58 Length of Last Word --Python
- LeetCode OJ 系列之75 Sort Colors --Python
- Medium题目总结
- LeetCode OJ 系列之165 Compare Version Numbers --Python
- LeetCode OJ 系列之151 Reverse Words in a String --Python
- eu in haskell