摘要:
剑指 Offer 53 - I. 在排序数组中查找数字 I 遍历 从前到后遍历,找到一个+1 时间复杂度O(n),空间复杂度O(1) class Solution { public int search(int[] nums, int target) { if(nums.length == 0) { 阅读全文
摘要:
剑指 Offer 53 - II. 0~n-1中缺失的数字 遍历 找到值不等于索引的项 时间复杂度O(n),空间复杂度O(1) class Solution { public int missingNumber(int[] nums) { int ans=0; for(ans=0;ans<nums. 阅读全文
摘要:
剑指 Offer 25. 合并两个排序的链表 遍历 class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode head = new ListNode(0),curr= head; while 阅读全文
摘要:
剑指 Offer 18. 删除链表的节点 增加头节点遍历,当然这道题跟原题不太一样 class Solution { public ListNode deleteNode(ListNode head, int val) { ListNode pre = new ListNode(0); pre.ne 阅读全文