随笔分类 -  数据结构与算法

摘要:高数基础1:创建函数的导数求函数极值步骤: 阅读全文
posted @ 2016-01-02 09:11 zhanggl 阅读(226) 评论(0) 推荐(0)
摘要:Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.For example, givenn... 阅读全文
posted @ 2015-09-19 20:36 zhanggl 阅读(123) 评论(0) 推荐(0)
摘要: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 nu... 阅读全文
posted @ 2015-09-16 07:48 zhanggl 阅读(307) 评论(0) 推荐(0)
摘要:何谓荷兰国旗:现有红、白、蓝三个不同颜色的小球,乱序排列在一起,请重新排列这些小球,使得红白蓝三色的同颜色的球在一起。这个问题之所以叫荷兰国旗,是因为我们可以将红白蓝三色小球想象成条状物,有序排列后正好组成荷兰国旗。问题转换为:给定数组A[0…N-1],元素只能取0、1、2三个值,设计算法,使得数组... 阅读全文
posted @ 2015-04-18 10:13 zhanggl 阅读(2506) 评论(0) 推荐(0)
摘要:从数组中任意取出2个数,判断他们的和是否为输入的数字sum,时间复杂度为0(n^2),空间复杂度0(1)假设数据已经是排序好的#include #include #include using namespace std;int a[] = {1,2,3,4,5,6,7,8,9,10};int siz... 阅读全文
posted @ 2015-04-18 06:49 zhanggl 阅读(403) 评论(0) 推荐(0)