自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(66)
  • 资源 (1)
  • 收藏
  • 关注

原创 [leetcode] 130. Surrounded Regions 解题报告

题目链接:https://leetcode.com/problems/surrounded-regions/Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's i

2016-01-30 16:17:58 2096

原创 [leetcode] 220. Contains Duplicate III 解题报告

题目链接:https://leetcode.com/problems/contains-duplicate-iii/Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i

2016-01-30 11:09:05 3266

原创 矩阵就地转置+O(Nlog(N))时间复杂度

题目信息:给定一个m*n的矩阵,将其存在在一维数组中,现在将其就地转置即空间复杂度为O(1),并且时间复杂度限制为O(Nlog(N))思路:以一个栗子分析如果移动数组。比如2*5的数组为:0 1 2 3 45 6 7 8 9则其在一维数组中的形式为0 1 2 3 4 5 6 7 8 9而我们需要将其转置为0 51 62 7 3 84 9在一维数组中形式即为

2016-01-28 12:17:32 5104 1

原创 Virtual Initialization - 虚初始化

这是我上Dean教授算法设计课的作业,题目描述如下:One problem with arrays is that they must typically be initialized prior to use. On most computing environments, when we allocate

2016-01-25 10:41:12 723

原创 [leetcode] 240. Search a 2D Matrix II 解题报告

题目链接:https://leetcode.com/problems/search-a-2d-matrix-ii/Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in e

2016-01-23 14:36:52 665

原创 [leetcode] 219. Contains Duplicate II 解题报告

题目链接:https://leetcode.com/problems/contains-duplicate-ii/Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = num

2016-01-18 15:18:36 535

原创 [leetcode] 217. Contains Duplicate 解题报告

题目链接:https://leetcode.com/problems/contains-duplicate/Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in

2016-01-18 14:54:01 617

原创 [leetcode] 151. Reverse Words in a String 解题报告

题目链接:https://leetcode.com/problems/reverse-words-in-a-string/Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".U

2016-01-18 14:40:11 2945

原创 [leetcode] 150. Evaluate Reverse Polish Notation 解题报告

题目链接:https://leetcode.com/problems/evaluate-reverse-polish-notation/Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand m

2016-01-18 11:58:32 544

原创 [leetcode] 46. Permutations 解题报告

题目链接:https://leetcode.com/problems/permutations/Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3

2016-01-14 16:14:55 753

原创 [leetcode] 319. Bulb Switcher 解题报告

题目链接:https://leetcode.com/problems/bulb-switcher/There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle e

2016-01-14 14:59:44 500

原创 [leetcode] 287. Find the Duplicate Number 解题报告

题目链接:https://leetcode.com/problems/find-the-duplicate-number/Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate nu

2016-01-14 14:36:22 834

原创 [leetcode] 99. Recover Binary Search Tree 解题报告

题目链接:https://leetcode.com/problems/recover-binary-search-tree/Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A sol

2016-01-14 13:27:39 2561

原创 [leetcode] 117. Populating Next Right Pointers in Each Node II 解题报告

题目链接:https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any bina

2016-01-13 06:36:40 1869

原创 [leetcode] 145. Binary Tree Postorder Traversal 解题报告

题目链接:https://leetcode.com/problems/binary-tree-postorder-traversal/Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1

2016-01-12 14:24:55 564 1

原创 [leetcode] 236. Lowest Common Ancestor of a Binary Tree 解题报告

题目链接:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/   Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the defin

2016-01-12 12:03:57 1058

原创 [leetcode] 222. Count Complete Tree Nodes 解题报告

题目链接:https://leetcode.com/problems/count-complete-tree-nodes/Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binar

2016-01-12 06:57:17 767

原创 [leetcode] 199. Binary Tree Right Side View 解题报告

题目链接:https://leetcode.com/problems/binary-tree-right-side-view/Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top

2016-01-12 05:26:20 872

原创 [leetcode] 114. Flatten Binary Tree to Linked List 解题报告

题目链接:https://leetcode.com/problems/flatten-binary-tree-to-linked-list/Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5

2016-01-12 04:35:41 494

原创 [leetcode] 94. Binary Tree Inorder Traversal 解题报告

题目链接:https://leetcode.com/problems/binary-tree-inorder-traversal/Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1

2016-01-12 04:09:10 441

原创 [leetcode] 103. Binary Tree Zigzag Level Order Traversal 解题报告

题目链接:https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right

2016-01-12 03:28:48 460

原创 [leetcode] 173. Binary Search Tree Iterator 解题报告

题目链接:https://leetcode.com/problems/binary-search-tree-iterator/Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling ne

2016-01-12 01:29:50 2248

原创 [leetcode] 116. Populating Next Right Pointers in Each Node 解题报告

题目链接:https://leetcode.com/problems/populating-next-right-pointers-in-each-node/Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkN

2016-01-11 16:00:02 364

原创 [leetcode] 230. Kth Smallest Element in a BST 解题报告

题目链接:https://leetcode.com/problems/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

2016-01-11 14:34:34 601

原创 [leetcode] 144. Binary Tree Preorder Traversal 解题报告

题目链接:https://leetcode.com/problems/binary-tree-preorder-traversal/Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1

2016-01-11 11:28:28 488

原创 [leetcode] 326. Power of Three 解题报告

题目链接:https://leetcode.com/problems/power-of-three/Given an integer, write a function to determine if it is a power of three.Follow up:Could you do it without using any loop / recursion?

2016-01-11 11:10:44 586

原创 [leetcode] 108. Convert Sorted Array to Binary Search Tree 解题报告

题目链接:https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路:前面有一题将有序链表转换

2016-01-11 10:56:13 509

原创 [leetcode] 138. Copy List with Random Pointer 解题报告

题目链接:https://leetcode.com/problems/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 nul

2016-01-11 01:12:22 790

原创 [leetcode] 109. Convert Sorted List to Binary Search Tree 解题报告

题目链接:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:这题的思路

2016-01-10 16:02:39 582

原创 [leetcode] 148. Sort List 解题报告

题目链接:https://leetcode.com/problems/sort-list/Sort a linked list in O(n log n) time using constant space complexity.思路:用快速排序的话一个比较难的问题是不能随机访问链表,而归并排序可以利用递归的性质。归并排序时间复杂度为O(n*log(n)),但是这题要求

2016-01-10 12:05:19 741

原创 [leetcode] 23. Merge k Sorted Lists 解题报告

题目链接:https://leetcode.com/problems/merge-k-sorted-lists/Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.思路:刚开始想要两两合并,但是超时了,后来看到用优先队列来做会降低很

2016-01-10 10:23:12 725

原创 [leetcode] 86. Partition List 解题报告

题目链接:https://leetcode.com/problems/partition-list/Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should pres

2016-01-10 05:25:47 402

原创 [leetcode] 25. Reverse Nodes in k-Group 解题报告

题目链接:https://leetcode.com/problems/reverse-nodes-in-k-group/Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a m

2016-01-08 10:51:18 773

原创 [leetcode] 92. Reverse Linked List II 解题报告

题目链接:https://leetcode.com/problems/reverse-linked-list-ii/Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,

2016-01-08 09:54:06 466

原创 [leetcode] 2. Add Two Numbers 解题报告

题目链接:https://leetcode.com/problems/add-two-numbers/You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a

2016-01-08 09:12:21 483

原创 [leetcode] 143. Reorder List 解题报告

题目链接:https://leetcode.com/problems/reorder-list/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' va

2016-01-08 08:18:06 2409

原创 [leetcode] 61. Rotate List 解题报告

题目链接:https://leetcode.com/problems/rotate-list/Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5

2016-01-08 06:55:50 406

原创 [leetcode] 24. Swap Nodes in Pairs 解题报告

题目链接:https://leetcode.com/problems/swap-nodes-in-pairs/Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2-

2016-01-07 16:11:20 419

原创 [leetcode] 141. Linked List Cycle 解题报告

题目链接:https://leetcode.com/problems/linked-list-cycle/Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:用快慢指针,慢的一次走一步,快的一次走两

2016-01-07 15:55:45 381

原创 [leetcode] 147. Insertion Sort List 解题报告

题目链接:https://leetcode.com/problems/insertion-sort-list/Sort a linked list using insertion sort.思路:我发现自从用了虚拟头结点之后刷链表简直是毫无阻碍,哈哈!!代码如下:/** * Definition for singly-linked list. * struct Li

2016-01-07 15:48:06 480

qt3扫雷代码

本程序制作精心,代码完整,为10*10大小的雷区,等级分为三级,简单,中等,困难。其中布雷使用随机数生成,扫空格使用广度搜索BFS,基本具备了扫雷的应有的功能。界面友善,希望能对你有帮助。

2013-11-15

空空如也

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

TA关注的人

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