- 博客(88)
- 资源 (7)
- 收藏
- 关注
原创 leetcode 394. Decode String
Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is g
2017-07-31 15:46:24 296
原创 leetcode 436. Find Right Interval
Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is on
2017-07-31 14:29:39 413
原创 leetcode 341. Flatten Nested List Iterator
Given a nested list of integers, implement an iterator to flatten it.Each element is either an integer, or a list -- whose elements may also be integers or other lists.Example 1:Given the li
2017-07-31 13:03:34 325
原创 leetcode 415. Add Strings
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits 0-9.Bo
2017-07-30 15:39:44 207
原创 leetcode 137. Single Number II
Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could
2017-07-30 10:57:29 257
原创 leetcode 482. License Key Formatting
Now you are given a string S, which represents a software license key which we would like to format. The string S is composed of alphanumerical characters and dashes. The dashes split the alphanumeric
2017-07-30 10:22:57 1121
原创 leetcode 390. Elimination Game
There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach the end of the list.Repeat the previous step aga
2017-07-29 16:24:44 379
转载 Josephus Problem 约瑟夫环问题的讨论
问题分析 Josephus环的问题看起来很简单,假设有n个人排成一个圈。从第一个人开始报数,数到第m个人的时候这个人从队列里出列。然后继续在环里数后面第m个人,让其出列直到所有人都出列。求所有这些人出列的排列顺序。 一个典型的示例如下图所示: 在上图中,我们从n1元素开始顺时针数到第4个元素,然后n4号出列。这样,我们就剩下了7个元素。我们在剩下的
2017-07-29 15:44:54 1172
原创 leetcode 621. Task Scheduler
Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent different tasks.Tasks could be done without original order. Each task could b
2017-07-29 14:33:26 592
原创 leetcode 645. Set Mismatch
The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of
2017-07-29 12:14:41 346
原创 leetcode 377. Combination Sum IV
Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target.Example:nums = [1, 2, 3]target = 4The pos
2017-07-28 14:46:09 260
原创 leetcode 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.平衡二叉树就是平衡二叉查找树,它的定义就是:是一棵空树 或 它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一棵平衡二叉树。递归方式的解法:package le
2017-07-28 13:38:54 223
原创 leetcode 424. Longest Repeating Character Replacement
Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the length of a longest substring containing all repe
2017-07-28 11:40:19 469
原创 leetcode 449. Serialize and Deserialize BST
Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be
2017-07-27 18:38:04 604
原创 leetcode 524. Longest Word in Dictionary through Deleting
Given a string and a string dictionary, find the longest string in the dictionary that can be formed by deleting some characters of the given string. If there are more than one possible results, retur
2017-07-27 14:54:03 479
原创 leetcode 319. 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 every third bulb (turning on if it's off or turning of
2017-07-27 13:19:15 212
原创 leetcode 398. Random Pick Index
Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.Note:The array size can
2017-07-26 16:38:55 339
原创 leetcode 516. Longest Palindromic Subsequence 最大回文子序列
Given 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"Output:4One possible longest palind
2017-07-26 15:17:16 334
原创 leetcode 646. Maximum Length of Pair Chain
You are given n pairs of numbers. In every pair, the first number is always smaller than the second number.Now, we define a pair (c, d) can follow another pair (a, b) if and only if b . Chain
2017-07-26 13:10:23 2380
原创 leetcode 337. House Robber III
The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour
2017-07-25 17:25:53 325
原创 leetcode 287. 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 number must exist. Assume that there is only one duplicate number,
2017-07-25 14:43:52 256
原创 leetcode 142. Linked List Cycle II
本来应该是做leetcode 287. Find the Duplicate Number的。但是这题的思路需要用到leetcode 142解题思想。因此,先做142,再去弄明白287的思路,是一个更好的路线。Given a linked list, return the node where the cycle begins. If there is no cycle, return
2017-07-25 14:01:04 267
原创 leetcode 46. 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,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]
2017-07-24 16:11:49 316
原创 leetcode 328. Odd Even Linked List
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 in the nodes.You should try to do it in
2017-07-24 13:53:33 258
原创 leetcode 312. Burst Balloons
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get num
2017-07-24 11:16:35 273
原创 leetcode 543. Diameter of Binary Tree
Given 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 tree. This path may or may n
2017-07-23 16:52:44 292
原创 leetcode 230. 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 always valid, 1 ? k ? BST's total elements.Follow up:What if the
2017-07-23 13:51:30 261
原创 leetcode 241. Different Ways to Add Parentheses
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *.Example 1
2017-07-23 12:50:35 239
原创 leetcode 551. Student Attendance Record I
You are given a string representing an attendance record for a student. The record only contains the following three characters:'A' : Absent.'L' : Late.'P' : Present.A student could be rewar
2017-07-22 16:44:18 325
原创 leetcode 423. Reconstruct Original Digits from English
Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order.Note:Input contains only lowercase English letters.Input is g
2017-07-22 15:53:58 359
原创 leetcode 452. Minimum Number of Arrows to Burst Balloons
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordin
2017-07-22 14:18:44 338
原创 leetcode 494. Target Sum
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.Find out h
2017-07-22 11:41:09 428
原创 leetcode 318. Maximum Product of Word Lengths
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 assume that each word will contain only lower case
2017-07-21 16:56:17 244
原创 leetcode 541. Reverse String II
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them
2017-07-21 16:01:44 218
原创 leetcode 268. Missing Number
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.Note:Your algorithm shoul
2017-07-21 15:22:31 246
原创 leetcode 583. Delete Operation for Two Strings
Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in each step you can delete one character in either string.Example 1:Input: "
2017-07-21 14:48:25 529
原创 leetcode 392. Is Subsequence
Given 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 ~= 500,000) strin
2017-07-20 18:55:25 305
原创 leetcode 12. Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.将十进制数字转化为罗马数字。这又要温习一下罗马数字了:基本字符IVXL
2017-07-20 17:21:21 301
原创 leetcode 378. Kth Smallest Element in a Sorted Matrix
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, not
2017-07-20 16:49:34 243
原创 leetcode 22. Generate Parentheses
Given 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-07-19 19:17:33 237
[数学建模方法与分析].(新西兰)Mark.M.Meerschaert.清晰PDF版
2017-09-15
有名的combobox下拉框插件压缩后的js版本
2016-09-23
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人