自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(35)
  • 资源 (2)
  • 收藏
  • 关注

原创 leetcode Longest Substring Without Repeating Characters

class Solution { public: int lengthOfLongestSubstring(string s) { int len=s.length(); if(len==0) return 0; vector pos(256,-1); int longest=INT_MIN; int subl

2014-06-28 21:55:26 312

原创 leetcode First Missing Positive

class Solution { public: int firstMissingPositive(int A[], int n) { for(int i=0;i<n;){ if(A[i]>0&&A[i]!=(i+1)&&A[i]<n&&A[i]!=A[A[i]-1]){ //首先确保swap的地方没有越界,之后确保swap双方不一样,否则死循环。A

2014-06-26 22:11:59 300

原创 leetcode Merge k Sorted Lists

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

2014-06-25 22:01:50 319

原创 leetcode Copy List with Random Pointer

/** * Definition for singly-linked list with a random pointer. * struct RandomListNode { * int label; * RandomListNode *next, *random; * RandomListNode(int x) : label(x), next(NULL),

2014-06-25 21:31:04 333

转载 leetcode Recover Binary Search Tree

Two elements of a binary search tree (BST) are swapped by mistake. Recover the tree without changing its structure. 这个 /** * Definition for binary tree * struct TreeNode { * int val; *

2014-06-24 22:02:32 402

原创 leetcode Pow(x, n)

看到这个题目,一开始以为是大数

2014-06-23 21:48:29 298

原创 leetcode Anagrams

class Solution { public: /*思想:将每一个字符串排序,那么anagram在排序后必然相同,所以用map结构*/ vector anagrams(vector &strs) { vector res; vector flag(strs.size(),false); map temp; pair::ite

2014-06-20 22:25:25 281

原创 leetcode ZigZag Conversion

我在考虑这个问题d

2014-06-20 21:58:36 298

原创 leetcode Jump Game

Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine i

2014-06-18 22:16:20 355

原创 leetcode Jump Game II

class Solution { public: /*贪心算法即可解决这个问题*/ int jump(int A[], int n) { if(n<=0) return 0; vector step(n,0); int maxIndex=0,max=A[0],last=0; for(int i=1;i<n;i++){

2014-06-18 22:15:08 328

原创 leetcode Distinct Subsequences

Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting some (can be non

2014-06-16 22:02:50 311

原创 leetcode Permutations II

class Solution { public: vector > permuteUnique(vector &num) { sort(num.begin(),num.end()); vector> result; vector aresult; sub(result,aresult,num,0); retur

2014-06-13 22:26:33 296

原创 leetcode Insertion Sort List

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

2014-06-13 21:48:05 312

原创 leetcode Reverse Words in a String

Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the" Clarification: What constitutes a word? A sequence of non-space

2014-06-13 14:55:44 344

原创 leetcode Reverse Nodes in k-Group

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

2014-06-13 09:48:53 262

原创 leetcode Edit Distance

class Solution { public: /*最优问题,首先选取动态规划和贪心算法。该问题使用动态规划,动态规划列出在做决定的所有选择,找最好的选择*/ int minDistance(string word1, string word2) { int n1=word1.length(),n2=word2.length(); int maxLen=m

2014-06-11 22:17:46 411

原创 leetcode Next Permutation

class Solution { public: /*组合数学,下一个全排列的生成。考虑排列P,求满足Pj-1<pj的j的最大值,设为i 求满足关系式Pi-1<pk的k 的最大值,设为j。将pi-1与pj交换,并将之后的元素逆序*/ void nextPermutation(vector &num) { int n=num.size(); int i=n-2

2014-06-11 09:58:11 255

原创 leetcode Generate Parentheses

关于这道题目,因为和括号有关,开始想用stack

2014-06-10 21:55:15 293

原创 leetcode Validate Binary Search Tree

在这道题目中,需要知道zuoyou

2014-06-10 09:38:43 291

原创 leetcode N-Queens

标准的回溯法,扩展了所有情况

2014-06-09 21:39:43 264

原创 leetcode Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = "aab", Return [ ["aa","

2014-06-05 21:35:14 259

原创 leetcode Add Binary

Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100".

2014-06-04 21:44:19 333

原创 leetcode Construct Binary Tree from Inorder and Postorder Traversal

Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree.

2014-06-04 20:35:14 621

原创 TCP/IP 第三章 IP:网际协议

一、IP介绍 IP协议是TCP/IP协议簇中最为核心的协议。所有TCP,UDP,ICMP,IGMP都是以IP数据报格式传输。 IP协议有两个特点需要注意:不可靠和无连接 不可靠:说的是IP协议不能保证IP数据报能够成功的到达目的地。如果发生了错误(比如某个路由器的缓冲区用完了),那么IP选择丢弃这个数据报,然后发送ICMP消息给消息源端。任何要求的可靠性必须有上层来提供 无连接:IP并不维

2014-05-14 16:29:54 427

原创 leetcode Letter Combinations of a Phone Number

Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone buttons) is given below. Input:Digit st

2014-05-13 22:15:19 321

原创 leetcode Binary Tree Zigzag Level Order Traversal

Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between). For example: Given binary

2014-05-13 21:33:22 276

转载 三十分钟 掌握STL

译者:kary contact:[email protected] STL概述 STL的一个重要特点是数据结构和算法的分离。尽管这是个简单的概念,但这种分离确实使得STL变得非常通用。例如,由于STL的sort()函数是完全通用的,你可以用它来操作几乎任何数据集合,包括链表,容器和数组。 要点 STL算法作为模板函数提供。为了和其他组件相区别,在本书中STL算法以后接一对

2014-05-13 17:01:24 282

原创 TCP/IP协议详解:卷一 第一章

第一章 一、TCP/IP协议簇的四层协议    1.         一般来说,下面三层一般在操作系统内核中执行,而应用层在通常是用户的一个进程。应用层关心的是应用程序的细节而不是数据在网络中的传输活动。下面三层则对应用程序一无所知,但他们需要处理所有的通信细节。 2.        网络层与传输层的区别:                                     

2014-05-13 16:16:38 615

原创 leetcode Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.

2014-05-12 21:40:15 306

原创 leetcode Combination Sum

Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen from C unlimited numb

2014-05-12 20:52:12 349

转载 leetcode 回溯法 模板

/** * dfs 模板. * @param[in] input 输入数据指针 * @param[out] path 当前路径,也是中间结果 * @param[out] result 存放最终结果 * @param[inout] cur or gap 标记当前位置或距离目标的距离 * @return 路径长度,如果是求路径本身,则不需要返回长度 */ void dfs(type &

2014-05-09 21:45:45 1117

原创 深入探索C++对象模型 第七章 站在对象模型的尖端

主要探讨的有三个问题:template、异常处理、执行期类型识别 A.       Template 定义一个template(模板定义域) Template Class point{          Public:                             Enumstatus{a,b};                             Point(Ta=0

2014-05-09 20:24:44 603

原创 深入探索C++对象模型 第六章 执行语义学

1.        一个区段可能有多个return离开点,所以可能导致一些对象创建后,没有用就需要释放,这就造成了很多浪费。所以建议把object放置在使用它的区段的附近。 2.        C++中全局变量会放置在datasegment,如果没有被指定值,内置类型其所被配置的内存内容将会被置为0。(会被初始化),而局部变量则不会。类类型的话,应该提供一个默认构造函数,否则就失败了。 3. 

2014-05-09 20:22:22 498

原创 leetcode Count and Say

The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as 

2014-05-09 09:32:49 316

原创 leetcode 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact

2014-05-08 22:03:32 389 1

QQ登陆界面

这是一个仿真QQ登陆界面的界面代码,有需要的可以参考一下

2013-09-02

编译原理 词法分析

老师的 编译原理课件 讲的很明白 很有必要学习一下哦

2012-09-29

空空如也

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

TA关注的人

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