Java实现 1classSolution {2publicListNode plusOne(ListNode head) {3ListNode dummy =newListNode(0);4dummy.next =head;5ListNode i =dummy;6ListNode j =dummy;7while(j.next !=null) {8j =j.next;9if(j.val != 9) {10i =j;11}12}13i.val++;14i =i.next;15while(i !=null) {16i.val...
0066. Plus One (E) Plus One (E) 题目 Given anon-emptyarray of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit. You may a...
LeetCode-206. Reverse Linked List Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLSolution:/** * Definition for singly-linked list. * public class ... java 算法 单链表 链表 leetcode 转载 2021-08-31 14:47:45 77 阅读 ...
LeetCode Uz Discuss:https://t.me/leetcodeuz_discuss 验证码平台:https://t.me/jiema_USA 验证码平台:https://t.me/jiemapingtai2 WildRift - 英雄联盟手游:https://t.me/cnWildRift 沙雕根据地:https://t.me/shadiaoo 老王的福利:https://t.me/scottwang ACG 萌:https://t.me/acg_moe WSB ...
LeetCode-206. Reverse Linked List Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLSolution:/** * Definition for singly-linked list. * public class ... java 算法 单链表 链表 leetcode 转载 2021-08-31 14:47:45 77 阅读 LeetCode-...
Input:[4,3,2,1]Output:[4,3,2,2]Explanation:The array represents the integer 4321. 加一 int数组转str数组合并成str之后转int+1再转为str再转为str数组再转为int数组(智障了...) 其实就是变为int值+1再转回去. classSolution(object):defplusOne(self, digits):""":type digits: List[int] :...