自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(28)
  • 资源 (9)
  • 收藏
  • 关注

原创 42. Trapping Rain Water

对某个值height[i]来说,能trapped的最多的water取决于在i之前最高的值lefthighest[i]和在i右边的最高的值righthighest[i](均不包含自身)。 如果min(left,right) > height[i],那么在i这个位置上能trapped的water就是min(left,right) – height[i]。using namespace std;cla

2016-04-28 23:18:13 321

原创 84. Largest Rectangle in Histogram

详细的解释可以看下下面链接的博客 http://www.cnblogs.com/hxsyl/archive/2012/08/16/2643015.htmlclass Solution {private: struct node{ int width; int height; };public: int largestRectangleAr

2016-04-28 23:15:38 283

原创 20. Valid Parentheses

class Solution {public: bool isValid(string s) { stack<char> q; for(int i=0;i<s.size();i++) { if(s[i]=='('||s[i]=='['||s[i]=='{') q.push(s[i]);

2016-04-27 22:55:13 269

原创 32. Longest Valid Parentheses

用一个数组记录所有匹配的地方 然后在数组中寻找最长的匹配地方class Solution {public: int longestValidParentheses(string s) { stack<int> q; int *a =(int *)malloc(s.size()*sizeof(int)); for(int i=0;i<s.si

2016-04-27 11:42:16 219

原创 150. Evaluate Reverse Polish Notation

class Solution {public: int evalRPN(vector<string>& tokens) { stack<int> q; for(int i=0;i<tokens.size();i++) { if(tokens[i]!="+"&&tokens[i]!="/"&&tokens[i]!="*"

2016-04-27 10:35:05 260

原创 81. Search in Rotated Sorted Array II

class Solution {public: bool search(vector<int>& nums, int target) { int start,end,mid; start=0; end=nums.size()-1; while(start<=end) { mid=(sta

2016-04-27 09:55:39 302

原创 33. Search in Rotated Sorted Array

class Solution {public: int search(vector<int>& nums, int target) { int start,end,mid; start=0; end=nums.size()-1; while(start<=end) { mid=(star

2016-04-26 23:12:45 246

原创 35. Search Insert Position

class Solution {public: int searchInsert(vector<int>& nums, int target) { int start; int end; start=0; end=nums.size()-1; while(start<=end) {

2016-04-26 22:50:55 253

原创 69. Sqrt(x)

class Solution {public: int mySqrt(int x) { unsigned long long begin = 0; unsigned long long end = x; unsigned long long mid; unsigned long long tmp;

2016-04-26 11:34:42 316

原创 34. Search for a Range

class Solution {private: int binerySearch(vector<int>&nums,int searchnum,int start,int end) { if(start<=end) { int mid=(start+end)/2; if(nums[mid]==sear

2016-04-26 10:45:29 268

原创 92. Reverse Linked List II

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {private: ListNode *re

2016-04-26 10:06:29 240

原创 19. Remove Nth Node From End of List

class Solution {public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode *temp=head; int count=0; while(temp) { count++; temp=te

2016-04-26 09:35:13 250

原创 25. Reverse Nodes in k-Group

解决这个问题我的想法就是 进行计数 当计数 每次当count=1时记为head count=k时记为tail 然后反转 连入原链表 最后要记得的是 要把最后没有进行反转的地方 也加入到链表中class Solution {public: ListNode* reverseKGroup(ListNode* head, int k) { if(!head||!head->ne

2016-04-25 11:38:34 340

原创 23. Merge k Sorted Lists

本来想把第一个依次和其他所有的链表进行合并的 可惜超时了 class Solution {private: ListNode* mergeTwoList(ListNode *l1,ListNode *l2) { ListNode *prenode=new ListNode(0); ListNode *tail=prenode; wh

2016-04-23 11:10:46 435

原创 24. Swap Nodes in Pairs

class Solution { public: ListNode* swapPairs(ListNode* head) { if(!head||!head->next) return head; ListNode *headptr=new ListNode(0); headptr->next=head;

2016-04-23 10:02:48 312

原创 21. Merge Two Sorted Lists

class Solution {public: ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) { ListNode *prenode =new ListNode(0); ListNode *tail=prenode; while(l1&&l2) {

2016-04-23 10:01:43 260

原创 86. Partition List

class Solution {public: ListNode* partition(ListNode* head, int x) { if(!head||!head->next) return head; ListNode *less=NULL; ListNode *more=NULL; ListN

2016-04-21 11:23:44 402

原创 82. Remove Duplicates from Sorted List II

要注意这个链表的第一个元素也有可能被删除掉 所以加了一个空的前驱指针#include <iostream>using namespace std; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} };class Solution {publ

2016-04-21 11:00:24 569

原创 83. Remove Duplicates from Sorted List

class Solution {public: ListNode* deleteDuplicates(ListNode* head) { if(!head||!head->next) return head; ListNode *last;//指向去除重复的最后一个 ListNode *scan;//指向正在扫描的元素

2016-04-21 10:03:57 243

原创 61. Rotate List

#include <iostream>using namespace std; struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} };class Solution {public: ListNode* rotateRight(Li

2016-04-21 09:45:09 344

原创 138. Copy List with Random Pointer

这个一个人链表的深度拷贝 old链表为 第一步 在每一个old节点的后面加上新的copy节点 ,形成新的链表如下图所示 copy节点中的random指针指向 它要复制的old节点 next指针指向 要复制节点中的old节点中的next 第二步 更新copy节点中random指针值 copy节点中的random指针现在指向 它要copy的节点 如果copy->random->r

2016-04-20 11:52:38 590

原创 Linked List Cycle II

原理在linked list cycle 中已经叙述过了 这里不再叙述class Solution {public: ListNode *detectCycle(ListNode *head) { ListNode *fast=head; ListNode *slow=head; if(!head) return fal

2016-04-20 10:07:46 263

原创 Linked List Cycle

问题是怎么确定链表中是否有环 使用一个快指针fast 还有一个慢指针 slow slow一次走一步 fast一次走两步 这样如果链表中有环 slow和fast则会相遇在z点 slow走了a+b fast走了a+b+c+b 问题扩展 : 1.如果有环 怎么求出环的长度 2.如果有环 怎么把环变成单链表 3.如何判断 两个链表是否相交1.因为fast走过的长度为slow的两倍

2016-04-20 09:53:54 279

原创 143. Reorder List

class Solution {public: void reorderList(ListNode* head) { int n=countList(head);//n 从0开始 如果head中只有一个元素的话返回值为0 if(n==0) return; if(n%2==0)//n为偶数 {

2016-04-19 10:59:23 346

原创 #1015 : KMP

#include <iostream>using namespace std;void buildnext(const char *pattern,int l,int *next){ int i=0;//i 为next数组下标 int j=-1;//j 为next数组值 j=-1说明没有前面没有任何一个值相等 next[0]=-1; while(i<l)

2016-04-18 22:47:30 302

原创 #1014 : Trie树

时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho是一对好朋友,出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助,在编程的学习道路上一同前进。这一天,他们遇到了一本词典,于是小Hi就向小Ho提出了那个经典的问题:“小Ho,你能不能对于每一个我给出的字符串,都在这个词典里面找到以这个字符串开头的所有单词呢?”身经百战的小Ho答道:“怎么

2016-04-17 11:43:59 304

原创 Insertion Sort List

题目很简单 就是把链表拆分成已经排好序的 ,没有排序的 ,从没有排序的中不断的取元素插入到排好序的链表中class Solution {public: ListNode* insertionSortList(ListNode* head) { if(!head||!head->next) return head; ListNode *

2016-04-14 22:32:22 430

原创 奇异值分解(Singular Value Decomposition)

- 线性变化的几何表现首先看下简单的矩阵,这是一个对角矩阵 M=(3001)\begin{gather*}M=\begin{pmatrix} 3& 0 \\ 0 & 1 \end{pmatrix}\end{gather*} 我们先用这个对角矩阵乘以一个点来看看它的几何变化。 (3001)∗(xy)=(3xy)\begin{gather*}\begin{pmatrix} 3& 0 \\

2016-04-13 23:14:39 5979 2

PID算法详解

过程控制中,按偏差的比例(P)、积分(I)和微分(D)进行控制的PID控制器(亦称PID调节器)是应用最为广泛的一种自动控制器。它具有原理简单,易于实现,适用面广,控制参数相互独立,参数的选定比较简单等优点;而且在理论上可以证明,对于过程控制的典型对象──“一阶滞后+纯滞后”与“二阶滞后+纯滞后”的控制对象,PID控制器是一种最优控制。PID调节规律是连续系统动态品质校正的一种有效方法,它的参数整定方式简便,结构改变灵活(PI、PD、…)。

2013-04-18

三天入门M4——Kinetis(V2.2)

三天入门M4 手把手教你如何进入CORTEX——M4

2013-04-18

电磁组直立行车参考设计方案

电磁组直立行车参考设计方案 提拱了如何控制小车直立和行进的完整解决方案

2013-04-18

PID算法介绍

pid算法是用于反馈控制的算法 适合于工业控制

2012-10-07

数字电路教程

很好的数字电路入门资源,非常适合入门 数字电路是基础哦

2012-09-23

TMP100驱动

温度传感器TMP100的驱动代码,可以直接拿过来用的

2012-09-18

安卓开发门必读

安卓开发必读 Android

2012-05-13

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除