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.
- Loading branch information
luzhipeng
committed
Apr 12, 2019
1 parent
fa05b23
commit db3aee9
Showing
11 changed files
with
257 additions
and
49 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
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,41 @@ | ||
/* | ||
* @lc app=leetcode id=169 lang=javascript | ||
* | ||
* [169] Majority Element | ||
* | ||
* https://leetcode.com/problems/majority-element/description/ | ||
* | ||
* algorithms | ||
* Easy (51.62%) | ||
* Total Accepted: 365.6K | ||
* Total Submissions: 702.5K | ||
* Testcase Example: '[3,2,3]' | ||
* | ||
* Given an array of size n, find the majority element. The majority element is | ||
* the element that appears more than ⌊ n/2 ⌋ times. | ||
* | ||
* You may assume that the array is non-empty and the majority element always | ||
* exist in the array. | ||
* | ||
* Example 1: | ||
* | ||
* | ||
* Input: [3,2,3] | ||
* Output: 3 | ||
* | ||
* Example 2: | ||
* | ||
* | ||
* Input: [2,2,1,1,1,2,2] | ||
* Output: 2 | ||
* | ||
* | ||
*/ | ||
/** | ||
* @param {number[]} nums | ||
* @return {number} | ||
*/ | ||
var majorityElement = function(nums) { | ||
|
||
}; | ||
|
File renamed without changes.
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,49 @@ | ||
/* | ||
* @lc app=leetcode id=240 lang=javascript | ||
* | ||
* [240] Search a 2D Matrix II | ||
* | ||
* https://leetcode.com/problems/search-a-2d-matrix-ii/description/ | ||
* | ||
* algorithms | ||
* Medium (40.30%) | ||
* Total Accepted: 170K | ||
* Total Submissions: 419.1K | ||
* Testcase Example: '[[1,4,7,11,15],[2,5,8,12,19],[3,6,9,16,22],[10,13,14,17,24],[18,21,23,26,30]]\n5' | ||
* | ||
* Write an efficient algorithm that searches for a value in an m x n matrix. | ||
* This matrix has the following properties: | ||
* | ||
* | ||
* Integers in each row are sorted in ascending from left to right. | ||
* Integers in each column are sorted in ascending from top to bottom. | ||
* | ||
* | ||
* Example: | ||
* | ||
* Consider the following matrix: | ||
* | ||
* | ||
* [ | ||
* [1, 4, 7, 11, 15], | ||
* [2, 5, 8, 12, 19], | ||
* [3, 6, 9, 16, 22], | ||
* [10, 13, 14, 17, 24], | ||
* [18, 21, 23, 26, 30] | ||
* ] | ||
* | ||
* | ||
* Given target = 5, return true. | ||
* | ||
* Given target = 20, return false. | ||
* | ||
*/ | ||
/** | ||
* @param {number[][]} matrix | ||
* @param {number} target | ||
* @return {boolean} | ||
*/ | ||
var searchMatrix = function(matrix, target) { | ||
|
||
}; | ||
|
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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,47 @@ | ||
/* | ||
* @lc app=leetcode id=88 lang=javascript | ||
* | ||
* [88] Merge Sorted Array | ||
* | ||
* https://leetcode.com/problems/merge-sorted-array/description/ | ||
* | ||
* algorithms | ||
* Easy (34.95%) | ||
* Total Accepted: 347.5K | ||
* Total Submissions: 984.7K | ||
* Testcase Example: '[1,2,3,0,0,0]\n3\n[2,5,6]\n3' | ||
* | ||
* Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as | ||
* one sorted array. | ||
* | ||
* Note: | ||
* | ||
* | ||
* The number of elements initialized in nums1 and nums2 are m and n | ||
* respectively. | ||
* You may assume that nums1 has enough space (size that is greater or equal to | ||
* m + n) to hold additional elements from nums2. | ||
* | ||
* | ||
* Example: | ||
* | ||
* | ||
* Input: | ||
* nums1 = [1,2,3,0,0,0], m = 3 | ||
* nums2 = [2,5,6], n = 3 | ||
* | ||
* Output: [1,2,2,3,5,6] | ||
* | ||
* | ||
*/ | ||
/** | ||
* @param {number[]} nums1 | ||
* @param {number} m | ||
* @param {number[]} nums2 | ||
* @param {number} n | ||
* @return {void} Do not return anything, modify nums1 in-place instead. | ||
*/ | ||
var merge = function(nums1, m, nums2, n) { | ||
|
||
}; | ||
|
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,89 @@ | ||
/* | ||
* @lc app=leetcode id=887 lang=javascript | ||
* | ||
* [887] Super Egg Drop | ||
* | ||
* https://leetcode.com/problems/super-egg-drop/description/ | ||
* | ||
* algorithms | ||
* Hard (24.64%) | ||
* Total Accepted: 6.2K | ||
* Total Submissions: 24.9K | ||
* Testcase Example: '1\n2' | ||
* | ||
* You are given K eggs, and you have access to a building with N floors from 1 | ||
* to N. | ||
* | ||
* Each egg is identical in function, and if an egg breaks, you cannot drop it | ||
* again. | ||
* | ||
* You know that there exists a floor F with 0 <= F <= N such that any egg | ||
* dropped at a floor higher than F will break, and any egg dropped at or below | ||
* floor F will not break. | ||
* | ||
* Each move, you may take an egg (if you have an unbroken one) and drop it | ||
* from any floor X (with 1 <= X <= N). | ||
* | ||
* Your goal is to know with certainty what the value of F is. | ||
* | ||
* What is the minimum number of moves that you need to know with certainty | ||
* what F is, regardless of the initial value of F? | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* | ||
* Example 1: | ||
* | ||
* | ||
* Input: K = 1, N = 2 | ||
* Output: 2 | ||
* Explanation: | ||
* Drop the egg from floor 1. If it breaks, we know with certainty that F = 0. | ||
* Otherwise, drop the egg from floor 2. If it breaks, we know with certainty | ||
* that F = 1. | ||
* If it didn't break, then we know with certainty F = 2. | ||
* Hence, we needed 2 moves in the worst case to know what F is with | ||
* certainty. | ||
* | ||
* | ||
* | ||
* Example 2: | ||
* | ||
* | ||
* Input: K = 2, N = 6 | ||
* Output: 3 | ||
* | ||
* | ||
* | ||
* Example 3: | ||
* | ||
* | ||
* Input: K = 3, N = 14 | ||
* Output: 4 | ||
* | ||
* | ||
* | ||
* | ||
* Note: | ||
* | ||
* | ||
* 1 <= K <= 100 | ||
* 1 <= N <= 10000 | ||
* | ||
* | ||
* | ||
* | ||
* | ||
*/ | ||
/** | ||
* @param {number} K | ||
* @param {number} N | ||
* @return {number} | ||
*/ | ||
var superEggDrop = function(K, N) { | ||
|
||
}; | ||
|