随笔分类 - Array
摘要:[抄题]: 给定一个整数数组,找到和为零的子数组。你的代码应该返回满足要求的子数组的起始位置和结束位置.给出 [-3, 1, 2, -3, 4],返回[0, 2] 或者 [1, 3]. [思维问题]: 老是想着数组双重循环用枚举法,想不到任何别的数据结构。 用hashmap的好处:一个数据结构可以包
阅读全文
摘要:一 [抄题]: If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the
阅读全文
摘要:[抄题]: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4
阅读全文
摘要:Array Data Structure ‘Recent Articles’ on Arrays Topic : Introduction Array Rotations Arrangement Rearrangement Order Statistics Range Queries Searchi
阅读全文
摘要:[抄题]: There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complex
阅读全文
摘要:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam
阅读全文
摘要:不重复的: 方法一 [一句话思路]:排序之后用归并。 [一刷]: [二刷]: 格式上:for循环, else 后面也要加花括号 [总结]:结果中有几个数要看index加到了多少 [复杂度]:sort n*logn, merge n/1 [英文数据结构]:Array sort, array merge
阅读全文
摘要:合并两个排序的整数数组A和B变成一个新的数组。给出A=[1,2,3,4],B=[2,4,5,6],返回 [1,2,2,3,4,4,5,6] 假设A具有足够的空间(A数组的大小大于或等于m+n)去添加B中的元素。 给出 A = [1, 2, 3, empty, empty], B = [4, 5] 合
阅读全文
摘要:形式汇总: 206. Reverse Linked List 92. Reverse Linked List II:Given a string and an integer k, you need to reverse the first k characters for every 2k cha
阅读全文

浙公网安备 33010602011771号