摘要: 下一个值覆盖当前值即可。。 class Solution { public void deleteNode(ListNode node) { while (node.next.next != null) { node.val = node.next.val; node = node.next; } 阅读全文
posted @ 2021-06-15 12:37 ACBingo 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 链表形式的大数相加,没什么难的 题目要求不能修改原链表。那就把两个链表遍历一遍,把数取出来放到stack里,再进行相加 或者利用递归?(不过也是一样的,自己构建的栈只是换成了递归栈) class Solution { public ListNode addTwoNumbers(ListNode l1 阅读全文
posted @ 2021-06-15 12:29 ACBingo 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 二分的一种变种,这次是比较条件改变了,相邻的两位来比较,进而判断左右区间的选择 class Solution { public int peakIndexInMountainArray(int[] arr) { int n = arr.length; int left = 1, right = n 阅读全文
posted @ 2021-06-15 00:26 ACBingo 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 二分寻找边界 public class Solution extends VersionControl { public int firstBadVersion(int n) { int i = 1; int j = n; while (i<=j) { int mid = i + ((j-i)>>1 阅读全文
posted @ 2021-06-15 00:05 ACBingo 阅读(33) 评论(0) 推荐(0) 编辑