From b92118eb3189e23cfbb0a7c947e3963292cad9a3 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Mon, 25 Dec 2017 13:00:22 -0800 Subject: [PATCH] Remove questions --- questions/01-histogram-stars.md | 37 ------------ questions/02-matrix-islands.md | 56 ------------------- questions/03-k-smallest-two-sorted.md | 40 ------------- questions/04-synonyms.md | 36 ------------ .../05-longest-consecutive-set-of-numbers.md | 33 ----------- questions/06-string-compression.md | 25 --------- questions/07-biggest-number-after-swap.md | 21 ------- questions/08-pivot-index.md | 19 ------- questions/09-move-zeroes.md | 18 ------ 9 files changed, 285 deletions(-) delete mode 100644 questions/01-histogram-stars.md delete mode 100644 questions/02-matrix-islands.md delete mode 100644 questions/03-k-smallest-two-sorted.md delete mode 100644 questions/04-synonyms.md delete mode 100644 questions/05-longest-consecutive-set-of-numbers.md delete mode 100644 questions/06-string-compression.md delete mode 100644 questions/07-biggest-number-after-swap.md delete mode 100644 questions/08-pivot-index.md delete mode 100644 questions/09-move-zeroes.md diff --git a/questions/01-histogram-stars.md b/questions/01-histogram-stars.md deleted file mode 100644 index 766a2feb..00000000 --- a/questions/01-histogram-stars.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -id: 1 -title: Histogram Stars -topics: [array] -difficulty: easy ---- - -## Question - -``` -''' -Given an array of integers, print out a histogram using the array. Include a base layer (all stars) - -[5, 4, 0, 3, 4, 1] will result in the following: - -****** -***** -* -**** -***** -** -''' -``` - -## Follow Up - -``` -Print out a vertical version of the histogram. - -* -** * -** ** -** ** -** *** -****** -''' -``` diff --git a/questions/02-matrix-islands.md b/questions/02-matrix-islands.md deleted file mode 100644 index 26b3ed06..00000000 --- a/questions/02-matrix-islands.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -id: 2 -title: Matrix Islands -topics: [array, depth-first-search, matrix] -difficulty: easy -source: - - https://leetcode.com/problems/number-of-islands/ - - https://leetcode.com/problems/max-area-of-island/ - - https://leetcode.com/problems/number-of-distinct-islands/ ---- - -## Question - -``` -''' -Given a matrix of 0s and 1s, count the number of islands present. - -[[0,0,1], - [0,0,0], - [0,1,1]] - -Answer: 2 -''' -``` - -## Follow Up - -``` -Given a matrix of 0s and 1s, find the size of the largest island present. - -''' -[[0,0,1], - [0,0,0], - [0,1,1]] - -Answer: 2 -``` - -## Follow Up II - -``` -Given a matrix of 0s and 1s, find the number of unique islands present present. - -''' -[[1,0,1,0], - [1,0,0,0], - [0,1,1,0]] - -Answer: 3 - -[[1,1,0,1], - [0,0,0,0], - [0,1,1,0]] - -Answer: 2 -``` diff --git a/questions/03-k-smallest-two-sorted.md b/questions/03-k-smallest-two-sorted.md deleted file mode 100644 index 1eaf3037..00000000 --- a/questions/03-k-smallest-two-sorted.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -id: 3 -title: K Smallest Elements from Two Sorted Arrays -topics: [array] -difficulty: easy ---- - -## Question - -``` -''' -Find the k smallest elements from two sorted arrays of integers. - -Input: [1, 2, 3, 4, 5], [2, 3, 4], k = 3 -Output: [1, 2, 2] -''' -``` - -## Time Complexities - -- Bad: - - Time: O((n + m)log(n + m)) -- Good: - - Time: O(k) - -## Sample Answers - -```py -def k_smallest(A, B, k): - res = [] - a = b = 0 - while a < len(A) and b < len(B) and (a + b) < k: - if A[a] < B[b]: - res.append(A[a]) - a += 1 - else: - res.append(B[b]) - b += 1 - return res + A[a:k - b] + B[b:k - a] -``` diff --git a/questions/04-synonyms.md b/questions/04-synonyms.md deleted file mode 100644 index b3615d76..00000000 --- a/questions/04-synonyms.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -id: 4 -title: Synonyms -topics: [graph] -difficulty: medium ---- - -## Question - -``` -''' -Given a list of synonym pairs, determine if two words are synonymous. -Synonyms have a symmetric and transitive relation. i.e. if a <-> b and b <-> c, a <-> c. - -Input: -[["computer", "laptop"]] -"computer" -"laptop" - -Output: true - -Input: -[["computer", "laptop"], ["laptop", "pc"]] -"computer" -"pc" - -Output: true - -Input: -[["computer", "laptop"], ["laptop", "pc"], ["tablet", "iPad"]] -"computer" -"iPad" - -Output: false -''' -``` diff --git a/questions/05-longest-consecutive-set-of-numbers.md b/questions/05-longest-consecutive-set-of-numbers.md deleted file mode 100644 index 2231f8b3..00000000 --- a/questions/05-longest-consecutive-set-of-numbers.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -id: 5 -title: Longest Consecutive Set of Numbers -topics: [graph] -difficulty: hard -source: https://leetcode.com/problems/longest-consecutive-sequence/ ---- - -## Question - -``` -''' -Given an array of integers, find the size of the largest set of consecutive numbers present in the array. - -Input: [100, 4, 200, 1, 3, 2] -Output: 4 because {1, 2, 3, 4} -''' -``` - -## Sample Answers - -```py -def longest_consecutive(nums): - nums = set(nums) - best = 0 - for x in nums: - if x - 1 not in nums: - y = x + 1 - while y in nums: - y += 1 - best = max(best, y - x) - return best -``` diff --git a/questions/06-string-compression.md b/questions/06-string-compression.md deleted file mode 100644 index 60b6a227..00000000 --- a/questions/06-string-compression.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -id: 6 -title: String Compression and Decompression -topics: [string] -difficulty: easy ---- - -## Question - -``` -''' -Given a string, compress it by grouping repeated characters. The length after -compression must always be smaller than or equal to the original string. - -'aaabbccc' => 'a3b2c3' -''' -``` - -``` -''' -Given the above compressed string, decompress to obtain the original string. - -'a3b2c3' => 'aaabbccc' -''' -``` diff --git a/questions/07-biggest-number-after-swap.md b/questions/07-biggest-number-after-swap.md deleted file mode 100644 index 2f43f22f..00000000 --- a/questions/07-biggest-number-after-swap.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -id: 7 -title: Biggest Number After Swap -topics: [math] -difficulty: medium -source: https://leetcode.com/problems/maximum-swap/ ---- - -## Question - -``` -''' -Given a non-negative integer, find the maximum possible number if you can swap two digits at most once. - -2736 => 7236 -''' -``` - -## Follow Up - -- What if the given integer can be negative? diff --git a/questions/08-pivot-index.md b/questions/08-pivot-index.md deleted file mode 100644 index 81e978c9..00000000 --- a/questions/08-pivot-index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -id: 8 -title: Pivot Index -topics: [array] -difficulty: easy -source: https://leetcode.com/problems/find-pivot-index/ ---- - -## Question - -``` -''' -Given an array of integers, return the pivot index of this array. - -A pivot index is the index where the sum of the numbers to its left is equal to the sum of the numbers to its right: - -[7, 2, 3, 4] => 1 -''' -``` diff --git a/questions/09-move-zeroes.md b/questions/09-move-zeroes.md deleted file mode 100644 index e8f9556f..00000000 --- a/questions/09-move-zeroes.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -id: 9 -title: Move Zeroes -topics: [array] -difficulty: easy -source: https://leetcode.com/problems/move-zeroes/ ---- - -## Question - -``` -''' -Given an array of integers, write a function to move all zeroes to the end of it while -maintaining the relative order of the non-zero elements. - -[0, 1, 0, 3, 12] => [1, 3, 12, 0, 0]. -''' -```