import java.util.ArrayList; import java.util.Arrays; import java.util.List; /** * Source : https://oj.leetcode.com/problems/plus-one/ * * * Given a non-negative number represented as an array of digits, plus one to the number. * * The digits are stor…
题意:给一个数按位存放在一个int数组中,要求返回这个数加一后的数组. 懒人解法: public class Solution { public int[] plusOne(int[] digits) { java.math.BigInteger Bigdigits = new java.math.BigInteger(toString(digits)); String s = Bigdigits.add(new java.math.BigInteger("1")).toString(…
前言 [LeetCode 题解]系列传送门: http://www.cnblogs.com/double-win/category/573499.html 1.题目描述 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…
Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. Example: Input: 1->2->3 Output: 1->2->4 这道题给了我们一个链表,用来模拟一…
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. 将一个数字的每个位上的数字分别存到一个一维向量中,最高位在最开头,我们需要给这个数字加一,即在末尾数字加一,如果末尾数字是9,那么则会有进位问题,而如果…
原题链接在这里:https://leetcode.com/problems/plus-one-linked-list/ 题目: Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list.…
463. Island Perimeterhttps://leetcode.com/problems/island-perimeter/就是逐一遍历所有的cell,用分离的cell总的的边数减去重叠的边的数目即可.在查找重叠的边的数目的时候有一点小技巧,就是沿着其中两个方向就好,这种题目都有类似的规律,就是可以沿着上三角或者下三角形的方向来做.一刷一次ac,但是还没开始注意codestyle的问题,需要再刷一遍. class Solution { public: int islandPerime…