自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

早睡早起好少年

为什么坚持 想一想当初

  • 博客(30)
  • 资源 (5)
  • 收藏
  • 关注

原创 leetcode-168-Excel Sheet Column Title

Excel Sheet Column Title Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z

2015-07-29 12:21:07 564

原创 leetcode-198-House Robber

House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is t

2015-07-29 10:50:48 485

原创 C++ new malloc realloc

int* a = new int;          分配了存储空间,但没有赋初值int* a = new int(10)     分配了存储空间,并赋初值,即*a = 10int* a = new int[100]      分配了存储空间,但没有赋初值,a为长度为100的数组的首地址int* a = new int[100]()    分配了存储空间,并将数组清零,a为长度

2015-07-27 09:37:47 854

原创 leetcode-20-Valid Parentheses

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, "()"

2015-07-26 21:17:49 512

原创 leetcode-204-Count Primes

Count PrimesDescription:Count the number of prime numbers less than a non-negative number, n.题目 Count Primes计算小于n的所有素数的总数。用一般的方法超时,应该用筛选法求素数 ,参考 筛选法求素数class Solution {publ

2015-07-26 19:48:10 642

原创 leetcode-205-Isomorphic Strings

Isomorphic Strings Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a charact

2015-07-26 19:24:13 541

原创 leetcode-202-Happy Number

Happy NumberWrite an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the numb

2015-07-25 23:08:29 654

原创 leetcode-160-Intersection of Two Linked Lists

Intersection of Two Linked ListsWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 →

2015-07-25 09:28:22 560

原创 leetcode-111-Minimum Depth of Binary Tree

Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf

2015-07-23 22:04:57 508

原创 筛选法求素数

筛选法求素数。将合数都标记,剩下的就是素数。出现一个数,则把已这个数为因子的数都标记为合数。如2,所以4,6,8 10....都标记为合数如3,所以9,12,15.....都标记为合数如4,所以16,20,24...都标记为合数即,若i是素数,则从 j=i*i 开始,把 j+i , j+2i , j+3i .....都标记为合数 (因为从2*i , 3*i,

2015-07-21 21:16:03 1058

原创 反转单链表

反转单链表1. 用数组将单链表的值存储在数组里。方法简单,但浪费空间。2. 遍历链表,从第二个节点开始,将每个节点的next指向前一个节点。原链表的最后一个节点变为头节点。3. 遍历链表,除第一个节点外,将每一个节点依次插到第一个节点后面。最后将第一个节点插到最后。way 2 :ListNode* reverse_1(ListNode* head){ L

2015-07-20 14:40:40 522

原创 leetcode-234-Palindrome Linked List

Palindrome Linked List Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?判断链表是否为回文。空间复杂度O(n)。/** *

2015-07-19 11:39:12 408

原创 leetcode-231-Power of Two

Power of TwoGiven an integer, write a function to determine if it is a power of two.判断给出的数,是否为2的次方,如1,2,4,8,16... 移位操作,2的次方的数,换位2进制表示,都是第一个为1 ,其后面都是0,。如8=1000class Soluti

2015-07-17 19:25:08 594

原创 leetcode-27-Remove Element

Remove Element Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave

2015-07-16 20:16:40 495

原创 leetcode-203-Remove Linked List Elements

Remove Linked List ElementsRemove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4

2015-07-16 19:11:13 483

原创 leetcode-235-Lowest Common Ancestor of a Binary Search Tree

Lowest Common Ancestor of a Binary Search TreeGiven a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wiki

2015-07-16 18:13:38 598

原创 leetcode-237-Delete Node in a Linked List

Delete Node in a Linked List Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and

2015-07-16 13:22:37 740

原创 leetcode-153-Find Minimum in Rotated Sorted Array

Find Minimum in Rotated Sorted Array Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum ele

2015-07-15 22:24:33 444

原创 leetcode-58-Length of Last Word

Length of Last Word Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist

2015-07-10 23:11:25 476

原创 leetcode-53-Maximum Subarray

Maximum SubarrayFind the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous suba

2015-07-10 16:47:29 431

原创 leetcode-112-Path Sum

Path SumGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below bina

2015-07-09 21:46:10 516

原创 leetcode 46-Permutations and 47-Permutations II

PermutationsGiven a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]

2015-07-09 20:22:06 765

原创 全排列

全排列暴力枚举,每次在数组中选一个数,能则继续选下一个,否则另找一个数。#include /// 排列#include#includeusing namespace std;void next(int n,int* a,int cur) ///1~n的全排列 cur为要填充的位置{ if(cur==n){ for(int i=0;i<n;i++)prin

2015-07-09 18:13:49 849

原创 leetcoder-50-Pow(x, n)

Pow(x, n) 可以直接用库函数pow(x,n)一步搞定,但明显这样就没意思了。参考快速幂取模二分,复杂度为O(logn)递归方法class Solution {public: double myPow(double x, int n) { if(n<0) return 1.0/myPow_1(x,-n);

2015-07-09 16:46:30 859

原创 快速幂取模

用二分,使复杂度由 O(n) 变为 O(logn)#include#includeusing namespace std;/// (b^n)mod m; (a*b mod m) = (a mod m)*(b mod m)mod m O(log n)/// (b^n)mod m; (a - b ) mod m =( (a mod m)-(b mod m)

2015-07-09 15:20:02 784

原创 leetcode-230-Kth Smallest Element in a BST

Kth Smallest Element in a BST Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's to

2015-07-09 12:10:36 862

原创 leetcode-64-Minimum Path Sum

Minimum Path SumGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can o

2015-07-08 19:06:46 611

原创 leetcode-162-Find Peak Element

Find Peak ElementA peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The ar

2015-07-07 21:53:55 471

原创 leetcode-145-Binary Tree Postorder Traversal

Binary Tree Postorder TraversalGiven a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3

2015-07-07 20:14:13 493

原创 leetcode-21-Merge Two Sorted Lists

Merge Two Sorted ListsMerge 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.合

2015-07-02 23:03:46 633

[溜客资源论坛提供]C++黑客编程揭秘与防范

黑客资料,了解Hacker,覆盖知识广,有兴趣可以看一下

2014-11-13

c/c++语言参考

包含c++各种库函数,以及c的函数,c++中STL里的各种函数用法,很经典,即可作为入门基础,又可以当做工具书。

2014-08-27

UNIX环境高级编程(第二版)

UNIX操作系统,讲的很详细,适合新手, 绝对不坑

2014-08-20

《算法导论》

《算法导论》是一部很经典的书,里面包含了许多算法知识,深入浅出,图论,搜索,数据结构,应有尽有。对搞ACM的帮组极大。

2014-08-15

空空如也

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

TA关注的人

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