
c++ leetcode
文章平均质量分 82
淡泊shine
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Sort List leetcode刷题
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *so原创 2014-07-19 15:01:42 · 433 阅读 · 0 评论 -
Longest Valid Parentheses
#include #include #include #include using namespace std;/**Longest Valid ParenthesesGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed原创 2014-10-28 12:01:46 · 360 阅读 · 0 评论 -
single number II
注意定义数组赋初值和右移存入的是最低位,c[]原创 2014-10-14 16:44:42 · 371 阅读 · 0 评论 -
valid sodoku
class Solution{ public: bool isValidSudoku(vector > &board) { // Note: The Solution object is instantiated only once. vector> rows(9, vector(9,false)); vector> co转载 2014-10-14 17:05:05 · 474 阅读 · 0 评论 -
重建二叉树 leetcode
http://www.cplusplus.com/reference/algorithm/find/原创 2014-11-17 20:20:15 · 687 阅读 · 0 评论 -
anagrams两种解法 用map来优化查找
#include #include #include #include #include using namespace std;/**Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.Anagram(回原创 2014-10-26 18:00:22 · 745 阅读 · 0 评论 -
leetcode刷题,我的解法1 twosum问题
struct node{ int num,pos;};bool cmp(node a,node b){ return a.num}class Solution {public: vector twoSum(vector &numbers, int target) { vector copy; //定义node类型的矢量,赋值的时候原创 2014-07-10 16:48:57 · 518 阅读 · 0 评论 -
Search for a Range 两种解法
自己的版本,二分查找,找到的时候liy原创 2014-10-31 15:46:13 · 576 阅读 · 0 评论 -
Reorder List leetcode 易出错点已标记
#include using namespace std;/**Reorder List Total Accepted: 23179 Total Submissions: 113917 My Submissions Question SolutionGiven a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L原创 2014-10-20 10:15:40 · 474 阅读 · 0 评论 -
remove the nth node from the end of list leetcode
AC的代码,注意设置的连个原创 2014-10-18 12:56:07 · 371 阅读 · 0 评论 -
把树变成链表 Flatten Binary Tree to Linked List
思路是:拉直的顺序相当于先序遍历,所以先访问根,再访问左子树,再访问youzh原创 2014-11-13 16:26:58 · 388 阅读 · 0 评论 -
subset 集合子集问题
这个帖子讲的很好很详细下面是我的解法,使用的是第二种思路原创 2014-11-08 19:48:20 · 583 阅读 · 0 评论 -
Add Binary leetcode
class Solution {public:/**注意的问题:1,从低位相加,故a,b数组从最末开始,需要分两个下标i,j 2,相加需要int,但数组a,b的元素为 char,所以任何操作都需要-‘0’,特别是最后出来后b[j]+addc的时候,注意是((b[j]-'0') + addc)/2; 3,vector的push_back操作是末尾原创 2014-10-22 19:34:26 · 483 阅读 · 0 评论 -
insertion sort list刷题 leetcode
先分析一般情况下的插入排序,给定数组A,从第2个元素开始,与执勤啊原创 2014-07-22 09:34:03 · 387 阅读 · 0 评论 -
二叉树建立及遍历 实例
完整的给出二叉树递归建立和非递归先序,递归后序代码原创 2014-08-12 19:36:33 · 432 阅读 · 0 评论 -
Longest substring without repeating characters解法
做了一周的题,看见各种解法,发现这种解法最精妙转载 2014-08-28 12:18:48 · 556 阅读 · 0 评论 -
Add Two Numbers 看着简单,其实各种奇葩情况需要考虑。。。
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution {public: ListNo原创 2014-08-31 13:50:39 · 467 阅读 · 0 评论 -
ZigZag Conversion刷题
ZigZag Conversion Total Accepted: 11937 Total Submissions: 50113My SubmissionsThe string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may w原创 2014-08-31 22:47:38 · 538 阅读 · 0 评论 -
remove duplicates from sorted array I II一些思路
在已排序的数组中去除重复元素,要求不使用多余的kongj原创 2014-09-28 17:08:04 · 451 阅读 · 0 评论 -
3Sum leetcode解法 分析
坑死人不偿命的3Sum,知道思路,改了一晚上才改好,各种小错#include #include #include using namespace std;/** Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets原创 2014-10-05 23:07:31 · 550 阅读 · 0 评论 -
String to Integer(ATOI) leetcode
对题目的理解:1.前面如果有其他的字符,只能是空格,若有其他字符也是非法2.前面只能有一个+ - 或者没有,如果出现 +-2,或者 ++ 2,也是非法3.越界非法原创 2014-10-22 16:00:07 · 355 阅读 · 0 评论