forked from azl397985856/leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 修改azl397985856#209 azl397985856#279, 增加todo
- Loading branch information
luzhipeng
committed
Apr 24, 2019
1 parent
3f8598e
commit b159f16
Showing
8 changed files
with
217 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<mxfile modified="2019-04-24T03:55:11.597Z" host="www.draw.io" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36" etag="RuhMS0eC7MZ-eP7ukQ4K" version="10.6.3" type="device"><diagram id="2aZ_QtbOp8G18H4-aLN5" name="第 1 页">7ZpBb5swGIZ/DcdF2AYDxzZttsMqTcqh2mlywAFUwBScJemvnymGBOyknZYQouWU8NkY87yfzWuMgabp5mtB8uiJBTQxoBlsDPRgQAiQ54qfKrKtIw4GdSAs4kBW2gXm8RuVQVNGV3FAy05FzljC47wb9FmWUZ93YqQo2LpbbcmS7lVzElIlMPdJokaf44BHddSFzi7+jcZh1FwZYK8uSUlTWd5JGZGArfdC6NFA04IxXv9LN1OaVPAaLvV5swOlbccKmvHPnOA7L7Nis9g+/bRfnk3ivr3O11/kbfwmyUresOws3zYECrbKAlo1Agx0v45iTuc58avStdBcxCKeJrK45AV7oVOWsOL9bOQ5D6bjiBJ5IVpwujl4B6DlIhKKspTyYiuqyBNcSVKmkicP1ztdAJaxaE8TR8aITIWwbXhHS/yRwP4CHlDgHaNnfkzvBIy8LiNgqpBsDSP7XIygwghdnBGwRgYJKZDA5SGNLZOsEY42OLZMshVI1uUhjS2T8AjnJDS2THIVSI4CSdwuP/b8z1gmat4v4yTphUgSh5k49AUeKuL3FbxY2K47WZDGQVBdRou+K86SZVwaR2jL4z0HMpthE+LTqGSbPZWArahkaVSC51LJU1Ryj6TyPxm4gJRR28oJWPbcHHBVlO0qYBg7Zyow8bXABMjp0Gzp7ptjGw1JU3XHDeDrw4kcTXKag+JUjbQ6H4+UJuzNmpajSU7dtHk+mqpP8q6GZjOMJU0bq7k58DpYNVRXk5sIdHMTY01uDvsYUt/JJDQLq87cqWZ+HBaso8oHfsw076czeBr1cFe89glzKTsGVNfcaqeuMf5v7UBv5CHzwl4aqGb6NvA+KZ6lWa4OKh5Uzftt5B0Sr3GzjXjehUceVNcKN/EO2T/kTrry2ZqNkGHlU9cmrXzwJt/Rl6FY89pjWPHUzQdFsnbrskPO/MCzL1zbsqtKCVnQ5AcrYx4zrX7fexUWjHOWagTmLNflgehfXnU13YTVLvQkLX1CJwHNC+oTToNJzkpR89f7hnAvt0RHl65PfV+TB0EsGpB9Ktmq0ucUOWD13vViB040azhPkwaWfa40ULdXDIgTLqkY1Q57Awy/rqpNa4ECEeyaC3c/hMPqN42z5nTRnbqFuuQ2H3TfKKNeLthnm8zF4e5rg/eyvW820OMf</diagram></mxfile> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* @lc app=leetcode id=239 lang=javascript | ||
* | ||
* [239] Sliding Window Maximum | ||
* | ||
* https://leetcode.com/problems/sliding-window-maximum/description/ | ||
* | ||
* algorithms | ||
* Hard (37.22%) | ||
* Total Accepted: 150.8K | ||
* Total Submissions: 399.5K | ||
* Testcase Example: '[1,3,-1,-3,5,3,6,7]\n3' | ||
* | ||
* 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 in the window. Each time the sliding window moves right by one | ||
* position. Return the max sliding window. | ||
* | ||
* Example: | ||
* | ||
* | ||
* Input: nums = [1,3,-1,-3,5,3,6,7], and k = 3 | ||
* Output: [3,3,5,5,6,7] | ||
* Explanation: | ||
* | ||
* Window position Max | ||
* --------------- ----- | ||
* [1 3 -1] -3 5 3 6 7 3 | ||
* 1 [3 -1 -3] 5 3 6 7 3 | ||
* 1 3 [-1 -3 5] 3 6 7 5 | ||
* 1 3 -1 [-3 5 3] 6 7 5 | ||
* 1 3 -1 -3 [5 3 6] 7 6 | ||
* 1 3 -1 -3 5 [3 6 7] 7 | ||
* | ||
* | ||
* Note: | ||
* You may assume k is always valid, 1 ≤ k ≤ input array's size for non-empty | ||
* array. | ||
* | ||
* Follow up: | ||
* Could you solve it in linear time? | ||
*/ | ||
/** | ||
* @param {number[]} nums | ||
* @param {number} k | ||
* @return {number[]} | ||
*/ | ||
var maxSlidingWindow = function(nums, k) { | ||
// bad 时间复杂度O(n^2) | ||
if (nums.length === 0 || k === 0) return []; | ||
let slideWindow = []; | ||
const ret = []; | ||
for (let i = 0; i < nums.length - k + 1; i++) { | ||
for (let j = 0; j < k; j++) { | ||
slideWindow.push(nums[i + j]); | ||
} | ||
ret.push(Math.max(...slideWindow)); | ||
slideWindow = []; | ||
} | ||
return ret; | ||
// 双端队列优化时间复杂度 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* @lc app=leetcode id=214 lang=javascript | ||
* | ||
* [214] Shortest Palindrome | ||
* | ||
* https://leetcode.com/problems/shortest-palindrome/description/ | ||
* | ||
* algorithms | ||
* Hard (27.15%) | ||
* Total Accepted: 73.1K | ||
* Total Submissions: 266.3K | ||
* Testcase Example: '"aacecaaa"' | ||
* | ||
* 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 performing this transformation. | ||
* | ||
* Example 1: | ||
* | ||
* | ||
* Input: "aacecaaa" | ||
* Output: "aaacecaaa" | ||
* | ||
* | ||
* Example 2: | ||
* | ||
* | ||
* Input: "abcd" | ||
* Output: "dcbabcd" | ||
*/ | ||
/** | ||
* @param {string} s | ||
* @return {string} | ||
*/ | ||
var shortestPalindrome = function(s) { | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* @lc app=leetcode id=5 lang=javascript | ||
* | ||
* [5] Longest Palindromic Substring | ||
* | ||
* https://leetcode.com/problems/longest-palindromic-substring/description/ | ||
* | ||
* algorithms | ||
* Medium (26.70%) | ||
* Total Accepted: 525K | ||
* Total Submissions: 1.9M | ||
* Testcase Example: '"babad"' | ||
* | ||
* Given a string s, find the longest palindromic substring in s. You may | ||
* assume that the maximum length of s is 1000. | ||
* | ||
* Example 1: | ||
* | ||
* | ||
* Input: "babad" | ||
* Output: "bab" | ||
* Note: "aba" is also a valid answer. | ||
* | ||
* | ||
* Example 2: | ||
* | ||
* | ||
* Input: "cbbd" | ||
* Output: "bb" | ||
* | ||
* | ||
*/ | ||
/** | ||
* @param {string} s | ||
* @return {string} | ||
*/ | ||
var longestPalindrome = function(s) { | ||
|
||
}; | ||
|