自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

风顺水流

never stop.

  • 博客(34)
  • 收藏
  • 关注

原创 LintCode-剑指Offer-(380)两个链表的交叉

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

2015-11-29 17:01:53 558

原创 LintCode-剑指Offer-(41)最大子数组

class Solution {public: /** * @param nums: A list of integers * @return: A integer indicate the sum of max subarray */ int maxSubArray(vector<int> nums) { // write your cod

2015-11-29 16:47:48 330

原创 LintCode-剑指Offer-(46)主元素

class Solution {public: /** * @param nums: A list of integers * @return: The majority number */ int majorityNumber(vector<int> nums) { // write your code here int n

2015-11-29 14:24:03 363

原创 LintCode-剑指Offer-(378)将二叉查找树转换成双链表

class Solution {public: /** * @param root: The root of tree * @return: the head of doubly list node */ DoublyListNode* bstToDoublyList(TreeNode* root) { // Write your code

2015-11-29 14:18:00 2160

原创 LintCode-剑指Offer-(374)螺旋矩阵

class Solution {public: /** * @param matrix a matrix of m x n elements * @return an integer array */ vector<int> spiralOrder(vector<vector<int>>& matrix) { // Write your co

2015-11-29 13:22:59 923

原创 LintCode-剑指Offer-(376)二叉树路径求和

/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this->left = this->right =

2015-11-29 12:27:48 409

原创 LintCode-剑指Offer-(105)复制带随机指针的链表

class Solution {public: /** * @param head: The head of linked list with a random pointer. * @return: A new head of a deep copy of the list. */ //递归真是个好东西,没想到真能用一个变量实现,简洁明了啊,非常好。

2015-11-22 02:25:50 1534

原创 LintCode-剑指Offer-(12)带最小值操作的栈

class MinStack {public: MinStack() { // do initialization if necessary } stack<int> s; stack<int> minstack; int minnum; void push(int number) { // write your co

2015-11-22 01:22:11 262

原创 LintCode-剑指Offer-(70)二叉树的层次遍历Ⅱ

class Solution { /** * @param root: The root of binary tree. * @return: Level order a list of lists of integer */ public: void lev(TreeNode* node, int levelnum, vector

2015-11-22 01:03:42 346

原创 LintCode-剑指Offer-(69)二叉树的层次遍历

class Solution { /** * @param root: The root of binary tree. * @return: Level order a list of lists of integer */public: void lev(TreeNode* node, int levelnum, vector<vector<int>>&

2015-11-22 01:00:56 267

原创 LintCode-剑指Offer-(68)二叉树的后序遍历

/** * Definition of TreeNode: * class TreeNode { * public: * int val; * TreeNode *left, *right; * TreeNode(int val) { * this->val = val; * this->left = this->right =

2015-11-22 00:05:59 271

原创 LintCode-剑指Offer-(140)快速幂

class Solution {public: /* * @param a, b, n: 32bit integers * @return: An integer */ //要用long long类型,不然可能溢出 long long fastPower(long long a, long long b, long long n) {

2015-11-22 00:00:07 452

原创 LintCode-剑指Offer-(371)用递归打印数字

class Solution {public: /** * @param n: An integer. * return : An array storing 1 to the largest number with n digits. */ vector<int> numbersByRecursion(int n) { //我感觉这道题有点显得

2015-11-21 22:48:03 547

原创 LintCode-剑指Offer-(165)合并两个排序链表

class Solution {public: /** * @param ListNode l1 is the head of the linked list * @param ListNode l2 is the head of the linked list * @return: ListNode head of linked list */ L

2015-11-21 22:24:29 371

原创 LintCode-剑指Offer-(174)删除链表中倒数第n个节点

/** * Definition of ListNode * class ListNode { * public: * int val; * ListNode *next; * ListNode(int val) { * this->val = val; * this->next = NULL; * } * } *

2015-11-21 20:43:53 253

原创 LintCode-剑指Offer-(245)子树

class Solution {public: /** * @param T1, T2: The roots of binary tree. * @return: True if T2 is a subtree of T1, or false. */ bool isSubtree(TreeNode *T1, TreeNode *T2) { if

2015-11-21 20:29:12 269

原创 LintCode-剑指Offer-(372)在O(1)时间复杂度删除链表节点

/** * Definition of ListNode * class ListNode { * public: * int val; * ListNode *next; * ListNode(int val) { * this->val = val; * this->next = NULL; * } * } *

2015-11-21 17:44:14 290

原创 LintCode-剑指Offer-(373)奇偶分割数组

class Solution {public: /** * @param nums: a vector of integers * @return: nothing */ void partitionArray(vector<int> &nums) { // write your code here int i=0;

2015-11-21 17:32:17 854

原创 LintCode-剑指Offer-(73)前序遍历和中序遍历树构造二叉树

class Solution { /**' * ' *@param preorder : A list of integers that preorder traversal of a tree *@param inorder : A list of integers that inorder traversal of a tree *@return : Ro

2015-11-21 17:05:29 297

原创 LintCode-剑指Offer-(160)寻找旋转排序数组中的最小值Ⅱ

class Solution {public: /** * @param num: the rotated sorted array * @return: the minimum number in the array */ int findMin(vector<int> &num) { // write your code here

2015-11-21 01:51:58 262

原创 LintCode-剑指Offer-(208)赋值运算符重载

class Solution {public:char *m_pData; Solution() { this->m_pData = NULL; } Solution(char *pData) { this->m_pData = pData; }// Implement an assignment operator Solutio

2015-11-21 01:43:39 328

原创 LintCode-剑指Offer-(28)寻找旋转排序数组中的最小值

class Solution {public:/*** @param matrix, a list of lists of integers* @param target, an integer* @return a boolean, indicate whether matrix contains target*/bool searchMatrix(vector<vector<int

2015-11-21 01:24:18 299

原创 LintCode-剑指Offer-(111)爬楼梯

class Solution {public:/*** @param n: An integer* @return: An integer*/long climbStairs(int n) { // write your code here if(n==0) return 1; long s = 1; int i=1; int j

2015-11-21 00:37:09 861

原创 LintCode-剑指Offer-(38)搜索二维矩阵Ⅱ

class Solution {public:/*** @param matrix: A list of lists of integers * @param target: An integer you want to search in matrix * @return: An integer indicate the total occurrence of target in the

2015-11-20 23:36:52 296

原创 LintCode-剑指Offer-(40)用栈实现队列

class Queue {public:stack<int> stack1; stack<int> stack2; Queue() { // do intialization if necessary } void push(int element) { // write your code here while(stack1.empt

2015-11-20 23:29:38 251

原创 关于指针的引用的讲解

前一段时间,一直纠结指针的引用,因为在关于二叉树的的一些操作中需要用到指针的引用。具体就不讲了,现在主要写传入指针的引用与传入指针的区别。假设我想实现一个管理员的功能,管理学生信息,无法访问到学生的指针(比如说有了学生的指针,管理员就可以看到很多学生的隐私),只能访问到学生内部的指针(比如教师的指针,为了简单,这里假设学生只有一个指针)。#include #include usin

2015-11-20 11:47:57 285

原创 LeetCode-001-TwoSum

class Solution {public:    vector twoSum(vector& nums, int target) {        int i;        int j;        vector tmp;        for ( i = 0; i             for ( j = nums.size()-1; j>i; j-- ){

2015-11-17 01:05:36 322

原创 LintCode-剑指Offer-(159)寻找旋转排序数组中的最小值

class Solution {public:    /**     * @param num: a rotated sorted array     * @return: the minimum number in the array     *///这个没有技巧,直接遍历    int findMin(vector &num) {        // write

2015-11-17 00:01:52 261

原创 LintCode-剑指Offer-(204)单例

class Solution {public:    /**     * @return: The same instance of this class every time     */    static Solution* getInstance() {        // write your code here        static bool ex=f

2015-11-16 23:46:50 1426

原创 LintCode-剑指Offer-(365)二进制中有多少个1

class Solution {public:    /**     * @param num: an integer     * @return: an integer, the number of ones in num     */    int countOnes(int num) {        // write your code here     

2015-11-16 23:45:16 806

原创 LintCode-剑指Offer-空格替换

class Solution {public:    /**     * @param string: An array of Char     * @param length: The true length of the string     * @return: The true length of new string     */    int replace

2015-11-16 23:43:39 311

原创 LintCode-剑指Offer-斐波拉契

class Solution{public:    /**     * @param n: an integer     * @return an integer f(n)     */    int fibonacci(int n) {        // write your code here                int tmp[3]={0,1,

2015-11-16 23:42:05 354

原创 LintCode-剑指Offer-翻转链表

/** * Definition of ListNode *  * class ListNode { * public: *     int val; *     ListNode *next; *  *     ListNode(int val) { *         this->val = val; *         this->next = NUL

2015-11-16 23:40:04 343

原创 如何两个模板类会相互包含,那么需要在类定义之前声明其中一个类,并且声明时要用模板。

如何两个模板类会相互包含,那么需要在类定义之前声明其中一个类,并且声明时要用模板。

2015-11-07 10:57:10 1094

空空如也

空空如也

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

TA关注的人

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