
数据结构
GoGoCoder
喜欢web前端后台开发,最近在关注微服务,欢迎一起交流。
展开
-
简单算法题之 Two Sum
Question:Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target原创 2016-08-19 00:33:56 · 602 阅读 · 0 评论 -
快速排序
快速排序在所有的排序算法中,快速排序算是很不错的了。实现起来简单,而且它的平均复杂度为O(nlogn)。性能相对于冒泡,选择和插入要好很多了。由于近几天回顾了一下数据结构的知识,温顾而知新(@_@)。所以用java实现了一遍。原创 2016-08-11 23:26:25 · 353 阅读 · 0 评论 -
求最大子序列和
[问题描述]给定一整数序列A1, A2, A3, … , An(可能会有负数),求A1 ~ An的一个子序列Ai ~ Aj,使得Ai 到Aj的和最大。[Input] 1, 2, -23, 6,3,1,-5,7,-11.[Ouput] 12因为:6+3+1+(-5)+7 = 12。 这道题有很多解法。最简单的就是暴力穷举。用3个for循环来遍历所有的子序列的求得和,平均复杂度为原创 2016-08-13 03:34:23 · 417 阅读 · 0 评论 -
顺序表--Java实现
顺序表是一个比较重要的数据结构。它的特点有以下:逻辑上相邻的数据,在物理存储的位置上也是相邻的。存储密度高,需要预先分配空间。后续的代码可以看到。便于随机存取。但是它存储结构跟数组是一样,所以也就不便于插入和删除。当顺序表较大时,插入和删除都会引起大量数据的移动。如果插入和删除频繁操作的话,最好使用链表的数据结构。顺序表一般存储不经常变动的数据。一个顺序表的存储数据后,基本操作有: 置空,原创 2016-08-28 15:40:30 · 8465 阅读 · 2 评论 -
LeetCode之反转数组
LeetCode之反转数组Question: Rotate Array QuestionEditorial Solution My Submissions Total Accepted: 97790 Total Submissions: 425073 Difficulty: Easy Contributors: Admin Rotate an array of n elements原创 2016-11-01 14:41:48 · 1345 阅读 · 0 评论