- 博客(23)
- 资源 (7)
- 收藏
- 关注
原创 2014准备好了吗?
2014准备好了吗?明天就是2014了,还没来的及拥抱13,14转眼就来了。这一年特别是这个学期过得特别快。学了几个月的驾照,终于算是辛苦的拿到了。这一年经历了不少。这一年感觉自己长大了不少。这一年从上课的节奏要慢慢过渡的上班的节奏了。这一年定了不少计划,买了不少书。这一年又得开始了下一轮的计划。这一年。。。。。。。。。。慢慢的发现自己知道自己想
2013-12-31 20:37:49 596
原创 Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-
2013-12-31 20:19:14 521
原创 Implement strStr()
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.本题为字符串匹配问题,在此次个人使用的BF方法,若优化使用KMP算法!详见 BF与KMP算法char *strS
2013-12-28 09:41:17 606
原创 Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", ret
2013-12-22 21:45:58 622
原创 Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",Return
2013-12-20 21:37:24 607
原创 Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2013-12-19 20:07:11 724
原创 Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Sort List里面也有实现。/** * Definition for singly-linke
2013-12-19 18:59:04 656
原创 Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [
2013-12-19 15:39:28 646
原创 Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet"
2013-12-19 14:03:00 630
原创 Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va
2013-12-12 21:37:47 577
原创 Valid Number
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguo
2013-12-10 22:31:29 759
原创 Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".此题是按我们平常的加法运算的角度入手,从低位加到高位。(可以反转字符串,便于理解)。注意防止长度不同的,不小心的操作导致溢出。再者插入字符每次是从头开始插入!
2013-12-10 19:42:32 678
原创 fork 与 vfork区别
创建新进程的方法有fork()或vfork()。vfork后一般会调用exec一个新程序。书apue中有介绍p176。区别:(1)vfork与fork都是创建进程,但vfork不完全复制父进程的地址空间。fork :子进程从父进程那得到数据段和堆栈段等,但不是与父进程共享而是单独分配内存。vfork:在没调用exec或exit之前子进程的运行是与父进程共享数据段
2013-12-08 22:56:15 639
原创 Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on
2013-12-08 21:42:37 755
原创 Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.//俩个指针用于定位!ListNode *de
2013-12-08 20:42:01 658
原创 Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.一个链表复制,除了复制next指针外还的复制random指针
2013-12-07 20:19:38 665
原创 Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1",
2013-12-07 14:03:01 645
原创 Valid Palindrome
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a
2013-12-05 21:01:04 598
原创 Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without usi
2013-12-05 20:13:11 670
原创 Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ext
2013-12-04 20:11:33 666
原创 Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,
2013-12-03 20:21:39 550
原创 Pow(x, n)
Implement pow(x, n).//此题思路,第一种最简单的迭代,第二种基本的递归,第三种,分治法。// x^n = x^(n/2)*x^(n/2)*x(n%2) //再者本题注意的细节,x=0,n=0,n负数等double pow(double x, int n) { double temp; if(x == 0)return 0;
2013-12-03 19:06:53 555
原创 Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.//此处返回值是int,故而一些地方需要注意。下面代码使用二分查找!还有另一种方法为,牛顿迭代法! int sqrt(int x) { int right,left,mid; if (x < 2) re
2013-12-03 10:22:40 763
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人