摘要: 问题: Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two eleme 阅读全文
posted @ 2016-04-21 11:28 wwwglin 阅读(189) 评论(0) 推荐(0)
摘要: 快速排序: 参考:http://blog.csdn.net/qarkly112649/article/details/35794097 阅读全文
posted @ 2016-04-20 16:10 wwwglin 阅读(161) 评论(0) 推荐(0)
摘要: 冒泡排序: 阅读全文
posted @ 2016-04-20 15:12 wwwglin 阅读(229) 评论(0) 推荐(0)
该文被密码保护。 阅读全文
posted @ 2016-04-20 14:59 wwwglin 阅读(1) 评论(0) 推荐(0)
摘要: 直接插入排序: 思想:每趟将一个待排序的元素作为关键字,按照其关键字值的大小插入到已经排好的部分序列的适当位置,知道插入而完成。 性能: 时间复杂度:最坏:O(n^2),最好O(n),平均O(2^n); 空间复杂度:O(1); 代码: 阅读全文
posted @ 2016-04-18 14:04 wwwglin 阅读(210) 评论(0) 推荐(0)
摘要: 最近总结一下排序算法相关知识。 排序算法的分类: 插入类排序:在已经有序的序列中,插入一个新的记录。 直接插入排序、折半插入排序、希尔排序。 交换类排序:交换类排序的核心是“交换”,即每一趟排序,都能通过一系列的“交换”动作,让一个记录排到它最终的位置上。 冒泡排序、快速排序。 选择类排序:每一趟排 阅读全文
posted @ 2016-04-18 13:55 wwwglin 阅读(102) 评论(0) 推荐(0)
摘要: 问题:Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements. 思考:开始想通过两层for 阅读全文
posted @ 2016-04-14 15:48 wwwglin 阅读(172) 评论(0) 推荐(0)
摘要: 题目:Given a binary tree, find its maximum depth. 计算二叉树的深度。 解决:采用深度优先遍历。 阅读全文
posted @ 2016-04-13 15:14 wwwglin 阅读(115) 评论(0) 推荐(0)
摘要: 问题:Given an array of integers, every element appears twice except for one. Find that single one. 思考:运用双循环,微循环循环待比较数字,内层比较。增加一个flag表明是否匹配。 知识:flag的使用,以 阅读全文
posted @ 2016-04-12 14:12 wwwglin 阅读(161) 评论(0) 推荐(0)
摘要: 问题:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 s 阅读全文
posted @ 2016-04-11 18:07 wwwglin 阅读(154) 评论(0) 推荐(0)