自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 《算法概论》课后习题8.8 证明4SAT是NP完全的

题目8.8. In the EXACT 4SAT problem, the input is a set of clauses, each of is a disjunction of exactly four literals, and such that each variables occurs at most once in each clause. The goal is to find

2017-06-20 15:33:50 723

原创 LeetCode 22. Generate Parentheses

22. Generate ParenthesesGiven n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is: [ “((()))”, “(()(

2017-06-19 15:24:11 244

原创 LeetCode 538. Convert BST to Greater Tree

538. Convert BST to Greater TreeGiven a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than t

2017-06-16 23:03:15 268

原创 LeetCode 49. Group Anagrams

49. Group AnagramsGiven an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return: [ [“ate”, “eat”,”tea”], [“nat”,”tan”], [“

2017-06-07 15:31:55 255

原创 LeetCode 50. Pow(x, n)

50. Pow(x, n)Implement pow(x, n).题目意思: 题目意思很简单,让我们实现一个幂函数,也就是给出xx和nn,返回xnx^n.解题思路: 幂函数是什么我们都很清楚,xnx^n表示n个x相乘的结果,最简单粗暴的方法就是写一个循环来将n个x乘起来,但这是低效的,而且这种方法在Leetcode上提交也不会通过。但是,对于n个x,如果我们把这些x分成两部分。 x∗x∗⋯∗x

2017-06-06 15:08:42 369

原创 LeetCode 525. Contiguous Array

525. Contiguous ArrayGiven a binary array, find the maximum length of a contiguous subarray with equal number of 0 and 1.Example 1: Input: [0,1] Output: 2 Explanation: [0, 1] is the longest con

2017-06-03 12:15:32 336

原创 LeetCode 71. Simplify Path

71. Simplify PathGiven an absolute path for a file (Unix-style), simplify it.For example, path = "/home/", => "/home" path = "/a/./b/../../c/", => "/c"题目内容: 题目给出一个绝对路径,这个路径可能包括"/.."和"/."这些访问上一目录和当前目

2017-06-02 17:56:33 260

原创 LeetCode 36. Valid Sudoku

36. Valid SudokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. A partially fi

2017-05-23 20:18:59 227

原创 LeetCode 142. Linked List Cycle II

142. Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.Follow up: Can you solve it without using ex

2017-05-22 11:41:17 226

原创 LeetCode 141. Linked List Cycle

141. Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?题目内容: 题目给出一个单向链表,让我们判断这个单向链表中是否存在环路。解题思路: 这题我尝试了2个方法来解决。 方法一: 因为如

2017-05-21 20:06:52 227

原创 LeetCode 459. Repeated Substring Pattern

459. Repeated Substring PatternGiven a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given stri

2017-05-13 10:47:34 225

原创 LeetCode 539. Minimum Time Difference

539. Minimum Time DifferenceGiven a list of 24-hour clock time points in “Hour:Minutes” format, find the minimum minutes difference between any two time points in the list.Example 1: Input: [“23:59”,

2017-05-06 11:37:55 344

原创 LeetCode 343. Integer Break

343. Integer BreakGiven a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, giv

2017-04-26 18:19:51 194

原创 LeetCode 357. Count Numbers with Unique Digits

357. Count Numbers with Unique DigitsGiven a non-negative integer n, count all numbers with unique digits, x, where 0≤x<10n0 ≤ x < 10^n.Example: Given n = 2, return 91. (The answer should be the total

2017-04-26 16:31:48 274

原创 LeetCode 413. Arithmetic Slices

413. Arithmetic SlicesA sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are a

2017-04-18 15:34:37 221

原创 LeetCode 338. Counting Bits

338. Counting BitsGiven a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example:

2017-04-18 09:59:32 207

原创 LeetCode 516. Longest Palindromic Subsequence

516. Longest Palindromic SubsequenceGiven a string s, find the longest palindromic subsequence’s length in s. You may assume that the maximum length of s is 1000.Example 1: Input: “bbbab” Out

2017-04-16 19:37:46 270

原创 LeetCode 435. Non-overlapping Intervals

435. Non-overlapping IntervalsGiven a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note: You may assume the interv

2017-04-16 14:59:26 276

原创 LeetCode 452. Minimum Number of Arrows to Burst Balloons

452. Minimum Number of Arrows to Burst BalloonsThere are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizon

2017-04-16 14:05:35 248

原创 LeetCode 543. Diameter of Binary Tree

543. Diameter of Binary TreeGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest path between any two nodes in a t

2017-04-10 17:38:41 222

原创 LeetCode 517. Super Washing Machines

517. Super Washing MachinesYou have n super washing machines on a line. Initially, each washing machine has some dresses or is empty.For each move, you could choose any m (1 ≤ m ≤ n) washing machines,

2017-04-09 15:59:16 494

原创 LeetCode 523. Continuous Subarray Sum

523. Continuous Subarray SumGiven a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple

2017-04-09 14:38:20 250

原创 LeetCode 310. Minimum Height Trees

310. Minimum Height TreesFor a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimu

2017-04-02 18:58:48 239

原创 LeetCode 477. Total Hamming Distance

477. Total Hamming DistanceThe Hamming distance between two integers is the number of positions at which the corresponding bits are different.Now your job is to find the total Hamming distance between

2017-04-02 11:45:52 334

原创 LeetCode 210. Course Schedule II

210. Course Schedule IIThere are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which

2017-03-25 17:19:50 403

原创 LeetCode 410. Split Array Largest Sum

410. Split Array Largest SumGiven an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the la

2017-03-18 21:54:11 467

原创 LeetCode 513. Find Bottom Left Tree Value

513. Find Bottom Left Tree ValueGiven a binary tree, find the leftmost value in the last row of the tree.题目内容: 给定一个二叉树,找出树中最后一层的最左边的元素。解题思路: 解决这个题目主要包括2个主要内容:遍历二叉树,实现树的遍历可以用BFS和DFS,我这里采用了BFS。因为题目要找

2017-03-18 18:59:06 367

原创 LeetCode 24. Swap Nodes in Pairs

24. Swap Nodes in PairsGiven 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->1->4->3.Your algorithm should use only con

2017-03-11 23:19:20 254

原创 LeetCode 19. Remove Nth Node From End of List

19. Remove Nth Node From End of ListGiven a linked list, remove the nth node from the end of list and return its head.For example,Given linked list: 1->2->3->4->5, and n = 2. After removing the secon

2017-03-11 22:10:25 220

原创 LeetCode 100. Same Tree

100. Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.题目描述:

2017-03-10 20:46:37 222

原创 LeetCode 26. Remove Duplicates from Sorted Array

26. Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another arr

2017-03-10 20:30:41 260

原创 LeetCode 75. Sort Colors

75. Sort ColorsGiven an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the

2017-03-07 14:27:27 301

原创 LeetCode 3. Longest Substring Without Repeating Characters

3. Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Examples:Given “abcabcbb”, the answer is “abc”, which the length i

2017-03-04 20:26:52 233

原创 LeetCode 2. Add Two Numbers

2. Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two num

2017-03-04 16:51:19 579

原创 LeetCode 1. Two Sum

1. Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use th

2017-03-04 16:00:58 374

原创 LeetCode 41. First Missing Positive

41. First Missing PositiveGiven an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time

2017-03-04 14:50:03 306

原创 LeetCode 97. Interleaving String

97. Interleaving StringGiven s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example, Given: s1 = “aabcc”, s2 = “dbbca”,When s3 = “aadbbcbcac”, return true. When s3 = “aa

2017-02-26 13:32:33 341

原创 LeetCode 6. ZigZag Conversion

ZigZag Conversion The string “PAYPALISHIRING” is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H

2017-02-25 16:23:07 196

原创 LeetCode 345. Reverse Vowels of a String

345. Reverse Vowels of a StringWrite a function that takes a string as input and reverse only the vowels of a string.Example 1: Given s = “hello”, return “holle”.Example 2: Given s = “leetcode”, retu

2017-02-24 23:44:39 301

原创 LeetCode 392. Is Subsequence

392. Is SubsequenceGiven a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~=

2017-02-23 23:59:12 274

Bresenham算法画圆

这份代码是一个vs工程,可以vs打开,实现的是使用Bresenham算法画圆

2015-05-05

空空如也

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

TA关注的人

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