Files

16 lines
958 B
Plaintext

Twelve problems: optimised answer vs brute-force answer on one example each
===========================================================================
1. maxSumSubarray([2, 1, 5, 1, 3, 2], 3) = 9 brute = 9
2. permutationInString("ab", "eidbaooo") = true; ("ab", "eidboaoo") = false brute = true / false
3. slidingWindowMaximum([1, 3, -1, -3, 5, 3, 6, 7], 3) = [3, 3, 5, 5, 6, 7]
4. longestUniqueSubstring("abcabcbb") = 3 brute = 3
5. longestKDistinct("eceba", 2) = 3 brute = 3
6. characterReplacement("AABABBA", 1) = 4 brute = 4
7. longestOnes([1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0], 2) = 6 brute = 6
8. minSubArrayLen(7, [2, 3, 1, 2, 4, 3]) = 2 brute = 2
9. minWindow("ADOBECODEBANC", "ABC") = "BANC"; minWindow("a", "aa") = "" brute = "BANC"
10. twoSumSorted([2, 7, 11, 15], 9) = [0, 1]; target 100 = [] (none)
11. threeSum([-1, 0, 1, 2, -1, -4]) = [[-1, -1, 2], [-1, 0, 1]]
12. maxArea([1, 8, 6, 2, 5, 4, 8, 3, 7]) = 49 brute = 49