自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(32)
  • 收藏
  • 关注

原创 LeetCode 374: Guess Number Higher or Lower

374. Guess Number Higher or LowerDifficulty: Easy We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wr

2016-07-15 14:55:09 377

原创 LeetCode 368: Largest Divisible Subset

368. Largest Divisible SubsetDifficulty: Medium Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj

2016-07-15 14:46:18 520 1

原创 LeetCode 209: Minimum Size Subarray Sum

209. Minimum Size Subarray SumDifficulty: Medium Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn’t one, return

2016-07-07 15:40:30 433

原创 LeetCode 239: Sliding Window Maximum

239. Sliding Window MaximumDifficulty: Hard Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers i

2016-07-06 15:09:53 359

原创 LeetCode 330: Patching Array

330. Patching ArrayDifficulty: Hard Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum

2016-07-01 14:40:58 392

原创 LeetCode 214: Shortest Palindrome

214. Shortest PalindromeDifficulty: Hard Given a string S, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by pe

2016-06-30 14:46:28 617

原创 LeetCode 142: Linked List Cycle II

142. Linked List Cycle IIDifficulty: Medium Given 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

2016-06-22 10:48:38 353

原创 LeetCode 141: Linked List Cycle

141. Linked List CycleDifficulty: Easy Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?思路定义两个指针,同时从链表头结点出发,一个指针一次走一步,另一个指针一次走两步。如果快的指针追上了慢

2016-06-22 10:28:32 309

原创 LeetCode 092: Reverse Linked List II

092. Reverse Linked List IIDifficulty: Medium 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,return 1->4->3->2->5->

2016-06-22 10:21:25 360

原创 LeetCode 206: Reverse Linked List

206. Reverse Linked ListDifficulty: Easy Reverse a singly linked list.思路为了反转链表,需要改变链表中指针的方向,使next指向前面一个结点。 每次调整一个结点,已调整的结点的下一结点为前面的结点。 假设需要调整结点i,调整结束后,i的next要指向它前面的结点h,且链表会在i和最初next指向的结点j之间断裂,为了防止无法

2016-06-22 09:33:34 349

原创 LeetCode 264: Ugly Number II

264. Ugly Number IIDifficulty: Medium Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10,

2016-06-16 16:38:25 389

原创 LeetCode 263: Ugly Number

263. Ugly NumberDifficulty: Easy Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugl

2016-06-16 16:15:25 779

原创 LeetCode 275: H-Index II

275. H-Index IIDifficulty: Medium Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optimize your algorithm?Hint: Expected runtime complexity is in O(log n) a

2016-06-16 16:05:27 410

原创 LeetCode 318: Maximum Product of Word Lengths

318. Maximum Product of Word LengthsDifficulty: Medium Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters.You may a

2016-06-16 15:22:34 359

原创 LeetCode 316: Remove Duplicate Letters

316. Remove Duplicate LettersDifficulty: Hard Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your re

2016-06-07 19:36:01 394

原创 LeetCode 274: H-Index

274. H-IndexDifficulty: Medium Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher’s h-index. According to the definition

2016-06-07 19:20:40 409

原创 LeetCode 268: Missing Number

268. Missing NumberDifficulty: Medium Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2

2016-06-03 14:24:22 321

原创 LeetCode 228: Summary Ranges

228. Summary RangesDifficulty: Medium Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return [“0->2”,”4->5”,”7”].思路由于数组元素已排好序,而且没有

2016-06-03 14:02:16 360

原创 LeetCode 091: Decode Ways

091. Decode WaysDifficulty: Medium A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing

2016-06-03 13:48:57 304

原创 LeetCode 345: Reverse Vowels of a String

345. Reverse Vowels of a StringDifficulty: Easy Write 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: Give

2016-05-25 16:04:38 484

原创 LeetCode 329: Longest Increasing Path in a Matrix

329. Longest Increasing Path in a MatrixDifficulty: Hard Given an integer matrix, find the length of the longest increasing path. From each cell, you can either move to four directions: left, right,

2016-05-25 15:36:44 440

原创 LeetCode 328: Odd Even Linked List

328. Odd Even Linked ListDifficulty: Medium Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value

2016-05-25 15:14:32 479

原创 LeetCode 035: Search Insert Position

035. Search Insert PositionDifficulty: Medium Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order

2016-05-19 10:14:23 302

原创 LeetCode 020: Valid Parentheses

020. Valid ParenthesesDifficulty: Easy Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid. The brackets must close in the correct or

2016-05-19 10:01:02 345

原创 LeetCode 005: Longest Palindromic Substring

005. Longest Palindromic Substring思路回文可分为两种情况:AA’和AbA’(A为字符串,A’为A的反转字符串,b为一个字符)。 对于字符串s的每个字符,分别计算把它当作A的末尾字符和b时可取得的最长回文。 使用string的substr方法获取该回文子串。代码[C++]class Solution {public: string longestPali

2016-05-19 09:41:03 337

原创 LeetCode 012: Integer to Roman

012. Integer to RomanDifficulty: Medium Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.思路首先要知道罗马数字的记数方法,罗马数字采用七个罗马字母作数字: 基本字符 I V X

2016-05-11 10:46:31 330

原创 LeetCode 011: Container With Most Water

011. Container With Most WaterDifficulty: Medium Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoin

2016-05-11 10:04:21 297

原创 LeetCode 007: Reverse Integer

Reverse Integer Difficulty: Easy Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some g

2016-05-11 09:18:20 358

原创 LeetCode 136: Single Number

136. Single NumberDifficulty: Medium Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could

2016-05-05 17:34:21 279

原创 LeetCode 003: Longest Substring Without Repeating Characters

004. Longest Substring Without Repeating CharactersDifficulty: Medium Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer

2016-05-05 16:43:00 458

原创 LeetCode 217: Contains Duplicate

217.Contains DuplicateDifficulty: Easy Given an array of integers, find if thearray contains any duplicates. Your function should return true if any valueappears at least twice in the array, and it sh

2016-05-05 10:36:02 351

原创 LeetCode 219: Contains Duplicate II

219. Contains Duplicate IIDifficulty: Easy 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] = nums[j] and the differe

2016-05-05 10:30:21 315

空空如也

空空如也

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

TA关注的人

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