自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Dufre

Stay Hungry,Stay Foolish

  • 博客(11)
  • 问答 (2)
  • 收藏
  • 关注

原创 leetcode No147. Insertion Sort List

Question:Sort a linked list using insertion sort.Algorithm:新建一个链表,模仿插入排序的过程Accepted Code:/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next;

2016-10-29 11:59:58 557

原创 leetcode No143. Reorder List

Question:Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4

2016-10-29 11:15:38 504

原创 leetcode No142. Linked List Cycle II

Question:Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Algorithm:首先fast每次走两步,slow每次走1步,如果fast走到NULL,说明没有环,如果fast和slow相遇,说明有环,假设fast和slow在Z相遇,

2016-10-27 19:57:45 453

原创 leetcode No23. Merge k Sorted Lists

Question:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Algorithm:1、把链表数组合并成一个链表2、对链表进行排序这应该不是个好办法、、、仅供参考Accepted Code:/** * Definit

2016-10-26 21:37:30 567

原创 leetcode No148. Sort List

Question:Sort a linked list in O(n log n) time using constant space complexity.Algorithm:类似归并排序,程序有注释Accepted Code:/** * Definition for singly-linked list. * struct ListNode { * int

2016-10-26 21:22:24 527

原创 leetcode No215. Kth Largest Element in an Array

Question:Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,Given [3,2,1,5,6,4] and k

2016-10-25 16:08:36 489

原创 leetcode No160. Intersection of Two Linked Lists

Question:Write 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 → a2 ↘

2016-10-20 21:24:38 699

原创 leetcode No233. Number of Digit One

Question:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6, because digit 1 occurred in

2016-10-15 20:55:32 651

原创 leetcode No138. Copy List with Random Pointer

Question: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.Algorithm:算

2016-10-12 19:29:17 737

转载 必须在类初始化列表中初始化的几种情况

原博地址:http://www.cnblogs.com/kaituorensheng/p/3477630.html1. 类成员为const类型2. 类成员为引用类型#include using namespace std;class A{ public: A(int &v) : i(v), p(v), j(v) {} vo

2016-10-11 09:14:33 2012

原创 leetcode No155. Min Stack

Question:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.

2016-10-10 09:12:09 600

空空如也

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

TA关注的人

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