棋子

导航

2015年10月16日 #

spiral matrix

摘要: 螺旋遍历!!这道题,之前在一家公司面试见过,当时,依稀记得是使用的递归思想。leetcode上再见该题:参考了一位大神的博客的代码: 1 class Solution { 2 public: 3 vector spiralOrder(vector>& matrix) { 4 ... 阅读全文

posted @ 2015-10-16 01:02 鼬与轮回 阅读(137) 评论(0) 推荐(0) 编辑

2015年10月12日 #

Remove Linked List Elements

摘要: 题目大致题意就是:给定一个链表头节点和一个数值,删除链表结点中所有数值等于该给定数值的结点!! 1 class Solution { 2 public: 3 ListNode* removeElements(ListNode* head, int val) { 4 ListN... 阅读全文

posted @ 2015-10-12 15:58 鼬与轮回 阅读(176) 评论(0) 推荐(0) 编辑

2015年10月3日 #

自己动手实现线性映射,哈希映射

摘要: 一个简单的线性映射:#include#includeusing namespace std;templateclass LinearMap{public: LinearMap(int size = 101) :arr(size) { current_size = 0; ... 阅读全文

posted @ 2015-10-03 11:03 鼬与轮回 阅读(308) 评论(0) 推荐(0) 编辑

2015年9月30日 #

简单大根堆的实现

摘要: 1 //头文件定义--heap.h 2 #ifndef _MAXHEAP_H_ 3 #define _MAXHEAP_H_ 4 template<class T> 5 class MaxHeap{ 6 public: 7 MaxHeap(int size=10); 8 virtual ~MaxHea 阅读全文

posted @ 2015-09-30 13:21 鼬与轮回 阅读(643) 评论(0) 推荐(0) 编辑

2015年8月31日 #

Convert Sorted List to Balanced Binary Search Tree leetcode

摘要: 题目:将非递减有序的链表转化为平衡二叉查找树!参考的博客:http://blog.csdn.net/worldwindjp/article/details/39722643利用递归思想:首先找到链表的中间节点,于是链表被分为了由该中间节点划分开来的两部分。递归地处理这两部分,最终便得到了平衡二叉查找... 阅读全文

posted @ 2015-08-31 00:11 鼬与轮回 阅读(259) 评论(1) 推荐(0) 编辑

2015年8月26日 #

中位数II

摘要: 该题目与思路分析来自九章算法的文章,仅仅是自己做个笔记!题目:数字是不断进入数组的,在每次添加一个新的数进入数组的同时返回当前新数组的中位数。解答:这道题是用堆解决的问题。用两个堆,max heap和min heap,再加一个median值,维持两个堆的大小相等(小根堆可以比大根堆多一个)。对于新来... 阅读全文

posted @ 2015-08-26 14:29 鼬与轮回 阅读(263) 评论(0) 推荐(0) 编辑

2015年8月22日 #

largest rectangle in histogram leetcode

摘要: Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histog... 阅读全文

posted @ 2015-08-22 20:05 鼬与轮回 阅读(196) 评论(0) 推荐(0) 编辑

文摘

摘要: 只有知道如何停止的人才知道如何加快速度。生活中没有绝境,绝境在于你自己的心没有打开。任何伟大的东西,你分到日常的每一天去,都是很小的事情。当你是地平线上一棵草的时候,不要指望别人会在远处看到你,即使他们从你身边走过甚至从你身上踩过,也没有办法,因为你只是一棵草;而如果你变成了一棵树,即使在很远的地方... 阅读全文

posted @ 2015-08-22 12:49 鼬与轮回 阅读(155) 评论(0) 推荐(0) 编辑

2015年8月21日 #

Maximal Square leetcode

摘要: Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matr... 阅读全文

posted @ 2015-08-21 23:52 鼬与轮回 阅读(175) 评论(0) 推荐(0) 编辑

2015年8月20日 #

Majority Element II

摘要: Given an integer array of sizen, find all elements that appear more than⌊ n/3 ⌋times. The algorithm should run in linear time and in O(1) space.网络上的思路... 阅读全文

posted @ 2015-08-20 15:01 鼬与轮回 阅读(184) 评论(0) 推荐(0) 编辑

2015年8月19日 #

Merge k Sorted Lists leetcode

摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Hide TagsDivide and ConquerLinked ListHeapHide Similar... 阅读全文

posted @ 2015-08-19 23:57 鼬与轮回 阅读(196) 评论(0) 推荐(0) 编辑

2015年8月18日 #

学习方法-暗时间

摘要: 根据主题来查阅资料,而不是根据资料来查阅主题 。以前读书的时候是一本一本的读,眼里看到的是一本一本的书, 现在则是一章、 甚至一节一节的读, 眼中看到的不是一本一本的书, 而是一堆一堆的章节, 一个一个的知识主题, 按照主题来阅读, 你会发现读的时候不再是老老实实地一本书看完看另一本, 而是非常频繁... 阅读全文

posted @ 2015-08-18 09:02 鼬与轮回 阅读(184) 评论(2) 推荐(0) 编辑

2015年8月17日 #

4sum leetcode

摘要: Given an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives the sum of ... 阅读全文

posted @ 2015-08-17 00:35 鼬与轮回 阅读(179) 评论(0) 推荐(0) 编辑

2015年8月16日 #

valid parentheses

摘要: Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ... 阅读全文

posted @ 2015-08-16 01:28 鼬与轮回 阅读(191) 评论(0) 推荐(0) 编辑

2015年8月15日 #

两道考研算法设计题- 2010 2013

摘要: 2010:设将n(n>1)个整数存放到一维数组R中。试设计一个在时间和空间两方面都尽可能高效的算法,将R中保存的序列循环左移P(0 2 #include 3 usingnamespacestd; 4 5 voidreverse(inta[],intbegin,intend) 6 { 7 i... 阅读全文

posted @ 2015-08-15 15:38 鼬与轮回 阅读(794) 评论(1) 推荐(0) 编辑

2015年8月8日 #

regular expression matching DP

摘要: 这个题目,我从前天晚上(8月6号晚上)调试到现在(8月8号16:21),太心酸了,不好好总结一下,就太对不起自己了!这是题目:Implement regular expression matching with support for'.'and'*'.'.' Matches any single ... 阅读全文

posted @ 2015-08-08 17:13 鼬与轮回 阅读(198) 评论(0) 推荐(0) 编辑

2015年8月6日 #

valid sudoku leetcode

摘要: 该题:判断一个9行9列的数独是否合法,并不是判断数独是否有解。也就是只要判断每一行,每一列,每一个子九宫格是否有重复数字,若有,则不合法。 最简单的方法,当然是使用3个二维数组,并使用3个二重循环来进行判断。 不过我们可以稍加改进,一个二重循环即可以解决。关键在于行,列,子九宫格是如何看待这两个... 阅读全文

posted @ 2015-08-06 14:53 鼬与轮回 阅读(132) 评论(0) 推荐(0) 编辑

regular expression matching leetcode

摘要: Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The... 阅读全文

posted @ 2015-08-06 11:54 鼬与轮回 阅读(179) 评论(0) 推荐(0) 编辑

2015年8月5日 #

Add two numbers leetcode

摘要: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single ... 阅读全文

posted @ 2015-08-05 00:13 鼬与轮回 阅读(264) 评论(1) 推荐(0) 编辑

2015年7月29日 #

快速排序 c++

摘要: 快速排序的思想很简单,注意实现的时候一定要考虑周全: 快排思想:分治递归的思想!! 选取枢纽元pivot很是关键,我是直接用的第一个数组元素; 初始化i为第一个元素,j为最后一个元素; 首先j从后往前遍历,寻找第一个比枢纽元小的元素,将其交换到i小标所在位置;然后i从前往后遍历寻找第一个比p... 阅读全文

posted @ 2015-07-29 19:48 鼬与轮回 阅读(161) 评论(0) 推荐(0) 编辑