diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..4631c57e5 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,13 @@ +# These are supported funding model platforms + +custom: https://paypal.me/aQuaYi +issuehunt: aquayi +ko_fi: aquayi +liberapay: aQua + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +otechie: # Replace with a single Otechie username diff --git a/.gitignore b/.gitignore index 0a4848118..873ef8600 100644 --- a/.gitignore +++ b/.gitignore @@ -21,4 +21,6 @@ testDir/ coverage.txt # 删除 Goland 设置 -.idea \ No newline at end of file +.idea + +.orig \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 00d60d30d..f5175e0be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,18 @@ language: go go: - - 1.9.x - + - master + # whitelist branches: only: - master - - stable + - stable -script: +script: - go get -t -v ./... - go vet ./... - bash ./test.sh after_success: - - bash <(curl -s https://codecov.io/bash) - -notifications: - webhooks: https://hooks.pubu.im/services/3wp9q4yqlzm8fxr \ No newline at end of file + - bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..98a30acc3 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "debug", + "type": "go", + "request": "launch", + "mode": "test", + "program": "${fileDirname}" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index a18e60f7e..5e8440178 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,308 @@ { - "todo-tree.flat": true + "todo-tree.flat": true, + "cSpell.words": [ + "ABCDEFG", + "ASCI", + "Barcodes", + "Bigram", + "DDDDLLLD", + "DDDDLLLL", + "DDDLLLL", + "DDDRRRR", + "DDRR", + "DRRR", + "Defanging", + "GGLLGG", + "GLGLGGLGL", + "GLRLLGLL", + "Gawl", + "Gawlme", + "Gawlqt", + "Gawluvn", + "Gaxwul", + "Gcamwel", + "Gnaynwl", + "IDID", + "Icode", + "Inorder", + "LDDD", + "LLDDD", + "LLLD", + "LLLDD", + "LLLDDDDD", + "LLLLD", + "LLLLDDD", + "LLLLRRRR", + "LLLLUUUU", + "LLLRRR", + "LLLUU", + "LLUU", + "Leet", + "NLZGM", + "Negabinary", + "Ocurrences", + "Paddr", + "Puerkito", + "Qedo", + "RLLLLRRRLR", + "RLRRLLRLRL", + "RRDD", + "RRLL", + "RRRD", + "RRRRU", + "RRRU", + "RRRUU", + "Satisfiability", + "Squareful", + "Subarrays", + "Subsequences", + "Supersequence", + "Superstring", + "Tribonacci", + "URRR", + "URRRR", + "URRRUU", + "URRRUUUU", + "URUUUU", + "UURRR", + "UUUULLLL", + "UUUUUR", + "UUUUURRR", + "VPS's", + "Vals", + "a", + "aaleex", + "abcdefgb", + "abcdefgbabcdei", + "abcdefgh", + "abcdefghijklmnopqrstuvwxy", + "abcdefghijklmnopqrstuvwxyz", + "abcdexyzfzz", + "abdfg", + "abdfh", + "abefg", + "abefh", + "aboveyz", + "abrodyz", + "abslute", + "absoryz", + "acdfg", + "acdfh", + "acefg", + "acefh", + "actresz", + "actt", + "akyj", + "alexlovesleetcode", + "alicez", + "alphabet", + "antaprezatepzapreanta", + "apmnolkjihgfedcbq", + "append", + "arith", + "asas", + "asdfdfs", + "assqjfwarvjcjedqtoz", + "at", + "atach", + "atgcatc", + "b", + "barcode", + "bbazb", + "bcdefghijkl", + "bcdei", + "board", + "bool", + "boustrophedonically", + "btree", + "builder", + "byte", + "cancel", + "cand", + "cands", + "capitlization", + "catg", + "cedefifgstkyxfcuajfa", + "checked", + "chromedp", + "clean", + "codecov", + "coordinate", + "count", + "ctaagt", + "ctxt", + "cut", + "czvh", + "d", + "deck", + "defang", + "defanged", + "dfdsfkjdfleiwllsgoidkjflsdfjdfierwsd", + "dfs", + "dietpepsi", + "diff", + "domain", + "dot", + "dqtozctcdk", + "e", + "efghabcd", + "emails", + "enention", + "etco", + "exection", + "exention", + "exps", + "fassqjfwarvjcjedq", + "fcuajfassqjfwarvjc", + "fgbabcde", + "fghij", + "for", + "form", + "fumcfsngphjyfhhwkqa", + "func", + "fwarvjcjedqtozctcd", + "gaswxyz", + "gcta", + "gctaagttcatgcatc", + "ghefcdab", + "ghiabcdefhelloadamhelloabcdefghi", + "gitignore", + "goconvey", + "gruj", + "grukj", + "grukkmj", + "grukmj", + "hgfedcba", + "hunu", + "i", + "if", + "iloveu", + "increasing", + "index", + "indexs", + "inention", + "int", + "ints", + "is", + "j", + "jarzoaupviqkx", + "keet", + "keti", + "keto", + "klmno", + "kloveiloveu", + "ksqsq", + "ksqvsq", + "ksqvsyq", + "kssq", + "kyxfcuajfassqjfwa", + "l", + "laiden", + "leelee", + "leetcode", + "len", + "length", + "letcod", + "lexicographicaly", + "lleeelee", + "longest", + "loonbalxballpoon", + "lpnpelpwy", + "make", + "map", + "max", + "maxs", + "move", + "mozillazg", + "mpma", + "mymflnlegtrnr", + "n", + "nbsp", + "next", + "nlaebolko", + "nlaeolko", + "ntse", + "num", + "numberify", + "nums", + "numsnil", + "okhateimloveyou", + "ooncedefifgstkyxfcua", + "path", + "ppedxfumcfsngphjyf", + "pqrst", + "pwwkew", + "pyqrhjamdrias", + "querys", + "r", + "rame", + "range", + "reactjs", + "replace", + "reqs", + "res", + "return", + "revealed", + "rorse", + "rune", + "rxocajdeo", + "saeed", + "sb", + "seq", + "sfgstfsqlqmfjv", + "size", + "sort", + "split", + "splitted", + "ssaaedd", + "stretchr", + "string", + "strings", + "strs", + "subarray", + "subgrid", + "submatrices", + "submatrix", + "subtrees", + "superpalindrome", + "superpalindromes", + "t", + "tail", + "target", + "tcode", + "testemail", + "tmps", + "to", + "true", + "ttca", + "u", + "unique", + "univalued", + "username", + "uvwxy", + "uvwxyz", + "var", + "welldonehoneyr", + "wordlist", + "worldabcefghijkmnpqstuvxyz", + "write", + "x", + "xbyqqh", + "y", + "yeellow", + "yllw", + "yollew", + "yollow", + "zaaaz", + "zcpzvh", + "zczpzfvdhx", + "zczpzvdhx", + "zczpzvh", + "zczpzvhx", + "zczvh", + "zppedxfumcfsngp", + "zzwobllyxktqeibfoupcpptncggrdqbkji" + ], + "cSpell.language": "en,en-US", + "todo-tree.tree.flat": true } \ No newline at end of file diff --git a/Algorithms/0001.two-sum/README.md b/Algorithms/0001.two-sum/README.md index e0bada077..e4c09371a 100755 --- a/Algorithms/0001.two-sum/README.md +++ b/Algorithms/0001.two-sum/README.md @@ -1,26 +1,30 @@ # [1. Two Sum](https://leetcode.com/problems/two-sum/) ## 题目 + Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: -``` + +```text Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1]. ``` + ## 解题思路 -``` + +```go a + b = target ``` + 也可以看成是 -``` + +```go a = target - b ``` -在`map[整数]整数的序号`中,可以查询到a的序号。这样就不用嵌套两个for循环了。 - - +在`map[整数]整数的序号`中,可以查询到a的序号。这样就不用嵌套两个for循环了。 \ No newline at end of file diff --git a/Algorithms/0001.two-sum/two-sum.go b/Algorithms/0001.two-sum/two-sum.go index 7832a3df2..895ca0c3f 100755 --- a/Algorithms/0001.two-sum/two-sum.go +++ b/Algorithms/0001.two-sum/two-sum.go @@ -1,21 +1,21 @@ package problem0001 func twoSum(nums []int, target int) []int { - // m 负责保存map[整数]整数的序列号 - m := make(map[int]int, len(nums)) + // index 负责保存map[整数]整数的序列号 + index := make(map[int]int, len(nums)) // 通过 for 循环,获取b的序列号 for i, b := range nums { // 通过查询map,获取a = target - b的序列号 - if j, ok := m[target-b]; ok { + if j, ok := index[target-b]; ok { // ok 为 true - // 说明在i之前,存在nums[j] == a + // 说明在i之前,存在 nums[j] == a return []int{j, i} - // 注意,顺序是j,i,因为j 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 +``` ## 解题思路 + +```text (2 -> 4 -> 3)是 342 (5 -> 6 -> 4)是 465 @@ -16,13 +21,16 @@ Output: 7 -> 0 -> 8 (7 -> 0 -> 8)是 807 342 + 465 = 807 +``` 所以,题目的本意是,把整数换了一种表达方式后,实现其加法。 设计程序时候,需要处理的点有 + 1. 位上的加法,需要处理进位问题 1. 如何进入下一位运算 1. 按位相加结束后,也还需要处理进位问题。 ## 总结 + 读懂题意后,按步骤实现题目要求。 \ No newline at end of file diff --git a/Algorithms/0002.add-two-numbers/add-two-numbers.go b/Algorithms/0002.add-two-numbers/add-two-numbers.go index 7fd17b306..f20e86b08 100755 --- a/Algorithms/0002.add-two-numbers/add-two-numbers.go +++ b/Algorithms/0002.add-two-numbers/add-two-numbers.go @@ -1,71 +1,39 @@ package problem0002 -/** - * Definition for singly-linked list. - * type ListNode struct { - * Val int - * Next *ListNode - * } - */ -type ListNode struct { - Val int - Next *ListNode -} +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// ListNode defines for singly-linked list. +// type ListNode struct { +// Val int +// Next *ListNode +// } +type ListNode = kit.ListNode func addTwoNumbers(l1 *ListNode, l2 *ListNode) *ListNode { - result := &ListNode{} - temp := result - v, n := 0, 0 + resPre := &ListNode{} + cur := resPre + carry := 0 - for { - // 在当前位上进行加法运算 - v, n = add(l1, l2, n) - temp.Val = v + for l1 != nil || l2 != nil || carry > 0 { + sum := carry - // 进入下一位 - l1 = next(l1) - l2 = next(l2) - // 如果两个数的下一位都为nil,则结束按位相加的运算 - if l1 == nil && l2 == nil { - break + if l1 != nil { + sum += l1.Val + l1 = l1.Next } - // 为下一位运算准备节点 - temp.Next = &ListNode{} - temp = temp.Next - } - - // n == 1 说明,最后一次加运算进位了,需要再添加一个节点。 - if n == 1 { - temp.Next = &ListNode{Val: n} - } - - return result -} - -// next 进入l的下一位。 -func next(l *ListNode) *ListNode { - if l != nil { - return l.Next - } - return nil -} - -func add(n1, n2 *ListNode, i int) (v, n int) { - if n1 != nil { - v += n1.Val - } - - if n2 != nil { - v += n2.Val - } + if l2 != nil { + sum += l2.Val + l2 = l2.Next + } - v += i + carry = sum / 10 - if v > 9 { - v -= 10 - n = 1 + cur.Next = &ListNode{Val: sum % 10} + cur = cur.Next } - return + return resPre.Next } diff --git a/Algorithms/0006.zigzag-conversion/README.md b/Algorithms/0006.zigzag-conversion/README.md index 50acc4730..6c84fcf8f 100755 --- a/Algorithms/0006.zigzag-conversion/README.md +++ b/Algorithms/0006.zigzag-conversion/README.md @@ -1,30 +1,39 @@ # [6. ZigZag Conversion](https://leetcode.com/problems/zigzag-conversion/) ## 题目 + The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) -``` + +```text P A H N A P L S I I G Y I R ``` + And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conversion given a number of rows: + ```go func convert(text string, nRows int) string ``` + convert("PAYPALISHIRING", 3) should return "PAHNAPLSIIGYIR". ## 解题思路 + 输入"ABCDEFGHIJKLMNOPQRSTUVWXYZ"和参数5后,得到答案"AGMSYBFHLNRTXZCEIKOQUWDJPV", 按照题目的摆放方法,可得: -``` + +```text A I Q Y B HJ PR XZ C G K O S W DF LN TV E M U ``` + 可以看到,各行字符在原字符串中的索引号为 + 1. 0行,0, 8, 16, 24 1. 1行,1, 7,9, 15,17, 23,25 1. 2行,2, 6, 10, 14, 18, 22 @@ -32,9 +41,9 @@ E M U 1. 4行,4, 12, 20 令p=numRows×2-2,可以总结出以下规律 + 1. 0行, 0×p,1×p,... 1. r行, r,1×p-r,1×p+r,2×p-r,2×p+r,... 1. 最后一行, numRow-1, numRow-1+1×p,numRow-1+2×p,... -只需编程依次处理各行即可。 -## 总结 +只需编程依次处理各行即可。 \ No newline at end of file diff --git a/Algorithms/0008.string-to-integer-atoi/README.md b/Algorithms/0008.string-to-integer-atoi/README.md index 31688ed81..8e3ec742a 100755 --- a/Algorithms/0008.string-to-integer-atoi/README.md +++ b/Algorithms/0008.string-to-integer-atoi/README.md @@ -1,12 +1,65 @@ # [8. String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/) ## 题目 -Implement atoi to convert a string to an integer. -Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. +Implement "atoi" which converts a string to an integer. + +The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes an optional initial plus or minus sign followed by as many numerical digits as possible, and interprets them as a numerical value. + +The string can contain additional characters after those that form the integral number, which are ignored and have no effect on the behavior of this function. + +If the first sequence of non-whitespace characters in str is not a valid integral number, or if no such sequence exists because either str is empty or it contains only whitespace characters, no conversion is performed. + +If no valid conversion could be performed, a zero value is returned. + +Note: + +- Only the space character ' ' is considered as whitespace character. +- Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. If the numerical value is out of the range of representable values, INT_MAX (2^31 − 1) or INT_MIN (−2^31) is returned. + +Example 1: + +```text +Input: "42" +Output: 42 +``` + +Example 2: + +```text +Input: " -42" +Output: -42 +Explanation: The first non-whitespace character is '-', which is the minus sign. Then take as many numerical digits as possible, which gets 42. +``` + +Example 3: + +```text +Input: "4193 with words" +Output: 4193 +Explanation: Conversion stops at digit '3' as the next character is not a numerical digit. +``` + +Example 4: + +```text +Input: "words and 987" +Output: 0 +Explanation: The first non-whitespace character is 'w', which is not a numerical digit or a +/- sign. Therefore no valid conversion could be performed. +``` + +Example 5: + +```text +Input: "-91283472332" +Output: -2147483648 +Explanation: The number "-91283472332" is out of the range of a 32-bit signed integer. Therefore INT_MIN (−231) is returned. +``` ## 解题思路 + 转换并不难,难得的是,处理各种奇葩的输入。详见程序注释。 ## 总结 + 良好的单元测试真的很重要。 diff --git a/Algorithms/0008.string-to-integer-atoi/string-to-integer-atoi.go b/Algorithms/0008.string-to-integer-atoi/string-to-integer-atoi.go index 1a9bc4132..016f60638 100755 --- a/Algorithms/0008.string-to-integer-atoi/string-to-integer-atoi.go +++ b/Algorithms/0008.string-to-integer-atoi/string-to-integer-atoi.go @@ -3,71 +3,52 @@ package problem0008 import "strings" import "math" -func myAtoi(str string) int { - // 除去 str 首尾的空格 - s := strings.TrimSpace(str) - if len(s) == 0 { - return 0 - } - - // 取出 s 的符号和主体 x - sign, x := getSign(s) - - // 裁剪x丢弃混入的非数字字符 - x = trim(x) - - // 根据sigh和x,转换成int - return convert(sign, x) +func myAtoi(s string) int { + return convert(clean(s)) } -func getSign(s string) (int, string) { - sign := 1 +func clean(s string) (sign int, abs string) { + // 除去首尾的空格 + s = strings.TrimSpace(s) + if s == "" { + return + } + switch s[0] { - case '-': - s = s[1:] - sign = -1.0 + case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': + sign, abs = 1, s case '+': - s = s[1:] + sign, abs = 1, s[1:] + case '-': + sign, abs = -1, s[1:] default: + abs = "" + return } - return sign, s -} - -func trim(s string) string { - for i := range s { - if s[i] < '0' || '9' < s[i] { - return s[:i] + for i, b := range abs { + if b < '0' || '9' < b { + abs = abs[:i] + break } } - return s + return } -func convert(sign int, s string) int { - base := 1 * sign - res := 0 - yes := false - - for i := len(s) - 1; i >= 0; i-- { - // 为了防止特别长的数字,甚至超过float64的范围,所以,每一步都检查是否溢出 - res, yes = isOverflow(res + (int(s[i])-48)*base) - if yes { - return res +func convert(sign int, absStr string) int { + abs := 0 + + for _, b := range absStr { + abs = abs*10 + int(b-'0') + // 检查溢出 + switch { + case sign == 1 && abs > math.MaxInt32: + return math.MaxInt32 + case sign == -1 && sign*abs < math.MinInt32: + return math.MinInt32 } - base *= 10 } - return res -} - -func isOverflow(i int) (int, bool) { - switch { - case i > math.MaxInt32: - return math.MaxInt32, true - case i < math.MinInt32: - return math.MinInt32, true - default: - return i, false - } + return sign * abs } diff --git a/Algorithms/0008.string-to-integer-atoi/string-to-integer-atoi_test.go b/Algorithms/0008.string-to-integer-atoi/string-to-integer-atoi_test.go index 8ab82e1da..a7f2f187c 100755 --- a/Algorithms/0008.string-to-integer-atoi/string-to-integer-atoi_test.go +++ b/Algorithms/0008.string-to-integer-atoi/string-to-integer-atoi_test.go @@ -25,6 +25,16 @@ func Test_OK(t *testing.T) { ast := assert.New(t) qs := []question{ + + question{ + p: para{ + one: "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000522545459", + }, + a: ans{ + one: math.MaxInt32, + }, + }, + question{ p: para{ one: "123", @@ -83,7 +93,7 @@ func Test_OK(t *testing.T) { }, question{ p: para{ - one: "", + one: " ", }, a: ans{ one: 0, @@ -97,6 +107,7 @@ func Test_OK(t *testing.T) { one: 1, }, }, + question{ p: para{ one: "-", @@ -105,6 +116,7 @@ func Test_OK(t *testing.T) { one: 0, }, }, + question{ p: para{ one: "922337999995452345782348957234895793875923845789234758923745987239485798345789237598235980234859023849058349058903890869059068490683490869038690385690385906839056890548690586904568905468905908590839056890345869034856903568903854690835906834906839045869034869034568903458690356903569056908345906839056890586903546890345869034568903586905689054685690905689035468905689056890879056907890879086903548690387905469054690890689035869038569034856908356908345906890345869056890356890358690569083546908549086905690345869038569034569083590689058690385690358690586908345906839086390689056903869058690345869038690586908569054690834590689054869083569035490689035689058690586905409689086905869038569083549068390468903586903569038549068905869054690345906890346904856903546908345906890568903569054690590685906905689058690586905869056890869035869035890789068790907903890835657428975457575789075098759084752897589475029847589047589234759028475902847592834752908759827589725987517891598715908749871908579841790817598715901875901874190879085791879018571897491837249874987235987589734897123489712390847913857190287549018735902036854775809", diff --git a/Algorithms/0010.regular-expression-matching/README.md b/Algorithms/0010.regular-expression-matching/README.md index 19a8ce759..3312a2454 100755 --- a/Algorithms/0010.regular-expression-matching/README.md +++ b/Algorithms/0010.regular-expression-matching/README.md @@ -1,30 +1,67 @@ # [10. Regular Expression Matching](https://leetcode.com/problems/regular-expression-matching/) ## 题目 + +Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. Implement regular expression matching with support for '.' and '*'. -``` + +```text '.' Matches any single character. '*' Matches zero or more of the preceding element. +``` The matching should cover the entire input string (not partial). -The function prototype should be: -bool isMatch(const char *s, const char *p) +Note: -Some examples: +- s could be empty and contains only lowercase letters a-z. +- p could be empty and contains only lowercase letters a-z, and characters like . or *. -isMatch("aa","a") ? false -isMatch("aa","aa") ? true -isMatch("aaa","aa") ? false -isMatch("aa", "a*") ? true -isMatch("aa", ".*") ? true -isMatch("ab", ".*") ? true -isMatch("aab", "c*a*b") ? true +Example 1: + +```text +Input: +s = "aa" +p = "a" +Output: false +Explanation: "a" does not match the entire string "aa". ``` -## 解题思路 +Example 2: +```text +Input: +s = "aa" +p = "a*" +Output: true +Explanation: '*' means zero or more of the preceding element, 'a'. Therefore, by repeating 'a' once, it becomes "aa". +``` -## 总结 +Example 3: -动态规划问题。 \ No newline at end of file +```text +Input: +s = "ab" +p = ".*" +Output: true +Explanation: ".*" means "zero or more (*) of any character (.)". +``` + +Example 4: + +```text +Input: +s = "aab" +p = "c*a*b" +Output: true +Explanation: c can be repeated 0 times, a can be repeated 1 time. Therefore it matches "aab". +``` + +Example 5: + +```text +Input: +s = "mississippi" +p = "mis*is*p*." +Output: false +``` diff --git a/Algorithms/0010.regular-expression-matching/regular-expression-matching.go b/Algorithms/0010.regular-expression-matching/regular-expression-matching.go index 7db5a395e..8440a27a0 100755 --- a/Algorithms/0010.regular-expression-matching/regular-expression-matching.go +++ b/Algorithms/0010.regular-expression-matching/regular-expression-matching.go @@ -1,45 +1,52 @@ package problem0010 -// 程序中存在以下假设 -// "*" 不会出现在p的首位 -// "**" 不会出现,但会出现 ".*."" , ".*.." , ".*.*" +func isMatch(s, p string) bool { + sSize := len(s) + pSize := len(p) -func isMatch(s string, p string) bool { - dp := make([][]bool, len(p)+1) + dp := make([][]bool, sSize+1) for i := range dp { - dp[i] = make([]bool, len(s)+1) + dp[i] = make([]bool, pSize+1) } - dp[0][0] = true + /* dp[i][j] 代表了 s[:i] 能否与 p[:j] 匹配 */ - for i := 2; i < len(dp); i += 2 { - if p[i-1] == '*' { - dp[i][0] = true - } else { - break + dp[0][0] = true + /** + * 根据题目的设定, "" 可以与 "a*b*c*" 相匹配 + * 所以,需要把相应的 dp 设置成 true + */ + for j := 1; j < pSize && dp[0][j-1]; j += 2 { + if p[j] == '*' { + dp[0][j+1] = true } } - for i := 1; i < len(dp); i++ { - if i < len(p) && p[i] == '*' { - continue - } - - for j := 1; j < len(dp[0]); j++ { - - if p[i-1] == '*' { - if p[i-2] == '.' { - dp[i][j] = dp[i-2][j-1] || dp[i][j-1] || dp[i-2][j] + for i := 0; i < sSize; i++ { + for j := 0; j < pSize; j++ { + if p[j] == '.' || p[j] == s[i] { + /* p[j] 与 s[i] 可以匹配上,所以,只要前面匹配,这里就能匹配上 */ + dp[i+1][j+1] = dp[i][j] + } else if p[j] == '*' { + /* 此时,p[j] 的匹配情况与 p[j-1] 的内容相关。 */ + if p[j-1] != s[i] && p[j-1] != '.' { + /** + * p[j] 无法与 s[i] 匹配上 + * p[j-1:j+1] 只能被当做 "" + */ + dp[i+1][j+1] = dp[i+1][j-1] } else { - dp[i][j] = (dp[i-2][j]) || (p[i-2] == s[j-1] && (dp[i-2][j-1] || dp[i][j-1])) + /** + * p[j] 与 s[i] 匹配上 + * p[j-1;j+1] 作为 "x*", 可以有三种解释 + */ + dp[i+1][j+1] = dp[i+1][j-1] || /* "x*" 解释为 "" */ + dp[i+1][j] || /* "x*" 解释为 "x" */ + dp[i][j+1] /* "x*" 解释为 "xx..." */ } - } else if p[i-1] == '.' { - dp[i][j] = dp[i-1][j-1] - } else { - dp[i][j] = dp[i-1][j-1] && p[i-1] == s[j-1] } } } - return dp[len(p)][len(s)] + return dp[sSize][pSize] } diff --git a/Algorithms/0010.regular-expression-matching/regular-expression-matching_test.go b/Algorithms/0010.regular-expression-matching/regular-expression-matching_test.go index 6a596f86b..4ed47bc5a 100755 --- a/Algorithms/0010.regular-expression-matching/regular-expression-matching_test.go +++ b/Algorithms/0010.regular-expression-matching/regular-expression-matching_test.go @@ -98,6 +98,24 @@ func Test_Problem0010(t *testing.T) { one: true, }, }, + question{ + p: para{ + one: "ab", + two: ".*c", + }, + a: ans{ + one: false, + }, + }, + question{ + p: para{ + one: "ab", + two: "z*t*x*c*a*b", + }, + a: ans{ + one: true, + }, + }, question{ p: para{ one: "ab", diff --git a/Algorithms/0015.3sum/3sum.go b/Algorithms/0015.3sum/3sum.go index dc3cd1a65..0e38a5831 100755 --- a/Algorithms/0015.3sum/3sum.go +++ b/Algorithms/0015.3sum/3sum.go @@ -8,6 +8,9 @@ func threeSum(nums []int) [][]int { res := [][]int{} for i := range nums { + if nums[i] > 0 { + break + } // 避免添加重复的结果 // i>0 是为了防止nums[i-1]溢出 if i > 0 && nums[i] == nums[i-1] { diff --git a/Algorithms/0020.valid-parentheses/README.md b/Algorithms/0020.valid-parentheses/README.md index fc8edd119..2d9f5d009 100755 --- a/Algorithms/0020.valid-parentheses/README.md +++ b/Algorithms/0020.valid-parentheses/README.md @@ -1,12 +1,58 @@ # [20. Valid Parentheses](https://leetcode.com/problems/valid-parentheses/) ## 题目 -Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. + +Given a string containing just the characters `'('`, `')'`, `'{'`, `'}'`, `'['` and `']'`, determine if the input string is valid. + +An input string is valid if: + +1. Open brackets must be closed by the same type of brackets. +1. Open brackets must be closed in the correct order. + +Note that an empty string is also considered valid. + +Example 1: + +```text +Input: "()" +Output: true +``` + +Example 2: + +```text +Input: "()[]{}" +Output: true +``` + +Example 3: + +```text +Input: "(]" +Output: false +``` + +Example 4: + +```text +Input: "([)]" +Output: false +``` + +Example 5: + +```text +Input: "{[]}" +Output: true +Given a string containing just the characters `'( '`, `') '`, `'{ '`, `'} '`, `'[' and `'] '`, determine if the input string is valid. +``` The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. ## 解题思路 + [栈](https://zh.wikipedia.org/wiki/%E5%A0%86%E6%A0%88)是一个后进先出的队列,用在这里可以避免复杂的判断结构。但是,Go语言的标准库没有栈这种结构,我就手动实现了一个。 ## 总结 + 选用合适的数据结构,可以让程序清晰。 \ No newline at end of file diff --git a/Algorithms/0020.valid-parentheses/valid-parentheses.go b/Algorithms/0020.valid-parentheses/valid-parentheses.go index 9cf6b9098..9cebeb474 100755 --- a/Algorithms/0020.valid-parentheses/valid-parentheses.go +++ b/Algorithms/0020.valid-parentheses/valid-parentheses.go @@ -1,45 +1,28 @@ package problem0020 -func isValid(str string) bool { - s := new(stack) - - for _, b := range str { - switch b { - case '(', '[', '{': - s.push(b) +func isValid(s string) bool { + size := len(s) + + stack := make([]byte, size) + top := 0 + + for i := 0; i < size; i++ { + c := s[i] + switch c { + case '(': + stack[top] = c + 1 // '('+1 is ')' + top++ + case '[', '{': + stack[top] = c + 2 + top++ case ')', ']', '}': - if r, ok := s.pop(); !ok || r != matching[b] { - // !ok 说明“([{”的数量,小于")]}"的数量 + if top > 0 && stack[top-1] == c { + top-- + } else { return false } } } - // len(*s) > 0 说明"([{"的数量,大于")]}"的数量 - if len(*s) > 0 { - return false - } - - return true -} - -var matching = map[rune]rune{ - ')': '(', - ']': '[', - '}': '{', -} - -type stack []rune - -func (s *stack) push(b rune) { - *s = append(*s, b) -} - -func (s *stack) pop() (rune, bool) { - if len(*s) > 0 { - res := (*s)[len(*s)-1] - *s = (*s)[:len(*s)-1] - return res, true - } - return 0, false + return top == 0 } diff --git a/Algorithms/0020.valid-parentheses/valid-parentheses_test.go b/Algorithms/0020.valid-parentheses/valid-parentheses_test.go index 4be98ebdc..7f281d7df 100755 --- a/Algorithms/0020.valid-parentheses/valid-parentheses_test.go +++ b/Algorithms/0020.valid-parentheses/valid-parentheses_test.go @@ -64,3 +64,9 @@ func Test_Problem0020(t *testing.T) { ast.Equal(a.one, isValid(p.one), "输入:%v", p) } } + +func Benchmark_isValid(b *testing.B) { + for i := 1; i < b.N; i++ { + isValid("{{{{{[[[[[((((()))))]]]]]}}}}}") + } +} diff --git a/Algorithms/0024.swap-nodes-in-pairs/swap-nodes-in-pairs.go b/Algorithms/0024.swap-nodes-in-pairs/swap-nodes-in-pairs.go index ec814604f..861bb3717 100755 --- a/Algorithms/0024.swap-nodes-in-pairs/swap-nodes-in-pairs.go +++ b/Algorithms/0024.swap-nodes-in-pairs/swap-nodes-in-pairs.go @@ -12,13 +12,9 @@ func swapPairs(head *ListNode) *ListNode { return head } - // newHead 指向 head.Next 节点 newHead := head.Next - // 让 head.Next 指向转换好了 newHead.Next 节点 head.Next = swapPairs(newHead.Next) - // 让 newHead.Next 指向 head 节点 newHead.Next = head - // newHead 成为新的 head 节点 return newHead } diff --git a/Algorithms/0025.reverse-nodes-in-k-group/README.md b/Algorithms/0025.reverse-nodes-in-k-group/README.md index 370a3f6a6..c12ea0d0b 100755 --- a/Algorithms/0025.reverse-nodes-in-k-group/README.md +++ b/Algorithms/0025.reverse-nodes-in-k-group/README.md @@ -1,26 +1,24 @@ # [25. Reverse Nodes in k-Group](https://leetcode.com/problems/reverse-nodes-in-k-group/) ## 题目 + Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is. -You may not alter the values in the nodes, only nodes itself may be changed. - -Only constant memory is allowed. +Example: -For example, Given this linked list: 1->2->3->4->5 For k = 2, you should return: 2->1->4->3->5 For k = 3, you should return: 3->2->1->4->5 -## 解题思路 -题目要求,把一条链上的每k个节点进行逆转,不足k个的末尾,则不需要逆转。 +Note: -详见注释 - -## 总结 +- Only constant extra memory is allowed. +- You may not alter the values in the list's nodes, only nodes itself may be changed. +## 解题思路 +见程序注释 diff --git a/Algorithms/0025.reverse-nodes-in-k-group/reverse-nodes-in-k-group.go b/Algorithms/0025.reverse-nodes-in-k-group/reverse-nodes-in-k-group.go index f0d487db4..ea68a3d81 100755 --- a/Algorithms/0025.reverse-nodes-in-k-group/reverse-nodes-in-k-group.go +++ b/Algorithms/0025.reverse-nodes-in-k-group/reverse-nodes-in-k-group.go @@ -1,74 +1,43 @@ package problem0025 -/** - * Definition for singly-linked list. - * type ListNode struct { - * Val int - * Next *ListNode - * } - */ +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// ListNode defines for singly-linked list. +type ListNode = kit.ListNode func reverseKGroup(head *ListNode, k int) *ListNode { - if head == nil || head.Next == nil || k < 2 { + if k < 2 || head == nil || head.Next == nil { return head } - next, ok := needReverse(head, k) - if ok { - head, tail := reverse(head) - // 递归 - // 把整理好了的前k个节点的尾部,指向整理好了的后面节点的head - tail.Next = reverseKGroup(next, k) - return head + tail, needReverse := getTail(head, k) + + if needReverse { + tailNext := tail.Next + /* 斩断 tail 后的链接 */ + tail.Next = nil + head, tail = reverse(head, tail) + /* tail 后面接上尾部的递归处理 */ + tail.Next = reverseKGroup(tailNext, k) } return head } -// 判断是否有前k个节点需要逆转。 -// 需要的话 -// 会把KthNode.Next = nil,把k和k+1节点斩断,便于前k个节点的逆转。 -func needReverse(head *ListNode, k int) (begin *ListNode, ok bool) { - for head != nil { - if k == 1 { - begin = head.Next - // 把前k与后面的节点斩断, 便于reverse - head.Next = nil - return begin, true - } - +func getTail(head *ListNode, k int) (*ListNode, bool) { + for k > 1 && head != nil { head = head.Next k-- } - - return nil, false + return head, k == 1 && head != nil } -// 返回逆转后的首尾节点 -func reverse(head *ListNode) (first, last *ListNode) { - if head == nil || head.Next == nil { - return head, nil - } - - gotLast := false - - for head != nil { - temp := head.Next - head.Next = first - first = head - head = temp - - if !gotLast { - last = first - gotLast = true - } +func reverse(head, tail *ListNode) (*ListNode, *ListNode) { + curPre, cur := head, head.Next + for cur != nil { + curPre, cur, cur.Next = cur, cur.Next, curPre } - - return first, last -} - -// ListNode 是链接节点 -type ListNode struct { - Val int - Next *ListNode + return tail, head } diff --git a/Algorithms/0025.reverse-nodes-in-k-group/reverse-nodes-in-k-group_test.go b/Algorithms/0025.reverse-nodes-in-k-group/reverse-nodes-in-k-group_test.go index 01bed1ee8..38872e46b 100755 --- a/Algorithms/0025.reverse-nodes-in-k-group/reverse-nodes-in-k-group_test.go +++ b/Algorithms/0025.reverse-nodes-in-k-group/reverse-nodes-in-k-group_test.go @@ -4,102 +4,49 @@ import ( "fmt" "testing" + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" ) -type question struct { - para - ans -} - -// para 是参数 -// one 代表第一个参数 -type para struct { - one []int - two int -} - -// ans 是答案 -// one 代表第一个答案 -type ans struct { - one []int -} - -func Test_Problem0025(t *testing.T) { - ast := assert.New(t) - - qs := []question{ - - question{ - para{ - []int{1, 2, 3, 4, 5}, - 3, - }, - ans{[]int{3, 2, 1, 4, 5}}, - }, - - question{ - para{ - []int{1, 2, 3, 4, 5}, - 1, - }, - ans{[]int{1, 2, 3, 4, 5}}, - }, +// tcs is testcase slice +var tcs = []struct { + head []int + k int + ans []int +}{ - // 如需多个测试,可以复制上方元素。 - } - - for _, q := range qs { - a, p := q.ans, q.para - fmt.Printf("~~%v~~\n", p) + { + []int{1, 2, 3, 4, 5}, + 3, + []int{3, 2, 1, 4, 5}, + }, - ast.Equal(a.one, l2s(reverseKGroup(s2l(p.one), p.two)), "输入:%v", p) - } -} -func Test_needReverse(t *testing.T) { - head := s2l([]int{1, 2, 3, 4, 5, 6}) - begin, ok := needReverse(head, 4) - assert.True(t, ok, "长度足够的链却提示不能逆转") - assert.Equal(t, []int{1, 2, 3, 4}, l2s(head), "前链不对, 没有被斩断") - assert.Equal(t, []int{5, 6}, l2s(begin), "后链不对") -} -func Test_reverse(t *testing.T) { - first, last := reverse(s2l([]int{1, 2, 3})) - assert.Equal(t, []int{3, 2, 1}, l2s(first), "无法逆转链") - assert.Equal(t, 1, last.Val, "链尾部的值不对") + { + []int{1, 2, 3, 4, 5}, + 1, + []int{1, 2, 3, 4, 5}, + }, - Nil, _ := reverse(s2l([]int{})) - assert.Nil(t, Nil, "无法逆转空链") + // 可以有多个 testcase } -// convert *ListNode to []int -func l2s(head *ListNode) []int { - res := []int{} +func Test_reverseKGroup(t *testing.T) { + ast := assert.New(t) - for head != nil { - res = append(res, head.Val) - head = head.Next + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + head := kit.Ints2List(tc.head) + ans := kit.Ints2List(tc.ans) + ast.Equal(ans, reverseKGroup(head, tc.k), "输入:%v", tc) } - - return res } -// convert []int to *ListNode -func s2l(nums []int) *ListNode { - if len(nums) == 0 { - return nil - } - - res := &ListNode{ - Val: nums[0], - } - temp := res - for i := 1; i < len(nums); i++ { - temp.Next = &ListNode{ - Val: nums[i], +func Benchmark_reverseKGroup(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + head := kit.Ints2List(tc.head) + reverseKGroup(head, tc.k) } - temp = temp.Next } - - return res } diff --git a/Algorithms/0030.substring-with-concatenation-of-all-words/README.md b/Algorithms/0030.substring-with-concatenation-of-all-words/README.md index 2000e07d1..e2097d21e 100755 --- a/Algorithms/0030.substring-with-concatenation-of-all-words/README.md +++ b/Algorithms/0030.substring-with-concatenation-of-all-words/README.md @@ -1,19 +1,31 @@ # [30. Substring with Concatenation of All Words](https://leetcode.com/problems/substring-with-concatenation-of-all-words/) ## 题目 + You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters. + +Example 1: + +```text +Input: + s = "barfoothefoobarman", + words = ["foo","bar"] +Output: [0,9] +Explanation: Substrings starting at index 0 and 9 are "barfoor" and "foobar" respectively. +The output order does not matter, returning [9,0] is fine too. ``` -For example, given: -s: "barfoothefoobarman" -words: ["foo", "bar"] + +Example 2: + +```text +Input: + s = "wordgoodstudentgoodword", + words = ["word","student"] +Output: [] ``` -You should return the indices: [0,9]. -(order does not matter). ## 解题思路 + words中会包含重复的word 详见程序注释。 -## 总结 - - diff --git a/Algorithms/0030.substring-with-concatenation-of-all-words/substring-with-concatenation-of-all-words.go b/Algorithms/0030.substring-with-concatenation-of-all-words/substring-with-concatenation-of-all-words.go index 0142e0547..93dec6fc1 100755 --- a/Algorithms/0030.substring-with-concatenation-of-all-words/substring-with-concatenation-of-all-words.go +++ b/Algorithms/0030.substring-with-concatenation-of-all-words/substring-with-concatenation-of-all-words.go @@ -1,80 +1,113 @@ package problem0030 func findSubstring(s string, words []string) []int { - res := []int{} + lens := len(s) + res := make([]int, 0, lens) - lens, numWords, lenw := len(s), len(words), len(words[0]) - if lens == 0 || numWords == 0 || lens < numWords*lenw { + lenws := len(words) + if lens == 0 || lenws == 0 || lens < lenws*len(words[0]) { return res } - // remainNum 记录 words 中每个单词还能出现的次数 - remainNum := make(map[string]int, numWords) - // count 记录符号要求的单词的连续出现次数 - count := 0 - initRecord := func() { - for _, word := range words { - remainNum[word] = 0 + lenw := len(words[0]) + + // record 记录 words 中每个单词总共出现的次数 + record := make(map[string]int, lenws) + for _, w := range words { + if len(w) != lenw { + // 新添加的 example 2 出现了 words 中单词长度不一致的情况。 + // 这个违反了假设 + // 直接返回 res + return res } - for _, word := range words { - remainNum[word]++ + record[w]++ + } + + // remain 记录 words 中每个单词还能出现的次数 + remain := make(map[string]int, lenws) + // count 记录符合要求的单词的连续出现次数 + count := 1 // count 的初始值只要不为 0 就可以 + left, right := 0, 0 + + /** + * s[left:right] 作为一个窗口存在 + * 假设 word:= s[right:right+lenw] + * 如果 remain[word]>0 ,那么移动窗口 右边,同时更新移动后 s[left:right] 的统计信息 + * remain[word]-- + * right += lenw + * count++ + * 否则,移动窗口 左边,同时更新移动后 s[left:right] 的统计信息 + * remain[s[left:left+lenw]]++ + * count-- + * left += lenw + * + * 每次移动窗口 右边 后,如果 count = lenws ,那么 + * 说明找到了一个符合条件的解 + * append(res, left),然后 + * 移动窗口 左边 + */ + + // reset 重置 remain 和 count + reset := func() { + if count == 0 { + // 统计记录没有被修改,不需要重置 + // 因为有这个预判,所以需要第一次执行 reset 时 + // count 的值不能为 0 + // 即 count 的初始值不能为 0 + return + } + for k, v := range record { + remain[k] = v } count = 0 - } // 把这个匿名函数放在这里,可以避免繁琐的函数参数 - - // 由于 index 增加的跨度是 lenw - // index 需要分别从{0,1,...,lenw-1}这些位置开始检查,才能不遗漏 - for initialIndex := 0; initialIndex < lenw; initialIndex++ { - index := initialIndex - // moveIndex 让 index 指向下一个单词 - moveIndex := func() { - // index 指向下一个单词的同时,需要同时修改统计记录 + } - // 增加 index 指向的 word 可出现次数一次, - remainNum[s[index:index+lenw]]++ - // 连续符合条件的单词数减少一个 - count-- - // index 后移一个 word 的长度 - index += lenw - } // 把这个匿名函数放在这里,可以避免繁琐的函数参数 + // moveLeft 让 left 指向下一个单词 + moveLeft := func() { + // left 指向下一个单词前,需要修改统计记录 + // 增加 left 指向的 word 可出现次数一次, + remain[s[left:left+lenw]]++ + // 连续符合条件的单词数减少一个 + count-- + // left 后移一个 word 的长度 + left += lenw + } - initRecord() + // left 需要分别从{0,1,...,lenw-1}这些位置开始检查,才能不遗漏 + for i := 0; i < lenw; i++ { + left, right = i, i + reset() - for index+numWords*lenw <= lens { // 注意,这里是有等号的 - word := s[index+count*lenw : index+(count+1)*lenw] - remainTimes, ok := remainNum[word] + // s[left:] 的长度 >= words 中所有 word 组成的字符串的长度时, + // s[left:] 中才有可能存在要找的字符串 + for lens-left >= lenws*lenw { + word := s[right : right+lenw] + remainTimes, ok := remain[word] switch { case !ok: - // 出现了不在 words 中的单词 - // 从 word 后面一个单词,重新开始统计 - index += lenw * (count + 1) - if count != 0 { - // 统计记录已经被修改,需要再次初始化 - initRecord() - } + // word 不在 words 中 + // 从 right+lenw 处,作为新窗口,重新开始统计 + left, right = right+lenw, right+lenw + reset() case remainTimes == 0: // word 的出现次数上次就用完了 - // 说明s[index:index+(count+1)*lenw]中有单词多出现了 - moveIndex() + // 说明 word 在 s[left:right] 中出现次数过多 + moveLeft() // 这个case会连续出现 - // 直到s[index:index+(count+1)*lenw]中所有单词的出现次数都不超标 - // - // 在 moveIndex() 的过程中,index+(count+1)*lenw 保持值不变 + // 直到 s[left:right] 中的统计结果是 remain[word] == 1 + // 这个过程中,right 一直不变 default: // ok && remainTimes > 0,word 符合出现的条件 - - // 更新统计记录 - remainNum[word]-- + // moveRight + remain[word]-- count++ - - // 检查 words 能否排列组合成 s[index:index+count*lenw] - if count == numWords { - res = append(res, index) - - // 把 index 指向下一个单词 - // 开始下一个统计 - moveIndex() + right += lenw + // 检查 words 能否排列组合成 s[left:right] + if count == lenws { + res = append(res, left) + // moveLeft 可以避免重复统计 s[left+lenw:right] 中的信息 + moveLeft() } } } diff --git a/Algorithms/0030.substring-with-concatenation-of-all-words/substring-with-concatenation-of-all-words_test.go b/Algorithms/0030.substring-with-concatenation-of-all-words/substring-with-concatenation-of-all-words_test.go index beb0531c3..9192aad52 100755 --- a/Algorithms/0030.substring-with-concatenation-of-all-words/substring-with-concatenation-of-all-words_test.go +++ b/Algorithms/0030.substring-with-concatenation-of-all-words/substring-with-concatenation-of-all-words_test.go @@ -41,6 +41,11 @@ func Test_Problem0030(t *testing.T) { ans{[]int{3, 12}}, }, + question{ + para{"attoinattoin", []string{"at", "tto", "in"}}, + ans{[]int{}}, + }, + question{ para{"attoinattoin", []string{"at", "to", "in"}}, ans{[]int{0, 2, 4, 6}}, @@ -57,6 +62,11 @@ func Test_Problem0030(t *testing.T) { ans{[]int{8}}, }, + question{ + para{"barfoothefoobarmanattoinin", []string{"at", "to", "in", "in"}}, + ans{[]int{18}}, + }, + // 如需多个测试,可以复制上方元素。 } diff --git a/Algorithms/0033.search-in-rotated-sorted-array/README.md b/Algorithms/0033.search-in-rotated-sorted-array/README.md index d1c1b9017..86ab141fe 100755 --- a/Algorithms/0033.search-in-rotated-sorted-array/README.md +++ b/Algorithms/0033.search-in-rotated-sorted-array/README.md @@ -1,6 +1,7 @@ # [33. Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array/) ## 题目 + Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). @@ -10,19 +11,22 @@ You are given a target value to search. If found in the array return its index, You may assume no duplicate exists in the array. ## 解题思路 -先假设old = [0, 1, 2, 4, 5, 6, 7],利用二分查找法,很容易可以`5`的索引号,当old变换成了new = [4, 5, 6, 7, 0, 1, 2]以后,同样可以使用二分查找法,因为old和new中的元素有明确的对应关系 + +先假设old = [0, 1, 2, 4, 5, 6, 7],利用二分查找法,很容易可以`5`的索引号,当 old 变换成了 new = [4, 5, 6, 7, 0, 1, 2]以后,同样可以使用二分查找法,因为 old 和 new 中的元素有明确的对应关系 old[i] == new[j],只要i和j满足关系式 + ```go j=i+4 if j > len(old) { j -= len(old) } ``` -其中,4 = old中的最大值在new中的索引号 + 1 -所以,如果我们手中只有new,我们可以假装自己还是在对old使用二分查找法,当需要获取old[i]的值进行比较判断的时候,使用new[j]的值替代即可。 +其中,4 = old 中的最大值在new中的索引号 + 1 +所以,如果我们手中只有new,我们可以假装自己还是在对old使用二分查找法,当需要获取old[i]的值进行比较判断的时候,使用new[j]的值替代即可。 ## 总结 + 本题是二分查找法的升级版 \ No newline at end of file diff --git a/Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array.go b/Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array.go index 37e257459..1685cb071 100755 --- a/Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array.go +++ b/Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array.go @@ -1,41 +1,38 @@ package problem0033 func search(nums []int, target int) int { - var index, indexOfMax int - length := len(nums) + rotated := indexOfMin(nums) /* 数组旋转了的距离 */ + size := len(nums) + left, right := 0, size-1 - if length == 0 { - return -1 - } - - // 获取最大值的索引号,以便进行索引号变换 - for indexOfMax+1 < length && nums[indexOfMax] < nums[indexOfMax+1] { - indexOfMax++ - } - - low, high, median := 0, length-1, 0 - for low <= high { - median = (low + high) / 2 - - // 变换索引号 - index = median + indexOfMax + 1 - if index >= length { - index -= length - } - // 假设nums是由升序切片old转换来的 - // 那么,old[median] == nums[index] - - // 传统二分查找法的比较判断 - // 原先需要old[median]的地方,使用nums[index]即可 + for left <= right { + mid := (left + right) / 2 + /* nums 是 rotated,所以需要使用 rotatedMid 来获取 mid 的值 */ + rotatedMid := (rotated + mid) % size switch { - case nums[index] > target: - high = median - 1 - case nums[index] < target: - low = median + 1 + case nums[rotatedMid] < target: + left = mid + 1 + case target < nums[rotatedMid]: + right = mid - 1 default: - return index + return rotatedMid } } return -1 } + +/* nums 是被旋转了的递增数组 */ +func indexOfMin(nums []int) int { + size := len(nums) + left, right := 0, size-1 + for left < right { + mid := (left + right) / 2 + if nums[right] < nums[mid] { + left = mid + 1 + } else { + right = mid + } + } + return left +} diff --git a/Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array_test.go b/Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array_test.go index 1d97355b2..0e52f729a 100755 --- a/Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array_test.go +++ b/Algorithms/0033.search-in-rotated-sorted-array/search-in-rotated-sorted-array_test.go @@ -31,15 +31,30 @@ func Test_Problem0033(t *testing.T) { qs := []question{ question{ - para{[]int{4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2}, 5}, + para{[]int{2}, 2}, + ans{0}, + }, + + question{ + para{[]int{8, 9, 2, 3, 4}, 9}, ans{1}, }, + question{ + para{[]int{4, 5, 6, 7, 0, 1, 2}, 0}, + ans{4}, + }, + question{ para{[]int{6, 7, 0, 1, 2, 3, 4, 5}, 1}, ans{3}, }, + question{ + para{[]int{4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2}, 5}, + ans{1}, + }, + question{ para{[]int{1, 3}, 0}, ans{-1}, @@ -55,11 +70,6 @@ func Test_Problem0033(t *testing.T) { ans{-1}, }, - question{ - para{[]int{2}, 2}, - ans{0}, - }, - // 如需多个测试,可以复制上方元素。 } @@ -70,3 +80,27 @@ func Test_Problem0033(t *testing.T) { ast.Equal(a.one, search(p.one, p.two), "输入:%v", p) } } + +func Test_indexOfMin_evenLength(t *testing.T) { + ast := assert.New(t) + array := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9} + numsSize := 10 + for i := 0; i < 10; i++ { + nums := array[i : i+numsSize] + indexOfZeroInNums := 9 - i + actual := indexOfMin(nums) + ast.Equal(indexOfZeroInNums, actual) + } +} + +func Test_indexOfMin_oddLength(t *testing.T) { + ast := assert.New(t) + array := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9} + numsSize := 9 + for i := 1; i < 10; i++ { + nums := array[i : i+numsSize] + indexOfZeroInNums := 9 - i + actual := indexOfMin(nums) + ast.Equal(indexOfZeroInNums, actual) + } +} diff --git a/Algorithms/0037.sudoku-solver/sudoku-solver.go b/Algorithms/0037.sudoku-solver/sudoku-solver.go index f95936d71..2668c721c 100755 --- a/Algorithms/0037.sudoku-solver/sudoku-solver.go +++ b/Algorithms/0037.sudoku-solver/sudoku-solver.go @@ -1,72 +1,45 @@ package problem0037 func solveSudoku(board [][]byte) { - if !fill(board, '1', 0) { - panic("此题无解") - } + solve(board, 0) } -func fill(board [][]byte, n byte, block int) bool { - if block == 9 { - // 所有的block都已经填满,成功找到了解 +/* k 是把 board 转换成一维数组后,元素的索引值 */ +func solve(board [][]byte, k int) bool { + if k == 81 { return true } - if n == '9'+1 { - // block 已经被填满了,去填写 block+1 - return fill(board, '1', block+1) + r, c := k/9, k%9 + if board[r][c] != '.' { + return solve(board, k+1) } - // print(board, n, block) - - rowBegin := (block / 3) * 3 - colBegin := (block % 3) * 3 + /* bi, bj 是 rc 所在块的左上角元素的索引值 */ + bi, bj := r/3*3, c/3*3 - for r := rowBegin; r < rowBegin+3; r++ { - for c := colBegin; c < colBegin+3; c++ { - if board[r][c] == n { - // block 中已经有 n 了,无需填写 - // 去填写 n+1 - return fill(board, n+1, block) - } - } - } - - // 检查 (r,c) 能否存放 n - // 使用匿名函数,避免传递参数 - isAvaliable := func(r, c int) bool { - // 当前位置上的字符需为 '.' - if board[r][c] != '.' { - return false - } - - // (r,c) 所在的行和列不能有 n - // 在这里就可以体现,挨个往block中填写的优势了。 - for i := 0; i < 9; i++ { - if board[r][i] == n || board[i][c] == n { + // 按照数独的规则,检查 b 能否放在 board[r][c] + isValid := func(b byte) bool { + for n := 0; n < 9; n++ { + if board[r][n] == b || + board[n][c] == b || + board[bi+n/3][bj+n%3] == b { return false } } - return true } - for r := rowBegin; r < rowBegin+3; r++ { - for c := colBegin; c < colBegin+3; c++ { - if isAvaliable(r, c) { - board[r][c] = n - if fill(board, n+1, block) { - return true - } - - // 把 (r,c) 还原,以便以后把 n 移入下一个可行的位置 - board[r][c] = '.' - - // print(board, n, block) + for b := byte('1'); b <= '9'; b++ { + if isValid(b) { + board[r][c] = b + if solve(board, k+1) { + return true } } } - // n 在此 block 中无处可放。 - // 返回 false ,让 n-1 调整位置。 + + board[r][c] = '.' + return false } diff --git a/Algorithms/0037.sudoku-solver/sudoku-solver_test.go b/Algorithms/0037.sudoku-solver/sudoku-solver_test.go index ceceb8a51..395ba43de 100755 --- a/Algorithms/0037.sudoku-solver/sudoku-solver_test.go +++ b/Algorithms/0037.sudoku-solver/sudoku-solver_test.go @@ -64,53 +64,3 @@ func Test_Problem0036(t *testing.T) { ast.Equal(a.one, p.one, "输入:%v", p) } } -func Test_Panic(t *testing.T) { - ast := assert.New(t) - - qs := []question{ - - question{ - para{[][]byte{ - []byte("..9748..."), - []byte("7....8..."), - []byte(".2.1.9..."), - []byte("..7...24."), - []byte(".64.1.59."), - []byte(".98...3.."), - []byte("...8.3.2."), - []byte("........6"), - []byte("...2759.."), - }}, - ans{[][]byte{ - []byte("519748632"), - []byte("783652419"), - []byte("426139875"), - []byte("357986241"), - []byte("264317598"), - []byte("198524367"), - []byte("975863124"), - []byte("832491756"), - []byte("641275983"), - }}, - }, - - // 如需多个测试,可以复制上方元素。 - } - - for _, q := range qs { - p := q.para - fmt.Printf("~~%v~~\n", p) - ast.Panics(func() { solveSudoku(p.one) }, "输入:%v", p) - } -} - -func print(board [][]byte, b byte, block int) { - fmt.Printf("\n====fill %d in block %d ====", b-'0', block) - - for i := range board { - if i%3 == 0 { - fmt.Println() - } - fmt.Println(string(board[i][0:3]), " ", string(board[i][3:6]), " ", string(board[i][6:])) - } -} diff --git a/Algorithms/0044.wildcard-matching/README.md b/Algorithms/0044.wildcard-matching/README.md index d5ca77bec..c82115d38 100755 --- a/Algorithms/0044.wildcard-matching/README.md +++ b/Algorithms/0044.wildcard-matching/README.md @@ -1,27 +1,74 @@ # [44. Wildcard Matching](https://leetcode.com/problems/wildcard-matching/) ## 题目 -Implement wildcard pattern matching with support for '?' and '*'. +Given an input string (`s`) and a pattern (`p`), implement wildcard pattern matching with support for `'?'` and `'*'`. + +```text '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). +``` The matching should cover the entire input string (not partial). -The function prototype should be: -bool isMatch(const char *s, const char *p) +Note: + +- `s` could be empty and contains only lowercase letters `a-z`. +- `p` could be empty and contains only lowercase letters `a-z`, and characters like `?` or `*`. + +Example 1: + +```text +Input: +s = "aa" +p = "a" +Output: false +Explanation: "a" does not match the entire string "aa". +``` + +Example 2: + +```text +Input: +s = "aa" +p = "*" +Output: true +Explanation:`'*' matches any sequence. +``` + +Example 3: -Some examples: -isMatch("aa","a") → false -isMatch("aa","aa") → true -isMatch("aaa","aa") → false -isMatch("aa", "*") → true -isMatch("aa", "a*") → true -isMatch("ab", "?*") → true -isMatch("aab", "c*a*b") → false +```text +Input: +s = "cb" +p = "?a" +Output: false +Explanation:`'?' matches 'c', but the second letter is 'a', which does not match 'b'. +``` + +Example 4: + +```text +Input: +s = "adceb" +p = "*a*b" +Output: true +Explanation:`The first '*' matches the empty sequence, while the second '*' matches the substring "dce". +``` + +Example 5: + +```text +Input: +s = "acdcb" +p = "a*c?b" +Output: false +``` ## 解题思路 + 注意审题: + 1. '?' 可以匹配任意一个字符,但是不能匹配空字符"" 1. '*' 可以任意多个字符,包括"" diff --git a/Algorithms/0044.wildcard-matching/wildcard-matching.go b/Algorithms/0044.wildcard-matching/wildcard-matching.go index 66e1d1c4e..3c300bf9a 100755 --- a/Algorithms/0044.wildcard-matching/wildcard-matching.go +++ b/Algorithms/0044.wildcard-matching/wildcard-matching.go @@ -1,17 +1,16 @@ package problem0044 func isMatch(s string, p string) bool { - ls, lp := len(s), len(p) + sSize, pSize := len(s), len(p) - dp := [][]bool{} - for i := 0; i < ls+1; i++ { - rt := make([]bool, lp+1) - dp = append(dp, rt) + dp := make([][]bool, sSize+1) + for i := range dp { + dp[i] = make([]bool, pSize+1) } // dp[i][j] == true 意味着,s[:i+1] 可以和 p[:j+1] 匹配 dp[0][0] = true - for j := 1; j <= lp; j++ { + for j := 1; j <= pSize; j++ { if p[j-1] == '*' { // 当 p[j-1] == '*' 时 // 只要前面的匹配,dp[0][j] 就匹配 @@ -20,12 +19,13 @@ func isMatch(s string, p string) bool { } } - for i := 1; i <= ls; i++ { - for j := 1; j <= lp; j++ { + for i := 1; i <= sSize; i++ { + for j := 1; j <= pSize; j++ { if p[j-1] != '*' { // 当 p[j-1] != '*' 时 // 单个字符要匹配,并且之前的字符串也要匹配。 - dp[i][j] = (p[j-1] == s[i-1] || p[j-1] == '?') && dp[i-1][j-1] + dp[i][j] = dp[i-1][j-1] && + (p[j-1] == s[i-1] || p[j-1] == '?') } else { // 当 p[j-1] == '*' 时 // 要么,dp[i-1][j] == true,意味着, @@ -39,5 +39,6 @@ func isMatch(s string, p string) bool { } } } - return dp[ls][lp] + + return dp[sSize][pSize] } diff --git a/Algorithms/0044.wildcard-matching/wildcard-matching_test.go b/Algorithms/0044.wildcard-matching/wildcard-matching_test.go index c5d78d8c7..24a6fc4a1 100755 --- a/Algorithms/0044.wildcard-matching/wildcard-matching_test.go +++ b/Algorithms/0044.wildcard-matching/wildcard-matching_test.go @@ -7,113 +7,59 @@ import ( "github.com/stretchr/testify/assert" ) -type question struct { - para - ans +// tcs is testcase slice +var tcs = []struct { + s string + p string + ans bool +}{ + + { + "aa", + "a", + false, + }, + + { + "aa", + "*", + true, + }, + + { + "cb", + "?a", + false, + }, + + { + "adceb", + "*a*b", + true, + }, + + { + "acdcb", + "a*c?b", + false, + }, + + // 可以有多个 testcase } -// para 是参数 -type para struct { - s string - p string -} - -// ans 是答案 -type ans struct { - one bool -} - -func Test_Problem0044(t *testing.T) { +func Test_isMatch(t *testing.T) { ast := assert.New(t) - qs := []question{ - - question{ - para{ - "aa", - "a", - }, - ans{ - false, - }, - }, - - question{ - para{ - "aa", - "aa", - }, - ans{ - true, - }, - }, - - question{ - para{ - "aaa", - "aa", - }, - ans{ - false, - }, - }, - - question{ - para{ - "aa", - "*", - }, - ans{ - true, - }, - }, - - question{ - para{ - "aa", - "a*", - }, - ans{ - true, - }, - }, - - question{ - para{ - "ab", - "?*", - }, - ans{ - true, - }, - }, - - question{ - para{ - "aab", - "c*a*b", - }, - ans{ - false, - }, - }, - - question{ - para{ - "ab", - "*", - }, - ans{ - true, - }, - }, - // 如需多个测试,可以复制上方元素。 + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, isMatch(tc.s, tc.p), "输入:%v", tc) } +} - for _, q := range qs { - a, p := q.ans, q.para - fmt.Printf("~~%v~~\n", p) - - ast.Equal(a.one, isMatch(p.s, p.p), "输入:%v", p) +func Benchmark_isMatch(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isMatch(tc.s, tc.p) + } } } diff --git a/Algorithms/0049.group-anagrams/group-anagrams.go b/Algorithms/0049.group-anagrams/group-anagrams.go index b533d0022..56144651f 100755 --- a/Algorithms/0049.group-anagrams/group-anagrams.go +++ b/Algorithms/0049.group-anagrams/group-anagrams.go @@ -1,38 +1,27 @@ package problem0049 -import ( - "sort" -) - -func groupAnagrams(strs []string) [][]string { - res := [][]string{} - record := make(map[string][]string) - - for _, str := range strs { - temp := sortString(str) - record[temp] = append(record[temp], str) +func groupAnagrams(ss []string) [][]string { + tmp := make(map[int][]string, len(ss)/2) + for _, s := range ss { + c := encode(s) + tmp[c] = append(tmp[c], s) } - for _, v := range record { - sort.Strings(v) + + res := make([][]string, 0, len(tmp)) + for _, v := range tmp { res = append(res, v) } return res } -func sortString(s string) string { - bytes := []byte(s) - - temp := make([]int, len(bytes)) - for i, b := range bytes { - temp[i] = int(b) - } - - sort.Ints(temp) +// prime 与 A~Z 对应,英文中出现概率越大的字母,选用的质数越小 +var prime = []int{5, 71, 37, 29, 2, 53, 59, 19, 11, 83, 79, 31, 43, 13, 7, 67, 97, 23, 17, 3, 41, 73, 47, 89, 61, 101} - for i, v := range temp { - bytes[i] = byte(v) +func encode(s string) int { + res := 1 + for i := range s { + res *= prime[s[i]-'a'] } - - return string(bytes) + return res } diff --git a/Algorithms/0049.group-anagrams/group-anagrams_test.go b/Algorithms/0049.group-anagrams/group-anagrams_test.go index 9f4cfd1cd..143eeff4b 100755 --- a/Algorithms/0049.group-anagrams/group-anagrams_test.go +++ b/Algorithms/0049.group-anagrams/group-anagrams_test.go @@ -2,6 +2,7 @@ package problem0049 import ( "fmt" + "sort" "testing" "github.com/stretchr/testify/assert" @@ -46,8 +47,8 @@ func Test_Problem0049(t *testing.T) { fmt.Printf("~~%v~~\n", p) res := groupAnagrams(p.one) for _, v := range res { + sort.Strings(v) ast.Equal(a.one[len(v)-1], v, "输入:%v", p) - } } } diff --git a/Algorithms/0051.n-queens/n-queens.go b/Algorithms/0051.n-queens/n-queens.go index bf680427d..da836ef13 100755 --- a/Algorithms/0051.n-queens/n-queens.go +++ b/Algorithms/0051.n-queens/n-queens.go @@ -32,8 +32,27 @@ func dfs(r int, cols, d1, d2 []bool, board []string, res *[][]string) { n := len(board) for c := 0; c < len(board); c++ { + // 把棋盘想象成 + // 以左上角为坐标原点 [0,0] + // C 轴正方向向右 + // R 轴正方向向下 + // 的坐标系。 + // 这样的话,每个格子就都有了自己的坐标值 [c,r] + // + // 对于 '\' 方向的斜线而言 + // 同一个斜线上的格子,利用其坐标 [c,r] 计算 r-c 的结果相同, + // 不同斜线上 r-c 的结果不同。 + // 所以可以用 r-c 代表不同的 '\' 方向的斜线的编号。 + // 但是 r-c 有可能是负值,无法作为切片的索引值 + // 所以 +n,可知 r-c+n >= 0 + // 所以,使用 r-c+n 作为 '\' 方向斜线切片的索引值。 + // 对于 '/' 方向的斜线而言 + // 同一个斜线上的格子,利用其坐标 [c,r] 计算 r+c 的结果相同, + // 不同斜线上 r+c 的结果不同。 + // 所以可以用 r+c 代表不同的 '/' 方向的斜线的编号。 + // 所以,使用 r+c 作为 '/' 方向斜线切片的索引值。 id1 := r - c + n - id2 := 2*n - r - c - 1 + id2 := r + c if !cols[c] && !d1[id1] && !d2[id2] { b := make([]byte, n) for i := range b { diff --git a/Algorithms/0053.maximum-subarray/README.md b/Algorithms/0053.maximum-subarray/README.md index ce7069912..714c1e33d 100755 --- a/Algorithms/0053.maximum-subarray/README.md +++ b/Algorithms/0053.maximum-subarray/README.md @@ -1,6 +1,7 @@ # [53. Maximum Subarray](https://leetcode.com/problems/maximum-subarray/) ## 题目 + Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array `[-2,1,-3,4,-1,2,1,-5,4]`, @@ -10,11 +11,7 @@ the contiguous subarray `[4,-1,2,1]` has the largest sum = `6`. More practice: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. -## 解题思路 -利用好`连续`这个约束 - -详见注释 - -## 总结 +## 解题思路 +利用好`连续`这个约束 \ No newline at end of file diff --git a/Algorithms/0053.maximum-subarray/maximum-subarray.go b/Algorithms/0053.maximum-subarray/maximum-subarray.go index cc5e68d60..26a4be4d8 100755 --- a/Algorithms/0053.maximum-subarray/maximum-subarray.go +++ b/Algorithms/0053.maximum-subarray/maximum-subarray.go @@ -1,37 +1,18 @@ package problem0053 func maxSubArray(nums []int) int { - l := len(nums) - - if l == 0 { - return 0 - } - - if l == 1 { - return nums[0] + sum, maxSum := -1<<31, -1<<31 + for _, n := range nums { + // sum+n < n,那就还不如直接从 n 开始统计。 + sum = max(sum+n, n) + maxSum = max(maxSum, sum) } + return maxSum +} - temp := nums[0] - max := temp - i := 1 - // 可以把 for 循环的过程,nums[:1] 每次增加一个,直到变成 nums 的过程。 - // temp 就是这个过程中,每个 nums[:i] 中的 max(nums[x:i]) (x=0,1,...,i-1) - // 整个 nums 中连续子序列的最大值,就在 temp 的所有取值中 - for i < l { - if temp < 0 { - // 因为 连续性 的要求,而此时 temp < 0 - // temp 从 i 处重新开始 - temp = nums[i] - } else { - temp += nums[i] - } - - if max < temp { - max = temp - } - - i++ +func max(a, b int) int { + if a > b { + return a } - - return max + return b } diff --git a/Algorithms/0053.maximum-subarray/maximum-subarray_test.go b/Algorithms/0053.maximum-subarray/maximum-subarray_test.go index cb5aa3a77..8e6891b9b 100755 --- a/Algorithms/0053.maximum-subarray/maximum-subarray_test.go +++ b/Algorithms/0053.maximum-subarray/maximum-subarray_test.go @@ -29,19 +29,14 @@ func Test_Problem0053(t *testing.T) { qs := []question{ - question{ - para{[]int{-2, 1, -3, 4, -1, 2, 1, -5, 4}}, - ans{6}, - }, - question{ para{[]int{-2}}, ans{-2}, }, question{ - para{[]int{}}, - ans{0}, + para{[]int{-2, 1, -3, 4, -1, 2, 1, -5, 4}}, + ans{6}, }, // 如需多个测试,可以复制上方元素。 diff --git a/Algorithms/0054.spiral-matrix/README.md b/Algorithms/0054.spiral-matrix/README.md index 7ce795596..7fd91546e 100755 --- a/Algorithms/0054.spiral-matrix/README.md +++ b/Algorithms/0054.spiral-matrix/README.md @@ -1,9 +1,10 @@ # [54. Spiral Matrix](https://leetcode.com/problems/spiral-matrix/) ## 题目 + Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. -``` +```text For example, Given the following matrix: @@ -15,6 +16,7 @@ Given the following matrix: You should return [1,2,3,6,9,8,7,4,5]. ``` + ## 解题思路 见程序注释 diff --git a/Algorithms/0054.spiral-matrix/spiral-matrix.go b/Algorithms/0054.spiral-matrix/spiral-matrix.go index ff8a4147b..8a13f3517 100755 --- a/Algorithms/0054.spiral-matrix/spiral-matrix.go +++ b/Algorithms/0054.spiral-matrix/spiral-matrix.go @@ -1,45 +1,45 @@ package problem0054 func spiralOrder(matrix [][]int) []int { - r := len(matrix) - - if r == 0 { - return []int{} - } - - c := len(matrix[0]) - if c == 0 { - return []int{} + if len(matrix) == 0 || len(matrix[0]) == 0 { + return nil } - - if len(matrix) == 1 { - return matrix[0] - } - - res := make([]int, 0, r*c) - res = append(res, matrix[0]...) + m, n := len(matrix), len(matrix[0]) - for i := 1; i < r-1; i++ { - res = append(res, matrix[i][c-1]) - } + next := nextFunc(m, n) - for j := c - 1; j >= 0; j-- { - res = append(res, matrix[r-1][j]) + res := make([]int, m*n) + for i := range res { + x, y := next() + res[i] = matrix[x][y] } - for i := r - 2; i > 0 && c > 1; i-- { - res = append(res, matrix[i][0]) - } - - if r == 2 || c <= 2 { - return res - } + return res +} - nextMatrix := make([][]int, 0, r-2) - for i := 1; i < r-1; i++ { - nextMatrix = append(nextMatrix, matrix[i][1:c-1]) +func nextFunc(m, n int) func() (int, int) { + top, down := 0, m-1 + left, right := 0, n-1 + x, y := 0, -1 + dx, dy := 0, 1 + return func() (int, int) { + x += dx + y += dy + switch { // 如果撞墙了,需要修改 dx, dy 和相应的边界值 + case y+dy > right: + top++ + dx, dy = 1, 0 + case x+dx > down: + right-- + dx, dy = 0, -1 + case y+dy < left: + down-- + dx, dy = -1, 0 + case x+dx < top: + left++ + dx, dy = 0, 1 + } + return x, y } - - return append(res, spiralOrder(nextMatrix)...) } diff --git a/Algorithms/0054.spiral-matrix/spiral-matrix_test.go b/Algorithms/0054.spiral-matrix/spiral-matrix_test.go index 1e3413be1..59f7c4e45 100755 --- a/Algorithms/0054.spiral-matrix/spiral-matrix_test.go +++ b/Algorithms/0054.spiral-matrix/spiral-matrix_test.go @@ -31,12 +31,19 @@ func Test_Problem0054(t *testing.T) { para{ [][]int{ []int{}, - []int{}, - []int{}, }, }, ans{ - []int{}, + nil, + }, + }, + + question{ + para{ + [][]int{}, + }, + ans{ + nil, }, }, @@ -89,15 +96,6 @@ func Test_Problem0054(t *testing.T) { }, }, - question{ - para{ - [][]int{}, - }, - ans{ - []int{}, - }, - }, - // 如需多个测试,可以复制上方元素。 } diff --git a/Algorithms/0056.merge-intervals/README.md b/Algorithms/0056.merge-intervals/README.md index 70b9e5dcf..c1af9b73a 100755 --- a/Algorithms/0056.merge-intervals/README.md +++ b/Algorithms/0056.merge-intervals/README.md @@ -1,16 +1,16 @@ # [56. Merge Intervals](https://leetcode.com/problems/merge-intervals/) ## 题目 + Given a collection of intervals, merge all overlapping intervals. -``` +```text For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. ``` + ## 解题思路 -1. 先对 intervals 进行排序,按照 Start 递增 -1. 依次处理重叠的情况。 -## 附注 -最快的答案和我的思路一样,只是使用的是 merge sort ,自我感觉我的答案更清晰,就没有改成他的。 \ No newline at end of file +1. 先对 intervals 进行排序,按照 Start 递增 +1. 依次处理重叠的情况。 \ No newline at end of file diff --git a/Algorithms/0056.merge-intervals/merge-intervals.go b/Algorithms/0056.merge-intervals/merge-intervals.go index f80d58654..e1acc6650 100755 --- a/Algorithms/0056.merge-intervals/merge-intervals.go +++ b/Algorithms/0056.merge-intervals/merge-intervals.go @@ -1,6 +1,8 @@ package problem0056 -import "math/rand" +import ( + "sort" +) // Interval Definition for an interval. type Interval struct { @@ -13,20 +15,21 @@ func merge(its []Interval) []Interval { return its } - quickSort(its) + sort.Slice(its, func(i int, j int) bool { + return its[i].Start < its[j].Start + }) res := make([]Interval, 0, len(its)) - temp := its[0] + temp := its[0] for i := 1; i < len(its); i++ { if its[i].Start <= temp.End { temp.End = max(temp.End, its[i].End) - continue + } else { + res = append(res, temp) + temp = its[i] } - res = append(res, temp) - temp = its[i] } - res = append(res, temp) return res @@ -38,33 +41,3 @@ func max(a, b int) int { } return b } - -func quickSort(is []Interval) { - if len(is) <= 1 { - return - } - - j := rand.Intn(len(is)) - is[0], is[j] = is[j], is[0] - j = partition(is) - quickSort(is[0:j]) - quickSort(is[j+1:]) -} - -func partition(is []Interval) int { - i, j := 1, len(is)-1 - for { - for is[i].Start <= is[0].Start && i < len(is)-1 { - i++ - } - for is[0].Start <= is[j].Start && j > 0 { - j-- - } - if i >= j { - break - } - is[i], is[j] = is[j], is[i] - } - is[0], is[j] = is[j], is[0] - return j -} diff --git a/Algorithms/0059.spiral-matrix-ii/README.md b/Algorithms/0059.spiral-matrix-ii/README.md index 7cab5d39d..9209d5c41 100755 --- a/Algorithms/0059.spiral-matrix-ii/README.md +++ b/Algorithms/0059.spiral-matrix-ii/README.md @@ -1,9 +1,10 @@ # [59. Spiral Matrix II](https://leetcode.com/problems/spiral-matrix-ii/) ## 题目 -Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. -``` +Given an integer n, generate a square matrix filled with elements from 1 to n^2 in spiral order. + +```text For example, Given n = 3, You should return the following matrix: [ [ 1, 2, 3 ], @@ -11,7 +12,9 @@ For example, Given n = 3, You should return the following matrix: [ 7, 6, 5 ] ] ``` + ## 解题思路 + 依照题意,设置填充边界,沿着边界填写。 见程序注释 diff --git a/Algorithms/0059.spiral-matrix-ii/spiral-matrix-ii.go b/Algorithms/0059.spiral-matrix-ii/spiral-matrix-ii.go index 7be27e212..dc36f2308 100755 --- a/Algorithms/0059.spiral-matrix-ii/spiral-matrix-ii.go +++ b/Algorithms/0059.spiral-matrix-ii/spiral-matrix-ii.go @@ -2,7 +2,7 @@ package problem0059 func generateMatrix(n int) [][]int { if n == 0 { - return [][]int{} + return nil } res := make([][]int, n) @@ -10,35 +10,39 @@ func generateMatrix(n int) [][]int { res[i] = make([]int, n) } - // 4 条边界,依照题意,沿着边界填写 - top, bottom, left, right := 0, n-1, 0, n-1 - num := 1 - for top <= bottom && left <= right { - // → - for j := left; j <= right; j++ { - res[top][j] = num - num++ - } - top++ - // ↓ - for j := top; j <= bottom; j++ { - res[j][right] = num - num++ - } - right-- - // ← - for j := right; j >= left; j-- { - res[bottom][j] = num - num++ - } - bottom-- - // ↑ - for j := bottom; j >= top; j-- { - res[j][left] = num - num++ - } - left++ + max := n * n + next := nextFunc(n) + + for i := 1; i <= max; i++ { + x, y := next() + res[x][y] = i } return res } + +func nextFunc(n int) func() (int, int) { + top, down := 0, n-1 + left, right := 0, n-1 + x, y := 0, -1 + dx, dy := 0, 1 + return func() (int, int) { + x += dx + y += dy + switch { + case y+dy > right: + top++ + dx, dy = 1, 0 + case x+dx > down: + right-- + dx, dy = 0, -1 + case y+dy < left: + down-- + dx, dy = -1, 0 + case x+dx < top: + left++ + dx, dy = 0, 1 + } + return x, y + } +} diff --git a/Algorithms/0059.spiral-matrix-ii/spiral-matrix-ii_test.go b/Algorithms/0059.spiral-matrix-ii/spiral-matrix-ii_test.go index 698f02f96..c60557a6f 100755 --- a/Algorithms/0059.spiral-matrix-ii/spiral-matrix-ii_test.go +++ b/Algorithms/0059.spiral-matrix-ii/spiral-matrix-ii_test.go @@ -30,7 +30,7 @@ func Test_Problem0059(t *testing.T) { question{ para{0}, ans{ - [][]int{}, + nil, }, }, diff --git a/Algorithms/0061.rotate-list/README.md b/Algorithms/0061.rotate-list/README.md index 2fcff2ab6..53b999863 100755 --- a/Algorithms/0061.rotate-list/README.md +++ b/Algorithms/0061.rotate-list/README.md @@ -1,12 +1,27 @@ # [61. Rotate List](https://leetcode.com/problems/rotate-list/) ## 题目 -Given a list, rotate the list to the right by k places, where k is non-negative. -For example: -``` -Given 1->2->3->4->5->NULL and k = 2, -return 4->5->1->2->3->NULL. + +Given a linked list, rotate the list to the right by k places, where k is non-negative. + +Example 1: + +```text +Input: 1->2->3->4->5->NULL, k = 2 +Output: 4->5->1->2->3->NULL +Explanation: +rotate 1 steps to the right: 5->1->2->3->4->NULL +rotate 2 steps to the right: 4->5->1->2->3->NULL ``` -## 解题思路 -见程序注释 +Example 2: + +```text +Input: 0->1->2->NULL, k = 4 +Output: 2->0->1->NULL +Explanation: +rotate 1 steps to the right: 2->0->1->NULL +rotate 2 steps to the right: 1->2->0->NULL +rotate 3 steps to the right: 0->1->2->NULL +rotate 4 steps to the right: 2->0->1->NULL +``` \ No newline at end of file diff --git a/Algorithms/0061.rotate-list/rotate-list.go b/Algorithms/0061.rotate-list/rotate-list.go index aff6d15c3..805173f95 100755 --- a/Algorithms/0061.rotate-list/rotate-list.go +++ b/Algorithms/0061.rotate-list/rotate-list.go @@ -11,24 +11,23 @@ func rotateRight(head *ListNode, k int) *ListNode { return head } - fast := head + tail := head for i := 0; i < k; i++ { - if fast.Next == nil { + if tail.Next == nil { // 处理 k 大于 list 的长度的情况 // i+1 就是 list 的长度 - // 这一步很巧妙 return rotateRight(head, k%(i+1)) } - fast = fast.Next + tail = tail.Next } - slow := head - for fast.Next != nil { - slow, fast = slow.Next, fast.Next + newTail := head + for tail.Next != nil { + newTail, tail = newTail.Next, tail.Next } - newHead := slow.Next - slow.Next, fast.Next = nil, head + newHead := newTail.Next + newTail.Next, tail.Next = nil, head return newHead } diff --git a/Algorithms/0062.unique-paths/README.md b/Algorithms/0062.unique-paths/README.md index 80ebeae01..eca348fb7 100755 --- a/Algorithms/0062.unique-paths/README.md +++ b/Algorithms/0062.unique-paths/README.md @@ -1,6 +1,7 @@ # [62. Unique Paths](https://leetcode.com/problems/unique-paths/) ## 题目 + A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). @@ -9,10 +10,25 @@ How many possible unique paths are there? ![robotMaze](robot_maze.png) -Above is a 3 x 7 grid. How many possible unique paths are there? +Above is a 7 x 3 grid. How many possible unique paths are there? Note: m and n will be at most 100. -## 解题思路 +Example 1: + +```text +Input: m = 3, n = 2 +Output: 3 +Explanation: +From the top-left corner, there are a total of 3 ways to reach the bottom-right corner: +1. Right -> Right -> Down +2. Right -> Down -> Right +3. Down -> Right -> Right +``` + +Example 2: -见程序注释 +```text +Input: m = 7, n = 3 +Output: 28 +``` \ No newline at end of file diff --git a/Algorithms/0062.unique-paths/unique-paths.go b/Algorithms/0062.unique-paths/unique-paths.go index 63f6259a3..6f1b54892 100755 --- a/Algorithms/0062.unique-paths/unique-paths.go +++ b/Algorithms/0062.unique-paths/unique-paths.go @@ -1,32 +1,26 @@ package problem0062 func uniquePaths(m int, n int) int { - // dp[i][j] 代表了,到达 (i,j) 格子的不同路径数目 - dp := [][]int{} - - // 创建棋盘 - for i := 0; i < m; i++ { - tmp := make([]int, n) - dp = append(dp, tmp) - } + // path[i][j] 代表了,到达 (i,j) 格子的不同路径数目 + path := [100][100]int{} for i := 0; i < m; i++ { // 到达第 0 列的格子,只有一条路径 - dp[i][0] = 1 + path[i][0] = 1 } for j := 0; j < n; j++ { // 到达第 0 行的格子,只有一条路径 - dp[0][j] = 1 + path[0][j] = 1 } for i := 1; i < m; i++ { for j := 1; j < n; j++ { // 到达 (i,j) 格子的路径数目,等于 // 到达 上方格子 和 左边格子 路径数之和 - dp[i][j] = dp[i-1][j] + dp[i][j-1] + path[i][j] = path[i-1][j] + path[i][j-1] } } - return dp[m-1][n-1] + return path[m-1][n-1] } diff --git a/Algorithms/0062.unique-paths/unique-paths_test.go b/Algorithms/0062.unique-paths/unique-paths_test.go index 4b77378ca..f4ab89387 100755 --- a/Algorithms/0062.unique-paths/unique-paths_test.go +++ b/Algorithms/0062.unique-paths/unique-paths_test.go @@ -68,3 +68,9 @@ func Test_Problem0062(t *testing.T) { ast.Equal(a.one, uniquePaths(p.m, p.n), "输入:%v", p) } } + +func Benchmark_uniquePaths(b *testing.B) { + for i := 1; i < b.N; i++ { + uniquePaths(100, 100) + } +} diff --git a/Algorithms/0069.sqrtx/sqrtx.go b/Algorithms/0069.sqrtx/sqrtx.go index 72bbe48b2..02ce03593 100755 --- a/Algorithms/0069.sqrtx/sqrtx.go +++ b/Algorithms/0069.sqrtx/sqrtx.go @@ -2,11 +2,9 @@ package problem0069 func mySqrt(x int) int { res := x - // 牛顿法求平方根 for res*res > x { res = (res + x/res) / 2 } - return res } diff --git a/Algorithms/0069.sqrtx/sqrtx_test.go b/Algorithms/0069.sqrtx/sqrtx_test.go index 75bf685e0..ff57c0b68 100755 --- a/Algorithms/0069.sqrtx/sqrtx_test.go +++ b/Algorithms/0069.sqrtx/sqrtx_test.go @@ -2,6 +2,7 @@ package problem0069 import ( "fmt" + "math" "testing" "github.com/stretchr/testify/assert" @@ -64,3 +65,17 @@ func Test_Problem0069(t *testing.T) { ast.Equal(a.one, mySqrt(p.x), "输入:%v", p) } } + +func Benchmark_mySqrt(b *testing.B) { + n := 10000 + for i := 1; i < b.N; i++ { + _ = mySqrt(n) + } +} + +func Benchmark_math_sqrt(b *testing.B) { + n := 10000 + for i := 1; i < b.N; i++ { + _ = int(math.Sqrt(float64(n))) + } +} diff --git a/Algorithms/0072.edit-distance/README.md b/Algorithms/0072.edit-distance/README.md index 70d132cf8..d9c7a2447 100755 --- a/Algorithms/0072.edit-distance/README.md +++ b/Algorithms/0072.edit-distance/README.md @@ -1,53 +1,37 @@ # [72. Edit Distance](https://leetcode.com/problems/edit-distance/) ## 题目 + Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a word: -``` + +```text a) Insert a character b) Delete a character c) Replace a character ``` -## 动态规划思想:[参考源](http://www.cnblogs.com/AndyJee/p/4602817.html) - -假设dp[i][j]表示以S[i]结尾的字符串和以T[j]结尾的字符串转换所需的最小操作数,考虑三种操作,然后取三者最小值: - -1、替换: - -假设S[i-1],T[j-1]已对齐,即dp[i-1][j-1]已知,则当S[i]==T[j]时,dp[i][j]=dp[i-1][j-1],否则,dp[i][j]=dp[i-1][j-1]+1. - -2、删除 - -假设S[i-1],T[j]已对齐,即dp[i-1][j]已知,多出来的S[i]需删除,操作数+1,则dp[i][j]=dp[i-1][j]+1. - -3、插入 - -假设S[i],T[j-1]已对齐,即dp[i][j-1]已知,需在S中插入S[i+1]=T[j]来匹配,操作数+1,则dp[i][j]=dp[i][j-1]+1. - -状态转移方程: +Example 1: -dp[i][j]=min(dp[i-1][j-1]+(S[i]==T[j]?0,1),dp[i-1][j]+1,dp[i][j-1]+1) - -初始值: - -dp[i][0]=i - -dp[0][j]=j - -复杂度: - -时间复杂度:O(m*n) - -空间复杂度:O(m*n) - -空间优化: - -由状态转移方程可知,dp[i][j]与dp[i-1][j-1],dp[i-1][j],dp[i][j-1]有关,可以去掉一维,只留下dp[j]。 - -等式右边的dp[i-1][j]和dp[i][j-1]都可以直接改成dp[j](旧的值)和dp[j-1](已更新),只有dp[i-1][j-1]没有记录下来,通过某个变量保存起来之后就可以。 - -因此空间复杂度:O(n) +```text +Input: word1 = "horse", word2 = "ros" +Output: 3 +Explanation: +horse -> rorse (replace 'h' with 'r') +rorse -> rose (remove 'r') +rose -> ros (remove 'e') +``` -见程序注释 +Example 2: + +```text +Input: word1 = "intention", word2 = "execution" +Output: 5 +Explanation: +intention -> inention (remove 't') +inention -> enention (replace 'i' with 'e') +enention -> exention (replace 'n' with 'x') +exention -> exection (replace 'n' with 'c') +exection -> execution (insert 'u') +``` \ No newline at end of file diff --git a/Algorithms/0072.edit-distance/edit-distance.go b/Algorithms/0072.edit-distance/edit-distance.go index 88ab32faa..018bce864 100755 --- a/Algorithms/0072.edit-distance/edit-distance.go +++ b/Algorithms/0072.edit-distance/edit-distance.go @@ -1,33 +1,47 @@ package problem0072 -func minDistance(word1 string, word2 string) int { - m := len(word1) - n := len(word2) - cost := 0 +func minDistance(from, to string) int { + m := len(from) + n := len(to) dp := make([][]int, m+1) for i := range dp { dp[i] = make([]int, n+1) } - for i := 0; i <= m; i++ { + for i := 1; i <= m; i++ { dp[i][0] = i } - for j := 0; j <= n; j++ { + + for j := 1; j <= n; j++ { dp[0][j] = j } for i := 1; i <= m; i++ { for j := 1; j <= n; j++ { - dp[i][j] = min(dp[i-1][j]+1, dp[i][j-1]+1) - - if word1[i-1] == word2[j-1] { - cost = 0 - } else { - cost = 1 + // dp[i][j] 代表了从 from[:i] → to[:j] 所需要的最小步骤 + // 按照题目给出的 3 种操作方法,分别讨论: + // 1. 先 *删除* from[:i] 最后的字母,得到 from[:i-1]。 + // 再 from[:i-1] → to[:j] 此方法所需的步骤是 + // 1 + dp[i-1][j] + // 2. 先 from[:i] → to[:j-1], + // 再 *添加* to[j-1] 到 to 的末尾,此方法所需的步骤是 + // 1 + dp[i][j-1] + // 3. 先 from[i-1] → to[j-1] + // 3.1 如果 from[i-1] = to[i-1] 的话 + // 无需 *替换*, + // 总的步骤是 dp[i-1][j-1] + // 3.2 如果 from[i-1] != to[i-1] 的话 + // 执行 *替换* 操作,把 from[i-1] 替换成 to[j-1] + // 总的步骤是 1 + dp[i-1][j-1] + dp[i][j] = 1 + min(dp[i-1][j], dp[i][j-1]) + + replace := 1 + if from[i-1] == to[j-1] { + replace = 0 } - dp[i][j] = min(dp[i][j], dp[i-1][j-1]+cost) + dp[i][j] = min(dp[i][j], dp[i-1][j-1]+replace) } } diff --git a/Algorithms/0072.edit-distance/edit-distance_test.go b/Algorithms/0072.edit-distance/edit-distance_test.go index 7471b2ab4..2020c86a3 100755 --- a/Algorithms/0072.edit-distance/edit-distance_test.go +++ b/Algorithms/0072.edit-distance/edit-distance_test.go @@ -14,8 +14,7 @@ type question struct { // para 是参数 type para struct { - word1 string - word2 string + from, to string } // ans 是答案 @@ -114,6 +113,6 @@ func Test_Problem0072(t *testing.T) { a, p := q.ans, q.para fmt.Printf("~~%v~~\n", p) - ast.Equal(a.one, minDistance(p.word1, p.word2), "输入:%v", p) + ast.Equal(a.one, minDistance(p.from, p.to), "输入:%v", p) } } diff --git a/Algorithms/0073.set-matrix-zeroes/README.md b/Algorithms/0073.set-matrix-zeroes/README.md index f1d09bc25..259efb52f 100755 --- a/Algorithms/0073.set-matrix-zeroes/README.md +++ b/Algorithms/0073.set-matrix-zeroes/README.md @@ -1,16 +1,39 @@ # [73. Set Matrix Zeroes](https://leetcode.com/problems/set-matrix-zeroes/) ## 题目 -Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. -click to show follow up. -``` -Follow up: -Did you use extra space? -A straight forward solution using O(mn) space is probably a bad idea. -A simple improvement uses O(m + n) space, but still not the best solution. -Could you devise a constant space solution? +Given a `m x n` matrix, if an element is 0, set its entire row and column to 0. Do it [in-place](https://en.wikipedia.org/wiki/In-place_algorithm). + +Example 1: + +```text +Input: +[ + [1,1,1], + [1,0,1], + [1,1,1] +] +Output: +[ + [1,0,1], + [0,0,0], + [1,0,1] +] ``` -## 解题思路 -见程序注释 +Example 2: + +```text +Input: +[ + [0,1,2,0], + [3,4,5,2], + [1,3,1,5] +] +Output: +[ + [0,0,0,0], + [0,4,5,0], + [0,3,1,0] +] +``` diff --git a/Algorithms/0073.set-matrix-zeroes/set-matrix-zeroes.go b/Algorithms/0073.set-matrix-zeroes/set-matrix-zeroes.go index 1b298ea74..87180c005 100755 --- a/Algorithms/0073.set-matrix-zeroes/set-matrix-zeroes.go +++ b/Algorithms/0073.set-matrix-zeroes/set-matrix-zeroes.go @@ -1,34 +1,48 @@ package problem0073 -func setZeroes(m [][]int) { - rows := make([]bool, len(m)) // rows[i] == true ,代表 i 行存在 0 元素 - cols := make([]bool, len(m[0])) // cols[j] == true ,代表 j 列存在 0 元素 +func setZeroes(mat [][]int) { + m, n := len(mat), len(mat[0]) + col0 := 1 - // 逐个检查元素 - for i := range m { - for j := range m[i] { - if m[i][j] == 0 { - rows[i] = true - cols[j] = true - } + /** + * 从上往下,从左往右 扫描矩阵 + * 利用 mat[i][0] = 0 表示,第 i 行中含有 0 + * 利用 mat[0][j] = 0 表示,第 j 列中含有 0 + * 特别地, + * mat[0][0] = 0 仅表示,第 0 行中含有 0 + * Col0 = 0 表示,第 0 列中含有 0 + * NOTICE: 循环的顺序很重要 + * 需要保证 mat[i][0] 和 mat[0][j] 被标记后,不再做为别的标记的依据 + * 要不然的话,标记有可能会被污染 + */ + for i := 0; i < m; i++ { + if mat[i][0] == 0 { + col0 = 0 } - } - - // 按行修改 - for i := range rows { - if rows[i] { - for j := range m[i] { - m[i][j] = 0 + for j := 1; j < n; j++ { + if mat[i][j] == 0 { + mat[i][0] = 0 + mat[0][j] = 0 } } } - // 按列修改 - for i := range cols { - if cols[i] { - for j := range m { - m[j][i] = 0 + /** + * 从下往上,从右往左 扫描矩阵 + * 并根据前面的标记修改 mat[i][j] 的值 + * NOTICE: 循环的顺序很重要 + * 需要保证 mat[i][0] 和 mat[0][j] 被修改后,不再做为别的修改的标记 + * 要不然的话,标记有可能会被污染 + */ + for i := m - 1; i >= 0; i-- { + for j := n - 1; j >= 1; j-- { + if mat[i][0] == 0 || mat[0][j] == 0 { + mat[i][j] = 0 } } + if col0 == 0 { + mat[i][0] = 0 + } } + } diff --git a/Algorithms/0073.set-matrix-zeroes/set-matrix-zeroes_test.go b/Algorithms/0073.set-matrix-zeroes/set-matrix-zeroes_test.go index 6d3cc44f2..a6c94b88b 100755 --- a/Algorithms/0073.set-matrix-zeroes/set-matrix-zeroes_test.go +++ b/Algorithms/0073.set-matrix-zeroes/set-matrix-zeroes_test.go @@ -27,6 +27,32 @@ func Test_Problem0073(t *testing.T) { qs := []question{ + question{ + para{[][]int{ + []int{1, 0, 3, 4}, + []int{5, 0, 7, 0}, + []int{9, 1, 1, 1}, + }}, + ans{[][]int{ + []int{0, 0, 0, 0}, + []int{0, 0, 0, 0}, + []int{9, 0, 1, 0}, + }}, + }, + + question{ + para{[][]int{ + []int{1, 2, 3, 4}, + []int{0, 2, 3, 4}, + []int{9, 1, 1, 1}, + }}, + ans{[][]int{ + []int{0, 2, 3, 4}, + []int{0, 0, 0, 0}, + []int{0, 1, 1, 1}, + }}, + }, + question{ para{[][]int{ []int{1, 2, 3, 4}, diff --git a/Algorithms/0075.sort-colors/README.md b/Algorithms/0075.sort-colors/README.md index 9becdd515..a7064f1af 100755 --- a/Algorithms/0075.sort-colors/README.md +++ b/Algorithms/0075.sort-colors/README.md @@ -1,19 +1,22 @@ # [75. Sort Colors](https://leetcode.com/problems/sort-colors/) ## 题目 -Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. + +Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively. -**Note:**You are not suppose to use the library's sort function for this problem. +Note: You are not suppose to use the library's sort function for this problem. + +Example: -click to show follow up. +```text +Input: [2,0,2,1,1,0] +Output: [0,0,1,1,2,2] ``` + Follow up: -A rather straight forward solution is a two-pass algorithm using counting sort. -First, iterate the array counting number of 0's, 1's, and 2's, then overwrite array with total number of 0's, then 1's and followed by 2's. -Could you come up with an one-pass algorithm using only constant space? -``` -## 解题思路 -见程序注释 +- A rather straight forward solution is a two-pass algorithm using counting sort. +- First, iterate the array counting number of 0's, 1's, and 2's, then overwrite array with total number of 0's, then 1's and followed by 2's. +- Could you come up with a one-pass algorithm using only constant space? diff --git a/Algorithms/0075.sort-colors/sort-colors.go b/Algorithms/0075.sort-colors/sort-colors.go index 470045c04..8e42d098f 100755 --- a/Algorithms/0075.sort-colors/sort-colors.go +++ b/Algorithms/0075.sort-colors/sort-colors.go @@ -1,45 +1,25 @@ package problem0075 -func sortColors(nums []int) { - length := len(nums) - if length == 0 { - return - } - - // 三路快排需要 nums[0] == 1 - temp := nums[0] - nums[0] = 1 +// 借鉴三路快排中的划分思路 +func sortColors(a []int) { + i, j, k := 0, 0, len(a)-1 - // 三路快排 - // 排序完成后, - // i 指向 0 后的 1, - // j 指向 最后一个 1 后面的位置, - // k 指向 2 前面的 1, - // 在整个排序过程中,nums[i:j]中始终都是1 - i, j, k := 0, 1, length-1 + // for 循环中, nums[i:j] 中始终全是 1 + // 循环结束后, + // nums[:i] 中全是 0 + // nums[j:] 中全是 2 for j <= k { - switch { - case nums[j] < 1: - // 比 1 小的,放入队列首部 - nums[i], nums[j] = nums[j], nums[i] + switch a[j] { + case 0: + a[i], a[j] = a[j], a[i] i++ j++ - case 1 < nums[j]: - // 比 1 大的,放入队列尾部 - nums[j], nums[k] = nums[k], nums[j] - k-- - default: + case 1: j++ + case 2: + a[j], a[k] = a[k], a[j] + k-- } } - // 分情况,还原temp - switch temp { - case 0: - nums[i] = temp - case 2: - nums[k] = temp - } - - return } diff --git a/Algorithms/0076.minimum-window-substring/README.md b/Algorithms/0076.minimum-window-substring/README.md index df209a889..866cbd523 100755 --- a/Algorithms/0076.minimum-window-substring/README.md +++ b/Algorithms/0076.minimum-window-substring/README.md @@ -1,9 +1,10 @@ # [76. Minimum Window Substring](https://leetcode.com/problems/minimum-window-substring/) ## 题目 + Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). -``` +```text For example, S = "ADOBECODEBANC" T = "ABC" @@ -12,10 +13,6 @@ Minimum window is "BANC". ``` Note: -1. If there is no such window in S that covers all characters in T, return the empty string "". -1. If there are multiple such windows, you are guaranteed that there will always be only one unique minimum window in S. -## 解题思路 -双指针的解法 - -见程序注释 +1. If there is no such window in S that covers all characters in T, return the empty string "". +1. If there are multiple such windows, you are guaranteed that there will always be only one unique minimum window in S. \ No newline at end of file diff --git a/Algorithms/0076.minimum-window-substring/minimum-window-substring.go b/Algorithms/0076.minimum-window-substring/minimum-window-substring.go index 43ee9896e..86aa2668f 100755 --- a/Algorithms/0076.minimum-window-substring/minimum-window-substring.go +++ b/Algorithms/0076.minimum-window-substring/minimum-window-substring.go @@ -1,48 +1,41 @@ package problem0076 func minWindow(s string, t string) string { - sLen, tLen := len(s), len(t) - - need := [256]int{} + have := [128]int{} + need := [128]int{} for i := range t { need[t[i]]++ } - has := [256]int{} + size, total := len(s), len(t) - min := sLen + 1 - begin, end, winBegin, winEnd, count := 0, 0, 0, 0, 0 + min := size + 1 + res := "" - for ; end < sLen; end++ { - if need[s[end]] == 0 { - continue + // s[i:j+1] 就是 window + // count 用于统计已有的 t 中字母的数量。 + // count == total 表示已经收集完需要的全部字母 + for i, j, count := 0, 0, 0; j < size; j++ { + if have[s[j]] < need[s[j]] { + // 出现了 window 中缺失的字母 + count++ } + have[s[j]]++ - if has[s[end]] < need[s[end]] { - count++ + // 保证 window 不丢失所需字母的前提下 + // 让 i 尽可能的大 + for i <= j && have[s[i]] > need[s[i]] { + have[s[i]]-- + i++ } - has[s[end]]++ - - if count == tLen { - for need[s[begin]] == 0 || has[s[begin]] > need[s[begin]] { - if has[s[begin]] > need[s[begin]] { - has[s[begin]]-- - } - begin++ - } - - temp := end - begin + 1 - if min > temp { - min = temp - winBegin = begin - winEnd = end - } + + width := j - i + 1 + if count == total && min > width { + min = width + res = s[i : j+1] } - } - if count < tLen { - return "" } - return s[winBegin : winEnd+1] + return res } diff --git a/Algorithms/0076.minimum-window-substring/minimum-window-substring_test.go b/Algorithms/0076.minimum-window-substring/minimum-window-substring_test.go index aa6b163d1..59732cddd 100755 --- a/Algorithms/0076.minimum-window-substring/minimum-window-substring_test.go +++ b/Algorithms/0076.minimum-window-substring/minimum-window-substring_test.go @@ -28,6 +28,16 @@ func Test_Problem0076(t *testing.T) { qs := []question{ + question{ + para{ + "a", + "b", + }, + ans{ + "", + }, + }, + question{ para{ "kgfidhktkjhlkbgjkylgdracfzjduycghkomrbfbkoowqwgaurizliesjnveoxmvjdjaepdqftmvsuyoogobrutahogxnvuxyezevfuaaiyufwjtezuxtpycfgasburzytdvazwakuxpsiiyhewctwgycgsgdkhdfnzfmvhwrellmvjvzfzsdgqgolorxvxciwjxtqvmxhxlcijeqiytqrzfcpyzlvbvrksmcoybxxpbgyfwgepzvrezgcytabptnjgpxgtweiykgfiolxniqthzwfswihpvtxlseepkopwuueiidyquratphnnqxflqcyiiezssoomlsxtyxlsolngtctjzywrbvajbzeuqsiblhwlehfvtubmwuxyvvpwsrhutlojgwktegekpjfidgwzdvxyrpwjgfdzttizquswcwgshockuzlzulznavzgdegwyovqlpmnluhsikeflpghagvcbujeapcyfxosmcizzpthbzompvurbrwenflnwnmdncwbfebevwnzwclnzhgcycglhtbfjnjwrfxwlacixqhvuvivcoxdrfqazrgigrgywdwjgztfrbanwiiayhdrmuunlcxstdsrjoapntugwutuedvemyyzusogumanpueyigpybjeyfasjfpqsqotkgjqaxspnmvnxbfvcobcudxflmvfcjanrjfthaiwofllgqglhkndpmiazgfdrfsjracyanwqsjcbakmjubmmowmpeuuwznfspjsryohtyjuawglsjxezvroallymafhpozgpqpiqzcsxkdptcutxnjzawxmwctltvtiljsbkuthgwwbyswxfgzfewubbpowkigvtywdupmankbndyligkqkiknjzchkmnfflekfvyhlijynjlwrxodgyrrxvzjhoroavahsapdiacwjpucnifviyohtprceksefunzucdfchbnwxplhxgpvxwrmpvqzowgimgdolirslgqkycrvkgshejuuhmvvlcdxkinvqgpdnhnljeiwmadtmzntokqzmtyycltuukahsnuducziedbscqlsbbtpxrobfhxzuximncrjgrrkwvdalqtoumergsulbrmvrwjeydpguiqqdvsrmlfgylzedtrhkfebbohbrwhnhxfmvxdhjlpjwopchgjtnnvodepwdylkxqwsqczznqklezplhafuqcitizslzdvwwupmwqnlhxwlwozdogxekhasisehxbdtvuhrlucurbhppgsdoriyykricxpbyvxupencbqwsreiimclbuvbufudjrslsnkofobhptgkmmuuywizqddllxowpijhytvdkymzsulegfzfcjguojhzhxyyghhgbcllazmuuyzafahjjqgxznzinxgvgnbhrmuuljohjpkqpraahgajvzriyydengofskzgtppefzvwrvxadxjaydjydocqvsxpdyxyondvmyrfvqiaptanwllbaquxirmlqkmgzpbnputmldmcwoqvadwavqxeilraxdiwulmlffxsilvgcnbcsyeoqdsaolcorkmlxyzfdyznkuwmjxqcxusoxmqlxtzofocdmbiqzhflebzpbprajjqivhuvcvlhjnkwquosevfkzfzcwtcietqcamxcikltawrsshkydsiexkgvdidjbuldgkfqvrkxpdpjlakqsuurecmjkstomgrutzlqsxnjacuneedyzzrfbgpoykcmsvglwtdoqqztvugzakazlrhnxwdxifjccsozlrpckpxfldglpgnbauqzstxcaiecaudmotqyknfvsliiuvlurbvjwulwdsadmerazjyjydgrrobnmmjdpeplzcjcujhhpbhqmizlnhcgwftkrcnghctifcmbnvifwsvjcxwpeyycdrmwucedexnlbznquxvtpretoaluajxfajdwnhbugofjpuzmuxflolfenqynzxubjxawgbqmsyvhuwvotaajnfpaxqnwnjzwgzvmdnaxlxeiucwpcyzqfoqcegaspcqybnmgbndomkwgmvyqvxgblzfshimykeynslutaxjmjgvvdtmysubfvjxcrjddobsgombomkdvsatvvfwnzxsvgszzbccrgxzulclzpqvhsqfnvbcwywrfotgsxlldilatnntcfqmxgrkdsozsktzbogtlrerzrtuhiplnfxknqwsikudwncxdiqozxhaoavximjvuihjzdcjpwmmlploxeezbmzrmwrxlauficojhqtxohlzwwpwcuvfgwzuvqrgqmlaozmxshuiohingzjitgobcnwzdpfvdsxrujroqlwhvgubgdlzjzdnozptqwqurqnlzezssvznctokybljdoyrppngmdcdvpqvuppmmqbqlrajsmuvcupskcawhcbdrrangrbuhcnstndobzjgtyydcabkccpvtpjbgmyprljkamaelkkgkkmnknzosojnfupnhncyalkazlemxoshaewkuvymjkzqeqdlfflfsygrjmdidypdcmoyjoktykldapqiwenpcviniovnmkqqygpivbdvloaoftwcxltzhbmrrhedtuuudleamjvaxwqfrohozcpidbzxkfafcwbfjffwocyoaotrccfdeumjxngjthrvfsapyhnojlcmbxddzlidhwnhktqdcjykcazcjoqszveaskfsvnxckkjwgczknzupbvtkjmeihlkzvptqfrurdgnjkouxpqpqmicvugebrqdmgyenpbethrerhaqwrfodoqaiyemqxredpjqhkwctpgmwjcsaiifyyfiwmuojntmdeemqaolpwxnfbffjpmjnssleocncxbhbhttjjeyfdllessqjfzwxtjdilsmivvlcqglzmlepyrwskmbrnzqhivrwnfgiasmsaxrnkxeipaaboduccklmfckuhrcjlqblnuaxrfhihjlwofyqrleynpswiwhvmigbejavojgvsrtgztysefrrulpekwzwghakqaigkocehxnirlbvqspmfgqpdrolzowrqgycuchdzumqhnmyhdmojfeowsaxiypyenbapidoerhletlnyychdgwbayziwoicbjcsthixzplfkwtiwvsbdodfocpksxmvhqnczvaylnexjxgguyhzomecotoiqcdzuqctoesbrwyavgiresquewyvrmdhqhjkzleppwqgupirxtkcncytyxqpjuyadhmeuqulomtidcbbxlfmndfnawcmsdoxkadhtzshmmsrotsnfxzudgifcmtwpjtamzhfybmkneedawqhwrbzyjgawaznjunvtwcsypenvirvhhcdbgezrkbnmadyvsvopyippnckxviedmjgsnfkaizmjckgviwmghdvwhhtdpaicjowxvgzdglokyufgtroawjwesrhirrmbfiacrzfzmujmqpujiilftjlmdswulkxquzslyzkltuzmluxtcjawulkxfguqqrikrcwreiezeelpyjlaulyqziogqizgbhtsmrmqzqreudvsogviuvyveobuyadakwuwngomxfsrkomywhiqejlixnfwpiwzesxrznfwvapfobekkmdpxqzvdettopusjsliftgatwijzmvmaydypcvujopxfksocfxjydmrbuabiwpkwsklwfihtxhahzpleoxftjwvfzynxnzthkhfppnloulyvajbqigktdhyefnbunwdxfiowxzltljonuqgfwqybxzhemkybjdyolnnjmaczjtpfjvmhlllkkuoyhoaqrageptnetsdelumwpyfclsoxpewwsymlasqqofuhzxomucijaqookclzhjxbhjniefaukudkrrwlthxwznklpvnyfkaowpyauyugsxsmrrzmayiblsmdqzdxmfniuoiqoezjdtvukwhmxrnkkcncbtzpyoxvchnrlmarixnuvwhsowfayuccndrmrpjuwwnklnbtmqnhnwcbthbrbfvpkndbemxaikmvzpqlgettcxwvezpfgmwqzzrfnriybutdmkosqjnsglqkkhsqtogvqzadsibudvzphnjxxyrfjhsvokniyvdowfupovlrskizxtwwroecxwzmgmwghbxdgruumfnfpxensdlltpnqloeraayjdxpmojiapwhgvotorhbmypckdjdgjdrpagbosjrhhyndojthsutqlwcrfizqlqhozieruvabwpgmabusynljlncsvbljusztddkxbkyzbhlcifugthsexuxsykdsccnfixcljdkkkvmudjbwstcppbkplnhqsuvctanedxppudjxomvhhywzbgonwydquasoahsfejuangybsvkctjbxppknnpfirxyugszmcwnpcnswifycobbfrltgcaovaopghptjngartunbzofppgvitqpxqftquixbzqmmwmdrituijaxaiujckabbfwrbfqeggqveeaxntsxcuwfcrqgbqiexgybnofuxypdepbrltqpnnurgkyjcioaoobcciybgnflegerzvhokdfqofzsnpsedvgieejmtoxzuervzajldrbtwcmmsgqvcyfiepuzduayyrvztfkxylquneihlyfpykxczrddledlxykrfwofjgcznkgyllnjwkovdrarxfcvepmllatvivuvfcvsoickushylirjntetkqhwsatcvpyctvvheztardaenrncnrwxjfvbhqechegbzdifcegvhiauapwnhukqbiuiyamgethfwrnbvvyedyadozsxvfpxnlhllutrpaxnumorhnyknyqdziavpsucdbqpxjimmhaitqzadxltybwxlzsbrofwqxlnjwcvdcfxsexyektcnpbbqucjkjgahtqqpsntwssoyrocchgrzispewzoghrpajfqbulxmdnmuerylxqmhkenhfcpmvemelehfretwtftxwrlwjxfwdtdivuwsalwlpdsjjlfcqyapsnnbmsxqlcaiyxayiylzbdimoophorygelkqdhirmjzmgcloaynecyqsofbcyzjemtvscfjqokdumqknoarsyjnoroqpqbucwrwbwhtlswhgouvfuoxuykipbagreavatudqbxdvvmekgzpaqowobgfchlvlosnhotxsqcnnptxvtowlduzebgiirfvfzkpofmgxpvlgpibkxzvcuwivcqfvxcbwoqkueqrvmcbdnfnmeioaewxiocdlgehvwurdkkyypcdchqonaeoealmqqqbwwktvemyrxyrocvqlngzokpsmahcszfrvrmsyzsryrkmvfehvkgjwxdixkmsjtjhmvbkwubwnmiitopoaxxwudgunumznxiasjmrfqnscybxmsonqnlmquigowfetpeoasfgiuymsbmhuawmphagbjmsftwbkcpkuusdqrrjudqqdmetvfbzqprvkpwurnenjxsaqkjmnbdtphomorlegecqtammoqazpuzhekuunzpcidpxwcdcjhueigryytxqnzzujtqxufbdkscgxfkgpgkxmdxmwwemxegjzwgudjxncbvzifhxlrwzvtntssfpwnyxlgrosqduryvadcxqvupspdmjxtbvhbssimjacowwntysvvjsraljfxscqvxzxsuhedjirfegyczvakntkycqxxuqsuprmlysqhakofqojrjjbzdozhgxgapbwgskstciafsrkjfvapheqmsptaoccddzkxjeqomttfkfqpcsgjywvqopsctviwuuvfymvkhortvhiycrhapftdwlipgqlcmikkufwdwowtxhrbybcpgvvcidrpvethmdtjlpmhfjadqugqxifffchofafcgylueefpwuybdagvunntvuydxhrehwhpwukazrrvlpyqsflmsaipvguuolyxjhniczkdqcyetyuldiaxiipfojzexacghpqlqboidomwnhispkqzshfiqgnngpwqgmbwnqesgtrtabmrleqdlxldeatmrrcxfgvvycneveaxhoossgxfglimlbydudcajavhcilzpnwwbmrtuoaazjmlmlqhqshzseiwotxdjvckhteeheejprueemlwguvbydzmyxshswscpygyemhwfdajpnhyhczhhytivnpqjjsyjazqmgmsmoddblbipcpxbkhyawqjiiktkjjzrxrflwjmjmwbpnysahqafhjnrvjegsdaswfdsqsedofuefmemegrnrfhnolviovakdgetaiyonuusgyeneyawdjltugdkegwhobcojdezxztgzatgyvcdhpwbxbobhkixlnlxqqypprvotquroyuvpsynumodzzbmmmlecjvtdtiwjeozdiusdvhxhwcgxdvlsgpwqmqvfarrehqjsnevilurjwagcvrwbistviockitprkyjxcghqayzzygdtzzvirqfcfhmpbdgnesmgatydrycqgflheipxzwbggovjtdwxxigydedwefommausilphirpohmxasvypfepiksepzvblvvdfhvnrmehvrgvjbvagbsqmmwdmrezmcfslaheonljergpseqafkstwowiibkwfpoqrxwfnhqryyjsczukjmdfcaqkdchirxakxwpkfhbffkxkltuwfxehxwscybkpymzvkqfpzjuevtqjmkfrilbhhvkfwwwwjxutpzlokfviblrnwyhgkinrfzzbwxzhvtcmvnbhvwpwjilfhsntadmhclkyjkfgdksaxviutxqdgckpuyixbugfiretblzgvthvpppioilwmyliwvhzsoeafktgwumtnvqckinbqyxcwlkugstygaankttinhedfuhrcusstswrdjojbjkjjkyugtcvcgyhdgzfaravlwpohdaimktwwtscmwypdywigvnjppeaotrvyrglbbjzvbchxcwcctkjqashpykdubzssfdvgowbpalnchrhccsvekctkozepazjhegntdridcxilrpovjlzvnufctmttlfcpnqiqjtwnsgajxqegbdbrygvtuopfvrvjjfbsyxhrdkaaahickjtksoemetuakpjwwmqvkyopiqskxamkkhuexyqctkegbpcybsvnsjdcbvnzvbjhjfligekzoqhshlqjenwywbbxwqyurjbcpnlvrxuhqezxprgvefucgxcfnazgkalbpwwivqslwtlmlthrydwhaampcnyopjpfhlpcehqabdmowwhxzdecdsrihrwwambjxrmbaecbhqpfmxcmcioichqjbmgbyjlyczzdfbeoswvgvysziihlszwtocwomjmqkmtrpafjwdqtbksjvcwpdtkrxiglsuceivwyvdjtgbmjohvljrammmgkumvogztpvrpswaodeaosjjdsdfhprnblbzajyvavmpqksenwgcoqntkqytirglehketlbtiplyadepzntpdhkpxkjhbptfzfmsspnbfybfbiwcvqtyxdpwpyeqqzyrgklzbycgxdnankfiayizeyvtybmoakfjwsixrmgqptsffxnfywgcwcxudjjgvqrrjzralxscskhyixfitmkpqjjttubonsiwtbygaqlscuskrysmmedcopxjjbzytjupksxkkifnfxzyxuljyqloflzrmzpfikwveuhremejmfijzvtalgotrqkdpblznhwsdelisrtewdowyjwkpmdjcpmtqzvehrymxjwqaqwytmuuvsgnhlwjakfskayttwfrhejjufipsejpxrcecypeluxvwvqquxhdbqnxxxnpbyfyqjcukszvowsltibpfktjcggzdvrgwwfofjipdjmshefbmisuslfutlvyjmfhkkvstfhxpwrwawzpeslydquxdpvmeatomqgiwqflmyjmwjdadoaieufkldwpfseuimcgejtqhdfdoiftzfbfbjpmmmctginqwpxbysthxymljreiyinzrdmdrqyzampydozejvngtaueraosicrzhfcaxdzzrqyuhzaquoyqoswhtlzbprbyyfywizvbrvwyvyqrmpjajgicrjegaheboexzduauqyvnxngjcqmmwwqpfwvidbjufitkctgusbjrpqatiohekytsuqaatjuytpkvkqsesdvjvwedmmjxmepgupinaenvtxseqkiiogtlexpqlynxdeezvopvteqoejuuvfellxxpwofimvfrzlrvaisvmllswgmtlqfypenmsuugrbyrnropbgkptvipdujonqocudooykurmuibnwqofceyzoqdiztvpiylloblzxdnsnohmewtgcrfqhkaieyzowmbmnplluafhomvsioamiiersfaydboboqnbfbobbtiqgekqsldcthunouorvcsjuinbjbcmvlcdrptlayoviikweyqzdklxsabdbdqyqubhjxvlxjiftvexvuyyejyzlzcncuntprcaoxmniwtbrzynvxnbilaumdjrxykopopfodtwboyvpyikxxlilmcxrnoqlahdrwifbdberbzgahsxhefssjrjygbkiipzgxehdimujldjvxjebowtaneyvgkgqzfxzmgcusydgdpdbyjcohyowcpskzabbfyatecnzcthgimhgvlucllyqasazsdcadctkgjljcurmgaudnqhzbhpdarduxfwakqmqbxbfrurzuncidljhtykvrproxorhgdzhbdouxhusuycxkleflpccgttdjkkppmyqpmnmthgnhintvtygkclrweufqhxftvyiklwfudtdlixjbxpmaafygzfyicebaejmpirllmoyunhylzknbrlissgbxmcxqojhwcsjpjhjwphjotwpkjzfcigbwkynyjuwlpfaanmweviupelbqnguvovrzvgxedwrubuuqiqwdyqufcwxrermtofujotprpintchjkziqaykhcietnxhilpcudvlwntjgysrkrbaralyeteyibhsmwuibsvxhpippaizskalknkqiqqrsyjeugpwakvhbeyqggqyqskcfwtnmlggjqlgyceymzhqfhgmnwmgqykvufljrrpajcghgkhvmqltxrhlqutgsdepjpaairasujbcvjxhzidxckksedazgeopvqrehsybbbgykdimmllovxicaidiprakhrqqjqumsaledtsrgfhdcpfcailpbnbkeudokxcexplaifsqlbunrbstmdipslcwffmscpyzejbppvfcxbpqdhjrmtgeeibknnepecqjosafphhmjyeognfuglznwczlrddwfthvnjadqjrbiwpolwiskjhgngrhjudqqmmdvoinycpgagwldgfnqmtfsmmbjruzdgeawnqurfarlwcodidvuwcplpquimtosxormeldlouzkxnphrmdppsaglwoxpcsptjbzufnkbmvabmhublmsfoyqlooatiportpnacybovesjnmkaycgncwyrmakwsannpdnsdqiyuchipuipyqebpesdheazgpovsbpvtavqcfatzkjxbpaquutdyveelscdtrboryeudenepyesoeikzdpzztgmlkpgbsuvrzrwfgdufhmvnwhocwqdpypaigilzcgsdxqjetflcuiqspgulwxcuoeevmquowouwedcakncevuzkbtxztbwhfacrqyhnoblvgnvrazxxwwjxsgynhuwoxbfnzocqqnnyakrcjpzfniehqfuzbrnyssmthqlzeyxgipjugkbttgblnxloqynkrbgarrzxqyganpuvbwpuesgrrtfiruukvakpslmkmskbjhxlfohjgpczijjaeembexqykdiwxvyjevujjdurtwsdhcdliqnopfnbixyisyrytnheqbxjzpnhtsubkjqbpddzcbjxbavundaegxpgoepizljjvbnmgqljtvguxbqlgqrnpitdnknmvxxqakehcqqvnwpmzfxgxqtmzosoafcvebofosmqkemzcdmbllhiccxdsrtswvodweimwudjaricuudfgnqirpnkigcedshbyrovnreniopejtmpiezztolduqhzkrajkoeyhklrybwjwiaembfhprkljtktmncxdivluievjaehkhlyithymrjvnwqbjtymdvzyeevpgzxrikprdzprqaofyfhhahwffvdlbaaicxbkksbprshktvprcybcixinunyyoagqajckbeztwgdreulgvmldltshisfyunquwteyzgtvowpusabpomsbhmirgqqbdixcbeaaktyarnvlpwbdkvgtkqmqgetmnrooxqrhjrjceepvcqaooghywwqdamrnffecvxlgoukuzzrdsrsgxbgvxyaykrnrytttsebgblccntffmxnlzvhwthwgbmxzhtvaxwiaklcxgietfregonfhxdpyppzziwzhthifukcdsgyazegnslwrpmrgbqflpgskoapkntpfznhauopoblfszwzcoendlipbienvxfdyukaoapccbjuchvhwcubncrqnxfkvknvfawtalyeojbtrwapywqnbjfohlyexozcovyqjyvzhysywsnvpgkqpseydecasefibdzmdumkuelqxanmgyeyskyvodxjherkhqxmmjxgpkxmkkarkercqpzfszqzdhmnajzmuyvjiuytgymrfdvvsxclwsmbcaocjqqfolrzhpsopehwjcsbbwozpbbtbpxnhnuwblvicpwsvdqeiiflhwlwxmradoplbmjezencvlwqroubxbmexxcwjvzpjqamcjrepeikrgaiuwjrzwxxvbvhwuwflwuphltwrdgijiregcxfaveyyafxubehzyzgjueaymlhwelcgjhjgoheombkpgsqgtwqncslodvkhgmqrvzzjgezuhklpebwxxombgapkvztdnjxiiwuqctmkdxbhyzgxntywvngqobvblsmtpgmrbydfwfowgxuwsusniadwbaamtmikuubvufcsmtpuqlqifkxnkcmmcoavakfwgjrbqwtepkyhvrrbboqmqeasscqsnxotgiwwescvcbcyuvbvjrjzwjtoojjbhzwpjtopnqkptopnjqlskutigpyuyhxhjtxuonkbdwtzliowbzrlwktczrwabtjmoigfvsibpbacmqynspaocvqdoodrjndxvmetgnuvqwzcmyrgprurokvdaaujpahnmnguacstyrxmpptfinyxataawwklwtykggfjixegobtgsondblcdfeedaqoxlphrvocelimckhkevxhzilcppisqahplwyftnjxasmeetoiplsqudujtdelflarjywenheozqsdjhoaugqojnaeqepvrpocqmgdukrvcmzovpopvheguglmmcjdsyhimnlgafecrfsmuhbpqhxmpkabnjghjnrybcedjihanaojjsabbyptkpuxabemoxkrcqwlbeoqgeapwasaahtlwpiyspkjmuaqnzcodselwecvhuvhbqszfdzaskjggjxtkbhntoapscmzwjjzzbaheahykqhsbgmmjvbcjcteegfdpocrqdawdhxpzehamvovtqxeusiaaodseijwnjtqsqhrwqtimkdhcclwwuyxkcrqmanzlgrfyywworgcbljfpxbltakfebvqdiroqitogrmwlszodkushvgcxqhdudvxlmmcuhscbhzmzyafkuzusfwryexshspuhdybnreqadczdegpbgjvnionmlfvgxpncqqrhuhhzjieqrutxfomneabqhwyeoljebanyiwztgejxaewhujvzlyrsvpzlairdkgbscbokhzijegsyrnxcmqvjfwwhgnlqvmlzpzjyytjeacdrrcwfvrqapmivbtnwhavzbhzcalgcnlugqqmljclarvxuomrynozovyqwjzaykufcmtnxvbzowwjnjcnyqmmomfkyemyqhdtvwivujukitvxexkcqyqemvqkbcjulophnxejjavtvrqzocbeasimpyzrbknmacvnbbymeufzlxzbzagbuqqkrpduzqibsgpthpgnjnnwlmykogojyetrtwlumwvgcmzlehznvmmgamsosixsmqkhoxdctbixnkjrrkhoyvuyhpmbxktmcfttdxvyyewnofhhpqwnlsnshzvhlovowohznexlivbyaigrycgjutdevyngoiwkyflmklzugavjibcifjtbeyhzwwineexfklrwysqgtlpdosovdhxhggjedrrjxrohehdcawitjayyumvzusicbrgekanirervnvxnthicjjcfvyersnvtgczrcnzvtqqgnpwiygnippplpueihadnedgisfdlyvtnkrykylunakaqehanhdalihvaoynotjefacpynkopuqhaxjnepprxymanmndfwjkznczcmnsiebiblvickbzjqzycpdilnumcwmfkzzsfaajnvtpgurrkqpnhsxvhrhmqtravstautlirezzzqqljhyqbxllrvxhoojjiemcaxkrcmsdekqnrrguotffocodsaoaecdgapxedrjibzvuqdphxuonzdstfhwjjbqlqpruhaekcbfufubeqqrpvkjarhjcibqathwakammcrghlincaetvoevhlgmticwblsdvtphxjqgwataaxuxoysvmyjhindlzwqurieoruwnwpowmkvcknaynjgyxljwjcsakwqbsmqodgmsshudwubkejkdvtzevrfhqxkkmbzpjnjcxehtyifeuphpliticasuacemfddptntqtalrktyekhvxqpguraorcsfiyjztyslruykgrkncsibkzjgrjukmoqwobvhzpsslrerkpgohrqtqzzjjvuxjktalohmfceqvihfzqughmbzncjyxfvjrojeesqjuwbrglxgbtokhqjuuutszqdshowlgoxdkyurltzmonwvfisacluedxwklvwtjvwwvtphoovdduajcslgffmjcjtpgrirohnkcetsuqvykyjoquvyzhjdscuawcsklhwporiiifiudrjwngumpdrkhlmdqgqbqotegdoqixkoqvkedgqvlifsvtylaqpqeiwmlkcvhnjaiveobwjmgqhcjhnjxcbbmxozksvtfgtqcxefupucfbeoisahwbkjbailtfeyoyqsxwxtltwquaheuhlrkwclymyrsfsidiacfzwstujpuqurxhijfkxeyvvsanafyckfcgxxagmwyinxsxhxjedibbacqbjoftthbtgdbtaadpxvpgvykyimzjqqmzgrvcbwvhawccygtwdicajpzrdactsoubipdloasqyxsxfnviyzjhqkytmbofrjgbalmonheleykjohtmhctzmttzwhgosortbejolqbrqoaevtseylemfznditrbjjwkphacxetqsvwpqpwoaadhbqljmemvpkieskirobhiyeypvufxwifzbsinyxkohuuzhdrvgagfggwbcdzyogzpajeygqoonlpuqirwjxdrdbtffufvaekcoqaugrktcanskfqvewnixinecvzezlipbimibwdfytzjyqecotmlbcsfxtjwfrmgcaqfwwlxpkgncmrqgeejgwpdpabwupdwpvdorolgbtvdhnuntyzbwoenohkizpgomkeeapmdikhqxdfsdetzuzojgytfpcwcoagqsuucebudgcvjiqkdpyoyzjfoldqbgysyvmczpxdvzaghtqmiqaipkogxrwzxxtxsfarwzwryzzhupuchwnzibfgudhuaatuhtodsmwslvafmwktsxsdaxjudsqfskazfoeaaasovuvhsfcnevqgubdxttdnffoltsltsfjpafyumchrxxxuyattwygbdumymzsgfdxhixbvajoziltjopcknjntfcrublaipapxxruzcizkwstkhywxjlsonjipxlxmnplmgimkqlumfqypqwmziepxpaomlmaadmmjuyvmjpbphbgxyswiyofnouczicblonwkorzxiaoqbupboojmcrcqnervgsixhgjvxivhkjzmgpnwdzlfqpxftoabikapqmlpwgwhrwvzlkyqjjxbyugtkiwsszjklwzhewoyslxfwxvhisjgorbyaasuzbfkaetecicuvcbrzwziqkqebueduwatahfalyeqijmenoxmkwwdgphklmpfkpakwhkkhraqcmwpatdnscqyrzkelajwpliouvybmarqmpfpjkcbmubftojhouffhnvbitdwvwmimtxxgbasvdaqrjxhgennskrceuzzsnjgjifpjfjgljzcvykddzqvjhxpdyryocgzlmowtzfelejicvlfudcfncxscoqqszpdnfcifhnsnyaptnxpqbwddtygjoycpohcvjlcsaufawxtjukcvghbafjjwhnlxvqtgbvbdsgdofyabiczolaqrjcnqpyqmojvrgwuyezpkxrlfvkwgmmxvqkogleubpptvlpwspncmepuzaqfmefkvradcexevnzsaoosfbwshmmgoeoaitmdmmgpsgvnvwgvmwqsaokhayoocermzdqlsyckezazvixigpagdmogkewokpajtsunrzxxyzzuhwconewqqmycqvqakqlfjischsbftabbyfrllnebccdszvvmoirzqmdzgehzficdqtrbjxdlzifbgcnulgvduydackahscnkygmjdrwebdfhgudtbywvwzwzjyiecxocfclitjnvnuetpimsikpfkngvlqbqosstugeoptlcprxeblykworgbxdpnffdxzzrffhxyuznmxupkuzgismmpsbfxikujlnpqvmornefmyvxswddpspekslhcydljqcanqqfeumsuhppevutnlzzdnihlluudxwrnnytjkmeudvayptnaumfhumuhgplfnevaeokqcqkgnkgcfueagjjdxekfvxnidilhyvybnkjavpeclkestoxsujzphmzkukuthswwchwzycckmgehwbbqkbhtnhgiradbubxwkwyiyasniyuhzyxmzhfmolwhnbihegeocexcgrpoqmvpkvdlcjxswwzkzkreqxsubrwhjoyzavqmsuxufwmbsonuyfyqeskikirvwpwwnokfkhcpeqtyegsensuslgaxprunjqmwewdpefgkwzicgdhtvdnimnhdhbqstcqaztpfbxpxxxbfciyyomicbsfktxcpaupboggrdxoawpfzagzquhsvzzivwmkyhbbxhhokeeldvscxybnskhqmiajhmvfvwhsdqgnxkaagtedtftorcgdlgmsuhzqfikizryydyalterplkdcmliztutnetflbqucjscmscamirbtbgyprgrkckzidfuhxojgiouaqumblpuovsgmyxybhyjnffuctfibtecmzqnkgjzbehqeeohlotatyuvscfvxkzjjqyvyiwbodrshiavwtxqrsnlwvhtfifqadnynkabptwzbwuaptsilhujcddjlizmnpmbzoeqiaplylnpffysnucrxhbkpcwerlhszmjhoyvpkierqcjdwlwvsxgjceotpvopjxyaxtpjetauykzwxvsqvazxepswlgnwflwdhlonhphhbidydxoazqzehscuyprecpjjdxwkofrpnwotwcvvuvbcndwnuptxfcgicfuqmngcluxhysfvngzcmxqgnjduomestyifnqhymeinxnimvhphghotqtpgftyytjeibnjourbrglfbuuladbwwulcahdacoglpuufonihttownlhqoimkfzpfishliowzisfyfnhajvyyggqvqchvewcmqkzyyxyipfiwuryfmxetfuqxzxtfuxrkjrljoltgqbeksdshawchssetrzynxsaijlszylhopmajpsqrqsajmeegedvdvvngifhgtpwidzturmlkgnvtrzbxewczuqhcxrlqihaliwfcismofhjwikwnjaodqyfqpsixcjikhpmphadohnmszihijvlbvtrklajnltasimhrnmfwbsqbcxlnvxpqsiddimtvgvnqjwiylpxmhnpmlbzgaoyszbxhosfwnumzrwxemusviihvlhdnxbfwfegtzlrofdnyalemhxhrfrmsyrfxtmuasctrpmiwpvvribdsynjfewxenebiqxilbdeqpmnhikyslekkrurxsrdhvesoeczfidwxqlgavfuglhscdkbxbeeykymobnwjrsijdplawfghmblrnooqstoctdtuqpdjjosofdoblwkzzxrmlhefcvhwycqqtwackuspagslfcmebftmnxrpsalsfejyajbmfvdfcvsjzfnckiozghpahctmgenipqwulzanwsyxzmzkunjcuadefyslefwtvsnhspwqkvojjntfbfixhndmnyardwmbqzkkribbdpkoegwfnefwtkjiijbmhnpzozkfhnincvbgbxoqdvmyfviogjcpytpnsbubodoqysybrorxjdxrbghjrlzqeqfyrzzfeqxekxhbmyaxeyqfgzqxkppqhuoyuqfagchqaotonuntueaadqzqgpgpjxofntgvynnadgoqcbjwhlyncydkplzaingxjouhdhhgqxzsakrkwrxyrcigpjhazpziduribaotxnozafjwyiuqmeycnhemydwbxnlbpcuopiorpznqijgwngadqeroioshddktfhhxpxohxexhnfddnegdixusnmcrrmmztvyltosssrzgwejjirptqjnexrxoelnzgnmbcgvuxwcvblhlewgvhwzenystjivrvhvxoqunnwjqksbookjvgkzvktpvdmnztkyjasxprihbalpqvbndnoyyhptnbimxsmgvhfmypubrfshatwfjkdhuvchynvvfhecqjpobjrsokcqdyvmlavfvaounjrusvzlhozkztcpdefgdavqasvysluhwleqjdbstdcswghzlmhqocgqxdorokzmyfcjiedbhhvdnccyqjqgoywnbnerxfdvkggukjxrquweyyeojxwzvtmxitqhyuflclhmvhflbbrabwqmtnmqiapqtgxuceheqqslxxyzaqbdorpjgdzqepizxitzmcfctxnswotyeubuoqdwuenavvzsdvtqxyusvkltyerebsypldlhhajfwixbfrtdroxnyiiypacqucfhfsqotztrktspmoudcsscabcrbehxiohphxdczztjsnagbvjfncjpdlhgrqfbfmqmkwqlvjupywvcrgjgivynihvcxddcpuqbqgmnriesfbwyhffscfhlmfnjisoxmebenptgyxyfyufickcerjrdoepwzdwnjzswonfonftnczvelxkdjcixixwhauvktpihepwrvrfxsadeanjjrriapejragbtvmdcbbtwuavndytdmeofvwfmdredxhzvvexxfsvbttowrjzfnplllsxojduhlvcizbhgtfhmyyirhjxvykgmcfaojwvwrzesaoattkiriskrchmctuoycrmlnjjhipbkdcfymnrwgcnklcmfwdfyurljcwskmuwrybqkrhizjvlxxzcwchwyaiicgcoswmmwnciglqhvmsujswfwfcvhmflshznglzcabnjodqlplfbfbibimyradctlbitohxrkkayoskfdpiitrmdfkvgoxbbbjwpqtgcgicwbmbeempzfbeknzsbzteaccruwaweizalnbqtphuukzhxazbzthbxkvsgvqkfrmrhpjafsvzcugzuicwbkzyuuscrlozcaqjpbmwthyxdgyzobvrlvqhrkjlvzkazclqfxnyelxhrvjiwezjbrqvcbgzcsbbunuzkjzpwwyprhxqoxbrososvuuymvbiixhtggkeekuyutokqpbhjqbhmvhbrijbgrwozgtgtpeniuxblyivqlefhlgavpddiaskgnqzeuomolnzmxwcjcjsnpujfxmpxgzgvphzjwozhbbvbzamcjgpzaagxpvxvvdtkmswigxskynlanzcxftwhucelxdgsizfvubdaavmbjzbyydvfytmsvtfvwmphnucjxfmadyboycmyhiefbqazlfuitlpjitshyehddirdmebtohzrybqjgmtayklgddnekxhnfbsshvnvdmmbnfmwriyrsjzwmpcwmlltmfltbzqenfhdmtbdbzxwkwuwlwvxhirwqerrfkxvreydzzgdafzkcvinrflaqeygiqzqcwltcjwbkegmkfymcgbtomweswmdontqlejnphqbmxnyelmhtnchcynuxbxloqezwpmlxfolcbjgoxnkkqtmqhhnkgbzzfavupjtuxgwbpermsbzivlaesqqbrpawsvsheobeuzfmdwavazfxlidfytgpjgndehkkvloqmvcpsenuesrpauwyndpylebpmnahaqzmmdcgipamjtdmnzmcecdqggfuuhcuydhkhlqrcsfllizajmcoqfewojrirveralbjytaclfqyppyzbanrirqwajgtgkmgynqwiszvyptngrmiuzbcsravcgqiqdpoqhnbzowzdqpljbtddxhvqjstpjdimuyeblfdzecewrqfvllaiuxzequvzxflservpxyrddxzungrbrrjopkshgpgevtyzktqjuhmxfntuulvnehbvttcajkeedefqxvbtdoskbmgxzcldlmbegderokxtocjoxlhcbaoeovcnzpskbtojzvanfxiubsizfrdirsmfnqumfnwjimshhtwnsfjwztxgkaoesclhvgtavrlfgennzjctqlppgmxrnlvhqgploknlczridexepcxinnzubxnqiiyaqplhzzsdajnfpnjhpgpevoaxnnnwxnwqekxglrlldzsuobbdhshfjkcwxruvhtnldkrqbddgevbuwexfxgkiqoeqgblnuyyzkspnxsudpxxnbwsyefgvtnlboyokypjkjazgutjjsiwuequivbfrqssgshqsybchdcnxxyiqgemmwgushajzsdfnkxfkairdmgcjekbmqnynuvhdvsfpvmcgkiqmskqeqspxftjvgkicfriajnrfzwnledyypqcgktdpmonvyxxdphfyuxdwvqhbwhzlxdtkwyzlpmgnmftbpyzjxdhuvpvryufwzagyzhjowrdiyylnzkzwpgtlxoewllskmainjtdhkiplhaygnzecgxpdmwzxjtjxvsmhnpoaaglhijpvltartrwfpyezrpypjlwxckxcqilztawewyxpquwhsailrhabuwywjvbbfmcanzfjxeypywxswhepogqkdoholipswutjtauseukfqjxoqbehiwrnladyiuthomqjmnesjoxczvsrywyivsvgsagdvzkjnctzrxubnrfmmxfnwevrytzqtfvohfyuktwbsqefhjtwjylfegwczxvveqjlyjgkeelwusbddwbmvmtztreuozptpbgpmozrsnnofrsknvziiskdmozcnrveseuestxlilbncvaprzabtkehyfklwhpqllxehurphufjqfbhgbizlohjvtwuankmzjsigjxndezvjacrbmtocaxyvvsviehjobtwkrjqvinhkqynerbhtahovbmgfvrvxlrjedbbnpiyhjllcnuypdolearkwkhtvbczegbrvlrcudnzskzhnnusqneoynjtontstwmohdqeggfaqeidrcxjsbxqpgjfueynckcknuqwavyqbgwultedxdvokgtglttpfxbvurruopnryjmleqqbtlrfrnleghumgvjapaxfrkxrvjezbwdwhwcbjphsybefznhqpeviqsclbgnedsbmofpywxqvawcbllrcqnmifowjxlpcdqqrxgrufjrhhvjugawyplhxbfgyqvctotmnbgjirapzvyvebscqfjpgqvhgtjbjeowhwipnkfoifkmieobjaqrqoyzjkasqqqymynclustcefkivntveloslnbvnvmenksozwzwpsatxkesaxqekeyytbtgwhmjthxtdyruqropdukdtajgghezixhgfwsydrtgqmdgfrwjngogiamqhqpsqyyvuqvxirgadjgjceurmkxukmkucbmsampwfnwpeepjnvurcokobhllvxhyztsbikznxvedztmoqhhsxrjybumwrtuspptxztmyqqbqjpebwmuudduezgdqcxjroeqpzcpqsqgdimeeaaagfvmedpxfpgwdmovoqkekdmnlaupbushantgqjdyylwdylymbjsoogbzgvqhskosxiyqtcqrpmunxtbbevpubsviolpgygavqanjedauqwjprnsxihrmamuqalyytavjajsfoubgrkyixqgiazucmqsodsmzujiwudbjxerqppboghygiuiwkckqwypsizoecsncwhsnwtceccmlxwhjauzwuqocsdjuvwwtfrhcmlipnvckrlwsfxqaohegmpcjobctsjxewgvkdxwulsosqhsgqzocoqncrpylbvsxbpjepgbaarsqanyqomucfhhyzfkacezetlkitnktfdmhqkyezuiecrcbyodbuehqpraihlcooqvgcvmbquhummvmcanxewpuqpexailqyiydekewfoqtanhcnvbrrqnhgsgictbdcbgimketywmajtfwqgpkxdtfxcpzvscxuihivnbvjpyskdqbjgnijipikhjgbmfxwnftagrmvpegsvjdbyomgdurmdxorclqrrluzcgxtmdnhorkmhyumulzaiptncjetxavzgsttxiclzpzgnttifuipjbelnlhklclswgntppgqefxuaschomzxpdkcqtocxawtijoxauofbnzchdjvrkugogleazizbgtkphjscxxfmyhtdtqudmattlatnisqpncgxmyblxgyxqtajkuowxirkimxshqjusqtequsobqlrlocxiqwhynsiarbjhkfaczgttajwqupeitbtkzaknutpmwatifvleegaepyxlqdwjepvgrgvmbmaxmthrrsyxyabpyabodxakovqhblvexvblrlckdchecktdlwtqvtajpstsdoxckanblslruuxxescrpvikpiwgbpygfxjpaysnqfenbbmguoxljhxyqvetmfbscmjelesdlwqnacvwqujacgyuefnqkokodutoalrljkajmxhfsqfuxfobmdtwtenwaimavgneqqqenxjhooblwroiwhhqnwonebpzjddzvvditnshdtubnkmjttbhrswvvmwerbdmxiwqxoxdktgxdsiwnmdegabboxhfzmtwupmuglzqefphyzflnjsvltybrfgqrzooqaiyljorofymhfawossblqcewkuplidekncxwtolyozhubektwohmslkdiaosfudvxcrqreqhgydheqbaekowvbzddqwikbdjdxzwbsgjqjrwzuydemcbpdhsvfdiggrlftijlosdzjzzfxellindmuvhzyphhjumcevpuqsuztvhsbsdkfiybefcexjnggckkxzfnrzpkwwexqjjwshzwnccmnsstucetbjjukyggwkfmtpklwkjlmoxzgrvavzvykesweacakjpgybrxldkzrkbzbwbxxwxjbqffqjidszjtacsofcpymqxqoypnxmwyedfvmpahqjcrluhtywrnprdfpsvoetojxugllgucrwvescxrarerijzxbuohncsmwyykgumzrhejlbclsidcreauyqcnsuapvabdundnuhzfkbsfmxhfbjabzepsyrjvrkznxebtlaaxducpsmvvvxxxbmpbfazwkyjjcmepmgmqarhudesybpvedmgimfgyfrhjenyqvmiwdqsiumjydecitkshrygwsphwdhoyuxwzprilfrljxorsakaskgqcxyaafpbbmzbdsloyeajdqcwqmwkzebdbbeegthihilkdyadccmfuobldzxcdyhfblligssnafzfdciheumzjqmopjstkzallnvrfphhugnzivgpstodjcraljvxkxlvkgprwwbseqspnyeftuiewbfjmajxyusicjayhdtmtlbglhofdwjbaqkmrvjrpezspbsxeljzymgkvurysczstlhkhsbywcsmgnlmywmziujdocdiecdxnkjwcmvbrppxccjdyxcgrnlhpoqtsvthfeejrbmiqdhvfsydscljrwrgmjbeewolbswstjclolgufgxxklhbhahwllcphqcikycfjgryrzszgrwqcfsmfbiqomhwdlgpkjvtrmrjllktfgmjmgvtjfkystwxfcmrnhmfveqjraewgqguydoklyiftecaiqtwagbxmtgdtlcbdkwepkoakwffcjgmazichlztggxztbdylzcalqbvoicssifskpwtdvnjdklwnovapxaaqdxemzxekeywtupwrcgvortbhqbwqeygjvmxwldgpbclxuhrwponihqpyunqylwhikhfwklnmqylmieixsxiaozainqiaorjayowjbmxtmkfupquhncjdblnqbvrrpcsnqqytcvnrgulvkfeajodnztddqwwfyotqhrklpzcvtqsgvyihmnuogxtxupcugxlnpvagwfbrvvxsthzivtybtrypidjoaudrrexnjahgxgytoydjtbkmuldcqnrsjwkdcjqnmxtleseuqhdjkpyecbjsqclcyxfbixouxigdamxswadirbnufyoxazbyyizhgqddyliayfswhveyztsgrjfrkjsjrrsxhvchhkhhpbdyzhxabriuanmlwewqxophlsqueabwbeucotcrlklnazayfwodmgmayeueewaicxksqnjdzvrburccqqheytgwxbdezfmdcwwvlfyncpozjqbbjihhdogcpjgqosttrpocxopzggapwbshlbpopxtgizwyusrnhhrewjgcpgtnknvxomoglhmtilrcdlrmsjtosbshjlutyrrnfhtqohlwudbzosmibhztirarfxldqesylnobxcxrfyrvtfdumeouwqlbpygiebgrowslysffsycldigpmwliowlgxsodtwvjspxthcycabnfjvwvthgkftqcleggadsuspnctogvrvacrwzmffwkzopmsxvuanrueeyxueulawntunhzuglvuaipxflzucwyjuxdbrrdpeyjtfkolvjiwtxtyivsnrqwlpboisrxxpiqxseioqqkjpfiacanttjhkkvtdpscedudvbmlrexawdiwhljbgsiqefljuglbjieejssazpavulrcycdgwnyaskmpszqbhuhqpzsopvjjiclgeqmadkcywonoqdrxzbqoaierdndlrqtxhfzmscmqszfieyggzywagbtmqwzinthwahiujvldwsmdqujsshuainobkojzjsvlzfgicroblcebwptqwnshdhinxtogljrlqzvtsludnahlpabnqwwtfgiczyknjdazfxsxjobwoiifklvchtvmafqzfcooioonmikvxntnvbvgnqiwjgllndltgbhqqxdegpzfdusywnglfrhrzucoypjgrtwjqznwqodtiwuglcrrtbkuvolteuzxnxggyvepjiiteearhrkcsuxqlilpenoukuajpgaaoituptmwnyyhvxxgfjvmwjggfirworwdcpzrllnymnfhlfnsoiektksyskwjdsmfjlwwzlwlzcsmjfexpjjkvdkqpgztynajaxgzkcmlggxpncoenxokbyasgblgomqplyqvcfjjlgazirfxouiruikbmxhcjxrwxkuapdlcjnduejtvdbozmaayyiajhugfgchxfszqfdmmmghrjvqvytvwbyhkspparwxyqwpybdkplrgvozqmsokvmsfgjvgbtdzmbqkdwwshpbcdcvsulepxwwdgrljnqkbtdlyzjtiyundykvuvajsyfxgzkpoccpvfcuglnoljbohlmbgomamtzvujkklobjtddzqsqbdrskfennsbqgwpbtbodocfxwkcxbunexhwjmcyzuzrbyherksuyvbwrmaopvevuluexwcyteqwezavjtrjothhhixwdbtxmndlmimfmedsddnoygxobhvipvgswarlpvybfkitolltpahpgheiobsdwzxtbqgqnesspalfmwzdwgufpypdahiwihrlyzclewgvwrakqzpoiktxkkdmuljctcqtesgiomfmefzuhqirceonotzkfkpapfttxzdnmibspcowtynvcektxkdewsglzbeybhlprpjhrxfmvviazutyeyfdtlosnvrqcehwtqdnpizkdjmeeffkgknbvevizmydtfzoxedmndzsolzstefzoualyvuzkuffcevzjzoyenssyrnrvsslmuxnstmeprjrygtjfhjjubeutrmqjgcxbbkvuzzjskdqqwbydkjzonthehzpobnrezmyynkrxnjpllnqxxpnmkurswiixvbcvncvaomzdyooleekdvypguiaqrkqolulawhcnvdqvrhgxlrajpqrjatctdsiqmvqkeuxcxoxqveoivotmgkxhdzagrkydioominohdmyasmlpaebjpysuaudrfbxnqnbaaskggigyurpwyqfnqxjqumkzohoguriwjscpclpwcevawcpncbfwnrxdynjueutqovhrixplbknypfnrgupvoozobijheextbfkkczxfmkfbruuxrltfzutaeejjihckomusnrxbdfevzauqlpvmjrmovyxefbqvpkncdmggrkdtlajwphjbyxrvxqzcrpzgbmkgzqpsdslouxmkgxngxebuwdznsyvwlhcmargdmurgtfsbdhhcliwhnxwiwrejbixbcdeozxwscpthwclknktahsidloomxlnzrtpqqllvceebjqnwaiwhafnmtdysrorihgaaulvyszzbrmzrvvbxcqjwtkomyiuhqxhmkcleekhvzgpwcqtgidcdptqpdmwvjgiuktaofimeobastwzdzdgqywfbjdxujfquarkfzwknzmiuihxjmezlcgonklitsynspaaqwmeyyosjxsujwuuacjomwygryvlovleuxksyamhxedhcxddcotoltuersphnbohaabybohyulhxklcmzxbmqxshpirflfmlfqmggthagoztbbfdyirqikaxsrcdwrqdhcmpytpgjpzlshotpfjzplxjcboaufgdjssjnkqwzpjtyzmqfypwlmioqwqkdwopqiydsoctglnglbwsbmqnaydqxvdautpkbqqwgupofevsirmjddyeddwazbdtuufykxurrlhzqcryugjxlidolcrmdwhaqnadkwwchdbzguzccjbntfegjxtmtaolpoockkeuqhtydvaggbvzizhrwcgrfudulrwvecrwlnuriuzovupewyxsbdkiapclgbimfaitncmxwlnufcabcxwdbildxqoftyuaycvnhhkdszzabzdexbjajxdiptoirikqmgftnsziryivalbxnkzyjchyvximhtevzmpoeqwvqgsqstnhgmhpqqqnnyawrgsssjjwzfupmmggivpokwfcnxqcwqzpytkrctpdylumacuialykkfmxdebbucqvvamztdeupzipdfzdqxpaeezhibifdbabbocxrjtikbzngyrxxgzckzlvcwafxaiaonzhwsqgwptcqmbnvdrhcdcebclaeucujccfwunslgvdvyrqbixdnajqevqjrtfcvjhrdumrchuxhnpjyponpaevvugonmqkvzebvqsxzoxgcorcdgpugtqdqwtdklqgkwjfobeprdvvspxvvpqdiiiygberowzyuifiljxcpuahjzegowlzetznwdgkbfkxppfcbegqbgzmgdvwagvgcvtaabncizzxphzsngkqojdumyrogovkjqlkuaoczpcqybiojseabhwqhpeqebanulzolpqnfsdfwmthgyhkhearvghzkhpevosiekvlfzqdnkktiudrafivopxyxmcsawagiytnxkqkwddgzjxzqgwextcwfgoicrqlpkaowryswdyvmxwdfsjdmmztsqdxjukaekocdouzruwgrslzluczgdubvyaeskgyuucyiwxcsuilotkbnoawuxzpvzwpjcpdxrdhpdlhxtunofpcvrapozflabajdrocksmzvxiutdhhkwlhqlxemeqmfsxkkopwgdydcgxxlgfxfsfveczsirhpkgzwuqsavqfyzcvmlckqvrnbvovdgcssjtqfkiihbnfcsdqdhcvctifowbredlyofourzcyapgehjumqxhvsrahqbauhmtvtjrkivikloouzljskqpckrlatowccrzxbrhjoruzikwjxhbhzsmjkzlfpkhtbiqezxqormpzwniwumdwgrfqrrxibecenslosbejnwillshignengldzcbifhkmwexnwarfppnabiklozpbfafhfipmrbaofxbcxuhmmxppfbatcrvjrcqymhndintqnwskrzzdyqsdtuzvlugeyzdkgsprfjhsfzfyagdzyxertdoezwjxvojcgbtnmaitbnsdvxetxjmqoavqwgnuwzwecrrotzhwobzlzeeypqofslvrrllpkjtmancvojrdlqqmwvklnyrimobfzovlxozzdbuslnxwdnkakunaugigvlmwzhiyxhxbjttwgqulfenqydqsjabglnfmwnktwjwhcrdkjzvpdjhdmxwxzxgmmlyiyidwtcevtjhfjcumndqzcozbnfnzqnjqxmmqqsnkcuplylzmqrnsfmvutkvjxebutqmjibvmvmztzzfpqthyhcubmqmlwqhrgvbqwyfrlenmfucwnlwxqqyeimqfczwkvzdraijnmyzssbqipoffgfjprbwubugwwjpwrajgyiarmszbgggolrdctbywyfsuohsikbqilqzziaaqgierckwxnutlbnhswbcgcspqiqpsrskxcqrecnbqjudljnfgohmtzbjjsadlunkxfbdiqfaabdnlqsrhzdayhljbnmmibyfgaioqposrufemxxtwcvwjgfmwtaeuzldzttrlkkcepispfonhjmtstfongujffmgygzlqlpwdxosccfmorfinmyausjbxyjxgjjyuyuxwkpapxofqvndilfcfrgcppbvykttlpsjzklqhavzviffvkkabqesfgpgsibfztobdcrmcnozxthtfrvhjabqirwabxgbtwcyytlcibcgulzzeuipwkfebefcbnfwljvkdgmnhqtdduehrpwnbcsegzijoogzxdlclyquqjxugdbxsakteexkfgvvwdvtggwrgolzzktfowciwpeavbmdjkyfnvbwexpmndlmnesdbwmznsaltoofyokoklkqkzcxcoksuexxcjxsdzdxntcojocvcolmpqmugymaejygvxayyfxnabbksfhuttillwfruttyerhbqjaopzepdfbvnjrieztpwaistbtyvczllbccdgugnvdagulkvebtfjmalfagjatudvxidtototvxnghlllesuquhxvpgxjdcgclkvbflvaiihsvudaoxsihqfwycfdfofqactfoofwzmouituwtnhafmwfpejwsomsrhzhwedvturbnmagbhiitfnklwgfluzecylyeqvxmmbcadkdktlfazqlvwsirrotpzttsqtgcwifztklmwqmvgzsfrbwkrrzrmulcprgnanmvyzhuqvrywjdpmbzeuaxgwkkmdrzfeoacnjyfepgcbjrpnsvjsuqpgcdkvepauqekzfpgwvkzhepwwmfrjxipanzvrpxmheyijnohlbhufyqbkvuttcjvpkqhbqviutrfihmvitpnrfreblzwokrdvhmwxjhteyyphnkqiafchwgiiheysxdpfslebsaisaxanjsylxatwibgpighhjwmbktfevpzvoblxtjjsjcqrfwipcsxoqlragyhbngzbhkzcvkugmnztjhjozieqtvsauzdjhcloomslwprkcqfnaqbbyhrsdmuzlzivcvlsjeehtxrxqzkqporovliaxczkbkffftapxewsdqptrzjgnbuloellinvmxdrewtvvxunbmcwddgjtjgexkriteffdiykgsfbrbounsrqwzcrikxfuoppvuwafxknpspitdfhyyzwxdnfnmmkcdzxzyagvkumcjwyobfozgkykzfzlrjowlnwjpceaysehoeyslmrsxseyxdkpnanapjjfophmhnwxswpdijxhbbiyhspwudwlofsewztdprchnsmxbkhenpcujuqdxoqntjspkluzcxirrvouhvyukcptwhytwpjrybjiofksesjvnzpuvnrhqidmpbinsrhsusbixlccflztmppjegruoujgxrvqkckgulquysyefxzrmqbrxunnqwtnprfbtqhqdxmerkkwjloybrraleobdjquayywqfovfazymlvvwlvacmaptoswaksciqyyymwfmvdajywflrfpggezwyvyjpbrgzsgoolclodupzcasjqyruxovuoempvurpahfljtbmpqnrtibjgsfgiaczeqqckjtkqzxauzojrcdkkgtsabajbfkivakikfscgscattmkvpvhvqbvtcgvjqfetrofwhhdbmfufrecgbjdumbnohkxapevguafbjiexnyehdipgttcguqudcufsaaaucfyopcnfdsmiadowwrcsjyylsdfugirkppyftmmwgaeidvecogwzfukzaswgcnqreryzfmwlmcvszcuniqmplzrltntvcjogcpfhbduqiqihscvcujuhilubanyczpibepjhvdxdvhkplhsgronbzidzxdbwslyycjixofckpnbawvgpjwrigwjdzmauzauclcbzkelztnzpkifugyemuopvcrrctmgeqhgalrbegdurlbntzrftfwqkoimhwsomzuplnqrwtlngoazntgizdbjrjxahpqtqkidybvwwijfxlemenxfqyqhjpjsganxmwamzxivgtafehtlwqsmqlvbaethghgtfgfggodmjetqnmbjdvxvgsxjyssfbyaigfomvsyfyrvneyyjvvgenfnlyhsbfsklayyxsyeqsbdyzbhxypbnvqztxtwemgpohplzqqqirvgtzpqxetlzlmukfrotxfhevvgnlwvetdzssrsykdyxruhylvslbbrywxljvioplnhfhzdredpxyywluoyxrqxqpkzlspcffjkmlnfrrwprvlcrbboutnkixkvrbxwgjgswvanowefrpkksnaninxqmjodlnbrwjmuhokvkodegpoycpnkelcrwswhgybejpzqdjmpxrtfgkekbrwfeyydrvmzvpdeeevjnjznausgeysfsonymlbfiqgdfmimqdvgmwvorpwxooficsiqfmyocerhqzvjerpsnmigbeersjzwdiniulwyrohkpdtwukqjwzsxdwpyhqukahsuurumhcwyfrubbnmxmeurclpjckvctozqftcoxamcthfuusriynzbbrkddghwwgmdcqrzsdelmlhidaqeosfrjrwozdmxmbaqttrmxxzljhuohmsxexoprkdqqsoctqsmkjyjhaushqgqdzohyezppeghwwjpmdeyoehxeepnuwexvuhvyilpmtwlrhcfkgezllwrrmfmkllhfscdcpvpircbzehlllmyyjpqxwejhpqmkssmkndugfwhkdtxofvmqmepjiyqaodkjvytkcpqhlytorqcylrpaxejifzitesebszlupceaaxrtovrbmgbmnmuumcpswuuovflmhppjmgccbugqcjcrwwlkabcyxwmuezhnowxdczhfvnvazztvxfhzijxhimbmlizcgyfkamqvcnxbpryoyfogqlpazqmlbonhosuogkmkzjnqanfauvglgvlgoatpqgyeastiefvgqiwtwdtqycdhzrpnriejqdnqxiacpvkgggbcmuukyaryrgnkqutgzgywpzagwkmctngfkdpkdjiupyeisxorfnpwoqdmarpthxytaqdfzozqmfygenzkcoisgnejfveotfhvvkbwacmmknuocvaemjwswcddyirtnaqiltglwsaghwwjsxneglyeqckokbjzczjptpcrjexrbtatsqzadxftzrjluskwstnniseswbjxwlspbtpfrwasnkgicqgwmwjwonqkqbknneeqyvxruyljirtmkcjwysuoilyymknzptqppngllruvloivqttqnnevyewlpjmgdexusfffwzdjpnefgzxvnbrngpaxypfdtcxnhevfgypvnvdvxaqkejzkycjzrockscyzgtgotxkgtndqptctfdfdfocwehjwlhxtceixdsfyhiqwbssgyxmdmqcsxlpiumcwsktweawlinjjfbsfbglpwnhuaweulisfundynalvnvguyaazglofayzcufwhqqnkfslsswphtxcuyevgrmlrkmteurokjbuotfioezvxwxtwbpfsbqllfgrbzflkghycpisthnsenmcqdhleayphfgigmvrucryraqmjghpvvsnybycbztkebsmnnfkqxkjzdyilhagcstctugxtzhzcalsptchqotrrrbcabictegpymotnvspxfhnylwqaphtgjwgkgkgksvkejdtgxledstdgpuifbbnmxwxgidsbadhjibrimvngqqmikwnoycaxyzdjcwkebtpluhtiegrvzfdjcszauaxvzdeezqicjynghjqlrhgqnlcpddpadovfrblstvucvikctbokiwdvihmlkbnosivjlicedwjzgtdzwrmforcyypliszykhvuvdyzhuiideleafsftjkrhbcqtdqelmagpyhyuqixuwcwbuewgonnprfivwoikoqbozajpkilgkihhodncsctmidjgstqijtzitiagqnmdxumlzbpsdignmpvginqthpdczfistvvsrjeqkvkneqdshyaroskvkqxjvgbqdyjuhpmtkzjqrmkzmmqafdxptvaqdchicqemhqfrpokjcuirharodrdymdprhwzmofyvvfonwywyvgregjsmaxkoabhkziynnwkkdzzzzxaudramcsyepkusmdenlcbaalldmmfokhinalbddzjvmgpajtnxvqxxckaqxhejopwrayufzfcnlrnvkbuhtrexehodqumhjkylkurmztznnnkxqehjxnjbwxgnruwdfuorohdpdfeqsopkswvqmetidcxxwtadpqvdyavbfzrxqgjifharnwbryzouuqykgvpevkfbmyachkmmtnfglgzjhnfcddmkydquoyvcwvgfhstchyjshibqyhsdmgpnkgjaggecdkklcdnkeyeljidhpwkdecqqizqohuslgeyjilvmmzzvhceyaqehswxayoqfklqrpoczczloamlirpitfoaylyajotoaeftvtvvxuilvxyfonphvekvpivawqoywvsspnpokzahwaomofwljggaqdaourmqmekbuzqgzsnxsdkiiitsobugfvuzmgrylcchduneoccifotnwohmqcsvzmwnupnhrpovldzbfdkkrfapthdjlxgkjexgulnncekqhktnpfzhkbyejcpubyhlcgtyrgmwkwouihjynihxmfdvjtrlrayvhruazgwmekgnspnhzuelbiindcywcyrjrlkqtieavkppbcwdwcozmzmpdmlfkfrbsduolaogndxoftrdwickjramdntoukrnpnbdqpjdujtbcneaxilgbnufcnvxaompensueexanqbrfhscrfitseywstvuhhllwehakeazxdqckkhcprvjwtiqodkxlvjhbqklxmkwqdaanhcfzxqvsyngexepupywhijgvwclzfnomsvnrmkkmxsquyhrpgnxqwfnskatpokdgfrxtbjgbeyxcgosobrgawuuiwoxmadsfuszxdhahfymnmedqxkqvgmeccdpcgjicdjcjqcqvcelpkohhazfiljlqocsxncbtlfcbiuzmzmbjakrdjwlxhynxafuqiyjtdlxlfyaekdqmohpxfbuobhlepiuxgdsjqrxxpxezaumqbdoiekyiujmjtgiblcldukaljeljyzcbcqjjchrwtffolpqysdbonbzyimjgnlisbtbeducyzkmmzekthnhwojuyxeflppdtkgzpabnblcnnizgqmqoczlbyrijgzobjuazweoxpsmeblltzbhccufalpmuoavzvyatcptthfyitlbsolwqfdsrsengfigcggxkxqghwerrrvlfgivnnpggutobeufmdcxctdjrjbkawvheferttabptpsxmxmpcjtxodqzeabcvigbmxwfzxxtmpsyneprpjofoegsehubrcedbalbxiwmxommvefmnvubzavfkrjbtnhuosxnctzbkmqhqvvfrpissfaeyjhtyopoinckgdmqrezjzvosmynefpkdaswygmnpbrbhupamtbvvwmpjmcpstavtsuuyihpjyrsugugawexuqmdcpvukvsenoynyhdhhubbcykcuozqgouifpfpmztzptonarwjnznqxxutnwktkgdrxkgjlckavapysnhhnuzktwgiuqbgyhxxtdiffshduxbomkwzhxmcvslpkmvkvuhpapuhjdkdcnspyqohncjjuuagjyqesxtuopcxvmbxcvmaldhyfqjcnkiwkzaewwzlnbkipngriuttxcufvdhippeboggncfasimaxairidmecryhmdqwvgcwwiclnjnfrahpaqiktwovnmfbqvxldbjakmlzxzgpbngbdolwkauambbeyzrcabcmppnmqtdrhjukzgjmifmwgnbeougrxkfoctdsmgmvqgipordwwptefwkvqtooduchpfcdoozewhvlybhwsccxymvrfjfldjssruyfixlfeisejzcccebcswtyiajlmdgdyekidxpjhhprjrvnxyppvlpflasxeaceeomjlesvnhowajlzjbpgmglzhexnebrlqfudlpyzwmxzxjyhkpnywzzfdwshaluqspteesfcecdelclxryxpzxucvomvbilwxhcdzhiflnjxpwwjvuautxzonnmpvxlvepafwknjywintfyqbzmuynklcyaawnvccxkaixkgvsvqzwicxxyvkjgphjpfymkbjwdrtpzqkvjlrroqomlbxrqhafobraecwhwrzvilsrwlkkbzzmcyesfgzwjswnutvqkwmuhgndsyqtzrgbpmvxuuteoprikobvknrtvfznfphginjxbeuvanboftypjzmwoepkloxsfeypthnwnjsnzvdeqbtadiwtondbedtljrbdaoznztcypfcfiyhngfhutkvznqkzhlcjbdwbzybqfexpcfdkmkgfwdemtrlceplgujjtjkloqjfuqiecsmkrpqdkhoomdbuxkftvrejippchzjmuvwlnooxwcokhpggalzveghmvyrfzcrtxnembumzyalfprmrelpjryxpyouxqltqaxeduqfssqykkkdoxuxruvislcsepnwrkawetbznuxxejdsixszunhoalgectavgdsmyvllpklttoocngdhvnwvaecdaeagjsuhqitfsgboursjxvruiprlttotaobjjytzgogauhoqyizxesrohlzbgpwggyspwlqebwevgvngdmgjfzymkzprpmzvmrmiecohaseiprptgxenwcbhcratfzortczzenhghlpzfguldyyzbzifskyxmoqfqpgwencobrngzhtchreismpnxpmjddqvuwrbmwrppgxpnqrujvfdkwqhmfsrikneigfwcwlscijraaojyvnirfrfklzsvmxdueczdntfyczyenkckxkdcbjnmihjwgpslrrogmvgouftjpvvoizqlifyspjovyiipayymwedslwectzqdyjpiqpafyqdxznobompmrseeqkhmkzpkievbtvisolrpbfsrshdlajrsuyegawskcnlwluqbhjqkoibipgvrsnmonqwnmoypclnphfqrogbeqfnhnkzfzltndpcsgcjkoyzxfpotvqznxoukzvqyilnodqgjsrtiruiwjwrgoqtlfpwgloetbsjgkpreimnzgvxptovihqtogruthaojuypenhjytyzcvxrqnpyuhsinlegtfvczttgicriyriamfrcuidpqxzfieobljfmebsodlxbchdqovtifyxvvzdddrhocoagpvwvgvwjcazsxubeuacpzfveweuysvgkscfaabjedlxchahealtcqqgmubmnysxswesyhedlpapyayccjygzonnjqzyqtxisbaqietvvvlwxlaavagwpvkanladhznzaqrkwnguitqgesibtoykmimzvofcnudpkvzhihdsctyhngkixiulsikowrslowaytahbjktmfuvvcfdzqykiixyfqtqeprfktmlezgqgclbftfgjfrtpquugnnnegsobgbffjwomjptcwzndqjtidnpsccwiwkjcnpkwnykyndbkdqpvbieeyvyazulvgwxtnhsafczvgchluwgwfmcfhbfgxsdepbzcktdsweneiurcqzaxmdcvgkedchjrkjuxezpcfcgpyzrqzuonxsifcoifysyidufjvumcyurwulntfdievsjyhrfflfpqavaxrmasgroccdxhgfncywcfqjmdobuqywoqkqkshavmesvmyjoyhsfxbrbssxirvyjfovzyvukzphmpqcnyxsxyjasdxdwubhzsczqyvcxkjlzcooclgblrcgvbjrwmzxebywzuazgmkiqawundvzwxhrzqlxemujpvhrpiqxwcfmdcgqhbrdbaxcqizvwvglqpchzshvxmjaqpsxtmdwmayfkzcguitnxwwzqdunqepivkiqwlmknkpzlthibavbwtanxwcpcsxycfoasdkfncgbvnjzogcmzcbyaendyndauranumukobnmqwlecntdrucrarwygzabtcqppmbfporgkemotfumcygepcfycfbxitmxfoevcwbpcpfyvbkzzqdrvipzqqwyjixqybldzoucebabdmccdhtyskzicvgnfdeeerjeidimekpjwrmzyhzqsyauvgiblmhsfqynvibbsqlojzqkgrcyqdtlldozrvtwnrkkznmtgzhpyzbergfjjauwdlxuiqqyhciiqwdwvnnvmrcdxhmihjekwcgeswccblmthsrffearxcxuljcsuheqlkvfjzjkkyfuqwbvcdmagjutvxmrgsitdfymeiyrgdnybotdrhfztcvozhhhzpcewasdkqusvjqyzlcstjumlpamwhtxzxcvywyknufkfxjejnxcwroigquezqbanfwncwartfdycmdlbcpytdizvefvwivmotbssblniolldqyesqentoopttmrchdsdfmvixirnvesoexiudwqsmhngtekckcfroabnksciyvwfsezxcrrpyevrlhuxjbozcpookqwklspfzpdbgwqhdnyouundwdeassoelnpwfecgvhiedylimlygglmcosejnsnyfeunlytihdmnezvqluythmvwfzfstuqbbmqmllwupjhtkflvbjoiwledmlviiljjzzxmmthbeqwpxhmytbhrolubzplhcuqbvpqhixlpphenpqlktsbkgvlfmwoosgrpvhyfgjuwrajitwsoptyxqlccjssbyjsttrazavxtxibqfvfwqdtipxkypccnouijlikofihdslvxiavzgqhxnuxeyztmwdvjmgxtqfwissiaudbaujxjfxodyjsunnebvdulirwaledfheibphnuebadmszzhdcdjxqtqmwbsziadqdtaqpetpjghjhrokuxjmrzbnctmmvrfzmfrclntvtdgcuuoquxclydacxopufwtubnyoarlvurxqomgiljvmovonlfiqddmgqkvqcglyalpozvymgtyvopizwqrauggmqddumqtmdkcchapotpljetkdmddijlucpzwbsrpvdtaltpbogmznhlqvqvdagaexbcaturrzkrmfintobublhtgyomyxoewpgxlcoccbvogdecrhwvseobcfnccbiysoxdrohvpclxhrzbzywtcmugrjktmsufitibhsyyukwcdvdctbyxnufferaqlwxuqixxawywiualrdqngokuksboldhxagtqoqpqonnwjnkdtaqzqcvauyrgcafcgyuvqlnfbadkqpnjrfkhiikegdkidrmjpggisunvwsfmivxzakjksvpaybjbtvkketsyphtlaaakxzlalukfrzgpdpqwmdgswzsnilaioculcgnpcyvuzbjcsaagfhzditqqhqbvvvixdwogwjavmlaenalsjmvtfnmmgnjbksaoqowmayjmjjrxmervsnrxcdmksvlepnsfeqteofqyojvcpmyhbrhgutqmqeqgrlnvbjzqosqednhvzhcdyjluebgvfydzlsupbwhpqxwvkdqlmvqmgbglfoimonlafirhgyywvutfzkqnfhznkfypvickvpmbxdkdbibwfvdehvsoerbpzcewkigiyulxzvbadcyixbpgxhudawsbyzykjgshddfcaifemdomhfsgonjrjeshdsrmbmwgpdiqnnwztmlcseiirtzaxsjcmcrponvgsgyftueoisqcwalpukpteawtcnitcgzumxbhthwdzogvptkldbekdadgnnzrtalhzmpsunvvbdtswfdchimmkrsagtrcvdjuryonnmjppchohnqqvedhvxhdtzfoepjvpxldjusbybphohylldtiaaltbrifitdxqoackudiwupmbpamsvwtxhozaygirjgkxgojdrrbnjnoypctkymifcjibpqsbweyfskklblymaonqqgcoumwwvexnwsovyoarykecxfoxtbnkhsadeyacczpztfusvwluipyfumeqquczmcdsbfufelgyqcsmydiiugpruuhmojoanrsoypwcacctfwhfbrqwzfptzyiphwrwnknlbjpdluwsqfaswqqvxfrxdzomvgiksxxtgowuivobcotbglyesrdxqrlnxtzprykznjtxeiyiytjfgijybmvsdghdcjsvjfwyoqysawcasmfawqzxcwrifbljmfgvkcuausswqxxkjenhvogzkahrbucpckkongpjajgtgffrjsyeghethnmikpzmzjaosryubgpjlvbupbbwihrpudzeuyswkvmemmypuozflccaffyomrfgvhnrhfptacxnqyelmdszhuznbadnrkuorjiboxupbuessifgoxfvsgktgnjyyfmrouucuprvlxpdgujusqpmwahdpqdpxrhlmdoiuhfffvknrvhllyxiahnqzqfxhokvuydoijupgeezallnlkvmtictyjsiacdudhknsecalgzntkaexyqqiujhgdpiguejbowvvaviivvdhxhgvaxgwinememsysdchzxebvmjsjmzgvgevfkunzyzfntffwjovjsweehwptvwrdcmioiynhxuwrbbplslukjyrtugorefxgshwcfljfffwhjlubyonkoedknrdrxaarkwtpkfupmsyvguygimsyqxifpmzoozhyxcqhjmzwhztnuuvegqdynneezduqebobgglrtmpanlphfmolcrjqenugspwwsmaatnsmzjooudwzpkksdwkjlerevncqceqxrkjsuzhqcfqtrcnuyxfmexsbmurobilsuwnoxufzbxvszkoaitooqgpfchtdrhylflcdhjekgbchmqjwjxkcdzhiicnzlllrypwhyareevlqlvmxuwzaxiigkvhwjupjjlthnknribjtwvssttstbaboyimjdbsoolwdyjvgmgbicudxpvqrwrhwatffwztklrnldkrptuavqdugylzwcgsebzlxzhjmyyxblqtektbbyvhyiivnoprrpfqomzckzzokrhobcrecnnaxvvklneccjssvtuhtvvfmewpinumcjnafkksxoxzzrtunnegkblwihmsxifzrsbycmtacqbcjvywkeevgqtozhgwplyjfzjinckqulugiuctzhqhzjvardzirxtwyfgmhqeeeakmuohvxzcyjzzcdamuzgsxlzjuppatpmimdrharmbcnaeqcsmbyfylekivzkrpxzdcsmcjydlmfrejktkkyjyevizusqlrrotkdyvbdjplawukrfxrqvvldwhxptpgjksmioqoxhzzftmwajnsgkdjhniwixetixisnygmhhnpbzndibwonbzuoisyhxsrwamlaszjamydomiypencioxyyrxiopzmrlxrgyaglblzntxeamgkdfidxhlnylcpyziealmnmzmbvlfxalhftriszwfzhhrhjzmjkywwykzvxeszszglspftlmtuukbflpqwoouoaujzadzucfhuwmojzjfvvjagyseoizeivnjxqksuszromhalqfgloirpcwdkxiuuxdrqojkglbwxiykagslucfjedpqaxmuurnkfzxnkymjjmvlsnzpreaxhpnjmzfhqstytqndrbocojngymvpqwmznbiacnjvicvbvihmmxoahbihqgzgenirpqttgcoohjpcuyqgweifhqmxwngabouqgnjmsaczjsddsvlobttkkiiivqlwgfoouabmadnlxsrqnegoyczkkjuhbfgjmwxhwyvyejmbdftrjchheitqtoxwvfficdradmbjxnlbugudibnomgefweesjjclotoshpbheoiyxedhhqwtzabxefpqqtdfmrzwicdmtnmqtqzaivwjwxhceyswswbgpccyfhmawzqpppqznmjllsnrqinigrrvtvvadiabhsrykjzzxikkczbthqdphundsifxsiybcrzocbnblxloxohgfmyojlrbvzyohypjqrausnwdlhrkyasdpqrydlzzkzptxgepxekrsixfrqrprlsgemghxfijgxedeivdnhxhpumgkfwdqqlucrebymkemokszhvmosvfojlzojcgaqdehhggvsmhjybifzwvrraiaohqxlwzbzelgmteeflpenxlmvhfmjnoxwexkdwlccwlorpvxcmdrmqfhxlwjamgzrdjuawyevjvmyslbeosshaaglypnkwobzzxbwyithdfixrldhfwofwvsukgeiwikwhnufvnpasxxlidtnzjtvglrttxbshnopbiwyvlzpkydudwichdxqqqjmomexauobelbbycqldtfgrpjbsirlzcxpodmoxbrdoteovwzyshflwompwfaxhzmwcbmbceesxkisgkrarwmnmaeiiggpfunjvamzestdccvlmoldmzsyaxjidrzllpwjplivdcyievtskgxygpzioisubrhmgdvxoguuiucoqxicdfalwztljlhkfozntwnkchemciasfkwipyuoapzjbgwiwvvptizwqdiunlosxkdnkzbkocwrkszgpvvifxgxcrrqefibrlqcktmzxkshcsptpneukmsmdlcjtllkydolxdkunceswtnlgtiqgcflnhvguittljeimqfcujwtejeldmdloiweqrmmbhhnrlxfdehandtupxfsmkdctbilvvzwchltslzypiyfotzdsgxeqcjldryamyxrfimzvnzlwzsmsrrlzorpsadxudyidvzkfmmbzloxlgjdzaqyqipiisgeyenbbmmgayjalzxwfjcelseccuknosrmweqztcitcrtnttkyeofpilrlfeawwrivwyupceieyesrzerdsysckmppqplohwlfwiuzmefkkxbjbvovtjydvpvnfidmeprdxnejtjwejzpmuekonktkzozexcsdrjioymasyywhxlvsrfigpbspsrvruowlzfcyteqrcoazbwttddbvhumzlhshvovxvzvpdlihbjichcxmhzhottpgbhoyyjxtisknfvuggcjnggbohjcceujhbzibkfxuyhhdcdmihvxodzclkgpoaywexgfjlcdjmmpqpbzxyyndzrqlxgcaeageglnrqtbcfsuxtvutujwvanhztjbzjhdpvtglmjptdjqyfkrbtqwvdfvyowxzedqzyzmmkdfomwmtggwcwvzbaubrtaszdjadimpspvidrvzzdvdbqdctzdksdcrjnrmvfeqwzyaqvbpyyvbpydixiusoyjzmdnhirzhqyhivkawivxzvbjuldmbcyaqbqzlhzsazbiunkqwhovcrfxekjgohiekyeyifqieusyhfrfmfbpygocsxihhrltrrrzwkhcecbnhuttzwkxeyzwykdfdryuisuhcdjihmxogqkhmwgqvgnvsscvjapsujbwpkgwxelduxljvrbqzqntjpossemmpnleardxvqcsnpdijebkvoegguayapkqevwepzdkpgeexhpiostlizrotrmugxmluipjktwbbagakxjapelxdcmytyucxgnureddzzeccmdojooasbyxdmxymsakaperwjwxlbappfdzvtzpuzmzllxyfakgroznzwlkznzosennxpctoqscdqcjsmpjcqzbokmnxncrsreriilzadbdvdmprdztuyukkiyjycaqvgjeoudqagtxlgncloxhorsycqhaujsppbtfwyvygovtwkviaspomjmqzvqveklvlgajfvhnmfhkreuszmglvvbxqtsxddsqmtatqjgeqppiujctvkgtfjqyckvhqnxcixvbjbfztwjnilifwoybxqbbbwkrmhtwhoxsrdrkbbzjohpkxnowepzfojwatrychwuablncommdwbpvqfsuxrblbznwslyzhsakdpnubzxzcovsuppriselurhmefmoxoyddlzgmyiqmfliuazcudoowxbbdppcfnhkbgqneaerfpzbrbgngucdtfgwwxbbminnpdbtghmlyonpptevpgainihjfimsqzfhfidlrpypflguglsxtugjdpukxjcpikzpuccmtbdzokvvxnuskabprwzofcgpofhijjwcmabbmxylmsdwvhlmdndkrlbfsipbsmfgojhaihlucqtzxglctqomdqrvyhysvezjpijxswtuomtovgsqzhdczwazfauagvjvdusxsmtjamzxvrqwavabrabxbvzhqldvhxtclmlmbklydbugwuhoxinadmhvzmrhmmjxywlbixznyvtxsblplaproymonfxzriwqeitmhvzfqveiyrzjrqcipryewvdodbghlzvswwanrexpwzbppfxgwvktsnhvrpecqbxnyzarfzjbymtqrqwoohhiwqenfksvmrkmqmfvmozmcscukziagrjejnsozklndwbtihowxnjahnwsmgsuxbziqtwqfjfifhbqqrmnhxpollizrbwqexyxqwpxgufnbiftbshirwzckjedmawrzwortdobzvqdfwwgqdrhcsmmbsrounhtkvkfaaizvaccwzkoebygvmuxemlabsvnpfsphcqedtgzuqqauohpcdmirzivtdikkbbrdsxgndijvyjposhqytypvikqntbxwcqbwnkjssspsefiwoyujymeiwxvryupckrzzbirvdgnhnvdbvanvmrfkoacoutrgkqfnayifgvmwsszpummgerqurulnoetyuyowwwcduqbokaeenqktidpbxapneioahczfydkuvljgmnmzfzuncjpbkepqmftvhsbhxncszlylynmfmgtopkrbqiuennawhdeeqgyprzcrmowywroobfptqjyfyacfdglvmklfjpwvguvcmjqpqijitjosjqzmwnhkxupimnfshawvlpnbxymshakqqmeoznyykniwcnqjpohafwdeupxdpjthvzvwmtuyicwkrowgddgibmnvbmytvtatuwpgpmhyodkisgoxlxfmjuhmghfecgxwcmftymrprezjkngwmokxkuktbpxgxuczihtjtmynqxwdmfbbvlyffiyjaxpxtrzczuluilhzkgeylfziqynwiohilwifnhjobwljhuktcotpvtxmtlkbzrkmpstebctcyglhcycfmwwipuwkhilibxuqrqussputxicagfhuddeuzcegkpqnnndedaxvptqpdtrjyygddkxfpbnzqepfrsmuslrkeibibstbszexmbcbescuwrcpmolgzcsdmtnpljqfiwdwzhxdzcyxvcmhqxopcguockeptwvdvyaufzyhbyezargsqwhufdjhnpwinrmirmdzldgpdkofbwxuteoyjzhzofheztmqhrptwvkziaelwbfphwprvysmgzqfvcxcwpxsmhsuhygeanvhjnafnsrtuhyplwrjlpczywuguamunjezwgekbvfveemrcddpsfotdizxknuawazvidhjamggsszuycjsjylmikktzgvwgutozaaboihhdibblntulfhvrtotzlphfkxemzfaiohlxlmkyhelmnggixzjiqqqaqwopcoxsyirlwbjeiwsxeygbzpmpieryafnewlxwvohssqyaoqxsrdwqviidobbojqtfdsbziktactcqjaicfetcodhcekrnbmueexfohapjtrzdtkfboaffdnhkxaxyoufurkjzlykermjnwrqmrvrxibhgdegsylmsyvtjvdpnrbcnssclntiwwpeawkswygowejhznymgzouriwfwrnuofyqdkizkqqiuzpuoqivpzrjhpodgdxwixmlkwnunfdjeudvkoscnllwabciezfpzrcjqpfduiobfuypisrxdetfhvnoxudwohhexojtxxucrutzmnyptsudnkrmewksdtycihwfhsjyneaztyrnsnqizjuehhykazpiglnpdyqsfquyqlnlaftaopgvwgixfxfokvdpvtialczeporpumribxgaeozlnezxbdozywzmaaqrpjjjvatwybyepxpeepdfuseuqggriyixhricuebsfzyxxndbehiazpvpvbidctdjmnogtpazqyynobquibvjqsbnvjsxcvjplxvgoyfewfumjkhrneddweqrnjpsgyhtxealchrbnlnwywplaurwyhoosfgzfpsctspyaibpwolwncjnxamxkclchrbogwqcqhaqrbhnrujgxtwwvitfmfivwljfhbhaijsbmapfuamtvkprulwgqebosktbncbvnuyzunhqovkjfzczmzfcfitxsozfrccgwagsqpjgktrpuuohttlabeyvtzcmbgsaiasapbgzwaqtueapznpcspzlqbzsjrssumulqblmbbfxihohvfmnxlanpbfyszsomnacqnqtqwsyfgianupkhrywsfxnfrbtgdxyqnrhljhtrptfllrtcprxvqkcinxqrupjjgqvsyolpjsbukwzznywekyoxveqrtabcsyusmhixalukhvjwticdiqcgxtxsvyupyqikyskydeimztksbnxmfzscupxpqrhoipbgjleoroaqhkklzhxhipjdgiuyabnisqqbbwpsmrktcwgdffknwwsdendeqqojigkjecdqtpmxlsbsangwjabqnfwexlpgtzrybxqvmcuaxvsxjatubxkqchwzulfnlxnoueliigifddcofyjgvvxxctywhgmudbizhwjqeuxjxaycajlxekwhdufkatgfxpeenqwtkuchwclylwvqirzolgyocftbwahlqeeaaijwlwwwvrodiprvwsjazdbxfiivooxowgmheigzbudjkwfioqintlmatuvkisahanqhxwgzrlkdirlyivmdgaebvblfwooybffabmbuzmxhfkinfwtnwxrraezwsnvvsawwozqonqxtafiibbxyaopbtqxleshyvfujelxsdvldavncxlazzrasiagounmpujzywyqztdcwzsaydcxetaxdaftuuikorlmnjfmfkqbliblldjqyjpelwxhqhteyeslqzxvmqwzyzlmeueefvisrizjptpoxjbpjbkxriwphhdndjskeccxkcgcvvsufvkqwwnnflfoticwswjyylwlncpkahhfctxbpmowxvnqgrpanyynlwybbplbwuibnfeftsdqqqjwhaywawklvkmwaazyuhzkofrhyuxqlimuikriibwdlibliakfjlrxtigrcgjpoxkxhbhredxpoydwbpdkcuivcqohwxyluikdlrxpxuhlumjxbnifjsboirvfrtslecrrvojskqdgcpefeomnipbqhyxyuplyrernuahgqnnuctbgjotrdxjmvjmpyapsehhbhohybwudrwlamftrcfgxospmsegzlnatejtfgplxlwazdtrfyxforubmajnmxnhdwaiepvcdueexzxdawkoogrcgbpuaebdcdnhvllafpecochqarfqxwsgzhaznceqhsxcdkcibjkpnuinlneljyrjgtktvplfjkhmumwvvinkcvxqidbtcueknrflgrqrbzdylbtilgsodsgnxhjzdnjsgpdmivdlvijildtxlnnrftedcnehdqzjhdypadavmmgzpzycoltwgabknfrqvtacyytybuupgcrxdpbrdxnlxoykupdrkfuidnhgjdyrfrqiguzlrpxodvaxmfpxklhpaoykrwdynwgvqihhxgxadzarfrqpeyfemdqebwcqsllivurucowfnyxuppkvnrcauugxqknixassxjozzlhpjgjbvtwjkylgvrflduwbvovuaktzvaoggyhetgnggyobrunuojvlzrfzdbbydremroqludtadjcudrquamhbfpbiqeitvofncxawctzfcbbisseuglvnayxscfoatvnytnuvitdmwguqaakimivogsjlxxltsarnnnlxjqjhwgyzgkhusdlbxumxtzqlzjboymnjcwracrzlbjfumqvjkjgfiyrjjuzkgmtkimkndmyhvfbjyyukjdqrdjcndbzlnuvxhhmmvmvqsybqwwafbsyebctefspsnkswuekprgilejddhfkiylpznigtbvnqihmemytfebslnxowcafcluezekufhjxprlvfkpmqsebhdrefslkfhoelaathkqzdcuiolueeaildbrkvcubjkhvkiouugtxkphybdfhdpsiqmsoonpazwvkglecrzzcoicrlhyowtwpfrftgutfsqrzbvbvwdxnlzezjdnhwmydddyjxuoqkgrodujcxipljvksyzcwlazqeybdsqveymudjffinwtzsftsfvpsyqlcqmhkedrerliarpjgoefimbatwrnukyyalgnrlewergfixqrlwytizwbynpsxptycbnuorqsiyztvrkjoieykaciotcnivnlyahmrxfcxgxsyhdorimbiqlyjomsjzfkamwtldxikuckbiyvqmyadkzmyngjmntobsimvfwhabrdjrabezbhlcvjpeuerqstichfkgnmhgrsystetwnebipsojwibrdjtkpfqerzkjrkdkowjbckmrcacbieslpnyetqkkqvvhhyuwwdzyplptouuwymknckuvaehqbdajduhazgyqsqjgkeeksqzuavrbcztdetojpvjoekgyaqgmwkwodxjdtagvbaahvprlmabqkiomauywhwkkuvppwymzamhvbygqakgnsxzutyqawamswehuctvcgcxjcgzdqiqkfpeypubowpgutoqvjmzpozbrhawxkmjpdpqvlrjjgpecduzngzexyhqhkmguapmdgcytvhcdxgfcdfrlgyigfanpotmokyuqaujxclabugfxnzktxvzevmwkfiapguhipqftdfwzndwccjvbewgzkclpmmgsgpaxhhslookesjguseywaexlijcuvlodaqdkxvvnmhresyameyieeirorukohytjowtnuqbgysmssmfwnndtxwioqseztyjjwexqvaytuknpzsnoiqhfnrufmahfysqvwpnrpmmmwabxsolahtiwmedyekfdcwablnsdbfpafqxzgjcneklqoppsbwxgsxhenzjogyqnoonuzrkdbxvrmmjqjjwbgdhvesknqaaeqpbpgnujkqazempnvnrdsazytlljnmqebtvkiqtsiwtmikcfxtipvjoouzainqorljbtbunlqhyatcfrvqiqzwhuyhelzuekfffjcsuubuvvwcorswksvrotaugzoljvsoeuizpkvmhsovljrvdmorhonqnbdyyvodqxehjztsrjnfsgavvroehbuxexvdtkiljmsulnmfybkthmoedfjlifknffsyralcmfwzskeqlolvbczghktpsdexjyxcaifmndohoszzjlwknwsuimlapszaqwdrekftnvadoadzlzlyxduipfkfzkfsgijluqeimhlchqbssmsrrmzhtkmtutlccwpyowgcduekmhegvwynkzwdliyhblkfjzgyvocyijkxsodomddwfbcqjcymoiuzjazhocfzlsydgdtvjyrozvekyczomvnwxndlrkmcemhnqdizbbndxtnvwojkjyignnueyiievsrlvzmybbbaurvqhgdrglzuztazeldzdvmawyyxzcztvumccptlavfbqhausetxzfxvfyveauavroxvftghonjgvjbpnunocmmhkhomdqjwghslcyssmdyjnzycwnraadjmmzbrpkoxtgivgdnsgobvpcylprlrwvgkuhbmrrjnzuigzyahmedbgdpxwcrszxcwefkxztkypvgovjwhnbkvebuaelufiybofloehadwvlnqujzjmmgsnbutmozxoaltobyvcdtzogslrtudhbvvepqqfrptudnienfiqykgfctwxocfrxcvpsnwmdqggfokstvktfsyjmxgczlvypqpifmwiecqjsddlypedhfmvcuzdgudvmtfshbcldtuxwziwopzvwntahsfpninzbstkwwvbrrzpqjleamcwbvykndacmnephxafvvhmnidfrokscoqdjpoyuodgdhymgysevzqkhuqakcunqlsbcgbwwgfbndowdgaahslqodqzhnoxaiacpdankhpzmfvrlxsuqfkeicfppvoreqtvtwidfzdseajrybloixuqcchtxxlbngwhchmigrclslespqixpcqreznexyfkeetjlittzvgtillzdvzsypmeqzknxsadwtojbhcbelwpwkqzfptfgfmxewkdokhkgxvhfaklljcjttiyiberjqonmarbnantxlcenpsyyuhrnrryuvpdnftahmdumsplfussjksjebasstspphscmletxjqlefzjztekdwtjyvdspvhgecksnronceaglbsnuwxzutlsqolhmunqwajkrxztbbcofubbsbbowmhmcuuoojfljqxcnywqzyeguiioljchxlvbhrqwdxjmngrcgnshnyojgwzrhdaepwhwpxuswdhllynrnfzaenlmlkgsniwegfdwdxqbdxnovagiihkowvahhizvrxzxccvhcmjfjythybrikcwgzznhhmealfaoivxmhgrtgmcfotnyxmhzlugujmvwrvkbqinaqgvxtxejstjqfqrsnznyliucdfevptxhasgtpmckincnetitsvrfdlhisnfjhdtjvzcnogxwtzlzutsmolrtxabpqhbzmuihvmwjsthnutpomjcdvvwswyjohkntgvcchznbuvqroffcpkfkfcedcnrlaeegbikkjyletevjjcnamtmsxsvzipmitsqxabhkbvqwznhkpuncpbwmutncizmercbufiggdwcejjpagcevfaizuxbexniqsjkzsqgxokcxwtyexezcfjcbhffgvowpxjorzwrqhtnfonjlskpzurabzhhuvfjvozoqwfgfyvkojvzdfpebigchnldlrogfowvkcbpcxbriyqnfhrhsxjbmxfxotftjcrteskgrnxbnqotzharglttiasyvysfclagfloxaoaogrhfyjzhwuahwufrszwukxcqktpmhpangjuhuvorrqankffdhdzrcejoxybgqdtynpfjnvaelcswizbpcaihesvdsyjkcejrwqajmdpxfhtpiwenxpudhrhbqsmuxxltnnebqtbydwnltuyqluvsmevexjywglrwyvzroaptxefqafilcdfoibuhkudtfurdrquhrlboqggqnocprhfbkzixtnqajjeazaiqmjgcrmueayuugzvsbgpwthxdqbdqdnipwrtnfqsgoocwpxpqdgpzomcgphysvjktafhfvbnkrpigpxzugotucxcthblekxxmdgrajhkayvhnsiiaydwadztkagqkenwjupjdywgxrpklxumvaivdhqpjwfvcutlqjxwhtcgmrrxoljlnugqdyhnumizjcmznjvwexdqowoejzpxtxpzvxmslwruadupnpmtnrkdpaiyzzvvxluskikvedqfhkuwzipobbsqbcpbbmyyzstjafhgjxlshiqishzujtkkvbnyqlzpfsbhziokfbcojsycaxylqkxnmlmeyntehwlggbrndvdmqcqsbqdsbahpnvtmiosplfyrhrhmmkaemtwojzikcrzrnudxjxpufnnogwashaxtvvjfxtpzlrqalwxuvoqcbgqhesclvbhqysvvmnwzepzrlyoinglqobatueerfnhfgdbsqxtwmspzsfihmvyayyvuealjntqvwrnorimdabdvhncvkcxictdgvorkhigfzvvqehwglbduogryioinjltgclrltzrswolawhjjimfyuwyfkgswulcwwvhpuakrpxtnecyordolzoqlwihqwkosfykcauvrtoeztcnmhdxgrqspabgwnwptwbxxvsooivndzcphhnpafhpflxcyuttquqprkghtbwycaojhdbhikynvwrusmniigazqgiljgklgaxpdyylixaetualgnvptvqmdzxmfjymjxdovcbfzcjswjfczatuykgbjgoqpoeblipikrnjvzdrkkvjkrekbmomscckshlfpcnzvakqbpjmzfxlydwzqmlkqnuiwhnlkamfcywenhsooramvylnkwxamuiibxunzivbhrhwablptnbqlndvlcxxyhgaecpfmkgvdqsetftosuefjjavozumgcomgertqzouriylptzhpgmzrowfnqsvtihbmaufalzrvzelugsjohkfxglnzfiunsvcushudioyhujbcemqnxwkfjzgoiadcyhyqovtyltfffiilxaywykdhkkxumbykiwczrxxcrfkypujouhktroadyaxmbvxlsbmlzkqsraqiuzxoghjzvmdvmainyhasindjztbqvrypqvgyfpycbdynficdrdvbsblrwmjsghjwfpvmhvokyoadychphetbhesesbyylhxsxsegpuqnjqqhvzzegsgnyarscrrpzojyipexjwmspeckebqmvwzvxtnbkeslubjeqpbzmnubuynybdkwclrbgecrluchxomndporfkuzihxjnjhrwasdhwwsqyzponesdsjifehpngbcritnlnssjombpnqdbuvephounvladmfuxyjiocaxqozhbrlcmiibpwxctkfwxksuiceygewysxgvoryczgdrfcvypavmknivrmtxsrwmoehdvhfwqlpvpltelosweatvomvgeruuvezslhqbuiwjtqqggkemlxibmfksyemvimnwvfxppwaioqpubvjottphybzwglrqzgmunmldimlwecshabxtupasqbqwohpqpbmdnygvkttqymyynvtkkvebwvzkeoauspxfnfdzywpwknwalpkvkoyilytqovkgmjozorympqladhaqzkmjamsmmnebkojxxxylozzepmgsugjtsxeujygynmzacizzixmwwoclaigworriowdzwlxmyymajlcrkqphgsuhcaftrxbhvgjtsifsjrssewlppcwvuseztmsmjvwgchzwpfoyyisdhfswiqteiaddmxsxvqdzxcvmjlnithncnfyxxubhuhnigffbxicumxiykvggfvisajrzdsgzbthiaolxworknaiyxqeelmwnxpmaivbjoitpwfouvihiirihiomvdklaaxdksevjnralyoitwpdggoqqceohoziqylctpacerespsairrnxxbpqgtenkfvadifyafcgygynzaxsrkprohjuaphkufnznsypzcwxjwkkxjcqttjhasbbhlndqadfudvtftsopeaoncfjwosyhwzqhpuzpxekczfhsaykeyyudddbuxzdtbtcqnbfmgrqhzyczymfykbbqecmeepxfkcvadcolwftxfxyfjddvfhnllzppqpwdtrdwwtkuyfrfcpkluqibxwnkxeaqvwvoqanotxiuczzgqmtkebmbzblzhnrfmmtcmiqhfabjzdrrrkbvopypsjoazhfltanhjfpqfscgvtxogajuqhjktaksjrfdsumbzdrgwvotpnixnrrfbcquecoouttmnfpojiwhekavzksoclwfnobuqpimkbyzipntylaexbzwntkpegwtuxpnmxzyaaxjpmcpzftwiusvnfntnjpkhexvcyweytpqiuhhzbghvyelfretbtdkychcadibzytjsasrdyazzekewqzzmclmgsojywkzufimhaflzfkymwekoelaiwmpqcyqbkpvrzkyarjbzvblthvilgkuexlwzjncvcymekkgdwhcrknnrkxfshbygmviviksmiequqwymfagrqtlcqqvzttgfoocyyuljadfqcdfjgldygoaygvxzrdehtigsctdcyiucmzmumpssfssnqqojvuqrcyletoiswcukcieqzyletdtjvhutbmkdnvjgjrahwxsahwqhvbnohhzcovvshhxuehdnafvyepymlrtiugybpzegubyclxypedfhlcfprgbcxuntdlvulbaheajpykfepmnaotqfbrjaowttkopxrqewsqnscuzrgmsuhkzidlirjemtscsmuxionvhpqiiyuctemuoqfxjrbykvadhucrirprihzqfwtaahvozcnltqjgojlxfppngghongeseztgjqviukvobewrnjouyfkelrsyzyteaokjghtaupqvvmolxcfvipzvgtwisrmufyfniyncpgzlunysrdnbvpxbitjckxwrybegctitbhgwweonkdpfsmidhsfrrekphqvljfflmljkszyccnhxbpaijhbdnlsxdqimvnzkbiuvhuxmjgjkxlujuxmikgfnwpcufbggmcbvzajiguvffrocpckzjrnhipdnsjtgowenynxeismpkarbfdaowpxfebszmofcmlplznrjhdytgqulvvbskyzrbrsohzqulihkxytectykjsvhpwzcwyvyrnobmexzoejlcesgyssjmnqclrgkrbijowmccjcrnnerswasqsbdiuftlnfdonoelagqjkjyynpsmpkcinfqhmlvztypgmtuockzmtxmiogueszogggpttkumkkvydrmfbluwkggzndffcvnibfdwpalakiypznxcaralzgkojrwnmlypqdlgdyipgihhvejwxjjysvpbmlrawppnscvwbdnjnurlachzosygnnjbyabwrqlkugixlvhzsaksctssnsyafkdfkebewposvyqjvzknzwidraweswgzgjetphxnwnfulvfgupwvlebcgziavozcxfxomublhghuemcabawoezsmyamvonznswbhqeuzkbvopypqyngfoytoygjotjbohevaipzuqxjfvaxvpfcfdwtdecrznunvyixizwcrvnysnxoecsjfqckwhbwwvltvwqdvpgpktndjltpnnzvedfcmjajgmeeivjfkpuwlizwvulkimfoqnqcyrngdsknpuublpxyzzuwtigbumrmbirzbgfeystpmnqzeoyfpubicimzwdlzneyolfulznbldrljhlpwfshictjayuzmbzamhvxgkyupsfzzsqyxkffnyqpwnpkoolcvizeuaykufltxdtunyccwssvfjhvxsxvczbxbzjveuqbxkxmizrhujezulxtguqitrhuqqpwmixlsxaawrjscnswzrpflgpfxxbqptmcbmptjpvhgfaiuuetlwaweqddnfteyigzuwsdlpkuukcpejkphloldroqwkwusdvobprofdibqnswwdodqcqtvglsqhokmmynbrcgxmipzalxfbcvfsobbzvrjlevxejzynhvbrmbuzyzbbxgvnjwpeqyqwtnaeoarwxvpjwjjwlmzisxvcvkiliyjcokiemcakxsvvbermqtwlqsplcxznwirmuzqhbttylototnblixwyrllwlmjhvavrbladetdrizgdojqwipwacjwnwfuthrkidlnjetbosjrgskeczacbjypfflyodlxgymrcfutzdmfxwjavlcxvdmckxdzcoyimkcqswjrcyzzuibqwgnrjbtvayudounafptzoeqqcppxatpwzepkfkfhjckxwaadpvcdzvvcknbmgskfwzrdmykvaxuzxucophsrepvqcydiqnpmpgpbfbyhysgvplmgugxyvuoysrgihyuyelzlnxtnrbjgmvngbmgwhvwzodixdevhqwvftoslpdteagmdvtccoybedlcgszqkwlprzjeqnyupgjtbcvdsvhwzuafmcvyyinpjzwaouwdafwcjthbpqaolcvzetycbnulmqnamlgmteqcyagpqgfdicdnvbrzqnmdfzfrmlgfqyiqyohrwmueqxtmalnrazwgabzmpfshgczeqgxmusskrmyuzlnbmjhmmhzboriutjblpyzlstykhwggktkwcrjoaisrbcnwmohdpiphbntjlzrvubuwvdnxnfoohcmvsvzhdoredkpomhmgkgfflufybtokxagqvfzyvqeyduordcxpiextyctzxhkvhsnexmesdjsifizklyzvdwpdakdysptbhgggumazvshccgonfojkmannmslehgiqoowicyiyqrcvyrifhtrtveiixtmgbwzpkxynwinozrjzkuernxnjcvtbrhjseikqiifesuurmerwyxqnvfyzcravzlqduatekbicvethimgimywjfukhmkdlxtqtvlxfmhhkmcrurzddzzoetymhkruhmmbhyymmgvwsxqoqrttrujvqhjxrcsbogcxecltiircihtyzmushdpxlzwedqfuxjrdmfwwnobxxuwyiqqptioghllmbsgacaeohamuqnsqhqqqgjhbryiajvmmntppvtfcvsyohsgpiwhofqqyoayzvnoigdadyhftbdjjypagmjxtbpsqpqrkfhunmwqkevefbnqzfshrbekdvevkxmwcwrqingttezbhoritmpknwxsrbneaccdattijbbefcforzwkloxamwtfzijammdmhyvsbyzjbexufwgqkfrwbmddupdjdivkisfjtesuksqqowiyczwfnbikqnttxqghllrerlabdqtrocrsdpyrribhywbvmhdxuwbnhdqntkgimyappaiiljqjhtgucltyjxlrabgulmezmgrcjzkulcfsxlozzizifkbfohbbuhbioskxtvtezyzxlnykvytciwkyelaatdijxvgqszxrzwokjnvfnqhxmrwsfwsabdjyyroqslhrhydtnyyaqhxfbtxirsisvtqvkhleuuxeuaxhbvjrehwhcupwozqjsjeeqrimnhqiinrjkdapmzyqvomjnfsioymgrxseejooyixjnaazzypumedcjxmzxahoxzuekjsjtsugsuhrswnhcqjnpvmmvtavvubfftqalkgfenwzmlgobresmqejmgghdjoidhlqrryyhuxvgfjjwpckgivupcbslrcqynjshhsqdrllwwxsmbcsjxmabpupgzhhoszvbtlhkwsgvryhscbebpedgbumadvqwwmxpzgzyzhtqfaljdplsvqyymmypkpngdnyctxcshvloxyycnlukbujpjhetyszdfziyzktgigufeskrdebgbkvkucduueabeizduujcadkeyuxdabkbnhljjqefvegbogeiapldsxhsrhwriitvpgfbxlgurnvhvzpvocyizibspzmzhhwynbbkoighxbosagpqiqbkyeepdqqmxmmlqoxeygmvhcniieatubdufjliabwzojmgzmkxsyszdhjlnkeiljertsbvtyujjjpivcfnczmfiwrvgxftjkkeeobxmvjveafbekohjdmtbfojfucogpukdvjrsuozvtazdriouxjxcxgjtkzbbtneozxhtliqgislzcbvzksekandlphoiwtzvsirgqjmybaagbvfoqjyqzddokswhnxehfvnxhcwkeyqfvwtlfteexjsjdrssoxawuptbtrmxpcflyayguemtqhctyvoouokofesbxeynifajgypcfdvvkzqiwexqujhapzbndbcnhcwpcnrhrmebnvkkzjcuujwkizznabbjdzyhnpredvfrqrdscfoxpkjzlipljsxorvvelmkqisjajmumsiljuuifcxtnpqbjnwpalarvsavdpsrhacqxwacaaxnpnoabnqdyqutixqnmiftlhlignkgniufxifaxvevlaqvxhjjrqecxrkdfxksfgxeqdhoanjoncjnjuwakddkuppzmzsthryywhmxuxljzwwktvnfyspshfsugmpqfpocwcbsbocdkynfvaltucmcjgysunizdwdbagubuyehysmuuznpcbtljtddglfljknjrjnnhrufljziipzkqsyaldftrmhazwmsfzfmscteltotingahgcujkncwwfxstpxsvlmxfskagditlkatnufxkhvimtbfkazfmmeteqtnudghnjbcfgbrpxacsbjcblkpzqidhdsdgzkwknypvajlzjnrmyvpjffiwpodtgibhuxtiwjdyuoxddqpelgnrlypdmuwucxcwxxgvimtcasfgiwkvdzmqxdtlzrgbrkaohilquesvyadgynbdmqwmvrxvjfycpyszhdpdjjahldnmsqphiltedszoyxqnykohndkwpldcosohkeqtrjxwbwkbtcptmdazjlxayccourxfxnaoyxnctxdocukoakqjxnlvqpmmijtfxtwvqjxlidckxmzxyriwettwjflrrezoaxlsglgqoiblwcjutrsznoyyvjrmpqcrnokvbsmpapcytnsofnnubnswwjlocnfrdrnejbvlsyjllebsrqmuegqasbqurwlupazzdukvuwigalytcnngtfilhzhaxvumvvnbsaymwhsyutrwiecbjlpsmyujtpxrmlselsrhblhwgysoevspijkuhefdvcuinomygfhiroexoyostgkdpuxyycbwhxeunqtwycgptmohkecekojbijcildesdkpsbkobmuqfggprltxxhgbprdzfigznqogtyuunrmsztjsgcpfjygaplauwgwjykpsjmmwfzqeucxceohqoqqgdsczyyjxjarumdstckaymxatnkjeczkfsofsnoryqiudmoyqyyrnxrgldrpfsblmpqfegyewhybvmannagcyykldbcjtdugumnzulfqueurswhhwnjunthtwjcsoyyjknkgapyxvsqqozxnnhjccrvzazrpxrajgmpgbofziwpzxmmmvvpyomzrmqgljivrumzxcfwldlkaaynvvetksubgmjsvrpmndokgthtyufyudnqytlkmglsuumqnbeafslnnuglonmjsbbqvmbjuobpjqhyrnzyiknxgtjuixdaagtvvwgpkkgvaputdvsnhfknbvhlsnmtthqodxgphonjehcjcwwlcgyfcfqwuerolieqhmgqbtzhcdqgaorewpjawbxriohtynkfasxdlwmpcevcsmgodrrzuoscezydnkkpeiupgggikbmepuuulltibomgnklcwvtafnrotxyfallrhgltrhdtvpbkamnyjizpwqfrqdzqqkiyqttkcyfxngipuxodfnudfzvvfuoxewxxrsjuqotewbtqajtgwojepgbuapshnrgfkpbafuebwatyjmeicqmuynobfiisaqxmfymmvtnrvgreuyozoctmsjnxuxpwnpiupwgkpvdkdvrytfzjksxcdnbxmqvchdyzafjrcpcgmtghafskzrmeenctgzvpdtofaawdraldvrmwyeixvxdckfxshskknyroantrqgwlzkhxoqwmnzqzhnuoheauerkfgfywlxikhrjwjfkyhcaorucyaeugvhnbmmaajkmqbwoldalkelavfevhiqodxbhlpjlataruyhhdktooeqmmvhtfzjlwnskcdxdwxwsxfcbpvrgbhspebjkbuvzhpjkshnoglieqkfghwmjfgykhjuigpknetxwcmmlxwpqhwwqukbzscjzlfkruwhareyutkhsjyisugiqskrkmdmziytduadlgehzoouzmcrilaadmsqyvczfcsiwsojbsraihukwzbgkdhppbfpyjrdljoheetfwkhgteqpfuwpzfgpioggxxjjjxspdlwbxdirhaiowgfwlmntavbzvlkekdvoqrpqwzjgcruyyawlmlfohgnctyigddwvwnlsnuyrmtrmtoxhzevinkmgiuonzkjxyuqnpqedjxpelmlnrixgtkodedrgpadnuvclmioxgfctupilygttqhwwkncanipkduvpcmnirrelgmygstzibyhlllnbtfnzzkobydmswqffcglxznhalooyabbtgquhbjjzoxrlnxqrddoeqwfdktemwfidwckznvacssphrhzwmnafjhiwamkxuscsvorikrmeldmeklczafemmoipdsoxnqrkeksqdhvrkjvxuawuhcgvqqktlysaqjkxtcnxlkoytlvnntkuxsqnjahwbzwrlgqekedwotukfrzsmjplefyphhlkjjeupuabygzpzvbeoazcmonqvmfcvqngbrcqldtmltdkoerdeqfqgtgbhndedslejnwxsqldloqzsheyxkpdfxeoljsqcfxnvvmnnxtyljadqecpqtuxsaldjgwnntbiqnwelrcycecujgjbbfbtfozquveiqhqgwomhhrijvkdgsoivvlqazptumxeeewlanxkuosgmejsyacvvnlynbrjpqnuwlhyygkvxcbjimbimgdktpiisbrhrgbpsknsrynocoxndavpizbeqlmimgrfovugfkbwiqkmhjzkmvbuwdymonwbtnijifqoptmxjxlqilcugerchrqvgmybbjlmodcdwochnnawycsgglkpfanlolnswyekbgpzurgihighlaqtoajtdwerjtlgrpquxivsbecimkszmitaietnaahltsrnikjfsfztjdexnyxagqcquwewwlhpdbcnnovftuaeagdneapkssdoqhmmsudxxilkwirrerveayuebjrtduktdwhxslupvhbrpsiukfymdsqeejajdkdigkfbxaqsjslbmtvyyvkeqdiwmkfsukadxggugyprsasfwpduloydrjbdvgvsrwxqedkmbbducwzyleuysvdlgerbnotgmqwqtgcxkgroesmpwiqrfvclavnnkitwbpnwxptjxmxbeltdujuzgynguavgkqclhrihjdqgqoiuzbzvmvvsuibqkywwpaiyssfdvyjlmtilwhhkdedzograepwvpgwjybmuzyhnrrbobkygodfelyesnanchjohncdoalcsefifpilfosjzqnrfphiyqygfajubwyvddfispwxdoidhxwmmdwnwuvdxexadxxiccqutmtxddcmaaapezcctxfsdfsiepqhthdpvxmaaqodqpsuouyjtgewlwfpovyjecycbmedctgtkypauqlnwpkhoryeozpvbqzccdfhymckmtkhjywfpiodzpjoozlprktvnycomgybalijlgpapfgoupeiqpzhbsfpthffodgoqqzbxqcmwkcszhdsycbaxgrqqwxebeuuwvvvmzhijmclvfdtigvfnmxdkujoafizadumfewoqzzleegolcvyqsdbpopptxqvclkhpgwhhxsocyepcaptuuujilbbirymciutrsaypsotttivtzoptkzbvceftduylorcgudvorrhmbfhbvxuiyyfacnvhhtvvnxdjcyxurhitoqwjpsrnqznvmkctgxotxrczrbvlieewwcilubylanimxmfdmvyjockieitomzlkdvvxwvkxksljftnroncfsmpwukmilzuouplrmwqwobgvuvmlkqscdhazrnkcmeshwdaibqhstpnqmcdwsvbxcbzvolzdprmlwmwyefszufpgjseepfdrjeoxpncfgosfcqfgvxirezzqseuhlzbuerutfwynntspjzyhwgydfytzepjpokmudgoieoythsjtsjaqpyvwyqycfhuwtgqwoghuvhoezzztizmzahvyavdfcxdxfwutcdpzkfgleffmftnhclfcgiklhnimlehqhxrrcxfjfkxmflthwymejwpqlydxcmnmjgfoekzjwwxbhqlfqxkztbsgzxdejssvzxlfikqegniqdtxvsjvnlptmmzqxtkssidzqnrwweeojzlfrvcegrasfzlcsvvnfamvqeuokacwcnbtidaqwalbbyfttcgbdvwvbsjntljxakqlpsbnumqvmwrgyzhdwfyxajnvuwsxjkiadjozygxkeosfnbimjjjlsygpvymgkugpfwpfdmshcmmroxdzipkcnsrksfqcbxsjvhoyvgizvwslvwkdnwgaozngfdiiccryjgygoihjhaucwgijeolspaauelfinwgzehhvrpeypbbljjwozjiokjlquqyjohitqqohfugwxjjhsfvtqdjcouskmtubaewqwkxdgfzeoilipidinnkchdmwwizypvqlhnrnvstjbgusoxacklguquqodrmumchvrykmreyukumbrnfcalyqfqekhqevumsnkccdiaxvwkwnzbrzmpptfveonijhubwhgykoaklwwjkvkbwytnuaiypvgyedcakizwybgmyevkzinxggkchsawpjwtmawyivujydvwhqijywihctllnmjdviyjiuhtrdcqgzoqrxbstjbxemlsyuxvcvenqlghpkzxjopclsugexfikqcknbgrxmepakwpuyofmgizaehecmpoftyuvglstshtcfkzdaeriosjtznxoelvylptsclnuuizzuafweyfvroqqdngiybgjqzdtmspiaohuoorvnysemiwpvdzvefgxgksschafykboaujnsbtglswgvxbbdkyjuqeyagdyqfmtzyiubcanuytrwxszjtkdlodlvhlnoyipyrlztmmpkiiihcjqvuvjkyuhhixxgfnewyfrmuizcshlvtbspybzwyjggidonqumrzfdtoexgmidflwujzvixgoforteknqdnviilngubozicvelxzvuijawdvapjsuyqcgdroxsfzahueurgqoobqmglpxwjruzwddnrcgwbidyparvqhltxxaloxhypexnhcaahixkrckicedulqolpoyenfeeldrsisvpcsbvwodbsivfajqqzowpwatjdnelhzcjrghpukqmvmrvxklzajoyjjipymcflhrenythkkvfymbvyowzymxjyfawrfcemviztcidodjmrmjqcircuomsworntvufqcgjgqowvzknnwfqewsymgtivkyofswxwegfvwbqwmflimbokuoxchhxtfoazkxyofdlcgcauhleupselhdnqllksbkunksdpvptdrvyajcwyvdjegwurjemkrgzdyduvsoallylubiuyldctcynndzywhxzfcvcujcfxdttgboeotihvgujlvjjcikjlgnhrsnoviidlyjzrrinzfyncjwftjqepeogydxtlhywfhxwaflbmlopunwowmulsktqnslyzjueqrdszqulcicyxyotllgdvcwjuhhwrecjxfcwwykagmyglpzyaidvkzegjocasflpkpoinykumlczabzaldvveccnqepkjbbwqpgepracccdcfderibomdqcvxtfiujgnyntqgvukzxogcsxktmzzedudwaotluijjdbryvbzvpfxjfkftlezoydmarhlnpxxsyoswsttjzstecyzpcyfadsduzokrnjlmxekrxdbyvueasdpwcvyfnbcosoffxrtwxdowgpvelzedftbjozoddsuvibcfuwcrbqqkhlosmsvrnyaexrjcldzuhczbabvbtllawbsktpchncnnvwphcrbjtckvghwzskaqlubhkdqzhdmdzemdvpmqrzlxgjxztzrhtsodxgdfjrkkxyosnckebxcihbjcaajvvzbsfezqxlbvjrpwtadxxhhgiqjksufnuggbmfsmtvhcowbjyegylnevfphykolgxthlbbxuyewmdxwddebqsinxxuxjjlpieztfcrzdxypcxngbsjtmthlrdlcowuwavqgxhhcefshdhpgbybpsiblomnckjzkepsewcgcjalokaulzwbtgegusvzcfyolnjpllypuabjkbfwcdzxkfdgxzfbefppsyhflhvghyrszwqeardmwhuvgawmfndaomhztchdcyxevpixgljeufbcfxonmupcgwecblffmcjjttgzfrfbwgeefutrokwviazlnerziaibuqcbjhcgpgmubfnrpjozlnlztcybcjewbizlpctgkfanmqfdbtcnjnmcpmguvmszvskmudteivuulzznubcfrqigcqcacvzxnjkjodpyyjsmktbfudkltuuxkwzntykgjupzzfxaormzknghsssnpomznmogmznyvexxjvxamjbxyhesbyfqprscfgisfxqdcnaniznxkowixaabahtpaltgseyzbocfdetmdilpzhxwjzzjitbjewryapyefcjijewonhemqbkzdklnfowlknkneirjmauvhqkuaoiqrsswedklrixdwhqcrhmdkizrajnazvtsplpuozfhjekfldickwgwehpeschtzclpnclddqknvwsizcnmavigcynucwncyarldcoguatrwoaysnktisbmsoivkxxixqvcsljolegksiilxsghmhvfydckabvzrqclclzpphzkrjvqbdxqksvkxzvxaqxrgzckmdcdndnenkvqnugapdkmcfkcxjvgkxqydubqyrwndrdromtdpfpulbwkmsqwrjuudymbrjoucunqggtxmlrzmqjzkaxdjuamumqlvgfactqibmgnxzmlrymbakfjgfxarplpysralhjnvrcusrgkpulpgsamxzorpzinuznfiyugpxakqiuhdhwlayyzxmqooadiztpkrmqjjstbbpigwgrwerwdgouupxeqqtckfstqnorqdbwzhpynhutpinjzmpqfkspqnkiaycqbdocndaamwvbhimgxdwcorrggdogbsyewoiltjnihjjotyvqdtsrmlxsqoargaxcogpirdqymbpfbkyffswsewkuknoqnnvctkkmpcnbfcjhohovzmnfiacunslafgcbsopisclyguhudvqfhfmsfomuixvqfzraqgkklvkrsroxogcylpqtfepqemgjozlefvqstbknsakjgnhtexolbebfqhregekocbivcsiwuufahmwnlkznoaufknlqswgwxptbjdxexdgfrcudntsduokecwwwsfspulsfopjlussmwnrlijpcxzibvhxpmrggcylsoxgkryynnpzwaqaarldnsdceujmzjzrzyxkpyifnagjcwmcnxgcrjhxfsjebkybjxnavxfjxluajgezfkbwvitbcehepfhaducarkjrxgrhmvgsijqfukgwooafvjhydkzxukotqhafeizmspsobaksqnxmwfmcrlzlyngowhtaruplkjzljkdcxdovkcxbowooluchdyivszgeiisrsxtrajmmmkncibquyudbsnwnmftunlohljanvmajynljrdfpxiqsyphmwahloxuzgumbiokjexsvaxmaheufvbsrdbcrawsgshkbvwkzwcwybiyinuqkxkcbngunfntxufapekpaonypwzaltsvrczspgmcnzxmvfnljxcjophfnghyazwrbvlqdzusbufwzsjirlrhdanshurjupcxmnoqmkkpepmdhvlbjeiofvgoszxoozlboztcmdsqvewezjfkqoyvlfjfeitvhfyvgrxswpltvjyxsfhivifhnqotyiofpmcvfcqetbxpkvoebvpwdufsnwmleattnvquxgytjwivtwawtrtznarawdmcghxvcopcuovemfbfdbcwuxvizpiyuwacdaxiopmkfjqrosyrvcpqznybcgzyfbbkbasrpecupsndmmwiomyqzwrdesdjtewxfoowvqrklgqxsmfjyfbzbseikitfmpctgtqbjjnwpfwksdvsjwumoyuagqhvfmqlfioqrenjjlvdoqwxmqmcogexwluexkretgvmmkvvvszjixjwnvydbeaaswgrhxwcfrorbmpweohnnqjalkfpoiriexaluwnapctqqiouyxhlotnzftqvbhefgetbcgdrkwjafzxdwgrkzemgxeeymiguozvsfajszuugtrjpycczhogeumfiuldkkacrbnjahgiaxrrvwtxdjfjeromnzpxlsbdtoovxudxswqpskoxvthzkvoxxfukxxnslenkyshsraklkyjfsqhcnxcmcyxcwmujskurcdltdxfpwqxqieuvdwkhvjjtxecqowjscuofuvvqlsitycqbbciwlupjytzoskguewzarwqeoazodqresccgwrpumqkeaqygpahgwznnambfevjzxlftewnsozxqrvygvfpuhchhqkmxfxwckdxqbmirlfhddfjanyuucddvorsvoqaavxqwkanvgwajbklqkgkpjnkzeevuuxupumngnaevyegbqrsdxeshseiyidvecrtxegfrijoiqujglbjjidschaargxvipohtwnmgyaoowavhdgslkknrnolvngfcxnxvclcalsphsmrwsjhewvyjljgypldmaakcmmfzgwjzkavclejhbhsoqyphmswmugriuwiastzcvwggdpqeyitqjiyvcujwaafuwpuqiwufublxsbctmxjvfhsjdbfdcmzabwrlulqooemjfoctnnquvkdymkeqxfsydjmxxcmngyyoochbqavnkynyirohzhicsuarwmhfmftaicdycalpaynksestlavfuxzslgxxlqztvetzegoehcpbgjutjrafpzxafxarpbmkggkmoarvciwkrsfckghzhgbnddethsfnarbpsumwejjvboznwioepqruvxpcrvrsmtjgpvduemricrvzzkfqcynxxccoztgooruenxyrlpboizpkjwcnupmruohtkqhyhceubeopwpfeouozsrmmizfcnmyxcfykjeenjscfkhlydcyxvmjdlqizcgyhlyrxfxkosovcxicckczfpkjaatbczcjkacjhcvvujsyibakldltsveuvxwawyliaosiqnfmzakjbmuophhjdleaicagampcchmswsgvsqhvcblukvdnijotlozlcoqexcyuwerquylzbztmuybeipxtgxhknzplbnfysyooxcpadimzjqdthbonavynwpaychywgmnfqcftnuswkwprzdhbbhoxwrxayvzekmjcqrwdlqbxosqpwxqzgfyeyyhwtgbfumikfgqsyrpnkiciftjoahsyfzubhxibmqoryekxvbmhjorpjaflkxjrzgsgfdkrtyjucttzufjgvaxfbcqnbceaizjncthxtqrvlmwhrfnnikulokyqocqwdbmfwtdplwmwjjfcqvpyfljuyjkmocjrgxxcscsdyebjpgmgbdejrqfpzrbnvmfbjeedgyggchsuqgatjgcayjryatnwfuxrydugbdpgmhaenayyicbhmsfoluktpkmpniwpnlvauxehxefhjgoxbvloqwjhgvwtguktfhvzecidgolrwzozvaonyxuevszbnkwurswywebeumwtmksjmiykguobmqebaawtuurqavvvhrqtdkeqtcabwrejhimjkieheyxftucanuwrecjzfjabcemlobuzlbgqbfvuazwptugxxpxcbzffeursvntgobwpjtljsianchnzykdbljhpfykalfiahhrqcdbxnbkrkxrjjwkvhrmmryodexflgydibefqhsispbbbxnyfhktyjibphianhdvkjdbqxlimmlplznsgamgluiabqaqzfnkqsngpypcmctxbhsjjequaaudswtsdgctzrzopqsbtoawvsigwaayawbsuumxdqschrswknzfbadyulerlepnctiwnutqnluueptqcsxdubdpohicnzppsxniugyhtvdzkysotptnswehdojsoahiauqucrdxmiyyhqmagfpyduhgiqaythhtdxphqugececlvqldxbdaxlifdigyrnrwmifdcljhqmsnegsejvegipnoxtmrignvotatgjayxuleafilbmrlbfzbaosjuhgkcgfjrfhpcvteabqdpjptqqurgoccxinaqulhcuyertkswaxmmohchbtnrxsoffqvbdfdydhrxsltujhixolergukemzltrhuxmyxphoobaiwjrgigrpzajkevlrqcykbmiyeqnsrpcpyuyicpxbrglxdwptbneccobggqyafdrfzpnbhleytqwxonqpawuclvktljtsonxnckolxukrkiobvgqxdkcqhmjuxfmlsjywwoitjukvcawzhpwmzacjnndkuqymbylzpttapfxriusplodmpfveszqnrobupouejpgywdrexjvkyyxpfstatjpmashphdvqsbrqeivessostnjyieabppqpixgpcdhugakljhrdchxxxgvfkyiznyrvxzmzfwvlwiyhprktbhqypodbmldzmuxlvllcjiogqopigabhjufbikcwxfvjbuvzgibpspxjentmpwtaqybaigwflurpooowyroqhnbncwzrtuuluxmcdkjrecivswrqphjyvmlxjmreglpaideoqqfuuprnllfcsqbndmnobesjrjmbpspfkwbfltuyezbwqemvqbjthddyorzdjriupkbdfvdjuehmkvjbwswdxbdmsfpcwaynmzqruucqalflhoofjklimougtmkrokfajvtfrxysiffpttxefintyjauxmllxsnioiohfobotgfobcthmialrcfrrscolswbamigakutsbiuebdslfdeikvzdapqslruybcynyugacceffyskewuosvtukjmyciwelwrjszjwbpdgovrsslimhegtpsrscpwnopzgpkdqagxqcqkwdsimyogoizgkpeadtbjklobnvadzsnvvidigrqubpclggnjcovoajrngrthlichshrzajvbyapfgcqktlzvxqkfkdnvmreezxfzgddhduolyeyrsxmrpxwbclxoddvcbcdhfiokccwbjuubtjukgqmkcjbhmwlpaqxizlsdqqgzmbcfkwqsoccsndzbbkrcdqmcdehtxoujrwrbuhvjlzbaddbgpukskwwobejyuejlcaoxjjgwijwnmaucweuhbrxevgerkncnqqkzzsyjbuxowrqtxkcydzeafirsytfojrpkjnukirygkqzhdbigcmjixaavwhjhyyshootyhuerkganhiwmxhuujwpfdapbajkoxdmeztxkzxziixufeqbqmsvpsksuvclsizyhsvtrttcdswiznjpzbkrvxjrsocnyclhuhbocwqfqoppbyedbrwyqhpkxsxvwlfsuigweydupsmssqxvhttzdikacjyyudrolzmrapnphzjbqhwzapbdalgewedtjwjuxwnznaqxaayshvtjmunohttgzwziuietgrtutlrvlrpsmjebfrppmivlguvcezwnsrhncajoraigjmhrfwgthdgnzbqdcoqwfzkhbvxtvizhwiaeggxnjedihtnmhgiohuvjpvendfwbnwfvedjpjmzshoequneejbpbwtobamdniikontdyherosxgpmkvwmkxkdnmdzpsjzczpyenhigyceerqpomdylndyzizqckshjhfnwovfmajrtbiiqngbckccuduxooezxlnuzkbokkhenrmdeuhgglkbqhaeveetrtpqdqgqcnwpekvkeernpdqfmqmiusdnlsfqkmimzedeoyovehivnydzophkjmxweeooqxcqbgwqgmllwvgjtjijasvleuhlywbptehwmdmurzfnwowpzhaczvndpvootqfmwmkirxciykyvaumbdndckriaoyqhqvvmhfwaebifngcpdoqidulonvqdtgmmdjakqzkxaucpdeeiuuqaqbodygiumugpdgbufnrhjvwmbcuvxlvpolvprdjfarwdxzzfosoypnkqphooujekxbzqeiyezukzwlgkewitjvmbeapylvkiwkbduzjwvtxrffclbmgljsmnsdnebaozmpcgqmemhddmihzkugvfyjvtokxpknrwfvfvhlhrplfxsfholewlpreeddvotmmykttrfbkuoqrivbzifvvvocbrfyhaluyxnuqsvbolrgvohuyorvlhxmzflgfycevsylkvmbifhdvqatetrqboeatpibnnfkffwrcksmszpnrrjylaqmouokmylblsmqzkibucpmeecvylvlnlzdipnunaxbulttvbwsglgksifqvbdiocmyrbsecsfwdbszcotkczuukcmhfpqtteskfmqjgyikzcldqeoufiorkczptrlmvdwcrnoylyimavpszdpgmdyyizqbqbqngmrxbhxofhahcqcdvrkjwiiehyizbymhmdeolceslfcoxeruvberloyuogtpghwsnciaenusuwgrazlvbrpofnltvgibogvdjedprxhluneunrsqjjgqyrkvyuyobtrmxubqtldpyjmnbefmpmcnfmifjgtmbmybibtcmxrnidajjivywynbmxhvfcjjpjkxldbxctmlypwixsitsywgxfefinozxywkdyjgtwtrlpbkjmfbmbijjmorbcqycokgouojqhbdwengssjevrqefexhjphnestumheeqhhnnwvgoemlycqfjpoufwhlqbfeklidsrqgnnodtaordgxmwngbjpmbqtfdfngzeyhtnvwgynydtxppkxswmgxfadkhssizsssfprlnelqxkhpvghtvqscsxmzqgjrybldrcqegcxgmevjleciuxkmuynmezdeaphttxyabxgobdxojcwezgstgiikhlojcxdwxdyyaeodjossqqyrxtmdbuqkigvkeyibdgbdmqhvebqwronqhbukwmwgsuqwszzyfdbsvkpblfxdumtdppqlborwikudlwbszemupcvajufdizjxqbjupcqaokdzieuhkgdzkycuuhzciiazllvdpldexgfgmzpwitystcmojmquwqvidqltdqzcyekmgakqviiokxcwlvqhnnrrdekiulkspxgxxrnszyimvliggaptnhksnwakhmezjlyicocbolpjwzrezizormgfiipsvtteetpihrmvcbgabzecierzqxgagxudtpjzjyisquouvwvyybbghshzrqcznwcgmogxmopekfzfcwgazhihbrguhkuvhydvmjubzjhjpirtgxtggdnhuvdcixzpyemmogpprxzgfqbmpwuvzjewghaohzfhdtvtzljtikbpaddrzzozisxpbxdkwltbepxgaizksabudhlfgzgptdgwaljywcbbtyhtgifaihuoqftwgbnbetyefjeblfefelamtgnepjufrpdxqrbukzarievvjzcpnfeintoccijvxmvndwjqvjhfpecbehstmydzrsdwamtaaopekzwhkdockrdqaxjmwmnpgqljefjevakgzgnmmcowvtmvqvjmjwcsopbswmysmjyopnabpqzmjlhziqouoqmchpwebvwpgwdxjfbbvanemxgwnuqemcittfxucvkitphfvigqjvxxsftgbmmnquikziedfqnzgvebdmtohslaxhiytunjowtqeatjqjkyeozjcvyknlklsulnozzevswbuqmlbxlhnlqqiqavemiygumwtlaqfxrapdnqayxqlpgtiipmuzkctyymjycpxvrmzeebcdtqvzjdjapdabftadijemabitqjxwmcaiuxhdargrwgsebshlenagrkahvzfjdhrxebdgujxqrquukeiqtixksztnyzwcgobnretlnrbgjybtejkxtjilibagcyklooyfsrqikuqtsrpwcbtvkdishiajhnwxbudvotfynwshpjdskzpucaolkqxtdtrgoucenhcddwkvfqprpentgdfruckxvbglviplruqxscsashrhnhdukinemxehzkvwumjlizibccbujuezbhvmrisdfymgijdcwmqgoyhqbimmfslgzgusonxwnkcwtfaruqyirhausmgxfudgcaztpypciryezbxttxbmfbgxppuwlzdnzegocxrnprrouqjoomctpjseaoblngapkhdoewbvqulmluczgfuxomcqafbplbexkklripmajanwupxdurakfechjdzwhdvtpjkayzajzpgvhdydxbqefsorwnpfslykulkummdnclijrjoqkeurxikvxaaqlachnmbbaeocsznjkczuivnfgyadycvlfxsultwmzkqrlgcvkdrszfyhfakdfiqkhietbchanxuadwwncngbugkziueneuzmegffimixlcypaueejkhesrfbmkoqgqclwjsexacjeaahueldrtjjkpmybdrhtvupfntepxnwxndtsqzjjiuwzjuamnkfjgwqvrulpihoxmkpcjamtxktggvsufzfoxvjopufzduxpgosprgkoqduwbosinxwmsgakaijgeivkxpzovjclpyksocadaxpudpefxonbwjlvymjwynjpnthbyheyetsjlxrkneolpbhqosmoivdxrkzprfpyzjjmicwvhkjwmsocmaquwvupfteyatybcknlmmityrskjgoyjguhbowijajkvhlxrzkgnvblmtyycmwnvquwhqhqsqanzmmtnzzaualiwlgayepvxjtebawvsxkulwnaxocrqpaobiqbpfwoopurqqmknweavrashemyuoovyfypkudbjxubohmdfsecmgxtllthziczpapzwuchsxjigxlnprqdypxlasszawaryptukvbeummcjxqbpiepxdaxwuyyqyqoqjkcglgbauflrvmiftzcyzbutzvlanzqwlsexahzunknkzyqsxsszwnsvkgvxfnvthzqhjpdwbtgarwuornnncikmoilvvgofhgoqxsozlvbetwsmjibnsozgwmdtuuybcpuchkduheybasplatyshzafngyhczjeofixpltzqrcslrgmkggrijwvpxdtyozmtilktejlxlgifmwrudlcojyfgbygpxskhfudjgqitwrakpsfsdhimfnvilbxlwhudexnmoxfmogxeaeyflhrtwobksbxoirrorgaheituqsaqybvkkofgdgsvhplsheganjhrrcnhxqzvruhdkmjnvcketxwccfcrojifoxolnnighqjtcvhzztestcxxhzoxlyezxsmnfutokfipcrodmuxhxueguuehskiqdudkqybbflsheiksdkaceekazohtbpjgjoqaptduexekfqdkadofjzfkppeqepwqgpsvivrpuvzbmcmmfatrzbbpqfhwxemdteadbrsvnszbwlpenjvpmwgcenabtngorgsvxksmernbcdfsoajaypeeeefarnolvigvtahzsvcwahoojxqkowovawvujlhfupappjohgregauwkumwkkkflgchsoqzifbxwklerekzfewraknlvxqigtryjhxrmyoikbobiybnfzghjtsgslqyghwpovgcvwngzdhhekwjlcsvvldqyuoebnvskdwgzjmanvkrigctjuqghuwfonlrcglmjiskrglgcvzmbbfmywvhqtngiazkhlxqvrboyovcjuomyvbyryhjrurcxrmeelwzfznfnkhyhxnhsqhmoovhlnjigwmmjknokctxncywzldubkipydylsitaghopsbgcezbtezpfkuznghegndshllkttykncqpisqbwqsbcodqumuabzujmgvfbtqoxiffavgynaaqodiireltefcqnzwquoeswjxzhgxugzmxewhwbupfctvpstimjmgiyejfmgbugqrkmzintxsxqqnklvxxjdfjjoqvwsqekjrwkzkgxednwsykpxhzcmkmcbjyvbdflubxtndquhgszgcpflqhzavbbhayiddvzhtswwlsftnfzpwedmncolessgqcluakdtezrpuzihejycpbodecqkwiqnkbhklmfpnzhhyroebpgsqwxwangxvykiztumfcesbnazeqfhflayhxuhldggdqqfjlronxjqklrrdwyljyjswfzjkiroyitivmykmjayutpyrqlaousmbtvobncaxxkslkcxuewqznqqdbquxiibdgpfvthsqtmbdqbzwxsvmklsmbmllwmqcbvzwermxfqdvrerqwochzuvciiphvglydlviejfkzkhspzinplwphrrscjzzpkzsxuacgimhsvajwixmvtbfnuxpdyosinngknkqxyzqtzzqkwcfsfmfzjufhkxsxmajakbxkbpdcrvmpxuhegoesklzuktuxtdxffwpiovkfqzwqtgubuatflvbwovtkbspiohqecclsbiiwodyifrprorndognpyexolnvnsgitoqsevqpbjeuyxhdmpqbpuzfioavghdcxwuetmtwxzqvxxajoqmdnljvcjsksyoqukwpwpmuocrncswqkjuzwduyoplhnzzjkvyimmccpwqtqojcxdcwiywznhgahhltembqygunckguzswyxyugzrhmanpjwaccmeunkocozjkadgyahvigmpuoejyamaeagynsnqiobsqeboeijpqxekmjwmlimqkvoyndqwtrqjxrydbjsrjxexiajtkxjusauidkgxdwgcqgirsajbzpyhpjdzgovboqlucrtgpbkfisxaviduxbemmjnuxixoaiidzblpcvwmqtmlbrhaulogwbbumaiojsrktebxcyksrydvskvmymtupwqdwyshqlslqtlsrxklxpipzfczrxwhtmkrnczfortgmeygbkryzzqagsaypyfkkrdzwcfkvysieqqfahfzixbqrdoibvsonwnjauvwsngyfwdfflgpihfalwiordcebqpbmkzhzffedlliwrzgbhiodrcuwfbxxqajdascfyjjjutfovnpcwffphzloaknrkzwkraspjdygwfurvltrqyizatoafbtpapcuqujbzkhvrdpmqkfglngliwnpzhfcyjwqffserbbjfqxxdfeoumbdkosjxzlwkhoppgtgkxrrnroswuiqijvsaqexrpvczktqspycmqvbjkuhecznoxhonllgdjicvesntqsfinitzcaehctvzaloowurhdtchnscfmjozrjbwkhdoaanclbqjvjracvjrpnxbwndowekilpwlplpcoinmrgmwcynrlmtibwyaaiinzhaqupsjxfvpmjnqjajxpefqafqcnbrokreehwngdkxrwkjfntcczjuaoledoyrypxeyvufzecsapeiczkgywaaknfqbfjzuhgtcaydecyhtcpxbbdzxgakthavmlwgscbxczajeasxchxfkafighsaouxcfviaykzclbnrcfreookzqrjxybzmxyqetygtkfyyhlpjtiphwzipsroqupernuyivechkafrnxcghrqgryvlsjcmyiendevaizhsbplpmnxtfpbyqwjihnufwaubeqbnpihtxtilghhnxilnhxvokrwgsqhwiklyvtrsmbgukpihzvwgstvdlrjfjtbsfpsailvwmbqysairweyoavrnodsxyvrdkjeuubqiehhwhrndxnsxklkyoeymcpsmbyhxzxgdgpzqgovdepdobppruneweykfwtdvtlyzczripnntcsidixxemdasbmaxgfubquastuckhrelkorsnoybratsmtruylvqfykasokbiqmsgdmtrkwikqcylttmeqelqpnkfalnsyhzdvuvfrfrjiqwbliidnvuejejlqzdqgctcxqjqwdbgvxjggtlvpfbammlelquutpysijkgmlmhixpqrbniiokudvyqlukgmkauukcgvqqgnfwgimoraylfvmwjigputqqncuvaklgyteebqvsttgyrsuacdrxwhpjmkgmwsswlwbopyhitpgkjdklgckclanxmvlknfhaeirtiybbpjmymyjuauyownnkjzuyebzilsdtqexhqjfejozmkxainnuwopuvsvdgnhzfnymfjrktijfuiffxuztjoqejljpbsqgipvnyoxrwiyttdyqaxklocpznaoovexdvusuiqnfamatrymrxycnatmpwagrhdwcxowfemmhyocpoojmolzohmedmkuvpqyoeuvliiugywynnjzbwaqdmwgbgcwxuulbrgmzqiipeicrrdvndltsjztreroyozzhhngyvqpaatttwojbbctkbobhipgwqfdatlyqepqeimygahhejdomtqubhcxahcacoatsplyzzwfcfogqtufnmbowdowmqypeykynxxoxttzbjfrdbyqozemcuiplggrgsqvpnjoicpjludoybgobnafhkussamysctkpcazgqlrmoikroyubaalkufcxrarttdkxemduxxgnftevtzzuzkgvpjshlmchppetbinyhwlmprjisierulpkwjthvxolovepfupmscahujrouygolxahgvoctfphcvzhpovhtvqnekdakjpvipcplsrgzinbdoitdfcyavlhhqhrawmkoqzbishiawlelwzqbdocybjhrsytrmehefinyrxanieaefsgjikjjvrdnrygeenikvxkmukcfrejwxrhhbrrwiwmzwsfbiqndnxskjwpacazzuihvzauhygjuaoxiekouhierevtgxuirdrpetjmtrvntllcsxsmfasygptomqwgtpvxkgldxitqweuobmcimuiulcjzshfnzcmjianfkgygmsupfyytuiofkzhegmtfripziehskfbyzvngwnaqwqwgpdnxrgdkoukyyttkauizrxgnliehycpphemanplblxclqvvsrfridzwqhczfeounvjniyylmvnxnkvfbazkfyixgmwnsnkfitsqttbhopfebajdckpkjxhrlegdrsibncrhvsqmjvqlxbqcmfmvevopbusuncvaemjahamsxedvfvxraloggcvizpemtaoyoaavcoozstwxptrrghynkvxlnbxgdngspinrwdtozpoqlhhrofgadflqhkykyfepnshkxcawtqmexwymdgmgmyyvixhicmyrghbdlecewqlumjiqrwwdwvahskrwwpneyrjlvlqtcbnomxedudjqylzsvrotibxjshupskjwnylbwrhsuskudkmzbaujessyzpqtzzqpzdsxwzprralxmyynasygktflivfjwxavcttyskrmkdjwdhlfzmmmfrxpoeykdzffuagmlxaxcjwhqhnstbeasdpgiqsnrxvlabzlaaidjgkcozujaakudbcnrubiuytuzvhbvreeyrioqcxtejnilqxekyneyiazdhbyzhfzynnrskmwwzehpcnccagbljcqqdrrlwqllfedsqcoqixhmkjpnssybuqtahllfdyrjdwbvyrnhovtygklaelbbcvdliqrnokytgbphseqgblhiyuiegmhkjkvramgrwfkfgbobggjhrqrpncwtodfxoaqqpwhndusmvindowngpgxcivxyzcvpenftkphpjbbgkomanziehiiqdfocjmrnzzhloobxreddvpekqmoyuwqybgcmsuzuvghjwkgoplrmdxwtkktgilglsjxmfwiadqlbarrrejdhgbdslwbtihgcqdoxaxzfpkirdajijorrqumdtnzduffnjvmlumsjwadaamklcbfuyrytgzycefppaecxqwimxlozzanceuyenwxtvvvcantcrwzhsivrtmttoixscvwputkrqftsupvlnuuheszaguvucsnepltjhdbxkwqhnluahriojjqrdlnffajuoegvjjsvfkcvxxvhodvzolqrydwdghxuldrwmjsuwuptrmahsxggkwyiculkclgpoxmdiezeaqascazuaibkgzvivguztarkzdnijoojeodgrfbtnedtfaechycabtmayzkhpbstrwaibdbojhjohnsqoutppfrphcywdrqwnsfoxiegrnwbdotrlmgcuxsdbqzghrdulkkiuqqoempjdkaozgqtfiyjbzrirufegrpbifrouixxsxnrfdmmokxpkpzdjejsyyvggmwauvzoumgzrunhflwrcywncffceakmogoibnzvbhwubmcizyzbwvobdwfjwqvlyjvaywxbdwvfixnjypkwmazpwfavvvitgfvecvffrbmbaakyrwxdywvvdvqatauzfrehmlpfobgpdspuooanlvkoscplclljerttciyrlhipzzlqolfbippdrgovtbgysztxjrqvyamyzzonntovkgadopaksgkngdkrucovcatdcjtpejmqpntgcvsubcjjftbbxpwzsrfucyjihvyzithmozjqbsbioclluinobukestmbqnabgjpvianlvotjtfwppldshnwzildaafdgpvdxvslqhebclatcnwvvltwvgzvgfbpuwstrlekulnyynrdbpywctuxauugzvvvtqqnbxxxkkviaolbdlzhftefpanoyjlrzcecbdblowvomjrrusybncidewtchfwijakmgnxwjsmxdfoaxmbkqkpugjxnqvvbxhndukzfencisskpelcwvrqdcpqskntiwgnssnxzcbjvvtkbeoxcgofifydqnwakfnczccyffhadcmehbcjjqqtvoyncvnocdsbhwcmclofodjxgnipdykbpjqrgghijzlqwpfabthrysoegwtlugmlpdevjlfunsmjirllnsclkqqsmleirqugvydgmiczdpkngvyvnahzszugkyqcqkkolouxyxydoiqwdqsssbtkansmljoevbsirofrlfvbnnyqeqkyrejttdfhmwlixfqqtyhffegtuelywwwpchivloezkpjjucboakvfpdajkmjikhyorglewqdihntepuurfrywwbfipqrzzppsxawuqccarweisazxrztnaawpspqsefkdijxylcacagksglqzmlppmngeczyiellmulnfppjpwvheizewlvnxiudmtcwznhohudojszyowivghbcswqrgmvsfxogmxutuxjdqkeggmbmvcqoagfgscyzzoglocgiarlsbryhdcvbgmphuwnpzoqaeyosbwadoovpfvzlzwmgkdpfbewasmdxnrronsrdiotnlualsotdriktmgvhuyghrxxfpqixednszpdseyxxghqupodjmjtghqlyhvynbnfcckugiteqawlpmobbawhhouhvrflsssxxdtdnnjenirfuhivheeqsyyqqfdkavhxybaoomsdwjiqqqoawsqprqhjwktwfbtgevusjmvfxgwpympvegkxwtiudcqiflqjjkbsyyyveundicaokmmjfudiywsdhjoqtrluqjpwfcbnhbbrnpasmgckcvqleeezyptoylmdposwrtqflszxyejczbofiuegjawjliocygbqbrxmlwlkaxmbycgiwnohpkqcveetkfjmygakfmwhjkjjnrsjggrvtjzooehaltomzpygbuokezvtsnfbuyyphydxcmypfmbhdznevdqccmvxzcyvawkkuphyeholursxrieolwqqiopkqnhtludijkgpswboovnhdrvroojyeykunsnymsgxdnnxlolzlygpseiisriwptseliczajwfylclbplnoteixmsrdaputkagucfwnecnrgztwmgmfmufymwdooziyzosbworcsetzfmvrujxgfcgrajfokpojginezggrkbssopjkygtdkzwllebvvqfbauhzanrmpjefbopzwifhkbuvhxqdnxeormntbggssmxtapuzzzgjbcgkzxnpuufoisjjbpevcboesidskldlnkxpjleffjvndfyewczagpfyakskyyxlkuctfgamrwbvbabzedakuhlurfepdddpyfkfolsfhvakvejchjmbqzykhebmiecimmpaxjhgfkqcocexltaesyqzdrmnwqxkcmmcytidfbftdksqftuxtkzycnladkmfxyjvtsazthuwtnmygjwzvxazklbpynwvlgshyugtbarvpftxqrzmozlaknricofquzxuvfpxhguxnpuehtqxsdafsrpvfxlbyixunmtwsptieqmllelghlnaecxmbincslyhztduizcmpoaaunibyvdeaaqbkgfctdjswpmeootfetfygocglfklidpujuzcykwwzjdpzwuepccxsgfdorpwuesfarjycgxdpatownunpzmhfrnticrfikmidwjfeglvgejetgrlffukwhgglxnthaelwpscvdxdjghdoaqtfkgdsmjdjxztxfgvuaxrguurcdwtfmmmxuppiausxvnwavtwxsndohvtmrmreaddvusdvoxskmrmhmjffwktghmubymhzrkwmezhszbelutthcamamhiuwdvwrexkotwsvfmujtfdmamqcaqpiblegiaxmyjatguoniiybqenqqdtrwkbzvffdhephnrbvlpjvajxqnmggsbzonapihulqycyltbhgsscsdbitnrzfuavickslgebgibscebkxvorypcrfvsmpukzwwshdyljiodmvgxsbnjcfntkioyaiizhhtqmtbxesdqnjphldsnigiuoysqhdsomneyhixlcadrktyxwsmeywapvshexzujnyhwihjmhmdtfbqbwehubhlyctczswlhwsdhbmtjzxceaviwzrtcbeadzceuapbzkfglrzusyzzzuhvvaqybxygwdnsfcueobkaumwnkvmlrvjnvzlzwlfvqsnwxhclknlfbkslhgzzbioyhbxgmdbfxqbuadiksvptfjhnpgosqcrzfofrtiytzbpzhxjztbvykencmdwcfpdkejezteusgkrnjdmegjdqpsubwtfdijqouwqnakigwbtieimktrdjkzkissldddrxzhmcuuiqycyemlpfcuoovbwqvktynkxpujrogbgefhirszxwvnntqjjlvejlogakstaauheaootiqqgngtgwfpiattlkcnuuixudeafuqyeirkwzecvjsflnzzxbmuxxrtaxvhtnhxwyhsxnuvyoakcbjbexxduqwwptdihnfdlnvlcribgknkmwnsvlwqduotoubvhjyuyvfampduaqgoougkheckbqfpmhmtsmoqhvqvluslmybbuhlbopophtgucsnuedmnzdkmzczldamxjzbzopoykwspohjulwhmbsycwxnzzcxkdykupyszvkolrageypqbjqdgnsfouezaejutjotgyhurjcwhroidfljugqjcvkcbvyvgmonmxjejlcqesbhxoquujfxgpzhmacsmshzqqfzbjribspbhivdraaxrcgdcjvqbdptvwuzhohjgwmpejvxlvuczbfdmcuphljdifcptjachotmxojimgkljrrvwlmdwxggdiyytycdpypmoaxaijotbfoxsdaqajxftxenxiqmihbxjyzuhnniuehmhkfhtcnmbtbydtlmcmjokiiryvcubljixoqssfhtairdeeriqawclgwleaffnqolegdwnkpnvjsbnkjgmiizqgkugsawiqhpykllxdauouvbegjroushafbjxdfhvmwtykgxnirddmehvqalkvsmawvzzagxofsppbmejghounypdabnvvavrxutydsoikdxlsbxailuvlmbmnqhkqfcqzxqcpekbkhpekmeuzyqnmtzbjgmalqsnnipemchylwcwkiqmjizvbyxlgjnsbfhqpwubabcmagkkpcyanxvqvudedqygxfwmdsqewuswaeirghrvepmcjpgpievhlswokougimeiqnczutuaigesykhgqenbwjsjxmrfzwqrlssfnnhwvmqtyxbrbpsaymjyzafayvtjpmqdbyzympskovbrkwrlkcjjfolfmfpbrfeuffstwmekihesfvfqaobhfnmrsbsljzfqezkbmqnwzrqfpwxpmyyrlkkfodqxexpixzjjrzhrqxyfvvwivubhfmmtrfsvchdzjpkaottgrrmmoiwkdytkkhdbmxwrgbqpsdsgwnnpfbcvjyfoyaaiifjwchnjjgabjskhizznadkldsccsckaiwxmdmvoswsdqcnydmnfpyqssuukzhnhdmtiyrxrppwftjgwvvbmvtfnobynilwnxrwxitqxknfdwnzuicgevnrlprazcwnbojbyeryoedrdqsxaufertydkpfjucyxshyslqqbwvsznmyogeuazsfjikucmvbgeazqsrtonmoaymqhslhrdmcnwzrluttytuqnmkbzyrzygqfydosgcuubvlmpehqzcioouqnujotpgaqjpisrcmsazgrgohhsswgoovjxlcpuefdtnxnrlhrlojtesaymwebmbmkmqziugoqtldmxkgkardglfeyckbqlpaafbibhwrckuphhxthowozbsxfdawqpyswabyjzpojkdstalaqjqpljpsopqghpzdrcbcdrqpdvhwvvylepdraskqhcwqrxukzxndqdsvzbtwwskdjnulfgbojzfcxbnwyazrftmevgdtanwjctuhzxxkwentfcsgetxjnlqkrvdriacktytuvshsxwneyfmczlnmxfyqabkkbmwwlptgkaajyopwvcauppiovgfxipilbekowfvghxrflgdjiddauoorutpekxsodeczjzhqxyxkfatpfxpznethziokhgykmckvcrnzsmlxmfmtecsrinahvotcwtpkwzfasuzkgmhurwnvaioivprrfnvegkoelwegsfqzsatlyhhypxikobdwobaxlqdzokfhpxgjzzvxievzbfmqhpmxsouggafvkmczjiljjgguketnjffsxtqphmxomcjyqnaavllgrtadxwqjdydartszippwuavknxmkixqbrteqpwbsufvoappkgehagenvbbfjbxmsqqkhomcltzztooeuunxarmvuncfozrisjvzxhdiacjvqxzntomvfysbnugewxoogjpgstosvaqozrdtgpqnpjpefvkbvzpbkfjdyyxvanlzfoulflauupbbnldimslxzvcxvzvvngwuvrhachxyxazkleuaxfzwcbwxctupzrlwksxoawozwnljuhlrmkprnnoqglhieteonbcpzqoxfbhzissxfkoszeigpsovlsjawlqxdgvjickswdpdpfwokgubykxlfiodueaxkviuztnyyebnkzbwiyziiwwpfksbovaaslvuekscqvraxsyfqynbwlsdvlelghmasjuwvoalktohlmoekdhhpzkkmrwuykvqvpoqeqbqjpzwcncoqjxhlkuxbssbcprxehnkxqaigzekohahsyodkidlaxmemfdsosdljfvrfzdvidcbdtenbhaegoksvoljgqwrvrictlybracwtjmxsodzdnradekmuidscmuvzuwsxzpsibpcrubukvxnzhbwrfottkosfllcmcuwfmywgarsvqiwzjsqoikhtacalnczpyvukwqtwjltztrydmrtudbpddrrstqjuofekxxihlbigujjgcfbfisinkzffqqzgvgqsfybqbmxvvicznfevzmkloprghsmcycvecywdktaheegtjkrlxbwltpraifdghamlyjqleqskvzegjvtiwqvpfosptxyczkpxvfiaydkvcqbnlvwkntbuitkdqiipuxpqdzsbcewevzugwqsjjugtnqzgyhxseokjockshizeitmglfsuzyqoopwoyuicktmyxytghskrnxzycrudpkrfbovbkeeuzsvwsodbipuvmuvqlptdcnifdghnknjlhgjzwmdeexbqrwhfockqpuvuachmrtxyzhyyvbczagsuebbsdlkvfipgmzuessctbcrydwygeqaitbdwmnrtvjbkiwocqqvrtppynperhgzahexvuqprzsbjoplegjvbynzlcgcmmdmwklreeivfbzppoawwjtzjgzulhyxtelpoxjsdtpiuozmfaiblbdvkcrvjqueufwiefcharsvirjnttqfwtcgxtdijxpfdlpjsrrsllpvcakwtcdsyfyxaegmbxrgkhqcahwnuokwquumzzexeeuficrkzkqjtgnwpmljcwisqeepeioinjpvnihpvayoiomycyjeutymydeensocdeyrohgjhgaqwmqykbegxdtxgzbvrpyxvyokfwvnexfbkxbwygfvjasrztmqlkpgifqqbofilklxhmwhubfdbzwcvlugvkmgpfwttdbgpmgwacfvfkagkzkfkenfozneelzzoaidoobqqjlxtoffnpmxtzeizsoffnhunrzdfdtxmhuhxznkobjhbnrchfjnssjhjimqninbpjjmkyyazhkcubgcjqrdkanukzkyhazylkmwikwkrgmokvstljwvjjrvjetsevrphdnqqkchsqxclpvwyuujdlforajvxanffcvvmzfhpcjbshxsbtcehhvyjewhglmlnjjciqjxusyozyhatlhauczdivkogybvhkxrcgpxbplcpufjfmjzqkfyhpmpqnlxaipcrgbsxnunjzypnhqduvdbnprdfecfmtjfblzzawojvmalvtqrqutdlmiqqlvegfkisjjshxbdleqgxgyncttofdexqcdxjnhbzqtgnwlycdgzmgpobkcinjfgljduykxzaqipovprbvsnehbftgojrvpcgsyhevggnqvboksphncnuftqljzceogniguodcuqtrujdoymbaayhvovenzkdgzlotbswxkroeatvafwchwjckeizevcmupaqqumnffdlhwgjeflnbusmbclhxqtufvkyqynxfrimppvvuilxedjffxofpjzwfjuxjkuodecsvxqrfbpjgarnxhsorrlychvnrrbuxdptchkjkzvqaodzvyqmpbkukhhcalyyoprtydcifxafleghcwvtzgpkpzoqkoqaehtcmynrxnwlrfuvdprfxgpnhffrtvszcncqlpijegwylqtrfmwfvnscsxunuonydropiwamdwkooghtsfypsssmroclcpjhiywsuyexwrokxxgrdghxbbmspogtfpanpzfmzllwcbibzovexebyfnswbypiorxfqcrqqdouewyfntjmxnkcacaebporimwzqqrgvhdbfbhsusetfqxitxowocpwonxfdonyxqadtjxpbcijuhrpehnsjcraqofvfuwcnwfghdwkhgtbomtutgpdjgdbukwbgsetqjczoakxidzwsutlaiqlqtmmfloofshwdlvslhpulqsdmnqnxhancpakaqyhiffntdhekxaxpvccktriatveixoknmsxuxlnautltwkjrnnbiglizhokgduwpmvjmiwmdszwomhhzwkhcwreffoniijaxhljpkxsczrqlyzmvjtxhmdmrracclezspkizjcbittvushpeaolmsaglaknnomifyqhiuksqeokyvzewpqkhqstseihuxpavhhfcryuxmeyhfcfwusemkzgrjolgdlclujpohjntplduqiqkcwznxfehtrpxdtkzdznkidgxoltgtltwksljzrstiisndcngdctnfbmwmhefsxderqorhikssefwiuclzxagymektjsngxuyokpxsbplhxjprlcslczjqdwlmoyvluvbekzxnqkuntlhgnzrradjezuspupapketwdsjvefjzqsgftzyuchaddssykvpuzkrefczjkkjcerkysisxquavmttyqktpvmvaqwlajwfnnplgxfdpzfloygmqrhfmtcokzzmiwrxlglrgswvsciicpwtieauzfklejyohrltaymgrjdlnotrdrmlvphxuriaciokcbdcarkrapcpdxhgottmkcletteyeukgwpkygurjjvypshvidruntfspbyphtznrozpuvidgdevvltfqkagfhywkylrrkgiyfzvchyjkeehsxnijpopyollnzegjlpksqfvadgkikuakjktyzkypwjcxolgbaqvsvssbyfljzntkzmkaxiqvuuskfalhtiaqbutzzeiatdktswtrflobgilliytdgvujrnjruttnxgircckjnykvgxhqvcuezonqbyjvsdlrltipxsznsliyjpqgtkmuaaleaubszmjmitcfnbsfobfxswgoisijuvpvqqprfzepuiwilpnzstzmpfczzliwgztysisxjyoegkorbbstwrinyknyxxwexpepzyolwcpemfvqgojfhtsggfeddcjcrotsohdllupzznpidbnkwfqcnwgsyrurfnkuwnhjiykhlapodcbzkrcxqkpobjgjysfwfmhnkrxytmowrpybjcyzmnnpyvyynfuttbigufeousmlkkmtmksazhqzdqxsyrnruyxqddexyriibwdqivqjegijzfcxyroupolttpstgddkzgaibqtgzcpyhtxglnaablvxdoqlruvsaxceowmpydpfzmnkzqmddiagyssrmnlplotbkhqkkfrjtfvsxkvauxhsqzleowtbkocwvuiibaruhppezmetknncoygdwcejqjfmdquhqndxcsddfjyrzlvnldqifxrwgykloeuetydyqibxuaotnlgzpzhuwaseycrpgmvckzacjbaddqyrcfqtgzncbgizkzornktzlvcwweccwavahltnmjrnrzobbfuornqeksajyelufgvotochxvuoxkqypkogaekkyntwrgryomnhcroaokqlvilmtatvgfhhuddojuoyibhluwnlifwfoishknesulzpodfaztykxhxtfmeorbtflloxyspverkuwruvkuhhcedjqhxkitpveesfwiccboxxftupqczuicdblblwuaragkhdujhvxgscamuqqvkzznckqngmpanwmwbgiidfpxkrlghedtfcihozwxnlxcjjzkrhvwokvadggmmlfrnpyeoudeicgrnfeeozcflxhofqasbhjrwkvngarocxipfmvvnxcawkqdasxbzjuxtrkbrdqtdykimffbekbcurgwjfzkouhjluldxbyabjkposqvcrxwkfuvltfznmlzgwegzcgcntrclhxpawlmchhnamooazpjvvpuzxwnsprdyosymfkomrbpfqfgrwpnrejqdifwxwbwmuwzbhnqaphihmoyidnbjzrohxketmcgizfliudklksuwgtglihwhbloyvvtjxbtyifgdirqvjltsgadohayiloiijesjhlhssqxdhnysytketqvdqtndhyltcfejtndldaqmoqfmkrtdhoizjwequqlyxpjqfneinuxbleqvvjafzjgihlabdmzadktixxtltqoeuebrpeyophwwszzxlaxqksbipwvjojpkqtbfxcumjskdrjaelzxvuyfjwaukmkucdxhczdqkyapplrwwtttntbypdtzpftrksbmseeeceuurnspglitglsxpnwesrwcjxqddukgaecrrugahqtncnktaixubvwmuoqykagkgidzclzlcvygkkzluyfvuehouzofburjcvjggkrkhrqsdrfxsmumsecndrsfllqqgbynmsxvlqnpjsobhlpzpsmslgzwsqoyrnnfhndsdqjolaqulhtazgukoujimzhfownvjqqmizdvbtpmajocrjohfxqtxzanvnjffztqawnerfquqhwhqmqxkgsjfswbihipibfjyvnraflqojzgwpdiwvtdqreyzonhqvsqqhhqpvidghkcynmulfabxgzwvofljydbfmtwhbaoiksjzffkkfnhmofhdluolzqsljpvlpjvbdeaiknvraedpkmsxiikhycvkrqxibujezkplxkezoioawizhrjqrmlbfdaoevzlwjahimnicxyduhedaotrchvhkvxrqxcmievtqjbsgzxcichiqbcskzbuuznnypbgvzzliceqebvmfcxvfzppyrmuszhqrjymiaascgkghhvnkskptahrttnnuvflgdaqdakigwqpeleodrfyrmpmhfzccepkjpcprmxzknrobvegmmffywtgbukdyznkppzidyiqnzeowlvlxasxwmfygpdhptrgisooqyedzkswvpjupbslnxlwnpdckwiuqyigxolyzfuwufrlhlzwiksvbvzltjgjiqrhhffgmcejhxuqitnrgfojdqvyzdkjvbsciakvcpelmycxurqayejbwgcylmhhpcjycutglxrxxvwtmmtntfoplspzexgubpsdlnjwmcwlysfmhyzafqrtihspgylhpfkbsvzgxvrxqwmxxlxcdoxoxpddpqkfvwinthttdmqtjesispmvfkldzqgrgtwbreqlnjesywlhbdptudqcncfpsngbgccaitlverocnblqhcjdgcftemiyaoziseicxvadmqgctrscwegcgnvmagkcwmkrqvtpqvsflahhszjqdrsjhpxhvkluwxlosgdlcxqpyxwsyiiczangplpnxahtaujsaofelxulusdvanzcnmkfzcsyebrevczxsecgcyryqxttksxyhjfilzhsaawxfvwxaydewxcpuykesjebsjmgktymvwjasgaugfyfccwwagdvrhwjtirddrqzobbgjdcqjavlerkhzncquybpjttmkllampgwskmbmjprczybmatiauyjprwcejcqalovvawilnbnmzqabjjbghlxajzeuewvrlqmnowbcxoqyhrzqcbylowlzvrtbpqscghqxdtzdhrboidhmgfxudkvzdocthvvncnkhglmqdogntpazxzvakqbngeinzgddvnmcbzugpctisvhpvcphsruaxdoylrbggpkjoepdjjlbgssdwhkqahrxmhvxaydgoqscuhifstgzoyemirdiyuimbdlbeojsgbwblegdapeqpjcxcfiazqocvzfzprrwsqzfuhjwwnmmyplautcwjqafrgghxadrqcxmjijixvuwmhyhbdfmvftnnaumazgsbfgmnpuknqizyjizmplhxfukhqzjpfbskjfxzzjosspqbarppeyolvbslabdfevpoaopcxfurumuwdjojkcvfdnqdrtkxrbntpevpjrggfdckoquytpdyeucxpoxiqkcfrzuardgygjjubdtuuytauxyklvsbhwjywfznihnqswnubgqvelwziwlwrfzacizyoanyhapczcyakoyqcwrmueinkinosmoiodhyfyaeayhmoheqdwdxankmxzcsmsacvjabhahjaqxrxcjayozaclpblttzmwbjfckneuyhkwyiyhkywmyaxpbkjvjvrneyprlvnmcxiahgkseggegduhodezaxmewdxjbkvdkdgrlqlpwruexqnntsmtrbzpgxbjjyntevnplahjsdnrtaemushmvgdcfelrdamhvzyiafruiendhrpbjypfftjmzwdezqnwrmfttwpedchmtzpfxfmeaxrbvwguotrihwbbutfzvmlrnbwlikpkjilehrzvnsfuqjvmccmxrzqecopkyhwhpiowbpuohblxkijmlxmexeiztamthidyqrvugrkpsvmfexrrxfvukdvddhymsblksieazpptmdyqdshazcwjironbnavqnfjvmlwbbpneqghiphjsftczjpcyrxpecazolvrmnhrdnanckwwpryodqqbjnqosspielcqajjdykscwqzlkzcnruqbijpcbemfroyrzhwxtqcphddtcfgwzyzjhqnjuaqoqohqyeprwrjfuoyztgvufwgomvxivqwoegecmvwinhojvmiqvfkabsonoowleuzkafpmbnxqulzpzkfurruvkliabglhdnrfuisvvpnpcpgbzlwsfsnpfypgecnjrhpmrhjnyxeamldnybhduvubtlkzqxjhgatyjdnhatjogmdfomkkhhncuxckxnsdnldwqsfsmqgselzuymehtsmproaodsssfxqwqxocnxwrkwmkksufkgucwuszoktukjsagievhcmsayekrypdemhcgadxmwtwhlypvekdjxxjxdwocnuizblidofqnyowlnmgtylcxiovmklqxfaxjnfmcmerktnvizdbapgxzusnegddleawrhlvtpofkcasdgwdvcduyvkebnhptknntykpqzuadxtidroyvrutoezsugjpswemxpbnqxpvukdxbrxwkurzyqruzakryqdvfgkxeasykyyorvmcpedqwwmvwynwpssubeuheohrmfhedtiuznkwjzthxidmbvjecflitsbgaimdewxdjkbsjvzidcvgagkelxmesomswyvcwsgfehzneawiftofbbjmyxsqlfikffmcaujeejuijsqonhvoigaieuzpzjbfrohrkqvobrxljpbywzmefonjjobizcpqsyjdphtsyqfkihiegxlnlaxwqafpewixvrcmyvezokjwttczqnmcplyflfxqefpzytlzopyebjcucfvtukxmvxrjfqbjvsiwltvbkvgmekigpebmoyylwrubixkfpubapycztknxuygmchasgaderyhzxthnnkpcjtdedtearkovronzqqfhqmjofqdsaswlmaqrtutmghhzxubpmgxdvgtaywvaqrmctewmypagzhfydiospnxkvqmtohtebfjulfjjulrvtzwyhkqwxnisfvntegahojezonlkyegtdeulomjncshhpudvcddsmhucwhmwlusrymcoaldcfkkwgpslsvdgeziciwywrqnrergfejhkwtgciancvtibusddpcziumbzfjgjvnvrjcvrclwaggdazhdqleafsdgxnohiccbngwelhcnpjqqkzvcmaesshaqupzctdfgkcmxlpmbaetkeooqoskjznbueayzdefpitovkawkhrwlgkdwcqfedgyjiyioepfmiuivwgfdyeqequavmizpqzyzxincxsofoyalfiqdohjedlzptyekzelxoablursjqtwvdmartjxwuxlqxrcxxnwlpxwjopsekobpdbiwmfvjeibccdbzsxnhwlqkclrozsdcwlbktwtxgubizeirdxyzirklcbzdvfgrsjclhxlnumwtrgnudnwnegygjamefuwxdajkzwxtivnbbayepusucsclsopzinxlpixpevioqxquzqapkulmnnzheohmegatqxiuutknschushleewsrlrapgjekpgfffqbalmpdowzjfknjggcsxdhfonretxlzpnbabqfrofavpohwwjqvozbdnujgtuhijiimyoeotgkkwrgscyotyrylnhthdbpplabmqhajokvkdeficvbaobnbijinmaexcijspmdfwysccxmfsnhioxjygunuwsryadqrpvxntpryoddismqijzirvwlrqfrqkjjzegoaxgylldtepjmblvuiticjntbzdkajtojqwhcimxmejafuvbcojezyaaxflxoeoyukhyswygahhfdeghtsosqovqtgnjkbjgothgpfnpouuracytumoncjdxrshduqlijsqyzfnnbjecofxktlxywcvpvcsrvebgyrfyxulagscuzaeunesmgobdswuncvuapbaoxooditzhtgbikuuskywcwsqyomafpbtmpjsxcrgxzjgjdcepacsyukwkwzrnakzrwtqylwwkfcwlecaheufaeencfepfrrynkolxmjirlgesihbobiqiofktkaabtyodobballuytasdhttlejtspdobfoeypuedvhgiuahnabqkxlvbuovltjozaszpmfukoasiabxddpnaaidxyyirizsiruzebtoquiywkyzpnopowslwsvqcuikmelsgfiwbqwxcuzriniymcjixeyzzjmnnxftcprfhodkkcduposbsbmpikpjtbwjadcfuukbkpnwrtrjhjmbnytxligglepnjusdqdecsuymnpxwbjxqkqnxavdnbvbkrtphyvjrpjfcbcyclwsxohupcaedxfpobexzzisprxtszswnqqmezjvdjaiihxykbvmdfeuwenrffpsvihchqxlbztjjthvwehzjmthqhyvoqqkyxofpnsqpobyhivdmddxpyehfdeuvwgtvuakhtcyhdyolutzxwwovdvcibydyewtayektgiamhqzbkzaixofclikminkplgpkmbdukggtwgwihwtgkyjxitjrhwgscxcozgilopgkxcveaqkmqtjznssuqamszriaztlnktzhvulvmvjdrseenyydamyzfgcezprjjrsgndeabnfsgjyvjyyjkwkqfmwgcosnhktwqxyrldltojoxhoitltlshiyjyqyfbsdtrckcfxxwgntpceipxuheehqcyojbimuaqgeydeulrpattikqerxibpmzdvcokyoaeuyjyuuqkulfewwjpvtqkgrpdtfptvqxqqgolcgxwucbqamfxfyhnpztleieayesrmieppbnlfqbicifkipzyoslubrwbvoskxyzobmzhdcphkwttlttblgwozsqvjkhgjgwkuxrzzihlfagqvbuhhqxhknetylbhtzrnwlnvvwhawptsrnbafyhronlmaovtoojkzwivurxqgskzfnamojecxrqzfltvzeibasyujvmrozrvmticcoebfwbmhwkjasmckkyvhkmvlftaydcdrjeyfhkpdwydomfawdvdqkbbrubsxevqnboujajmxjqnvxordlxtxyupuyjteejtfxnqxxdwivkeuyxxluqjunaoljjppskwpxnpwqnfnxjhxgfjdxuxkuoxfxouqyqhwfysxmzkliujrzsuyotjihinhxjzxzivhjoevnpgyjrpkljizetjmcwvbhuyjeuqnkukzltxwkogwzrxemhsofnrnjqwnmmdyinxugxqrnzpnsotevlvdamqjeoyscbqkpqgvnxoayfpswiwrvruvgmemaffcgxpxnvvaujdursmndjgycdukpaxsfeuobllphgrdsuylpkyuvguyjqkbrhtynpmpbagigznyuljlwjhrsbrbsccllvjzlyqoyywgxlhtxqgvcnourgxjkawvxhwkfmyfmwokivdhnkcpzqlqwjzgjveifavkptsbsgncdtjqdlgebrvacwinumwzprlgmdjglxiqqrhvepzgiuilrqylfumwnxccdniqkthcmoxrdxzlthwmzvzgrlchjgjoutegoljbbgsefrszaqlznlghwkohrzvnuatjncmplgvqznpzgdatqgcotqwkrtzmvsxjxlyirvyqlqprvrmlypzthxfzrenmymxvxxfqtegewxvtojeoydhidmjuswirkgmjdszwyfawcxpshvhhyqrddaxvygoiobrrvqqvxqtbqiuzddidtahyagwzokjcnbuktkfrcysuiotnrerlealgghhvsrzhsvsnhzekazginawfepskpdqxlaufruolpgyxifjiepstrqyxhshywawjasotmceeledvjmfpdzjvshuzacyyewhgoxbdbfhmjkjvyokbotygdthfxhdddkjujkxkrgzcsixqxitnbsvelcjikolpywjjiiubqtdidbaclupmmmtzpejztwqtuadckzdbsijvlkawgpjseetticudakzumcwxbbyvljsxtstzketoiojtsdyspxmczkzcnzxbisyektdwyzkiptbiyaaoxpqzbrdpqdqavqehjkehjqqamtikvlavaswbjzsbcicxaifksltdblepfmacxczzvvbexvibgkzgsgqntkqwvwmcjmhiogilelqdgyemkftenltgvkdtgpxrdectnmftxxwfxasjgnptajcyvfrdwqvbvzuilbbiyzpxzjghwwbzfdxakqdggahbzdlmfowfnmdpvlwuhztocqqmgwuowbqyhdmmujtjvwysivmruhgzzynhuiwtlmtsrfgloavlwvegqqanaimzgbhbjduxrppkuwwlytwwoafhtfwtnkuvlbwvgsuxjjkehgpfbnerojyjouedeyysaxngrjgbuqheyylblpsbytkmporwnqoppdxgmdhgvokvowwalrbkkoybeqxtilixogdclnjjdvgsrfufwxrilpjqhjjruuolcunpjyyoufilkcsiajsnbbfkkpchlssnohcxgdoakwnwbggdpyqszwdmnhvyznnowrncudcgcsedykgpiyikunyjuthtiwjeozhkcltedxjbiptsqdckqcwkvffdcriqqrcscvzgvijdacxqfccveyhaepfggnywecqjyrptayyabxqizueetngxclfibdgfhzofqfaseashykpxfvdajjxnveywjedqfuwybyqhbjozvgyadeaonzckdaimgodmkbklbatcljdhrcjvgmjvnlirnqfugkiqnucpwxtkixtabcvjqgeeumxhfednrneejivihpspolpppmygtemntlwapangprnzbijizbypopefcenvlzkekgecitiynvzogizhjxxzodeqkslvrvzecfgmyqklojcwtbdeacdogifqcslvqmzuthgtyrfocjkwmnamqgcyqjoscbpsprmiysbylimotymfmorewwcmfsgjvwdknpunkvoxgclzbzfnqytmwxzcphlmfrwugqksnyqvadvbfcqvcjhziibzsolxfhuozeipcakeehgjlwgoinnsyqsqgdpmnjcopkdrlqwrzeclcizmxofvexnkadynoceephxazvtzzvkcfloezvcfsprvuqijumpjwmlvieuhbglircnsxpxsgpnbhxmdmbninafxhcfkistcwiwuzuoflbiuywxkxmsnnakucremkzqijneijsqutaqsxneuczjpzulblppxrgiatmjcfbyybosydxvfwewxahaozplqxtqsibwncungkggqfbvdisaibawarkspfjhnmecraqxnyfddhygrsibwiawzkpqrayhoejfgzetzkwctxkmrunnenmezdwrduytajzhlfakpxpkubwnwkbaxngxqdqvzqoazphkvhxmgmxcptqldtmdgucyxsvxilzjdgwyptmwhjywfqiijwnrsprqjmpraodduzdlsphzzixeyhoidezyvrofffyftbkpancudkvestksaacgeceavuhcbfkwhuljkngpzbvtwfmxfofmslmpftsgaecjaptkezzgcuzzbnyjedvwohovcidcmhmmyhzeiamkxmlybjhfmeecnsxpacumliajrzqzcclzqxzsghzvndxbvxqvzmjnwmwnnoopraohzobfxbckealaxexysjlpvkciytartobuecbddeokebmdhjdaurprdtcbmcvhswdzyfcejqopucubnxbiqsztobvcdsmyopxmuzsfsiumkonyoriejhyzlvcqnoobdnpynkdhsatfqidebllnulmfgoyvcmyiapgpzlwsnrzebckfpvslietovrlzfjhhbnyabuuonturxfwocqalutbrmnrtyybzozcpwwflsacphaejqewnzyennvgnwhnkjrbfngshivxrxbdohzbixhxkddyznnlwgmdtuvdfsawqdzembhuyorltwlujafhgrkboietaerqjrwvsfrsukfnhqisspayhmcvugqxnhpwaouutlnpwudflnxfczglmiiioyfdgxcilwdejqufkzmxokfsllextoijppnxmrfxnicwayenxqkncpfoclnvaxfpnumznrxacbycbepaxcnbtsrwghrgeyxrulrheojgrklsqasnehrybiuhpnpuoolizesgudolnzfgcztggmeivapkohgcvumvygdtkrezrmftlbbsngckgrxwadawzptyvwrhnxjgjobvrdphlrttkqslwshvhatfymmnkvutmxqfcfmnwijjybuutbsddlkbywqiukdikunmbccakljimdfhgxmlkwmivespryxbumnvorvacgjqjqyrnmczjqievctmasnwecsvupvyygpjwpblbdlmwvqrxlfafuwmyqhuictgjkpfbsteyeruzjnyvsacoxompvjzychjozoprhtpnmlmwyntsnvimkxehgdhklqymhpdqkvexgsvhfobvjkhvhlfnpmzcdxokotcyqgxzbsgigjdsvlpewutnjsrmrhyfdagtjfskyasgmwahjqmhmfxvaojryjxbmfwvkphirbrdzrnijzqygnvgdfydqxeccdzmuivlkorjfeurfkplzkuersiiromtroflwczgqqsyumpzyemzogdianqreemvsujrwkxparnwfexdileysiguxyobfazxukotuokwhzsndrsncxlwhuteuhgzjhzgrpzlflhnkbcnuuayrnxajqfeznfkugqlwrwbcfqogsbcndagrxhapogobobxutislgwplmetfhvulxaevjgkxpbadcxzvfuinqaacgtjnqfaoielrlvrayrfapgywaikqimvoigeymgoulblyzcaxwhalnajoitgribhqinouufqhgbfhgffcmfpbhyppuwiczqshfidzptgyxnffskjgrykywzqsxyuxqogwxmvohemgrslmeuuyuewtgoldnicdwlzvxxmgbynusagxxdvrhtkniytvgvaegacfzomcobwhbfeaibsruchccazixapectldhzfvadcekieujyoedvifvkqsmfyoykthlaeofjsqrymbxahavrhsbxnneldexwnjwsxcbruurivqjesgwabxzonebqkbnymlqlptejnvslmdrelngongcckgswjhuvtmgifmuvhoivrzaepitcoxgafyxogrjberlldfgnvqioqktftojhlpirphfxyryekmsotadprldhyworkxayokpdrwbspbyanqqjrtyigbpeafxkcakqmbveyyypawppnhyeawojafpakpmmpxebybhyahocefrtnsxpqnaqssqchfqycubcxldxsrzwytpnnofdbhutzmxgrngvjiahtdgnwikubbkosptvynrycogvcntnxtwswdfslrmovyenpxionzmpoumshfhgyeauhgmuzbiuzojplsfyttpjncdxhldgpecympsnscirsridlpefivqwxuthfypuerusiogasoukhepvutccpsyomtvrumnygjtoxzrpplbyprtjmvodqmscipwecleivxyuwpmnanmsgfdvdrytgsxoivumhywewwyummiocugkbkfedezjwzzgutubssfopgibusrwmahommupswzrvyzpsutmmaadikgddyzryihmxebpaagxbgovchhqkhustavyaxqyhxkebowdqearkpmoytficbdybawczmchmplpfhtvmtnykbplxwtzxyzazweykhfwytmdchaqcnrnriyoetnbunbtlgrvpzupuiuwruptkgiboipucevwtyregkcvjymfigczbtslzbmpjdjnhglbgcfnpjkyhxgpfioibjvcmjtvmelumwvsbchqmsqvrwnwgdhjmcnymgwymhsadptguawiupdnnskuwrdkttlhzhgoqaovsjcmmauirzwfuizqbecwxnezwkpmmdiepmqdmmleohjirkysocpmqtnmfcbrhjwwvobjdnnrwyzoizgxbxltqaivcjnjulipzjyeyovxmulxvtwzrhsjhaflluufheuiqvnolilxfywcusbnzwwiydvkzspgwmpmjcdumqtrrqunixaktyuseqcditkefbtqfykrogjfwfuecwqwvlobbsellqprtkjyiuqzabeygbekxvgsiwvloawasntmyckiyahaboyjpdumachibctpeprxemjcrvlrwssziqlxvhmxjtfkxaccrvzwikybflsdgkfodsoazayktdxqgzuxwttefuflhaqpkxgnpuqouobptyhzzexvxscfmjswjiluirjxlzohppyjniimmfjlalqmviigtucbnoyzpmifdhoqpwebeqoebfsynbhixjjmxklnwuscdisuezxkplosqhtgkaojjyvhijwgfqiiydeccbntmdldmelwezhqzfxjovqvlafjfjnjkacwgqbsuorboarpfqzvlrqyrvhzeuiqxlpdbqvxfoyvprkujjsucisugbvkwdbtoqyrivrpkrmbjzvsipplyjheneqjhteyleruzillaymlxkfhzuuzgddthuerpkpbogvppidripcfbhpbelamrghyclprxgsnnpceyfvgxzoygfbmqcyjkfimszdpiycxnhbnoywnxkmfrpsjrqtbwdpqetgmrkjgrmuikqvhcjpvzhesxzwvclmjguvzehgytagesdnwncrolxgjxcgboukwqgwvpctieboygcutgljskqdhuljiivhyddtshoblrpjytftcqdwcvbkpmvawqhvukqorhpeahpacuugmzeowfyluvnqounkgeyznqfnzuodokkalorhwruqniibewllclmpbseamsedeqfpgwycotudddghbtsdehuizyintoqzeypnuppkikpnpvvqopvvwrdxrnlmedmibdvysnkdzaqoxngmddjzumxnbkafnmqrrnrjabozbfpzsvnxyyxukwiniktxwjopwfyzjpamuqnoncomanimjqatatqyefncmodvdeizwxpjadxaqgnbwnuzilzmspqeduciamjwjahjefkwlxyjmukuhkizzygeukmwwxshxarbfdascabouoieysfxslbnxpjtmebjgunnxnfbnipjwzpwrvvjgyygnkzbqcnwyalxpsyeanpzofxfatrirrohdqituvrtxcqoursxgkyvpvcrovzinqpsgzmaxfvwkoleffdlpbiezlxpgxxvnmovocxljvhtjsaqydbphkwgxtvfqtbfhrcvvciexqygkywkdzaklysirookjrrsiuqdwyjvqhddhbnlapxonqyfgorpfijpczuayexqnatvbjieyfsovqvbfmsmwcczbybbczuqznndyvhzaznyrkbyywnuaptdnxfsybizoxcpsloumbsenwelsrfsibvyycqyfaxwxclrnzlacggpckawcfqkgnkgsaexaetzgeqtdcvfibummwkqcackpnrhnxfqbyrjfidimaqwcmiojselugvjvorjmybpyszdaeooegkgsuwbocoilmugcnpqlsgjlhpnlfcrloadjwhxzxiklesoriecamnntebejfwutyacujcvgmhuqakhiolkbaawfbbqgzlzxnetwipewwymwkvgzitcktyrwbiecvdbijvgtkkpildhvapwkiaxdbozcydhtjidudlqpyhallhgnwfahhxminmnmruhcenzkypzwwbhjiqzhxzoeyaplocxiyhmeulosaorzrykaqjjnkzuibjuqntancmrwygrawkbnkmnbvyqixkqzvmpkirxkdpjdvagtmhgwvwxtuqbscrrygikoziyexjkulspxzvuxrtqojrgmkzmqjygkgfqfqabcsqzumtrfnjvyabmmcaflzlvfsmnjooljhkdvewatfwrhzetegypfmnnebanpqyaxjdspbvkgtbpuhlyqjqvxdicgkpxbqyabbvsdscllfbfpmgfxwaxblzhxqeaicbjgydlqfyblbicnohnkjklulusdzumdvvjvzwlgvotwxvmncbymnliygcbhxnkulwqmsdsnsompjycmzcaoqkmynpfmfrgsnyegcyvumhlyhpkismwiwkglanxfegxsedaidxcshnqofaxxovhkgpwgcvngbmagraouytmficvneumuqthwifekattchtkywauwtjbenyrsteolzvjkapwbipfrlrrhrldnwgrkekezqskqqtcqiytsoajbrcijonymvpwbbcbsvnkljmdtkxmazxbralcqaacvrbzsdamapwnyktuxsgzrfdifokxrmcmdflwknilfhaftvzqnhsfnvpujcuaowpsbcqlsayxhbcdwctkjlryiitskpuzlltoojbgjadtdhwzlrlxfevnnqhzfeasptgdeilqkqlnyhojacghicvvuexcixuyrbdxjpnvfyifhypkavrlzoiwvfyddsdwvhtgyjbfjlltkcdmzwxbngxilxnqprolairatthcesxqwadwzcxmiwwwtjoicdvcnpegkmkqgihdkmzjoyxzuvxnflxhqtmdkqlucwkjgroqfnculbvhxsueftlwozbyqnsulffrwtjeilyvptcmnyqssdqgdsfvhzrsezlduuhdihyxcdjpbbjteaajuhebiyvnxgsrazuigvhiyqzbtivykxjegohooeblmtcnuzxcwhkuzlxtusterclxsumgbprnlwchvckrjwniikbcfwiwzvwtsiatztimplumnefyaugihkmmixkjugdmqdhqyseodycsckqfeypnkebvbmexuhklmtdlljbqidkmncrudjhnnjiqxnntwzgjtlugvvzdajpqmjmpstehepxdekxakdjfpfnmampdwgtkphbjafqhwpmaalbkrmriseuurjzprubjbcuejnngczgcljoeyhmqmgmfrmwiixtkbookbbsdczinkwriefaslpxedvnlsivtwjfxmydpzleljyupduhrlgvobkavtvqrhwrvwukxfriqpcguzpnkyjbbvbxqynihlzdjtpgagpqxtyuuqhhoqipojoehempplubgjhgqyzpuzjorrvhjfxxoncyrqpjcjkkuttksscotlclcasofrlwhpwyglhkwtuqnndhhfvbqzovbijhaufjmbhsmrcikwazkdgriduzdiwerfntbscntlfhejrrgsqsvzjgcgfhodohidcjygztugbyqspwmgqihbolhvvyajhioktmssgmzjlpdcnqkdareqdmnymnjtvzfqmyjukkdxbgaqyktyezohnbhzqsvlracfynzlzeiankslxlmbmckaerbujwicxmixbjiaorcdduqahcdvfnvlgzhrxruudcsgncibvmgzixbpzhlewirdjzwhqqdwuxciallvzswipyzqfmvbxmggndpevtcsqecsrnorhkbwkaprnkvkybsogisebuwtaymuncnxoovzokqdulnvpgjxodbrzxmbxavnciktwfsnqkqmygjpmsmcxovynjankvamekhcrzphmiumofbcypgxfbwtkygwtilzuselutvgdrurwvtwmzuscslpqtlldwlxprkjkfrqwlhtidpuelmhfzyvsjjviuuznfkzkbpjoxewavqghdnmcnkxztuhppicwsbitrrjqvfsrxyacoohbyeatajkprmnjqwejnnblutcsteuhsblthnmixxzqlnadjgoywpjqknkerhnmkafsotclsddgqdjbmaakplcabnguuvggwnykhcxzgafwgraurceingkqtslporwkfwwozvnfxvdfofzhhdpxmcnhuyzisxuztsnuncblzhqnmsuwxmtjoitihstbpnakgpfvrigrpzectbyqptcdbvnkpgleunoccvxuegntfrxauxsjquourcegksmefbikygeemratkxthxlspihjzlqiviucpxkzwqfaeyaxlassxgkoqtypeoxcyuenropphwsnvuniufatnmidiivoyuqyounilcxuzphwkuegcgcpumveuqtumlsbgfltiipjawhmtlsvtumngjucbnwoyorgucbekqpmpwykjrhcntrwflygyxwznnhjpjnczeoqanajghltdfpiqqqrpnscazmsibukgkagxdsfkfzpkqzdiquxdmafnmzwpvgvgieflwlybmpocprlflikzkrmyrkomsjsbnaollonzebbtsoyfzkgjbuisfwhxhbaxbpiofxnjareufebeohqqeykjwrif", diff --git a/Algorithms/0078.subsets/README.md b/Algorithms/0078.subsets/README.md index 816e08959..19d53ec26 100755 --- a/Algorithms/0078.subsets/README.md +++ b/Algorithms/0078.subsets/README.md @@ -1,6 +1,7 @@ # [78. Subsets](https://leetcode.com/problems/subsets/) ## 题目 + Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. @@ -8,7 +9,7 @@ Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,3], a solution is: -``` +```text [ [3], [1], @@ -19,8 +20,4 @@ If nums = [1,2,3], a solution is: [1,2], [] ] -``` -## 解题思路 -先`run`一下,观察输出结果的队形。再用递归的方式解题。 - -见程序注释 +``` \ No newline at end of file diff --git a/Algorithms/0078.subsets/subsets.go b/Algorithms/0078.subsets/subsets.go index 59cf72c08..117f5e565 100755 --- a/Algorithms/0078.subsets/subsets.go +++ b/Algorithms/0078.subsets/subsets.go @@ -1,26 +1,11 @@ package problem0078 -import ( - "sort" -) - func subsets(nums []int) [][]int { - res := [][]int{} - - recur(nums, []int{}, &res) - - return res -} - -func recur(nums, temp []int, res *[][]int) { - l := len(nums) - if l == 0 { - sort.Ints(temp) - *res = append(*res, temp) - return + res := make([][]int, 1, 1024) + for _, n := range nums { + for _, r := range res { + res = append(res, append([]int{n}, r...)) + } } - - recur(nums[:l-1], temp, res) - - recur(nums[:l-1], append([]int{nums[l-1]}, temp...), res) + return res } diff --git a/Algorithms/0078.subsets/subsets_test.go b/Algorithms/0078.subsets/subsets_test.go index 80ba275e4..352d80d6e 100755 --- a/Algorithms/0078.subsets/subsets_test.go +++ b/Algorithms/0078.subsets/subsets_test.go @@ -2,6 +2,7 @@ package problem0078 import ( "fmt" + "sort" "testing" "github.com/stretchr/testify/assert" @@ -32,11 +33,11 @@ func Test_Problem0078(t *testing.T) { []int{1, 2, 3}, }, ans{[][]int{ - []int{}, + nil, []int{1}, []int{2}, - []int{1, 2}, []int{3}, + []int{1, 2}, []int{1, 3}, []int{2, 3}, []int{1, 2, 3}, @@ -45,41 +46,41 @@ func Test_Problem0078(t *testing.T) { question{ para{ - []int{9,0,3,5,7}, + []int{9, 0, 3, 5, 7}, }, ans{[][]int{ - []int{}, - []int{9}, + nil, []int{0}, - []int{0,9}, []int{3}, - []int{3,9}, - []int{0,3}, - []int{0,3,9}, []int{5}, - []int{5,9}, - []int{0,5}, - []int{0,5,9}, - []int{3,5}, - []int{3,5,9}, - []int{0,3,5}, - []int{0,3,5,9}, []int{7}, - []int{7,9}, - []int{0,7}, - []int{0,7,9}, - []int{3,7}, - []int{3,7,9}, - []int{0,3,7}, - []int{0,3,7,9}, - []int{5,7}, - []int{5,7,9}, - []int{0,5,7}, - []int{0,5,7,9}, - []int{3,5,7}, - []int{3,5,7,9}, - []int{0,3,5,7}, - []int{0,3,5,7,9}, + []int{9}, + []int{0, 3}, + []int{0, 5}, + []int{0, 7}, + []int{0, 9}, + []int{3, 5}, + []int{3, 7}, + []int{3, 9}, + []int{5, 7}, + []int{5, 9}, + []int{7, 9}, + []int{0, 3, 5}, + []int{0, 3, 7}, + []int{0, 3, 9}, + []int{0, 5, 7}, + []int{0, 5, 9}, + []int{0, 7, 9}, + []int{3, 5, 7}, + []int{3, 5, 9}, + []int{3, 7, 9}, + []int{5, 7, 9}, + []int{0, 3, 5, 7}, + []int{0, 3, 5, 9}, + []int{0, 3, 7, 9}, + []int{0, 5, 7, 9}, + []int{3, 5, 7, 9}, + []int{0, 3, 5, 7, 9}, }}, }, @@ -89,7 +90,35 @@ func Test_Problem0078(t *testing.T) { for _, q := range qs { a, p := q.ans, q.para fmt.Printf("~~%v~~\n", p) + sorted(a.one) + ans := subsets(p.nums) + sorted(ans) + ast.Equal(a.one, ans, "输入:%v", p) + } +} + +func sorted(iss [][]int) { + for i := range iss { + sort.Ints(iss[i]) + } + sort.Slice(iss, func(i int, j int) bool { + if len(iss[i]) == len(iss[j]) { + for k := range iss[i] { + if iss[i][k] > iss[j][k] { + return false + } + if iss[i][k] < iss[j][k] { + return true + } + } + } + return len(iss[i]) < len(iss[j]) + }) + +} - ast.Equal(a.one, subsets(p.nums), "输入:%v", p) +func Benchmark_subsets(b *testing.B) { + for i := 1; i < b.N; i++ { + subsets([]int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) } } diff --git a/Algorithms/0080.remove-duplicates-from-sorted-array-ii/README.md b/Algorithms/0080.remove-duplicates-from-sorted-array-ii/README.md index 04e62ffa8..d19324513 100755 --- a/Algorithms/0080.remove-duplicates-from-sorted-array-ii/README.md +++ b/Algorithms/0080.remove-duplicates-from-sorted-array-ii/README.md @@ -1,16 +1,46 @@ # [80. Remove Duplicates from Sorted Array II](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/) ## 题目 -Follow up for "Remove Duplicates": -What if duplicates are allowed at most twice? +Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. -For example, -Given sorted array nums = `[1,1,1,2,2,3]`, +Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. +Example 1: -Your function should return length = `5`, with the first five elements of nums being `1`, `1`, `2`, `2` and `3`. It doesn't matter what you leave beyond the new length. +```text +Given nums = [1,1,1,2,2,3], -## 解题思路 +Your function should return length = 5, with the first five elements of nums being 1, 1, 2, 2 and 3 respectively. -见程序注释 +It doesn't matter what you leave beyond the returned length. +``` + +Example 2: + +```text +Given nums = [0,0,1,1,1,1,2,3,3], + +Your function should return length = 7, with the first seven elements of nums being modified to 0, 0, 1, 1, 2, 3 and 3 respectively. + +It doesn't matter what values are set beyond the returned length. +``` + +Clarification: + +Confused why the returned value is an integer but your answer is an array? + +Note that the input array is passed in by reference, which means modification to the input array will be known to the caller as well. + +Internally you can think of this: + +```text +// nums is passed in by reference. (i.e., without making a copy) +int len = removeDuplicates(nums); + +// any modification to nums in your function would be known by the caller. +// using the length returned by your function, it prints the first len elements. +for (int i = 0; i < len; i++) { + print(nums[i]); +} +``` diff --git a/Algorithms/0080.remove-duplicates-from-sorted-array-ii/remove-duplicates-from-sorted-array-ii.go b/Algorithms/0080.remove-duplicates-from-sorted-array-ii/remove-duplicates-from-sorted-array-ii.go index 4bef6499b..c6bd1ade5 100755 --- a/Algorithms/0080.remove-duplicates-from-sorted-array-ii/remove-duplicates-from-sorted-array-ii.go +++ b/Algorithms/0080.remove-duplicates-from-sorted-array-ii/remove-duplicates-from-sorted-array-ii.go @@ -1,18 +1,31 @@ package problem0080 -func removeDuplicates(nums []int) int { - length := len(nums) - if length <= 2 { - return length - } +func removeDuplicates(a []int) int { + size := len(a) + + i := 2 - res := 2 - for i := 2; i < length; i++ { - if nums[i] != nums[res-2] { - nums[res] = nums[i] - res++ + for j := i; j < size; j++ { + if a[i-2] != a[j] { + a[i] = a[j] + i++ } } - return res + return i } + +// 可以把 a 想象成一层一层摆好的木板,从下往上,索引值变大 +// 重复的多余木板被抽掉,上面的木板就会下落 +// +// i 始终指向下一个合格木板要放置的位置 +// j 始终指向下一个需要检查的木板的位置 +// +// 注意前提条件: a is sorted +// +// a[i-2] != a[j] 说明 a[j] 是合格的木板, +// a[j] 重复次数还没有超过 2 次 +// +// a[i] = a[j] 就是木板下落 +// +// 到最后,i 就成了所有合格木板的数量,也就是 a 合格部分的长度 diff --git a/Algorithms/0082.remove-duplicates-from-sorted-list-ii/README.md b/Algorithms/0082.remove-duplicates-from-sorted-list-ii/README.md index 8dc831fd9..473e4ce11 100755 --- a/Algorithms/0082.remove-duplicates-from-sorted-list-ii/README.md +++ b/Algorithms/0082.remove-duplicates-from-sorted-list-ii/README.md @@ -1,13 +1,17 @@ # [82. Remove Duplicates from Sorted List II](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/) -## 题目 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. +Example 1: + +```text +Input: 1->2->3->3->4->4->5 +Output: 1->2->5 ``` -For example, -Given 1->2->3->3->4->4->5, return 1->2->5. -Given 1->1->1->2->3, return 2->3. -``` -## 解题思路 -见程序注释 +Example 2: + +```text +Input: 1->1->1->2->3 +Output: 2->3 +``` diff --git a/Algorithms/0082.remove-duplicates-from-sorted-list-ii/remove-duplicates-from-sorted-list-ii.go b/Algorithms/0082.remove-duplicates-from-sorted-list-ii/remove-duplicates-from-sorted-list-ii.go index 3219dd9a4..ac304737c 100755 --- a/Algorithms/0082.remove-duplicates-from-sorted-list-ii/remove-duplicates-from-sorted-list-ii.go +++ b/Algorithms/0082.remove-duplicates-from-sorted-list-ii/remove-duplicates-from-sorted-list-ii.go @@ -12,22 +12,15 @@ func deleteDuplicates(head *ListNode) *ListNode { return head } - // 处理 head 重复情况 - // 上面刚刚检查过了,head != nil && head.Next != nil + // 要么 head 重复了,那就删除 head if head.Val == head.Next.Val { - val := head.Val - head = head.Next.Next - - for head != nil && head.Val == val { + for head.Next != nil && head.Val == head.Next.Val { head = head.Next } - - // 值为 val 的 node,已经全部删除了 - return deleteDuplicates(head) + return deleteDuplicates(head.Next) } - // 处理 head 后面元素出现重复的情况 + // 要么 head 不重复,递归处理 head 后面的节点 head.Next = deleteDuplicates(head.Next) - return head } diff --git a/Algorithms/0084.largest-rectangle-in-histogram/README.md b/Algorithms/0084.largest-rectangle-in-histogram/README.md index b827f8ad1..801ea8402 100755 --- a/Algorithms/0084.largest-rectangle-in-histogram/README.md +++ b/Algorithms/0084.largest-rectangle-in-histogram/README.md @@ -1,6 +1,7 @@ # [84. Largest Rectangle in Histogram](https://leetcode.com/problems/largest-rectangle-in-histogram/) ## 题目 + Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. ![histogram](histogram.png) @@ -11,15 +12,17 @@ Above is a histogram where width of each bar is 1, given height = [2,1,5,6,2,3]. The largest rectangle is shown in the shaded area, which has area = 10 unit. -``` +```text For example, Given heights = [2,1,5,6,2,3], return 10. ``` ## 解题思路 + 从[这里](http://www.cnblogs.com/ganganloveu/p/4148303.html)复制了以下思路: -``` + +```text 1、如果已知height数组是升序的,应该怎么做? 比如1,2,5,7,8 @@ -56,4 +59,5 @@ return 10. 综上所述,result=10 ``` -具体的解题过程与上面不同,详见程序注释 + +具体的解题过程与上面不同,详见程序注释 \ No newline at end of file diff --git a/Algorithms/0084.largest-rectangle-in-histogram/largest-rectangle-in-histogram.go b/Algorithms/0084.largest-rectangle-in-histogram/largest-rectangle-in-histogram.go index 5f0e5eb88..a30bfd0eb 100755 --- a/Algorithms/0084.largest-rectangle-in-histogram/largest-rectangle-in-histogram.go +++ b/Algorithms/0084.largest-rectangle-in-histogram/largest-rectangle-in-histogram.go @@ -1,45 +1,51 @@ package problem0084 func largestRectangleArea(heights []int) int { - // 在 h 结尾添加 -1 可以让 for 循环中,求解 area 的逻辑一致 - h := append(heights, -1) - n := len(h) - - var maxArea, height, left, right, area int - // 如果已知heights数组是升序的,应该怎么做? - // 比如1,2,5,7,8 - // 那么就是(1*5) vs. (2*4) vs. (5*3) vs. (7*2) vs. (8*1) - // 也就是max(height[i]*(size-i)) - // 使用栈的目的就是构造这样的升序序列,按照以上方法求解。 - var stack []int - // stack 中存的是 h 的元素的索引号 - // stack 中索引号对应的 h 中的值,是递增的。 + // 在 heights 中原本是非负的数字 + // 再首尾添加了 -2 和 -1 后,简化 for 循环中 begin 的计算 + heights = append([]int{-2}, heights...) + heights = append(heights, -1) + + size := len(heights) + + // stack 中存的是 heights 的元素的索引号 + // stack 中索引号对应的 heights 中的值,是递增的。 // e.g. // stack = []int{1,3,5},那么 - // h[1] <= h[3] <= h[5] + // heights[1] < heights[3] < heights[5] + stack := make([]int, 1, size) + // 把 heights[0] 的索引号,已经放入了 stack + // end 从 1 开始 + end := 1 - for right < n { - if len(stack) == 0 || h[stack[len(stack)-1]] <= h[right] { - stack = append(stack, right) - right++ + res := 0 + for end < size { + // end 指向了新高,就把 end 放入 stack 后,指向下一个 + if heights[stack[len(stack)-1]] < heights[end] { + stack = append(stack, end) + end++ continue } - height = h[stack[len(stack)-1]] - stack = stack[:len(stack)-1] + begin := stack[len(stack)-2] + index := stack[len(stack)-1] + height := heights[index] + // area 是 heights(begin:end) 之间的最大方块的面积,因为 + // anyone of heights(begin:index) > height > anyone of heights(index:end) + area := (end - begin - 1) * height - if len(stack) == 0 { - left = -1 - } else { - left = stack[len(stack)-1] - } + res = max(res, area) - // area = h[left+1:right] * min(h[left+1:right]) - area = (right - left - 1) * height - if maxArea < area { - maxArea = area - } + // h 的索引号已经没有必要留在 stack 中了 + stack = stack[:len(stack)-1] } - return maxArea + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b } diff --git a/Algorithms/0084.largest-rectangle-in-histogram/largest-rectangle-in-histogram_test.go b/Algorithms/0084.largest-rectangle-in-histogram/largest-rectangle-in-histogram_test.go index b2956f2e1..2e3daa9e6 100755 --- a/Algorithms/0084.largest-rectangle-in-histogram/largest-rectangle-in-histogram_test.go +++ b/Algorithms/0084.largest-rectangle-in-histogram/largest-rectangle-in-histogram_test.go @@ -27,6 +27,24 @@ func Test_Problem0084(t *testing.T) { qs := []question{ + question{ + para{ + []int{1, 100, 101, 1}, + }, + ans{ + 200, + }, + }, + + question{ + para{ + []int{2, 2, 2, 2, 2}, + }, + ans{ + 10, + }, + }, + question{ para{ []int{6, 5, 4, 3, 2, 1}, diff --git a/Algorithms/0090.subsets-ii/README.md b/Algorithms/0090.subsets-ii/README.md index 0338ee5c9..38f7cf3e1 100755 --- a/Algorithms/0090.subsets-ii/README.md +++ b/Algorithms/0090.subsets-ii/README.md @@ -1,14 +1,13 @@ # [90. Subsets II](https://leetcode.com/problems/subsets-ii/) -## 题目 Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. - For example, -If nums = [1,2,2], a solution is: +```text +If nums = [1,2,2], a solution is: [ [2], @@ -18,8 +17,4 @@ If nums = [1,2,2], a solution is: [1,2], [] ] - -## 解题思路 -观察题目输出结果的规律后,利用dfs解题 - -见程序注释 +``` diff --git a/Algorithms/0090.subsets-ii/subsets-ii.go b/Algorithms/0090.subsets-ii/subsets-ii.go index aaacb92e7..7591295d7 100755 --- a/Algorithms/0090.subsets-ii/subsets-ii.go +++ b/Algorithms/0090.subsets-ii/subsets-ii.go @@ -2,27 +2,29 @@ package problem0090 import "sort" -func subsetsWithDup(nums []int) [][]int { +func subsetsWithDup(A []int) [][]int { res := [][]int{} - sort.Ints(nums) + sort.Ints(A) var dfs func(int, []int) - dfs = func(idx int, temp []int) { - t := make([]int, len(temp)) - copy(t, temp) - // 没有以上两行,答案就是错的 - // 因为temp的底层数组在递归过程中,不停地修改 - // 程序结束时,temp的底层数组的值,全部是 nums 的最大值。 - res = append(res, t) - - for i := idx; i < len(nums); i++ { - if i == idx || nums[i] != nums[i-1] { - dfs(i+1, append(temp, nums[i])) + dfs = func(index int, temp []int) { + res = append(res, temp) + n := len(temp) + 1 + for i := index; i < len(A); i++ { + // if 语句的含义是, + // 在 A[index:] 中,每个数字只能附着到 temp 中一次 + // 判断方法是 A[i] != A[i-1] + // 但是 A[index] == A[index-1] 也没有关系 + // 因为 A[index-1] 不在 A[index:] 中 + // 而且,需要执行 A[i]!=A[i-1] 时, + // 可以肯定 i>=1,所以,不需要验证 i-1>=0 + if i == index || A[i] != A[i-1] { + dfs(i+1, append(temp, A[i])[:n:n]) } } } - temp := make([]int, 0, len(nums)) + temp := make([]int, 0, 0) dfs(0, temp) return res diff --git a/Algorithms/0090.subsets-ii/subsets-ii_test.go b/Algorithms/0090.subsets-ii/subsets-ii_test.go index b107790fd..62dccfe7f 100755 --- a/Algorithms/0090.subsets-ii/subsets-ii_test.go +++ b/Algorithms/0090.subsets-ii/subsets-ii_test.go @@ -1,76 +1,43 @@ package problem0090 import ( - "fmt" "testing" "github.com/stretchr/testify/assert" ) -type question struct { - para - ans -} +// tcs is testcase slice +var tcs = []struct { + A []int + ans [][]int +}{ -// para 是参数 -type para struct { - nums []int -} + { + []int{1, 2, 2}, + [][]int{[]int{}, []int{1}, []int{1, 2}, []int{1, 2, 2}, []int{2}, []int{2, 2}}, + }, -// ans 是答案 -type ans struct { - one [][]int -} + { + []int{2, 1, 2, 1, 3}, + [][]int{{}, {1}, {1, 1}, {1, 1, 2}, {1, 1, 2, 2}, {1, 1, 2, 2, 3}, {1, 1, 2, 3}, {1, 1, 3}, {1, 2}, {1, 2, 2}, {1, 2, 2, 3}, {1, 2, 3}, {1, 3}, {2}, {2, 2}, {2, 2, 3}, {2, 3}, {3}}, -func Test_Problem0090(t *testing.T) { - ast := assert.New(t) + }, - qs := []question{ + // 可以有多个 testcase +} - question{ - para{ - []int{1, 2, 2}, - }, - ans{ - [][]int{ - []int{}, - []int{1}, - []int{1, 2}, - []int{1, 2, 2}, - []int{2}, - []int{2, 2}, - }, - }, - }, +func Test_subsetsWithDup(t *testing.T) { + ast := assert.New(t) - question{ - para{ - []int{1, 2, 2, 3}, - }, - ans{ - [][]int{ - []int{}, - []int{1}, - []int{1, 2}, - []int{1, 2, 2}, - []int{1, 2, 2, 3}, - []int{1, 2, 3}, - []int{1, 3}, - []int{2}, - []int{2, 2}, - []int{2, 2, 3}, - []int{2, 3}, - []int{3}, - }, - }, - }, - // 如需多个测试,可以复制上方元素。 + for _, tc := range tcs { + ast.Equal(tc.ans, subsetsWithDup(tc.A), "输入:%v", tc) } +} - for _, q := range qs { - a, p := q.ans, q.para - fmt.Printf("~~%v~~\n", p) - - ast.Equal(a.one, subsetsWithDup(p.nums), "输入:%v", p) +func Benchmark_subsetsWithDup(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + subsetsWithDup(tc.A) + } } } diff --git a/Algorithms/0091.decode-ways/README.md b/Algorithms/0091.decode-ways/README.md index afd426aef..fbfdd5be1 100755 --- a/Algorithms/0091.decode-ways/README.md +++ b/Algorithms/0091.decode-ways/README.md @@ -1,24 +1,28 @@ # [91. Decode Ways](https://leetcode.com/problems/decode-ways/) -## 题目 -A message containing letters from `A-Z` is being encoded to numbers using the following mapping: +A message containing letters from A-Z is being encoded to numbers using the following mapping: -``` +```text 'A' -> 1 'B' -> 2 ... 'Z' -> 26 ``` -Given an encoded message containing digits, determine the total number of ways to decode it. +Given a non-empty string containing only digits, determine the total number of ways to decode it. -``` -For example, -Given encoded message "12", -it could be decoded as "AB" (1 2) or "L" (12). -The number of ways decoding "12" is 2. +Example 1: + +```text +Input: "12" +Output: 2 +Explanation: It could be decoded as "AB" (1 2) or "L" (12). ``` -## 解题思路 +Example 2: -见程序注释 +```text +Input: "226" +Output: 3 +Explanation: It could be decoded as "BZ" (2 26), "VF" (22 6), or "BBF" (2 2 6). +``` diff --git a/Algorithms/0091.decode-ways/decode-ways.go b/Algorithms/0091.decode-ways/decode-ways.go index e76277d92..8fbeb995e 100755 --- a/Algorithms/0091.decode-ways/decode-ways.go +++ b/Algorithms/0091.decode-ways/decode-ways.go @@ -1,60 +1,25 @@ package problem0091 func numDecodings(s string) int { - n := len(s) - if n == 0 { + if s[0] == '0' { return 0 } + n := len(s) dp := make([]int, n+1) - // dp[i] 表示 s[:i+1] 的组成方式数 - dp[0], dp[1] = 1, one(s[0:1]) - + // dp[i] 表示 s[:i] 的组成方式数 + dp[0], dp[1] = 1, 1 + lastOne, lastTwo := int(s[0]-'0'), 0 for i := 2; i <= n; i++ { - w1, w2 := one(s[i-1:i]), two(s[i-2:i]) - dp[i] = dp[i-1]*w1 + dp[i-2]*w2 - if dp[i] == 0 { - // 子字符串 s[:i+1] 的组成方式数为 0 - // 则,s 的组成方式数肯定也为 0 - // 这时可以提前结束 - return 0 + last := int(s[i-1] - '0') + lastOne, lastTwo = last, lastOne*10+last + if 1 <= lastOne { + dp[i] = dp[i-1] + } + if 10 <= lastTwo && lastTwo <= 26 { + dp[i] += dp[i-2] } } return dp[n] } - -// 检查 s 是否为合格的单字符 -// len(s) == 1 -// 合格, 返回 1 -// 不合格, 返回 0 -// 注意: -// 题目保证了 s 只含有数字 -func one(s string) int { - if s == "0" { - return 0 - } - return 1 -} - -// 检查 s 是否为合格的双字符 -// len(s) == 2 -// 合格, 返回 1 -// 不合格, 返回 0 -// 注意: -// 题目保证了 s 只含有数字 -func two(s string) int { - switch s[0] { - case '1': - return 1 - case '2': - if s[1] == '7' || s[1] == '8' || s[1] == '9' { - return 0 - } - return 1 - default: - // '3' <= s[0] && s[0] <= '9',或 - // s[0] == '0' - return 0 - } -} diff --git a/Algorithms/0091.decode-ways/decode-ways_test.go b/Algorithms/0091.decode-ways/decode-ways_test.go index aff548692..52ba5c328 100755 --- a/Algorithms/0091.decode-ways/decode-ways_test.go +++ b/Algorithms/0091.decode-ways/decode-ways_test.go @@ -1,214 +1,132 @@ package problem0091 import ( - "fmt" "testing" "github.com/stretchr/testify/assert" ) -type question struct { - para - ans +// tcs is testcase slice +var tcs = []struct { + s string + ans int +}{ + + { + "203", + 1, + }, + + { + "546313216586746123648561321321564321657651231365456475642312356486765123156465132546543213546316543465465465465427", + 5038848, + }, + + { + "027", + 0, + }, + + { + "27", + 1, + }, + + { + "1", + 1, + }, + + { + "119", + 3, + }, + + { + "2011", + 2, + }, + + { + "1192", + 3, + }, + + { + "1102", + 1, + }, + + { + "1128", + 3, + }, + + { + "1", + 1, + }, + + { + "12", + 2, + }, + + { + "121", + 3, + }, + + { + "1212", + 5, + }, + + { + "12121", + 8, + }, + + { + "121212", + 13, + }, + + { + "1212121", + 21, + }, + + { + "12121212", + 34, + }, + + { + "12", + 2, + }, + + { + "226", + 3, + }, + + // 可以有多个 testcase } -// para 是参数 -type para struct { - s string -} - -// ans 是答案 -type ans struct { - one int -} - -func Test_Problem0091(t *testing.T) { +func Test_numDecodings(t *testing.T) { ast := assert.New(t) - qs := []question{ - - question{ - para{ - "27", - }, - ans{ - 1, - }, - }, - question{ - para{ - "", - }, - ans{ - 0, - }, - }, - - question{ - para{ - "0", - }, - ans{ - 0, - }, - }, - - question{ - para{ - "1", - }, - ans{ - 1, - }, - }, - - question{ - para{ - "203", - }, - ans{ - 1, - }, - }, - - question{ - para{ - "119", - }, - ans{ - 3, - }, - }, - question{ - para{ - "2011", - }, - ans{ - 2, - }, - }, - - question{ - para{ - "1192", - }, - ans{ - 3, - }, - }, - - question{ - para{ - "1102", - }, - ans{ - 1, - }, - }, - - question{ - para{ - "1100", - }, - ans{ - 0, - }, - }, - - question{ - para{ - "1190", - }, - ans{ - 0, - }, - }, - - question{ - para{ - "1128", - }, - ans{ - 3, - }, - }, - - question{ - para{ - "1", - }, - ans{ - 1, - }, - }, - - question{ - para{ - "12", - }, - ans{ - 2, - }, - }, - - question{ - para{ - "121", - }, - ans{ - 3, - }, - }, - question{ - para{ - "1212", - }, - ans{ - 5, - }, - }, - - question{ - para{ - "12121", - }, - ans{ - 8, - }, - }, - - question{ - para{ - "121212", - }, - ans{ - 13, - }, - }, - - question{ - para{ - "1212121", - }, - ans{ - 21, - }, - }, - question{ - para{ - "12121212", - }, - ans{ - 34, - }, - }, - // 如需多个测试,可以复制上方元素。 + for _, tc := range tcs { + ast.Equal(tc.ans, numDecodings(tc.s), "输入:%v", tc) } +} - for _, q := range qs { - a, p := q.ans, q.para - fmt.Printf("~~%v~~\n", p) - - ast.Equal(a.one, numDecodings(p.s), "输入:%v", p) +func Benchmark_numDecodings(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numDecodings(tc.s) + } } } diff --git a/Algorithms/0109.convert-sorted-list-to-binary-search-tree/README.md b/Algorithms/0109.convert-sorted-list-to-binary-search-tree/README.md index 013730a24..ce494a578 100755 --- a/Algorithms/0109.convert-sorted-list-to-binary-search-tree/README.md +++ b/Algorithms/0109.convert-sorted-list-to-binary-search-tree/README.md @@ -1,8 +1,25 @@ # [109. Convert Sorted List to Binary Search Tree](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/) ## 题目 + Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. +For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ by more than 1. + +Example: + +```text +Given the sorted linked list: [-10,-3,0,5,9], + +One possible answer is: [0,-3,9,-10,null,5], which represents the following height balanced BST: + + 0 + / \ + -3 9 + / / + -10 5 +``` + ## 解题思路 见程序注释 diff --git a/Algorithms/0109.convert-sorted-list-to-binary-search-tree/convert-sorted-list-to-binary-search-tree.go b/Algorithms/0109.convert-sorted-list-to-binary-search-tree/convert-sorted-list-to-binary-search-tree.go index 0c099c9cc..8358572ff 100755 --- a/Algorithms/0109.convert-sorted-list-to-binary-search-tree/convert-sorted-list-to-binary-search-tree.go +++ b/Algorithms/0109.convert-sorted-list-to-binary-search-tree/convert-sorted-list-to-binary-search-tree.go @@ -4,32 +4,36 @@ import ( "github.com/aQuaYi/LeetCode-in-Go/kit" ) +// ListNode is 题目预先定义的数据结构 type ListNode = kit.ListNode + +// TreeNode is 题目预先定义的数据结构 type TreeNode = kit.TreeNode func sortedListToBST(head *ListNode) *TreeNode { - return sortedArrayToBST(list2Slice(head)) + return transMidToRoot(head, nil) } -func list2Slice(head *ListNode) []int { - res := []int{} - for head != nil { - res = append(res, head.Val) - head = head.Next +func transMidToRoot(begin, end *ListNode) *TreeNode { + if begin == end { + return nil } - return res -} + if begin.Next == end { + return &TreeNode{Val: begin.Val} + } -func sortedArrayToBST(nums []int) *TreeNode { - if len(nums) == 0 { - return nil + fast, slow := begin, begin + for fast != end && fast.Next != end { + fast = fast.Next.Next + slow = slow.Next } - mid := len(nums) / 2 + mid := slow + return &TreeNode{ - Val: nums[mid], - Left: sortedArrayToBST(nums[:mid]), - Right: sortedArrayToBST(nums[mid+1:]), + Val: mid.Val, + Left: transMidToRoot(begin, mid), + Right: transMidToRoot(mid.Next, end), } } diff --git a/Algorithms/0137.single-number-ii/README.md b/Algorithms/0137.single-number-ii/README.md index 5d0059918..d25ac4f20 100755 --- a/Algorithms/0137.single-number-ii/README.md +++ b/Algorithms/0137.single-number-ii/README.md @@ -1,11 +1,21 @@ # [137. Single Number II](https://leetcode.com/problems/single-number-ii/) -## 题目 -Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. +Given a non-empty 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 you implement it without using extra memory? -## 解题思路 +Example 1: + +```text +Input: [2,2,3,2] +Output: 3 +``` + +Example 2: -见程序注释 +```text +Input: [0,1,0,1,0,1,99] +Output: 99 +``` \ No newline at end of file diff --git a/Algorithms/0137.single-number-ii/single-number-ii.go b/Algorithms/0137.single-number-ii/single-number-ii.go index b8da7a91b..2bd3b2efa 100755 --- a/Algorithms/0137.single-number-ii/single-number-ii.go +++ b/Algorithms/0137.single-number-ii/single-number-ii.go @@ -1,19 +1,33 @@ package problem0137 -// 假设 nums 中的数字为 32 bit -func singleNumber(nums []int) int { - n := len(nums) - res := 0 +//ref: https://cloud.tencent.com/developer/article/1131945 - var i uint - for ; i < 64; i++ { - temp := 0 - for j := 0; j < n; j++ { - temp += nums[j] >> i & 1 //首先把输入数字的第i位加起来。 - } - temp %= 3 //然后求它们除以3的余数。 - res |= temp << i //把二进制表示的结果转化为十进制表示的结果 - } +// 如果是出现两次的话,用一个 bit 就可以 +// 比如 ones,初始为0 +// 当 5 第 1 次出现, ones = 5 +// 当 5 第 2 次出现, ones 清空为 0,表示 ones 可以去处理其他数字了 +// 所以,最后 如果 ones != 0的话, ones 记录的就是只出现了一次的那个数字 + +// 公式是 ones = ones xor i + +// 那么,如果是三次的话,香农定理,需要用 2 bits 进行记录 - return res +// 当 5 第 1 次出现的时候,ones = 5, twos = 0, ones 记录这个数字 +// 当 5 第 2 次出现的时候,ones = 0, twos = 5, twos 记录了这个数字 +// 当 5 第 3 次出现的时候,ones = 0, twos = 0, 都清空了,可以去处理其他数字了 +// 所以,如果有某个数字出现了 1 次,就存在 ones 中,出现了 2 次,就存在 twos 中 + +// 公式方面, 上面 2 次的时候,ones 清空的公式是 ones = ones xor i +// 而第 3 次时, ones 要等于零, 而这时 twos 是 True , 所以再 & 一个 twos 的非就可以, ones = (ones xor i) & ~twos +// 所以,总的公式是 +// ones = (ones xor i) & ~twos +// twos = (twos xor i) & ~ones + +func singleNumber(nums []int) int { + ones, twos := 0, 0 + for i := 0; i < len(nums); i++ { + ones = (ones ^ nums[i]) & ^twos + twos = (twos ^ nums[i]) & ^ones + } + return ones } diff --git a/Algorithms/0141.linked-list-cycle/1.png b/Algorithms/0141.linked-list-cycle/1.png new file mode 100644 index 000000000..b0111ae63 Binary files /dev/null and b/Algorithms/0141.linked-list-cycle/1.png differ diff --git a/Algorithms/0141.linked-list-cycle/2.png b/Algorithms/0141.linked-list-cycle/2.png new file mode 100644 index 000000000..634e7a47f Binary files /dev/null and b/Algorithms/0141.linked-list-cycle/2.png differ diff --git a/Algorithms/0141.linked-list-cycle/3.png b/Algorithms/0141.linked-list-cycle/3.png new file mode 100644 index 000000000..9f11a9e45 Binary files /dev/null and b/Algorithms/0141.linked-list-cycle/3.png differ diff --git a/Algorithms/0141.linked-list-cycle/README.md b/Algorithms/0141.linked-list-cycle/README.md new file mode 100755 index 000000000..ba31f2aac --- /dev/null +++ b/Algorithms/0141.linked-list-cycle/README.md @@ -0,0 +1,39 @@ +# [141. Linked List Cycle](https://leetcode.com/problems/linked-list-cycle/) + +Given a linked list, determine if it has a cycle in it. + +To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list. + +Example 1: + +```text +Input: head = [3,2,0,-4], pos = 1 +Output: true +Explanation: There is a cycle in the linked list, where tail connects to the second node. +``` + +![1](1.png) + +Example 2: + +```text +Input: head = [1,2], pos = 0 +Output: true +Explanation: There is a cycle in the linked list, where tail connects to the first node. +``` + +![2](2.png) + +Example 3: + +```text +Input: head = [1], pos = -1 +Output: false +Explanation: There is no cycle in the linked list. +``` + +![3](3.png) + +Follow up: + +- Can you solve it using O(1) (i.e. constant) memory? \ No newline at end of file diff --git a/Algorithms/0141.linked-list-cycle/linked-list-cycle.go b/Algorithms/0141.linked-list-cycle/linked-list-cycle.go new file mode 100755 index 000000000..473955a48 --- /dev/null +++ b/Algorithms/0141.linked-list-cycle/linked-list-cycle.go @@ -0,0 +1,17 @@ +package problem0141 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// ListNode is pre-defined... +type ListNode = kit.ListNode + +func hasCycle(head *ListNode) bool { + if head == nil { + return false + } + slow, fast := head, head.Next + for fast != nil && fast.Next != nil && slow != fast { + slow, fast = slow.Next, fast.Next.Next + } + return slow == fast +} diff --git a/Algorithms/0141.linked-list-cycle/linked-list-cycle_test.go b/Algorithms/0141.linked-list-cycle/linked-list-cycle_test.go new file mode 100755 index 000000000..cceed6395 --- /dev/null +++ b/Algorithms/0141.linked-list-cycle/linked-list-cycle_test.go @@ -0,0 +1,73 @@ +package problem0141 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + ints []int + pos int + ans bool +}{ + + { + []int{-21, 10, 17, 8, 4, 26, 5, 35, 33, -7, -16, 27, -12, 6, 29, -12, 5, 9, 20, 14, 14, 2, 13, -24, 21, 23, -21, 5}, + -1, + false, + }, + + { + []int{3, 2, 0, -4}, + 1, + true, + }, + + { + []int{1, 2}, + 0, + true, + }, + + { + []int{}, + -1, + false, + }, + + { + []int{1, 2}, + -1, + false, + }, + + { + []int{1}, + -1, + false, + }, + + // 可以有多个 testcase +} + +func Test_hasCycle(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + head := kit.Ints2ListWithCycle(tc.ints, tc.pos) + ast.Equal(tc.ans, hasCycle(head), "输入:%v", tc) + } +} + +func Benchmark_hasCycle(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + head := kit.Ints2ListWithCycle(tc.ints, tc.pos) + hasCycle(head) + } + } +} diff --git a/Algorithms/0142.linked-list-cycle-ii/1.png b/Algorithms/0142.linked-list-cycle-ii/1.png new file mode 100644 index 000000000..b0111ae63 Binary files /dev/null and b/Algorithms/0142.linked-list-cycle-ii/1.png differ diff --git a/Algorithms/0142.linked-list-cycle-ii/2.png b/Algorithms/0142.linked-list-cycle-ii/2.png new file mode 100644 index 000000000..634e7a47f Binary files /dev/null and b/Algorithms/0142.linked-list-cycle-ii/2.png differ diff --git a/Algorithms/0142.linked-list-cycle-ii/3.png b/Algorithms/0142.linked-list-cycle-ii/3.png new file mode 100644 index 000000000..9f11a9e45 Binary files /dev/null and b/Algorithms/0142.linked-list-cycle-ii/3.png differ diff --git a/Algorithms/0142.linked-list-cycle-ii/README.md b/Algorithms/0142.linked-list-cycle-ii/README.md new file mode 100755 index 000000000..ed9f0f7de --- /dev/null +++ b/Algorithms/0142.linked-list-cycle-ii/README.md @@ -0,0 +1,35 @@ +# [142. Linked List Cycle II](https://leetcode.com/problems/linked-list-cycle-ii/) + +Given a linked list, return the node where the cycle begins. If there is no cycle, return null. + +To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list. + +Note: Do not modify the linked list. + +Example 1: + +```text +Input: head = [3,2,0,-4], pos = 1 +Output: tail connects to node index 1 +Explanation: There is a cycle in the linked list, where tail connects to the second node. +``` + +Example 2: + +```text +Input: head = [1,2], pos = 0 +Output: tail connects to node index 0 +Explanation: There is a cycle in the linked list, where tail connects to the first node. +``` + +Example 3: + +```text +Input: head = [1], pos = -1 +Output: no cycle +Explanation: There is no cycle in the linked list. +``` + +Follow up: + +- Can you solve it without using extra space? \ No newline at end of file diff --git a/Algorithms/0142.linked-list-cycle-ii/linked-list-cycle-ii.go b/Algorithms/0142.linked-list-cycle-ii/linked-list-cycle-ii.go new file mode 100755 index 000000000..b257e91c0 --- /dev/null +++ b/Algorithms/0142.linked-list-cycle-ii/linked-list-cycle-ii.go @@ -0,0 +1,27 @@ +package problem0142 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// ListNode is pre-defined... +type ListNode = kit.ListNode + +// https://leetcode.com/problems/linked-list-cycle-ii/discuss/44793/O(n)-solution-by-using-two-pointers-without-change-anything +func detectCycle(head *ListNode) *ListNode { + if head == nil || head.Next == nil { + return nil + } + + slow, fast := head.Next, head.Next.Next + for fast != nil && fast.Next != nil && slow != fast { + slow, fast = slow.Next, fast.Next.Next + } + + if slow != fast { + return nil + } + + for slow != head { + slow, head = slow.Next, head.Next + } + return slow +} diff --git a/Algorithms/0142.linked-list-cycle-ii/linked-list-cycle-ii_test.go b/Algorithms/0142.linked-list-cycle-ii/linked-list-cycle-ii_test.go new file mode 100755 index 000000000..3bfb77093 --- /dev/null +++ b/Algorithms/0142.linked-list-cycle-ii/linked-list-cycle-ii_test.go @@ -0,0 +1,59 @@ +package problem0142 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + ints []int + pos int +}{ + + { + []int{1}, + -1, + }, + + { + []int{1, 2, 3}, + -1, + }, + + { + []int{3, 2, 0, -4}, + 1, + }, + + { + []int{1, 2}, + 0, + }, + + // 可以有多个 testcase +} + +func Test_detectCycle(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + head := kit.Ints2ListWithCycle(tc.ints, tc.pos) + var ans *ListNode + if tc.pos >= 0 { + ans = head.GetNodeWith(tc.ints[tc.pos]) + } + ast.Equal(ans, detectCycle(head), "输入:%v", tc) + } +} + +func Benchmark_detectCycle(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + head := kit.Ints2ListWithCycle(tc.ints, tc.pos) + detectCycle(head) + } + } +} diff --git a/Algorithms/0146.lru-cache/lru-cache.go b/Algorithms/0146.lru-cache/lru-cache.go index 8b3126723..80ff4af94 100755 --- a/Algorithms/0146.lru-cache/lru-cache.go +++ b/Algorithms/0146.lru-cache/lru-cache.go @@ -7,111 +7,70 @@ package problem0146 * obj.Put(key,value); */ -// doublyLinkedNode 是双向链节点 -type doublyLinkedNode struct { - prev, next *doublyLinkedNode - key, val int -} +import "container/list" -// LRUCache 利用 双向链条 + hashtabl 实现 +// LRUCache contains a hash map and a doubly linked list type LRUCache struct { - // cache 的 长度 和 容量 - len, cap int - // 分别指向双向链的首尾节点 - first, last *doublyLinkedNode - // 节点的 hashTable,方便查找节点是否存在 - nodes map[int]*doublyLinkedNode + cap int // capacity + l *list.List // doubly linked list + m map[int]*list.Element // hash table for checking if list node exists +} + +// Pair is the value of a list node. +type Pair struct { + key int + value int } -// Constructor 创建容量为 capacity 的 cache +// Constructor initializes a new LRUCache. func Constructor(capacity int) LRUCache { return LRUCache{ - cap: capacity, - nodes: make(map[int]*doublyLinkedNode, capacity), + cap: capacity, + l: new(list.List), + m: make(map[int]*list.Element, capacity), } } -// Get 获取 cache 中的数据 +// Get a list node from the hash map. func (c *LRUCache) Get(key int) int { - // 利用 hashTable 查询 key - if node, ok := c.nodes[key]; ok { - // key 存在的话 - // 把对应的 node 移动到 cache 的双向链的 first 位 - c.moveToFirst(node) - return node.val + // check if list node exists + if node, ok := c.m[key]; ok { + val := node.Value.(*list.Element).Value.(*Pair).value + // move node to front + c.l.MoveToFront(node) + return val } - - // key 不存在,按照题意,返回 -1 return -1 } -// Put is 放入新数据 +// Put key and value in the LRUCache func (c *LRUCache) Put(key int, value int) { - node, ok := c.nodes[key] - - if ok { // 更新旧 node - // 更新 node 中的值 - node.val = value - // 把 node 放入双向链的 first 位 - c.moveToFirst(node) - } else { // 放入新 node - if c.len == c.cap { - // cache 已满,删除 last 位,为新 node 腾地方 - // 删除 hashTable 中的记录 - delete(c.nodes, c.last.key) - // 删除双向链中的 last 位 - c.removeLast() - } else { - c.len++ + // check if list node exists + if node, ok := c.m[key]; ok { + // move the node to front + c.l.MoveToFront(node) + // update the value of a list node + node.Value.(*list.Element).Value = Pair{key: key, value: value} + } else { + // delete the last list node if the list is full + if c.l.Len() == c.cap { + // get the key that we want to delete + idx := c.l.Back().Value.(*list.Element).Value.(*Pair).key + // delete the node pointer in the hash map by key + delete(c.m, idx) + // remove the last list node + c.l.Remove(c.l.Back()) } - // 为 key 和 value 新建一个节点 - node = &doublyLinkedNode{ - key: key, - val: value, + // initialize a list node + node := &list.Element{ + Value: &Pair{ + key: key, + value: value, + }, } - // 在 hashTable 中添加记录 - c.nodes[key] = node - // 把新 node 放入 first 位 - c.insertToFirst(node) + // push the new list node into the list + ptr := c.l.PushFront(node) + // save the node pointer in the hash map + c.m[key] = ptr } } - -func (c *LRUCache) removeLast() { - if c.last.prev != nil { // 双向链长度 >1 - c.last.prev.next = nil - } else { // 双向链长度 == 1,firt,last 指向同一个节点 - c.first = nil - } - - c.last = c.last.prev -} - -func (c *LRUCache) moveToFirst(node *doublyLinkedNode) { - switch node { - case c.first: - return - case c.last: - c.removeLast() - default: - // 在双向链中,删除 node 节点 - node.prev.next = node.next - node.next.prev = node.prev - } - - // 策略是 - // 如果需要移动 node 的话 - // 先删除,再插入 - c.insertToFirst(node) -} - -func (c *LRUCache) insertToFirst(node *doublyLinkedNode) { - if c.last == nil { // **空**双向链 - c.last = node - } else { // **非空**双向链 - // 默认 node != nil - node.next = c.first - c.first.prev = node - } - - c.first = node -} diff --git a/Algorithms/0148.sort-list/README.md b/Algorithms/0148.sort-list/README.md index d43c0726b..10af1dfa1 100755 --- a/Algorithms/0148.sort-list/README.md +++ b/Algorithms/0148.sort-list/README.md @@ -1,8 +1,5 @@ # [148. Sort List](https://leetcode.com/problems/sort-list/) ## 题目 -Sort a linked list in O(n log n) time using constant space complexity. - -## 解题思路 -见程序注释 +Sort a linked list in O(n log n) time using constant space complexity. diff --git a/Algorithms/0148.sort-list/sort-list.go b/Algorithms/0148.sort-list/sort-list.go index b96b8fce7..038df66bb 100755 --- a/Algorithms/0148.sort-list/sort-list.go +++ b/Algorithms/0148.sort-list/sort-list.go @@ -4,34 +4,38 @@ import ( "github.com/aQuaYi/LeetCode-in-Go/kit" ) +// ListNode 是题目预定义的数据类型 type ListNode = kit.ListNode func sortList(head *ListNode) *ListNode { if head == nil || head.Next == nil { return head } - - secHead := split(head) - return merge(sortList(head), sortList(secHead)) + left, right := split(head) + return merge(sortList(left), sortList(right)) } // 从中间位置,切分 list -func split(head *ListNode) *ListNode { +func split(head *ListNode) (left, right *ListNode) { // head.Next != nil // 因为, sortList 已经帮忙检查过了 // fast 的变化速度是 slow 的两倍 // 当 fast 到达末尾的时候,slow 正好在 list 的中间 slow, fast := head, head - var tail *ListNode + var slowPre *ListNode + for fast != nil && fast.Next != nil { - tail = slow - slow = slow.Next + slowPre, slow = slow, slow.Next fast = fast.Next.Next } + // 斩断 list - tail.Next = nil - return slow + slowPre.Next = nil + // 使用 slowPre 是为了确保当 list 的长度为 2 时,会均分为两个长度为 1 的子 list + + left, right = head, slow + return } // 把已经排序好了的两个 list left 和 right @@ -40,33 +44,24 @@ func merge(left, right *ListNode) *ListNode { // left != nil , right != nil // 因为, sortList 已经帮忙检查过了 - var head, cur, pre *ListNode + cur := &ListNode{} + headPre := cur for left != nil && right != nil { - // cur 指向 left 和 right 中最小的节点 + // cur 总是接上较小的 node if left.Val < right.Val { - cur = left - left = left.Next - } else { - cur = right - right = right.Next - } - // 生成 head 节点 - // 或者 链接 pre 节点 - if head == nil { - head = cur + cur.Next, left = left, left.Next } else { - pre.Next = cur + cur.Next, right = right, right.Next } - // 移动 pre 节点 - pre = cur + cur = cur.Next } // 处理 left 或 right 中,剩下的节点 if left == nil { - pre.Next = right + cur.Next = right } else { - pre.Next = left + cur.Next = left } - return head + return headPre.Next } diff --git a/Algorithms/0155.min-stack/min-stack.go b/Algorithms/0155.min-stack/min-stack.go index 287077c40..8a8364496 100755 --- a/Algorithms/0155.min-stack/min-stack.go +++ b/Algorithms/0155.min-stack/min-stack.go @@ -14,25 +14,25 @@ func Constructor() MinStack { } // Push 存入数据 -func (s *MinStack) Push(x int) { +func (this *MinStack) Push(x int) { min := x - if len(s.stack) > 0 && s.GetMin() < x { - min = s.GetMin() + if len(this.stack) > 0 && this.GetMin() < x { + min = this.GetMin() } - s.stack = append(s.stack, item{min: min, x: x}) + this.stack = append(this.stack, item{min: min, x: x}) } // Pop 抛弃最后一个入栈的值 -func (s *MinStack) Pop() { - s.stack = s.stack[:len(s.stack)-1] +func (this *MinStack) Pop() { + this.stack = this.stack[:len(this.stack)-1] } // Top 返回最大值 -func (s *MinStack) Top() int { - return s.stack[len(s.stack)-1].x +func (this *MinStack) Top() int { + return this.stack[len(this.stack)-1].x } // GetMin 返回最小值 -func (s *MinStack) GetMin() int { - return s.stack[len(s.stack)-1].min +func (this *MinStack) GetMin() int { + return this.stack[len(this.stack)-1].min } diff --git a/Algorithms/0160.intersection-of-two-linked-lists/1.png b/Algorithms/0160.intersection-of-two-linked-lists/1.png new file mode 100644 index 000000000..2021a524a Binary files /dev/null and b/Algorithms/0160.intersection-of-two-linked-lists/1.png differ diff --git a/Algorithms/0160.intersection-of-two-linked-lists/2.png b/Algorithms/0160.intersection-of-two-linked-lists/2.png new file mode 100644 index 000000000..4432fec7c Binary files /dev/null and b/Algorithms/0160.intersection-of-two-linked-lists/2.png differ diff --git a/Algorithms/0160.intersection-of-two-linked-lists/3.png b/Algorithms/0160.intersection-of-two-linked-lists/3.png new file mode 100644 index 000000000..eea063119 Binary files /dev/null and b/Algorithms/0160.intersection-of-two-linked-lists/3.png differ diff --git a/Algorithms/0160.intersection-of-two-linked-lists/README.md b/Algorithms/0160.intersection-of-two-linked-lists/README.md new file mode 100755 index 000000000..099a699a4 --- /dev/null +++ b/Algorithms/0160.intersection-of-two-linked-lists/README.md @@ -0,0 +1,47 @@ +# [160. Intersection of Two Linked Lists](https://leetcode.com/problems/intersection-of-two-linked-lists/) + +Write a program to find the node at which the intersection of two singly linked lists begins. + +For example, the following two linked lists: + +![p](p.png) + +begin to intersect at node c1. + +Example 1: + +![1](1.png) + +```text +Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,0,1,8,4,5], skipA = 2, skipB = 3 +Output: Reference of the node with value = 8 +Input Explanation: The intersected node's value is 8 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [4,1,8,4,5]. From the head of B, it reads as [5,0,1,8,4,5]. There are 2 nodes before the intersected node in A; There are 3 nodes before the intersected node in B. +``` + +Example 2: + +![2](2.png) + +```text +Input: intersectVal = 2, listA = [0,9,1,2,4], listB = [3,2,4], skipA = 3, skipB = 1 +Output: Reference of the node with value = 2 +Input Explanation: The intersected node's value is 2 (note that this must not be 0 if the two lists intersect). From the head of A, it reads as [0,9,1,2,4]. From the head of B, it reads as [3,2,4]. There are 3 nodes before the intersected node in A; There are 1 node before the intersected node in B. +``` + +Example 3: + +![3](3.png) + +```text +Input: intersectVal = 0, listA = [2,6,4], listB = [1,5], skipA = 3, skipB = 2 +Output: null +Input Explanation: From the head of A, it reads as [2,6,4]. From the head of B, it reads as [1,5]. Since the two lists do not intersect, intersectVal must be 0, while skipA and skipB can be arbitrary values. +Explanation: The two lists do not intersect, so return null. +``` + +Notes: + +- If the two linked lists have no intersection at all, return null. +- The linked lists must retain their original structure after the function returns. +- You may assume there are no cycles anywhere in the entire linked structure. +- Your code should preferably run in O(n) time and use only O(1) memory. \ No newline at end of file diff --git a/Algorithms/0160.intersection-of-two-linked-lists/intersection-of-two-linked-lists.go b/Algorithms/0160.intersection-of-two-linked-lists/intersection-of-two-linked-lists.go new file mode 100755 index 000000000..8087f85d7 --- /dev/null +++ b/Algorithms/0160.intersection-of-two-linked-lists/intersection-of-two-linked-lists.go @@ -0,0 +1,26 @@ +package problem0160 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// ListNode is pre-defined... +type ListNode = kit.ListNode + +func getIntersectionNode(headA, headB *ListNode) *ListNode { + a, b := headA, headB + hasLinkedToB, hasLinkedToA := false, false + for a != nil && b != nil { + if a == b { + return b + } + a, b = a.Next, b.Next + if a == nil && !hasLinkedToB { + a = headB + hasLinkedToB = true + } + if b == nil && !hasLinkedToA { + b = headA + hasLinkedToA = true + } + } + return nil +} diff --git a/Algorithms/0160.intersection-of-two-linked-lists/intersection-of-two-linked-lists_test.go b/Algorithms/0160.intersection-of-two-linked-lists/intersection-of-two-linked-lists_test.go new file mode 100755 index 000000000..f3f7867ae --- /dev/null +++ b/Algorithms/0160.intersection-of-two-linked-lists/intersection-of-two-linked-lists_test.go @@ -0,0 +1,83 @@ +package problem0160 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + a, b []int + ea, eb int +}{ + + { + []int{4, 1, 8, 4, 5}, + []int{5, 0, 1, 8, 4, 5}, + 2, + 3, + }, + + { + []int{0, 9, 1, 2, 4}, + []int{3, 2, 4}, + 3, + 1, + }, + + { + []int{2, 6, 4}, + []int{1, 5}, + 3, + 2, + }, + + // 可以有多个 testcase +} + +// head must Not be nil +func tailOf(head *ListNode) *ListNode { + for head.Next != nil { + head = head.Next + } + return head +} + +func Test_getIntersectionNode(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + tail := kit.Ints2List(tc.a[tc.ea:]) + + headA := kit.Ints2List(tc.a[:tc.ea]) + tailA := tailOf(headA) + tailA.Next = tail + + headB := kit.Ints2List(tc.b[:tc.eb]) + tailB := tailOf(headB) + tailB.Next = tail + + ast.Equal(tail, getIntersectionNode(headA, headB), "输入:%v", tc) + } +} + +func Benchmark_getIntersectionNode(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + tail := kit.Ints2List(tc.a[tc.ea:]) + + headA := kit.Ints2List(tc.a[:tc.ea]) + tailA := tailOf(headA) + tailA.Next = tail + + headB := kit.Ints2List(tc.b[:tc.eb]) + tailB := tailOf(headB) + tailB.Next = tail + + getIntersectionNode(headA, headB) + } + } +} diff --git a/Algorithms/0160.intersection-of-two-linked-lists/p.png b/Algorithms/0160.intersection-of-two-linked-lists/p.png new file mode 100644 index 000000000..55870e302 Binary files /dev/null and b/Algorithms/0160.intersection-of-two-linked-lists/p.png differ diff --git a/Algorithms/0173.binary-search-tree-iterator/README.md b/Algorithms/0173.binary-search-tree-iterator/README.md new file mode 100755 index 000000000..ebc854617 --- /dev/null +++ b/Algorithms/0173.binary-search-tree-iterator/README.md @@ -0,0 +1,27 @@ +# [173. Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator/) + +Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. + +Calling next() will return the next smallest number in the BST. + +![bst](bst.png) + +Example: + +```text +BSTIterator iterator = new BSTIterator(root); +iterator.next(); // return 3 +iterator.next(); // return 7 +iterator.hasNext(); // return true +iterator.next(); // return 9 +iterator.hasNext(); // return true +iterator.next(); // return 15 +iterator.hasNext(); // return true +iterator.next(); // return 20 +iterator.hasNext(); // return false +``` + +Note: + +- next() and hasNext() should run in average O(1) time and uses O(h) memory, where h is the height of the tree. +- You may assume that next() call will always be valid, that is, there will be at least a next smallest number in the BST when next() is called. \ No newline at end of file diff --git a/Algorithms/0173.binary-search-tree-iterator/binary-search-tree-iterator.go b/Algorithms/0173.binary-search-tree-iterator/binary-search-tree-iterator.go new file mode 100755 index 000000000..2259a0aa1 --- /dev/null +++ b/Algorithms/0173.binary-search-tree-iterator/binary-search-tree-iterator.go @@ -0,0 +1,51 @@ +package problem0173 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined... +/* Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +type TreeNode = kit.TreeNode + +// BSTIterator is the iterator of BST +type BSTIterator struct { + stack []*TreeNode +} + +// Constructor returns a BST iterator +func Constructor(root *TreeNode) BSTIterator { + stack := make([]*TreeNode, 0, 128) + res := BSTIterator{ + stack: stack, + } + res.push(root) + return res +} + +// Next returns the next smallest number +func (it *BSTIterator) Next() int { + size := len(it.stack) + var top *TreeNode + it.stack, top = it.stack[:size-1], it.stack[size-1] + it.push(top.Right) + return top.Val +} + +// HasNext returns whether we have a next smallest number +func (it *BSTIterator) HasNext() bool { + return len(it.stack) > 0 +} + +func (it *BSTIterator) push(root *TreeNode) { + for root != nil { + it.stack = append(it.stack, root) + root = root.Left + } +} diff --git a/Algorithms/0173.binary-search-tree-iterator/binary-search-tree-iterator_test.go b/Algorithms/0173.binary-search-tree-iterator/binary-search-tree-iterator_test.go new file mode 100755 index 000000000..86922032b --- /dev/null +++ b/Algorithms/0173.binary-search-tree-iterator/binary-search-tree-iterator_test.go @@ -0,0 +1,26 @@ +package problem0173 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +func Test_BSTIterator(t *testing.T) { + ast := assert.New(t) + + ints := []int{7, 3, 15, kit.NULL, kit.NULL, 9, 20} + + root := kit.Ints2TreeNode(ints) + + it := Constructor(root) + nums := kit.Tree2Inorder(root) + + i := 0 + + for it.HasNext() { + ast.Equal(nums[i], it.Next(), "%d", nums[i]) + i++ + } +} diff --git a/Algorithms/0173.binary-search-tree-iterator/bst.png b/Algorithms/0173.binary-search-tree-iterator/bst.png new file mode 100644 index 000000000..f160de8e3 Binary files /dev/null and b/Algorithms/0173.binary-search-tree-iterator/bst.png differ diff --git a/Algorithms/0190.reverse-bits/README.md b/Algorithms/0190.reverse-bits/README.md new file mode 100755 index 000000000..3a808f985 --- /dev/null +++ b/Algorithms/0190.reverse-bits/README.md @@ -0,0 +1,28 @@ +# [190. Reverse Bits](https://leetcode.com/problems/reverse-bits/) + +Reverse bits of a given 32 bits unsigned integer. + +Example 1: + +```text +Input: 00000010100101000001111010011100 +Output: 00111001011110000010100101000000 +Explanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its binary representation is 00111001011110000010100101000000. +``` + +Example 2: + +```text +Input: 11111111111111111111111111111101 +Output: 10111111111111111111111111111111 +Explanation: The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is 10101111110010110010011101101001. +``` + +Note: + +- Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as signed integer type and should not affect your implementation, as the internal binary representation of the integer is the same whether it is signed or unsigned. +- In Java, the compiler represents the signed integers using [2's complement notation](https://en.wikipedia.org/wiki/Two%27s_complement). Therefore, in **Example 2** above the input represents the signed integer `-3` and the output represents the signed integer `-1073741825`. + +Follow up: + +If this function is called many times, how would you optimize it? \ No newline at end of file diff --git a/Algorithms/0190.reverse-bits/reverse-bits.go b/Algorithms/0190.reverse-bits/reverse-bits.go new file mode 100755 index 000000000..8d123e77e --- /dev/null +++ b/Algorithms/0190.reverse-bits/reverse-bits.go @@ -0,0 +1,13 @@ +package problem0190 + +func reverseBits(n uint32) uint32 { + n = (n >> 16) | (n << 16) + n = ((n & 0xff00ff00) >> 8) | ((n & 0x00ff00ff) << 8) + n = ((n & 0xf0f0f0f0) >> 4) | ((n & 0x0f0f0f0f) << 4) + n = ((n & 0xcccccccc) >> 2) | ((n & 0x33333333) << 2) + n = ((n & 0xaaaaaaaa) >> 1) | ((n & 0x55555555) << 1) + return n +} + +// for 8 bit binary number abcdefgh, the process is as follow: +// abcdefgh -> efghabcd -> ghefcdab -> hgfedcba diff --git a/Algorithms/0190.reverse-bits/reverse-bits_test.go b/Algorithms/0190.reverse-bits/reverse-bits_test.go new file mode 100755 index 000000000..38f4ecc74 --- /dev/null +++ b/Algorithms/0190.reverse-bits/reverse-bits_test.go @@ -0,0 +1,42 @@ +package problem0190 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + num uint32 + ans uint32 +}{ + + { + 43261596, // 0b00000010100101000001111010011100 + 964176192, // 0b00111001011110000010100101000000 + }, + + { + 4294967293, // 0b11111111111111111111111111111101 + 3221225471, // 0b10101111110010110010011101101001 + }, + + // 可以有多个 testcase +} + +func Test_reverseBits(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, reverseBits(tc.num), "输入:%v", tc) + } +} + +func Benchmark_reverseBits(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + reverseBits(tc.num) + } + } +} diff --git a/Algorithms/0191.number-of-1-bits/README.md b/Algorithms/0191.number-of-1-bits/README.md new file mode 100755 index 000000000..9a046c070 --- /dev/null +++ b/Algorithms/0191.number-of-1-bits/README.md @@ -0,0 +1,36 @@ +# [191. Number of 1 Bits](https://leetcode.com/problems/number-of-1-bits/) + +Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the [Hamming weight](http://en.wikipedia.org/wiki/Hamming_weight)). + +Example 1: + +```text +Input: 00000000000000000000000000001011 +Output: 3 +Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits. +``` + +Example 2: + +```text +Input: 00000000000000000000000010000000 +Output: 1 +Explanation: The input binary string 00000000000000000000000010000000 has a total of one '1' bit. +``` + +Example 3: + +```text +Input: 11111111111111111111111111111101 +Output: 31 +Explanation: The input binary string 11111111111111111111111111111101 has a total of thirty one '1' bits. +``` + +Note: + +- Note that in some languages such as Java, there is no unsigned integer type. In this case, the input will be given as signed integer type and should not affect your implementation, as the internal binary representation of the integer is the same whether it is signed or unsigned. +- In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 3 above the input represents the signed integer -3. + +Follow up: + +If this function is called many times, how would you optimize it? \ No newline at end of file diff --git a/Algorithms/0191.number-of-1-bits/number-of-1-bits.go b/Algorithms/0191.number-of-1-bits/number-of-1-bits.go new file mode 100755 index 000000000..31fde8355 --- /dev/null +++ b/Algorithms/0191.number-of-1-bits/number-of-1-bits.go @@ -0,0 +1,13 @@ +package problem0191 + +func hammingWeight(num uint32) int { + count := 0 + for num != 0 { + count++ + num &= num - 1 + // assume num = 0b1000 + // num-1 = 0b0111 + // num & (num-1) = 0 + } + return count +} diff --git a/Algorithms/0191.number-of-1-bits/number-of-1-bits_test.go b/Algorithms/0191.number-of-1-bits/number-of-1-bits_test.go new file mode 100755 index 000000000..95b025c85 --- /dev/null +++ b/Algorithms/0191.number-of-1-bits/number-of-1-bits_test.go @@ -0,0 +1,47 @@ +package problem0191 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + num uint32 + ans int +}{ + + { + 11, //0b00000000000000000000000000001011 + 3, + }, + + { + 128, //0b00000000000000000000000010000000 + 1, + }, + + { + 4294967293, //0b11111111111111111111111111111101 + 31, + }, + + // 可以有多个 testcase +} + +func Test_hammingWeight(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, hammingWeight(tc.num), "输入:%v", tc) + } +} + +func Benchmark_hammingWeight(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + hammingWeight(tc.num) + } + } +} diff --git a/Algorithms/0208.implement-trie-prefix-tree/implement-trie-prefix-tree.go b/Algorithms/0208.implement-trie-prefix-tree/implement-trie-prefix-tree.go index bfe3c91fd..0c68569fa 100755 --- a/Algorithms/0208.implement-trie-prefix-tree/implement-trie-prefix-tree.go +++ b/Algorithms/0208.implement-trie-prefix-tree/implement-trie-prefix-tree.go @@ -10,33 +10,58 @@ package problem0208 // Trie 是便于 word 插入与查找的数据结构 type Trie struct { - dict map[string]bool - dictPrefix map[string]bool + val byte + sons [26]*Trie + end int } -// Constructor initialize your data structure here. func Constructor() Trie { - d := make(map[string]bool, 1024) - p := make(map[string]bool, 4096) - p[""] = true - return Trie{dict: d, dictPrefix: p} + return Trie{} } -// Insert a word into the trie. -func (t *Trie) Insert(word string) { - t.dict[word] = true - for i := 1; i < len(word); i++ { - t.dictPrefix[word[:i]] = true +func (this *Trie) Insert(word string) { + node := this + size := len(word) + for i := 0; i < size; i++ { + idx := word[i] - 'a' + if node.sons[idx] == nil { + node.sons[idx] = &Trie{val: word[i]} + } + + node = node.sons[idx] } + + node.end++ } -// Search returns true if the word is in the trie. -func (t *Trie) Search(word string) bool { - return t.dict[word] +func (this *Trie) Search(word string) bool { + node := this + size := len(word) + for i := 0; i < size; i++ { + idx := word[i] - 'a' + if node.sons[idx] == nil { + return false + } + node = node.sons[idx] + } + + if node.end > 0 { + return true + } + + return false } -// StartsWith returns true if there is any word in the trie that starts with the given prefix. -func (t *Trie) StartsWith(prefix string) bool { - // dict 比较小,先检查 - return t.dict[prefix] || t.dictPrefix[prefix] +func (this *Trie) StartsWith(prefix string) bool { + node := this + size := len(prefix) + for i := 0; i < size; i++ { + idx := prefix[i] - 'a' + if node.sons[idx] == nil { + return false + } + node = node.sons[idx] + } + + return true } diff --git a/Algorithms/0208.implement-trie-prefix-tree/implement-trie-prefix-tree_test.go b/Algorithms/0208.implement-trie-prefix-tree/implement-trie-prefix-tree_test.go index ba01667b0..672241465 100755 --- a/Algorithms/0208.implement-trie-prefix-tree/implement-trie-prefix-tree_test.go +++ b/Algorithms/0208.implement-trie-prefix-tree/implement-trie-prefix-tree_test.go @@ -17,6 +17,7 @@ func Test_Constructor(t *testing.T) { ast.True(trie.Search("abc"), "Search abc in [abc]") // ["abc"] + ast.False(trie.Search("ab"), "Search abcd in [a]") ast.False(trie.Search("abcd"), "Search abcd in [abc]") // ["abc"] diff --git a/Algorithms/0211.add-and-search-word-data-structure-design/add-and-search-word-data-structure-design.go b/Algorithms/0211.add-and-search-word-data-structure-design/add-and-search-word-data-structure-design.go index c2ae44e28..716395399 100755 --- a/Algorithms/0211.add-and-search-word-data-structure-design/add-and-search-word-data-structure-design.go +++ b/Algorithms/0211.add-and-search-word-data-structure-design/add-and-search-word-data-structure-design.go @@ -1,44 +1,63 @@ package problem0211 -// WordDictionary 是字典 type WordDictionary struct { - dict []string + sons [26]*WordDictionary + end int } -// Constructor 构建 WordDictionary -// Initialize your data structure here. +/** Initialize your data structure here. */ func Constructor() WordDictionary { return WordDictionary{} } -// AddWord 往 WordDictionary 中添加 word -// Adds a word into the data structure. -func (d *WordDictionary) AddWord(word string) { - d.dict = append(d.dict, word) +/** Adds a word into the data structure. */ +func (this *WordDictionary) AddWord(word string) { + for _, b := range word { + idx := b - 'a' + if this.sons[idx] == nil { + this.sons[idx] = &WordDictionary{} + } + this = this.sons[idx] + } + + this.end++ } -// Search 返回 true 如果 WordDictionary 中包含有 word -// Returns if the word is in the data structure. -// A word could contain the dot character '.' to represent any one letter. -func (d *WordDictionary) Search(word string) bool { - size := len(word) - i := 0 - for _, w := range d.dict { - // w 和 word 的长度要一致 - if len(w) != size { - continue - } +/** Returns if the word is in the data structure. A word could contain the dot character '.' to represent any one letter. */ +func (this *WordDictionary) Search(word string) bool { + for i, b := range word { + if b != '.' { + idx := b - 'a' + if this.sons[idx] == nil { + return false + } + + this = this.sons[idx] + } else { + for _, son := range this.sons { + if son == nil { + continue + } - i = 0 - for ; i < size; i++ { - if word[i] != '.' && word[i] != w[i] { - break + this = son + if i == len(word)-1 { + if this.end > 0 { + return true + } + continue + } + + if this.Search(word[i+1:]) { + return true + } } + + return false } - // 匹配完成 - if i == size { - return true - } + } + + if this.end > 0 { + return true } return false diff --git a/Algorithms/0211.add-and-search-word-data-structure-design/add-and-search-word-data-structure-design_test.go b/Algorithms/0211.add-and-search-word-data-structure-design/add-and-search-word-data-structure-design_test.go index e83e9efa2..0130e1c81 100755 --- a/Algorithms/0211.add-and-search-word-data-structure-design/add-and-search-word-data-structure-design_test.go +++ b/Algorithms/0211.add-and-search-word-data-structure-design/add-and-search-word-data-structure-design_test.go @@ -10,6 +10,9 @@ func Test_Constructor(t *testing.T) { ast := assert.New(t) d := Constructor() + + ast.False(d.Search("."), "search . from []") + d.AddWord("bad") // [bad] d.AddWord("dad") @@ -24,4 +27,8 @@ func Test_Constructor(t *testing.T) { ast.True(d.Search(".ad"), "search .ad from [bad, dad, ma]") ast.True(d.Search("b.."), "search b.. from [bad, dad, ma]") + + ast.False(d.Search("."), "search . from [bad, dad, ma]") + + ast.False(d.Search("b"), "search b from [bad, dad, ma]") } diff --git a/Algorithms/0222.count-complete-tree-nodes/README.md b/Algorithms/0222.count-complete-tree-nodes/README.md new file mode 100755 index 000000000..5ec0b0c1b --- /dev/null +++ b/Algorithms/0222.count-complete-tree-nodes/README.md @@ -0,0 +1,22 @@ +# [222. Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes/) + +Given a complete binary tree, count the number of nodes. + +Note: + +Definition of a complete binary tree from [Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees): + +In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h. + +Example: + +```text +Input: + 1 + / \ + 2 3 + / \ / +4 5 6 + +Output: 6 +``` diff --git a/Algorithms/0222.count-complete-tree-nodes/count-complete-tree-nodes.go b/Algorithms/0222.count-complete-tree-nodes/count-complete-tree-nodes.go new file mode 100644 index 000000000..23d96fa39 --- /dev/null +++ b/Algorithms/0222.count-complete-tree-nodes/count-complete-tree-nodes.go @@ -0,0 +1,25 @@ +package problem0222 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is predefined in kit +type TreeNode = kit.TreeNode + +func countNodes(root *TreeNode) int { + count := 0 + traverse(root, &count) + return count +} + +func traverse(n *TreeNode, count *int) { + if n == nil { + return + } + + *count++ + + traverse(n.Left, count) + traverse(n.Right, count) +} diff --git a/Algorithms/0222.count-complete-tree-nodes/count-complete-tree-nodes_test.go b/Algorithms/0222.count-complete-tree-nodes/count-complete-tree-nodes_test.go new file mode 100644 index 000000000..f62b90f0c --- /dev/null +++ b/Algorithms/0222.count-complete-tree-nodes/count-complete-tree-nodes_test.go @@ -0,0 +1,43 @@ +package problem0222 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +var questions = []struct { + pre, in []int + count int +}{ + + { + []int{}, + []int{}, + 0, + }, + + { + []int{1, 2, 4, 5, 3, 6}, + []int{4, 2, 5, 1, 6, 3}, + 6, + }, +} + +func Test_countNodes(t *testing.T) { + ast := assert.New(t) + for _, q := range questions { + root := kit.PreIn2Tree(q.pre, q.in) + ast.Equal(q.count, countNodes(root)) + } +} + +func Benchmark_countNodes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, q := range questions { + root := kit.PreIn2Tree(q.pre, q.in) + countNodes(root) + } + } +} diff --git a/Algorithms/0232.implement-queue-using-stacks/README.md b/Algorithms/0232.implement-queue-using-stacks/README.md index 3acbdaffd..2986f99e0 100755 --- a/Algorithms/0232.implement-queue-using-stacks/README.md +++ b/Algorithms/0232.implement-queue-using-stacks/README.md @@ -4,25 +4,25 @@ Implement the following operations of a queue using stacks. +- push(x) -- Push element x to the back of queue. +- pop() -- Removes the element from in front of queue. +- peek() -- Get the front element. +- empty() -- Return whether the queue is empty. -push(x) -- Push element x to the back of queue. +Example: +```text +MyQueue queue = new MyQueue(); -pop() -- Removes the element from in front of queue. - - -peek() -- Get the front element. - - -empty() -- Return whether the queue is empty. - +queue.push(1); +queue.push(2); +queue.peek(); // returns 1 +queue.pop(); // returns 1 +queue.empty(); // returns false +``` Notes: -You must use only standard operations of a stack -- which means only push to top, peek/pop from top, size, and is empty operations are valid. -Depending on your language, stack may not be supported natively. You may simulate a stack by using a list or deque (double-ended queue), as long as you use only standard operations of a stack. -You may assume that all operations are valid (for example, no pop or peek operations will be called on an empty queue). - -## 解题思路 - -见程序注释 +- You must use only standard operations of a stack -- which means only push to top, peek/pop from top, size, and is empty operations are valid. +- Depending on your language, stack may not be supported natively. You may simulate a stack by using a list or deque (double-ended queue), as long as you use only standard operations of a stack. +- You may assume that all operations are valid (for example, no pop or peek operations will be called on an empty queue). \ No newline at end of file diff --git a/Algorithms/0232.implement-queue-using-stacks/implement-queue-using-stacks.go b/Algorithms/0232.implement-queue-using-stacks/implement-queue-using-stacks.go index d8506b282..7412fc49c 100755 --- a/Algorithms/0232.implement-queue-using-stacks/implement-queue-using-stacks.go +++ b/Algorithms/0232.implement-queue-using-stacks/implement-queue-using-stacks.go @@ -1,80 +1,40 @@ package problem0232 -// MyQueue 是利用 栈 实现的队列 +import "container/list" + +// MyQueue 是利用 list 实现的队列 type MyQueue struct { - a, b *Stack + list *list.List } // Constructor Initialize your data structure here. func Constructor() MyQueue { - return MyQueue{a: NewStack(), b: NewStack()} + return MyQueue{ + list: list.New(), + } } // Push element x to the back of queue. -func (mq *MyQueue) Push(x int) { - mq.a.Push(x) +func (q *MyQueue) Push(x int) { + q.list.PushBack(x) } // Pop Removes the element from in front of queue and returns that element. -func (mq *MyQueue) Pop() int { - if mq.b.Len() == 0 { - for mq.a.Len() > 0 { - mq.b.Push(mq.a.Pop()) - } - } - - return mq.b.Pop() +func (q *MyQueue) Pop() int { + front := q.list.Front() + res := front.Value.(int) + q.list.Remove(front) + return res } // Peek Get the front element. -func (mq *MyQueue) Peek() int { - res := mq.Pop() - mq.b.Push(res) +func (q *MyQueue) Peek() int { + front := q.list.Front() + res := front.Value.(int) return res } // Empty returns whether the queue is empty. -func (mq *MyQueue) Empty() bool { - return mq.a.Len() == 0 && mq.b.Len() == 0 -} - -/** - * Your MyQueue object will be instantiated and called as such: - * obj := Constructor(); - * obj.Push(x); - * param_2 := obj.Pop(); - * param_3 := obj.Peek(); - * param_4 := obj.Empty(); - */ - -// Stack 是用于存放 int 的 栈 -type Stack struct { - nums []int -} - -// NewStack 返回 *kit.Stack -func NewStack() *Stack { - return &Stack{nums: []int{}} -} - -// Push 把 n 放入 栈 -func (s *Stack) Push(n int) { - s.nums = append(s.nums, n) -} - -// Pop 从 s 中取出最后放入 栈 的值 -func (s *Stack) Pop() int { - res := s.nums[len(s.nums)-1] - s.nums = s.nums[:len(s.nums)-1] - return res -} - -// Len 返回 s 的长度 -func (s *Stack) Len() int { - return len(s.nums) -} - -// IsEmpty 反馈 s 是否为空 -func (s *Stack) IsEmpty() bool { - return s.Len() == 0 +func (q *MyQueue) Empty() bool { + return q.list.Len() == 0 } diff --git a/Algorithms/0232.implement-queue-using-stacks/implement-queue-using-stacks_test.go b/Algorithms/0232.implement-queue-using-stacks/implement-queue-using-stacks_test.go index 00b3828a4..15b3a8e8c 100755 --- a/Algorithms/0232.implement-queue-using-stacks/implement-queue-using-stacks_test.go +++ b/Algorithms/0232.implement-queue-using-stacks/implement-queue-using-stacks_test.go @@ -16,31 +16,10 @@ func Test_MyQueue(t *testing.T) { for i := start; i < end; i++ { q.Push(i) - ast.Equal(start , q.Peek(), "查看 q.Peek()") + ast.Equal(start, q.Peek(), "查看 q.Peek()") } for i := start; i < end; i++ { ast.Equal(i, q.Pop(), "从 q 中 pop 出数来。") } - - ast.True(q.Empty(), "检查 Pop 完毕后的 q 是否为空") -} -func Test_Stack(t *testing.T) { - ast := assert.New(t) - - s := NewStack() - ast.True(s.IsEmpty(), "检查新建的 s 是否为空") - - start, end := 0, 100 - - for i := start; i < end; i++ { - s.Push(i) - ast.Equal(i-start+1, s.Len(), "Push 后检查 q 的长度。") - } - - for i := end - 1; i >= start; i-- { - ast.Equal(i, s.Pop(), "从 s 中 pop 出数来。") - } - - ast.True(s.IsEmpty(), "检查 Pop 完毕后的 s 是否为空") } diff --git a/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/235.png b/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/235.png new file mode 100644 index 000000000..2035831d0 Binary files /dev/null and b/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/235.png differ diff --git a/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/README.md b/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/README.md new file mode 100644 index 000000000..d3dc3e399 --- /dev/null +++ b/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/README.md @@ -0,0 +1,30 @@ +# [235. Lowest Common Ancestor of a Binary Search Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/) + +Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. + +According to [the definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).” + +Given binary search tree: root = [6,2,8,0,4,7,9,null,null,3,5] + +![235](235.png) + +Example 1: + +```text +Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 8 +Output: 6 +Explanation: The LCA of nodes 2 and 8 is 6. +``` + +Example 2: + +```text +Input: root = [6,2,8,0,4,7,9,null,null,3,5], p = 2, q = 4 +Output: 2 +Explanation: The LCA of nodes 2 and 4 is 2, since a node can be a descendant of itself according to the LCA definition. +``` + +Note: + +- All of the nodes' values will be unique. +- p and q are different and both values will exist in the BST. \ No newline at end of file diff --git a/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/lowest-common-ancestor-of-a-binary-search-tree.go b/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/lowest-common-ancestor-of-a-binary-search-tree.go new file mode 100644 index 000000000..c33715502 --- /dev/null +++ b/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/lowest-common-ancestor-of-a-binary-search-tree.go @@ -0,0 +1,20 @@ +package problem0235 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined.. +type TreeNode = kit.TreeNode + +func lowestCommonAncestor(root, p, q *TreeNode) *TreeNode { + return helper(root, p.Val, q.Val) +} + +func helper(root *TreeNode, p, q int) *TreeNode { + r := root.Val + if p < r && q < r { + return helper(root.Left, p, q) + } else if r < p && r < q { + return helper(root.Right, p, q) + } + return root +} diff --git a/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/lowest-common-ancestor-of-a-binary-search-tree_test.go b/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/lowest-common-ancestor-of-a-binary-search-tree_test.go new file mode 100644 index 000000000..dae2d1174 --- /dev/null +++ b/Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree/lowest-common-ancestor-of-a-binary-search-tree_test.go @@ -0,0 +1,70 @@ +package problem0235 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +var questions = []struct { + pre, in []int + p, q, ans int +}{ + { + []int{6, 2, 0, 4, 3, 5, 8, 7, 9}, + []int{0, 2, 3, 4, 5, 6, 7, 8, 9}, + 2, + 8, + 6, + }, + + { + []int{6, 2, 0, 4, 3, 5, 8, 7, 9}, + []int{0, 2, 3, 4, 5, 6, 7, 8, 9}, + 2, + 4, + 2, + }, + + { + []int{6, 2, 0, 4, 3, 5, 8, 7, 9}, + []int{0, 2, 3, 4, 5, 6, 7, 8, 9}, + 7, + 9, + 8, + }, +} + +func Test_lowestCommonAncestor(t *testing.T) { + ast := assert.New(t) + for _, que := range questions { + root := kit.PreIn2Tree(que.pre, que.in) + + p := &TreeNode{ + Val: que.p, + } + + q := &TreeNode{ + Val: que.q, + } + + node := lowestCommonAncestor(root, p, q) + ast.Equal(que.ans, node.Val) + } +} + +func Benchmark_lowestCommonAncestor(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, que := range questions { + root := kit.PreIn2Tree(que.pre, que.in) + p := &TreeNode{ + Val: que.p, + } + q := &TreeNode{ + Val: que.q, + } + lowestCommonAncestor(root, p, q) + } + } +} diff --git a/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/236.png b/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/236.png new file mode 100644 index 000000000..04be42ec2 Binary files /dev/null and b/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/236.png differ diff --git a/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/README.md b/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/README.md new file mode 100755 index 000000000..9aef441bf --- /dev/null +++ b/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/README.md @@ -0,0 +1,30 @@ +# [236. Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/) + +Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. + +According to [the definition of LCA on Wikipedia](https://en.wikipedia.org/wiki/Lowest_common_ancestor): “The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).” + +Given the following binary tree: root = [3,5,1,6,2,0,8,null,null,7,4] + +![236](236.png) + +Example 1: + +```text +Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 1 +Output: 3 +Explanation: The LCA of nodes 5 and 1 is 3. +``` + +Example 2: + +```text +Input: root = [3,5,1,6,2,0,8,null,null,7,4], p = 5, q = 4 +Output: 5 +Explanation: The LCA of nodes 5 and 4 is 5, since a node can be a descendant of itself according to the LCA definition. +``` + +Note: + +- All of the nodes' values will be unique. +- p and q are different and both values will exist in the binary tree. \ No newline at end of file diff --git a/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/lowest-common-ancestor-of-a-binary-tree.go b/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/lowest-common-ancestor-of-a-binary-tree.go new file mode 100644 index 000000000..b31387457 --- /dev/null +++ b/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/lowest-common-ancestor-of-a-binary-tree.go @@ -0,0 +1,35 @@ +package problem0236 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +// NOTICE: 此解法的时间复杂度是 O(n) + +func lowestCommonAncestor(root, p, q *TreeNode) *TreeNode { + if root == nil || + root == p || + root == q { + return root + } + + l := lowestCommonAncestor(root.Left, p, q) + r := lowestCommonAncestor(root.Right, p, q) + + // l=nil 意味着, p 和 q 都 **不在** root.Left 中 + // r=nil 同理。 + // 所以,根据题意, l 和 r 不可能同时为 nil + if l != nil && r != nil { + // 此时 p 和 q 分别在 root.Left 和 root.Right 中 + return root + } + if l == nil { + // 此时 p 和 q 在 root.Right 中 + return r + } + // 此时 p 和 q 在 root.Left 中 + return l +} diff --git a/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/lowest-common-ancestor-of-a-binary-tree_test.go b/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/lowest-common-ancestor-of-a-binary-tree_test.go new file mode 100644 index 000000000..85a701a6f --- /dev/null +++ b/Algorithms/0236.lowest-common-ancestor-of-a-binary-tree/lowest-common-ancestor-of-a-binary-tree_test.go @@ -0,0 +1,58 @@ +package problem0236 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +var root = kit.Ints2TreeNode([]int{3, 5, 1, 6, 2, 0, 8, kit.NULL, kit.NULL, 7, 4}) + +var tcs = []struct { + p, q, ans *TreeNode +}{ + + { + kit.GetTargetNode(root, 5), + kit.GetTargetNode(root, 1), + kit.GetTargetNode(root, 3), + }, + + { + kit.GetTargetNode(root, 4), + kit.GetTargetNode(root, 7), + kit.GetTargetNode(root, 2), + }, + + { + kit.GetTargetNode(root, 4), + kit.GetTargetNode(root, 5), + kit.GetTargetNode(root, 5), + }, + + { + kit.GetTargetNode(root, 5), + kit.GetTargetNode(root, 4), + kit.GetTargetNode(root, 5), + }, + + // +} + +func Test_lowestCommonAncestor(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + node := lowestCommonAncestor(root, tc.p, tc.q) + ast.Equal(tc.ans, node, "p=%d,q=%d", tc.p.Val, tc.q.Val) + } +} + +func Benchmark_lowestCommonAncestor(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + lowestCommonAncestor(root, tc.p, tc.q) + } + } +} diff --git a/Algorithms/0237.delete-node-in-a-linked-list/237.png b/Algorithms/0237.delete-node-in-a-linked-list/237.png new file mode 100644 index 000000000..bc4d4ffa3 Binary files /dev/null and b/Algorithms/0237.delete-node-in-a-linked-list/237.png differ diff --git a/Algorithms/0237.delete-node-in-a-linked-list/README.md b/Algorithms/0237.delete-node-in-a-linked-list/README.md new file mode 100755 index 000000000..ff051f06c --- /dev/null +++ b/Algorithms/0237.delete-node-in-a-linked-list/README.md @@ -0,0 +1,30 @@ +# [237. Delete Node in a Linked List](https://leetcode.com/problems/delete-node-in-a-linked-list/) + +Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. + +Given linked list -- head = [4,5,1,9], which looks like following: + +![237](237.png) + +Example 1: + +```text +Input: head = [4,5,1,9], node = 5 +Output: [4,1,9] +Explanation: You are given the second node with value 5, the linked list should become 4 -> 1 -> 9 after calling your function. +``` + +Example 2: + +```text +Input: head = [4,5,1,9], node = 1 +Output: [4,5,9] +Explanation: You are given the third node with value 1, the linked list should become 4 -> 5 -> 9 after calling your function. +``` + +Note: + +- The linked list will have at least two elements. +- All of the nodes' values will be unique. +- The given node will not be the tail and it will always be a valid node of the linked list. +- Do not return anything from your function. \ No newline at end of file diff --git a/Algorithms/0237.delete-node-in-a-linked-list/delete-node-in-a-linked-list.go b/Algorithms/0237.delete-node-in-a-linked-list/delete-node-in-a-linked-list.go new file mode 100755 index 000000000..9ae52ddb2 --- /dev/null +++ b/Algorithms/0237.delete-node-in-a-linked-list/delete-node-in-a-linked-list.go @@ -0,0 +1,11 @@ +package problem0237 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// ListNode is pre-defined... +type ListNode = kit.ListNode + +func deleteNode(node *ListNode) { + node.Val = node.Next.Val + node.Next = node.Next.Next +} diff --git a/Algorithms/0237.delete-node-in-a-linked-list/delete-node-in-a-linked-list_test.go b/Algorithms/0237.delete-node-in-a-linked-list/delete-node-in-a-linked-list_test.go new file mode 100755 index 000000000..428e789b5 --- /dev/null +++ b/Algorithms/0237.delete-node-in-a-linked-list/delete-node-in-a-linked-list_test.go @@ -0,0 +1,52 @@ +package problem0237 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + ints []int + node int + ans []int +}{ + + { + []int{4, 5, 1, 9}, + 5, + []int{4, 1, 9}, + }, + + { + []int{4, 5, 1, 9}, + 1, + []int{4, 5, 9}, + }, + + // 可以有多个 testcase +} + +func Test_deleteNode(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + head := kit.Ints2List(tc.ints) + node := head.GetNodeWith(tc.node) + deleteNode(node) + ast.Equal(tc.ans, kit.List2Ints(head), "输入:%v", tc) + } +} + +func Benchmark_deleteNode(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + head := kit.Ints2List(tc.ints) + node := head.GetNodeWith(tc.node) + deleteNode(node) + } + } +} diff --git a/Algorithms/0238.product-of-array-except-self/README.md b/Algorithms/0238.product-of-array-except-self/README.md index 4b2a803e6..762df6ed0 100755 --- a/Algorithms/0238.product-of-array-except-self/README.md +++ b/Algorithms/0238.product-of-array-except-self/README.md @@ -1,6 +1,7 @@ # [238. Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self/) ## 题目 + Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Solve it without division and in O(n). @@ -14,6 +15,6 @@ Could you solve it with constant space complexity? (Note: The output array does 见程序注释 -有一个100%,主要还是服务器的功劳,因为我同样的程序再提交一次,就只有40%了。 +有一个 100%,主要还是服务器的功劳,因为我同样的程序再提交一次,就只有 40%了。 ![100%](238.png) \ No newline at end of file diff --git a/Algorithms/0238.product-of-array-except-self/product-of-array-except-self.go b/Algorithms/0238.product-of-array-except-self/product-of-array-except-self.go index 36249f80c..402192d8d 100755 --- a/Algorithms/0238.product-of-array-except-self/product-of-array-except-self.go +++ b/Algorithms/0238.product-of-array-except-self/product-of-array-except-self.go @@ -1,23 +1,20 @@ package problem0238 -func productExceptSelf(a []int) []int { - l := len(a) - // left[i] 是 a[i] 左侧所有元素的乘积 - // right[i] 是 a[i] 右侧所有元素的乘积 - left, right := make([]int, l), make([]int, l) +func productExceptSelf(nums []int) []int { + size := len(nums) - // 题目已经保证了 n >= 2 - left[0], right[l-1] = 1, 1 - left[1], right[l-2] = a[0], a[l-1] + res := make([]int, size) - for i := 2; i < l; i++ { - left[i] = a[i-1] * left[i-1] - right[l-i-1] = a[l-i] * right[l-i] + left := 1 // product all left of nums[i] + for i := 0; i < size; i++ { + res[i] = left + left *= nums[i] } - res := make([]int, l) - for i := 0; i < l; i++ { - res[i] = left[i] * right[i] + right := 1 // product all right of nums[i] + for i := size - 1; i >= 0; i-- { + res[i] *= right + right *= nums[i] } return res diff --git a/Algorithms/0238.product-of-array-except-self/product-of-array-except-self_test.go b/Algorithms/0238.product-of-array-except-self/product-of-array-except-self_test.go index 47c801ef7..529046882 100755 --- a/Algorithms/0238.product-of-array-except-self/product-of-array-except-self_test.go +++ b/Algorithms/0238.product-of-array-except-self/product-of-array-except-self_test.go @@ -63,3 +63,10 @@ func Test_Problem0238(t *testing.T) { ast.Equal(a.one, productExceptSelf(p.nums), "输入:%v", p) } } + +func Benchmark_ProductExceptSelf(b *testing.B) { + nums := []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9} + for i := 1; i < b.N; i++ { + productExceptSelf(nums) + } +} diff --git a/Algorithms/0239.sliding-window-maximum/README.md b/Algorithms/0239.sliding-window-maximum/README.md index b2376f9e9..da4b103be 100755 --- a/Algorithms/0239.sliding-window-maximum/README.md +++ b/Algorithms/0239.sliding-window-maximum/README.md @@ -1,10 +1,10 @@ # [239. Sliding Window Maximum](https://leetcode.com/problems/sliding-window-maximum/) -## 题目 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. For example, -``` + +```text Given nums = [1,3,-1,-3,5,3,6,7], and k = 3. Window position Max @@ -19,12 +19,8 @@ Window position Max Therefore, return the max sliding window as [3,3,5,5,6,7]. -Note: -You may assume k is always valid, ie: 1 ≤ k ≤ input array's size for non-empty array. - -Follow up: -Could you solve it in linear time? +Note: -## 解题思路 +- You may assume k is always valid, ie: 1 ≤ k ≤ input array's size for non-empty array. -见程序注释 +**Follow up:** Could you solve it in linear time? \ No newline at end of file diff --git a/Algorithms/0239.sliding-window-maximum/sliding-window-maximum.go b/Algorithms/0239.sliding-window-maximum/sliding-window-maximum.go index 1cc1b6f2d..f4730c78a 100755 --- a/Algorithms/0239.sliding-window-maximum/sliding-window-maximum.go +++ b/Algorithms/0239.sliding-window-maximum/sliding-window-maximum.go @@ -1,28 +1,47 @@ package problem0239 +// 参看 https://leetcode.com/problems/sliding-window-maximum/discuss/65881/O(n)-solution-in-Java-with-two-simple-pass-in-the-array func maxSlidingWindow(nums []int, k int) []int { - // 题目里面说好了 1 <= k 的 - // testcase 里面还是出现了 k == 0 - if k == 0 { - return nil + size := len(nums) + if k <= 1 { + return nums } - // res 的长度是可计算的 - res := make([]int, len(nums)-k+1) - for i := 0; i+k <= len(nums); i++ { - res[i] = maxOf(nums[i : i+k]) + g := k - 1 // 比参考文章的分组少一个,可以减少 max 函数的调用,理论上可以加速。 + + left := make([]int, size) + for i := 0; i < size; i++ { + if i%g == 0 { + left[i] = nums[i] + } else { + left[i] = max(nums[i], left[i-1]) + } + } + + right := make([]int, size) + // size-1 很可能不是那组的最后一个,需要单独列出 + right[size-1] = nums[size-1] + for j := size - 2; j >= 0; j-- { + if (j+1)%g == 0 { + right[j] = nums[j] + } else { + right[j] = max(nums[j], right[j+1]) + } + } + + res := make([]int, size-k+1) + for i := 0; i <= size-k; i++ { + // right[i] 中保存了 nums[i:g*(i/g+1)] 中的最大值 + // left[i+k-1] 中保存了 nums[g*(i/g+1):i+k] 中的最大值 + res[i] = max(right[i], left[i+k-1]) } return res } -// 获取局部的最大值 -func maxOf(nums []int) int { - max := nums[0] - for i := 1; i < len(nums); i++ { - if max < nums[i] { - max = nums[i] - } +func max(a, b int) int { + if a > b { + return a } - return max + return b } diff --git a/Algorithms/0239.sliding-window-maximum/sliding-window-maximum_test.go b/Algorithms/0239.sliding-window-maximum/sliding-window-maximum_test.go index 12fe2bb14..d5f038942 100755 --- a/Algorithms/0239.sliding-window-maximum/sliding-window-maximum_test.go +++ b/Algorithms/0239.sliding-window-maximum/sliding-window-maximum_test.go @@ -14,10 +14,28 @@ var tcs = []struct { ans []int }{ + { + []int{7, 2, 4}, + 2, + []int{7, 4}, + }, + { []int{}, 0, - nil, + []int{}, + }, + + { + []int{2, 1, 3, 4, 6, 3, 8, 9, 10, 12, 56}, + 4, + []int{4, 6, 6, 8, 9, 10, 12, 56}, + }, + + { + []int{1, 3, -1, -3, 5, 3, 6, 7}, + 1, + []int{1, 3, -1, -3, 5, 3, 6, 7}, }, { diff --git a/Algorithms/0307.range-sum-query-mutable/README.md b/Algorithms/0307.range-sum-query-mutable/README.md index 06276ae21..e1efc295d 100755 --- a/Algorithms/0307.range-sum-query-mutable/README.md +++ b/Algorithms/0307.range-sum-query-mutable/README.md @@ -20,7 +20,3 @@ Note: 1. The array is only modifiable by the update function. 1. You may assume the number of calls to update and sumRange function is distributed evenly. - -## 解题思路 - -见程序注释 diff --git a/Algorithms/0307.range-sum-query-mutable/range-sum-query-mutable.go b/Algorithms/0307.range-sum-query-mutable/range-sum-query-mutable.go index 4d7840839..15c2aa1e6 100755 --- a/Algorithms/0307.range-sum-query-mutable/range-sum-query-mutable.go +++ b/Algorithms/0307.range-sum-query-mutable/range-sum-query-mutable.go @@ -1,27 +1,80 @@ package problem0307 -// NumArray 是 nums 的和的切片 +// https://leetcode.com/problems/range-sum-query-mutable/discuss/75724/17-ms-Java-solution-with-segment-tree +type SegmentTreeNode struct { + start, end, sum int + left, right *SegmentTreeNode +} + +func (node *SegmentTreeNode) update(i, val int) { + if node.start == node.end { + node.sum = val + return + } + + mid := node.start + (node.end-node.start)/2 + if mid >= i { + node.left.update(i, val) + } else { + node.right.update(i, val) + } + + node.sum = node.left.sum + node.right.sum +} + +func (node *SegmentTreeNode) sumRange(i int, j int) int { + if node.start == i && node.end == j { + return node.sum + } + + mid := node.start + (node.end-node.start)/2 + if mid >= j { + return node.left.sumRange(i, j) + } else if mid < i { + return node.right.sumRange(i, j) + } else { + return node.left.sumRange(i, mid) + node.right.sumRange(mid+1, j) + } +} + +func buildTree(nums []int, start, end int) *SegmentTreeNode { + if start > end { + return nil + } + + node := &SegmentTreeNode{ + start: start, + end: end, + } + + if start == end { + node.sum = nums[start] + } else { + mid := start + (end-start)/2 + node.left = buildTree(nums, start, mid) + node.right = buildTree(nums, mid+1, end) + node.sum = node.left.sum + node.right.sum + } + + return node +} + type NumArray struct { - nums []int + root *SegmentTreeNode } -// Constructor 返回 NumArray func Constructor(nums []int) NumArray { - return NumArray{nums: nums} + return NumArray{ + buildTree(nums, 0, len(nums)-1), + } } -// Update 更新 nums -func (na *NumArray) Update(i int, v int) { - na.nums[i] = v +func (this *NumArray) Update(i int, val int) { + this.root.update(i, val) } -// SumRange 返回 sum(nums[i:j+1]) -func (na *NumArray) SumRange(i int, j int) int { - res := 0 - for k := i; k <= j; k++ { - res += na.nums[k] - } - return res +func (this *NumArray) SumRange(i int, j int) int { + return this.root.sumRange(i, j) } /** diff --git a/Algorithms/0307.range-sum-query-mutable/range-sum-query-mutable_test.go b/Algorithms/0307.range-sum-query-mutable/range-sum-query-mutable_test.go index 4ba7cb96a..e18533413 100755 --- a/Algorithms/0307.range-sum-query-mutable/range-sum-query-mutable_test.go +++ b/Algorithms/0307.range-sum-query-mutable/range-sum-query-mutable_test.go @@ -6,30 +6,30 @@ import ( "github.com/stretchr/testify/assert" ) -func Test_SumRange(t *testing.T) { - ast := assert.New(t) - - nums := []int{1, 3, 5} - - na := Constructor(nums) - - ast.Equal(9, na.SumRange(0, 2), "update 前,SumRange(0, 2)") - - na.Update(1, 2) +var nums = []int{1, 3, 5} +var numsnil = []int{} - ast.Equal(8, na.SumRange(0, 2), "update 后,SumRange(0, 2)") -} - -func Test_SumRange_2(t *testing.T) { +func Test_NumArray(t *testing.T) { ast := assert.New(t) + numArray := Constructor(nums) - nums := []int{-1} + ast.Equal(9, numArray.SumRange(0, 2)) + numArray.Update(1, 2) + ast.Equal(8, numArray.SumRange(0, 2)) + ast.Equal(7, numArray.SumRange(1, 2)) + ast.Equal(1, numArray.SumRange(0, 0)) - na := Constructor(nums) + numArray1 := Constructor(numsnil) + ast.Nil(numArray1.root) - ast.Equal(-1, na.SumRange(0, 0), "update 前,SumRange(0, 0)") - - na.Update(0, 1) +} - ast.Equal(1, na.SumRange(0, 0), "update 后,SumRange(0, 2)") +func Benchmark_NumArray(b *testing.B) { + for i := 0; i < b.N; i++ { + numArray := Constructor(nums) + numArray.SumRange(0, 2) + numArray.Update(1, 2) + numArray.SumRange(0, 2) + numArray.SumRange(1, 2) + } } diff --git a/Algorithms/0315.count-of-smaller-numbers-after-self/count-of-smaller-numbers-after-self.go b/Algorithms/0315.count-of-smaller-numbers-after-self/count-of-smaller-numbers-after-self.go index 45883117e..a613be5e7 100755 --- a/Algorithms/0315.count-of-smaller-numbers-after-self/count-of-smaller-numbers-after-self.go +++ b/Algorithms/0315.count-of-smaller-numbers-after-self/count-of-smaller-numbers-after-self.go @@ -1,13 +1,49 @@ package problem0315 +// ref: https://leetcode.com/problems/count-of-smaller-numbers-after-self/discuss/76584/Mergesort-solution +type entry struct { + num, index int +} + func countSmaller(nums []int) []int { - res := make([]int, len(nums)) - for i := 0; i < len(nums); i++ { - for j := i + 1; j < len(nums); j++ { - if nums[j] < nums[i] { - res[i]++ + n := len(nums) + enum := make([]entry, n) + for i, n := range nums { + enum[i] = entry{num: n, index: i} + } + + count := make([]int, n) + merge := func(left, right []entry) []entry { + res := make([]entry, 0, len(left)+len(right)) + var pop entry + for len(left) > 0 && len(right) > 0 { + if left[0].num > right[0].num { + pop, left = left[0], left[1:] + // for any i + // pop.num > right[i].num, and + // pop.index < right[i].index + count[pop.index] += len(right) + } else { + pop, right = right[0], right[1:] } + res = append(res, pop) } + res = append(res, left...) + res = append(res, right...) + return res } - return res + + var sort func([]entry) []entry + sort = func(es []entry) []entry { + size := len(es) + if size < 2 { + return es + } + mid := size / 2 + return merge(sort(es[:mid]), sort(es[mid:])) + } + + sort(enum) + + return count } diff --git a/Algorithms/0315.count-of-smaller-numbers-after-self/count-of-smaller-numbers-after-self_test.go b/Algorithms/0315.count-of-smaller-numbers-after-self/count-of-smaller-numbers-after-self_test.go index 5c0f6e303..80faf7d96 100755 --- a/Algorithms/0315.count-of-smaller-numbers-after-self/count-of-smaller-numbers-after-self_test.go +++ b/Algorithms/0315.count-of-smaller-numbers-after-self/count-of-smaller-numbers-after-self_test.go @@ -13,6 +13,11 @@ var tcs = []struct { ans []int }{ + { + []int{5, 2, 6, 1,5}, + []int{2, 1, 2, 0,0}, + }, + { []int{5, 2, 6, 1}, []int{2, 1, 1, 0}, @@ -23,6 +28,11 @@ var tcs = []struct { []int{2, 1,1, 1, 0}, }, + { + []int{}, + []int{}, + }, + { []int{5183,2271,3067,539,8939,2999,9264,737,3974,5846,-210,9278,5800,2675,6608,1133,-1,6018,9672,5179,9842,7424,-209,2988,2757,5984,1107,2644,-499,7234,7539,6525,347,5718,-742,1797,5292,976,8752,8297,1312,3385,5924,2882,6091,-282,2595,96,1906,8014,7667,5895,7283,7974,-167,7068,3946,6223,189,1589,2058,9277,-302,8157,8256,5261,8067,1071,9470,2682,8197,5632,753,3179,8187,9042,8167,4657,7080,7801,5627,7917,8085,928,-892,-427,3685,4676,2431,8064,8537,343,505,4352,2108,4399,66,2086,1922,9126,9460,393,443,5689,7595,850,8493,2866,732,3738,7933,3666,2370,5804,4045,7903,8009,5387,5542,7593,6862,1547,6934,-160,9693,4560,7429,9989,7232,-594,587,6476,9277,4471,5979,6268,2419,6706,-727,1927,7361,9684,5519,2703,1723,5181,3545,4290,9421,4288,1656,1541,9632,1448,-490,4747,5416,4139,-845,3834,3349,8594,7882,2279,7777,9369,9917,8167,6799,-612,5604,5787,2615,7033,5986,-322,8631,1793,-612,3528,206,419,1413,8585,5658,-981,1391,8088,7035,6259,-651,3118,9105,4531,2569,7576,7981,838,5715,1387,8506,331,7844,9187,6812,1221,6916,2361,5869,1002,5944,344,310,-981,3541,960,7667,8478,6610,9678,6511,3891,468,1347,115,3683,-982,5993,1875,69,4723,9949,3097,6822,1809,4672,3064,4587,2228,-580,6866,8977,9224,-261,4311,5304,1169,-511,7881,4252,3520,517,1714,6316,9399,8902,-376,4452,-414,1282,8399,1582,4933,7642,6671,1530,6175,2321,7191,9479,7211,6559,4040,6830,7416,602,6970,7978,4941,2225,7949,7398,6964,5912,1328,9818,8268,-999,4800,2510,6984,918,2181,9142,6036,5447,4337,9459,9070,-171,5017,7625,2807,6172,7139,-966,5374,4320,1266,6637,7043,-636,4346,7651,2102,3936,6906,4677,2505,1357,6219,2778,5193,5994,4155,1350,9806,2404,9970,8132,1054,5197,1421,4908,1185,6817,7034,239,8012,1740,7582,8098,8786,3703,2030,8422,3912,3300,8238,4293,898,7025,4871,1781,3688,9833,2108,6812,4171,-539,7759,3088,9106,2839,9216,3165,451,2475,8717,410,5226,6835,423,7611,426,6514,2729,-715,4223,9212,6197,1684,7505,5464,5505,2320,2156,5838,3702,1641,6709,-930,5108,2480,3753,2035,142,530,3975,4683,885,482,7599,2955,2265,-883,6708,8365,6133,1966,1460,7730,9852,3032,4275,1292,5735,1491,6617,6958,9245,2946,-624,1845,7854,-392,3744,-978,9238,-805,3657,1313,5916,2077,6207,530,5617,9580,3298,7353,4722,3747,8642,3237,5917,4639,5602,-728,6265,-826,7002,3510,4661,-310,2975,3352,-212,9713,9852,5880,1397,2439,-820,9292,-681,8605,1298,449,223,6176,6025,3350,4342,2084,4888,4758,9008,4887,4404,9062,162,2160,1016,6123,2511,4042,1376,82,3456,7935,457,1749,1961,8787,4533,1900,4539,5425,2164,1770,8246,7766,-658,3278,5294,8406,1422,5607,4261,1927,3493,2392,6676,3451,5064,2997,6097,7442,7862,2216,5976,3368,6933,2461,9414,7472,4053,6290,2009,1017,1099,2779,8272,62,5264,8398,1890,2985,5609,4586,2658,4991,6283,5220,1668,5944,678,9951,7074,4800,8967,2062,9661,8590,471,4244,295,1796,549,8674,5724,8285,4021,1368,-958,-402,9705,5967,1157,9951,244,5400,6930,3452,1989,330,1980,2975,1402,3279,3690,4176,6125,2907,7731,6372,8838,5425,7919,2871,9449,5142,8611,8283,7954,9166,8249,-578,1611,8126,2502,4890,-571,4994,-683,3989,3653,2815,8919,2543,5254,8529,340,-624,7370,1735,2641,7211,8111,8408,5042,4490,4669,6958,1127,-890,2074,9249,3182,5455,-859,7150,9680,6251,418,5649,4673,615,7114,6124,6321,7104,5576,1016,2925,8126,289,-934,2022,6877,7511,-267,1696,2912,776,1660,-501,9965,454,2819,7877,6270,6488,4653,9768,3312,6005,-493,7951,2899,6184,8353,8827,1606,2664,-960,8820,1960,9089,6693,-364,2342,1542,7639,627,2780,2517,7982,-853,7262,24,2550,-796,9125,3520,4421,2494,164,6166,4169,7589,8133,8186,3013,2380,3445,544,6316,5219,4218,-38,8178,8832,4529,8194,4040,428,5452,5493,7630,9085,8922,7477,2353,-585,7635,4205,2173,1944,4167,3494,6455,6188,4657,3586,-325,5553,9911,4256,1723,1802,1493,9194,5591,3196,-223,2691,-117,8906,8400,2789,2352,7183,2483,5578,4266,-306,2400,9131,7736,2118,8348,3815,740,6895,1493,9705,9754,5703,6496,5884,-476,4455,2538,4539,5749,1977,1016,5680,4140,3049,5450,4040,6545,374,-230,5685,-274,6769,6985,-798,-372,4431,936,7060,2754,2744,5273,4204,6323,3418,495,5399,593,6757,741,-51,4156,6194,7365,8369,3761,2272,9370,2314,6914,4052,2152,9922,1067,4512,4572,5720,9598,4106,8166,692,5223,5961,2677,364,4143,3406,3736,9542,3765,7079,6883,9523,9919,9318,319,9929,6134,1143,4698,9612,106,7341,4280,828,6894,2226,2430,5142,9087,6927,9619,8258,7550,-927,3211,6563,1105,4252,8177,3778,5259,3520,6266,7478,3980,1575,6036,9990,4429,9182,5333,5816,7391,133,9336,8056,7056,4639,692,7110,2537,6815,1097,8222,469,9261,2375,-586,4661,8480,5538,8136,6058,4696,3731,6606,-731,1014,-90,1654,6886,6107,2479,8635,9985,6760,-696,2310,5149,7655,1957,8508,8067,4267,6264,-921,-105,-709,9832,5404,4340,4874,1380,9725,4136,6233,6332,3566,2438,3484,5772,1978,8674,8419,4552,7302,5311,1427,5316,5714,9505,-344,-298,9046,8574,6079,7278,9278,9025,2342,3776,6316,7669,-144,-522,4363,-569,5063,3258,6046,4751,4686,7960,1783,6635,4880,8120,6343,2867,9717,8764,8045,9294,9375,1931,189,6325,-139,6281,-388,5924,4815,1116,927,710,5047,2539,8499,4743,206,5781,4462,3542,8633,9148,6598,-662,3800,1253,-13,3688,2241,1134,7568,9947,7351,508,63,1095,7667,2773,3747,5769,235,5077,7841,-197,5441,9539,5216,1953,346,4655,1223,2132,1612,6767,113,3593,246,3768,1328,9948,8542,3259,1908,2411,9961,3524,8384,3801,-671,1815,4455,5425,8520,9058,9325,6496,3711,2433,1208,5974,8710,2362,-824,1243,6881,4113,1648,9862,6678,8915,-457,8099,9243,-81,8162,5458,4257,8471,-832,2291,7328,1319,1587,3912,3299,1441,5968,3427,7633,9174,9637,5881,4418,6218,5905,6847,-522,9440,7428,5545,3152,9299,1731,5722,-4,2846,9369,2817,2517,9466,365,1006,2647,8186,2194,9343,3738,9113,6461,5186,7680,3790,5677,9850,3599,3606,8449,-49,5545,5368,3938,9055,3488,35,6692,5937,6324,6136,8021,6032,3526,9639,6555,-47,4333,9436,1621,3893,9982,2777,7300,2105,6549,4584,6186,3708,5739,257,1729,4840,6098,7953,6575,1176,3646,637,169,3151,9486,9133,3686,1780,2044,-725,7576,8602,318,5126,-503,3678,8473,366,-273,6206,3329,7449,8260,6356,2584,-507,9635,2191,2085,3296,9386,1934,4715,3596,8387,5777,7565,1498,2966,6248,5309,8700,6752,579,-517,5712,6112,3443,5189,9322,7061,6511,1100,8506,5422,5206,6468,6521,4366,475,511,3687,1438,7213,9831,1864,1997,-922,3933,6013,5663,360,1203,7981,-486,2277,4924,4344,1916,4247,6971,2184,6671,5118,8156,5660,9056,4206,1603,8901,-999,8940,6757,3564,3756,3216,4452,1999,6922,6630,-882,9982,2340,-698,904,8642,903,7716,3505,8439,5719,4893,-442,3284,567,8991,-2,5119,1017,8683,7914,-683,-938,3958,7051,-729,8211,-699,9536,1634,1405,4296,-770,8602,2730,164,9906,331,584,-955,6185,4632,4550,4369,5737,8825,7303,2248,9028,3021,8359,1754,3037,5342,4757,4787,7864,4949,7283,1571,5827,3851,3148,7441,4384,5452,5609,6773,-727,355,2989,8771,3370,244,8380,9480,4839,8414,9408,8085,6775,2640,8403,263,1935,-544,9270,6237,1017,27,1780,1114,9586,5859,1227,5593,3130,8592,1040,7364,3465,-4,94,301,2938,1555,7759,5278,4390,-167,4905,5228,2601,3484,2349,8010,3956,9257,1393,553,3389,4562,1260,1966,9315,4666,1569,191,3479,-717,-60,-477,5924,2027,5531,4063,5460,3232,720,8161,7049,7375,1440,8728,2705,2994,7680,7914,71,9188,1485,4452,1425,5519,4,7129,4943,960,7946,6709,7035,-591,9704,4897,-402,3870,4447,8932,9575,8197,8382,3640,7782,-352,2209,480,7902,4827,852,3,6087,5001,5581,-582,3275,108,750,3642,1096,7237,4662,6547,-271,8013,-33,1713,9345,7500,1560,295,5041,422,8657,9374,8883,4466,6731,1191,9552,1462,244,6637,-722,737,3542,3099,5856,-490,3675,9865,7561,2431,9036,5846,7077,8970,172,2696,1510,8717,2647,9465,5455,8510,4990,211,9327,-432,4994,3262,6228,818,3362,1782,2079,-551,1937,1974,1956,6903,7234,3085,4678,9674,3635,2843,-125,3930,2661,702,150,5492,2351,2161,3758,8235,2101,3287,4149,4510,5726,1075,-572,5022,3096,8546,-235,5658,7021,7516,-849,3923,6519,6023,-67,7530,9333,-749,1991,8833,2535,4104,2583,1631,7557,266,4937,6492,2077,6813,4315,9968,-723,5753,2833,-984,4953,8055,9845,3436,3593,4356,6059,8632,4472,513,1409,641,-49,1407,1049,1448,316,945,8206,4936,3395,7808,-134,28,9538,9082,-9,589,9798,6046,2165,6846,1924,6466,4648,6240,4513,5002,5493,2400,3220,5578,4002,6948,5161,-426,3673,9618,8592,4690,2011,2248,8558,7890,5397,2414,3568,8190,9334,7378,8542,4147,5964,6820,7219,6007,1407,5325,4191,259,7098,8980,742,3111,3783,1089,5273,6546,7302,8216,953,1804,-481,-79,7487,9827,2757,2132,-836,8545,2017,7649,2550,8651,-259,112,9355,5483,6124,4499,3851,3927,3561,5420,2964,3498,7861,-727,7656,4914,596,5593,2520,4104,3810,8500,7971,1303,7801,3652,7840,8550,617,1739,5990,1798,4251,2104,8698,197,4552,6506,8751,6143,4879,5305,4796,3192,2759,5221,2096,4803,8211,4675,5288,8721,435,6416,1868,-887,8444,5363,5804,-485,6296,7503,5177,1445,4364,8153,8206,-230,4387,559,4229,8308,323,3792,9869,4525,5948,8213,6352,1412,-390,9143,537,-582,6238,9643,1072,400,4239,9040,5220,4827,6921,9102,8268,2914,1248,5472,6122,2742,2638,7357,1202,5933,3230,5463,-784,1159,7994,8755,2976,7185,6975,-299,-256,1368,9408,8662,1245,4797,8642,9461,1115,-815,-872,8049,8542,7994,6512,8794,5838,170,3264,5602,5492,4453,6291,1590,3856,7289,9827,4455,7641,9615,6093,4468,1733,909,3910,865,8837,6111,8485,2202,8003,3576,8703,948,3971,3893,9810,3662,403,5996,1806,6435,6070,4199,8086,1765,1545,9266,8059,2547,6616,7594,4092,7027,2958,1901,4317,5928,7803,7822,6045,3648,1002,7468,3107,7911,9291,7053,-799,5713,6362,9234,7945,9627,449,7527,6293,4788,8137,9964,-194,6293,3880,5948,6131,1404,8863,3288,3936,7135,4852,5818,7153,1515,2695,7623,2483,-229,3272,4167,9091,8562,1823,6680,-393,9592,3987,3519,9027,431,6601,3349,4221,2650,9707,8329,947,2896,7380,271,4265,7562,9119,1644,276,6563,6196,1899,3443,4258,814,5490,-442,6866,2299,5408,8618,1679,5215,-112,3825,5229,1501,5265,8302,9624,3512,9561,4379,1683,9040,9995,4379,7870,7286,8820,5388,9639,8669,7312,4337,600,1832,-598,1490,7416,7613,3554,1448,1881,7148,4921,6560,1789,4394,5017,7106,8568,349,9005,7629,8863,9906,2578,6780,2999,796,5315,3078,6506,5431,3948,2838,3816,9748,1747,2969,1603,8499,9807,9594,8628,9711,9641,1328,561,4425,683,-858,5647,5565,2354,1704,7008,6352,1793,9380,1218,-636,7071,3875,7003,-106,20,-233,6777,6512,5610,1879,7585,-498,-216,9206,-282,4464,4777,723,3981,3419,4044,-926,8941,9878,3411,8201,7237,6021,1697,4294,1541,9335,459,-450,-195,4427,331,6519,4529,7777,3748,4326,8234,6921,1101,6842,-109,3938,985,4190,516,589,4272,1807,8101,597,4041,5117,9822,882,9580,9769,7662,3042,146,6872,5925,791,2336,5846,2183,-923,3747,6417,-107,6681,4133,9693,332,1465,9276,1447,678,7049,6248,8105,-348,9761,5127,757,8455,8143,3706,7640,5650,354,1019,4300,8655,9336,4627,306,6901,-56,4467,4367,6901,8791,2412,192,6439,4356,-847,5751,4701,7719,3345,6927,-361,5697,6065,3873,1565,9350,3172,6401,2312,2249,3740,1633,4289,1829,5730,8011,5999,8216,4922,-405,1165,9984,1589,8064,4536,4097,7626,5934,46,3502,2133,4861,6149,9568,4446,6372,9923,-602,3980,8588,3613,-908,3301,8202,5073,4156,2813,7170,1164,1578,8893,5499,7758,763,549,9917,3841,-761,8625,2424,-317,9725,-540,287,4221,4157,6819,7719,1309,6090,1731,6922,3700,5172,664,-436,496,7288,2719,4908,1976,1575,4507,3410,53,-659,965,1691,1707,5954,-175,2736,7619,-931,4906,-768,7343,59,8041,8075,1058,2702,6003,9820,6096,2527,5953,-717,883,-231,6228,1391,358,866,260,3101,8641,-372,5667,1210,657,9227,5544,4504,4647,2667,947,8308,6520,329,5929,9997,8624,4168,5434,-993,1131,2820,2748,3763,10,2094,2403,8224,6195,4941,9734,-85,-398,6054,496,5659,8596,-942,4663,1754,9837,-233,7771,4194,8622,1651,2475,5615,7846,3913,1623,1083,8004,5761,6974,305,7640,-837,3782,656,-717,9048,3480,5440,1502,1223,6831,7456,2639,1605,7579,1646,5079,8384,2315,1148,-872,2480,4633,902,4336,821,-266,734,1137,6649,8472,7373,6875,7803,1285,7911,4299,2857,2842,1448,340,4335,429,9776,1335,7687,683,4514,4751,1479,936,911,6723,-438,593,7598,8586,5595,-111,8732,9909,-260,8150,3642,3685,6775,9833,8285,2350,1558,6610,7478,5397,377,1331,7452,6149,4946,-16,1431,8751,4324,8417,-814,5213,881,6885,7087,6070,1096,1359,4582,3919,1093,2530,8169,-916,6475,668,2965,8395,748,8338,1720,1324,5422,9287,5921,7563,2004,5338,5460,7600,-20,1487,1021,2152,71,6892,6357,-104,9696,1950,-525,-324,9454,4285,4928,4694,3226,2359,8443,3353,1362,8109,568,9809,2374,8087,1530,486,4339,4550,9728,7511,3136,3666,3063,916,541,3674,421,3044,3382,8974,-269,8042,6509,5186,3427,3510,8015,6505,5923,7052,8995,3886,8802,2722,6875,5622,465,1562,4542,-824,5079,1040,1446,9077,8536,-215,8083,1398,2181,1753,5125,8284,2717,5165,3487,6588,903,5640,3969,2772,1301,8207,7933,1308,4202,1029,-397,9190,-829,478,6586,-563,7956,-903,1485,8742,7332,3453,5534,194,2538,8786,29,5057,9897,-641,1517,6947,7080,5235,-514,1985,4365,4503,6966,8363,4894,7093,595,7236,6176,880,6247,2312,540,3776,4902,5499,1746,5848,356,5310,5425,5038,6360,3638,6433,4940,-286,5083,4480,3923,1785,8882,334,4927,9559,8792,4666,3768,9420,4492,3344,9996,5597,6670,9026,3778,1827,8328,9543,8398,356,8833,7291,-831,8190,-201,2713,6153,7648,3413,2336,271,4000,7087,8194,2358,627,1600,1974,1332,9932,7769,-620,4275,9764,3689,1293,3888,7263,837,-26,1669,-357,9699,5446,8475,3114,3057,7832,626,6912,4788,4679,2674,5367,2838,1970,3505,4018,693,6753,5461,4766,2281,1306,6972,1764,9671,1153,7722,-148,9946,5831,854,4605,6310,6948,2018,5290,-541,5899,-555,5220,1609,3818,2086,2699,5137,6093,8520,9930,6770,7570,3113,3629,1886,9551,9362,5585,2498,9412,9107,8208,89,48,3235,5614,7411,4551,3203,9746,8057,1263,2113,6876,270,2090,-7,1649,6172,6607,220,1366,5694,2569,-519,7645,5665,2938,6192,1994,2985,6290,-458,-867,1643,1187,2065,2078,7302,2904,3684,2407,5816,6043,5516,6317,8489,-684,-609,2925,1399,4185,6900,5552,4558,7980,5530,-943,3672,5107,5763,414,4781,6718,5509,8952,7528,3756,9731,7352,4254,147,2684,3434,8231,9878,9611,1684,5510,7124,9059,4569,-139,2966,6949,8356,1406,906,6581,9660,1030,2649,4878,2568,334,9531,5667,9102,7191,155,3085,5959,5141,109,-312,8457,7882,1920,-665,2709,9119,728,3992,9354,3566,2174,8331,7861,971,3045,8428,5954,2486,2582,9346,3038,8231,1414,4279,6878,6350,-622,2991,4372,6911,4604,21,4828,4690,9142,6293,9799,1382,4552,3033,3577,816,6945,-495,5553,6557,760,5344,1122,8722,5872,3912,5560,6512,3608,1818,-649,9391,2875,1556,-69,849,788,2844,-540,9727,5641,5131,9668,3971,2971,4612,8215,6910,805,7064,8866,1457,6679,5047,4730,2273,7333,6570,8396,2280,996,3813,1634,-825,1535,4462,1072,8452,1727,9304,-672,6998,7530,866,1670,1989,5024,7449,7819,9974,1438,8971,2586,9806,4011,1032,5059,4537,4484,-112,3292,5738,6848,3824,27,7462,6771,9221,-406,5300,4572,6666,2385,4347,7939,7728,4780,3224,60,2409,2944,7777,2859,2057,9543,-401,7318,3605,480,8773,3419,8669,7405,-710,2190,7699,2235,73,3635,3558,6149,234,5206,7540,4983,4369,9483,8050,2420,9645,1315,7895,2844,9540,8159,8570,7474,6953,1040,3061,6179,9557,-284,1446,1289,4901,2021,7562,-732,1244,5005,2082,8427,-205,-253,3756,1403,6612,5085,9844,7956,8671,5829,4068,9505,7809,3178,-29,4789,9062,5391,1885,394,-146,6184,9288,916,7399,3402,3252,7584,233,-381,7594,-886,5536,3478,9891,8255,9435,1979,1459,3287,2771,8715,5793,6542,8549,7959,2729,4864,9049,8265,-904,4930,4980,84,4311,330,5980,9263,4042,9335,7134,-538,2340,-673,7051,8998,1808,2763,5070,3005,1167,4604,2564,5557,8652,8129,202,3396,6814,6708,3055,9245,-323,5964,4349,4550,9209,-200,7533,8839,6623,7406,9111,9592,1538,3843,1962,-941,1453,238,2624,7539,2111,3177,9574,3404,369,2437,3007,2834,5334,9612,-287,-742,-585,4028,9908,5594,1769,3467,7964,909,6543,5628,9248,8075,4748,6446,-537,6265,7987,490,9359,2894,6115,5055,-150,5522,8748,4998,2335,4229,6110,5335,2069,914,8491,8404,-36,8730,8229,5085,7524,6799,-530,3132,4600,6914,8407,6439,8630,3859,697,-240,4056,8935,298,1907,347,1149,3555,8726,4936,423,3145,8372,3849,2315,5842,3824,549,4898,7676,6746,1133,9779,7377,9611,64,9987,9405,-701,2016,6889,6815,6191,4672,-107,2521,-20,346,4686,9064,-185,8709,7213,1684,9009,-567,6676,213,7708,4586,3242,-658,8752,9326,6683,6736,3492,5809,3542,310,2098,1024,9670,3049,-149,5850,8121,2547,151,1844,186,1085,-200,3087,3051,7712,3368,1428,-845,686,1927,6312,7841,817,37,8283,3504,6467,9795,-394,2940,3452,4076,2918,1123,2981,1349,6682,4047,4404,9545,8878,3566,9100,897,461,-519,1000,2577,23,2979,2801,3804,3444,1375,8297,5401,1113,8479,7745,-315,7226,6173,5289,149,4569,-14,2413,4840,5928,-431,7021,2984,3493,4001,3911,-815,3501,4011,-466,9164,6402,9830,6303,-884,5336,1826,625,4335,2956,5501,7576,2293,6779,7043,8022,8815,9971,8377,5663,7871,1327,4521,1468,8710,5115,5101,1698,4931,2247,6158,-933,9012,3824,1698,62,3157,9741,2613,1688,269,5702,5935,8921,-50,6172,7181,6173,5737,8902,110,8319,2188,9720,-910,-783,-894,1169,344,-381,1031,4143,8407,1371,820,7092,7738,901,7988,9350,5655,188,8884,6695,597,4160,6252,3057,2499,1246,6258,1557,3484,-263,3367,6956,1552,9861,1870,1328,-487,8651,8045,4475,4153,888,4266,3090,3226,6372,2077,2542,9401,-846,8973,6449,8149,7662,8781,2881,2866,7805,511,6434,-88,-569,983,8913,8576,1100,3892,9272,6291,3979,1184,1142,-140,3747,9029,5235,3330,6124,4539,6871,7353,8384,8139,1783,6688,5392,7359,-881,6512,5048,3348,703,7283,-828,484,4245,7655,628,844,2853,4287,8989,1721,8261,9047,8691,9802,1022,746,1955,1379,9983,3465,6810,6503,8667,9067,4670,8532,6461,-542,6735,8007,6979,823,686,7618,4376,3532,8143,2348,57,7990,6996,1530,2846,8801,-634,2633,420,8171,9375,5993,5918,-409,-300,4405,1151,111,6599,-29,2646,1664,7720,9569,437,7964,1146,5299,7997,2041,7162,9109,7680,4940,4163,6989,1937,3220,-353,2643,-864,9167,1211,-671,6189,961,753,2407,5322,5093,5146,4215,8762,2163,8048,5623,5239,3023,-984,4775,8600,1075,907,8847,-998,1241,4057,3466,-11,4284,3750,2755,7501,6002,2615,8465,8455,6595,8491,1726,4575,3557,7816,1119,9954,7310,-938,-680,8347,7448,4705,4354,6115,7185,6905,4775,931,9458,-195,7426,134,982,8722,8698,8888,4549,6816,6509,2757,6875,8647,3833,7503,1436,6233,4728,9187,2520,9494,5585,3689,6427,9999,1353,1768,2965,3554,8629,843,-255,5551,737,7897,5039,6233,8282,5527,9305,1910,6272,3313,1329,606,585,5703,4571,7306,3677,5433,7016,-441,104,5925,8177,8282,518,6288,6746,7710,9942,-147,3694,1205,-802,5449,9765,-321,3115,7149,9418,6934,5718,9295,5493,1931,1092,8171,2770,3573,-133,6384,8499,7071,513,5687,9925,4356,4417,3357,2113,9150,9248,878,3289,7910,1300,1472,9702,1076,4844,8374,-956,-855,5183,8348,2598,9007,6800,3825,4709,4678,6883,8787,5185,1271,8774,3466,153,2436,7253,7522,2179,700,5966,3882,5316,6695,280,996,7831,4494,-594,1450,8196,2969,4678,3972,5363,9918,8438,6073,3920,5828,4561,6150,6280,8809,6542,6128,4791,1350,-589,6830,2692,2157,5506,4480,6019,5544,6751,7913,4909,5712,7593,447,7773,6073,3664,6156,398,4679,6734,9039,5826,104,3543,740,3359,6617,919,1511,-387,4985,9964,3583,120,3639,7110,3497,1623,6074,8766,7144,2716,464,5176,24,3180,2653,710,938,6663,2737,3919,5560,3191,9070,-12,7016,6784,-16,4844,5995,3293,-644,4175,5477,347,466,1721,8960,2424,9477,5932,2160,9940,9098,3411,7409,4809,5506,6784,7598,8500,5358,6928,2703,9115,5889,1595,5599,6316,-611,-572,6462,2943,7732,2448,5168,-452,69,2491,-341,9973,3656,9792,2915,6347,5450,2884,1273,5931,6361,2362,2680,1149,346,8518,81,7770,9916,3828,4938,8936,-35,5269,7662,8818,3797,4916,6567,3861,4820,1758,5910,4899,5046,631,1956,187,9079,3463,3873,6770,976,9415,2778,9935,6030,2278,7929,7813,5039,9346,1346,-836,5447,7919,6947,6608,7639,9953,165,-776,5969,2198,3260,5540,92,8400,5052,-907,7216,8854,1410,6368,6307,6411,5546,986,726,6800,9022,2211,4972,-217,8152,1914,5270,9754,5949,6864,726,4871,3831,3540,-645,-798,3752,2859,2383,8457,9116,1168,9817,290,4303,5551,237,8233,2384,-710,7912,9657,8341,8946,2651,9903,4308,5646,1396,2054,7935,3975,-983,3909,8766,9371,1278,-82,796,2209,2621,6283,9236,3358,9182,3481,8336,2099,6899,4510,5784,4174,2102,6583,1712,-983,5615,1784,-800,738,8470,3685,3070,8304,-131,7591,157,-909,4277,8073,3007,9684,7121,-551,124,3560,-706,5659,7542,5828,-194,6697,7534,2138,2000,908,6477,6952,3684,900,9580,7501,2291,56,5219,6511,2902,-709,2196,861,7394,3737,5238,5262,5997,4872,8996,7659,3325,4221,8563,3728,5191,1392,6445,9212,-223,9082,791,863,8972,-673,540,7716,6880,7429,-669,548,3405,7392,4962,4841,1357,5961,6008,9801,466,728,2745,9750,117,1889,944,-921,8483,4964,8539,8830,9403,3676,2883,535,2524,2992,8236,4812,5617,2779,5567,7816,9140,7324,5307,3336,9102,1560,356,9530,7293,1810,9141,6338,1589,4773,7826,3063,6381,6098,1790,9625,5595,1825,5925,3959,6992,4332,6019,-7,9074,1209,8322,1554,5827,785,6916,7568,5127,5883,5304,4602,3496,3228,9568,5287,8425,730,9021,6057,9450,5053,-549,4588,1451,3337,9475,1050,1681,7256,9419,3478,9569,148,-643,3903,9674,5404,2836,6783,-620,2610,7080,5057,9577,5108,4592,7221,435,9225,6914,6261,946,-13,5981,3017,4569,1626,1940,9176,5170,5763,5104,6629,7879,4751,9063,2349,8173,6337,3,3033,9631,4907,4653,8077,6579,9433,9700,9863,3082,4582,6033,-745,8549,576,7137,9155,-407,6198,570,7831,2656,8994,8800,2727,5829,6872,1869,1247,6746,6617,5404,8737,3568,6186,5350,4347,905,5032,8501,7058,8724,5425,2822,9372,333,4516,8713,6075,3536,6239,7811,6455,9917,9111,798,3249,-761,8918,62,3911,-45,7024,5920,4266,5390,2835,9087,1404,2581,3730,4396,9259,9484,9377,3897,2307,5673,4124,4050,92,7264,4052,4225,6460,4787,3625,6457,7829,8027,474,4449,6819,7910,7831,1599,6774,9749,6218,9215,6607,3967,501,-258,3484,1796,9745,7875,7622,4869,7634,9116,5130,7535,7154,7571,6190,2406,8232,8883,5822,7172,4149,7520,4658,6067,2653,2310,84,5280,7145,256,8705,703,9054,6812,4360,2821,1339,1168,4943,9323,-639,1335,8393,2908,9985,4847,3079,9097,2895,4759,8293,4916,-587,6565,-431,-750,4103,3136,4561,4751,9179,8330,-571,9926,-670,6096,5633,-286,3281,3739,-280,2667,3104,5136,9012,8767,6918,8491,8572,4128,862,7640,2360,-106,1030,6697,786,1948,8788,8659,9061,5596,8445,3305,5846,6511,4999,5282,5321,2797,1735,5392,5772,-23,4934,222,-955,5738,7119,5337,582,3203,4554,4391,-787,-667,3235,979,2056,6200,303,9188,2821,3700,9942,5834,7193,3379,2620,1318,7027,8549,7635,7231,1701,2895,5658,1647,-34,1697,1806,-588,4781,1408,127,5403,7320,9995,8595,8258,4048,-698,3736,7343,3267,-466,9779,8551,8014,2617,9496,6011,7347,6559,3488,2522,9264,2660,4729,63,-408,8100,7765,-126,5437,4202,4682,9065,1020,184,9450,5997,1759,4491,8932,-542,8064,2530,5500,-911,7157,7817,4255,6655,5277,9215,-300,9331,1023,9097,4802,1272,7031,9200,7906,7953,5007,1354,837,3016,9036,5377,8707,60,1745,1277,5390,7552,8232,3589,1080,1615,-221,9090,2625,6183,4632,5437,225,7686,9600,2262,9179,8517,4844,2635,4488,2928,7545,4530,7637,332,4370,4796,8779,2871,7834,4565,6267,1569,1241,6856,5165,5350,4637,3317,505,985,1922,7994,4171,2136,5138,353,1610,6611,6206,3177,63,7776,7472,-168,8225,8910,1315,4553,7458,6912,3164,5876,2112,6395,8937,2238,8023,6836,7014,6256,-253,8723,3980,4737,6783,1909,2268,8811,7558,4305,5117,-764,1447,806,6672,4467,3624,79,6709,55,1327,5461,5277,3032,5611,-147,5933,8557,3990,2775,1162,8831,-676,595,2646,6274,4454,1990,6947,941,1086,5290,4710,5441,6395,4669,4330,6649,-867,-979,654,6599,3640,3881,2629,-726,9893,-921,4094,-133,3993,1343,1748,5781,5265,3307,246,3766,1925,-39,3778,8622,1755,5092,5465,7080,4440,7556,8290,4722,2720,1452,8235,3161,6204,3471,5575,6561,9884,5349,8356,1173,8844,1406,5924,8716,-42,2456,384,1615,6979,1089,922,2384,5158,2279,1872,837,2086,8190,4128,1907,1249,757,2754,6781,3428,6485,7708,2196,2575,-59,6810,8732,5624,3299,-393,9155,-939,1079,1728,295,7104,226,6305,4489,8674,-132,9217,8226,-391,9832,6918,2464,5522,8691,8957,544,3175,1748,4981,9728,8572,5363,821,7583,4628,6837,3395,2012,7800,935,243,-474,7930,2851,3992,7960,1205,1232,1115,-411,7323,6201,1144,1801,1284,6310,2446,7227,6151,503,1367,5396,9645,-361,9317,2667,2735,1224,6687,8485,2565,1055,8723,4965,8675,2611,9534,3661,511,6929,4668,2734,6503,1325,7322,3390,9864,2976,2158,5116,5864,2719,3720,2555,8877,8625,2232,3942,1084,6029,3555,1374,616,533,7791,7466,1212,9619,9073,280,6521,713,494,5435,3423,6602,9608,-12,3012,6815,5095,2339,1629,-452,-296,7626,7548,1902,4234,2913,5500,1143,6403,1497,3835,2566,7443,307,6450,7850,8868,3108,4319,1984,-635,4665,538,2272,6845,3617,8742,9432,4058,4932,9791,8533,3156,3602,1474,2046,2658,933,6871,6526,3036,2083,8177,2480,4342,6520,5618,4681,-353,-299,250,6380,6004,-322,4727,3124,8033,7712,9454,2435,8778,8386,2100,8332,536,7170,331,3734,8262,7382,7712,3636,1060,4770,4147,1025,5148,3605,5098,6373,554,7897,3682,8309,6594,8575,660,6221,1356,921,2362,3148,8003,7977,3413,9331,5870,6885,5087,3410,6133,841,9934,9316,1043,5055,4670,9511,6793,3507,3704,5458,5339,8234,44,4826,7931,616,9200,4115,67,1366,816,5670,2180,4867,5822,1250,2043,9005,2272,1569,9302,521,1957,1001,8750,205,-145,7029,8227,8054,2936,2273,-513,9315,-131,8312,915,7917,7755,5103,3280,6700,-133,6596,7581,4074,3973,8589,4535,2644,2732,746,7097,8639,7887,8990,8606,6213,9174,8591,192,4051,2199,6020,1778,3931,3093,3907,7519,2074,-394,2739,281,3194,4692,5142,5730,-759,1884,3401,2021,7432,-981,3790,1797,8945,-248,8768,1190,-132,5078,2503,4080,9443,3150,9194,758,1477,2172,8608,1758,6204,5422,9419,6247,5378,4948,6218,4909,-299,1486,5239,5123,2470,-173,6588,9831,-581,6357,5046,1973,6224,1536,6424,6706,4126,936,9321,4425,5712,-127,276,52,3646,1216,1426,9720,6879,1722,4464,3425,-955,7568,7205,9326,2929,2536,3121,3272,1908,506,9725,7957,6154,1173,5803,-798,-977,2980,4869,314,5292,-216,3823,9664,8202,-462,6105,957,3934,194,5899,5852,831,-799,5891,4627,9478,4842,9106,8799,3900,7259,8797,2244,6539,6269,2130,-468,9109,464,5537,-686,2491,3077,7529,2502,373,-682,5650,8394,3820,6231,-391,6579,2828,1288,8065,7174,1546,238,8909,2685,-571,6370,3903,6762,144,5039,2046,3364,1712,5891,7048,2870,5597,9580,7372,2002,4702,4989,4684,1715,4484,6583,3927,1554,4197,5558,8588,2800,3499,1444,907,545,2175,6796,48,2778,6798,8490,9866,259,4396,8487,2244,7965,5069,2796,2294,5988,9492,3952,2883,9422,9946,6299,4511,4618,7431,2151,6899,6004,-229,2824,-426,7476,3190,9344,2458,6005,5827,2105,2582,412,9897,6649,6166,4863,8724,2077,6457,1623,9299,9878,9006,-212,1685,9297,8671,4721,3614,4210,2023,704,4146,5015,8289,3013,-457,7955,3342,6514,-950,7728,6703,6509,2197,5639,6375,8515,6276,2871,3724,338,3450,4048,-707,8831,400,8877,9803,9612,7361,7999,2085,1480,6460,9261,7444,357,3112,6072,6503,5260,7309,8935,5869,8519,6809,9783,9062,4832,1427,214,2966,5235,1320,-432,6445,9920,4410,5447,5527,8441,3231,9122,3249,3806,624,9171,-152,1426,657,8886,2039,7147,9008,5103,4331,3203,4919,-668,4928,-981,1950,8154,3275,7464,9797,938,1161,1342,8275,6522,3673,450,5846,8633,9722,5109,5374,1490,-965,1109,9131,3588,4838,8917,8146,8216,7968,7333,245,-861,1763,6059,8099,9451,1741,9029,8916,2061,3959,1613,-41,5068,8941,1295,9840,4254,6566,1823,9402,1534,-205,8597,3371,1065,4264,1117,4864,5847,9091,472,-529,9467,9389,4274,1005,449,2865,9541,9786,4103,2196,2479,-331,9948,547,8202,618,9875,7244,2043,9947,8998,7501,7002,-461,5337,865,-698,126,8237,3823,8832,7661,72,223,4523,2384,1131,-319,5384,6675,6280,1248,4429,7786,-37,7173,2435,-704,5289,6544,9505,8,623,4541,6642,2693,464,6652,3810,7080,2110,8271,3999,244,4346,7996,2228,8952,5381,2139,8632,8561,4747,4263,9657,6640,391,2132,4517,6833,3711,4470,9554,3652,3243,8485,667,4697,7899,3499,9251,5661,-148,365,3341,-334,5506,9416,326,3125,8000,8692,2278,2419,6572,9732,7205,-570,8282,7041,5291,9192,7600,8801,9616,1304,3040,345,1652,5736,-901,9252,1019,4695,4581,2284,9231,1401,505,2388,8236,4930,1236,2360,1826,-663,5360,1387,4665,-218,1938,4893,440,8815,189,1347,6904,5859,5557,5235,-519,946,7802,3990,3403,7323,6859,9923,8979,3904,3879,3369,6471,6430,1681,-38,498,1047,6758,3831,-830,3671,2901,7956,2470,6235,8856,1058,-636,6089,6333,621,5480,6461,-217,8573,3283,7374,8914,8250,8709,1466,-285,3759,8279,1211,2940,8233,-334,9013,4677,6821,8333,8439,2727,3338,7733,9295,941,5909,7098,2262,7158,-785,732,7157,60,1189,7136,9122,4348,9026,7906,6322,6245,7255,-335,9573,6818,-7,3527,7858,-211,2700,6095,-297,7349,2744,-90,-623,5371,5875,4612,1816,5475,5976,-254,5882,6994,1630,7897,1595,6900,6267,8857,7339,5310,7324,4696,-8,7384,710,6696,578,8881,1436,6935,4246,7231,-991,2560,8157,2267,6036,9486,1557,1305,9612,3119,8814,7461,5154,6960,3696,7071,4901,5845,6840,1968,7724,9836,4265,2003,2651,5782,9900,534,8648,2660,8759,4969,1577,4302,1304,1636,7804,4583,4930,2737,2252,2968,6843,7627,-249,-863,3117,2491,4794,7090,3956,-361,1105,277,3979,-811,7344,9425,9065,3798,2050,3923,8915,6868,2756,4234,9352,8930,4847,2958,7037,2239,2729,4382,2954,2767,-175,6318,2167,1573,3805,1021,7218,5935,7360,7200,9314,5443,7491,843,1821,7390,-388,9842,-813,6265,5646,3537,1936,3425,7249,9037,406,8650,2782,2610,6968,4068,8349,3153,5628,1694,4333,5730,2447,3388,3731,-179,-524,-867,6634,6928,5036,9175,7178,5985,9500,8982,3791,8220,7248,8101,-102,9158,4232,936,-149,3760,8957,-62,5193,8949,2254,3542,6445,4361,2939,6470,8529,1696,7003,1632,7384,2359,2904,3691,4666,3147,403,5992,6926,-955,6446,-124,2638,4207,2517,8094,-412,6297,5734,3262,1300,1489,2755,3285,4322,389,5738,8810,6065,2176,5387,6264,6616,332,7727,4304,4276,7090,4640,5770,3856,6320,9094,-199,6178,864,-177,4361,8137,6536,6414,5356,5045,6211,1653,5602,-278,2420,3357,2519,8417,2037,8418,-66,7120,6700,5178,-710,6596,6126,3024,6148,9619,6128,8922,-676,9909,1662,9526,1434,8366,-516,1351,8167,-525,-51,3978,9521,8915,6515,447,-993,236,3256,573,1179,8137,4173,691,7781,976,7214,2888,-524,3032,3422,35,371,8872,3423,8574,1836,4721,4582,2218,9157,9953,2274,329,7959,112,8569,9624,1113,7250,4104,6515,3637,1239,4341,8656,1799,7075,3833,2620,1887,297,2269,8688,-671,9769,4995,775,9766,4204,229,3072,-105,-433,8655,8992,7136,9445,4929,6656,7827,5044,7444,4016,1517,-817,2274,4636,3109,4528,9366,1935,4285,9549,6050,2720,7457,8146,7207,2431,2661,8346,1225,275,798,7959,7216,3034,6109,410,370,1469,-461,2651,3176,8730,3065,7219,1015,7886,-927,1008,8148,-961,2641,6864,3726,9478,5222,1631,8273,9559,5328,593,9383,5420,3569,6680,6083,7822,5271,1674,4830,-909,-944,8746,9277,7212,3556,6598,2647,3294,2002,3166,7482,7175,5717,7707,4586,9191,6909,7613,3134,6853,5947,9134,1556,455,-540,1346,7179,3977,7778,679,4818,1850,2116,1754,8901,8031,-860,4236,9395,132,3696,4527,3848,2965,4065,2226,-823,-443,7556,1436,4859,9405,4615,-680,641,-526,9711,-642,6996,4872,2683,7670,8481,2312,9094,3788,7686,1932,6855,6850,796,2494,1659,-836,6873,807,6286,5403,1968,9876,4789,-826,3352,5582,6964,4390,5623,2958,7502,8028,9472,268,1485,1895,8284,7057,8157,1637,5315,8596,6688,1665,2742,-126,3941,5956,6190,8034,-647,6645,5592,1383,5009,2834,201,9981,3653,2470,4137,3121,9451,4060,-114,-184,5475,505,687,5716,4601,4916,5745,16,7733,3489,592,7280,4417,3049,9286,8261,1804,4444,2089,7117,1427,7581,6438,6993,8092,2280,9448,2324,6269,8090,2796,2666,1339,-862,4487,-98,5448,7162,7373,9751,4188,7829,3499,3153,4639,2541,6372,351,4408,4446,3637,6293,9887,1261,9478,4666,535,1725,7783,6186,6000,8781,6668,3208,1980,3499,7715,656,3732,9672,3613,9235,2245,3344,2834,3511,-789,3595,2316,2649,2066,9220,8474,1353,9508,7618,4524,7849,8544,193,8636,8062,3289,2895,3124,3565,3665,167,4290,9442,3717,5917,923,4003,2141,2020,4348,7699,5383,5781,763,1019,8521,7540,-493,549,6419,9555,5619,1145,3843,4348,1404,8638,5807,-196,6921,7685,664,250,6998,59,5665,568,1391,4087,8627,3937,4180,9373,1993,7062,4091,1957,1851,9824,-242,1932,1318,6892,2982,-259,4928,7732,8319,9696,8931,6753,5216,6520,3756,34,3006,8213,9673,7111,815,4771,5786,1446,5555,5049,4319,8615,6246,9769,2822,2755,2579,7121,2554,2070,154,6803,2362,4541,6567,5926,1805,6843,4020,2962,9695,1533,-911,5386,7263,7444,-313,654,3466,6513,1705,3927,7605,846,8799,3990,1314,1648,-364,7351,6887,933,3124,9729,2730,4458,3730,3189,8412,8412,1922,3981,5484,862,8854,5323,8011,2083,3154,6380,2448,8571,2187,8837,430,8345,8470,4387,9168,7945,7808,178,7799,1459,5823,3081,2691,8828,7051,9641,940,8622,947,7368,6908,1134,-588,1605,6202,-60,295,4617,5442,5632,6219,4766,5462,5182,9702,35,9515,9532,5135,3945,1671,9773,-541,5578,1266,4237,6908,16,6965,1065,9102,1351,-973,-505,9654,4454,3824,8961,9096,1695,5012,3365,1583,-723,-734,9721,-279,9616,4144,3819,1101,6902,2964,4122,4523,3088,8469,8877,864,-763,-759,9108,4870,2717,3119,1114,2758,2327,-847,7550,-268,7614,3071,9393,9239,9411,5604,7106,7745,6064,6924,9418,-126,9267,1861,686,2595,-270,2907,-305,6239,6674,-834,8732,91,3697,-171,1584,505,9616,5023,6198,-476,-103,-13,7824,6286,6645,2415,1027,8351,4564,7865,816,-898,3162,1324,6263,4696,2907,8040,4499,939,1359,7362,7298,7680,623,8718,1601,-205,4564,9112,3844,8872,1446,4707,7060,1709,-631,250,5851,5854,390,691,1406,4194,4697,1633,5650,-685,6043,-929,3284,6182,9027,3401,8511,5870,3559,9998,9338,5891,87,6446,8243,6838,4067,6174,6010,8503,7574,9934,7638,417,9496,5602,7346,2635,179,5300,26,7949,5493,6129,9197,4230,2184,5879,8944,8458,8537,9683,1812,3757,517,4104,9362,2491,9343,7600,4728,1778,235,4007,2264,9482,31,1157,4746,9106,5196,6163,6729,5856,2549,3706,1875,2642,585,2089,8433,6612,8791,6395,2036,3705,-456,-653,5815,9450,3231,6869,9803,7686,7156,5337,673,857,3474,3515,4141,2286,-942,2595,9256,5787,9046,9979,8248,6536,5391,2632,8281,2560,5688,363,7619,3119,-496,21,1065,5096,5363,2483,7218,6573,3966,8334,6051,2225,6932,5485,4870,3880,9964,1214,7112,2829,3259,7390,8182,7956,9841,387,5592,124,1101,4893,3023,7359,6699,110,9493,1471,374,8134,5482,5463,7977,832,9324,587,3143,9143,6230,-129,1128,-713,8957,6401,6847,4060,5294,5684,9011,5469,1557,9551,325,5501,9002,8346,9458,177,4909,675,5447,9308,3969,4216,2517,9566,7514,7806,4888,6836,5832,5014,9226,7746,4081,4974,5176,478,17,6908,-980,3311,-750,137,953,2019,1059,8807,1024,1765,6002,1833,519,7837,8118,7649,5058,4411,-580,2606,3196,5706,246,4650,4827,2950,166,5650,579,7013,6004,1539,5212,2171,8785,1253,2591,5758,7995,7741,2826,631,-598,4088,-164,5079,2744,4512,6638,4226,1932,1411,3082,9298,6930,9409,5109,2666,9393,2968,2826,7220,6375,9258,-301,266,3462,7391,5214,2541,2808,5477,5497,7297,3732,9111,-634,8671,6927,7141,837,9843,7014,3744,58,4655,8523,-685,5974,-651,5832,5035,5467,9572,-554,8212,2711,7554,4440,3369,442,-981,5507,7771,6788,-38,-530,8845,4995,5596,7668,9769,-375,7236,7985,4268,9661,-160,4186,1996,312,-72,3253,4803,-853,9134,4893,-346,7670,-627,7839,7897,6891,8329,5197,9907,-801,7918,7016,6728,5143,5752,8688,7471,5561,1644,-874,1299,5363,1468,8777,468,3010,1488,3520,1444,5850,1799,2428,1315,-820,2445,5333,7445,3672,750,8583,9383,1885,4158,8884,2340,-940,4843,5155,9521,6688,2204,5631,5630,9041,9933,4192,3396,2183,-16,3429,1177,429,5187,1364,521,3870,3296,4115,4377,2697,2565,-198,7265,7689,5140,3743,5400,5950,1049,1768,-793,253,1888,3202,4703,6359,3491,8057,9265,1265,7534,4381,6295,1310,4572,2227,9633,2833,5822,1345,8138,3427,2488,8786,4363,5297,8382,1314,790,2950,965,2336,1178,2170,-963,9797,-657,9573,5687,3967,2830,-444,6613,-58,9416,3831,6422,3160,4172,4959,5388,4705,-603,2643,942,8266,219,1793,-544,179,3072,3912,9218,1831,1422,1830,7788,7611,7525,9542,5512,6037,382,2811,-202,1264,2737,2059,7717,8054,-580,2473,813,7264,1768,2012,5701,6032,6684,9104,1595,3915,892,6887,7119,6967,7532,3743,3420,9657,681,7563,3530,4369,1020,537,4094,7209,4375,8691,310,9109,5646,3672,7313,-449,6896,3758,7815,285,8055,3054,-621,5745,7197,4839,8954,8056,1022,3255,6391,1542,1419,5395,5579,4001,8186,3049,4079,8941,9440,4027,5,8205,583,8051,9692,9437,5668,7126,4340,7352,5839,5034,5962,660,3172,-770,8697,5349,2722,9076,716,6623,4293,6690,1077,-32,9052,9131,8288,3180,1887,2165,-84,269,3783,5825,846,-784,2471,4540,3850,-825,-280,702,6378,8175,3841,8395,8426,9055,9537,9857,1837,3366,7895,8688,3015,2550,2116,-882,7804,3962,2186,7114,52,6553,8349,2563,729,-675,-810,-836,7687,1928,629,5286,-682,1142,4995,8784,4188,9777,1371,6789,9101,3854,-691,-454,1675,4712,536,3688,8729,61,9938,5717,1472,2863,7011,-643,-843,5296,258,7637,874,3884,1949,1707,4424,7847,2973,6241,7210,5789,8560,5608,-682,5478,5759,5195,9764,8046,5322,-673,6943,7374,3418,9011,1989,4763,-452,215,8253,2046,5833,6159,3580,8487,3499,2946,5272,3953,4400,9163,4692,-627,-801,9062,8536,753,2595,8670,8598,2593,2640,8900,2126,8692,3803,8088,97,1948,4169,2863,-666,4019,5462,8695,2888,7019,817,4140,9942,9680,5941,1019,9653,1019,6470,3574,1234,1431,1789,-503,-270,3230,9001,5146,8242,1319,3768,982,4472,9543,-41,8762,-442,3166,5553,5246,5979,5790,6802,1219,4060,5140,3696,5569,-81,-710,509,5257,7780,-265,9669,2847,7080,487,4635,1879,1353,5731,1404,2310,5400,552,2268,2869,-747,6189,5466,7958,6455,3737,4618,-446,4180,4072,2680,8595,7630,9924,4022,2972,-852,9917,7209,6880,1351,5715,2227,7653,5356,8719,9732,6210,1105,6743,5850,4547,9439,3330,6522,9255,9868,559,322,583,-855,8940,8491,4883,9799,6252,5235,7115,7091,-883,6586,5691,9208,6538,6081,4260,7510,4297,9972,8742,-656,4134,1849,9216,2272,9068,7235,3245,6293,8988,357,4059,3938,2741,9734,-370,9745,9475,4719,-935,9769,5603,6476,8602,5342,-789,9122,-789,-186,847,2876,-491,1914,5749,5493,3625,-462,4649,6478,7957,1813,447,6066,6947,5066,6203,1844,5070,7604,8188,4286,9458,9397,3892,8864,5139,9981,3514,6283,1286,9618,-882,-808,50,7155,9217,5287,509,-265,694,3286,6301,4911,2582,-581,-393,7241,365,8165,8144,793,6632,3859,-701,8333,356,1194,184,4362,7001,7565,-785,6327,126,3638,3357,5640,4471,6872,3852,8423,-620,4881,7402,3807,6649,8921,6992,5152,7723,-661,2258,3675,3927,8647,6669,4507,3132,6424,33,9052,8769,3939,4248,370,1250,6131,6888,-464,2531,3811,5992,9664,8512,5227,7760,4913,6585,3557,3026,1678,2189,7797,8506,5125,-389,3550,8371,6552,3391,9022,7280,5508,8089,-828,3576,4693,9736,6805,-959,3718,5864,7526,6218,9135,7367,7602,2848,6170,-305,5379,4481,5790,-267,4518,3599,-650,-385,-734,8810,7966,7313,8863,9391,8355,8281,5620,7480,51,7232,6474,508,566,9775,9635,8102,4630,-429,1436,3888,548,-626,8574,4072,615,7997,8723,3419,5817,-755,4771,6581,8187,5668,7330,1829,-247,-585,5138,8483,1154,6754,3934,4144,1440,5491,1324,2452,5842,2465,9992,6852,5184,8909,6304,407,3912,2219,4970,4704,8048,8387,5704,3271,165,915,2183,9054,1266,7931,2514,1681,3000,1551,7457,6126,9528,1681,6850,4613,3246,3264,9753,-590,1944,3762,8693,8390,461,-159,1912,5763,5713,4993,3576,7122,2832,9964,5873,-55,1348,1199,8616,3332,3139,3286,3412,6291,8836,5827,3592,7185,4613,2843,5363,2200,639,9804,2124,6000,7552,4850,1607,323,1537,3692,-98,5837,236,3645,2750,4359,6109,5909,584,2816,4088,2014,9275,9581,5143,4199,9570,9426,2246,7849,4093,4309,9737,969,149,8668,1527,5708,962,7749,-633,9046,6286,3720,9093,462,-972,-316,3217,3507,1569,1019,1680,7727,7224,7984,7968,5445,1918,2943,8422,3183,1081,8823,9405,3544,2046,8394,708,1531,3018,532,8467,1054,316,3341,-589,6355,2902,4274,7100,-257,8266,7067,2340,2103,2786,6725,6084,557,9693,3328,1241,8365,3547,9374,1509,-583,8980,-823,8455,7372,5307,5157,534,6815,2359,6959,4228,970,8924,7568,3386,265,7934,1523,7971,3910,618,4983,1925,4783,8296,9118,7435,5665,8832,-748,4420,6516,-569,4672,-142,7186,8504,8126,9659,3934,6824,4926,1971,1031,6208,7701,5381,7804,-231,7041,1094,3202,9710,2632,9476,8220,6226,1634,2714,145,2863,8230,2145,3595,7692,9680,2938,6468,1652,-524,1222,1799,5592,2685,1643,2359,6764,5445,5256,2859,7924,1308,9307,8774,6009,8697,6608,9712,8984,8691,3412,3006,7239,-664,2474,9077,9076,6633,4393,2750,66,184,5553,5071,-595,2772,9639,2831,8670,1905,342,3129,132,1549,9237,3910,-778,7886,6069,488,4520,6114,6959,3218,6469,8345,1681,6037,8993,259,4388,7263,5202,3155,5216,6343,3538,7717,4804,812,4721,757,7851,3036,3550,2328,5821,6161,3312,6887,2356,9084,3443,5388,-380,1449,7876,7466,8058,9433,7254,3841,4087,-701,655,2433,7387,3445,7129,3907,8869,4385,89,8344,7948,1497,1879,8412,9529,3116,-659,8052,9510,677,8837,7593,1831,6404,517,1381,941,9068,921,1252,9154,8465,3404,5420,4033,5624,7905,80,6063,1103,9627,7399,-794,3650,9563,3897,1340,1881,8835,5299,-3,937,8325,1935,9072,4145,1754,6835,3770,5677,3559,8114,3429,1778,299,4766,5253,8601,8316,2821,7863,5670,-255,-127,4031,-461,1823,1041,8279,6117,-443,9657,5182,4684,5455,2924,-958,6051,2147,3704,558,1560,-644,-17,6529,3615,1127,4919,8604,5441,4628,2563,7762,5426,1066,9181,5058,4627,2983,8096,5851,3112,7570,-510,3841,2918,5808,1498,4715,-549,7127,9534,6400,7658,3032,5369,5593,8832,-502,-345,2147,2211,3706,5157,5391,1123,-549,4813,-973,3398,-462,7797,498,-637,4080,9431,2237,8843,-405,45,211,8753,6027,6630,6657,1714,5941,4240,8038,8389,6815,2458,9248,9527,-677,9786,-344,5124,5804,1134,3353,1915,3586,3628,3085,3510,2365,5474,7339,2462,316,3840,37,7376,8893,7003,2529,3930,5769,6369,8805,-292,3321,1048,552,517,489,6621,5108,8792,8998,2873,1219,6279,7365,4611,1613,7165,1263,7977,2627,6166,6208,4063,5352,7041,3536,4622,-340,-913,6208,6061,6657,3628,6678,5193,5299,7169,2048,2868,6457,6478,4129,5476,6335,4151,6328,1191,3464,1889,1355,6618,-610,693,2964,743,4460,7396,5873,4556,983,592,7456,9322,253,6972,9712,4433,-725,7487,880,7124,6114,8151,7519,329,4057,2900,2346,-88,1827,7557,8592,7653,4604,273,2851,2033,7113,9371,2845,545,1335,1846,-413,5021,8627,9505,5221,9624,9129,4010,8552,1752,5115,5487,7461,6971,7122,2371,9844,3522,-748,1580,7294,6620,-865,3460,1397,1699,-398,5103,1389,8467,9169,9183,9179,7975,9244,4010,8984,6520,2340,4094,5764,8397,1373,996,-447,1639,5986,3422,4922,5123,3441,8419,2147,7930,2382,2708,5478,8738,2939,4128,1828,8649,8487,6945,-218,6169,562,7356,863,2214,9710,1201,4843,3910,8893,-343,301,1216,3755,9994,-849,2245,4815,4940,8457,3132,7437,3040,4126,5692,4840,2486,8802,-648,6428,2890,7854,2504,4951,3004,7113,3424,3963,9373,5268,1639,3256,1342,8922,4269,-686,7055,8325,7091,8571,5514,639,2357,5650,2942,8299,9903,6113,6863,5918,5566,88,1656,577,353,6898,-140,355,9077,2086,3444,1394,8028,6087,6945,7727,6227,9045,6251,199,1786,1386,261,5729,3632,273,7530,4201,-113,2496,7881,6985,6048,6924,2946,7578,1087,8307,6343,6256,1779,3760,9936,5350,517,2606,4496,2921,7552,4857,8122,1643,3986,-172,2998,9418,-594,127,7878,301,7710,4464,991,6317,1414,7267,7262,4804,8454,3205,3355,7837,7086,8799,1270,6874,4818,2612,2496,2964,4818,1507,5243,633,8778,6006,-73,-349,3182,6163,7372,92,1501,632,329,6670,9437,5576,8403,944,8344,4781,9529,2131,4758,-72,7677,4184,733,9558,7712,9394,2817,8484,8738,8654,8242,-8,1387,2755,3608,2290,7364,-904,9968,7337,5531,6658,7459,9093,3295,3402,8836,1239,4350,1093,7237,2120,5465,5915,6977,9183,-235,7450,519,8258,8010,2367,8019,1789,1402,-499,4979,8244,6010,879,9227,7736,7560,2345,3252,2314,5489,-908,7099,2935,9446,8520,2808,6459,8658,4615,4210,9404,4943,2042,3881,3877,6555,2248,4999,260,855,3829,1200,1266,1530,9756,3237,7247,8111,6295,5536,8472,7920,1752,6595,4289,1458,3877,561,-946,4847,5725,916,2982,5744,-590,7145,1635,7289,6894,3804,1203,8386,9029,1208,-714,594,7731,9815,956,2391,1103,1355,7032,267,6894,9506,5510,3714,3947,1326,9271,8989,9347,6908,7235,6043,7636,8794,4192,50,6992,1348,6765,-625,9732,6450,8958,-567,2891,7934,8503,2536,2973,2851,5303,8173,4420,3347,2761,3808,6948,2426,2693,4110,7217,2470,8255,911,4373,7073,7260,5922,7738,6256,8749,3440,4391,4560,3030,4729,3258,-589,9982,9516,749,7244,5084,3732,8034,5820,4616,2282,8261,789,8230,-861,754,7145,-122,7120,1666,4448,7960,5862,1750,7572,145,8761,-94,8697,5100,8758,3518,3100,-925,2027,6543,9519,3481,4395,2920,1192,2969,1392,7386,9733,2808,-989,3794,827,6224,-300,2331,5641,2852,6974,2476,5067,9046,5669,7804,5607,8233,6019,1204,5677,-866,4032,6552,7029,-263,8987,3101,1669,6014,8354,2706,7182,8227,1152,2728,8208,9133,9557,1538,-499,8118,844,-470,7826,865,577,-36,3117,4805,1538,1833,8532,6209,6725,5594,4953,2092,3572,5195,8895,4905,1880,6854,-826,2764,2305,6087,-507,2786,3493,7611,6810,6190,830,1680,706,3474,8263,604,7901,3927,69,4629,563,2265,520,5585,5839,174,3712,7472,8243,4143,-925,6442,4299,5519,52,7871,1246,4341,8543,6485,4837,2547,5994,6857,1831,7053,3856,4751,8894,6520,8352,7307,9222,6390,487,9145,6670,3098,5704,8619,-257,5760,538,-28,2833,5823,2861,7956,83,1588,4190,8183,1263,3606,2089,3670,2089,3170,7104,-24,7941,1326,570,5712,7927,-351,1336,-244,2653,9361,284,1921,135,663,8021,4938,4896,5827,2724,3720,5219,2050,3281,7080,720,2801,5266,9503,4818,2671,283,3999,973,-523,-880,-428,4850,1911,6716,5592,9884,3837,8309,6567,-927,4198,7823,4889,9242,4311,5652,6032,5813,3786,1554,999,7922,3488,1855,4205,1687,8975,4145,6033,5185,8269,1180,9720,1413,8313,1229,-789,5963,3913,3289,1893,6063,6253,-192,9531,5740,7151,7222,7747,5642,6191,5175,3981,1217,2923,6393,3887,3132,809,2116,2811,9485,5549,-717,5761,5950,1889,1555,7877,7379,9681,8568,8372,6892,6313,3875,9596,1638,-647,4625,1564,6121,8071,5955,8664,4405,877,1646,9510,8784,9298,6472,4742,1460,-713,5792,2346,2690,7520,-684,8060,4374,184,4192,-804,8980,7941,4908,5745,6516,3022,8867,8369,5934,4007,9687,3044,4323,4972,7925,4951,3082,6260,9053,9441,1549,3872,9735,1742,7733,6026,7503,2990,8103,5345,5508,1164,3660,5336,6909,7755,9801,8620,4661,4110,4404,2707,-559,9093,7936,7178,7059,-123,3741,1574,4907,8379,6166,6898,8310,-471,6057,9811,4303,6478,7797,9060,627,8274,793,8325,9724,8137,9719,8370,7486,338,4890,1216,2622,8594,879,7798,2689,9999,2903,7513,4183,6088,-265,9254,6789,4583,9090,2419,5739,9850,2149,81,7562,9030,876,8446,7323,9906,9177,178,4231,5321,6719,442,5596,3987,1326,5918,4586,3195,8842,3124,1308,3835,5435,7385,7001,9366,9678,9570,5437,6349,8454,4481,256,5889,9504,1044,5969,-109,6964,2258,3828,9479,5898,1374,3431,4351,-334,8324,9599,8852,8782,4244,3868,-987,8060,1017,6441,-268,3857,1326,8625,-683,8618,3311,2622,8116,4388,9361,7554,4603,1825,3469,8878,-990,5685,7326,46,4341,5764,3206,6025,3103,4179,5511,4189,1024,7853,4966,5679,529,885,9276,6492,8520,3433,355,1631,5344,7629,7261,-700,7543,9827,3976,9362,4192,4195,-833,-26,4190,8225,4623,5211,-511,-708,2657,4100,-599,1463,1368,4067,6620,8067,3396,9630,8893,4817,6813,9347,5997,809,2068,6772,8910,8919,6455,9875,4072,7626,4358,1422,5938,9472,2239,8907,9785,8250,1579,5438,4616,2879,-573,4140,6264,1638,7325,891,3472,1747,1397,2955,4918,4622,3242,1673,9521,7769,-242,5767,6919,6771,3787,8770,1201,9913,1862,5696,726,-352,448,3648,5489,732,-732,7743,7976,5335,84,6534,2904,5588,2633,3578,1308,1790,5610,4343,4498,5475,2628,8310,1007,3062,2297,3706,5554,8682,8562,8719,46,3172,3519,4528,4789,1504,-191,5627,9165,9272,2775,906,-553,-950,-368,3918,9269,5080,6495,-924,2108,7720,7546,1487,8657,6509,-470,1133,7900,4260,1621,2773,3224,9160,5859,2473,7236,8606,2819,5190,6667,2765,6172,7521,9995,4566,9004,5054,4158,3594,7427,9855,1959,-751,7237,8825,8211,4269,176,8683,5931,3130,2741,3853,3296,343,-313,9519,5641,5922,5531,8705,4026,1832,-224,1351,7172,7176,1521,6756,5595,2291,8422,863,222,-880,3076,7247,7069,6741,875,1725,4418,3358,9307,-419,4488,457,8041,4207,-34,2063,3966,7571,870,9389,8329,8023,7432,9064,3327,2213,8189,3805,537,9986,5979,7831,6350,9759,3231,6162,6598,6047,7788,2151,9958,8961,1731,8813,5345,2770,231,1060,6352,3342,7940,-368,4945,6517,8684,1118,9717,-735,866,309,2902,5775,990,3333,366,1822,5279,1399,1537,6445,9593,6922,9458,4116,5135,9609,-795,9034,1411,1110,-790,6972,-450,4214,3276,6111,3082,3932,3754,3321,5602,-657,-105,4374,3010,9675,6206,2186,6038,-80,4889,379,5705,4327,8509,8423,8318,5286,1453,7549,6789,1162,-71,7133,9173,-835,2407,4536,3512,2232,8983,7009,9198,-640,5245,2436,2016,3847,230,5079,19,47,1172,5670,6995,9050,182,1465,5790,3347,8758,1631,548,6682,4699,6778,1244,8115,4319,-770,286,4215,1847,3612,10,-753,436,4170,9995,1066,1316,30,1208,9320,2255,7321,7861,647,9975,9276,8025,8747,7370,-282,6886,969,4187,685,2279,6373,4091,6249,3325,5025,3583,8111,5147,9658,856,941,3548,3169,7799,2596,-130,9523,3435,6351,3894,2794,8805,7032,7970,9315,5557,7738,7004,3431,8835,-992,7071,5529,1618,9798,2764,2087,3439,1066,8722,7635,8098,8501,4036,9014,3801,9674,1360,5425,7534,572,5509,280,9279,3423,9465,6274,9764,5010,5612,8791,4225,7511,2560,4451,-48,6691,606,-418,4090,4260,4023,5158,5856,-610,7344,7160,1157,866,9467,6725,4520,4000,1076,3711,3114,5517,9828,492,5625,9303,7011,9774,238,2946,8954,4636,6518,5278,8197,4140,-552,2707,4941,2844,-788,114,6487,7530,4557,4805,4646,2462,7080,-562,98,9219,9497,7807,3498,3506,-351,5115,9286,11,-662,7293,1627,6665,3876,8914,898,3549,-381,8292,8786,9877,7007,5259,520,4216,5992,9044,4458,-2,8694,108,-918,9191,8887,9534,-8,900,2572,8941,-380,-540,6420,9646,7867,-793,1489,-345,1348,2984,9828,188,1809,8820,6023,5910,2637,5619,8719,1811,7377,7133,2963,6676,3906,7048,8404,8449,1381,5425,6408,5315,6290,-748,3145,9903,9243,3803,8325,8238,9602,9254,4401,7365,5054,4936,742,7259,7728,1407,4676,-835,7435,7121,-643,6386,9383,-326,1204,6763,5615,-559,3827,-366,3135,6197,5859,74,5637,3980,6278,4036,467,7765,482,6146,4984,9072,-163,4151,5508,8144,5373,1136,5571,586,-815,1314,7172,3556,3322,5762,4389,-575,6594,8192,-32,5492,3920,8874,6984,6952,574,2731,891,4410,9095,-721,1271,9635,-313,1279,5618,4689,7366,7833,4606,791,2286,6299,3389,828,-202,1284,3666,3767,8336,-976,7584,5627,3188,4326,-411,8281,1396,3933,2208,4056,2818,1705,2284,2436,2213,2231,6601,8548,7113,-535,9279,2746,6584,6070,1218,3315,313,-517,9882,6450,3280,2090,1313,-406,5725,2606,178,7914,4201,2783,9748,5776,5219,8004,-903,8584,558,2971,-754,739,7254,8125,9928,3370,5247,-373,8755,2939,3532,6843,7243,394,-941,2638,6507,8547,6231,6958,5761,6435,-359,8236,5498,2341,7293,7875,9234,7986,2375,2042,9938,3212,8058,5090,1902,615,3785,5480,605,1073,8164,2261,5321,7829,-598,1239,1967,5939,5398,5226,3290,8706,8439,-970,4004,5723,1993,8930,9067,8416,8865,-405,3102,4003,6919,7265,9503,1491,5819,4454,1791,-173,138,807,9751,9886,-978,7243,3980,858,5847,1484,7503,6311,8494,-400,8926,4698,3679,167,9401,5563,9648,7187,-735,5054,8366,1081,9748,3093,1498,8238,1928,9398,3222,8989,6615,9252,2603,474,3245,1819,5906,112,-923,2715,7868,5997,1963,8344,76,-397,9903,813,6583,9407,7671,3861,565,2356,2037,2370,5732,953,3434,3492,3023,-221,8068,9257,1271,3136,8822,7228,-228,4779,7657,3949,6402,2571,208,9169,8511,1870,4808,7007,4516,-452,380,9616,7540,6908,7423,5352,9391,3796,880,8704,8757,3593,7792,273,9918,2717,2102,4774,518,7753,6105,8138,-509,2228,2952,5152,2180,5742,9624,5733,2554,5410,808,6802,5774,3661,6007,5615,-674,6192,8209,5587,-343,5569,4148,8026,9744,3732,4234,3483,7563,2855,230,8247,5039,2690,9012,1223,3194,-781,-328,9092,8315,-577,5448,1179,9940,7472,1919,3323,7240,4793,4474,3837,338,9282,8167,7711,9609,8392,5260,2029,171,8636,987,-982,6090,838,5158,7473,809,4426,749,9434,4290,1738,5748,1530,6110,8124,7839,4739,3407,3428,3499,-118,3196,9126,-585,7511,7955,-86,8971,-218,6312,-941,9773,3511,5117,-316,4505,977,2964,784,681,6963,-898,7678,-751,2531,8967,1273,9178,9897,840,9464,8154,9438,6595,-974,7125,9007,1732,8241,9537,5562,4693,6847,6733,3745,1614,4037,4820,5763,5985,1480,-460,7344,978,8495,2489,9176,-84,4957,5021,7767,3627,2789,33,-482,1941,6905,5356,1151,5456,3784,4399,7477,9493,4155,1878,275,5720,9049,4468,9615,9895,-640,7735,3516,8103,7927,2232,3271,3918,8128,811,6377,7676,7110,5261,3168,7376,6741,6116,5034,5492,6565,-536,-230,8683,-231,9695,3280,1300,3290,5218,5276,6669,4400,4667,9788,8237,2848,6253,-83,-797,1252,-578,1230,371,4565,8365,-760,8564,1023,717,8130,4905,618,7574,4960,2620,2198,6978,1688,4874,6301,2419,4349,752,3609,1018,8517,3099,6075,213,8719,9284,3310,3341,9330,2928,2553,5092,2912,-14,8117,5148,8536,8545,5614,6953,3937,1989,6185,8478,5477,3597,327,1252,5381,5268,8620,2824,2950,5692,1030,8483,330,2971,2705,6213,7957,-687,7724,6945,2388,989,3063,5035,4353,634,7024,7472,4665,824,-331,4279,8047,7035,3674,4541,-341,7340,-407,9830,5812,3728,1705,7506,4761,-505,7449,-827,5906,3457,4411,6512,3808,3800,7519,6618,3200,-358,9602,462,2898,-497,3052,6465,2490,2191,7570,8256,-456,5511,2822,-599,9155,4942,9469,4016,6658,657,2398,2506,7785,910,2962,4472,4448,6200,8084,-998,1752,8612,-447,6327,-565,5562,4921,356,8729,3843,9659,8955,3324,9994,830,-770,3485,-994,9118,7506,3315,1494,-288,3068,8842,-402,4055,6896,-740,9754,8889,7227,8367,1549,5441,9111,6624,645,1342,8839,307,678,458,2973,8794,9639,640,7479,-927,3238,4761,-724,3298,1793,2669,2003,5637,-712,1060,5222,4398,7806,6084,1815,5268,-896,5868,-354,8176,6772,2307,-273,2426,631,4527,2633,2046,6992,1541,-922,1421,1308,2688,2508,-504,7837,1729,2225,7309,7700,5227,3142,8491,846,3794,1877,5895,3890,38,5061,3786,3775,4437,8986,4032,5524,9411,5982,7084,906,-661,-915,3051,1334,2062,2024,2654,7408,6162,7573,756,5787,1546,8787,6375,5387,1409,-889,7288,9160,3036,9483,983,7523,-420,5838,6019,3955,6721,1235,5601,2201,1426,1453,7177,5547,6850,4040,2535,4344,6945,1419,2972,-894,6736,5012,5815,580,1480,5935,-161,5801,1609,2624,6514,5271,8657,1774,6251,8840,9438,5270,-969,9230,2633,40,1466,7412,9692,4131,1223,7381,9611,1001,9157,230,5316,4800,4160,7382,112,3670,6701,594,7131,3721,6851,8973,1708,3676,3743,2060,7177,7083,4616,-96,-733,4267,1885,3000,3545,2345,5480,214,8125,2929,8041,7346,9611,2627,-444,316,1238,9838,7812,2999,902,440,4431,-734,6989,3920,8984,3234,6313,9286,3219,3531,7103,1070,6481,5801,879,5833,3665,3667,-920,145,4592,413,5559,9120,2852,7829,-118,797,5576,4517,7858,130,143,4480,5110,1615,2054,2195,3878,4192,6983,3616,3996,8816,-399,6731,4441,7672,8535,4260,1687,1733,8804,9880,9193,9334,9728,1482,1733,8534,4315,5917,6689,2710,1145,1506,4305,1954,-945,-990,1070,8469,3383,-305,4127,-150,8878,7475,2467,8536,-99,8135,6926,265,7247,8364,4626,6686,7209,2047,2978,6331,-480,2665,9953,6869,2384,2273,4093,612,8683,6138,2599,9879,5652,-637,1676,8676,5774,6336,2100,5347,3848,2131,9177,-64,382,4308,-933,4744,5007,9758,3291,5133,3030,2986,4314,1553,6997,2277,5174,4601,1871,-343,3640,1201,-561,771,2409,5398,5562,8729,-584,4673,7933,1646,3498,8120,143,-88,8633,7262,4163,8550,3066,4485,7325,2708,8372,1800,4256,644,3254,5291,8809,7391,677,9596,6423,-312,487,1172,-393,-618,-785,3567,8469,8688,2192,5876,1872,4754,7784,6269,3929,8824,4822,3565,1827,-158,6148,7949,9621,2388,5450,378,3610,7933,2114,1341,2107,3497,8791,5697,7819,5227,1384,8127,2640,240,5579,6249,1123,7070,6849,2406,9864,3300,6503,8680,7146,2789,2718,8293,3894,965,7996,5351,442,3505,8977,-49,2589,4095,2833,1957,-46,1446,352,9666,3336,9613,5452,-849,2625,4258,4302,187,5591,9096,281,5408,363,8953,4806,6300,5898,8654,4275,2705,9899,8328,4589,5508,4461,8226,7822,5900,6715,6220,7809,2817,-406,2320,8076,446,8720,3267,1085,8308,9791,93,7143,1556,6830,1670,8493,8166,293,7071,1567,5482,3582,7525,-295,4919,8087,-96,2594,9343,3960,-563,3445,3467,2528,2601,529,5964,9919,9928,5956,77,323,8684,4648,-349,6974,8843,7290,7671,549,-386,9841,1899,4356,6481,7847,4650,852,7054,6914,6838,6773,6015,1650,3717,2511,1138,1940,2789,302,855,3720,365,6232,2942,97,3425,8132,9522,-421,1395,9695,2704,8779,1161,-490,4290,4396,2203,9566,4309,5686,4844,9106,963,3307,-492,7688,2694,3770,8022,2318,6041,9824,2124,6369,-370,4699,1460,703,4297,4116,8486,9679,8522,7747,8917,836,4326,9510,9728,-627,6086,4794,6294,6101,6809,7186,6290,6731,6655,-35,9812,8165,6843,8007,3763,2155,1628,-808,4423,9713,2574,-692,6825,4586,-505,321,6292,6502,9230,2136,4637,9805,4586,7598,3365,-854,5264,178,2982,8124,9858,4318,6722,9189,2209,5690,4585,426,8628,1104,7888,7190,8311,9441,3692,1020,7513,2598,980,7299,8930,7866,8144,5281,9797,8086,5215,7984,2173,8660,-383,1501,-406,7603,4208,1406,3402,3968,4503,6577,7893,3853,5473,4421,4745,8355,7263,-998,631,3221,2487,1641,6526,694,8540,1111,9749,2597,2956,6114,3909,5491,5881,3288,2691,6077,7974,7968,1729,9537,3473,7928,1151,8616,6673,9095,2764,6399,254,322,-772,2534,1336,9903,984,5210,944,2232,7463,170,2077,3409,8500,8308,3052,1911,4112,1009,-11,5878,1669,2872,1788,6319,4558,5452,4604,9241,5914,116,5453,451,4915,248,5397,8114,6058,7616,1916,2370,3660,3012,1587,2797,5083,6858,9607,6308,8490,6115,1919,-52,627,-41,-765,4246,4283,6943,5099,2761,2445,9263,542,3374,5673,9351,9788,313,718,652,7132,8228,8139,2365,8232,9852,-465,5826,5933,7908,1913,6587,8136,6525,6650,623,336,4821,8282,2040,7927,8053,6413,2813,-852,6566,9956,3706,5513,9341,5619,1420,7146,6058,377,7402,5933,6127,4289,8023,2419,1840,2660,4146,8725,8801,7950,9246,9509,7783,229,6813,4989,7010,885,6915,1071,7905,7045,5587,3531,9647,706,1612,7422,3786,7352,2818,7353,1067,6645,9060,6524,1531,4952,4241,5326,1101,2808,7839,4876,3800,1248,-269,8946,5356,5744,8668,9313,4779,9589,7088,1658,-41,698,-439,-935,8451,4904,3956,4179,5631,489,6565,1095,552,1858,7999,1098,8958,1326,-519,4982,9767,1966,6744,9378,8393,7427,4593,6588,7287,1541,8202,8263,9531,8854,-819,2012,3388,651,8901,3078,4836,7572,3689,8760,3322,-68,9493,7106,8351,791,1999,8827,8977,8878,1759,3094,4729,1591,2928,8007,6538,1606,461,6529,4612,9694,34,4929,1761,-737,1278,1360,4178,-417,3488,8690,2883,8596,8426,4536,9690,6015,-169,5513,7334,4188,4419,448,7728,5707,2659,9918,8599,5203,8484,4449,5362,3560,3394,1178,-821,3425,7157,1157,9447,9676,3298,9455,9074,6615,2285,7659,7683,-583,-363,-61,-727,7417,7716,6585,9620,4332,4091,8900,8684,4450,1625,2542,-33,1944,2528,7424,1237,6459,6735,6849,9981,7837,-851,1821,8410,2505,4502,9354,1403,9733,1145,1043,4692,3518,8510,8892,5374,9299,8903,968,8162,1732,6502,3479,5378,415,9376,5559,3144,5982,6951,9072,73,332,6987,4719,3902,1349,8183,9756,3446,-360,4004,-605,3941,2259,6898,956,8087,1336,7202,6623,9173,5139,9272,5768,1446,7706,6123,-567,8364,3689,5841,3845,5789,1289,8182,-755,8981,2749,2003,4316,8832,1097,9623,768,9454,6469,5065,2491,4488,6502,-369,-247,-879,9881,3973,7333,8633,7642,3277,2675,5527,2472,6893,691,565,3600,4718,5165,1933,6041,4354,-609,1063,9495,-597,420,8598,6506,4559,5482,9474,970,9253,1194,7937,3476,6037,-816,467,7409,7042,2483,9745,-967,6110,4044,9942,7609,9093,1842,9659,6554,273,-26,2218,3235,2841,8701,2845,7680,7498,6246,4681,8266,3249,1861,4472,-425,-239,1105,6404,7856,9161,9117,6919,8541,1022,4213,3747,8636,7329,7749,9307,9866,2293,7802,5921,5745,1356,3153,7800,1725,2836,7970,8391,2490,1247,7722,4098,514,2238,9970,7882,-530,7183,3938,6848,7822,3493,3550,6373,3082,6918,3068,8776,8153,6389,-103,4424,1700,5696,1753,1248,6030,6675,6155,3643,2566,2599,7594,9894,371,5833,7046,8330,1019,-962,9212,7021,2837,-584,75,2361,2074,4139,7317,1839,-618,5977,2113,-622,3314,3470,-669,7291,1241,330,644,4395,4386,2516,4989,7628,8414,7993,2346,5211,5275,1086,4487,8779,2378,-755,-455,8332,1182,8239,5879,687,3540,9719,3923,6439,4655,7205,573,5057,2971,-978,8309,3829,5383,1472,5994,-737,8315,8016,7938,2277,5389,8502,4256,9159,3441,3217,5425,-754,9741,2035,-674,3594,8652,-253,7487,439,7083,5541,8636,5538,8741,-937,254,3756,8850,5908,6087,5209,7358,8989,1360,-428,6249,173,9950,8128,5504,6635,-937,8613,1282,7891,3785,-516,-489,167,709,9630,-289,6824,8664,5244,5456,5556,590,778,5161,7788,403,8709,9896,5057,-320,2760,700,2757,6066,2999,323,8810,5152,9854,918,310,1789,8413,1866,6017,8624,8051,7716,656,3808,9549,6339,854,9826,4696,7229,5523,-166,3313,3230,8603,1416,-848,3702,6845,2683,8566,39,6181,8330,8044,5679,8725,1958,-566,6438,5624,1878,6133,4518,3859,7675,-378,-173,9613,4348,2121,1764,44,9638,-562,2846,6882,718,7422,-392,3050,5929,2369,3938,750,2439,1915,6598,2954,5466,4663,7920,3093,9033,-58,4638,3096,1077,5975,-464,1189,164,9566,1949,5585,2843,7172,5695,3031,7201,726,7530,3565,-488,4743,9234,1077,1876,1630,7629,5372,3939,2111,470,8946,738,8884,4807,1982,2942,9502,908,2486,2312,1546,7617,9962,8953,7120,9264,6694,8658,9863,9572,783,3865,6067,597,6716,6923,2536,4358,5908,5103,-484,-503,4791,4419,4062,4099,7437,1628,6576,8348,304,-800,-930,-235,-285,19,-81,2485,3771,1040,612,8464,4550,8679,3651,6133,3130,4544,8439,8983,7344,1261,4736,527,7313,9906,9985,9624,7508,7829,9048,8503,9725,3860,8655,-999,6885,6123,1424,8914,133,5010,8405,5137,2837,1214,3270,4314,5409,8131,2234,-217,7336,2662,5633,5877,8539,8183,1503,4634,9188,7635,628,9587,7900,7952,1870,658,1742,7266,2501,2502,8224,1799,2726,1118,1372,42,6888,5109,2058,333,329,6509,3703,4002,4140,3715,1378,6146,2437,5710,-765,5345,2923,7972,7673,2441,5333,8311,3247,1647,8154,-672,2669,5573,6392,7464,-262,895,3237,9632,7310,-140,3494,290,2940,7316,9689,4428,9460,1783,4067,2804,801,-796,9898,4529,2393,6312,7247,694,4478,2407,6226,4189,8564,3969,2532,4058,6409,5090,4715,-206,935,1830,1736,391,2875,265,4684,101,1300,6586,3009,1215,6700,8438,1609,6674,1071,2336,478,8276,1464,1303,8172,3579,2317,8318,1876,856,534,8272,1573,4106,6204,705,5454,2920,-348,8433,6632,4037,3037,6378,7739,6514,5370,4556,9292,3544,3701,6171,981,9911,1398,9490,-711,147,6904,-258,8,9357,9039,-51,4670,651,732,889,1963,4163,9844,-647,-210,5173,652,4901,9705,5860,9323,1176,-907,829,132,9197,8251,1587,575,787,1451,6961,584,4356,7482,9067,2759,7706,4538,495,8690,7414,125,1748,6573,7691,8243,5572,6370,9858,-758,991,3959,986,8596,3099,3968,7186,5321,8464,6323,9213,2738,1375,9928,4420,1854,3748,8686,752,9540,252,8227,9672,9039,658,-160,7055,5646,-365,2542,4589,-602,6570,2206,4368,-168,4168,9200,1883,6343,6385,8416,1721,5506,-472,4577,6070,4639,253,7202,270,6515,205,4040,5786,2966,6229,5698,832,5068,4722,4645,1243,9890,6932,880,7681,2139,-853,6797,5073,5002,3471,-168,4665,1529,3974,4029,4245,4030,4901,294,3229,2040,9562,5926,2498,9738,127,-961,5597,4862,3356,3887,520,-537,1224,7026,1958,6888,2459,8876,5104,5952,2176,1985,8123,3922,8848,9444,8406,2158,5087,4311,3922,3580,1540,658,1584,9330,1178,1791,1677,6537,1093,3833,9778,6920,1606,3273,5225,8987,2799,-774,921,527,5355,4641,5673,4981,2608,9908,3745,409,5050,7230,2234,461,6699,6470,5608,9654,6804,2251,7068,5258,-387,2571,8366,3497,1443,-413,5842,637,717,3186,7587,2970,-55,262,9451,1263,5217,8500,6606,1612,5965,2812,2710,5305,1985,2132,921,9567,8663,3420,8187,2273,4966,3782,2066,5425,8039,2049,5565,1367,9250,-708,374,8799,8618,9012,5617,7618,6815,437,2265,-803,5451,950,1848,4762,-872,4186,3822,977,1993,7807,-443,7621,3544,7075,-142,7522,-477,1742,9480,8824,-488,-475,4431,8526,5017,4291,8789,2325,4264,6026,9228,921,5570,8414,-30,2001,9458,543,1416,440,5134,4117,4246,2015,3794,1938,5173,2995,4910,5385,7492,2961,-487,-786,459,81,2384,-520,210,734,6365,9904,7826,2711,9878,197,9210,-255,6704,8905,8524,9374,3773,8094,9254,2608,7866,8666,-289,-665,796,51,8030,702,8626,5678,5140,7906,4243,2574,9397,8011,2965,2637,9021,2984,4177,2052,2030,8072,4298,3249,-711,1526,8907,2263,7044,5862,8706,3391,8536,9410,4900,7885,1883,4024,7760,-266,8007,189,3793,5170,2685,4642,1017,8047,4876,8785,1904,4937,2117,2615,1438,868,247,7584,3857,-517,8703,8993,4549,5127,7147,3841,2503,5266,4090,9176,4428,7041,8370,6591,6254,1738,8356,440,1801,8954,-554,816,8766,6111,7129,-590,3529,477,-723,1310,1464,3361,-808,-476,5333,745,136,7169,8274,5971,2713,9814,910,-836,3717,6096,3560,3952,6278,2924,7244,1145,1776,5481,8917,7081,6170,9381,3258,2416,3086,7788,836,8422,6665,3766,5389,2475,4682,5578,-527,5040,5525,695,9627,4059,9109,951,-533,8036,-520,6553,5796,-156,226,-923,5842,3678,5617,2998,9773,5436,3463,2346,-529,-153,7795,1209,-310,1923,2234,1184,8479,1440,5188,-726,4720,5881,5398,5121,8187,2611,-140,2276,9762,2075,8709,1063,-734,718,1636,550,6394,7978,6257,4834,6296,5467,1902,632,7928,6177,7382,9647,6828,1064,7021,2611,3442,9577,-78,6355,2991,4470,5047,-126,6921,4931,4637,9579,6850,4665,9907,7650,9811,4278,1220,3221,4433,4777,5914,8530,2935,5942,1059,5337,374,461,7716,-110,-292,6087,5501,7985,8519,-162,1920,9363,3178,9587,1094,1826,6181,8722,7637,4174,3782,4003,6936,6940,568,6737,6680,7239,1113,7871,6239,-71,8466,6549,5244,-872,4770,3466,8462,9194,3199,7640,7327,473,7105,-179,-938,1232,7044,7457,8153,-609,8414,2569,77,5587,5811,3071,3271,3038,5998,5784,6249,8634,2029,2952,4529,5358,8834,3400,6053,7295,5329,4489,2334,7353,1077,9820,2736,8601,2375,3887,4078,1321,-6,8564,1607,1663,5829,7110,8396,8721,4369,4554,8611,7393,7427,2441,1390,8254,3239,179,6577,201,3685,9070,4439,1876,1372,-181,1556,5915,9797,3229,7560,2535,9984,1260,-894,-315,6536,6530,8166,9137,901,9440,6599,2719,5692,8700,-195,5363,5754,7172,7669,1767,9611,3704,626,9202,3080,2738,3713,4975,1045,3090,-615,-66,2338,6714,8300,3359,592,5457,4012,7136,96,519,2751,8169,5048,-915,5444,6697,8207,6719,5865,9000,3271,6715,5111,1340,9362,4456,7030,1776,8901,3015,727,6292,431,-554,8975,161,350,2571,1754,7078,8111,6484,1194,3393,310,1577,-966,505,8347,5883,2261,9093,3601,1141,5375,976,1518,8892,7798,70,1711,-260,8451,8978,7811,6747,1312,8112,-998,5035,1592,1689,7854,-704,6766,2796,8304,1436,4630,6013,669,6831,-918,2767,9273,3866,5713,1874,-6,5344,-394,2319,8651,7891,8439,6284,2313,-993,628,401,8625,9617,13,194,8298,9020,725,2373,2315,8238,5149,4864,5161,1298,8665,8326,4125,4628,2189,4946,1620,6963,8477,5373,6094,9922,2451,9422,-203,11,3128,7482,641,5784,1019,-835,-198,307,2976,175,5423,814,6472,5006,6580,1867,9361,6808,2289,2030,8492,7194,908,4852,576,-186,-554,9119,2176,5312,6018,3473,6833,561,9249,2972,8517,4488,1964,1506,2932,4402,2711,5954,5571,1310,435,4167,6466,-870,8191,7632,7063,1716,8960,6772,1065,1612,3887,6893,9022,8459,7736,-858,-325,-958,250,3564,712,106,3490,4392,8468,715,5,2219,1246,6083,2657,9816,3625,3159,3952,678,2823,8467,8554,1495,7262,483,2997,3572,6551,6135,-740,318,8150,7355,-891,6762,8772,9536,3809,1081,815,6267,4298,9732,7445,6486,2404,8639,1688,6236,4327,3155,7935,8495,-339,-362,4842,8903,3725,9363,7045,-594,4308,2664,7163,7437,107,-902,6412,6553,4308,7806,6660,7989,9321,3806,9012,1753,391,1284,1719,6400,5884,8115,1229,4004,2260,1719,9941,3778,9812,8629,2941,4864,1627,3287,6362,5915,9901,5814,230,4788,4664,-929,2688,3267,9551,9344,6508,6049,4254,3705,1271,6746,6478,908,1802,6796,4525,2911,695,347,607,5364,4905,6655,3465,-766,1138,328,126,4445,-827,6367,-356,8869,7604,2249,9227,7147,1863,6561,8194,5718,3219,3650,364,5189,951,1259,7749,650,-508,2345,8287,8945,3975,9923,4247,3859,-181,8784,168,3777,387,4585,-396,8528,1920,-953,7364,7721,6355,1550,6474,3945,1901,2116,8103,9253,6719,8774,739,2803,9766,832,6681,1476,8036,4162,4224,2605,5970,-790,-677,4306,5242,1553,9744,804,2188,3686,9502,8390,580,3138,1429,4924,8217,4935,341,5261,1164,8516,-594,3327,7771,4487,3999,5515,-191,5450,2350,-325,8238,5511,776,219,4038,9237,3138,6995,1456,5,7224,-322,4382,1154,7713,1985,8130,2108,9139,7391,-260,9012,-492,5511,248,600,5378,5801,6474,3762,3612,-548,4212,-140,7731,8960,-722,236,4136,-479,-809,7699,490,3150,5211,1847,5094,9672,7366,-611,1419,1912,5569,5858,1515,2066,-793,7584,-370,6691,1584,2627,2200,6447,314,4448,9681,5195,6650,-185,1660,1209,2076,8050,8367,3773,7640,6826,8022,8756,9757,4944,633,2973,-84,4363,3250,9805,4202,5913,2963,7957,3532,5234,4257,4371,5812,1641,9305,4114,5072,9678,6704,5468,1842,9,2361,8541,6550,7038,4399,5534,4253,8627,1432,4204,11,1210,5043,1443,1731,4491,4475,4783,6377,-119,7630,3292,9960,-263,6763,1102,7946,4483,7155,3800,7283,-591,1913,2204,9120,8259,5090,9406,7685,3475,9158,9497,9126,6700,2009,4574,1756,5680,8516,9303,1171,6124,311,6516,6198,5802,3203,7416,876,9246,7387,713,1769,3342,371,708,5738,5530,-655,3333,3239,6571,7948,8853,2090,8478,5968,2144,3004,2882,484,8410,-339,1102,1066,6249,1962,4221,6136,5238,7948,3185,2114,8962,4713,441,757,-452,6012,218,8073,8329,6732,4973,7102,8812,2673,-646,7578,1484,1578,8221,5178,6159,8066,3923,9233,7139,2534,-419,-656,8059,7517,1173,4245,170,-348,1671,8265,5504,5213,3080,4536,3102,7653,9889,9446,-747,4442,-680,4079,2405,7926,2311,9189,4469,9794,3473,1799,1081,9721,725,6462,1791,5587,-94,6649,8546,9580,1568,2205,6277,7545,4592,5962,9006,523,-804,8390,8560,8696,1320,2585,4349,9571,4573,4621,5105,-663,4994,1188,865,5915,945,5056,4444,5151,4041,-124,6149,9926,7780,8804,7911,8353,6960,6942,3365,8715,-946,9867,2476,1465,3337,9754,4798,-599,170,-361,811,4695,8069,-998,-738,8455,3050,6629,8909,-405,7094,8358,1902,4947,6353,2513,8322,8909,7715,2858,2538,7173,8067,3473,2917,8182,9501,-42,9842,3841,7927,9259,4822,4893,606,5470,9823,1057,4120,2352,6891,3684,1329,4344,2377,67,362,5821,1983,1231,2549,9660,9021,-768,807,6933,8039,9816,-661,2439,7655,6805,3953,6167,1648,6546,3162,5248,2208,3932,4334,6532,5314,-73,6621,1442,164,2485,348,9140,2453,7844,-525,9417,769,5512,9439,9782,1368,1429,8010,1492,9235,8167,1826,4638,3321,6040,105,6593,7614,807,-497,9271,5895,2564,6510,1997,8569,9574,3830,1253,7352,1874,6012,1476,6637,-96,7000,4589,6896,7837,7784,8636,916,-466,3188,8938,7109,9486,7127,8158,4414,9966,7492,873,4312,8189,568,2279,4497,2387,256,721,7704,7308,4693,6506,937,4482,3074,3627,2911,6586,5216,477,3504,7991,5281,7197,5395,-45,4737,7981,2913,9738,774,9554,2818,-140,-616,6665,7765,2461,5178,2286,5679,8098,5823,3859,9837,-678,1510,88,2031,1188,3408,1064,4115,8436,1623,3313,5644,201,7505,8795,9144,416,8540,4588,2741,4960,460,5058,8825,5496,-183,9741,9985,3684,4857,9812,4160,957,6540,9806,8113,6326,8784,4855,724,4075,2995,6094,5170,2049,445,1170,3434,4974,4650,4822,2840,980,8994,5788,4273,8411,118,5433,6990,2735,1652,7000,6920,3387,-845,2467,758,-908,3055,8925,4596,7899,1750,29,1889,5483,1295,9661,6419,4309,459,5501,1793,184,-326,2535,6794,6784,5872,-801,8002,4949,3472,3783,3031,4384,255,9776,7401,5247,5563,144,-516,3731,4892,4060,7159,179,1715,4305,8384,6088,-659,5628,3550,519,2684,-619,3856,2800,3707,2140,9418,4721,2519,769,469,924,1124,5234,2462,-772,9183,1438,5186,7615,3913,862,4181,6285,6766,776,8053,6973,8365,5903,55,6657,7577,2538,7442,5185,8303,3856,-833,3545,6939,6096,-496,2265,9319,8381,5403,9357,5999,2482,-321,7016,5602,-255,114,1874,6369,31,5701,6120,9781,7032,824,3747,2720,154,4438,5817,7607,-556,-780,1107,2848,1581,4563,79,4464,3191,8410,-462,9093,1030,4864,-745,4622,9039,6779,-995,8042,6303,6004,3251,4158,2495,9861,3709,6280,6914,3007,9171,7263,6243,6202,7096,9232,6047,5597,1134,4311,4282,6343,8772,7201,9116,3911,-639,9637,6931,2966,4808,1103,622,1677,4073,9671,-390,5464,6309,7867,9543,3253,3868,1234,6649,1293,9265,-874,6447,5867,2458,6731,-103,-770,4167,8634,9463,7271,9643,5553,1375,1847,69,1053,7078,2655,7810,7998,8211,9178,7907,8710,8277,8072,4940,4246,5944,7814,3829,1334,-552,7330,8223,-699,9614,9849,8488,1514,363,3267,2571,3492,2968,2504,4376,398,3098,2213,6445,8780,4976,-766,3956,-899,4639,5915,3476,6269,5872,7910,625,3378,1927,6858,2593,539,4629,9168,-909,3334,-927,3990,2569,556,9236,400,4927,6396,3471,2498,2690,7042,8244,8609,7542,9915,1858,2063,6663,4456,6493,207,8718,6179,2980,9432,1582,9738,7938,579,-202,4365,8896,576,7251,5739,7769,5168,6168,1386,4408,6252,8631,4843,7841,6316,5193,71,7996,-71,107,8972,3114,9900,2264,-312,3546,9230,7098,600,320,7813,5035,7367,5670,1440,9688,7476,7278,1164,3232,724,4478,2419,6044,-173,1460,9242,9874,6823,4288,8198,1921,923,9051,6004,691,1336,1545,9434,9993,-589,3001,3980,5453,1012,3337,4268,7918,3630,9718,6320,6858,3629,2731,9416,1770,6878,3634,3706,5403,751,4454,5121,4537,7814,4070,6591,9160,666,3999,9386,6489,7815,8100,2730,7762,5726,2668,1177,4139,9588,1327,1571,1772,3672,5022,6003,8734,8020,8341,4791,9558,4573,1594,9845,2467,4289,6505,533,5506,5561,5260,7748,7821,585,1277,8105,2690,2669,9921,6867,-7,8227,739,744,8324,9802,3534,245,6390,83,4559,8988,-708,7194,1621,8889,3829,2273,6998,3031,2137,1919,3406,8713,2669,6916,338,1380,7751,1660,5448,5095,5984,406,1945,4395,6694,6707,5986,5194,8525,4846,9102,1581,2283,4179,2884,2774,7234,5705,5869,1534,6088,184,3443,1617,393,8447,3788,5704,6800,7999,3999,2387,-631,869,1486,-974,4774,3967,7449,8692,8419,5945,7717,8845,850,6412,8696,8728,932,950,4441,1827,9611,443,5966,7703,5694,8139,8567,921,337,6476,5648,7853,2784,1483,7327,9816,3433,1676,3191,7390,5496,6408,3945,6013,8859,8505,4451,3949,3925,5670,1666,3838,2979,6135,9613,2513,8523,-577,831,5440,8330,9233,7976,1853,2155,-89,-644,9398,-641,7139,8675,507,7702,8590,5863,6190,3153,-126,1894,1111,1862,7629,1251,4043,-626,5873,9534,2665,5676,5815,9701,5388,4565,5414,2349,1166,4983,1863,1043,8717,2814,3503,5555,2011,428,-746,5979,6422,9261,576,2755,7696,2910,9538,1416,8708,1903,6950,1578,4646,9165,615,-978,6579,5744,4798,7048,1883,6884,3398,5840,1883,7187,4175,3350,9844,2670,6694,6288,1897,2274,2184,-335,5428,4752,5595,1671,7839,5213,5024,6834,2235,3348,6546,463,1651,4478,5131,-61,5507,3058,4352,5096,6195,589,8238,1587,3340,6924,2142,-325,5489,2162,7286,7164,6729,271,7806,-700,1117,164,7904,9163,7373,5184,7515,-489,7979,7835,1836,1841,71,2740,5935,3664,6703,-205,8162,5633,1843,4198,9823,3858,2412,260,6689,5333,1671,3655,8960,4854,5787,3433,754,1989,8973,2185,2290,8326,3664,1474,9626,1445,2750,5497,-826,4033,328,9978,6110,2891,2866,5259,7661,2678,2175,7054,2506,1866,4981,573,6421,6302,2163,1891,791,7131,5568,8515,8954,9609,3474,4622,4963,3524,3575,4880,1571,-990,4261,-690,9732,9597,8256,9334,7307,2409,7645,5609,18,9669,7143,8493,5932,9785,2500,1795,3795,4786,8107,323,6040,-480,5040,8726,2965,9010,424,1137,7223,-557,6586,2061,1438,1809,2218,6486,5174,911,6848,2033,9807,-96,7343,2563,5908,6528,-407,-434,7200,9592,-969,5884,1183,7327,-784,6812,5505,3397,5866,2380,6106,-6,6031,785,6794,1387,880,-123,2442,401,9442,4372,524,7249,6626,9999,6608,2196,2043,8044,-737,5879,488,4248,8940,-888,4408,5684,2684,6266,9923,5492,22,2100,8711,8900,3550,4671,6588,8699,4581,6238,8329,8494,-252,827,3638,-937,2130,2672,3682,-396,8343,6936,7855,5662,8737,1424,4647,4467,462,4002,8044,3980,2895,6291,4415,1795,1719,3569,-260,9021,9902,4363,2078,6525,8413,334,2755,6416,4761,8960,4823,9295,-704,-177,1784,8934,2607,17,8167,1115,9064,-574,2901,7081,-382,8660,4453,5678,6760,-13,6910,5874,7060,9297,9864,6757,8657,5345,9081,-962,699,-893,8351,8221,665,5752,199,5513,1465,5741,354,8594,2186,8880,9631,4656,833,9040,2534,496,707,7688,8381,245,427,6667,6336,9933,6126,5572,4782,454,5097,2628,8695,5173,470,5614,7582,4735,3525,599,-45,5742,4709,4087,2825,2438,4030,4427,9951,7918,3415,9214,-719,3226,1573,5487,8316,7251,5183,8887,4268,8880,159,9556,1137,2114,6407,-858,1599,753,1430,2220,9456,5078,-733,9095,2943,4595,9024,6905,1030,2449,2773,9579,1177,9384,7772,7085,2761,9482,8984,4537,-610,9074,8908,8561,6291,9386,651,6234,67,191,7690,8136,7699,2984,1889,3220,-768,8206,7440,6404,1143,9885,9323,7275,422,2911,9590,8069,4960,-50,4742,7421,9786,-621,1568,6512,9182,7536,4981,6281,-447,3707,-344,8775,29,2584,8906,-701,-707,8109,2825,3246,-622,7379,1086,600,3949,5862,4016,782,4363,-839,7311,4538,8422,7831,464,1304,2242,4457,2409,-794,-916,8401,5475,5912,9601,5045,4740,5501,7172,-725,7642,5988,9099,2902,9776,-235,6170,4244,1093,-125,3675,4731,1182,9039,9255,7767,-946,4045,699,5588,1041,3077,9886,6723,4982,622,8701,7573,8021,2612,6368,4138,7862,-680,3775,6905,-143,7080,8821,5411,397,7134,9810,4724,2095,9452,2867,8701,5056,7821,6183,8996,3082,3404,5218,9388,2564,2712,9043,-269,2053,7845,7998,2848,2924,3968,4555,8735,3357,-764,7400,5309,6983,3699,991,9463,2410,5085,5909,75,2660,3996,3171,831,4939,8502,7150,8838,6139,6501,1838,9119,8566,4955,4798,3285,9478,2687,7013,9229,9719,8389,3788,413,3134,9912,-130,3942,9385,8005,382,7591,5967,8599,1488,8135,46,7545,7559,1141,2087,8309,7401,3785,3922,8976,-329,7591,3620,3660,7550,9652,3206,5868,967,6967,4054,5065,7769,-403,7683,8329,1333,5104,1379,-300,9776,2574,5099,-60,3929,6818,8518,1193,8869,4165,3382,7359,4306,742,3698,-165,344,7067,1606,-900,7771,7887,3357,2532,1576,-776,-628,2179,4804,5245,4416,3369,6715,6180,4578,5466,6760,-522,5041,4278,8666,9601,21,4528,2409,-49,8967,7950,7800,4838,2327,-369,-41,2419,9164,-288,1752,4531,7738,6965,2556,1831,3767,782,9536,6114,8412,3784,1811,2971,1435,-524,-937,3315,2604,1069,7448,6683,1332,7680,5445,5850,4235,8333,-978,3334,4197,-159,7151,-194,26,5806,4803,750,5002,4005,56,6337,2975,619,6920,453,5012,-965,9278,6133,8282,6921,6057,17,2880,-589,4218,-444,4136,247,-286,-547,-235,-377,9434,8826,1230,5879,-846,-230,8553,5657,9928,9280,4457,4355,5557,9063,3799,200,4054,5868,8950,6873,-198,4800,3566,8045,-888,1980,712,629,7146,-701,1446,1124,8386,7323,7409,9519,-846,9327,201,3620,8465,-140,1961,4027,1670,8664,4787,3081,4504,9078,9556,7961,7356,4527,3793,4508,1482,7217,1569,5664,2274,3914,8615,2646,8934,8502,-222,3349,2048,8958,7265,7236,3731,5838,6863,1290,4070,770,1610,4467,9544,191,6953,2870,7003,3461,6955,187,1636,7713,5907,2016,8529,5715,7050,655,7009,-249,-263,1552,7405,4355,2883,7128,1289,2838,7574,8830,2970,993,2499,3584,1785,5731,4449,9562,8307,9061,9379,4504,9444,-496,4382,801,6421,6821,2739,8605,157,622,-212,7451,7288,2262,2972,3815,6446,5169,3045,-891,3411,2823,5583,4916,5172,2567,8333,6136,3617,332,8308,1076,856,8751,1267,-205,6373,3788,2977,2637,6603,4587,4869,-741,3315,2319,2151,902,1991,619,1161,4575,6680,4338,840,2879,4571,3358,4622,1566,7082,7791,8244,9302,5590,9124,2614,9563,7253,9083,-870,4464,4212,4114,6450,5942,431,9728,6453,1683,8928,4042,-650,3613,386,4718,8157,2374,3750,9470,8285,9554,4314,5427,2141,2405,2870,5354,-411,-616,2369,3854,8782,7468,8908,9279,5677,1766,887,525,4002,1772,6214,14,6876,9409,5680,3189,7791,3353,7376,4282,799,8671,-535,6657,3239,4223,448,6938,5862,3266,5175,5792,2025,-254,2588,8630,-105,-59,4426,403,3726,357,5136,1757,8494,7136,2287,8847,549,2470,-866,4453,4045,1906,4204,3440,2194,1971,5341,761,635,3690,5990,7453,6555,6419,4155,5704,-608,-402,-135,4287,7289,7312,3135,7374,579,6213,757,-386,377,5459,8249,2687,9367,8037,8364,4250,8674,2915,7810,7230,653,364,7244,6547,3696,4724,9045,253,7210,681,4536,3103,1885,3441,7838,3262,9677,-370,4065,9828,2891,4976,-314,7935,3338,3979,2607,3406,9868,-832,6299,7486,9765,5901,9432,9288,8664,7665,6482,5936,8118,1573,349,6977,2310,8193,-33,7508,8993,5295,252,4136,6081,9980,1763,7307,9341,1794,830,5424,6881,80,46,1806,-512,6426,4141,-895,2558,3415,2661,416,6810,7059,-850,9464,-609,3178,7582,6645,4974,2444,8196,7766,5533,5690,7417,6786,862,4488,2955,6511,5951,5055,91,7971,986,1353,3049,1649,2902,3044,-791,4343,6370,-114,8751,4395,2677,2957,2445,8102,4358,7160,8017,-559,5088,5370,-225,4390,5401,2296,9805,2515,7946,3004,907,682,3992,1179,8411,3885,-202,9942,9070,7131,3967,3211,-232,6433,7985,-166,5485,4053,9421,-968,5918,2779,2336,2892,5297,6636,4371,2809,4394,9989,1143,4147,2986,5500,5711,6674,7543,7833,1973,4839,1181,8629,5366,8896,9131,4332,4771,9823,-402,6796,2552,7477,3366,9132,-746,3114,5308,9518,-277,7526,999,8737,1207,989,-513,9198,6954,4215,3397,4721,8014,5828,68,8598,4915,214,3970,8769,1941,4873,5826,6609,8439,38,4024,8937,6636,4642,3332,9390,8880,9310,1941,8588,5904,7905,4758,788,2236,8852,9921,4714,3896,1244,9042,9467,-468,360,2250,448,6447,1692,2691,6810,-440,5366,1060,9478,2971,2579,6930,9440,8172,3916,1881,-986,4501,1664,4052,7620,7095,3229,-421,5440,893,111,1122,2887,2362,2185,-67,8388,8959,6632,3604,2350,168,2639,8640,3317,874,8181,62,3911,6332,196,4471,521,5736,2553,1208,4197,3011,2854,4291,5847,1999,2704,1683,3228,939,-891,3247,3850,3137,4166,2894,3445,8913,7600,9073,8200,8597,3286,7179,7673,2485,8398,-515,441,6222,3709,8602,8967,3329,3491,4850,7073,917,1249,882,1194,934,8042,218,6769,9696,3087,9261,8298,2842,167,7053,713,8580,4509,3810,8491,6024,6485,3719,9099,861,4706,6006,844,55,3279,7604,1075,3100,3636,7961,696,4000,8185,4737,4966,5944,1977,5357,4658,9774,745,1895,6628,3236,1586,6989,4585,8572,8026,5210,3509,7806,9692,606,1130,8990,7298,789,2276,-288,-852,7574,-482,-496,80,9924,2044,8802,1327,1024,8509,6509,2193,-332,6694,8615,2958,6871,-267,-216,5558,4563,8667,7335,1783,265,9860,6806,1735,3999,-143,-233,3067,3763,8439,6623,5030,7781,7866,-560,8805,3652,-214,1748,7900,8936,97,-685,7553,1878,923,8133,-259,9113,584,5922,5880,5234,7899,7095,4441,6005,6085,6568,5309,817,9381,1337,7902,-948,6007,2850,8760,6843,2471,4124,4986,2679,9793,8154,9108,838,3535,3735,7700,5304,3988,908,4159,973,3263,639,9837,3317,3405,3753,9283,303,4844,848,2884,5122,5274,-180,5311,3737,4739,9614,8655,-19,8076,2573,6325,851,-429,-839,-476,3917,1205,5829,1153,2566,860,3792,2675,-918,5280,4861,5418,4741,8937,9535,5789,8544,7970,9415,573,5345,5821,5918,2444,223,2301,9743,3339,9032,1732,8822,9819,-537,5813,2351,4812,2904,2230,1292,2125,1192,-848,-772,4416,9800,-914,9231,2853,6889,5431,4854,-700,9727,4301,5565,4195,3944,3550,9121,5693,7662,4766,8188,1786,698,8793,321,4424,2029,4202,307,1773,3049,425,3332,4286,929,6656,5533,3321,8670,5636,9544,7151,8807,2755,2625,-267,-46,6391,6712,8150,1701,-168,5671,7527,543,4096,-324,4167,3574,2479,7308,-885,2585,8095,6032,2458,9305,5140,665,8972,3101,6190,1630,4620,9533,516,3169,9439,1893,1119,5866,5902,5239,-197,8579,6925,8520,-67,5338,8005,6922,6118,5825,8260,6363,858,8992,4756,3692,2080,8973,-636,7666,3881,-356,5899,-90,4105,5902,8856,2344,1774,-229,1298,7061,8198,6643,4090,4673,6585,1153,-610,1185,2540,5337,1601,1525,9865,1576,7747,4923,2082,6034,7786,648,9060,2132,2102,4330,1739,-753,3088,3277,-315,-422,8270,1812,1585,7947,3587,2595,803,3759,8391,4268,2598,4251,9776,923,3330,5126,5844,-531,8193,7005,7714,7211,-772,5223,8868,8430,1646,8921,-429,-622,3192,1830,5652,1653,4222,463,1100,4078,1905,4666,3695,1417,8515,7903,5251,8332,7005,7044,9977,7540,1194,6804,2628,3976,1968,-501,9526,378,4107,4743,-842,504,6234,967,-33,8762,4890,8617,4078,-991,6781,3386,1835,9696,7952,1387,407,1564,2018,6821,6244,8139,8650,4275,3914,6064,4495,170,6088,5345,6827,9875,259,396,1347,4249,6702,539,4730,-283,502,3269,9654,-64,2313,806,2036,4890,3710,4733,-24,2806,1768,6851,8152,8299,810,2049,6064,2482,2735,5372,5618,275,9879,7114,4758,7215,4684,2576,5472,-276,-759,1999,4579,3402,6611,-713,6155,4382,2447,9982,5205,3666,5070,5233,9575,6897,7476,-696,7322,869,5621,5794,-924,9352,4936,5345,7400,8039,997,5140,2602,5957,7165,8200,5776,7849,9340,6963,25,6105,-163,7236,7671,755,3787,-656,8465,-934,5652,-820,3091,6257,713,4156,600,1272,5904,6332,482,7461,7352,1693,2491,8059,5165,9057,8398,292,279,9682,4994,8884,5813,2906,7370,4756,2715,1958,3994,1219,5273,1983,1639,1166,7531,5810,3481,2821,-820,1135,7528,-616,7295,9725,7891,-985,2341,8277,4565,-215,3888,9094,910,318,5499,8854,3825,5280,1865,966,6347,5634,-628,-545,7886,-296,9355,1505,8669,380,8206,6256,3567,8516,1973,3072,5869,9695,-389,6633,2451,9292,1941,3849,8288,7621,6338,7161,5735,9663,206,1952,5942,-249,3601,9074,8535,2974,4486,-786,5042,9692,1968,4240,4737,4645,2722,5006,6656,5246,1818,2425,8325,8953,9316,4687,3362,-156,459,7305,4601,4982,1198,340,2356,-783,5315,6769,3095,1892,-694,1727,6652,4253,248,2340,8781,231,2070,8751,5684,651,8259,6311,422,4476,8549,7432,8763,2264,152,4948,-219,3192,8610,-812,4701,-854,3707,7732,9317,-648,1709,9227,-562,6829,6057,8433,6818,2584,9130,3930,7198,7982,4075,6684,1613,5810,4996,3610,2728,7065,5652,6356,1613,3128,441,3150,6586,1223,5181,2730,8529,5937,6252,-7,3968,9472,4030,2623,4599,2111,3423,-247,2224,-38,9354,-73,684,2393,969,3037,8524,2308,5419,1410,7085,6937,7678,71,6023,3361,-478,-631,5140,8031,5055,8563,1128,1718,7509,3511,-943,66,1099,-851,8572,8056,-829,8082,-823,9508,8564,6086,9456,6985,-660,789,-757,6370,1353,3466,4113,5736,5484,1475,5274,5335,8713,-704,5239,9425,9681,2045,-451,6540,7726,8419,565,3756,575,2224,3505,9874,1102,6404,7393,42,915,5819,521,8067,4472,4180,3161,1394,2691,-111,1298,8171,6676,2306,1016,1555,1761,1091,-679,877,1465,4714,1570,5099,5286,2552,9594,7022,1952,682,9742,7454,6550,2318,7210,5229,3738,5333,4926,953,-312,352,9935,6739,235,5306,4358,9521,3393,118,3263,7748,5933,4490,4849,-822,6262,9859,2909,4913,6803,2918,8824,-958,6840,9494,8801,-167,-488,791,3511,399,3422,6872,585,6090,529,2144,4754,9228,-530,-806,2541,2271,5811,7991,-166,3249,4144,-956,3458,1681,-660,6,269,8812,8314,6390,6522,4652,-332,3587,7288,5221,5026,7429,-603,802,-543,8106,3206,4342,698,3133,6443,8638,4408,1461,1511,6950,3760,1316,6917,6564,2028,160,5396,3872,2965,8868,-833,-661,8268,8785,-377,-104,3128,5829,6400,-987,8454,1640,3891,2919,2887,-992,6545,9296,791,4141,8526,1888,2039,9530,9697,477,2705,1277,3128,2865,6641,5878,6378,9379,9827,1821,6459,8069,1484,5036,9501,-316,8519,3424,3784,-533,1545,-88,6283,954,181,1407,8429,7307,-949,1740,2564,3878,9232,9447,713,3851,8617,7044,1246,7061,4929,2507,4812,3850,2640,1755,3566,4691,9851,5335,9955,2314,3362,-782,-471,1164,8437,9111,3798,7304,3869,4040,2320,3275,-686,4783,8862,1003,3215,-811,1248,9078,497,4344,5787,482,4745,2792,-757,5132,6652,6766,9561,-298,3112,2710,-612,-227,5425,5875,8664,4595,8077,5345,1460,3912,9630,6794,6593,7611,5492,143,8600,-975,461,462,630,5739,6801,7114,2152,6254,5444,1466,1368,247,8360,3277,9104,1250,4012,5502,1189,7801,3743,8192,6995,7184,9004,8526,-647,8931,2719,5946,2424,5006,6360,6457,8332,509,1874,8052,2061,1238,7172,8634,-339,7213,-825,4467,2600,7450,4122,4117,4890,1163,9575,9843,1409,5928,-113,6174,2519,7828,1232,3469,8503,-117,3240,4099,8113,5669,2004,7158,7711,255,600,5511,7819,3935,9668,4744,9799,2076,1928,7113,4259,8770,4367,9841,2125,7156,3561,5827,806,3683,6273,-432,716,5119,5899,7050,8127,193,-640,4598,3696,7676,5584,-761,6433,5753,221,3073,1583,6731,6783,2008,7792,956,5924,5840,-901,839,4507,4704,55,2344,7423,-219,6936,8833,6565,4792,467,9647,733,2914,8469,-267,8924,6770,8433,-845,6022,601,2691,9138,9362,3578,2784,4450,1084,3801,-573,6653,5015,4816,5139,1037,5362,7668,9188,-879,131,7424,6488,9677,-25,6239,9296,6082,3906,5807,9277,8276,6548,1145,3376,7732,8110,225,1649,9752,9060,4387,-961,9443,6975,2832,7295,4508,5647,4018,-399,3664,-671,9411,4831,956,932,4440,7251,4159,689,2176,3070,9906,-689,7910,7842,1619,8060,4248,7207,4645,7843,9561,2337,5653,4936,-365,7045,2302,9816,2404,1111,339,4315,606,8880,-174,6360,58,4687,966,9330,4303,3249,4768,3343,6637,3181,5361,2462,8682,7264,4157,9673,3797,-805,9523,6397,2233,3457,156,8707,-931,2126,3482,3555,1405,-281,4733,6921,6506,2239,5624,9104,9039,6645,7266,-659,3511,1621,3236,7933,-905,8935,1249,4229,1091,1162,4250,2596,3954,4593,737,2384,56,6128,5823,7351,1655,3964,4703,144,3544,5004,55,5867,5852,-165,4411,8628,8929,1577,317,-752,8476,1028,9133,5295,-233,3944,1813,3275,7649,924,7497,9170,1310,4506,4382,-389,4131,827,4821,5247,5845,6239,6130,6582,2281,1354,8861,7707,2046,2004,7764,4230,7495,783,-811,3037,560,-888,2836,2267,1296,153,6840,396,7172,6920,2161,9897,966,9664,2604,480,845,-343,6354,6195,-926,473,1977,444,9864,3116,3907,3224,-413,1357,6762,5309,-89,5749,3629,5236,4556,3288,9330,6082,-120,1333,6313,756,4156,245,2519,1751,1971,-418,6228,6007,3492,-196,6184,9617,4209,6155,5707,4035,579,2474,5361,7776,3683,9657,6317,8929,9672,9001,2727,8870,-580,5252,9711,514,3314,764,5016,6052,3594,2987,6824,-234,7400,8734,5448,8255,6798,3304,7962,445,7331,9661,9138,-86,6033,5438,676,8988,-67,5596,649,7595,2903,5798,8862,475,7708,6054,-999,2354,8241,6932,9276,3542,8969,9999,8494,2216,4940,6158,49,6597,9314,6622,5339,7783,247,473,5646,6814,1276,6397,8441,8588,362,2777,8406,9865,7453,5132,-831,4462,5182,5161,8457,2664,2105,8943,7344,1592,787,8583,2551,6793,4972,161,843,3031,6112,-108,3610,5320,6906,6957,415,4802,1445,8158,-171,-360,-48,3674,4080,6535,3760,2085,9047,3278,6381,1595,9553,2683,6972,4829,9870,9851,1991,6603,8107,6445,1428,9669,3490,4137,6945,8305,3037,7245,155,9384,28,352,-592,5740,3789,-634,2764,1998,6835,2789,5321,713,530,9018,4020,5001,3254,2641,3389,8399,4887,4836,3030,-976,8049,-188,8323,4666,7114,5350,6507,-151,4589,3662,-238,671,8604,2870,4997,1816,-463,5034,8316,-604,1658,8320,2987,9098,1360,-872,-706,7375,5247,9304,9338,-820,8202,875,3030,441,6859,1382,-653,5381,7023,-153,7505,8451,3027,5559,9888,445,8969,7570,630,2492,402,2294,4107,7399,9881,8971,9914,8906,2863,1971,556,1938,3511,9838,9416,9833,-174,9470,6731,9278,3779,3987,1400,4,7114,3086,6916,-334,-646,15,2810,6177,9251,6546,4433,8329,3318,6053,4754,6166,1462,3780,3236,1559,5070,194,9040,313,8322,3591,6913,8292,5279,9467,629,-302,9164,1326,413,2065,2295,9766,8626,9916,8247,8654,5761,2003,-498,5131,5352,157,1875,8395,7145,8977,9687,6841,3517,9465,5853,6761,4793,-231,-574,5784,2192,4755,1367,2827,8559,-326,3654,918,-945,5240,8410,7340,7714,29,9497,5811,9920,1524,9503,5572,1421,6495,4431,-659,9752,8,329,-67,5187,9222,1979,1825,-27,539,6563,2525,1606,1784,6836,3512,9273,5658,9125,-50,1891,830,5094,8474,2349,7505,8733,7534,7265,2885,5376,-74,4473,-924,2363,7727,4454,7496,-640,5156,3863,7826,1136,3523,3309,3541,9830,9590,9688,3916,8112,141,-543,7319,8785,4866,9283,8623,350,5421,6486,6322,8791,1026,6509,2852,19,7582,6228,8050,7609,6086,9770,5484,-168,1251,9831,7774,1581,-85,2298,-671,5492,7334,8522,9375,6532,7685,7809,2155,8467,8317,1555,3106,3596,4606,5945,974,1333,-61,5984,5709,7211,301,5071,6250,5859,1896,7839,5546,-742,9142,7769,833,4669,5457,2738,-498,3385,7076,1817,-741,9960,6396,6165,-745,5043,-305,3272,2465,9917,2458,225,-514,9226,5412,3196,2293,2569,3011,4480,546,7994,9609,4778,980,7145,-244,1977,7555,-196,7686,6982,5720,6737,886,5728,6621,2596,580,3400,1347,8491,-961,8954,4867,4370,2782,8920,4946,9092,-424,7,376,5557,5351,9586,4209,9220,9831,5392,652,4115,-244,7275,5943,-497,7791,-451,7856,8634,1572,6401,5379,5829,2895,5379,2011,8660,2488,1699,6336,2787,8167,2446,3956,6614,4213,4332,7496,3908,9621,1184,5311,3781,7353,3265,-739,5795,-271,9580,5457,2381,7829,9694,117,7817,8035,1168,3295,6490,500,-150,7292,5401,2922,-704,7893,4743,2648,5279,8363,6963,3546,5507,1947,4403,-343,3902,7185,8654,-490,190,7884,27,6152,9745,8711,3934,-600,8477,4648,-259,-564,1290,995,1664,6133,3519,4859,4844,8767,-736,-908,1422,4505,8444,2195,6463,9146,-727,4271,5212,5463,8127,6724,8552,2599,3509,9613,1122,2968,7623,7703,4024,9062,1463,9171,7619,393,4200,8046,263,5102,717,3128,8368,4423,5053,4780,7714,2852,8066,9694,184,2016,-953,130,9789,5979,4215,6096,1073,4362,-204,2156,1371,6640,8084,3712,3322,3640,2734,2926,3957,2569,729,5117,3415,4988,6557,-419,979,480,3319,5848,8398,4423,483,6824,591,9039,4410,2116,9208,5934,7448,165,8722,2614,6916,9145,617,3433,1294,1166,8533,9048,2983,7794,4241,8455,501,1810,3955,9351,584,9862,5632,6237,8644,1845,2427,-949,4193,247,8173,7897,1975,9834,6375,7573,2272,3106,8330,8298,1819,7068,2134,5229,-936,7484,4571,499,6720,1134,6431,4369,4566,5630,8889,7450,5102,7767,1212,6198,795,9534,6259,-492,6136,1207,7017,5347,8614,5854,540,2920,1048,2919,8653,4380,1089,8432,1931,3380,9539,6889,4419,3754,5186,6501,5615,2610,2539,-411,2002,43,286,3097,5071,761,7,464,7040,2952,1724,9138,-696,4332,5635,39,-700,9407,5876,1747,1475,2732,3600,1081,2729,1920,9145,3992,2429,-796,1858,5169,5165,4568,2458,1645,9227,4864,4010,7695,9600,-597,8878,3988,745,-418,8920,3028,2429,562,1341,2687,4861,1869,773,5591,2828,4157,8397,6278,-775,1257,2478,9993,5880,1520,7640,-591,5964,9224,7724,182,5070,9067,9874,6823,5969,-883,3091,-711,2501,3357,3312,6510,9240,-725,1811,-310,8896,9974,776,-530,2407,6170,8714,1515,4296,5942,6699,-770,3199,8661,1839,516,463,3450,1597,6241,1005,1499,4066,9293,2222,129,7721,2505,6935,8870,3769,3691,867,8009,7064,377,-340,4833,510,7553,4926,9511,5686,2675,9566,-964,706,5767,9675,3535,2260,3120,93,9839,8427,-501,6231,9541,2316,563,356,-719,8319,6267,4650,5333,-351,4325,1592,26,4954,1094,352,55,9771,2272,5649,2075,4010,9793,5822,5940,7834,6534,7685,1029,5611,9630,4409,495,2496,3680,3675,7953,3953,3751,2124,2541,8144,3339,1199,4964,4541,2870,3219,7663,7820,7284,-751,5080,7399,6199,7432,2181,-546,8282,6342,2127,848,6818,362,4945,2894,8240,8462,1087,179,1650,7583,1942,9765,6080,90,7245,-990,-532,8480,8814,893,2629,8331,2170,414,8073,8799,1154,8023,3677,2270,8718,4986,2267,6761,4535,5381,-451,2608,4496,5402,4647,9457,5639,4392,4023,436,9706,4971,1138,4116,9540,698,6297,1303,6852,9150,4438,8831,5981,2325,9845,6199,-857,1953,4228,3025,5799,9164,-661,3040,8311,1583,-804,7966,5819,7304,7573,2966,9135,2280,4762,9417,7715,8773,2057,-12,1138,-855,1209,8482,8373,4422,7321,-214,5779,1296,9817,135,6510,9492,3683,2892,6353,-622,9046,969,8417,9279,973,2906,4075,-121,3161,2681,2087,655,747,1168,4193,3939,-515,7196,5213,6465,258,7403,8720,4038,3243,9546,2300,2377,7807,6450,1152,3721,4506,5412,8363,7550,1134,5351,7442,8688,8668,7708,-423,4287,8345,9862,-609,9696,232,3719,7259,6316,8234,9650,7456,2985,1354,4317,5978,1051,5529,3082,3161,9525,5717,1966,5594,627,9183,6095,8684,1706,919,2606,267,9938,-401,1945,3082,3908,7803,3277,587,4040,9716,9454,4100,7977,5344,2494,3998,4283,2986,8478,2075,1695,776,5253,2850,6724,-773,-540,118,7697,3390,-396,4358,147,7530,4122,4228,2483,7394,-391,6855,5667,266,6888,1394,6017,2644,2163,7741,9161,4433,4247,9214,1024,6303,3262,-950,7515,6207,5345,9172,585,7552,2269,4084,6141,2334,7199,2113,1175,1230,7966,2306,-376,3514,9775,7491,2763,18,3955,7359,937,2540,1349,3924,5384,111,8586,9608,7999,3603,9781,7933,3824,5247,2230,984,1882,936,-900,2637,9594,2661,8935,5154,8513,7574,6651,7131,6866,3509,1443,2558,-551,-938,8042,5199,4045,3309,-50,3049,-327,4734,4006,6649,3012,2936,3548,2949,1159,997,3369,1739,1375,6165,8593,9221,6822,8406,7172,-698,9905,6482,8979,-973,3380,1566,2476,5672,-934,4026,4670,7914,5279,7703,1,4174,5669,3589,7212,6368,6494,5076,6441,8823,1591,7733,466,7432,6098,1298,3671,5976,8991,-147,5738,6759,4200,3654,5563,7865,4453,9757,2101,1224,9112,4127,6858,7197,6871,4849,4420,2662,331,3663,4835,1464,2502,1691,-174,-275,-926,-475,-135,1324,475,6649,9297,-839,904,8946,9219,7540,1063,8900,6285,4996,1421,4787,585,6523,936,1457,4003,1921,3399,35,7193,6081,6188,2138,7192,5177,3197,1604,5037,-551,6558,2898,4487,837,8754,2622,1589,1508,5329,843,6010,4915,908,-240,-232,3336,5950,7893,7705,377,4773,7597,5586,2403,1419,4228,8286,2636,8613,4276,-112,6525,3703,617,5844,8140,8910,2122,6836,3333,2944,7906,4364,6295,6225,9114,3622,8006,7155,7945,7906,2484,3824,107,7129,3692,6033,6990,7130,1557,6141,6480,5093,1954,5125,3299,3314,6285,3963,2002,6061,5535,7786,352,9224,1086,6852,2187,1316,7096,6638,8839,5362,9696,2945,3846,2344,5646,2353,-161,3860,3967,8071,2625,8021,5440,5168,24,4106,7262,367,8687,8605,4231,3871,1382,4862,7788,2246,-176,2993,5306,-582,577,4699,9345,5166,950,415,7536,881,7859,4500,6573,1184,5693,1069,6578,2781,-242,9701,1963,7674,6425,9658,4770,4225,2164,723,3499,424,-146,7969,3107,6738,-689,2212,-675,4349,9902,3980,5781,3549,4074,2396,8264,-802,3032,9357,8431,7488,2840,775,8596,733,6061,3977,-284,1238,3291,9657,3546,6858,1189,8213,9747,5660,6476,4528,4957,7253,3890,680,4761,9241,2633,1453,5043,3648,8879,8454,7166,2957,6903,7264,4511,-405,-184,4784,3105,8377,9393,1320,7344,3443,1258,534,8827,-986,474,4198,535,7245,8086,3974,3728,3435,2475,-140,2463,9480,5245,7833,5557,9731,1512,3579,3117,2722,5002,5462,8151,7016,1569,1105,-709,5349,-330,8632,4049,-539,-21,4874,1108,7450,277,8838,6733,1398,891,4679,9122,-970,393,-804,6124,9225,1520,1503,8058,3402,1799,3917,6121,2811,-396,7828,8167,282,7565,7266,226,2682,7862,4070,1432,-605,2693,9785,3110,8008,9044,8506,3050,111,2687,3917,6691,3614,8329,1916,1815,3580,8073,1402,12,6763,2390,8798,8299,2445,5232,9177,1738,4798,8109,7201,4315,5231,7786,3538,7301,3518,9725,1589,9220,-195,6659,1987,-764,-960,1399,2833,9187,-350,5820,4843,3126,3502,4812,3442,5436,6335,7275,4818,1204,4351,4374,9641,1274,5661,8018,9493,881,-396,6990,2239,6584,1476,1556,-271,138,1433,2455,323,3899,485,5025,7182,8658,2570,9016,3261,7596,665,8000,6293,8757,6953,9772,1628,4966,748,4608,2874,9674,3330,5803,7741,2359,9496,9336,4933,6507,3226,7234,3543,-71,-314,913,8350,2729,2782,2850,8550,1491,7039,2405,2999,4122,1472,4461,7686,2379,-170,4499,3095,3667,3733,6493,1302,6137,8516,5951,253,443,813,-769,2660,3629,7515,8879,-667,3281,588,9936,5841,3433,-713,9357,2096,2447,5149,8325,794,9433,9222,6369,6176,5892,7210,6387,1533,65,9788,-314,2253,3587,37,6902,6823,5321,4587,6954,8890,3051,1789,2215,5948,538,1706,3853,8798,-420,3590,195,-29,1835,750,7036,4360,2797,7510,5774,3125,2752,9344,4368,2713,679,-518,4061,2704,5707,488,6980,8385,88,9779,8975,5997,6546,5705,-828,2978,8969,2357,1129,-444,2334,8708,9051,6979,3528,1432,6121,1089,-268,386,2554,9990,9117,8697,3440,5614,-450,4474,5711,4713,7577,7811,2817,5184,4302,7431,9758,5450,3561,-941,455,2487,7270,2165,762,8640,4476,4973,4879,8523,6667,-773,6620,2121,8373,9262,4134,3660,3674,-141,8380,9482,-652,3520,528,7022,6270,4377,3984,3589,2088,-110,-400,91,7406,-56,3313,3852,2951,-208,1234,1848,1886,1548,8721,9810,7500,3944,3767,7011,9517,8093,9607,4725,-723,3534,-664,4207,7599,2456,1204,7808,1009,2778,7281,-861,7117,930,3570,4153,1875,5304,1091,167,8880,2410,-274,7413,802,8529,499,2164,9961,8973,6035,-913,2538,2192,1672,4355,6863,9494,1687,1757,3332,2967,8823,7444,646,1285,-502,3223,4720,6662,-97,456,7656,-878,6493,2371,2081,4928,8567,1998,1505,9888,-666,7439,9658,-261,7004,2680,5639,798,5821,8517,6976,7622,50,5706,1889,644,4161,9544,713,-602,5488,3099,1038,4791,6118,497,2548,5077,8602,7884,225,1460,5512,6060,-66,3546,8471,5204,6553,4734,8254,1988,7892,4070,1073,6084,8136,5070,5526,8606,6501,7111,6282,2002,2116,6455,1596,648,5233,9111,6049,4109,9143,2245,3990,5015,-922,-388,4493,7700,1842,1384,6807,5994,2965,5566,-723,7806,4758,1277,5060,4222,1595,1690,9977,6721,8371,8287,3793,6458,6332,6555,7394,4942,5354,1919,8381,9371,5887,2344,5143,966,5831,5215,9534,6357,6071,7480,3698,925,972,5361,8289,8469,9159,2902,2627,2337,3207,7298,6264,1329,2023,2782,221,6652,6185,5670,9142,897,6546,9177,9721,4057,4338,1685,7723,4902,7319,5416,976,339,6146,-806,5805,3202,1300,6889,872,8502,6653,-214,9437,4469,6018,6486,6482,6514,3933,763,6030,3590,8261,8460,6249,8376,63,7806,261,9516,9170,2160,6948,6921,5264,7285,7416,8956,9147,8609,-792,5377,1550,233,6828,99,9080,5076,2013,523,9022,4388,4064,5786,2397,354,4034,3849,347,4325,2616,377,1705,9852,8384,2065,9636,-408,6331,-946,3908,4026,5996,9821,4719,3549,7351,2955,-911,-29,3517,8228,6181,9002,8925,-801,9377,6830,7455,3687,9823,527,3118,6551,3098,9440,5371,5316,549,-98,6125,6645,8018,2750,2648,3912,2054,195,-710,4454,105,7222,6976,2394,-427,5912,8809,6746,3005,737,8847,406,5650,3529,1992,3076,7257,360,5312,6640,739,2077,-853,9242,6428,8202,1917,8233,3631,6004,634,7913,8465,9504,2360,2748,9063,7257,8566,6575,5734,5047,1383,4468,-604,1159,6497,9436,2788,1972,8944,2525,3243,-633,1404,4514,421,465,1815,8454,2039,6714,3947,-412,1182,-778,3333,2231,5483,4515,3399,5948,5002,2934,2071,8620,4650,1119,9395,1512,7886,3265,3847,5617,8972,4732,2607,8894,3033,8933,1470,5308,8022,5604,6687,6829,4871,3482,-911,8410,3971,7042,9438,5008,5596,1048,8287,7877,3134,-795,4944,3518,-558,-641,6760,9600,5576,1158,2517,3830,5422,705,7473,4479,1667,8401,-276,5930,6272,1414,7822,3713,9486,813,690,-649,3103,7888,579,1162,8460,8563,2297,-93,1975,4588,5354,513,5434,9574,5857,7474,8132,6101,6830,5546,8876,6487,8414,7211,4504,-842,44,4340,4543,-826,6679,5097,2427,2914,4712,6653,1528,7493,5672,3729,5565,1607,9435,7358,4012,2047,3694,7077,5839,8244,5486,641,846,9187,-327,8598,-17,4047,4718,5130,7034,1467,7626,-156,61,-468,-22,7585,8760,6049,8679,426,6959,6600,959,4650,5892,1676,4985,8450,4188,8232,3904,5535,7521,3779,317,9399,7561,3442,5773,1706,4850,3156,8108,6008,5162,-7,-103,5836,1859,5610,9118,8878,441,8467,580,8915,7158,9005,1471,6932,8001,-272,8997,2635,8273,4686,7634,2156,-470,8945,8749,6505,-141,5257,1134,7653,-902,4697,8456,6707,1145,7438,2022,8750,1997,1136,2604,5799,5669,8008,7404,7842,3549,3746,5755,6647,7744,8253,3625,5785,3058,2831,585,-193,6815,3477,4735,-344,8589,6023,6815,4673,7374,4902,5824,7984,3320,8970,3642,-404,3123,6023,1522,5490,3821,-827,4421,3511,1823,1249,2691,4061,9719,5127,3045,987,244,4719,4333,-625,7303,2173,8345,948,4973,5267,7553,8024,7721,3755,5156,3608,5315,6534,9504,7610,406,4109,7917,-251,3242,157,4734,3691,2024,3310,3725,1514,7908,2944,6656,6534,8885,4281,8397,288,4656,3416,8848,5531,5033,1734,6142,5485,162,6507,4905,7975,7962,8986,7968,5523,9483,206,1150,6086,7954,6097,2734,3403,4454,5837,7486,1785,-346,9672,3279,6825,-404,718,4305,1134,4517,-941,1746,104,2303,2585,7913,9128,-461,777,6210,180,6644,813,873,9837,5992,9772,7033,2781,-369,4799,5987,1563,9913,3239,1481,-322,9982,1265,2586,4379,3358,-296,3408,3858,7617,1616,450,5611,157,-193,6282,4780,474,9559,8970,17,5880,664,2481,2087,3939,8263,8667,-347,-529,9784,6506,697,269,8244,-662,1282,6477,4183,6751,-37,2918,-729,9990,-812,-291,2762,4787,1265,5874,-854,-782,4324,6929,3134,5928,362,6993,2258,5678,-75,211,2302,9861,349,2815,-18,5104,9473,3958,4747,9315,9964,1218,-182,-591,2645,9184,163,6037,1308,1813,6096,3375,1843,632,1995,4196,-648,4676,5619,242,6023,4249,2173,6438,1513,6732,67,4048,9862,8001,9401,7478,2754,5553,3813,1522,4417,4606,281,-41,9060,1999,5856,8391,9434,3402,4265,2101,554,2145,6001,-580,2730,9039,1610,3174,2719,9363,6433,1955,7758,355,4787,6929,7957,-625,5611,5973,4026,9458,5096,8517,5555,2737,9622,5704,9637,1535,4022,4237,3459,4146,4650,7142,9238,-251,-228,8396,3732,3969,4492,6789,2850,4131,5552,8655,-714,5229,8637,9235,1458,-661,3822,924,4435,2153,7593,1077,233,4445,6449,3800,6609,3998,690,4077,6797,-81,4105,5339,1170,1315,81,912,1576,3395,1591,3379,4072,7733,8185,6947,5376,4684,9314,6877,3146,8944,-54,1034,6740,1038,1055,8726,7353,5164,1431,6508,-176,3177,1808,146,-114,7458,2064,7816,9704,1230,9269,6027,-622,6116,4740,6188,248,6983,8067,6867,1429,4107,26,-261,4374,6310,2536,8266,6219,231,2305,7776,4473,7630,-715,9031,8138,4398,5769,7100,7641,9256,3466,134,8616,9511,7079,6631,4609,8777,1126,9662,3608,-270,-799,1232,714,8471,-921,7293,3169,845,3588,3538,-607,2255,9356,5963,8335,2265,1118,3725,5472,9891,9686,932,6879,6261,6313,7127,3013,2169,9926,3200,8306,2032,5458,-789,7809,3982,6742,2066,6321,5221,2122,3748,7763,-139,4480,1396,4002,2808,2302,3264,9708,4610,4363,2655,8617,-522,7565,1681,9311,8392,5095,2315,4379,5120,6927,6246,-666,8850,6679,1608,8741,5540,792,678,8128,4147,1040,3778,5925,5081,69,-195,651,4150,435,2176,71,2844,8872,551,7267,7417,4858,7472,642,2735,4988,3432,6220,9778,2140,72,7140,1218,-85,9653,5740,8330,9117,6249,-867,5067,7963,22,6557,9374,2487,4885,9596,7318,4485,1971,1174,409,6753,4764,3662,7699,3369,384,-92,3985,9252,2289,9547,2538,3164,9456,8069,930,6535,8470,4669,8469,-305,2934,1414,8004,-431,5748,1733,5595,1050,318,6095,8163,1256,77,2190,9774,4022,1092,2514,8853,2473,7776,8501,7030,1961,-704,4446,1062,2693,9798,4520,7522,60,1313,-189,1009,-59,7365,8136,7421,8784,2396,4601,5590,273,5626,2184,-162,9093,8500,3987,3006,7549,3894,9209,1696,3131,7399,2824,733,5368,2252,3762,2789,1418,2068,8367,8082,5392,5053,4618,6615,9477,114,889,4137,9857,9987,3211,2155,2463,1189,2308,3972,-326,7396,2501,5511,6357,5106,7066,849,366,4207,8876,-164,2904,2762,3497,7843,1749,1673,9221,2632,1623,7538,2755,-495,6365,441,812,-211,5965,7194,6270,242,8607,9545,6660,3121,1674,2832,7229,3064,2307,1612,9824,2884,8393,259,9720,6419,9340,9071,8401,3843,9802,8341,3919,9790,530,3473,2228,5575,4786,380,9460,3210,7508,1605,8992,3505,3070,1358,7830,5020,5008,9112,1053,192,6705,6487,5491,503,8967,258,8606,8472,4681,3397,906,6945,2470,5518,3645,8757,3642,4663,2366,4722,7309,5976,6187,4110,3742,1410,7063,3513,6725,6134,1707,384,4431,7040,466,1738,1563,5019,1000,2702,2821,6475,483,8942,567,4725,8737,7934,8431,5097,6782,2887,9940,8148,4444,6814,-5,8987,7696,9097,7529,5997,5633,4160,-817,8333,3656,-446,4715,7129,8314,8803,8228,8227,9273,3524,2540,1043,3725,3969,-889,519,1639,638,2916,5313,6941,3818,2772,2084,7842,2771,1116,3988,4738,-586,8641,4599,9604,8579,-670,4850,757,3884,5679,9582,-309,5628,6508,2088,7864,9159,7381,8427,7718,3572,5282,6166,6338,2673,2030,4146,1180,3676,4124,291,7158,9956,6250,5345,7001,-559,7480,-540,5612,9739,4417,-464,2339,9265,6843,9243,5283,7758,5811,3133,2983,5403,-101,4177,8466,7392,4048,9352,3250,6986,4148,1589,6253,-970,441,3634,6379,8270,5751,2802,1998,1786,-983,9693,985,2483,1056,4336,-633,7266,4186,2447,3844,9076,6268,6859,9824,4847,8080,931,4742,3801,8016,3803,7598,6466,7459,2325,8046,590,8206,8551,2025,7098,4082,8074,2900,1168,2986,165,2559,5803,4569,9806,7075,8516,484,1446,1759,4344,4724,6627,-269,2363,5332,-343,1897,2899,7686,9044,9704,6444,3986,6260,7688,3081,6909,8592,777,7228,2457,7969,6464,164,8696,8850,1030,4785,7783,8493,5857,7361,6677,2693,7970,9990,9226,576,6170,1858,870,3219,3575,1393,9548,3859,2324,2713,7419,6819,8193,9580,7460,3751,804,-62,5368,761,9091,4378,6915,8,1088,1610,2032,6481,2621,6187,4701,7494,3829,3132,7208,2060,2661,751,5127,3712,8497,8880,5993,4771,7272,-692,7917,6721,3207,5084,473,782,5460,4387,48,2457,1653,8266,8758,7348,1,558,7734,-97,51,3178,8361,1267,8259,6298,2269,4464,5695,2571,8174,3110,7677,5724,5375,-525,850,9981,8825,3765,9164,5939,7455,3101,2712,5275,6538,2294,3663,-632,5131,4515,4934,8558,643,485,9435,2667,5746,7057,297,389,9422,8908,8842,9537,4336,-802,-322,7652,6943,7585,4781,4911,8045,8343,8727,4104,7296,3746,1470,8075,-468,7398,403,5811,5189,7270,3857,8929,8975,6824,6509,9375,-743,4375,6010,5294,4334,9598,117,7608,2653,8990,2763,5088,1932,8512,2111,926,8764,1687,7115,-717,-55,2521,321,3924,1056,5066,1001,3073,5919,2176,5695,68,7679,4897,-279,7863,6396,6291,5703,4340,9646,-492,7495,3838,6920,-292,2482,812,741,3410,6768,3861,3346,8492,9838,9748,9758,5334,5082,4072,1910,-411,187,-24,3487,5837,7686,4217,2640,2573,6443,3871,9607,6147,6539,9062,2033,3864,1962,-966,5032,6716,-131,292,2085,4560,4019,3368,1770,3575,8935,7276,752,-63,2093,8903,3902,5912,1494,8859,4507,9510,-754,3483,5614,1386,8895,2011,7261,2861,7800,8821,75,9119,8410,7890,-431,9827,9267,4682,3795,5534,5521,6547,1392,6524,7009,8736,520,7068,-229,5299,6849,-392,5442,-128,2564,4986,7608,7694,2264,7383,1301,496,9526,7708,3351,9160,5416,6884,5182,4382,9888,-134,4396,7375,6264,3600,7140,7486,1741,4717,2562,5713,8636,2982,7519,8011,4049,2519,6455,59,2042,3542,2081,-449,6794,9593,8356,7199,-166,451,6667,4726,7173,1764,5166,7544,8748,2708,3475,6651,6377,2606,5434,2449,7938,7917,4180,7901,216,4284,4816,5316,2235,-817,8204,9236,8998,2230,5785,5908,6495,3596,8119,7273,2120,3685,8872,5903,2797,3950,6357,4504,3132,4228,1223,9946,3172,6361,3865,9274,5304,3234,6295,4242,9485,670,-440,7090,5057,2493,7313,232,7166,-975,9086,-382,7923,921,7442,6172,8501,9216,7434,2836,1848,7047,572,2268,552,4814,8069,1742,9631,1999,2115,3161,3558,852,2451,3678,2016,8966,-106,2558,5078,9951,7103,1517,-835,8835,200,768,7449,2860,2997,2385,5806,-234,9516,4111,7107,3100,8366,7502,8851,2209,4377,4150,5291,3368,1132,8545,6327,8298,3167,2148,4710,1903,2232,921,7411,5693,-685,654,-219,4018,-236,3029,5739,6967,1787,9940,7537,2106,8805,4297,7550,-604,6741,1425,2062,9060,-203,7899,9779,3200,2629,2942,6132,8152,-47,7568,4679,461,8349,3123,3498,5982,5433,4076,8508,8120,52,262,8584,7389,1544,9690,9905,726,2719,2052,2169,9784,8875,4318,-634,293,118,67,4586,1148,2114,5725,8669,8188,3106,8778,3886,-827,8376,4147,9982,5267,4684,9155,4129,1648,-280,4495,9609,-749,-727,-98,9630,1824,1802,3953,7150,756,7247,4325,1857,2942,4598,2336,9992,8654,3797,1109,3298,3956,3669,4351,-353,2273,1962,-374,1866,3540,1180,3525,-244,5300,5888,7735,-313,406,7204,7925,1993,-66,4855,9349,2781,4243,-887,1938,2083,8180,4748,7617,7299,452,8497,1972,-511,6001,-250,655,-579,4849,7581,6600,3985,491,9046,106,-476,4846,-968,1840,-298,7636,1039,7546,4235,-203,9985,-687,5642,-408,3820,4280,8648,6705,5797,2618,4866,386,4210,2024,3251,5626,8682,1246,1973,3311,4107,7170,4666,5568,8466,-587,5070,5223,8221,1323,9928,7313,7120,4262,9535,1462,3723,9989,2254,0,2067,987,6620,7539,-661,7287,2104,8747,8414,9874,3514,1040,6895,907,-917,4105,4863,1937,8372,9514,3269,1536,7454,8574,124,-342,6067,1733,188,6774,2901,9046,5316,1672,85,-341,3266,9258,1796,2826,4286,1160,1060,7707,4819,2944,4783,9693,5357,6740,9184,8147,-800,-23,8720,5617,9514,9340,6517,3738,7183,4559,729,2856,5139,884,7582,655,9437,870,5161,299,7104,6522,8539,3451,670,9483,7215,6514,924,9169,3280,9830,7120,3613,4809,504,2594,8453,5533,5194,2397,2590,7489,761,6292,5860,3189,2593,7306,40,5901,2288,8511,1693,-498,7846,-143,9045,8994,4522,9187,8472,1178,4669,-586,5382,2543,9359,9996,3024,1878,7380,6084,3975,5847,-94,6783,-941,8618,2647,7318,338,3151,9398,1447,9768,6350,5430,7491,8999,2858,7305,9813,4489,6771,295,9014,2453,7358,2620,9730,1722,4804,2504,3673,5934,1939,7099,810,-28,4645,3484,5747,-521,3203,2345,4697,2870,5161,6288,1492,9647,2989,9637,5452,1476,2965,7182,2756,8139,9533,9157,7242,5332,3004,-981,4903,4566,3628,1918,8215,7867,7526,2573,669,4281,7733,2792,3719,8196,2938,2019,8079,1141,6753,9759,1658,186,-964,-833,6509,-969,1410,9007,8540,9516,6882,340,5902,342,5076,7880,9291,738,-525,1284,2394,3823,2211,5000,1986,7863,-315,9879,4622,9176,3641,4866,-855,3088,3683,6176,7281,6840,6944,8560,-721,6058,5430,9766,2094,9543,8810,6560,2047,196,4418,3443,7412,8056,7437,7977,9280,4555,3843,1035,900,1803,8922,1520,535,9356,-508,-654,5410,2908,-463,3107,8264,6616,-284,1561,4854,3327,7320,6067,2063,5277,4108,4023,6248,9429,286,6885,3172,5351,8136,7960,7401,-710,6945,6193,5127,9132,2503,6592,6030,6589,9129,3068,739,7546,2573,8343,139,5910,2703,827,7090,1360,2740,89,1231,4186,3230,4966,6090,152,9687,1834,5398,3941,7624,2613,6621,-632,7150,5864,3566,9413,7621,1504,6956,4931,9331,1576,-837,1262,4530,3875,563,-432,4218,5105,1196,4047,4605,-897,2581,5097,7341,165,4068,-654,1484,6661,6885,9623,-385,-85,5236,6043,-513,9447,1230,9282,2831,2767,6786,2047,1169,1167,103,4295,9937,5521,2379,9105,1754,6069,4635,2995,-712,-103,3816,5525,2034,1199,-400,8663,345,8080,6163,859,-22,-814,622,612,8529,5280,1583,428,2391,3196,9058,3973,857,6801,528,148,5659,1813,6790,3694,4573,4765,3003,-678,64,6239,7676,4888,-425,9981,6328,5146,2862,2449,-517,-682,6994,6501,1948,7882,9619,6569,6585,-992,1734,2417,6409,4538,4081,9561,599,7472,9033,8048,9639,8218,5197,1011,3340,13,4552,1303,6109,-318,4209,8766,-804,2357,1248,2630,8847,5680,1901,8689,3736,8679,6299,2344,9242,9551,9434,3384,-58,8626,8890,2825,237,2551,8707,1060,6102,7057,4682,3098,2463,2912,3191,5853,7269,5811,1885,1400,7126,3413,4881,6936,7629,8651,1003,2087,1317,1136,7914,3370,8854,5717,3933,9225,8425,4314,-867,7175,8187,2442,8778,787,574,-124,5934,9037,2919,278,9616,2577,9058,1199,2105,3820,7592,4061,9723,9083,1644,2201,216,7158,1300,1485,2438,6431,3945,9539,8608,9383,4757,1675,3448,3436,6238,7946,-369,-693,1382,9774}, []int{12469,6652,8255,3153,19990,8137,20644,3549,10075,13807,1604,20669,13697,7455,15314,4335,2013,14163,21393,12452,21732,16930,1605,8114,7629,14082,4288,7385,1029,16557,17132,15143,2732,13546,508,5711,12651,4021,19587,18621,4702,8842,13949,7863,14290,1450,7266,2219,5924,18054,17360,13882,16635,17971,1681,16217,9992,14529,2396,5283,6230,20618,1413,18319,18520,12576,18144,4197,20959,7445,18395,13352,3579,8441,18367,20131,18329,11439,16227,17599,13338,17833,18169,3926,215,1164,9428,11478,6926,18122,19092,2714,3059,10814,6327,10920,2148,6280,5947,20298,20911,2820,2915,13444,17196,3756,18974,7812,3521,9534,17839,9369,6816,13644,10174,17777,17992,12806,13130,17179,15742,5176,15916,1694,21332,11233,16862,21879,16489,831,3242,14954,20552,11053,14006,14581,6890,15433,533,5944,16728,21302,13081,7464,5531,12390,9138,10659,20787,10653,5408,5159,21194,4987,1047,11590,12839,10336,297,9718,8736,19130,17697,6628,17489,20678,21715,18252,15570,793,13231,13583,7273,16067,13995,1367,19207,5667,793,9089,2417,2857,4896,19095,13333,36,4837,18088,16059,14523,710,8289,20165,11147,7168,17089,17873,3717,13442,4828,18926,2671,17609,20316,15570,4493,15805,6773,13742,4039,13898,2702,2621,36,9094,3960,17236,18843,15185,21214,14978,9799,2964,4738,2239,9360,34,13972,5805,2145,11504,21713,8223,15577,5680,11393,8160,11230,6494,860,15660,19853,20337,1481,10650,12556,4373,996,17625,10529,9043,3057,5483,14597,20646,19688,1260,10941,1171,4593,18647,5214,11873,17165,15274,5103,14304,6670,16306,20783,16341,15050,10091,15566,16726,3250,15877,17800,11888,6475,17730,16691,15865,13778,4690,21421,18356,0,11624,7022,15894,3862,6395,20148,14031,12828,10682,20723,19995,1651,12003,17096,7614,14277,16181,65,12680,10648,4564,15175,15984,739,10697,17133,6250,9859,15703,11365,7008,4746,14358,7561,12319,13918,10301,4728,21357,6800,21644,18040,4113,12324,4875,11794,4398,15496,15946,2464,17812,5515,16984,17964,19380,9367,6094,18619,9788,8574,18239,10573,3810,15925,11723,5592,9329,21385,6252,15466,10321,933,17298,8164,20009,7670,20206,8310,2904,6921,19218,2822,12350,15511,2843,17011,2847,14889,7440,555,10416,20184,14284,5405,16800,12821,12906,6638,6327,13565,9345,5315,15266,136,12122,6922,9449,6093,2263,3073,9905,11335,3784,2971,16966,7877,6514,223,15250,18437,14140,5947,4946,17205,21361,8039,10497,4585,13344,5014,15061,15749,20218,7857,762,5711,17435,1220,9412,40,20197,371,9221,4625,13693,6160,14262,3067,13101,20813,8525,16478,11390,9410,18995,8399,13686,11214,13061,522,14362,328,15805,8936,11250,1373,7919,8622,1563,21048,21316,13611,4791,6817,342,20264,626,18888,4582,2882,2413,14171,13891,8611,10600,6165,11670,11436,19706,11667,10737,19808,2290,6300,4006,14064,6955,10000,4745,2154,8802,17528,2892,5493,5910,19246,10991,5790,11003,12651,6301,5537,18125,17188,684,8456,12385,18440,4840,13026,10423,5840,8867,6722,15103,8786,11953,7938,13995,16570,17366,6391,13749,8623,15615,6836,20410,16618,10002,14350,6005,4006,4176,7487,18144,2101,12310,18396,5770,7910,13010,11064,7233,11816,14324,12229,5331,13678,3350,21400,15855,11477,19540,6101,20857,18771,2930,10361,2562,5576,3092,18957,13230,18147,9923,4718,80,1184,20929,13705,4288,21379,2446,12569,15571,8763,5946,2628,5931,7870,4778,8426,9225,10211,13998,7718,17062,14459,19262,12596,17416,7651,20419,12065,18786,18117,17475,19909,18050,850,5207,17798,6902,11604,860,11786,618,9841,9135,7519,19398,6980,12252,18612,2651,753,16374,5442,7174,16071,17754,18346,11854,10849,11179,15595,4217,210,6099,20028,8229,12640,255,15947,20816,14200,2804,13037,11184,3212,15868,13960,14340,15845,12882,3985,7737,17758,2544,127,5995,15384,16593,1437,5363,7703,3526,5292,990,21312,2868,7507,17276,14224,14610,11128,20949,8451,13717,1007,17408,7666,14047,18188,19158,5174,7203,77,19137,5863,19673,15021,1250,6575,5040,16815,3230,7435,6895,17460,264,16109,2000,6957,387,19744,8849,10659,6854,2272,13991,10145,16710,17723,17824,7893,6644,8694,3059,14283,12132,10239,1876,17805,19129,10873,17834,9883,2806,12582,12672,16769,19629,19299,16484,6592,824,16773,10208,6250,5821,10127,8775,14493,14018,11096,8963,1319,12771,21141,10298,5387,5544,4951,19823,12845,8202,1520,7230,1720,19240,18216,7427,6581,15921,6809,12815,10307,1356,6658,19689,16941,6159,18100,9402,3442,15345,4947,20734,20822,13056,14549,13420,1031,10692,6907,10860,13146,5876,3961,13014,10044,7921,12540,9854,14651,2708,1505,13014,1409,15065,15516,383,1230,10628,3818,15646,7340,7326,12175,10167,14231,8598,2939,12433,3154,15028,3435,1837,10065,13975,16208,18093,9274,6406,20058,6491,15341,9863,6193,21082,4056,10783,10891,13057,20469,9961,17683,3332,12075,13521,7174,2684,10026,8565,9211,20361,9271,15646,15254,20314,21056,19950,2575,21075,13848,4208,11120,20475,2159,16133,10287,3592,15275,6311,6680,11917,19510,15353,20485,17837,16503,135,8186,14636,4130,10230,17674,9282,12111,8785,14073,16365,9701,5071,13646,21135,10587,19679,12239,13192,16207,2206,19942,17440,15576,10983,3327,15669,6877,15084,4110,17735,2882,19804,6587,819,11013,18247,12661,17566,13669,11089,9181,14693,508,3938,1761,5232,15218,13755,6757,18561,21089,14964,587,6458,11900,16649,5802,18292,17431,10237,14036,153,1730,555,20825,12379,10372,11410,4665,20608,9973,13962,14158,8854,6671,8679,13080,5843,18619,18091,10798,15991,12171,4768,12181,12979,20182,1272,1360,19338,18400,13673,15941,19780,19295,6506,9249,14117,16638,1651,935,10413,847,11713,8243,13609,11163,11040,17187,5451,14698,11397,17477,14147,7512,20546,18763,17338,19781,19916,5741,2305,14118,1664,14029,1198,13360,11276,4130,3776,3345,11667,6849,18204,11139,2335,13057,10603,8777,18476,19503,14610,653,9284,4417,1897,9054,6305,4153,16421,20936,16027,2941,2058,4082,16590,7315,9167,13029,2381,11705,16930,1550,12382,20173,11955,5766,2611,10946,4338,6109,5111,14891,2158,8863,2401,9201,4543,20910,18262,8215,5676,6597,20920,8725,17922,9262,632,5497,10560,12328,18207,19270,19762,14352,9081,6623,4305,13404,18586,6516,327,4372,15091,9874,5178,20733,14715,18975,1055,17361,19607,1764,17476,12390,10147,18078,306,6379,15944,4514,5049,9456,8282,4765,13380,8517,16483,19467,20295,13216,10461,13831,13249,15004,930,19919,16104,12551,8013,19679,5316,12900,1912,7422,19787,7351,6767,19959,2651,3897,7025,17484,6193,19733,9107,19337,14245,11858,16534,9208,12804,20661,8840,8851,17985,1820,12535,12189,9497,19201,8615,1984,14700,13298,14012,13666,17168,13473,8698,20250,14433,1825,10260,19863,5108,9397,20844,7281,15838,6035,14414,10756,13740,9041,12900,2420,5305,11223,13585,17017,14451,4227,8905,3190,2246,7991,19940,19328,8984,5401,5907,514,16318,18258,2532,11714,966,8960,17998,2646,1389,13757,8300,16071,17571,14023,6875,960,20195,6169,5980,8241,19736,5692,10973,8808,17807,12932,16274,4865,7624,13812,12022,18441,14742,3065,939,12819,13573,8507,11816,19611,15341,14284,4060,18037,12237,11835,14187,14311,10301,2850,2919,8961,4734,15616,20525,5548,5800,150,9439,13380,12713,2627,4266,17014,1000,6309,11328,10236,5645,10050,15155,6136,14575,11664,17323,12698,19093,9973,5049,18785,0,18858,14710,8727,9082,8059,10447,5798,15045,14481,216,20728,6407,575,3676,18265,3674,16485,8601,17843,12795,11254,1074,8187,3028,18944,1901,11645,3879,18332,16848,599,114,9470,15264,501,17385,571,19908,5099,4646,10113,424,18150,7134,2211,20578,2544,3058,83,13636,10760,10611,10257,12795,18589,15715,6223,18978,7695,17657,5317,7724,12018,10990,11044,16731,11337,15669,4966,12946,9238,7928,15945,10285,12230,12540,14687,500,2598,7641,18458,8326,2362,17671,19762,11123,17743,19627,17123,14684,6941,17716,2413,5652,872,19397,13692,3865,1947,5354,4058,19938,13000,4287,12492,7883,18069,3911,15788,8473,1891,2094,2475,7500,4916,16485,11869,10274,1581,11217,11782,6843,8509,6390,16951,9420,19346,4598,2985,8325,10596,4346,5693,19432,10774,4941,2265,8491,521,1777,997,13091,5803,12348,9626,12199,8031,3300,17201,15172,15774,4693,18320,7040,7615,16301,16744,2041,19196,4789,10364,4661,12318,1894,15310,11265,3763,16788,14518,15132,782,20090,11172,1134,9225,10347,18680,19849,17240,17594,8773,16470,1225,6119,2823,16697,11050,3546,1889,13367,11341,12409,806,8095,2101,3349,8768,4002,15486,10729,14193,1369,16890,1823,5198,19410,15941,4903,2451,11390,2694,18115,19450,18556,10368,14517,4190,19768,4722,2343,14344,515,3314,8576,7767,12908,975,8813,20330,16041,6482,18827,12883,15162,18699,2212,6999,4805,18215,6897,19586,12135,17799,11298,2282,19346,1070,11297,8044,13569,3472,8234,5304,5869,857,5599,5670,5632,14811,15431,7725,10731,19944,8722,7266,1650,9293,6914,3241,2164,12186,6342,6003,8955,17233,5903,8080,9717,10423,12627,3939,822,11314,7734,17837,1437,12498,15021,15905,266,9265,14073,13179,1746,15925,19306,463,5687,18384,6647,9615,6744,5019,15973,2385,11169,13990,5846,14583,10014,20410,508,12656,7223,27,11193,16872,20214,8338,8632,10089,13224,17967,10321,2861,4589,3121,1780,4582,3879,4670,2466,3700,17121,11146,8240,16397,1623,1922,19622,18827,1853,3021,20094,13186,5984,14628,5555,13912,10623,13519,10388,11241,12139,6390,7917,12295,9404,14838,11512,1077,8742,19747,17841,10695,5704,6119,17782,16519,11945,6411,8568,17061,19234,15608,17751,9665,13011,14553,15316,13093,4574,11790,9746,2361,15081,18585,3301,7731,8949,3947,11688,14049,15450,17088,3706,5318,982,1725,15769,20092,7061,5922,285,17729,5709,16051,6641,17922,1389,2086,19232,12079,13280,10332,9073,9217,8538,11950,7435,8406,16431,496,16048,11060,3027,12279,6586,9556,8989,17609,16625,4352,16298,8675,16391,17709,3055,5186,13013,5295,9831,5863,17992,2242,10404,13915,18086,13289,10994,11711,10851,7844,7049,11566,5849,10859,17025,10621,11676,18021,2680,13747,5420,206,17463,11819,12629,975,13554,15739,11487,4631,10040,16913,17001,1442,10084,2940,9777,17180,2465,8933,20084,10345,12916,17004,13625,4565,1149,18803,2894,798,13413,19662,3894,2620,9784,18588,11540,10877,14673,18711,17100,7320,4243,11999,13214,7003,6789,15464,4153,12868,7883,11981,398,4060,16588,18028,7446,15150,14770,1306,1389,4466,19205,17844,4230,10815,17805,19301,3972,332,222,16682,17611,16577,13880,18088,12668,2174,7936,12232,12022,10176,13486,4886,9030,15314,19945,10184,15935,19553,13137,10206,5145,3592,9121,3508,18151,13161,17465,5995,16575,8513,17891,3672,9250,9091,19895,8642,2619,12942,5277,13699,13081,9681,16715,5206,4785,18935,16667,6587,14046,15825,9479,14813,7375,5453,9892,12814,16181,16227,13030,8615,3762,15592,7656,16379,18956,14849,365,12415,13572,18852,16431,19526,2701,15683,13458,10764,16770,20103,1502,13456,9054,12847,13166,4519,18141,7965,9159,14987,10867,12576,15018,4734,6877,15842,6463,1436,7930,9597,18562,17554,5300,14136,1135,19424,9260,8385,18437,2659,13987,8068,9691,6780,19628,17087,3662,7243,15407,2366,9765,15713,18610,4970,2376,13903,13253,5437,8230,9749,3404,11956,1044,14441,6142,11804,17627,5033,11444,1641,8926,11466,4702,11522,17008,19450,8354,19337,9977,5040,18421,20080,9976,16243,15209,18003,11755,19465,17720,15257,9885,3004,5312,759,4686,15432,15768,8426,4603,5389,14957,10932,13869,5218,9994,11086,14868,17504,2507,18338,15785,18058,19912,6618,14246,7432,3359,11589,7559,13737,11806,9143,7115,8889,19622,5140,7366,4878,17353,19733,19341,17599,19548,19427,4363,2918,10040,3148,243,12216,12054,6217,5063,14679,13464,5218,18957,4151,685,14776,8989,14664,1649,1879,1419,14213,13739,12125,5369,15679,939,1450,18653,1325,10092,10659,3212,9194,8142,9309,135,18155,19806,8128,16749,15057,12878,5044,9762,4744,18852,2695,1022,1485,10016,2456,13736,10205,15980,8736,9813,16794,14475,3905,14308,1637,9086,3700,9562,2810,2967,9707,5222,16547,2980,9287,11199,19679,3509,19248,19577,15755,7468,2108,14348,12674,3326,6147,12520,5885,142,8718,13513,1638,14008,9440,19427,2454,4601,18720,4568,3115,14674,13218,16528,1201,19538,11199,3268,17163,16594,8632,15702,12155,2501,3731,9735,17548,18791,10338,2401,14384,1729,10048,9864,14381,17801,6268,2194,13520,9838,264,12323,10466,15821,7980,14434,1178,12227,12890,8937,4761,18787,7670,13459,6096,5979,8685,4893,9702,5246,12268,16329,12760,16676,10831,1096,4010,19854,4808,16418,10157,9352,15635,12643,1910,8247,5789,10726,13007,19142,9986,13391,19753,747,9129,17358,8444,169,7884,16632,11064,9448,6992,14827,4002,4782,17933,11821,15841,3271,2866,19722,8849,427,17418,6261,1254,19382,852,2364,9557,9439,14161,15766,4270,12891,5046,14370,8584,11221,3080,1038,2754,15012,6809,10773,5488,4764,10079,8057,1923,630,3625,4981,5005,12636,1503,6839,15569,126,10758,415,15089,1931,16304,16374,3778,6760,12707,19517,12873,6425,12626,501,3476,1405,13081,4411,2493,3439,2304,7498,17402,1151,12090,4073,3058,18480,11856,10045,10289,6687,3591,16741,13582,2418,12561,19769,17348,9423,11638,9,3903,6958,6838,8664,1829,5681,6191,16574,13007,10790,19322,1661,1103,12765,2738,12056,17270,101,10294,5060,19495,1396,15772,9455,17319,4883,6307,11964,15920,8924,4826,3812,16186,12215,14390,2371,15541,273,8677,3045,498,18107,8130,11621,4607,4077,14096,15217,6609,4781,15430,4860,10982,16837,6035,3931,216,6302,10226,3480,9684,3337,1332,3177,3903,13754,16998,15060,14158,15786,4182,15985,9612,7007,6974,4502,2435,9672,2593,19329,4277,15576,3079,10008,10423,4555,3547,3497,13876,1028,2925,15424,17183,11880,1606,17470,19537,1342,16377,8389,8466,13953,19411,16612,6074,4680,13666,15209,11515,2504,4261,15162,12855,10739,1774,4450,17479,9633,16852,323,11168,3440,14137,14514,12720,3817,4313,10099,8887,3809,6360,16382,151,13384,3049,7175,16787,3189,16684,4952,4234,11527,18441,12447,15324,5464,11370,11599,15384,1766,4551,3673,5715,1942,14131,13180,1614,19116,5356,868,1225,18684,9542,10671,10277,7618,6062,16848,7849,4308,16242,2855,19299,6086,16212,4602,2701,9626,10014,19143,15202,7481,8387,7337,3487,2809,8399,2568,7305,7884,17829,1316,16113,13406,11087,7967,8115,16066,13389,12413,14393,17865,8786,17498,6707,14060,11868,2655,4655,9992,305,10887,3693,4453,18003,16996,1416,16171,4356,5740,4988,10959,16507,6686,11028,8056,13541,3452,11885,8933,6790,4174,16358,15889,4184,9361,3674,1095,18188,289,2677,13523,800,15920,173,4519,17348,14855,7989,11676,2151,6330,17422,1840,10823,19353,655,4561,14172,14393,11120,890,5382,9637,9892,14205,16610,10561,14411,2900,14663,12792,3409,12905,5948,2792,8550,10565,11587,4954,12218,2447,11232,11442,10771,13093,8298,13198,10626,1280,10848,9839,8816,5018,17557,2400,10594,18742,17390,10148,8534,18488,9863,7788,19459,11753,13630,17814,8543,5098,16505,18700,16642,2445,17452,14727,285,16261,1432,6648,12720,15320,7898,5969,2290,8958,14359,16259,6013,2939,4695,5353,4212,19338,15513,698,9439,19049,8368,4134,8730,14661,3313,1738,4809,1155,18940,11444,16753,7369,7270,15629,2934,14026,10346,10144,6562,11303,6862,5333,8039,8969,3048,13723,11461,10296,5876,4155,14133,4970,18860,3872,15408,1520,19320,12121,3341,10010,12956,14087,5411,11139,832,12239,809,11024,4694,8578,5534,6594,10882,12575,16807,19279,13727,15132,7350,8240,5179,18633,18306,11662,6220,18380,17883,16214,1955,1863,7542,11713,14862,9898,7492,18950,15963,4076,5576,13907,2280,5542,1765,4765,12681,13432,2174,4255,11852,6329,873,15230,11795,7010,12714,5356,7121,12876,979,219,4746,3930,5480,5504,14643,6946,8305,6041,12034,12456,11525,12917,16684,557,712,6985,4307,9217,13920,11565,9881,15789,11537,99,8272,10798,11935,2523,10266,13590,11496,17522,14994,8432,18864,14701,9338,2037,6535,7867,16180,19107,18647,4814,11491,14299,17710,9892,1534,7052,14005,16409,4317,3410,13333,18726,3630,6469,10419,6308,2378,18496,11753,17782,14408,2049,7254,12272,10835,1976,1232,16569,15568,5211,596,6568,17807,3093,8850,18182,8087,5637,16339,15532,3528,7182,16514,12254,6156,6324,18161,7173,16142,4323,9348,13823,12905,686,7092,9517,13885,9923,1802,10308,10067,17818,12813,18914,4259,9830,7157,8096,3252,13945,913,11509,13253,3154,11131,3779,17034,12083,8668,11525,13159,8137,5017,631,18192,6857,4560,1641,3305,3189,6793,825,18757,11665,10768,18655,8776,7031,9912,16071,13848,3219,14117,17262,4390,13444,10619,10117,5788,14580,13246,16391,5806,3558,8480,4695,297,4515,9650,3682,16475,4844,18032,579,13995,14890,3332,4748,5295,10569,14753,15380,19110,4351,17429,6301,18857,8840,3615,10625,9772,9682,1567,7561,11792,13700,8480,1807,14767,13558,17860,1051,11009,9820,13389,5960,9417,15566,15200,10171,7428,1869,5989,6951,15270,6799,5413,18380,1064,14509,8095,2628,17033,7764,16846,14658,502,5628,15120,5700,1901,8130,8013,12482,2174,10836,14860,10478,9445,18250,15728,5998,18523,4113,15452,6759,18347,15905,16641,14748,13871,3612,7144,12520,18368,1262,4352,4064,10337,5335,14885,467,3987,10497,5442,16361,1396,1321,8330,4265,13244,10616,18835,15536,16807,11904,8900,18254,15284,7333,1703,10154,17511,11139,5095,2464,1501,12505,17904,3399,14599,7706,7449,14901,2165,1101,14912,198,11386,7833,18876,16015,18104,5252,4360,7507,6612,16859,11811,13101,16553,15517,6530,10260,17461,16026,170,10355,10430,1912,9303,2336,12144,17830,8831,17933,14121,824,5845,572,13974,17359,4945,6591,10556,7030,3828,9807,6211,11386,16707,15775,2113,7671,13532,13370,7105,17777,1192,12102,9354,9710,17702,1401,14765,17041,13211,14567,17536,18316,4479,8445,5209,101,4342,2164,6316,14765,5462,7296,18283,7680,2407,5976,7020,6697,10963,18333,1249,444,745,8778,18823,11428,4871,7772,15468,3370,13050,11493,17741,15657,10029,12858,820,12575,15500,2621,17898,6790,12328,10496,1480,11303,16833,10413,5814,9124,12310,10948,5386,3374,16349,16195,1677,16801,15875,10539,14703,13452,829,7209,9760,13663,16191,12824,16597,8452,2987,1329,8807,17143,2266,5098,2352,3773,7922,16773,10302,2481,7224,16116,8420,5779,11825,8372,2723,10236,14913,13351,3734,18548,14448,18255,1856,18861,17911,517,5273,13595,13454,12413,9859,1549,6105,1701,2346,9880,17351,1417,16708,14155,4712,17251,772,13226,2105,14950,9706,7356,606,16772,17774,13234,13317,7781,11728,7873,2272,5408,3541,18321,7038,1476,11811,15638,6133,1993,4973,2059,3639,1391,7092,7039,14936,7565,4260,256,2948,5107,12584,15168,3186,1788,15893,7786,12814,18510,1062,6828,7696,8797,6793,3700,6917,4112,13197,8735,9365,18088,16947,7892,17359,3315,2529,848,3492,6172,1763,6906,6575,8290,7674,4151,15884,10998,3678,16214,14966,1193,14111,12317,10786,1984,9631,1698,5886,10076,11907,991,13752,6908,7740,8638,8455,309,7757,8655,933,17430,12674,18514,12527,197,10847,4912,2832,9206,6837,11147,14663,5696,13295,13766,15399,16792,18705,15998,11427,15146,4058,9542,4311,16601,10482,10461,4698,10199,5608,12255,120,17135,8294,4697,1830,7171,18327,6214,4681,2194,11475,11888,16955,1631,12269,13986,12271,11531,16915,1913,15859,5507,18275,158,370,181,3766,2313,1078,3523,8849,16013,4121,3165,13811,14885,3298,15303,17655,11387,2043,16862,13134,2779,8878,12378,6985,6001,3898,12389,4432,7687,1270,7498,13579,4417,18475,4954,4043,901,16426,15375,9422,8854,3279,9046,7025,7240,12557,5310,6063,17699,249,16993,12665,15534,14714,16646,6664,6643,14952,2607,12638,1561,761,3435,16871,16275,3623,8366,17497,12420,8532,3780,3696,1472,8117,17068,10612,7409,12144,9508,13375,14207,15907,15495,4792,13075,10889,14214,198,12765,10306,7443,2944,14083,276,2555,8983,14671,2815,3189,6609,9050,16978,4686,15672,17075,16445,18313,3485,3021,5081,4106,18576,7611,13239,12718,16395,17101,9695,16157,12648,798,13125,15250,13551,3150,2911,14598,9200,7730,15463,5725,1806,15213,13574,4358,6580,16610,641,6195,2428,15496,17571,11886,11767,1013,1199,9241,3694,1897,12883,1653,6216,4583,14741,17882,2445,15154,3687,10669,15200,5208,13831,17133,14659,10111,8815,13535,5035,7185,1106,6205,217,17223,3804,561,12185,3375,3022,5790,10699,10325,10415,8895,16497,5400,15263,11229,10559,6866,26,9839,16198,3552,3273,16636,2,3848,8610,7575,1677,8995,8065,6392,14347,11859,6136,15934,15918,12832,15985,4664,9492,7740,14857,3627,18439,14040,106,540,15732,14254,9700,9106,12042,13824,13339,9820,3317,17622,1369,14213,1923,3400,16389,16347,16670,9440,13173,12656,6392,13277,16241,8194,14323,4178,12206,9732,17188,5965,17659,11119,7936,12510,18458,4034,4727,6740,7722,16199,3162,1270,11051,2980,14945,10194,12193,15574,11021,17355,4963,12263,7305,3989,2760,2727,11308,9457,13985,7903,10835,13498,962,1873,11692,15386,15557,2590,12277,13026,14612,18351,1444,7929,3767,320,10862,18058,1159,6978,13706,17482,13352,11327,17307,10943,4988,3564,15359,6391,7732,1464,12412,15916,13559,2576,11266,18300,9073,9179,7366,5289,17057,17218,3216,7254,14924,3918,4225,17934,3530,9878,15687,77,222,10398,15638,6063,16799,13071,8138,9650,9598,13217,16403,10398,3873,16371,7526,1940,5779,13845,14272,5380,2903,11716,8230,10593,12907,2170,3402,14772,9305,701,4177,15351,6719,9585,8389,10674,18234,15756,11885,8288,11460,9397,12000,12204,16406,12632,11969,9774,4002,711,13096,6234,5342,10914,9267,11786,10973,12959,14874,9947,11260,14353,2445,14632,11870,7834,11991,2368,9574,12932,16774,11437,1865,7648,2970,7348,12731,3266,4267,1049,10050,18250,7711,1891,7790,13537,7558,4452,11853,16286,13598,6261,2477,10340,1718,7041,6144,2908,3300,12799,6296,8259,10971,7049,16806,1660,13377,12967,1654,9821,11702,7221,612,8708,10823,2270,2477,4598,16599,5737,17434,11596,5325,18182,16841,7406,14011,9762,10870,12951,14300,15782,10615,13213,6220,16860,11518,4395,11022,12200,670,741,12409,6634,14500,5769,10297,929,1800,5848,1115,18188,7780,17928,6583,12230,10755,6523,3851,11571,12246,5648,6171,3626,2264,15794,1823,14537,18101,8072,9933,16511,1619,10434,14356,16302,8023,9896,12576,8136,9756,4652,11521,9867,10077,2766,4977,1988,16749,7457,8146,12885,3340,17258,6333,18104,11709,5505,14781,14591,10056,17157,3962,253,10719,14761,13193,12622,14306,18113,1943,365,11598,5365,7122,10877,1838,15539,10067,160,13622,16324,4066,12212,12132,12278,10875,3354,2916,12900,16611,5376,9951,1316,15109,4898,10402,17779,11559,13014,2915,9813,8055,7572,608,327,7920,6456,5649,15598,16754,3642,17872,2158,8858,10860,2061,15211,5646,476,14704,17594,15398,16448,6089,17986,8863,11024,4028,5125,14736,8293,25,8161,16126,17120,3835,1533,3025,5358,6024,12049,16924,7262,16838,7451,15379,5192,13040,9210,11219,8626,5197,12519,4552,25,10951,4657,320,2925,15586,7773,6779,15291,1448,14158,1916,152,8789,14932,6693,17597,13391,760,1865,7576,483,11013,14067,11287,1345,12692,14050,5240,5015,3199,12305,13112,7757,3185,17409,13991,5481,1754,10268,12368,6487,476,5320,3123,13825,7849,10292,10327,11551,9754,16467,14215,7179,8679,15706,7829,10222,4001,12228,16803,1296,16598,3001,3126,16403,540,2581,14299,12946,13854,547,2589,7301,13801,9861,9684,3945,11482,11559,17724,2441,2895,6217,17635,1851,4817,3253,134,15531,9853,15640,16133,17060,7718,6434,2563,5819,6636,15105,9631,10893,6262,10808,14437,16659,13669,10363,7177,16589,4265,2252,17250,13610,4672,16652,12053,4317,9564,14441,6727,12112,11682,4638,17399,10843,4697,11401,8190,13102,8821,11546,1638,16523,3683,15216,4248,11216,2979,12962,14016,10072,11327,10340,9274,7414,6978,17284,10316,15389,2893,16414,11589,17081,9947,757,9247,4088,7164,17115,3400,4464,13513,17019,7381,17267,1892,599,8064,17429,10513,6342,12709,644,5947,13204,9944,17268,10029,9242,13442,2364,16717,12928,11885,3245,1626,11444,6649,9203,4364,4873,16638,10116,11075,10014,12458,14462,9494,16447,5525,14928,11994,1647,6668,17328,9722,9328,14781,12369,16990,17434,17687,6731,9211,11519,414,15553,2624,13274,16574,980,11760,2611,14374,6019,16317,15976,6140,11171,12827,4745,3733,12624,12418,10482,15867,7510,11734,10374,8810,3161,9876,15441,13123,15840,10496,6292,16873,2202,9107,15811,11561,7450,11799,14315,12120,17721,16474,2989,6983,383,16145,1751,8049,1574,13057,11317,8672,10440,6317,16419,3983,5876,7752,8888,16694,17022,16854,8022,5445,10894,8424,8300,1807,13439,8300,8593,12110,9510,7574,12100,14314,14631,2437,8966,12686,14438,14317,4304,12617,17419,11742,16588,12358,8141,2482,1231,7348,4614,17403,14371,13974,9629,13989,16433,9993,13837,13231,13892,11696,5583,14916,16032,11106,13256,8461,13806,9285,11512,5995,5443,1793,10216,13204,2066,15724,2825,16307,12647,8798,6267,3872,3578,9716,16720,606,3863,15171,6416,17712,9575,6688,16368,6388,9442,14995,9667,695,12257,938,403,8357,6793,9120,9422,16488,15050,719,17626,541,11529,10782,1172,7010,7739,1180,6006,6727,9967,16206,15784,12800,15305,15450,8393,3078,13944,5506,1461,3338,12450,2948,4846,15811,15594,16266,10701,15216,7032,11107,12136,9759,10181,10234,6215,4498,10368,10970,1601,9667,1988,76,10916,13100,10252,2617,6865,9083,8819,342,542,6907,3256,5019,11637,2126,16442,6238,7643,17588,11061,13208,7136,5901,3815,12937,15368,13892,13265,4443,6359,10775,4356,1579,4437,4598,688,9421,3959,1833,10354,13398,17626,15415,14855,8225,492,7695,13427,6946,876,17315,15349,14470,5888,16856,11333,13432,12174,7288,5730,16516,5959,9330,1733,964,14590,14056,1425,10383,8474,9244,16195,3304,1917,16766,11289,4518,8961,15964,752,14530,5728,10488,146,13106,14135,8554,12306,10114,16401,1142,16579,3305,16228,9428,3729,12895,16383,14262,14334,9712,3861,3014,6550,16111,10276,15570,1722,4482,3731,10299,13707,14753,7436,3392,4283,1269,16185,5877,11546,9144,10353,1974,13886,16948,5296,16329,15228,9472,5896,8931,6381,13680,8996,13818,2161,8721,9399,15654,6291,14124,9035,11660,4193,3669,12580,9919,10199,9137,6992,2454,3247,4766,14354,8387,5106,9868,2197,4262,12181,11551,6769,1726,13996,13542,1351,14691,15848,3780,9003,13524,12650,6748,11047,5064,11824,15883,5250,14381,12516,12818,11618,1221,15531,8052,9284,12422,4734,5294,15663,13658,8586,9822,376,4001,2950,12264,8860,7451,1754,12316,1706,3798,10347,10049,6534,10586,1384,11113,15216,8060,6111,3514,15666,525,2614,5890,11620,8826,4849,12680,3171,3383,10055,9211,10295,11787,9147,8607,12188,199,32,2705,12115,7457,7855,5852,433,17298,132,8220,1400,8050,3810,4450,10817,10003,6930,1998,7657,4740,1552,7669,15282,4465,9738,10313,12841,8776,13591,14719,9213,5998,3985,14623,6705,11474,7178,10485,12024,17255,10118,14821,3523,15633,3904,11053,15426,1544,5542,2235,4244,12677,3379,3127,5441,9825,5287,4635,2988,4987,14537,8246,4699,3654,2865,6036,12326,7103,11859,13772,5146,5738,1518,12363,15428,10542,6899,988,16100,100,3358,4401,2081,12833,1959,11601,8834,15318,1399,16177,14556,991,17129,12536,5538,10374,15340,15769,2502,6696,4427,9539,16949,15130,10109,2956,13573,9021,12393,7026,4846,13884,3136,1983,856,14088,6175,7993,14136,3563,3608,3405,949,13164,11412,3453,4501,3683,11576,5489,13000,11336,2422,3814,10146,16787,1031,16293,5860,5975,3590,12150,14944,5685,3300,15352,9493,15268,5763,16599,7409,2435,12520,9056,5967,11830,3745,13135,6994,17106,6370,5059,9699,10875,5938,7510,5664,15567,15158,5164,7871,3349,11129,7255,3818,2613,2473,13815,13338,3564,16706,15886,2054,11858,2769,2406,10164,7035,11984,16670,1580,6413,12288,9647,5322,4222,887,1136,13554,13441,4646,8345,6234,10265,3437,11652,4013,7672,5664,13275,2082,11707,13891,15508,6542,8473,4767,597,9007,2478,5210,12320,7321,15307,16354,8041,9405,16931,14964,6614,7299,3973,4864,5809,3116,12351,11830,6425,4925,14365,5516,8490,11812,10426,9019,1038,1129,1990,11595,11033,1093,9094,6551,14129,13628,16371,5432,15325,14678,4946,14594,2470,12809,2122,7488,14472,13146,13621,7323,3288,9149,8171,3244,9679,7283,9606,11563,2497,13896,7386,14524,11904,14975,2681,11332,3772,3083,5336,6579,14058,14021,6980,16161,10807,12328,9578,6975,11205,2960,17065,16138,3260,9525,8980,16414,12171,7116,7414,10133,9938,14386,1660,9215,13926,2596,15954,8099,1702,3776,2923,10460,5045,9272,10693,3601,4838,15646,5183,4090,16091,2440,4696,3199,15216,1917,1369,12529,14349,14099,6220,5180,793,16095,1388,14479,3064,13880,13633,9573,6753,12021,1386,11860,13373,8014,7840,14922,8759,5751,5894,2801,12617,15015,13820,15586,14948,11271,15868,14917,1893,7969,5061,10992,4405,7755,6455,7706,13262,4876,980,5901,2038,6602,8965,9609,10514,377,4575,6919,4784,13122,27,7518,4430,15475,1207,15184,3485,1382,9504,5509,7998,16211,6536,15863,2819,3941,5004,14915,4371,11226,10008,16162,11279,9947,9325,11236,9268,1124,3953,9725,9554,5436,1317,11794,16796,687,11435,9443,4699,11232,4016,11519,11968,8054,3086,16011,8544,10456,1384,2024,1664,7262,3515,3843,16597,12205,4302,8597,6931,74,13270,12720,16001,6170,5532,6471,6694,4591,2395,16591,13844,11119,3440,10564,314,35,6259,9191,2066,9766,1249,7529,16487,14202,865,11041,3109,7705,1881,10722,10646,2910,311,10710,8816,16182,9133,15650,15151,7641,12775,15146,5081,11666,11260,4923,853,15645,2315,10145,493,5450,6377,13172,5469,2164,501,10313,14477,7508,11183,974,11707,5983,3606,13964,12626,4004,1939,15302,5750,695,11383,7626,11967,1788,9373,4779,6804,4269,10681,12409,6043,10214,16297,12914,4709,8902,9306,8871,4270,8586,11689,7662,4013,8112,10137,14752,5926,6994,3852,3014,2442,4960,11983,1644,5889,11985,14586,16712,1975,8427,14580,5058,13770,9390,5911,5141,10798,16120,7691,6044,16011,16806,11255,8611,8755,12966,4928,12139,10816,1224,5949,912,13027,6511,15894,5363,10815,10533,4861,5562,2214,16717,11750,11040,9110,14948,4819,11441,4121,15834,16686,15394,1245,4222,15826,14856,8894,7152,8108,4725,2694,7999,9295,14218,6255,868,13710,6740,11529,76,13366,11821,11514,4981,10226,11320,14575,11179,6017,7308,2088,6894,7834,460,15067,2190,15137,16541,16240,12820,13758,4819,3895,11420,15737,12934,2124,6381,10885,11482,9621,12733,15223,10577,14566,11934,16493,15426,9036,3808,1891,6159,9583,3640,898,11381,16678,8401,9897,10034,14419,6542,15508,6570,7427,2558,15576,1335,3801,2619,15122,4735,12456,15325,9384,8258,6499,9135,522,9144,27,4599,13956,6604,12931,16473,3048,3375,3666,14128,11492,7190,2262,10502,14701,16349,9380,9770,3898,55,3292,15484,7074,9013,15143,13927,14022,13657,12722,1930,198,4299,10819,13844,15915,4266,15309,15132,4757,7644,4079,1495,9304,15163,3580,16501,8121,11538,4383,15829,3947,1243,14606,6738,3216,8129,3297,9037,10476,15381,2298,746,15912,15798,8138,3130,2255,5964,16027,16399,7863,4937,5347,1053,16616,2417,13968,2531,16516,12546,4713,16609,15237,12928,12178,856,9661,2922,474,1744,14003,7398,14952,13139,1672,1889,8526,5202,3302,1070,9740,11670,11083,3498,8372,13317,1497,12421,5257,459,9577,11461,15925,1554,2531,8541,11599,5675,2273,11615,7372,12256,4798,14031,7670,1914,8217,13618,4955,15104,9715,4838,14603,14492,8832,8091,16129,11583,2155,4830,8495,11857,7204,8419,15975,7104,6498,14356,2604,8739,13457,6880,15539,10129,1328,2114,6652,1044,9888,15743,2044,6331,13600,14679,5032,5223,11467,16215,12421,687,14009,12161,9544,15441,13000,14831,16032,3566,6203,2074,4103,10226,151,15513,3117,8718,8552,5033,15476,3710,2329,5179,13919,9044,3463,5142,4347,523,9639,3683,8663,1217,4519,8989,2207,14829,1835,3621,11921,10400,9924,9446,759,3018,13258,7618,6711,12568,11850,16442,15075,7460,7433,6662,11260,11203,4135,1486,2313,3149,11684,7350,248,7090,5947,13474,5268,10922,14861,3161,576,10732,11071,2506,9788,11229,1216,14414,6522,12616,14939,13892,14629,3799,1107,7226,13931,3409,6001,13858,1038,15091,8652,11747,14014,14179,5674,6600,13121,15491,3003,10445,12173,4963,12271,328,2676,12267,1630,3365,12233,15236,8143,15084,13367,11035,10911,12413,1035,15861,11729,1519,6868,13294,1219,5622,10711,1090,12543,5695,1395,597,9602,10380,8539,4300,9749,10521,1157,10391,12000,4026,13324,3976,11843,10931,14791,12512,9494,12494,8652,1511,12578,2633,11548,2429,14821,3730,11897,7975,12339,13,5380,13693,4954,10602,15680,3906,3530,15863,6251,14705,12674,9264,11930,7090,12084,8928,10306,11726,4522,13037,16191,7995,4579,5527,10189,16270,2353,14428,5535,14603,9008,3934,8041,3527,4024,13138,8469,8956,5659,4921,6016,11713,12879,1162,194,6234,5268,8774,12084,7485,991,3215,1951,7522,278,12462,15534,15048,7236,4642,7421,14810,11740,5680,7925,15431,14828,8831,5985,11991,4900,5633,8149,5975,5695,1261,10949,4798,3917,7239,3088,12259,10402,12468,12227,15372,9637,12648,2827,4281,12505,954,16131,275,10860,9949,6827,4460,6659,12292,14954,2138,14365,5701,5436,11877,7642,13886,6261,9916,4105,8046,10063,5173,6594,7104,1253,741,188,11364,11798,9036,15147,12168,10443,15580,14859,7194,13667,12269,13496,1364,15108,7893,2965,1299,7141,14805,1423,9248,14791,4897,6816,11059,8076,5925,11092,14150,4100,11893,4000,12452,5055,5872,7022,8523,6242,2128,10429,11769,70,11050,1329,5467,7835,5274,13458,904,10862,10034,6389,3494,3787,5639,6424,7997,2107,10031,14546,10528,4782,9508,10796,11290,2015,12901,7965,7923,11977,8469,10072,7263,10871,14958,1220,10673,2848,1249,8047,13493,11167,10983,9448,9005,10712,4023,9814,1102,5118,6520,5264,13904,4585,13904,1410,11999,11393,9183,440,11240,10589,6038,10617,15665,10591,14669,495,16086,4029,15520,3691,13802,751,3562,13507,733,1429,7439,15504,14650,11107,2178,8,1855,6356,2379,3297,13456,7740,2565,12921,2995,12120,5809,735,6036,6586,1550,2064,14559,6586,14109,4264,8543,8345,4811,14976,16095,4896,1994,13177,1671,14095,15625,3183,12155,7613,11082,6890,3385,7970,14219,4197,11886,7182,5389,4339,1947,4877,14263,500,15821,8891,2687,15813,7767,1836,6065,1341,867,14200,14716,11967,15335,8802,11268,12960,8944,12406,7464,3787,266,4881,8394,6122,8253,15214,4400,7870,15477,10420,5540,12417,13409,12054,5087,5441,13696,3357,1916,2718,13130,12066,6010,10490,2111,2053,3716,831,5422,6198,14289,6037,12060,3025,13008,107,3018,13388,59,5406,11529,6991,15331,9161,3944,13554,15453,9300,2408,15192,9441,6764,11268,10433,12905,9222,4008,8645,135,81,14277,15058,12032,6742,11139,5407,6356,4482,6171,12404,11972,9887,12713,8288,14926,11572,12582,6136,11491,10237,14840,3824,2168,704,3516,11967,7361,12803,2527,8615,4253,4643,4108,14479,13168,190,7761,15162,1683,6917,8203,7146,5871,7491,4779,251,850,12482,3646,8654,15160,8307,479,2464,721,15604,547,11680,8667,5435,12611,13815,4896,14739,7049,12636,4363,11458,11448,2696,5150,3969,224,11474,2708,10656,9374,4408,15821,8546,244,6409,9630,11615,7966,9697,5842,12367,13118,15220,1890,3714,4306,13475,11731,13300,3928,9221,13949,11208,3968,5520,1297,7260,10191,10509,13108,535,11130,9633,3550,8806,5648,1785,15901,6817,5090,7563,6069,15163,7445,1311,1216,9443,2237,2520,9812,8250,8678,9847,1495,12658,6577,2384,12024,7978,5958,14944,13402,4149,8020,4575,11780,3614,12436,10796,11607,13161,4828,15132,4886,10582,13157,5572,5382,3485,187,8085,1330,9380,11837,12135,15556,7623,12772,6581,6094,8280,5186,10706,1996,7948,8009,6776,10601,15739,3370,15143,8310,2282,4027,12678,10452,10194,14160,11119,6160,4401,6573,12582,2477,6910,15409,6742,14815,4764,6360,5622,6584,303,6714,4866,5348,4528,14774,13677,3495,15156,12436,8111,12769,13790,1766,13921,13069,6269,5700,6039,6661,6785,1719,7743,15055,6868,10056,2867,7308,4625,4453,7817,12522,9254,9823,2632,2988,13733,12308,769,2296,10710,15200,9596,3174,7042,7811,3558,13897,9853,1196,11422,12484,2478,1840,11536,1563,9649,2323,3532,7420,13863,7178,7559,14921,4399,11612,7425,4347,4197,15562,1134,4314,3433,11358,5822,1110,8603,12538,13363,15371,14298,11158,8980,10836,6902,1518,5859,13210,15321,11660,2698,8400,9794,3612,9460,8743,7752,13808,10444,15448,5564,5471,5207,11668,5165,4507,1690,11201,4901,8079,10886,10012,4116,11258,7294,5766,15332,3730,131,9208,11855,12109,1030,2455,6466,10795,3975,7134,12323,2733,14056,7240,3416,3898,953,11966,11300,2865,5992,15353,5420,7941,6839,6068,13458,13458,4289,7217,9323,2757,14121,9086,12876,4508,6027,10594,4988,13696,4644,14086,2094,13341,13536,7817,14566,12771,12579,1725,12557,3616,9811,5914,5354,14061,11520,15193,2871,13753,2877,11969,11307,3129,631,3821,10344,1381,1898,8131,9239,9528,10354,8342,9267,8874,15266,1514,14988,15013,8806,7135,3912,15353,692,9436,3341,7582,11286,1482,11382,3024,14433,3452,38,742,15170,7898,6945,14219,14420,3943,8635,6295,3779,403,387,15257,1064,15107,7428,6932,3073,11261,5727,7391,7992,5903,13471,14075,2748,342,344,14413,8453,5368,5947,3090,5425,4803,209,12157,1077,12240,5868,14772,14583,14791,9439,11531,12419,10112,11281,14795,1275,14616,4155,2476,5170,1071,5631,1029,10323,10930,226,13847,1591,6731,1210,3765,2196,15056,8610,10273,779,1298,1428,12509,10382,10868,4903,2953,13247,8006,12562,2666,146,5975,3387,10345,8174,5617,12793,7923,2840,3436,11862,11773,12278,2372,13789,3778,1160,7995,14356,6924,13999,3558,8180,11425,3925,551,1805,9763,9767,2015,2465,3492,7455,8158,3816,9462,457,10035,102,6126,10216,14209,6286,13453,9785,6517,15505,14620,9812,1575,10536,13037,11090,7254,10199,9977,13431,12114,15424,12196,2047,14811,9382,11801,5208,1699,8936,1475,12619,9223,10135,14423,7497,4569,9786,14057,13338,13474,15063,4047,6781,2194,7296,14619,4987,14593,12129,8185,3999,1777,7156,4668,14763,1484,3119,8211,14279,8787,10153,10914,9731,5059,6696,4134,5208,2309,4445,13281,10744,13811,10442,4365,6689,802,512,9652,14699,6021,11086,15191,12204,11492,8958,2432,2701,6362,6424,7333,4694,81,5116,14452,9596,14157,15388,12982,10626,9041,5178,13021,5064,9464,1965,12107,5875,747,1465,2975,8619,8991,4950,11556,10663,7053,13096,9975,4602,11153,9155,8346,6925,15350,3204,11390,5449,6048,11781,12860,12549,15197,1999,9305,1612,3026,8361,5735,11735,10821,1596,14692,3565,1974,12787,9135,9109,12569,2655,14483,2305,5893,14246,10174,1258,3056,408,13971,10396,11002,7183,8859,9422,14052,9110,3673,14758,1899,9155,14039,13065,14622,1684,8364,2419,9071,14443,7040,7414,4986,14763,11911,12297,8334,10974,9621,8485,14316,12216,7213,8434,8696,2126,1454,11061,27,6093,354,1623,2813,4309,2945,13723,2904,3946,9848,4043,2177,12325,12710,12060,8520,7676,626,5098,5924,9422,1773,8000,8244,5595,1663,9335,2271,11193,9834,3630,8712,4502,13665,3243,5067,9477,12517,12171,5407,2346,596,7191,1209,8529,5294,7818,10660,7393,4175,3449,5763,14361,11054,14478,8565,5174,14459,5611,5400,11448,10294,14302,1019,1809,6272,11680,8694,4992,5364,9053,9086,11551,6650,14090,536,13467,11035,11327,2639,15056,11156,6664,1511,7976,13242,452,9757,509,9553,8448,9033,14664,653,12768,5231,11879,7682,6141,2044,25,9083,12151,10816,1373,682,13682,8398,9207,11998,14918,907,11428,12445,7421,14765,1208,7301,4244,1853,1318,5968,8160,191,14081,8269,942,11987,543,12232,12303,10944,12894,8644,15085,272,12332,11119,10727,8568,9411,13430,11729,9136,3756,168,3272,8866,3513,13546,2081,5650,3538,6331,3475,9538,3951,4801,3295,241,4815,8795,11679,6520,2493,13244,14343,4076,7239,13679,4683,84,8182,8560,14512,10650,4503,9216,9214,13893,15069,7283,6138,4474,1392,6184,3087,2010,8599,3354,2155,6800,6000,7162,7537,5177,4981,1143,11410,11961,8524,6608,8877,9650,2897,3899,282,1760,4070,5858,7969,10168,6252,12457,14166,3219,11753,7531,10086,3274,7797,4514,14624,5352,9442,3322,12557,6163,4867,13492,7494,8705,12889,3280,2544,5517,2784,4654,3081,4442,53,14831,491,14521,9244,6910,5335,797,10481,1329,14299,6709,10211,5790,7211,8267,8825,7945,575,5079,2758,12695,1708,3916,656,1651,5666,6809,14043,3968,3415,3964,12030,11806,11693,14452,8983,9712,1942,5293,1133,3204,5198,4282,11932,12392,611,4815,2570,11336,3875,4212,9227,9692,10551,13878,3649,6801,2681,10804,11122,10926,11682,6557,6115,14568,2374,11717,6265,7457,2843,2165,7067,11239,7465,13279,1827,13863,9138,6446,11381,787,10806,6569,12032,1800,12356,5629,548,9269,11212,8083,13626,12351,2839,5882,10120,3558,3393,8784,9033,6919,12513,5614,7037,13599,14241,6958,1399,12536,2231,12332,14574,14226,9142,11096,7391,11402,9383,8293,9556,2347,5765,314,13247,8704,5154,13777,2414,10416,7324,10508,2905,1357,13734,13840,12623,5768,4024,4397,1285,1774,6579,9345,2597,296,4784,7671,6671,233,1016,2386,10069,12462,6652,12765,12814,13716,14322,14754,3943,6012,12080,13199,5560,4889,4328,159,11948,6827,4408,11039,1464,10297,12684,4900,2424,454,250,210,11782,4066,2280,8583,442,2983,8214,13306,7142,14621,3301,10580,13749,6657,430,768,3719,7848,2144,6421,13229,1470,14813,9162,3441,5312,10883,504,203,8574,1740,11701,2619,6684,4076,3753,7463,11976,5471,9842,11133,9234,12957,8994,440,8813,9196,8442,14558,12227,8602,451,10767,11343,6046,13588,4125,7912,764,1676,12487,4201,9291,9730,6268,12824,6148,5418,8527,6772,7415,13768,7801,523,263,13636,12900,2444,4916,13090,12968,4911,4989,13399,4312,13114,6560,12259,1517,4065,7081,5291,456,6860,8764,13108,5320,10838,2535,7029,14742,14396,9425,2794,14353,2794,10080,6240,3105,3366,3838,693,1011,5760,13525,8336,12431,3214,6489,2752,7491,14196,1323,13176,778,5680,8861,8457,9448,9179,10511,3077,6903,8320,6385,8885,1267,398,2082,8462,11791,1020,14337,5247,10877,2052,7685,3954,3248,9092,3314,4515,8649,2142,4455,5271,342,9701,8726,12022,10016,6429,7655,769,7051,6902,5006,12887,11583,14654,6826,5419,189,14640,11028,10583,3242,9059,4394,11594,8573,13065,14384,9710,2897,10406,9232,7559,13991,5875,10107,13782,14564,2149,1805,2188,181,13354,12719,7982,14463,9748,8405,10882,10849,157,10186,9009,13695,10121,9530,7150,11399,7195,14649,13072,473,6970,3901,13693,4447,13515,11024,5747,9795,13406,1859,6866,6684,5085,14345,867,14357,13999,7751,90,14385,8877,9998,12847,8519,277,13569,277,1115,2545,5257,705,3979,9065,8723,6247,742,7657,9988,11946,3834,1969,9487,10627,8157,9657,3881,8160,11479,12241,7157,13945,13870,6604,13187,8249,14598,6097,9745,3142,14150,157,244,1422,10881,13641,8432,2061,1006,2317,5784,9765,7970,4839,582,832,10980,1857,12189,12165,2460,10180,6548,402,12413,1842,3000,1602,7243,10665,11398,280,9779,1520,6239,5869,8883,7401,10479,6526,12529,520,7923,11182,6471,10183,13220,10640,8234,11578,452,4391,6280,6623,12834,10216,7451,5578,9874,1390,13389,12996,6638,7077,1853,3079,9523,10476,730,4747,6467,9330,14138,12632,8314,11601,7937,10083,6132,5435,3645,4306,11639,12615,8181,832,6120,12409,10037,5895,13320,10982,8673,12030,216,6148,7653,14207,10344,59,6328,9144,11292,9597,13453,11088,11386,5180,9544,946,8501,7390,9028,990,7439,6173,470,835,350,13000,11840,11007,13068,13739,12354,12246,8812,11218,1407,10889,9886,2037,2119,14224,14041,12005,7563,762,3301,6540,2090,504,12659,6802,2183,11863,12871,5918,9047,315,7735,10032,12103,8850,11009,3817,1014,565,8164,12511,2909,10244,6593,6890,3298,8611,3146,4613,9074,4633,14443,10367,8215,13089,9669,1886,6553,4317,7953,7629,11905,12348,8883,5711,1553,2595,4271,13271,3075,11744,4699,3621,5374,3436,11139,9440,13837,3620,10343,7508,5666,5689,14126,555,3957,6341,12771,12330,1953,1130,3914,8937,8881,7962,6104,10681,5120,14368,9085,1262,3169,2972,12639,5773,5539,5711,5876,9607,12936,9012,6115,10757,7490,5132,8408,4279,2210,14160,4194,9238,11219,7788,3510,1764,3410,6228,1199,9010,1646,6163,4999,7138,9369,9108,2132,5082,6766,4036,13484,13849,8110,6918,13833,13641,4324,11577,6769,7059,14042,2654,1528,12681,3394,8836,2643,11436,493,13178,9565,6256,13234,1951,38,918,5591,5973,3439,2707,3595,11394,10756,11729,11705,8471,3901,5245,12306,5548,2785,12852,13586,6018,4065,12259,2291,3390,5351,2053,12356,2744,1745,5752,555,9621,5174,6983,10577,995,12067,10533,4422,4137,5022,10092,9287,2080,13930,5723,3013,12192,6010,13523,3357,564,13042,223,12312,10916,8259,8077,2049,10185,4446,10385,6911,2642,12949,11154,5784,1682,11618,3369,11666,6457,2160,7868,3895,7633,12064,13192,10981,8719,12809,325,7163,9798,575,7487,1136,10657,12363,11846,13839,6490,10180,7790,3941,2707,9408,11287,8346,11417,1025,10453,2788,5537,13891,4796,13587,11944,9416,3508,4909,1510,5102,11953,4167,6044,11262,13842,5196,9695,3534,631,2971,3709,8601,4856,3517,4426,10081,8402,8161,5089,11552,3079,13375,12684,9139,12588,9879,13859,12966,12580,5794,5296,10677,440,4563,13082,13080,9906,7097,4939,1404,1561,8527,7925,542,4966,13752,5038,12538,3851,1771,5433,1490,3376,13260,6415,283,11475,9198,1974,7265,9251,10308,5520,9657,12062,3556,9154,12949,1660,7072,10682,8067,5454,8081,9511,5936,11244,7608,2417,7493,2342,11414,5306,5956,4368,8846,9285,5634,10180,4404,13036,5807,8294,823,3250,11429,10922,11660,13424,10648,6309,6653,393,2201,4486,10815,5806,10481,6387,12728,7049,1439,12016,11508,3309,3798,12107,13534,5397,450,11637,13505,2220,12679,11062,3730,9549,2000,3147,2584,12981,2553,2997,13074,12160,5740,8302,6563,8571,11434,1425,9140,2776,13639,10804,263,6037,13556,6362,3098,3787,12652,8135,1306,2576,11950,3851,12961,6699,3622,10075,6190,8621,5931,11677,5756,3648,1701,7510,8076,12319,11924,4985,11359,8603,984,1144,6541,714,3700,2685,11870,9180,733,13630,7982,7392,8318,5120,58,9091,4115,6090,2047,3360,469,1285,9661,5981,2791,7665,12294,8288,7315,4625,11194,8267,2710,13045,7817,7312,5197,11613,8806,5355,10958,645,6255,5097,8737,3283,7404,593,10392,13437,9471,11048,5252,8189,8470,12574,652,854,4104,4172,6073,7918,8211,2781,593,7531,36,5686,705,11202,1964,477,6573,13278,4200,12570,769,1352,1570,12452,9013,9741,9780,3540,8903,6773,11497,11943,9962,4464,13071,13389,421,13715,849,7863,8700,2780,5623,3794,5912,5957,5288,5811,4354,8276,10622,4465,1699,6220,1337,10663,12601,10194,4553,6333,8645,9387,12486,918,5570,2669,2022,1972,1944,9698,7829,12461,12736,5007,2908,9273,10633,7242,3410,10378,2966,11383,4681,9136,9185,6515,8112,10209,5833,7245,860,117,9179,9009,9730,5936,9756,7912,8029,10363,3954,4993,9452,9474,6591,8247,9318,6622,9310,2865,5726,3749,3072,9658,507,2202,5110,2275,7033,10628,8748,7150,2592,2078,10701,13067,1616,10095,13528,6989,351,10732,2461,10276,9048,11547,10766,1710,6486,5015,4305,1174,3655,10810,12117,10912,7199,1644,4957,3916,10249,13092,4946,2004,3038,3677,750,7675,12160,13240,7904,13390,12804,6410,12065,3557,7782,8224,10678,10069,10251,4326,13656,5784,320,3340,10465,9620,167,5694,3105,3491,777,7762,3093,11915,12828,12848,12846,11287,12921,6399,12604,9492,4276,6503,8562,11814,3072,2597,711,3411,8848,5639,7544,7770,5664,11839,4045,11216,4325,4750,8186,12269,5040,6538,3641,12139,11919,10002,1007,9055,2015,10509,2424,4113,13430,2857,7446,6232,12442,843,1666,2875,6036,13756,184,4141,7411,7542,11857,5279,10589,5167,6520,8441,7433,4440,12312,454,9321,4961,11089,4467,7549,5125,10175,5620,6293,12991,7902,3402,5413,3031,12449,6698,404,10098,11653,10143,11996,8208,2117,4280,8374,5023,11609,13621,8956,9852,8714,8264,1396,3421,2033,1733,9886,1099,1734,12628,3951,5635,3077,11269,8911,9946,10891,9059,12576,9090,1536,3563,3066,1616,8453,5853,1630,10649,6591,1129,4434,11067,9984,8857,9906,5017,10701,2680,11578,9187,9085,3551,6003,13614,7973,1944,4572,6986,4984,10660,7415,11346,3391,6297,1058,5088,12963,525,1435,11042,1654,10829,6927,2568,9143,3092,10305,10290,7343,11750,5312,5504,10984,10077,12209,2925,9810,7356,4576,4423,5021,7353,3213,7817,2096,12171,8769,1176,830,5278,8948,10409,1396,3199,2090,1684,9552,12940,8220,11663,2504,11584,7295,13050,3981,7267,1177,10746,6528,2217,13084,10791,12888,4825,11759,12105,11984,11441,1256,3047,4747,5786,4157,10381,126,13558,10351,8150,9520,10492,12526,5404,5533,12201,2876,6733,2671,10212,3961,8058,8626,9901,12626,974,10467,1933,11436,11134,4245,11142,3534,3060,641,7485,11412,8736,2413,12654,10794,10588,4213,5340,4177,8072,121,10027,4955,12890,11771,4795,9228,11946,7061,6541,12837,7438,3849,6105,6101,9363,4087,7492,1601,2376,6033,2815,2901,3211,13245,5305,10186,11216,9039,8122,11678,10988,3484,9399,6624,3121,6091,1983,67,7320,8343,2455,5010,8364,528,10046,3342,10224,9741,5998,2813,11540,12370,2820,359,2031,10732,13291,2498,4244,2670,2992,9899,1607,9731,12902,8064,5870,6156,2955,12641,12314,12719,9740,10135,8729,10610,12056,6479,1325,9849,2980,9566,479,13159,9169,12250,549,4866,10957,11671,4411,4981,4825,7789,11243,6772,5423,4711,5979,9784,4272,4627,6361,10098,4325,11327,2443,6699,9919,10138,8558,10700,8941,11965,5519,6723,6942,5036,7136,5299,527,13408,12856,2222,10107,7528,5871,11041,8405,6999,4106,11312,2276,11273,164,2231,9983,1106,9951,3356,6787,10944,8454,3454,10481,1437,11952,1139,11874,7539,11943,5605,5109,97,3791,9253,12828,5550,6707,4890,2781,4949,3010,10252,13082,4746,17,5928,2316,8861,884,4146,8167,4800,9760,4314,7474,12277,8189,10718,8115,11234,8631,2791,8200,160,6228,9243,9807,926,12197,5095,3347,8617,11376,4613,9985,11212,2712,4640,11195,12356,12833,3181,630,11081,2337,668,10731,2363,1989,1206,5104,7187,3175,3531,11601,8821,9428,8081,7337,3863,5637,7602,12042,7284,3591,9578,207,4674,4100,8676,621,4697,5530,10454,9507,8789,2312,3352,2146,5503,11215,2021,10787,6050,1336,6950,1962,4040,1910,8044,8352,1465,5783,10272,11180,6328,96,9036,6524,7966,1311,10739,2823,6576,11567,9080,7187,4372,8538,9543,3515,9770,5952,7086,11989,9137,11297,10067,12371,8974,1872,12289,9319,5051,8173,11640,932,8234,1930,1211,4733,8308,4767,10811,1355,3226,6373,11075,2842,5643,3837,5706,3837,5123,9804,1216,10783,2909,1960,8170,10761,808,2921,943,4496,12496,1597,3617,1405,2081,10860,7258,7217,8290,4589,5761,7561,3775,5244,9758,2150,4676,7609,12632,7133,4516,1595,6103,2467,596,146,704,7156,3592,9314,7995,13088,5888,11166,9140,91,6351,10606,7190,12332,6490,8062,8525,8244,5827,3157,2494,10711,5468,3516,6355,3323,12009,6275,8517,7500,11106,2720,12856,2988,11150,2778,254,8426,5965,5232,3564,8539,8742,1004,12613,8145,9793,9874,10480,8035,8680,7481,6061,2764,4802,8889,5932,5051,2260,3835,4663,12547,7907,347,8152,8398,3553,3148,10617,10041,12774,11463,11199,9471,8794,5916,12658,3258,441,6858,3157,8582,10836,8396,11571,6584,2345,3263,12549,11712,12330,8943,6994,3035,350,8171,4084,4509,10186,392,10808,6535,1458,6303,229,11947,10666,7163,8119,9005,4904,11787,11163,8350,6075,12734,4926,6461,7218,10636,7201,4965,8700,12015,12438,3134,5898,12779,3364,10406,8449,10143,4873,10826,7625,7828,2682,5622,7613,9442,10419,12848,11464,6871,6191,6560,4523,544,12034,10628,9758,9616,1079,5727,3162,7143,11137,8583,9422,11042,653,8462,12838,6420,8905,10447,11981,2011,10999,2230,11054,12725,10847,12716,11114,10096,1638,7121,2748,4405,11390,2336,10439,4492,13024,4740,10122,6266,8487,907,12185,9273,6764,11991,4145,8068,12857,3841,1334,10168,11918,2331,11185,9898,12917,12086,1442,6321,7565,9186,1770,7898,6013,2868,8281,6758,5063,11671,4994,2847,5819,7697,9949,9511,12273,12626,12493,7699,8739,11172,6639,1545,8232,12411,2516,8327,1091,9465,3945,5807,12376,8232,2911,5334,6450,820,10996,12502,11660,11579,6317,5855,17,10697,2482,8814,899,5834,2860,11373,390,11365,5185,4384,10750,6491,12229,10116,6758,3433,5365,11665,13,7969,9852,1275,6423,8048,5058,8366,4956,6224,7758,6236,2485,10437,7135,7951,1883,2330,12119,8847,11221,5320,1653,3212,7543,10166,9746,369,10072,12725,5964,12195,6230,6233,190,1188,6227,10834,6755,7385,600,356,4413,6113,494,3000,2887,6073,8989,10643,5270,12470,11641,6975,9209,12156,8296,2228,3719,9164,11658,11665,8778,12750,6076,10134,6415,2950,8230,12273,3905,11644,12633,10838,3131,7634,6729,4666,525,6149,8567,3203,9791,2326,5340,3320,2914,4752,7050,6724,5075,3240,12303,10267,922,7992,9304,9137,5711,11458,2701,12755,3447,7921,2116,786,1760,5532,7670,2119,326,10230,10492,7484,1320,8847,4682,7784,4364,5458,2816,3357,7799,6365,6575,7642,4355,10849,2452,4859,3953,5594,7725,11321,11172,11369,1265,4979,5381,6599,6897,3033,982,7811,11878,11996,4529,2330,544,59,767,5827,11987,7178,8756,92,3735,10166,9976,3012,11266,8777,641,2583,10362,6247,3164,4516,5016,11845,8051,4137,9607,11186,4563,7293,8963,4509,8406,9930,12754,6618,11667,7131,6121,5449,9821,12604,3540,296,9598,11438,10696,6247,1415,11271,8133,4919,4479,5739,5097,1616,834,12194,7793,8117,7666,11288,5951,3390,937,2845,9509,9519,3038,9031,7730,3924,10920,2275,1467,141,4840,9582,9387,9014,2287,3255,6406,5160,11955,690,6506,1754,10461,6148,1160,3660,5851,9932,2277,12021,10778,10439,9781,11675,5116,3822,10624,5670,1862,12673,8148,10220,8541,12420,4997,8345,8829,8223,10155,3754,12639,11536,3254,11360,7411,4486,1475,2476,8534,5132,10325,762,6979,8722,11203,2551,12350,316,2267,1561,4620,7884,2411,5109,1637,3356,7325,2873,3032,8610,12189,9173,12043,6019,7166,12203,238,11588,2887,2537,244,9225,656,6126,5032,8262,4817,5774,5574,5081,7681,412,1062,6308,4749,12268,8349,3771,8175,1097,6899,1646,7789,6247,10940,10830,10694,7311,2928,9845,8981,2595,1102,9375,11711,183,4012,6504,5286,3812,11495,9235,11729,430,7254,4032,3570,5662,1460,7071,1209,1243,2606,7726,9209,11558,1404,2935,7848,5094,11212,3129,1852,8848,6662,8946,2692,10436,6219,265,1526,6092,3355,5383,1194,288,1697,6040,12555,2461,2768,1221,2644,11822,3813,9549,10141,1969,12521,11772,10321,11172,9597,853,9052,2358,6047,2013,3843,8467,5935,8325,5048,6978,5339,10397,7108,12156,2229,2330,5298,4869,10042,4209,1033,11994,5161,8428,5676,4451,11210,9192,10230,11781,7555,9976,9167,5152,11235,9,9234,7530,3095,12292,4419,3631,5157,2452,11111,9848,10356,10829,5850,11440,5576,12140,2797,7398,9739,1866,7497,1516,11719,5138,11898,8329,12224,6942,7601,11164,6061,9708,4155,6333,1129,8790,1912,682,5904,6097,5823,7085,7860,462,9508,9304,2557,2232,11877,8818,6417,5793,2457,5453,4798,7487,12277,1779,7601,11711,9132,12204,1459,4603,11318,6519,8571,7204,10427,5950,530,4332,6849,4485,244,1312,8511,9687,6436,6720,6525,4021,9184,515,1293,11584,11872,9973,5196,5206,761,7015,11667,1183,394,9412,3081,8721,5622,11242,2254,5256,731,10491,11096,12284,9096,7158,1796,6016,7979,11381,6309,1167,10986,1299,99,11541,11194,11875,1158,2248,4147,11253,730,535,8413,11999,10020,237,2915,762,2756,4629,12201,1385,3256,11100,7999,7874,4222,7547,10996,3258,9472,9201,4587,8700,5621,9107,10593,10643,2781,7323,8386,7192,8262,289,4793,12259,11558,5522,10485,10391,11911,11565,6209,9445,6910,6796,2055,9318,9832,2807,6518,181,9513,9167,418,8351,11669,783,2592,8769,7519,513,5534,737,4777,8154,7780,1250,7541,5706,8225,5776,1716,9839,1736,8097,6827,11334,977,5906,7394,10258,7243,2492,7459,1860,207,2708,9191,5224,4964,7651,6171,499,8558,10296,1124,7362,5615,11080,8990,8956,1832,4314,2221,6185,11327,321,2653,11886,799,2662,7491,6500,9386,9888,6416,2101,3777,8217,5023,2145,923,2661,5314,5435,10428,26,9606,7488,4791,6073,672,10352,2767,5609,3684,5769,4388,3109,3767,3924,3688,3704,8526,10675,9079,532,11486,4310,8500,7958,2584,4925,1503,554,12118,8332,4889,3560,2688,677,7566,4132,1351,9931,5909,4340,11948,7605,7011,10019,113,10682,1804,4547,277,2022,9207,10144,12143,4975,7036,719,10878,4502,5144,8760,9185,1601,67,4168,8373,10633,8084,8892,7581,8291,732,10247,7307,3809,9234,9858,11385,9976,3848,3486,12124,4785,10051,6857,3318,1864,5414,7274,1856,2391,10159,3711,7092,9797,468,2596,3384,7775,7184,6990,4868,10784,10453,32,5661,7523,3415,11020,11178,10427,10943,674,4671,5655,8804,9173,11608,2857,7611,6171,3180,941,1292,2098,11870,12025,22,9139,5617,2158,7640,2845,9420,8132,10497,682,10991,6427,5269,1326,11482,7336,11746,9076,298,6786,10332,2388,11845,4642,2853,10186,3326,11468,4767,11058,8443,11332,4090,1696,4792,3200,7694,1265,89,4225,9790,7790,3358,10291,1228,684,11997,2099,8398,11453,9551,5463,1791,3793,3448,3806,7486,2249,4982,5041,4554,883,9978,11309,2608,4676,10827,9080,878,6492,9526,5537,8181,4033,1369,11204,10465,3241,6525,8845,6209,619,1565,11646,9402,8727,9278,7067,11407,5375,2164,10688,10740,5146,9657,1444,11963,4207,3513,6475,1734,9613,7870,10025,557,3635,4454,6841,3591,7468,11631,7455,4001,7118,2082,8586,7484,5195,7754,7333,367,7944,10083,7302,735,7284,5755,9883,11737,5285,5842,5009,9387,4347,1384,10106,6710,4164,10983,2540,4696,241,752,11054,10166,485,7137,2489,11932,9279,3286,4835,9030,6474,6121,5383,1502,11247,10009,9522,11559,10244,6926,3411,1321,10541,2270,20,7810,2105,6814,9267,2073,6048,1996,11354,5885,3075,7431,2850,7819,9940,9646,6394,4915,4931,5003,989,4680,11055,475,9296,9755,1024,10883,876,8010,64,11698,5007,6757,763,6138,2246,4435,2036,1907,8712,113,9439,273,3938,10858,2575,11089,11823,2095,11356,9949,11323,8301,27,8860,10907,3049,10028,11420,7214,6314,8568,8445,5251,2939,5579,6457,7407,7660,2787,606,9083,2240,10305,3885,11059,1021,6574,6636,9509,5113,4232,1149,580,3275,8607,6979,2423,7085,5282,5975,9206,11340,5698,3207,1424,7354,10910,6056,11468,11769,403,9468,4990,9845,9663,3592,4734,5415,9868,2057,8022,9385,8806,6860,4626,9084,8417,7763,6624,7107,8222,513,856,10489,854,11530,4742,2586,4748,6808,6866,8331,5960,6253,11617,9954,4281,7880,1017,220,2542,476,2507,1520,6140,10081,260,10324,2266,1933,9835,6492,1811,9255,6535,4018,3548,8642,2988,6465,7916,3775,5879,1975,5063,2258,10250,4539,7681,1341,10485,11080,4742,4786,11109,4353,3928,6648,4332,1088,9797,6703,10265,10275,7186,8598,5399,3308,7783,10182,7044,5043,1462,2530,6947,6817,10342,4231,4366,7256,2264,10177,1466,4390,4105,7789,9609,346,9371,8570,3734,2231,4480,6571,5858,1828,8637,9101,6202,2050,734,5770,9691,8639,5096,6080,724,8959,648,11571,7349,5164,2985,9126,6306,544,9064,180,7459,4867,5912,8072,5248,5240,9127,8181,4604,702,11304,1622,4291,552,4463,7996,3835,3516,9161,9864,596,7037,4208,450,10854,6459,11153,5462,8220,1852,3729,3853,9368,2130,4350,5972,5940,7737,9684,2,3024,10251,601,7852,477,7072,6427,1486,10389,5253,11326,10622,4717,11665,2040,245,4875,6,10789,9077,4702,2747,767,4450,10484,646,5489,8439,277,11405,10532,8778,9943,2791,6933,10763,8143,1822,2585,10470,1420,1856,1599,4352,10422,11276,1812,9029,78,4606,6253,294,4668,3048,4017,3286,7117,306,2257,6684,5848,9334,7574,3069,6727,110,7343,690,9718,8274,3602,775,3721,1796,5991,3968,3325,8506,2769,84,2644,2537,4026,3817,533,9355,2964,3505,8821,9204,6667,4499,10030,2040,5163,3127,7351,5253,1116,6496,5150,5134,5864,10575,5417,6969,10977,7440,8570,2095,361,91,4400,2556,3332,3285,3969,8895,7610,9049,1937,7203,2762,10342,7811,6821,2619,115,8761,10723,4376,11025,2178,8997,613,7259,7462,5305,8168,2456,7025,3468,2636,2665,8638,6967,8302,5403,3816,5733,8403,2626,4301,109,8173,6423,7217,1732,2695,7359,899,7192,2829,3920,7925,6666,10161,2997,7655,10347,10940,6664,29,10751,3930,1112,2677,8848,11196,5489,2434,8812,11106,2188,10668,1321,6700,6220,5519,8808,1195,4978,8109,1745,8545,5042,8266,10473,2921,4983,5059,3302,8592,8495,6008,963,279,5620,3104,4316,4851,3594,6854,1302,9531,4231,9445,8751,11071,3907,587,1405,2442,11310,9207,4306,2074,1546,5790,277,8384,5219,10455,4516,7676,10754,4498,4820,8485,2239,7822,7143,2053,7184,4949,4950,85,1220,5958,1515,6911,10574,4137,9200,936,1965,6928,5883,9226,1203,1213,5836,6458,2813,3278,3424,5162,5505,8347,4895,5291,10234,634,8076,5776,9009,9930,5577,2881,2917,10214,11299,10616,10742,11129,2668,2916,9924,5632,7254,8028,3974,2318,2687,5612,3149,57,10,2228,9827,4645,730,5423,900,10264,8808,3686,9907,948,9463,8262,1350,8571,9691,5948,8010,8538,3252,4246,7634,550,3911,11322,8192,3596,3479,5374,1737,10053,7455,3833,11248,6952,383,2858,10041,7058,7627,3305,6644,5098,3341,10545,985,1469,5589,71,6063,6307,11094,4535,6425,4280,4243,5592,2712,8296,3477,6461,5906,3045,682,4872,2379,461,1917,3605,6678,6837,10068,444,5963,9204,2814,4725,9392,1200,956,9946,8528,5424,9854,4296,5772,8601,3935,9638,2964,5516,1763,4478,6543,10116,8649,1799,10885,7662,718,1596,2331,634,404,217,4788,9736,9988,3375,7122,3028,6031,9020,7508,5141,10108,6102,4781,2983,883,7397,9184,10889,3568,6693,1454,4819,9163,3294,2497,3286,4699,10066,6932,9045,6462,2530,9346,3844,1300,6812,7462,2261,8300,8082,3577,11121,4501,7704,9943,8367,3997,3923,9494,5088,2101,9199,6574,1524,4696,10236,995,3777,5307,4035,3107,998,2590,1418,10887,4527,10832,6667,144,3814,5472,5512,1243,6797,10336,1345,6619,1430,10182,6050,7492,7091,9875,5479,3897,11108,9501,5821,6714,5686,9397,9002,7088,7901,7399,8982,4006,612,3482,9252,1522,9933,4448,2205,9460,10978,1147,8319,2680,8014,2807,9667,9324,1352,8248,2689,6668,4755,8687,726,6129,9246,938,3761,10518,5130,454,4613,4627,3684,3769,1619,7135,11081,11090,7131,1128,1375,9863,5847,667,8140,10006,8441,8799,1633,637,10994,3028,5536,7604,8985,5843,1969,8202,8061,7993,7921,7176,2777,4869,3661,2255,3063,3955,1352,1970,4867,1422,7360,4103,1143,4573,9235,10636,594,2508,10814,3861,9918,2275,532,5450,5565,3332,10675,5466,6823,6020,10239,2072,4443,528,8781,3853,4900,9115,3446,7172,10924,3259,7471,644,5860,2567,1791,5443,5263,9576,10765,9623,8832,10025,1943,5470,10587,10805,391,7200,5965,7395,7219,7904,8279,7386,7829,7759,996,10879,9226,7943,9072,4885,3277,2740,188,5569,10772,3708,318,7916,5738,511,1358,7378,7567,10307,3257,5776,10850,5735,8654,4487,134,6375,1213,4122,9162,10898,5449,7800,10261,3318,6785,5726,1471,9688,2198,8922,8248,9326,10473,4796,2110,8562,3719,2077,8351,9981,8899,9166,6380,10812,9116,6319,9009,3282,9708,631,2594,603,8632,5326,2497,4509,5064,5639,7632,8907,4947,6563,5540,5875,9349,8293,2,1702,4326,3590,2733,7567,1764,9556,2196,10731,3706,4072,7175,4987,6565,6946,4393,3809,7131,8966,8957,2807,10510,4557,8921,2240,9615,7709,10100,3882,7419,1294,1354,224,3626,2431,10859,2072,6277,2036,3314,8466,1203,3175,4495,9471,9254,4155,2990,5197,2089,1009,6915,2746,3969,2859,7327,5650,6502,5695,10210,6947,1145,6501,1492,5988,1280,6447,9060,7081,8575,2987,3447,4708,4111,2661,3886,6132,7844,10522,7299,9425,7127,2989,970,1685,981,234,5311,5346,7926,6143,3850,3503,10199,1598,4434,6682,10264,10685,1335,1783,1712,8088,9131,9050,3433,9131,10741,548,6817,6933,8830,2974,7556,9037,7485,7615,1677,1357,5882,9164,3110,8839,8960,7364,3883,137,7526,10809,4741,6524,10228,6618,2482,8079,7043,1399,8328,6921,7105,5335,8915,3470,2891,3724,5189,9626,9691,8838,10133,10359,8675,1253,7745,6015,7943,1955,7843,2126,8789,7969,6575,4562,10482,1758,2674,8327,4810,8257,3875,8258,2122,7574,9931,7452,2584,5971,5271,6310,2157,3863,8712,5911,4821,2319,731,9803,6343,6704,9534,10151,5812,10398,7987,2708,977,1746,567,67,9276,5921,4962,5202,6589,1533,7476,2146,1594,2889,8829,2146,9790,2383,490,5972,10544,2995,7640,10178,9197,8290,5614,7489,8153,2576,9009,9058,10303,9670,174,3051,4401,1693,9715,4104,5841,8408,4683,9576,4338,939,10257,7970,9137,1849,3030,9630,9786,9674,2787,4117,5728,2628,3963,8810,7418,2642,1485,7405,5613,10436,1045,5903,2784,259,2331,2400,5171,583,4474,9486,3900,9372,9195,5535,10416,6923,835,6445,8166,5175,5402,1467,8532,6616,3681,10624,9366,6141,9248,5434,6292,4544,4384,2224,170,4412,7978,2194,10162,10380,4292,10167,9831,7458,3294,8439,8459,430,632,943,264,8217,8497,7426,10312,5293,5067,9638,9440,5421,2650,3553,968,2947,3532,8215,2281,7279,7561,7672,10620,8597,137,2824,9123,3512,5475,10045,2424,10393,2177,2071,5639,4477,9230,9607,6276,10000,9615,2010,8877,2728,7311,4438,6278,1422,10049,6438,4134,6841,7758,9777,1084,1332,7785,5655,4831,2372,8879,10380,4405,632,4951,403,4868,3240,7687,1994,8795,2362,7969,7418,9853,6030,9940,6604,2458,8428,6954,435,9030,4621,6676,4772,6616,2313,8854,237,9655,3741,2996,5245,9500,2117,10228,1802,10066,7239,5944,3471,5426,7272,621,743,114,10464,4891,8068,9300,8347,4235,3658,6377,3443,7650,1708,1578,4525,5619,6027,2910,6854,5262,395,2073,10076,409,1415,9237,7254,5472,6316,10052,1995,9870,2215,8598,4400,6840,173,1473,8107,7761,3444,10290,31,6898,4953,10473,8281,9703,2810,10206,7304,1274,963,3179,4168,3799,9327,3802,8332,8179,7000,5563,8866,4181,2825,5372,560,743,2105,7137,8497,9747,9703,7628,9152,2026,5107,4638,9242,8013,8390,9869,10374,3245,8433,6706,6531,2348,4090,8425,2690,3783,8580,8963,3441,2255,8359,4983,1518,3189,10432,8491,461,7857,4804,7549,8441,4386,4447,7093,4012,7605,3997,9344,8727,7101,883,5296,2668,6471,2712,2252,6785,7373,6893,4517,3507,3543,8211,10349,1356,6583,7708,8867,2020,36,9725,7681,3771,419,1066,3302,3029,5004,7954,2786,383,6720,3065,376,4203,4341,323,7916,2238,1307,1640,5242,5234,3444,5792,8211,8929,8536,3278,5989,6045,2070,5335,9294,3304,233,530,8836,2174,8744,6603,1679,4395,10132,4754,7090,5475,7816,1560,5835,3883,17,8792,4665,6145,2435,6700,250,8792,8533,8465,3201,6145,8988,5091,9619,4301,4095,6169,232,10125,2973,314,4438,9135,718,8051,1408,7682,6270,9116,6268,9217,59,1234,4583,9301,6600,6764,5957,7924,9441,2320,545,6893,1149,10290,8604,6228,7248,59,9071,2252,8389,4606,466,493,1138,1685,9989,671,7422,9118,5978,6176,6258,1573,1767,5897,8284,1366,9152,10222,5803,645,3659,1674,3656,6720,3887,1283,9230,5885,10177,1897,1270,2700,8835,2770,6672,9051,8507,8211,1635,4610,9883,6946,1836,10136,5465,7762,6215,802,4148,4075,9015,2345,133,4500,7413,3569,8978,1001,6800,8728,8477,6342,9129,2850,416,7006,6288,2777,6751,5305,4642,8135,589,790,9908,5117,3023,2668,1003,9928,417,3708,7420,1682,7909,576,3903,6560,3243,4697,1715,3295,2805,7149,3806,6135,5402,8342,3931,9373,905,5376,3932,2020,6588,513,2141,1118,9834,2828,6222,3694,7657,6320,3873,7683,1686,7974,4345,491,5475,9540,2016,2758,2540,8054,6034,4677,2992,1426,9263,1695,9200,5531,2855,3778,9744,1863,3338,3170,2444,8029,10147,9255,7586,9545,7200,8990,10068,9799,1746,4609,6637,1558,7217,7410,3377,5082,6492,5771,494,473,5503,5143,4804,4834,7853,2530,7077,8652,1252,186,65,714,663,968,872,3321,4505,1967,1561,8755,5261,8978,4384,6668,3933,5257,8727,9248,7756,2188,5424,1478,7730,10055,10107,9802,7896,8179,9304,8790,9884,4584,8939,0,7338,6653,2317,9165,1078,5657,8676,5769,3655,2142,4047,5016,6011,8423,3072,731,7733,3488,6197,6423,8809,8459,2388,5309,9401,7983,1570,9732,8213,8256,2723,1605,2605,7655,3321,3323,8483,2655,3542,2030,2264,985,7312,5727,2905,1264,1260,6953,4411,4696,4835,4425,2265,6637,3238,6245,218,5919,3718,8247,7977,3240,5901,8528,3998,2515,8398,307,3474,6118,6829,7802,684,1830,3983,9727,7667,810,4207,1227,3719,7667,9769,5089,9567,2625,4746,3595,1738,186,9948,5189,3196,6748,7588,1621,5137,3208,6663,4855,8756,4632,3320,4729,6818,5666,5332,736,1869,2665,2579,1314,3643,1207,5300,1041,2193,6975,3775,2121,7077,8605,2471,7055,1972,3131,1413,8443,2328,2194,8355,4261,3115,8471,2695,1784,1469,8432,2418,4746,6623,1625,5967,3677,596,8577,6991,4680,3777,6762,7972,6883,5890,5170,9364,4218,4358,6585,1897,9890,2258,9516,264,1077,7226,688,940,9400,9123,890,5256,1572,1647,1804,2757,4789,9822,336,730,5691,1573,5459,9690,6289,9361,2061,85,1743,1060,9252,8370,2420,1492,1700,2292,7265,1505,4948,7709,9131,3507,7899,5132,1418,8784,7648,1054,2551,6901,7876,8346,6023,6715,9794,220,1884,4564,1879,8674,3797,4567,7440,5794,8539,6667,9224,3483,2215,9837,5000,2641,4366,8756,1660,9492,1177,8315,9603,9064,1572,784,7310,6064,582,3278,5151,381,6875,2969,4938,767,4759,9196,2658,6663,6696,8474,2518,5943,492,5132,6436,5174,1173,7423,1192,6807,1127,4627,6157,3663,6549,6094,1729,5542,5244,5172,2101,9760,7172,1772,7807,2901,125,7041,5544,5483,4093,765,5184,2339,4547,4608,4805,4608,5396,1204,3879,2802,9453,6281,3218,9593,1047,35,5982,5361,3989,4456,1426,426,2077,7221,2705,7101,3173,8837,5550,6296,2921,2734,8158,4478,8806,9326,8396,2905,5527,4847,4477,4179,2337,1557,2381,9222,2031,2556,2465,6768,1943,4396,9593,7104,2400,3904,5631,8922,3487,201,1796,1431,5748,5124,6012,5419,3306,9694,4308,1304,5473,7360,2952,1356,6893,6673,5944,9463,6981,2962,7213,5648,562,3260,8313,4078,2246,530,6141,1528,1598,3807,7651,3625,871,1174,9273,2097,5600,8434,6791,2395,6250,3477,3387,5664,2712,2861,1787,9362,8585,4006,8138,2975,5379,4316,2797,5771,8011,2780,5884,2171,9094,264,1261,8687,8529,8882,5921,7647,6954,1321,2957,176,5788,1811,2584,5204,108,4679,4341,1834,2710,7794,506,7635,4093,7165,782,7549,479,2486,9241,8680,472,481,4893,8419,5398,4765,8650,3004,4740,6263,9031,1777,5862,8295,881,2713,9208,1429,2194,1313,5487,4602,4715,2722,4302,2645,5514,3614,5299,5701,7498,3575,473,189,1334,994,3043,439,1108,1593,6508,9562,7769,3348,9544,1098,8979,666,6803,8708,8377,9105,4264,7992,9017,3250,7798,8504,631,302,1654,950,7928,1556,8455,5912,5464,7821,4688,3212,9105,7907,3558,3272,8797,3582,4627,2744,2721,7955,4728,3797,256,2281,8680,2915,7074,6057,8506,3919,8358,9092,5260,7783,2582,4478,7674,653,7882,1080,4264,5469,3308,5020,1833,7910,5239,8559,2603,5274,2800,3241,2197,1712,1131,7518,4308,439,8478,8732,4944,5417,7139,4290,3128,5528,4526,8883,4826,7042,8152,6654,6361,2449,8136,1298,2502,8672,404,1667,8511,6246,7106,382,4016,1345,243,2089,2210,3871,167,468,5564,1585,1021,7133,8046,6117,3309,9370,1734,138,4169,6217,4032,4362,6355,3495,7179,1932,2469,5683,8606,7044,6265,8991,3769,3026,3620,7631,1671,8159,6687,4202,5610,3078,5009,5756,424,5306,5714,1532,9178,4462,8756,1768,416,7820,430,6573,5913,749,1101,69,5963,4111,5771,3547,9279,5631,3927,2961,420,749,7608,1990,603,2583,2853,1964,8183,2168,5414,237,5019,5989,5587,5352,7912,3191,757,2886,9245,2715,8378,1840,232,1545,2333,1395,6389,7738,6281,5118,6317,5631,2555,1470,7693,6217,7235,9135,6770,1837,6931,3180,3890,9073,812,6348,3517,4801,5273,767,6837,5181,4932,9064,6778,4953,9337,7439,9255,4616,1985,3697,4755,5054,5986,8187,3461,6008,1829,5496,1217,1301,7488,781,611,6121,5631,7699,8160,739,2557,8869,3654,9043,1855,2476,6188,8333,7409,4516,4162,4361,6823,6829,1401,6646,6602,7065,1867,7594,6218,812,8079,6485,5406,107,5030,3884,8069,8714,3663,7391,7138,1311,6944,718,55,1981,6890,7242,7800,354,8018,3113,954,5670,5844,3547,3718,3528,6018,5814,6206,8210,2642,3452,4821,5489,8366,3824,6058,7083,5452,4784,2900,7127,1830,9176,3269,8162,2938,4223,4408,2049,864,8128,2286,2328,5848,6912,7964,8261,4652,4820,8161,7143,7174,2978,2093,7833,3673,1036,6461,1062,4046,8543,4710,2499,2077,713,2223,5918,9120,3659,7271,3061,9254,1997,91,588,6413,6405,7748,8584,1685,8816,6462,3230,5714,8210,697,5460,5764,6937,7334,2400,8945,4050,1441,8621,3525,3248,4057,5136,1796,3533,348,809,2884,6540,7828,3756,1415,5517,4308,6887,961,1342,3249,7722,5180,74,5502,6519,7749,6533,5835,8431,3676,6528,5232,2046,8713,4698,6788,2399,8329,3473,1522,6174,1251,391,8394,1009,1172,3077,2375,6817,7656,6309,1926,3763,1136,2225,29,1327,7832,5837,2795,8472,3930,1864,5427,1735,2175,8295,7385,936,2334,632,7907,8371,7397,6524,2011,7635,1,5139,2235,2314,7428,251,6532,3258,7765,2099,4809,5929,1461,6592,68,3232,8588,4137,5668,2449,851,5372,517,2836,8067,7433,7872,6123,2829,3,1421,1210,8036,8839,866,1033,7736,8362,1499,2871,2825,7690,5205,4997,5209,1985,8064,7753,4357,4788,2722,5046,2247,6674,7887,5385,5960,9061,2925,8651,677,862,3510,7082,1426,5680,1744,129,680,1119,3386,1011,5408,1583,6225,5078,6331,2428,8594,6515,2786,2569,7871,6826,1652,4963,1364,692,385,8395,2693,5304,5877,3765,6532,1350,8497,3370,7888,4657,2498,2132,3334,4570,3147,5819,5500,1982,1228,4364,6197,101,7596,7160,6697,2298,8234,6459,1767,2221,4099,6558,8285,7805,7238,106,565,35,1072,3830,1465,945,3761,4545,7806,1472,846,2707,1919,5890,3081,8893,3867,3494,4137,1439,3214,7792,7873,2112,6824,1276,3367,3822,6255,5923,215,1114,7530,6899,86,6416,8036,8642,4016,1762,1564,6012,4437,8796,6964,6173,2844,7926,2262,5979,4457,3480,7347,7792,548,529,4892,8123,3937,8492,6632,353,4437,3074,6723,6940,940,77,6104,6231,4434,7225,6321,7369,8449,4003,8204,2301,1175,1934,2272,6090,5698,7466,1892,4169,2713,2271,8919,3967,8817,7877,3296,4899,2206,3569,6054,5715,8881,5618,1040,4835,4714,58,3087,3549,8594,8433,6159,5813,4379,3903,1923,6350,6121,1624,2326,6384,4611,3266,1438,1130,1374,5263,4906,6274,3695,190,1801,1112,951,4523,131,6028,526,8021,7017,2690,8316,6648,2367,6186,7469,5520,3491,3833,1146,5107,1655,1905,7121,1398,412,2766,7522,8073,4099,8837,4342,4002,680,7937,984,3932,1161,4621,498,7729,2405,37,6800,7084,5994,2107,6072,4058,2388,2579,7374,8302,6278,7911,1459,3146,8681,1548,6252,2056,7312,4259,4306,2978,5698,167,266,4366,5115,2104,8654,1523,2629,3844,8457,7569,1334,3414,2007,4863,7430,4871,1114,5119,1804,7672,346,3544,7084,4520,4094,5316,668,5262,2746,548,7428,5305,1490,1017,4123,8245,3405,6468,2021,827,6639,550,4412,1787,7022,2434,7340,2550,8154,6762,603,8049,421,5292,1039,1340,5194,5497,6017,3882,3759,374,4259,704,7020,7987,220,1024,4191,426,147,6984,1242,3389,5042,2314,4952,8524,6723,328,1977,2361,5313,5537,2056,2495,163,6890,505,6182,2109,2956,2601,5973,1074,4435,8514,5022,6142,659,2165,1829,2495,7231,7462,3863,6912,6276,7207,7784,8555,4823,1353,3237,748,4350,3443,8592,4220,5567,3222,7144,3665,5031,4266,4354,5465,2146,8205,4146,4906,8481,6160,5208,2296,819,2716,7591,6039,6415,4376,5253,4259,7654,1980,4213,819,1826,4873,1986,2201,4452,4436,4681,5886,714,6868,3465,8662,591,6179,1716,7099,4440,6485,3868,6587,343,2339,2582,8023,7317,4895,8223,6885,3602,8047,8291,8023,6127,2421,4502,2219,5336,7527,8151,1784,5684,1065,5978,5739,5414,3387,6673,1550,8103,6646,1401,2223,3495,1114,1398,5366,5214,285,3479,3405,6006,7066,7767,2487,7473,5552,2526,3232,3125,1222,7405,525,1707,1682,5745,2358,4191,5669,4979,7052,3356,2497,7840,4571,1166,1438,436,5571,993,7142,7315,6103,4773,6390,7707,2950,294,6762,2001,2069,7231,4924,5668,7120,3920,8034,6409,2817,460,283,7112,6704,1767,4195,953,510,2135,7246,5161,4936,3258,4431,3280,6790,8513,8161,197,4347,257,4059,2700,7000,2633,7981,4369,8424,3552,2222,1678,8362,1399,5855,2214,5196,724,6005,7456,8245,2044,2543,5720,6696,4454,5492,7818,1241,150,7312,7454,7565,1868,2849,4249,8224,4434,4466,4838,268,4750,1772,1517,5444,1582,4789,4326,4858,4001,696,5612,8478,6844,7625,6950,7263,6231,6213,3457,7557,42,8434,2744,1964,3432,8331,4602,332,944,498,1470,4500,7048,1,203,7329,3212,5948,7686,462,6302,7244,2282,4696,5735,2768,7208,7678,6778,3055,2783,6361,7031,3519,3110,7107,8107,760,8377,3805,6930,7939,4605,4659,1299,5069,8348,1646,4045,2635,6136,3684,1858,4213,2648,851,1082,5312,2335,1787,2784,8209,7737,180,1458,6158,6983,8322,265,2681,6696,6047,3877,5575,2084,5852,3273,4883,2513,3856,4188,5835,4925,727,5896,1928,926,2726,1063,7808,2690,6829,372,7991,1417,5069,8008,8269,1868,1912,6938,1962,7869,7042,2203,4409,3374,5465,879,5864,6641,1451,395,7881,5347,2776,5798,2327,7338,8089,3765,1794,6433,2229,5436,1946,5880,709,6163,4372,6078,6789,6743,7380,1528,416,3261,7607,6230,8003,6241,7007,4228,8346,6526,1497,4145,7020,1252,2544,4299,2623,997,1367,6671,6382,4427,5765,1548,4283,3172,3587,3055,5825,4810,1178,3485,6864,4854,6275,4945,751,4459,6855,3055,8156,1411,8022,2970,673,311,5878,6688,2671,4776,2539,5137,6925,5240,3759,8220,254,1951,861,2341,1730,3411,1623,3969,7157,2041,3326,5094,950,6486,7431,7706,1111,7239,4330,2906,4600,1148,4668,7443,4987,634,8118,8282,3611,4537,8170,4000,1546,5751,8162,6908,5592,7409,4533,1358,3927,3098,5425,4742,2349,1133,1705,3413,4596,4352,4500,2967,1559,7559,5169,4069,7100,881,4922,6070,2889,2046,6074,6007,3372,112,2656,1387,70,3124,7479,4310,6724,2109,802,2207,4938,1786,8011,5616,4082,1140,4953,2133,925,510,2698,5885,5879,5222,151,6779,4556,3414,3656,3097,4137,981,8074,6338,4755,4979,889,375,3615,4518,3878,6147,916,2076,4063,7022,5367,267,5013,3475,1188,2823,305,3697,2912,3587,2396,7786,4360,2679,1382,1145,1501,1635,4722,2626,171,7626,1867,4691,6465,3725,1454,3954,5478,5822,1383,6769,5986,6976,5204,814,5751,6428,2678,6322,4684,6919,3682,119,3448,5953,5341,386,2469,7689,6972,4834,7709,5267,2634,509,5997,4959,561,863,2165,5518,794,5029,5344,8002,5995,1413,3594,2828,885,4128,5105,6418,343,164,1608,2914,1954,4218,837,4144,3165,6966,406,7493,1552,4444,189,4250,7440,5785,1,6704,5451,5241,3207,3909,2631,8027,3550,5425,5881,3039,7540,6130,5395,5374,6007,7575,5267,4929,1621,4010,3991,5463,7224,6079,7482,3686,280,7843,5888,3001,4388,1600,1250,2020,3830,7859,456,4834,5428,6559,7763,3199,3654,1708,5666,1743,7568,90,5510,5112,2589,5716,676,169,3895,7093,7686,6106,7818,4875,1789,2126,819,1560,5960,2746,6491,6618,6761,7494,6563,7138,6800,6672,4450,3945,5164,6491,3615,1769,337,6143,6756,227,7774,7941,6949,1885,1031,3194,2668,3351,2982,2618,4027,1055,3065,2398,5478,7163,4454,172,3691,75,4205,5120,3334,5360,5084,6534,1242,3265,2167,5772,2678,1177,4197,7440,68,3228,54,3716,2654,1185,7478,1052,4407,5423,3319,2600,2755,5884,6723,7004,6253,7932,2114,2275,5622,4067,5482,913,7080,5278,2973,7573,1923,7798,6520,1200,593,3988,7200,1195,6017,4952,6393,4557,5261,1778,4016,5311,6999,4338,6444,5354,4571,813,6537,691,836,7241,3057,7886,2408,502,3359,7425,5893,1213,983,6409,4450,6088,4887,1812,7725,6166,6021,1622,3128,1297,4063,2519,5160,613,1818,7415,7847,5686,3917,6643,2142,1449,7273,5125,1274,1742,1872,7516,7902,312,2964,3665,4730,1509,3192,3890,6456,3402,7716,5320,5698,3399,2759,7494,2030,5710,3400,3458,4686,1315,4019,4482,4084,6366,3735,5498,7324,1257,3674,7464,5414,6361,6546,2753,6320,4892,2704,1626,3785,7592,1730,1885,2026,3419,4402,5090,6992,6483,6689,4258,7566,4094,1910,7764,2539,3886,5409,1160,4730,4762,4553,6295,6342,1197,1694,6520,2714,2695,7792,5665,737,6589,1299,1303,6649,7709,3309,928,5319,818,4068,7150,211,5879,1922,7069,3521,2387,5748,2954,2293,2115,3217,6938,2685,5677,987,1744,6269,1941,4670,4421,5042,1042,2125,3937,5515,5522,5040,4486,6784,4260,7202,1883,2385,3779,2832,2755,5877,4825,4948,1850,5098,881,3229,1914,1030,6697,3471,4816,5563,6396,3630,2456,279,1392,1819,17,4194,3590,6016,6878,6666,4992,6209,6970,1379,5284,6874,6896,1440,1448,3947,2038,7501,1068,4997,6186,4798,6466,6767,1425,983,5311,4759,6283,2748,1808,5919,7623,3202,1936,3029,5950,4660,5266,3561,5016,6952,6704,3943,3563,3547,4766,1926,3484,2890,5088,7469,2534,6712,317,1359,4616,6556,7214,6337,2046,2275,673,266,7306,266,5750,6816,1124,6150,6740,4892,5112,2998,642,2070,1538,2044,6096,1654,3627,279,4891,7378,2642,4748,4839,7497,4569,4000,4580,2403,1585,4282,2041,1495,6812,2740,3216,4655,2148,1050,179,4948,5223,7184,1166,2697,6110,2814,7359,1744,6793,2064,5595,1852,4028,7119,1193,12,5329,4770,4154,5646,2044,5536,3141,4833,2044,5737,3706,3106,7549,2628,5399,5126,2056,2333,2273,470,4559,4105,4654,1908,6177,4402,4279,5485,2301,3097,5283,1075,1897,3912,4346,686,4595,2892,3811,4319,5048,1177,6401,1852,3087,5529,2236,479,4575,2247,5769,5683,5386,937,6122,216,1527,854,6186,7054,5822,4369,5925,368,6228,6139,2005,2008,792,2660,4865,3293,5359,573,6329,4646,2007,3688,7463,3430,2408,923,5347,4448,1894,3280,6878,4147,4733,3129,1277,2095,6886,2250,2313,6410,3282,1769,7314,1746,2651,4549,120,3552,959,7524,4950,2746,2729,4381,5980,2598,2239,5561,2467,2009,4198,1148,5126,5062,2227,2023,1304,5602,4573,6528,6837,7276,3133,3952,4181,3169,3206,4140,1821,4,3703,222,7348,7256,6326,7080,5719,2384,5949,4579,737,7294,5595,6491,4808,7370,2450,1959,3355,4066,6229,954,4874,367,4213,6650,2784,6851,1026,1530,5640,317,5214,2137,1732,1960,2243,5130,4297,1380,5384,2113,7357,652,5712,2478,4772,5165,414,390,5606,7207,18,4753,1566,5697,150,5340,4501,3059,4733,2347,4889,712,4840,1285,5318,1686,1352,627,2373,1000,7085,3742,1102,5613,5204,7433,5191,2221,2106,6135,181,4730,1074,3655,6744,75,3758,4591,2557,4965,7379,4475,729,2149,6578,6704,3148,3926,5166,6569,3876,4935,6288,6413,521,1304,3200,44,2170,2541,3227,418,6293,5385,5996,4560,6572,1700,3897,3789,1041,3455,6102,3434,2692,4956,3745,1929,1882,3146,515,6754,7326,3705,2121,5100,6326,942,2589,5017,3979,6703,4024,6929,203,576,1915,6679,2481,717,6154,1482,6772,302,2683,5447,426,6492,3755,4542,5226,697,5329,4674,5424,6910,7273,5222,6482,4334,6767,25,1203,69,6251,6168,1179,4583,850,4437,1709,4573,949,6416,2180,6608,7101,3871,1292,6714,2404,1059,1201,5829,6253,878,1001,5158,4940,7275,4814,4457,3967,1021,4158,2478,6474,4207,1035,4471,5751,3924,3084,1127,674,4552,3892,3485,2604,2325,3438,3716,7261,5956,3012,6795,187,2877,1763,4393,6177,5497,4197,6573,3602,6565,816,7008,1482,2120,4950,85,1783,1224,1673,2175,6924,4120,177,6702,2681,3809,6649,5262,1406,2323,2559,7000,1511,6871,5832,5373,2549,6927,6617,3774,272,6675,6559,6329,4867,6863,1154,4826,752,834,5770,6041,5774,2701,1941,2852,157,6079,5598,4923,1477,7167,6810,5483,987,2647,6971,5992,4025,662,3889,5577,7095,267,1741,4989,6718,5653,4031,4843,369,3170,434,6437,715,2408,6520,200,195,5998,2570,2854,261,5531,1425,1110,3321,4573,3377,1228,3619,100,5485,3743,6175,5820,1010,1579,2163,3680,2276,139,56,6153,4324,4593,6931,4046,3859,4335,5373,176,5688,4635,6614,2615,7032,511,4742,3536,1426,597,3121,3840,1490,6558,6702,5750,35,3382,1165,4364,1390,2718,7085,5066,3991,1112,6337,5623,5896,2410,4842,3450,5796,210,3184,5178,581,5289,6391,4263,953,5318,7016,3820,2064,6785,2576,6320,4025,5762,4726,6508,2713,2936,4119,6740,2364,2474,6524,484,2028,5770,5852,2556,2617,3300,3709,6319,2893,153,5472,4167,5212,3122,1355,6762,2258,4031,4542,740,2433,3320,2767,1246,3941,6148,5294,6361,4677,4879,1878,6547,6188,3947,3858,2840,6751,2447,5211,6611,6903,6054,3169,959,2746,7012,590,3264,6691,5823,938,5578,4561,6193,1663,5892,709,5544,5555,1439,2043,5985,5441,3159,3246,6431,436,5567,3047,3066,5539,6828,2775,4488,1331,5165,3342,3983,5661,390,5605,5979,1566,4012,1585,456,6894,2355,4005,634,3237,5047,6109,1476,6325,3417,2884,5392,3502,1175,3089,562,902,5200,1723,63,5639,5706,2860,2312,1697,144,248,2087,3820,4066,3561,2864,4964,4643,3667,4214,4984,310,3944,3469,6179,6746,682,3640,2228,637,6353,5720,5633,3827,2174,408,639,2226,6477,457,1798,3634,5596,5112,2315,1845,3111,1192,6684,4584,5977,3117,1827,2595,1608,309,42,2808,2345,1371,5391,4920,1546,5535,4174,4410,3424,5908,11,2821,3391,558,5191,532,676,4362,3782,1162,3886,3253,699,4685,2586,1078,5040,963,3888,21,6492,4564,5851,5038,4517,668,2514,270,3395,351,3338,823,452,287,490,396,6557,6192,1464,4399,89,495,6020,4252,6852,6473,3537,3465,4191,6340,3096,788,3270,4384,6262,4988,517,3753,2940,5691,66,1904,1118,1067,5139,186,1580,1377,5878,5259,5304,6582,88,6468,785,2968,5925,555,1873,3238,1710,6065,3729,2614,3548,6314,6596,5623,5262,3566,3073,3555,1600,5170,1646,4225,2089,3143,6014,2342,6208,5937,497,2787,1946,6219,5185,5167,3028,4328,4947,1487,3250,1154,1674,3506,6557,774,4996,2473,5023,2847,4997,770,1683,5453,4362,1912,5934,4239,5039,1081,5018,475,466,1626,5251,3421,2472,5075,1480,2446,5357,6099,2532,1294,2221,2912,1761,4232,3476,6536,5759,6240,6421,3513,6455,319,3434,1168,4628,4881,2383,5948,745,1053,502,5257,5155,2054,2523,3047,4635,3892,2564,63,2796,2422,4127,3747,3888,2254,5753,4460,2922,852,5731,1332,1198,6011,1460,503,4586,3022,2516,2304,4720,3530,3715,158,2723,2091,1987,1223,1869,1047,1382,3518,4765,3371,1182,2442,3512,2741,3535,1617,4987,5414,5663,6318,4099,6213,2276,6465,5081,6185,72,3445,3291,3227,4593,4313,914,6551,4592,1684,6078,3172,221,2895,885,3576,5604,2114,2978,6381,5666,6438,3337,4007,1972,2130,2427,3958,362,243,2109,3031,5971,5193,6046,6268,4129,1729,1208,982,3130,1729,4440,641,4835,6321,4125,2614,5373,2719,5123,3307,1151,5899,286,4704,2643,3271,920,4863,4231,2661,3823,4171,1880,462,2235,5854,560,593,3387,887,2939,859,3791,1712,5754,4953,2033,5959,989,2147,74,3391,3134,1788,3240,2749,1983,1822,3901,1115,1037,2901,4273,5129,4601,4507,3206,4098,247,365,540,3279,5022,5041,2570,5068,1003,4390,1108,378,863,3965,5562,2279,6234,5448,5624,3255,5835,2423,5322,4975,1044,859,4976,4576,2896,3517,6035,791,4956,1057,3417,2528,1761,2730,5322,2621,6384,383,3121,6474,2395,3658,416,5370,2670,3058,2221,2708,6493,94,4414,5102,6419,4183,6222,6157,5795,5206,4500,4207,5457,1586,840,4808,2030,5491,598,5111,5975,3822,786,3158,4279,6512,1693,4988,6161,1705,1139,3911,4740,678,648,1706,300,4453,3153,62,2169,2696,2241,878,4680,4824,82,6204,242,2552,5130,4583,3629,2085,5461,5228,3946,4030,5020,4656,1154,3350,2415,4498,4188,3664,679,5332,1229,1448,2464,1616,2377,2460,125,3250,4406,539,5770,3285,2238,2408,2079,5386,3252,4849,5337,266,3669,3845,472,3276,3859,1993,6360,2129,5289,2429,1171,1039,3025,1341,5538,2946,485,6422,5937,4818,2997,2546,465,4404,5300,506,3885,3058,6113,18,4125,2287,2011,2351,3762,4520,3242,2304,3257,6418,1309,3112,2406,3881,3990,4542,5038,5198,1778,3510,1338,5651,3811,5802,5939,3209,3471,6319,357,4595,2137,4985,2622,5932,147,2476,3753,6135,428,5009,1222,5693,1352,1218,291,5960,4686,3139,2632,3416,5268,4039,653,5601,3536,738,2976,5697,1743,3516,4031,4467,5490,626,3014,5789,4481,3355,2594,6034,5752,5994,1742,5580,4074,5197,3439,1090,1936,5723,6321,3397,2919,1365,5831,6056,314,824,1937,876,4351,1612,2208,4561,327,3771,1244,6050,2373,2136,4631,6030,5312,2921,1705,6,3276,1592,3011,5016,4707,2513,338,3799,1146,670,1272,2312,2001,1898,555,5408,5750,4441,2729,1990,709,2166,5570,2554,1133,5290,640,2898,4267,723,3234,923,3925,2101,1331,3078,2371,2285,3128,3989,1763,2193,1591,2490,1173,60,2498,2850,2446,3053,2297,2607,5688,4962,5780,5273,5507,2522,4711,4990,2058,5376,286,856,4176,2762,5500,5702,2540,2621,3426,4647,1148,1347,1131,1314,1164,5173,728,4469,6093,2391,5859,5298,2262,704,4626,1023,5471,3227,2808,5412,4057,4292,2754,5754,1117,3316,4041,1103,629,2502,4928,1228,2394,2698,5111,1015,2917,5220,3331,3455,4000,1729,3683,3276,6098,1042,1681,4364,2466,1520,4568,3238,5433,5131,3577,2606,5012,6039,970,1253,5661,4726,1068,1911,414,77,4885,303,297,646,6154,1766,5541,1371,1189,5377,4278,1861,382,4382,5435,2303,4482,426,457,3754,3211,5462,4729,1608,751,6104,4432,1584,2890,502,446,2345,2748,5309,4329,3454,4963,5009,260,5511,2673,456,1589,5022,5584,646,184,4840,1647,1126,5131,428,5672,940,3936,3915,3553,5010,4565,3131,3977,4021,4285,3594,1071,5801,1359,5004,30,3973,2219,5460,4430,1993,2950,3412,2121,6016,5122,5643,1075,2590,2710,4886,3577,2859,1111,2966,1150,2438,964,6026,2468,2517,2715,5729,765,3330,1079,2228,3468,3545,471,3567,2701,3264,5884,5381,572,5059,2046,4114,1080,323,81,299,2791,1276,3841,1236,2035,1081,2718,2102,47,3534,3324,3620,3251,5507,5818,3800,5294,4985,5747,923,3571,3821,3876,1952,706,1875,5921,2461,5542,1549,5425,5958,267,3810,1907,3287,2221,1832,1312,1783,1261,76,126,3060,5939,48,5642,2189,4381,3605,3299,166,5893,2994,3660,2937,2779,2566,5568,3724,4789,3247,5050,1569,982,5383,759,3059,1705,2935,753,1562,2281,816,2435,2975,1104,4234,3628,2429,5315,3678,5762,4485,5372,2124,2049,414,546,4076,4246,5012,1524,468,3693,4693,896,2857,376,2904,2556,1953,4565,60,2013,4975,3875,1938,5617,3406,957,5438,2293,3958,1484,3126,5718,875,2332,5667,1606,1191,3781,3796,3446,448,5217,4339,5188,524,3501,4907,4336,3905,3751,5020,4033,1057,5426,3198,2611,1720,5412,210,4724,2708,353,3781,510,2838,3781,5337,1865,1543,431,1289,4385,4975,4164,2830,3128,4134,1206,225,1230,1965,3481,1455,1413,5850,1434,4752,3262,1710,3833,4762,938,5422,1743,1723,2942,1517,133,2254,2361,375,316,4981,1542,1437,4830,2520,1984,1021,2617,5037,2904,1985,2898,5772,1077,2378,3340,3714,261,4930,4322,4703,4424,124,3385,5285,5048,1464,5314,309,218,2301,1547,3603,1465,2867,819,1164,2788,1576,3079,2570,1337,5089,4778,3388,4976,4304,4319,5824,4593,1221,4191,1992,2718,1604,274,5592,769,2790,3124,75,851,3877,1092,530,5198,3201,5124,2775,3,4161,2383,1536,5672,4773,1309,783,1406,1633,4177,3872,4857,5129,2867,2664,3781,2984,654,3793,3414,4176,5748,702,773,1285,2854,4104,865,3091,385,842,2314,5615,512,1794,1003,1636,3176,2545,3084,532,2066,1495,4170,4834,4895,1003,1641,3757,1878,2025,3413,3523,708,5716,4285,3095,4343,3046,1931,3454,388,126,1603,2995,2362,4025,149,3787,2896,1847,5735,3305,2503,3229,3314,5533,4166,4469,161,4387,1022,3505,3588,42,5414,3167,3371,4415,4738,1085,3267,1934,3674,4282,4804,3574,4649,5395,4190,555,3746,451,4313,4547,963,2560,189,4931,37,3510,87,2185,3809,933,2767,884,1227,3633,3843,812,4429,4364,1441,1864,4717,3263,5224,4875,707,700,5536,3170,5135,3578,2086,4363,3059,1984,1554,2663,1196,3298,1571,1411,1165,4447,3561,2366,2034,87,1143,4439,210,4310,5538,4616,6,1772,4783,2946,414,2584,5210,1025,711,3404,5083,2551,3288,1502,1051,3813,3460,204,238,4596,367,5326,1330,4989,740,4733,3761,2408,4898,1548,2144,3573,5490,319,3949,1812,5288,1526,2546,4758,4456,3795,4208,3495,5458,649,1529,3597,390,2420,5162,4894,2093,2886,109,3151,5462,1536,2760,3004,2945,1958,3130,3948,3244,1473,1792,4751,5084,5267,2969,2281,440,776,4263,2928,3109,1166,711,1757,109,3265,3983,2135,1498,155,1426,3924,2753,669,1743,4977,654,1594,4960,3436,882,4694,3741,751,2856,4853,4300,4957,1691,611,3081,403,2179,4879,90,2949,66,2445,4451,5222,185,1413,5180,226,3989,3600,4768,3977,1856,5118,2549,4162,4556,2640,3914,1370,3473,3082,2389,1933,4091,3398,3734,1370,2140,750,2150,3855,1162,3168,1932,4806,3527,3677,513,2563,5249,2604,1874,2884,1605,2274,383,1658,497,5190,478,887,1744,1025,2079,4786,1703,3272,1249,4068,4003,4368,562,3547,2232,263,197,3128,4529,3080,4786,1097,1397,4282,2296,30,554,1084,67,4782,4529,75,4546,80,5224,4775,3563,5196,4010,172,932,113,3696,1205,2265,2618,3388,3274,1272,3164,3200,4832,142,3151,5164,5296,1539,265,3774,4363,4674,816,2421,819,1632,2274,5384,1074,3691,4176,528,981,3411,790,4499,2782,2637,2111,1215,1871,444,1171,4537,3823,1670,1027,1296,1393,1064,155,962,1250,2874,1301,3062,3141,1786,5208,3973,1461,868,5279,4186,3747,1666,4056,3110,2385,3159,2976,995,340,687,5358,3822,633,3137,2696,5155,2200,569,2138,4319,3429,2764,2934,80,3582,5316,1963,2962,3841,1967,4806,22,3860,5122,4794,411,251,914,2241,706,2203,3870,813,3489,783,1565,2871,5001,227,86,1761,1624,3348,4396,408,2115,2575,22,2208,1334,165,494,641,4771,4517,3610,3679,2803,319,2271,4042,3064,2977,4107,195,907,216,4423,2086,2654,851,2056,3614,4678,2685,1219,1244,3872,2353,1152,3849,3687,1481,579,3139,2405,1961,4762,70,160,4468,4725,294,430,2040,3323,3586,4,4552,1299,2402,1934,1915,1,3655,4963,893,2540,4594,1397,1476,5054,5142,734,1819,1123,2029,1901,3689,3334,3562,4981,5191,1369,3588,4361,1222,2942,5024,320,4575,2155,2337,216,1247,437,3511,959,580,1176,4508,3991,22,1327,1731,2373,4899,4983,841,2357,4599,3854,1099,3858,2883,1704,2832,2354,1771,1332,2214,2761,5166,3053,5202,1604,2112,95,240,1056,4488,4809,2322,3963,2355,2447,1603,2069,143,2800,4679,974,2040,79,1094,4784,737,2585,3240,727,2774,1837,103,2944,3641,3689,4992,322,1987,1789,179,360,3072,3274,4578,2695,4302,3027,1184,2354,5008,3689,3602,4087,3095,549,4530,7,703,704,792,3197,3684,3822,1504,3434,3071,1184,1135,602,4392,2046,4748,1085,2401,3083,1056,4151,2270,4314,3768,3845,4697,4479,163,4656,1777,3279,1625,2859,3466,3498,4364,733,1348,4250,1443,1076,3826,4510,300,3848,72,2614,1710,3959,2449,2448,2809,1036,4924,5057,1145,3253,408,3367,1667,4135,1069,2108,4435,406,2011,2424,4250,3131,1406,3799,4075,601,775,3055,4119,2330,4946,2723,5010,1443,1357,3770,2498,4532,2543,5025,1474,3787,2154,3190,868,2213,3391,247,819,2874,3216,3736,4225,570,164,2641,2219,4024,3068,100,3438,3146,577,1918,1213,3577,3601,1396,4072,925,3212,3179,43,872,2600,2675,491,1559,3883,352,3664,4511,3501,2722,694,4883,817,1836,4346,331,4549,3580,4325,60,3241,764,1725,4643,4747,2137,1772,2557,972,2240,192,3523,2795,2717,2850,947,2951,3977,4663,49,527,3856,3427,4868,443,3322,4703,3251,2277,3132,4692,4221,3464,997,2032,3999,4156,569,1225,4882,4579,2516,16,4741,3643,1783,3780,2573,3056,2333,263,2164,138,4716,2705,908,901,2532,3741,2405,790,1463,1883,4931,131,4052,4021,1210,4110,2440,3718,2600,4019,4768,1532,3041,2735,274,3647,1515,4875,1562,970,614,2454,753,4454,363,3339,482,2615,901,4650,2447,1954,2651,1997,3452,1926,2902,1580,4357,3714,2384,4788,2202,75,4716,3337,1474,2036,530,4356,29,1428,2038,2086,1097,309,2617,3562,3372,1470,2993,4520,4489,3436,3697,145,2047,1197,1936,4006,39,4435,1026,2398,952,984,2405,1632,2250,2546,795,1530,476,3194,3063,3721,1199,2253,2582,518,2061,2708,474,3078,3068,364,2459,4281,4405,1164,594,94,4209,912,4492,2820,332,2230,1248,1934,3849,872,3777,4505,1041,2495,2439,261,2328,830,2621,2789,3045,3210,3163,3362,1469,1053,4346,3857,1352,1333,3879,2368,3756,815,71,1822,714,43,1726,1452,1025,515,3457,626,3590,3489,1406,4779,878,4676,1603,668,829,273,3239,3174,29,659,1300,645,4756,1839,2182,1885,241,1039,3403,2783,392,2973,2056,2753,2476,1906,4509,3104,376,1031,3203,785,2304,553,1551,1204,1283,239,3156,3063,1976,337,3138,4613,2315,3123,2938,2236,708,1522,2793,3819,2071,4620,3185,4307,4624,4343,1642,4276,176,2738,4638,676,1903,786,2637,3065,2024,1763,3385,322,3631,4213,2819,3989,3371,1893,3877,637,3597,4598,4376,387,3051,2813,744,4309,394,2866,730,3718,1717,2946,4245,651,3762,3050,0,1458,3963,3415,4425,1986,4280,4710,4085,1398,2594,3087,452,3270,4427,3281,2753,3777,545,644,2877,3347,987,3174,4038,4107,594,1648,4022,4643,3621,2668,58,2392,2684,2673,4037,1599,1343,4242,3563,1122,781,4089,1536,3328,2591,505,797,1758,3047,373,2001,2724,3369,3393,615,2524,1048,3892,346,260,402,2022,2214,3212,2063,1320,4261,1853,3139,1114,4469,1591,3381,2520,4597,4590,1264,3229,3856,3150,1038,4504,1927,2231,3363,3919,1749,3474,497,4380,438,579,167,2872,2060,148,1620,1262,3307,1631,2696,733,661,4216,2160,2565,1828,1563,1877,3948,2528,2502,1734,5,3806,335,3900,2419,3396,2695,3153,349,2396,1989,314,718,4020,1657,2548,1181,214,2557,3881,159,1119,3881,1706,4215,993,43,112,3490,2637,4301,4306,60,3831,789,1718,605,3280,992,137,2690,3338,341,3545,3922,1711,2752,4516,607,4137,3573,688,1471,588,1378,2169,3481,4506,4133,4512,4109,1638,1223,659,1207,1888,4486,4301,4482,332,4321,3206,4260,2012,2105,996,408,3348,1717,3276,262,140,412,1602,2979,4237,3127,2293,3834,1810,2925,2418,2968,1017,2004,1779,1061,2525,497,4126,545,3821,1920,3255,3810,2605,4285,678,277,4173,965,585,1258,1361,4401,3951,4456,3786,3961,2792,1229,194,2548,2631,476,1169,3838,3325,4080,4355,3215,1869,4262,2822,3180,2422,307,167,2788,1316,2397,968,1591,3901,262,1924,782,20,2572,3827,3392,3561,414,4254,2789,4419,1035,4252,2696,986,3049,2260,133,4349,401,539,366,2547,4147,1198,1140,384,631,3079,1441,1060,1117,3176,1843,4160,2714,4092,376,1156,741,2497,3831,1358,3441,3931,3451,3327,1592,2602,364,2257,27,1361,3531,2248,3429,138,2512,1988,3561,858,1841,1756,1849,4340,4239,4278,2001,3666,458,169,3341,3927,2404,4129,3864,539,2603,3001,2949,3921,805,3017,1572,399,3446,2904,3631,3457,2851,4286,2619,322,907,4312,3515,1033,355,1322,122,2618,3325,3803,4126,3016,3469,3521,1262,3768,3700,1020,1664,1858,2281,2782,783,935,363,2794,2692,3260,521,2448,2891,2747,1136,3515,2623,88,4012,3487,728,2291,2591,1508,186,1763,3193,1108,88,4300,2931,2847,86,2426,262,1719,1378,4282,1373,478,178,4034,2563,1684,1302,1417,1611,2212,612,3545,4159,2324,774,3197,285,1157,3374,302,3418,3138,2663,3042,737,2664,2997,1424,624,1747,920,3714,14,3892,2354,2155,1505,3876,2373,3940,208,378,531,2585,2513,4116,2085,3984,4212,2530,645,2048,283,3222,2721,183,3431,195,3452,3749,1000,2885,2519,2675,1538,2518,1158,3754,1368,1047,2861,1496,3555,1340,1955,2957,2074,2115,3301,1932,4097,853,2476,1885,3228,1681,86,2643,269,4072,2526,1315,3416,4111,425,3411,3492,839,1684,2889,581,311,3194,2502,1540,104,3428,2267,1428,2449,3585,3067,1774,2524,1119,2133,237,1912,3136,3702,184,451,3409,379,2757,4097,3716,1921,146,3627,2209,271,155,877,753,1013,2740,1750,2293,2283,3725,86,32,920,2158,3592,1226,2840,3860,86,2058,2403,2490,3471,2942,3633,1384,1735,4019,800,1540,3291,3318,1954,3815,932,3856,3286,522,2026,3434,473,2357,644,1599,3535,2112,2328,2241,3311,1488,3429,4024,440,1130,15,418,4059,2648,2023,2692,776,2076,282,1195,887,2881,3428,1807,1656,1773,1431,1506,1898,1358,643,2337,1685,2290,2847,199,736,549,1647,2582,3515,2088,549,2931,600,3749,2078,1173,3812,2603,3161,429,3630,1369,2959,3782,601,1677,856,806,3557,3743,1514,3288,2007,3515,559,1036,1876,3839,591,4023,2487,2697,3585,1049,1280,16,1980,458,3403,3311,1091,4004,2745,3196,1222,1551,3445,3436,1038,2988,1168,2339,21,3149,2114,554,2858,781,2744,2035,2107,2469,3645,3125,2294,3248,821,2668,663,3864,2684,174,2644,817,2953,2370,3534,2541,570,1473,745,1470,3541,2035,763,3457,1060,1633,3849,2901,2042,1781,2308,2749,2445,1342,1312,198,1090,370,469,1522,2256,642,356,532,2932,1472,990,3689,101,1992,2437,366,99,3773,2517,997,896,1380,1697,750,1376,1045,3678,1852,1249,66,1025,2276,2272,2067,1261,957,3704,2174,1852,3159,3820,137,3568,1843,627,192,3581,1479,1243,564,843,1348,2161,1022,637,2386,1400,1908,3380,2624,71,813,1257,3929,2481,905,3122,136,2505,3669,3149,420,2208,3611,3884,2805,2504,34,1483,91,1262,1577,1563,2689,3663,81,994,230,3539,3891,631,149,1223,2564,3466,895,1932,2483,2744,72,1518,3444,997,538,516,1596,923,2575,703,882,1838,3655,1141,395,3111,1250,2812,3497,1716,1684,653,3203,2849,482,216,2107,532,3042,2134,3701,2378,1312,3724,12,595,2399,3756,1612,1148,1471,379,3812,3322,159,2548,3704,1169,546,472,82,3272,2556,2018,2249,205,1908,905,345,2124,723,465,354,3762,1144,2341,1062,1783,3772,2397,2432,3100,2633,3049,691,2321,3703,1932,517,1222,1652,1648,3130,1749,1680,1089,1235,3189,1526,761,2107,1971,1361,1487,3027,3075,2878,74,2139,2916,2502,2928,1107,140,3213,2546,1086,630,2703,466,2096,1360,3192,3267,710,401,907,2983,992,3705,2449,370,2838,1,142,3269,3379,639,1254,3205,1090,479,3130,3368,729,3117,1624,1121,3337,2088,1117,2666,1945,2215,165,1239,1927,2216,1966,3573,2286,1893,1751,484,3654,2075,720,1792,3597,573,2495,781,2678,3464,1898,3350,2383,1131,3687,2459,36,982,1824,1386,2321,3460,103,1388,3161,872,54,3057,2325,2823,2929,1363,3440,1111,1997,3521,2973,3313,1025,324,715,36,743,3211,3166,1878,2823,246,2301,767,3643,376,2536,3530,1599,1324,2479,116,3387,653,3174,3465,654,1327,1748,278,1413,1245,1030,550,577,717,1783,1676,144,2746,2105,2490,414,2819,3256,1718,1435,3524,1097,1124,2958,2480,708,1594,1879,2161,3121,2874,699,2141,2823,3235,3228,2923,169,1802,3108,3602,117,3548,402,1588,2747,2438,3073,3530,2823,1338,768,1803,2321,670,2181,1364,1395,3480,2242,962,2197,533,3372,2354,3208,887,626,1194,416,3587,176,949,1356,1640,2916,1423,524,1691,3518,3436,1714,2972,2112,1153,1675,1775,1326,3120,1003,880,580,2074,1279,2533,65,132,364,2870,1444,176,1789,369,2810,1712,1747,1139,2749,179,2566,2186,408,2577,764,2291,1195,1028,2866,3313,1803,1748,3324,645,2380,1399,13,2784,2345,2083,3307,513,2797,1060,1689,2322,1076,2659,1009,697,713,2913,1067,181,1464,3474,2761,1226,319,1622,2707,623,1140,745,1608,2081,355,3090,3410,2906,1496,3462,2888,1571,2032,1036,628,910,620,27,1172,3392,1179,3188,1999,3056,2769,2453,2609,2524,1448,770,1137,128,17,2899,2008,1638,1383,293,1300,190,1860,1623,2438,1292,1264,1457,1271,677,625,1392,863,737,2278,3049,3248,2483,2987,2595,82,3441,2363,3167,5,1392,807,1101,2122,16,1614,1813,2831,2000,2769,305,1665,2113,1458,2595,2323,2355,1938,2334,3090,812,2765,459,2663,2243,715,1483,2196,3141,249,2127,2437,1667,1474,2073,2788,1739,3360,974,693,3168,1641,2460,2567,2464,1867,1729,1158,412,1473,1859,761,1099,836,242,207,16,141,251,719,456,2378,3205,34,585,3094,3175,2670,634,3078,2263,1886,737,1832,491,2330,599,744,1577,883,1365,306,2532,2194,2227,966,2528,1933,1309,794,1885,122,2330,1210,1718,562,3003,1117,786,760,1962,562,2157,1851,582,216,218,1337,2134,2731,2681,416,1802,2647,2024,1039,726,1630,2834,1115,2941,1638,252,2293,1449,490,2093,2788,3022,951,2385,1328,1211,2714,1661,2219,2195,3075,1416,2740,2474,2721,2709,1061,1481,333,2463,1438,2138,2419,2461,768,2169,2251,1869,872,1877,1314,1317,2200,1520,893,2137,1986,2654,407,3079,623,2362,963,696,2428,2292,2952,1936,3208,1204,1475,1004,2009,1007,239,1479,1509,2716,1093,2704,1948,1877,299,1559,2462,410,2895,2868,1598,1479,699,1788,2628,972,233,1206,1897,117,475,1724,3070,1862,582,421,2547,559,2631,1664,2244,648,1992,611,2242,1133,214,3162,860,2577,2184,3149,1744,1581,938,509,1337,421,237,2646,1224,2274,80,948,84,1603,3196,1490,1999,1352,1524,999,2712,48,1197,3035,2760,2500,1145,524,2810,506,2073,1482,194,652,1270,3114,1341,2290,637,2682,3130,1953,2167,1643,1766,2397,1448,495,1712,2984,1068,703,1779,1369,2870,2738,2367,1169,2289,2390,1630,156,224,1711,1204,2708,3003,671,2414,1298,652,451,2835,1,429,1534,449,2372,2622,1459,1382,1288,1008,233,1002,3008,1812,2545,1896,3080,713,1331,1198,1082,1744,1866,2621,2296,732,599,74,1832,175,2756,1470,117,272,1712,595,2417,366,2800,2202,669,539,1639,2887,4,399,44,2030,2910,705,698,2573,1258,779,1413,2023,1096,155,2507,2592,365,2439,2333,346,1048,2507,1458,674,102,1048,3043,1171,2543,2833,2680,1152,311,1045,1401,2165,1311,2612,802,778,1298,2548,662,275,2177,951,2743,2600,963,1761,2854,755,1654,2548,2294,1506,1757,2468,1278,2322,1270,2991,713,2851,211,2138,814,56,9,656,1083,2839,161,1900,1651,1159,1255,1644,1239,1796,2034,2294,1645,612,1504,1509,2947,629,1846,2498,2896,523,152,2208,897,2092,673,696,187,309,660,951,365,1362,409,1672,2247,2656,982,2754,1184,2375,459,2471,2001,2672,2181,2944,708,1654,479,1556,1075,2918,1193,1859,2404,920,2862,2817,1645,2043,1171,2243,1247,242,172,521,2534,1022,1042,1061,2596,667,2183,929,1098,1412,662,1498,2368,919,211,1509,1113,1267,1288,2015,624,1931,2569,1879,342,392,496,54,995,1250,2305,2657,77,1164,433,2925,1840,1192,65,2778,834,922,1662,2488,485,2787,2741,1970,1921,1845,2194,1970,668,279,2879,169,870,1226,266,2104,2083,1695,1505,2117,2633,1087,729,860,1849,415,707,1298,2598,140,1221,316,247,734,463,2123,1434,1015,2262,1793,1098,998,2729,1432,987,447,114,1345,982,1769,395,2097,2462,284,2832,2624,1837,1978,1765,34,1053,2614,883,552,131,874,2544,2635,2086,1184,627,1864,543,180,363,927,2857,2644,2534,1154,1728,128,1438,1750,1500,2243,2299,1001,1620,1392,2192,2788,1681,1185,10,378,906,2135,826,458,2500,1430,1558,1542,2466,1979,51,1961,814,2411,2650,1343,1200,1204,204,2409,2692,81,1164,395,2057,1865,1396,1289,1180,798,210,139,275,2153,230,1110,1246,1022,188,569,711,719,638,2479,2755,2178,1261,1215,2037,2679,2316,2700,1472,56,1153,74,1335,2196,877,559,2240,502,965,2093,25,2051,486,1154,1318,709,1592,523,291,2495,860,168,2122,452,2404,377,797,2747,2511,1769,15,884,804,651,1351,1971,2631,658,676,1084,998,2458,2117,410,567,110,1061,1436,1912,208,362,2172,21,1855,836,760,1484,2385,724,608,2702,69,2099,2652,167,1985,910,1646,442,1685,2364,1974,2146,244,1658,691,402,1285,2608,416,89,1598,1004,488,1442,1751,367,863,1495,2363,2184,295,585,1593,1729,212,1106,2324,1523,1846,1416,2261,705,2177,1245,499,1726,2226,1483,1590,2343,1817,1972,1769,711,758,1800,616,398,1518,2461,1712,1252,2467,781,1217,1465,12,132,1338,2117,669,562,1883,1686,960,1585,52,2127,1407,544,1463,1270,609,631,2631,1849,2246,2228,1147,1777,1756,1808,2012,1441,1527,678,2240,2483,1647,797,1481,467,1630,1491,2518,1749,1688,2028,1122,460,466,1521,2208,2251,2422,935,864,792,1009,1966,1720,552,701,902,290,1805,1698,1581,2405,450,1778,2412,2536,1208,1276,623,2068,1416,1961,1519,464,319,1681,36,1601,998,538,1848,444,2232,1788,172,2447,1297,1646,1739,1738,1750,1162,420,1648,1075,2158,2202,1687,2180,242,2055,298,2450,2375,738,1848,1836,1466,1920,1955,2312,2361,2231,42,1497,584,288,1812,253,2340,1424,681,358,2320,1269,1190,1575,784,317,1180,1131,315,1244,835,320,609,2494,2151,698,2445,123,1682,9,1137,1169,1607,2477,1333,1049,1905,916,13,213,1038,2105,1639,2287,2265,36,2364,1782,1926,1073,2461,350,944,1713,936,2372,1461,1448,353,192,1620,1725,2047,856,834,1123,685,272,52,1247,248,1848,1793,764,115,1564,2207,1737,911,388,2209,316,1505,1024,654,919,1840,307,1426,1703,387,684,22,2292,1649,2053,634,2060,1034,1570,362,1986,2103,2335,748,838,2246,1827,2128,1680,1507,1362,519,1230,78,474,1652,2309,846,641,2201,779,949,70,521,1232,315,325,609,2079,658,1689,1095,113,480,40,953,705,1429,1222,965,1529,1332,868,667,2106,1246,457,2268,538,1941,938,1064,1451,2175,1271,788,2157,883,2162,528,1381,1965,1440,1660,1692,1303,974,13,2036,1084,1728,2256,1317,1434,441,2006,1919,902,36,1307,979,82,65,1661,2279,1424,462,756,1046,1388,368,1817,1190,561,2011,142,1488,1554,509,1889,1008,2237,391,364,63,879,1895,342,457,2008,2035,700,182,616,1200,1360,326,1373,2240,1456,1796,1933,1506,1650,1394,2088,1571,1986,1728,1181,21,213,1147,1186,26,1609,1302,717,835,1222,1599,524,1784,1405,997,1385,536,2181,1741,1063,630,987,1674,1433,1927,1364,345,385,2125,123,1995,200,1063,1213,1296,1656,504,1799,163,214,93,195,1783,2018,1462,1999,297,1639,1563,401,1184,1426,540,1256,1939,1094,1900,1025,1356,1753,994,277,2130,1763,922,1395,543,1230,864,1863,1437,1284,197,171,1399,573,1354,2064,2011,296,1921,326,2014,1651,2032,494,1604,1831,137,2025,746,1881,1182,1760,642,92,2008,1968,1510,161,1282,425,1757,13,1177,1899,1546,428,1700,594,1956,587,425,728,1372,1348,1811,1686,1773,924,963,1364,1526,1758,1846,935,1364,823,780,322,151,1552,905,1175,116,1900,1400,1548,1155,1658,1209,1362,1785,874,1963,931,104,831,1393,494,1300,968,23,1101,905,549,446,736,1015,2100,1230,812,388,250,1151,1072,64,1619,625,1820,384,1194,1239,1677,1761,1709,943,1225,911,1248,1462,2030,1682,281,1020,1730,134,848,224,1144,923,577,854,925,482,1718,787,1471,1450,1899,1045,1802,256,1115,871,1882,1268,1183,519,1369,1258,225,1431,1169,1720,1715,1896,1716,1261,1990,236,413,1353,1708,1356,731,862,1072,1305,1617,526,112,2019,841,1478,102,328,1037,406,1075,9,515,210,632,691,1679,1901,91,338,1352,224,1430,345,354,2031,1315,2014,1494,728,105,1123,1311,473,2032,819,459,112,2040,424,681,1033,827,119,836,918,1608,480,273,1233,216,139,1342,1101,276,1949,1834,183,1273,308,647,567,922,1698,1774,107,75,1981,1369,311,235,1691,53,414,1360,975,1405,169,736,36,2003,26,115,696,1086,408,1253,18,30,990,1425,766,1258,246,1434,588,1214,154,214,594,1962,242,698,167,1120,1883,903,1062,1855,1968,390,132,62,660,1825,201,1257,402,484,1263,790,488,282,512,947,53,1030,1184,215,1243,955,558,1304,429,1351,178,907,1927,1590,1840,1499,668,1167,855,430,975,1008,221,159,1770,506,1203,1641,1830,781,945,536,266,544,1220,64,656,1752,438,740,653,1810,1279,493,1530,232,1031,1360,1556,57,1151,1205,887,1811,1072,1646,1144,652,1838,1162,1840,424,882,926,775,906,991,1386,1763,115,120,1608,819,863,960,1317,671,899,1129,1650,37,1077,1643,1747,410,48,833,320,944,533,1467,348,205,942,1245,822,1271,863,279,875,1299,144,877,1080,359,383,177,313,414,749,417,746,863,1468,1534,1313,1077,967,1728,1294,708,1661,150,327,1268,328,334,1614,1379,1039,393,1228,124,709,447,185,133,1395,492,1457,1772,360,1699,1149,55,1159,964,1168,200,1290,1482,1271,386,853,158,111,895,1183,576,1508,1162,194,532,1433,906,1411,36,1629,1480,898,1101,1293,1408,1665,733,178,1553,1696,1286,1222,925,1576,334,1724,754,108,28,352,264,1516,10,1321,685,285,744,736,52,512,1657,1110,1483,513,327,760,1043,1738,1703,302,1234,1143,1152,1273,654,495,1731,683,1467,462,1036,27,1394,801,1206,471,1144,995,488,757,1383,120,875,362,801,607,510,685,1680,892,856,580,1498,60,1341,400,1610,1455,963,510,855,965,1211,1110,43,1523,1175,386,1503,1021,274,257,1404,813,306,746,1066,950,157,112,248,810,213,479,156,598,1508,231,1246,1280,914,1289,243,575,925,683,1083,1643,472,156,1215,327,128,1621,1021,1401,1533,1081,14,927,1351,144,1125,1563,522,908,1595,1241,838,427,316,206,1142,882,705,1306,667,200,126,758,1532,482,1573,523,634,1554,1341,280,1105,1396,853,1394,95,595,342,1328,74,999,380,975,291,189,1035,1342,320,151,458,1582,750,296,509,1440,502,1286,1381,1150,410,34,808,293,537,1573,812,1239,145,321,108,279,126,1201,1314,1214,1410,479,819,952,175,954,447,110,1453,1357,730,584,1231,713,1463,363,599,1197,548,235,916,451,683,541,326,423,1323,1288,914,864,805,1062,1479,150,260,738,1535,1550,607,437,479,298,453,707,87,1173,481,913,1014,863,1106,251,185,737,1376,108,548,522,626,1226,361,349,1420,503,342,1183,516,63,1002,190,244,103,950,1113,985,165,1314,1450,1033,568,343,523,1112,554,439,336,1482,528,1272,166,1463,992,1408,1373,1270,659,1470,1260,671,1467,203,602,425,889,793,180,1412,574,1148,331,1344,603,547,302,1184,813,811,1359,267,158,1010,983,870,196,1328,164,1275,1253,761,585,246,1038,452,864,612,1288,611,752,435,762,1088,911,934,681,625,303,1037,592,993,923,334,178,720,1027,187,335,318,788,252,481,496,951,188,1288,200,748,1256,1155,1212,791,983,504,1407,1175,711,986,128,1278,1123,1297,1095,892,849,673,20,1186,595,68,738,1019,1181,1242,1175,1174,1305,579,446,254,602,637,12,189,313,202,500,800,982,607,480,381,1108,478,257,631,725,48,1198,707,1322,1190,38,738,215,614,822,1313,85,818,913,378,1096,1255,1030,1157,1085,568,777,871,892,461,362,641,262,576,637,160,981,1336,872,781,958,49,1031,49,801,1305,672,60,400,1243,933,1240,765,1064,819,512,490,779,104,633,1126,1003,616,1238,525,940,629,299,854,4,170,559,866,1101,802,463,346,315,1,1267,230,413,238,641,40,959,619,402,577,1184,840,904,1269,696,1062,228,681,567,1050,567,1005,854,982,387,1046,186,1065,1099,344,918,601,1045,462,246,471,139,412,778,650,1241,907,1082,171,271,302,624,663,859,84,383,727,72,316,451,989,1133,1214,829,577,810,987,470,876,1071,203,913,392,1007,825,136,1077,1095,225,659,984,1047,765,928,845,424,998,1218,1133,180,793,308,211,484,517,260,1162,547,369,422,924,848,1005,1158,929,533,203,105,708,197,1099,602,850,114,225,274,323,800,404,776,629,918,532,459,875,329,408,193,666,515,1004,1052,750,629,874,31,950,812,467,658,164,195,698,588,115,372,271,972,1019,876,112,170,924,99,113,452,970,235,962,759,346,580,699,377,948,441,907,701,673,45,193,1130,1004,502,1044,721,872,436,395,654,765,346,487,39,638,574,622,962,172,158,1055,388,687,800,143,150,1047,994,984,1059,557,20,70,878,787,868,594,611,901,923,962,526,825,489,241,900,52,835,147,679,627,814,494,971,973,767,734,1014,23,550,693,632,547,1031,117,848,378,963,383,610,282,915,315,192,937,254,777,25,97,350,137,489,196,595,190,405,669,313,645,109,834,583,74,840,699,689,642,529,1006,48,806,473,739,70,337,173,166,430,719,469,424,873,1010,999,999,606,582,490,267,55,117,95,433,633,807,498,354,340,677,463,969,655,683,916,280,460,269,5,563,692,81,124,286,518,469,413,245,430,887,738,160,89,284,881,452,622,221,873,502,928,20,416,592,209,871,266,723,356,776,859,100,883,819,780,51,946,894,512,434,583,579,651,207,649,685,839,136,686,72,558,670,54,572,77,318,532,744,750,289,716,197,131,891,747,392,857,560,661,541,478,915,76,477,705,612,409,675,713,226,500,312,567,795,353,711,746,440,308,616,92,258,399,264,48,638,866,760,670,73,123,626,489,662,224,521,697,784,319,387,619,601,311,539,293,717,714,438,711,106,448,488,523,275,16,726,806,781,272,545,556,590,388,711,649,266,394,766,552,318,410,580,451,350,432,181,845,352,575,401,786,508,359,567,429,798,138,47,608,484,289,632,105,616,2,759,51,673,152,639,550,704,762,636,313,223,597,125,264,123,459,668,211,786,236,253,335,364,143,274,368,235,721,71,278,464,796,584,193,12,708,99,136,613,299,312,260,499,64,749,389,575,317,660,609,696,248,406,389,465,336,155,666,523,649,319,244,424,217,246,144,589,478,24,123,63,367,62,303,474,547,199,750,586,235,665,385,587,31,526,174,225,676,61,600,729,308,266,287,489,609,70,577,400,108,614,298,321,472,446,356,617,596,76,93,620,556,178,699,711,119,263,217,225,702,634,367,29,94,81,76,376,141,219,441,612,584,283,617,329,13,588,345,691,413,378,632,344,175,56,358,661,16,16,60,661,183,180,324,503,113,511,347,183,262,356,214,670,584,310,132,282,317,300,339,46,210,190,44,180,290,136,288,53,383,410,523,49,90,484,526,187,58,354,601,235,318,8,179,191,528,339,503,480,89,537,180,33,401,49,96,28,340,491,430,295,86,558,65,34,335,3,164,44,487,111,479,300,45,607,18,369,35,275,297,519,418,370,208,326,77,292,168,244,359,513,121,164,245,283,433,306,352,492,24,323,333,482,126,575,437,422,285,549,131,261,571,174,51,166,101,390,441,20,424,166,489,470,556,246,103,400,98,5,268,300,152,461,523,230,131,423,466,55,35,346,138,59,379,201,482,312,133,51,35,220,490,136,191,259,100,96,417,281,198,277,510,302,361,475,428,12,44,448,309,488,477,348,233,381,262,78,187,285,87,395,75,474,85,283,61,365,338,421,216,75,467,368,335,84,447,205,482,359,215,263,66,168,406,290,275,151,165,370,76,316,293,195,164,355,46,291,142,393,118,27,368,36,413,407,234,419,387,87,243,21,267,151,420,449,179,120,345,288,214,275,37,312,4,377,156,334,55,178,407,98,427,292,259,336,382,161,327,422,220,302,54,378,141,325,150,411,109,230,142,188,263,117,307,69,38,220,181,252,21,170,127,217,152,231,266,97,388,156,385,238,94,154,294,144,323,371,356,293,230,155,1,215,203,171,110,317,303,294,134,62,191,297,141,170,308,147,111,302,74,259,357,99,45,2,6,246,1,86,317,301,337,256,47,221,47,199,280,323,56,16,75,112,158,107,192,98,271,26,332,179,307,149,183,3,132,147,215,250,235,238,275,6,207,194,315,100,305,280,220,96,38,164,140,242,256,242,253,285,166,146,59,56,86,269,78,45,279,16,11,179,115,15,120,245,207,21,73,159,122,221,184,86,167,142,137,188,262,37,201,116,164,226,223,212,7,200,181,158,244,96,189,172,187,239,112,44,203,96,214,29,166,99,44,190,62,97,27,55,127,106,142,160,29,235,71,146,117,187,91,167,11,176,150,108,215,180,62,169,134,209,62,3,53,120,108,34,12,114,127,46,108,117,1,81,121,159,25,106,8,52,143,146,195,12,16,117,126,9,184,42,180,77,75,135,59,39,38,19,96,182,109,61,167,50,114,98,73,4,13,83,102,52,35,9,142,20,133,106,28,13,2,23,22,130,92,36,18,47,62,138,73,22,104,18,14,84,35,99,64,74,76,55,5,12,85,102,74,6,134,84,73,49,43,5,4,85,81,32,91,120,80,80,0,28,35,75,60,57,110,12,79,98,83,107,84,62,14,44,7,55,18,63,4,51,82,1,28,14,32,79,51,22,74,41,72,55,25,78,81,79,36,4,66,70,29,5,26,64,9,46,49,39,28,24,25,26,39,46,38,18,14,40,25,33,37,40,45,8,16,11,8,36,20,40,28,23,41,35,25,0,29,31,16,31,6,5,2,21,27,14,3,29,12,24,3,8,12,18,13,22,19,6,7,2,13,2,3,4,9,6,11,9,9,6,3,4,3,3,3,1,0,0,0 }, diff --git a/Algorithms/0321.create-maximum-number/321.100.png b/Algorithms/0321.create-maximum-number/321.100.png deleted file mode 100644 index 05da1f434..000000000 Binary files a/Algorithms/0321.create-maximum-number/321.100.png and /dev/null differ diff --git a/Algorithms/0321.create-maximum-number/README.md b/Algorithms/0321.create-maximum-number/README.md index efd7f3048..826042085 100755 --- a/Algorithms/0321.create-maximum-number/README.md +++ b/Algorithms/0321.create-maximum-number/README.md @@ -1,7 +1,5 @@ # [321. Create Maximum Number](https://leetcode.com/problems/create-maximum-number/) -## 题目 - Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the same array must be preserved. Return an array of the k digits. You should try to optimize your time and space complexity. @@ -34,9 +32,3 @@ return [9, 8, 9] ``` dits:Special thanks to @dietpepsi for adding this problem and creating all test cases. - -## 解题思路 - -见程序注释 - -![100](321.100.png) \ No newline at end of file diff --git a/Algorithms/0321.create-maximum-number/create-maximum-number.go b/Algorithms/0321.create-maximum-number/create-maximum-number.go index f3dbcce2d..a5311bf6a 100755 --- a/Algorithms/0321.create-maximum-number/create-maximum-number.go +++ b/Algorithms/0321.create-maximum-number/create-maximum-number.go @@ -1,92 +1,79 @@ package problem0321 -func maxNumber(nums1 []int, nums2 []int, k int) []int { - size1 := len(nums1) - size2 := len(nums2) - +func maxNumber(A, B []int, k int) []int { + m, n := len(A), len(B) res := make([]int, k) - var temp []int - - // for 循环作用是,每次 - // 从 nums1 中取 i 个数,得到temp1,在保证顺序的前提下,其值最大 - // 从 nums2 中取 k-i 个数,得到temp2,在保证顺序的前提下,其值最大 - // 把 temp1 和 temp2 混合成 temp,使其值最大。 - // 记录 最大的 temp 值,就是答案 - for i := 0; i <= size1 && i <= k; i++ { - if size2 < k-i { // nums2 不够长 - continue - } - - temp = combine(selecting(i, nums1), selecting(k-i, nums2)) - if isBigger(temp, res) { - copy(res, temp) + for i := max(0, k-n); i <= m && k-i >= 0; i++ { + temp := combine(choose(A, i), choose(B, k-i)) + if isBigger(temp, res, 0, 0) { + res = temp } } - return res } -// 从 nums 当中挑选 k 个数,其组成的 []int 最大 -// 不满足 0 <= k <= len(nums) 会 panic -func selecting(k int, nums []int) []int { - if k == len(nums) { - return nums - } - - res := make([]int, k) - // idx 是 res 上次获取的 nums 的值的索引号 - idx := -1 - for i := 0; i < k; i++ { - idx++ - // res[i] 是 nums[idx:len(nums)-k+i+1] 中的最大值 - res[i] = nums[idx] - for j := idx + 1; j <= len(nums)-k+i; j++ { - if res[i] < nums[j] { - res[i] = nums[j] - idx = j - } +func choose(A []int, k int) []int { + stack, top := make([]int, k), -1 + n := len(A) + for i := 0; i < n; i++ { + for top >= 0 && stack[top] < A[i] && + top+n-i >= k { + // 此时,stack 中 有 top+1 个元素 + // 需要保证消去 stack[top] 后的 top 个元素 + // 和 A[i:] 中的 n-i 个元素 + // 能够组成 k 个元素 + // 所以,top+(n-i)>=k + top-- + } + if top+1 < k { + // 如果 stack 中的元素,还没有 k 个的话 + // 先用 A[i] 填上空缺 + top++ + stack[top] = A[i] } } - - return res + return stack } // 混合 nums1 和 nums2 使得其组成的 []int 最大 -func combine(nums1, nums2 []int) []int { - size1 := len(nums1) - size2 := len(nums2) - res := make([]int, 0, size1+size2) +func combine(A, B []int) []int { + m, n := len(A), len(B) + res := make([]int, 0, m+n) var i, j int - for i < size1 && j < size2 { - // nums1[i] > nums2[j]: 优先使用较大的值 - // isBigger(nums1[i:], nums2[j:]): 当 nums1[i] == nums2[j]时,优先使用后面的值较大的那组 - if nums1[i] > nums2[j] || isBigger(nums1[i:], nums2[j:]) { - res = append(res, nums1[i]) + for i < m && j < n { + if isBigger(A, B, i, j) { + res = append(res, A[i]) i++ } else { - res = append(res, nums2[j]) + res = append(res, B[j]) j++ } } - res = append(res, nums1[i:]...) - res = append(res, nums2[j:]...) + res = append(res, A[i:]...) + res = append(res, B[j:]...) return res } -func isBigger(a1, a2 []int) bool { - s1 := len(a1) - s2 := len(a2) - - for i := 0; i < s1 && i < s2; i++ { - if a1[i] > a2[i] { +func isBigger(A, B []int, i, j int) bool { + m, n := len(A), len(B) + for i < m && j < n { + if A[i] > B[j] { return true - } else if a1[i] < a2[i] { + } else if A[i] < B[j] { return false } + i++ + j++ } + return m-i > n-j +} - return false +func max(a, b int) int { + if a > b { + return a + } + return b } diff --git a/Algorithms/0321.create-maximum-number/create-maximum-number_test.go b/Algorithms/0321.create-maximum-number/create-maximum-number_test.go index 038b97164..2a41d1f67 100755 --- a/Algorithms/0321.create-maximum-number/create-maximum-number_test.go +++ b/Algorithms/0321.create-maximum-number/create-maximum-number_test.go @@ -1,7 +1,7 @@ package problem0321 import ( - "fmt" + "reflect" "testing" "github.com/stretchr/testify/assert" @@ -15,6 +15,13 @@ var tcs = []struct { ans []int }{ + { + []int{6, 3, 9, 0, 5, 6}, + []int{2, 2, 5, 2, 1, 4, 4, 5, 7, 8, 9, 3, 1, 6, 9, 7, 0}, + 23, + []int{6, 3, 9, 2, 2, 5, 2, 1, 4, 4, 5, 7, 8, 9, 3, 1, 6, 9, 7, 0, 5, 6, 0}, + }, + { []int{1, 6, 5, 4, 7, 3, 9, 5, 3, 7, 8, 4, 1, 1, 4}, []int{4, 3, 1, 3, 5, 9}, @@ -71,28 +78,9 @@ func Test_maxNumber(t *testing.T) { ast := assert.New(t) for _, tc := range tcs { - fmt.Printf("~~%v~~\n", tc) ast.Equal(tc.ans, maxNumber(tc.nums1, tc.nums2, tc.k), "输入:%v", tc) } } -func Test_outOf(t *testing.T) { - ast := assert.New(t) - - nums, k := []int{3, 8, 4, 6, 5, 8}, 3 - actual := selecting(k, nums) - expected := []int{8, 6, 8} - ast.Equal(expected, actual, "输入,%v, %d", nums, k) -} - -func Test_combine(t *testing.T) { - ast := assert.New(t) - - nums1 := []int{6, 7} - nums2 := []int{6, 0, 4} - actual := combine(nums1, nums2) - expected := []int{6, 7, 6, 0, 4} - ast.Equal(expected, actual, "输入,%v,%v", nums1, nums2) -} func Benchmark_maxNumber(b *testing.B) { for i := 0; i < b.N; i++ { @@ -101,3 +89,43 @@ func Benchmark_maxNumber(b *testing.B) { } } } + +func Test_choose(t *testing.T) { + type args struct { + A []int + k int + } + tests := []struct { + name string + args args + want []int + }{ + + { + "6选3", + args{ + []int{8, 9, 1, 7, 5, 2}, + 3, + }, + []int{9, 7, 5}, + }, + + { + "5选3", + args{ + []int{5, 2, 7, 1, 9}, + 3, + }, + []int{7, 1, 9}, + }, + + // + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := choose(tt.args.A, tt.args.k); !reflect.DeepEqual(got, tt.want) { + t.Errorf("choose() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/Algorithms/0337.house-robber-iii/house-robber-iii_test.go b/Algorithms/0337.house-robber-iii/house-robber-iii_test.go index e237f48b8..863f5a7c7 100755 --- a/Algorithms/0337.house-robber-iii/house-robber-iii_test.go +++ b/Algorithms/0337.house-robber-iii/house-robber-iii_test.go @@ -4,32 +4,28 @@ import ( "fmt" "testing" - "github.com/aQuaYi/LeetCode-in-Go/kit" - "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { - pre, in []int - ans int + nums []int + ans int }{ + // 用 0 表示 nil { - []int{5, 2, 4, 1, 3, 1000}, - []int{2, 4, 5, 1, 3, 1000}, - 1009, + []int{4, 1, 0, 2, 0, 3}, + 7, }, { - []int{5, 2, 4, 1, 3}, - []int{2, 4, 5, 1, 3}, - 12, + []int{3, 2, 3, 0, 3, 0, 1}, + 7, }, { - []int{3, 4, 1, 3, 5, 1}, - []int{1, 4, 3, 3, 5, 1}, + []int{3, 4, 5, 1, 3, 0, 1}, 9, }, @@ -41,7 +37,8 @@ func Test_rob(t *testing.T) { for _, tc := range tcs { fmt.Printf("~~%v~~\n", tc) - root := kit.PreIn2Tree(tc.pre, tc.in) + root := &TreeNode{} + initTree(tc.nums, []*TreeNode{}, root) ast.Equal(tc.ans, rob(root), "输入:%v", tc) } } @@ -49,8 +46,48 @@ func Test_rob(t *testing.T) { func Benchmark_rob(b *testing.B) { for i := 0; i < b.N; i++ { for _, tc := range tcs { - root := kit.PreIn2Tree(tc.pre, tc.in) + root := &TreeNode{} + initTree(tc.nums, []*TreeNode{}, root) rob(root) } } } + +// 创建二叉树 +func initTree(nums []int, parents []*TreeNode, root *TreeNode) { + if len(nums) == 0 { + return + } + + if len(parents) == 0 { + if nums[0] != 0 { + root.Val = nums[0] + parents = append(parents, root) + initTree(nums[1:], parents, root) + } + + return + } + + newParents := make([]*TreeNode, 0, len(parents)*2) + for _, parent := range parents { + + if nums[0] != 0 { + parent.Left = &TreeNode{Val: nums[0]} + newParents = append(newParents, parent.Left) + } + + if len(nums) == 1 { + return + } + + if nums[1] != 0 { + parent.Right = &TreeNode{Val: nums[1]} + newParents = append(newParents, parent.Right) + } + + nums = nums[2:] + } + + initTree(nums, newParents, root) +} diff --git a/Algorithms/0342.power-of-four/power-of-four.go b/Algorithms/0342.power-of-four/power-of-four.go index d3fb32597..db9a3d121 100755 --- a/Algorithms/0342.power-of-four/power-of-four.go +++ b/Algorithms/0342.power-of-four/power-of-four.go @@ -1,13 +1,19 @@ package problem0342 -func isPowerOfFour(n int) bool { - if n < 1 { +func isPowerOfFour(num int) bool { + if num <= 0 { return false } - for n%4 == 0 { - n /= 4 + // 如果 num 不是2的N次方, 那么也不是4的N次方 + if num&(num-1) != 0 { + return false } - - return n == 1 + + // 过滤 + if num&0x55555555 == 0 { + return false + } + + return true } diff --git a/Algorithms/0342.power-of-four/power-of-four_test.go b/Algorithms/0342.power-of-four/power-of-four_test.go index 296bb0649..9c1cd7c43 100755 --- a/Algorithms/0342.power-of-four/power-of-four_test.go +++ b/Algorithms/0342.power-of-four/power-of-four_test.go @@ -13,6 +13,7 @@ var tcs = []struct { ans bool }{ + {2, false}, {16, true}, {5, false}, {-5, false}, diff --git a/Algorithms/0343.integer-break/integer-break.go b/Algorithms/0343.integer-break/integer-break.go index d0889606b..725c1d347 100755 --- a/Algorithms/0343.integer-break/integer-break.go +++ b/Algorithms/0343.integer-break/integer-break.go @@ -1,5 +1,6 @@ package problem0343 +// https://blog.csdn.net/fuxuemingzhu/article/details/80486238 func integerBreak(n int) int { if n == 2 { return 1 @@ -9,26 +10,11 @@ func integerBreak(n int) int { return 2 } - switch n % 3 { - case 0: - return pow3(n / 3) - case 1: - return 4 * pow3(n/3-1) - default: - return 2 * pow3(n/3) + res := 1 + for n > 4 { + res *= 3 + n -= 3 } -} - -func pow3(n int) int { - if n == 0 { - return 1 - } - - res := pow3(n >> 1) - if n&1 == 0 { - return res * res - } - - return res * res * 3 + return res * n } diff --git a/Algorithms/0386.lexicographical-numbers/README.md b/Algorithms/0386.lexicographical-numbers/README.md new file mode 100755 index 000000000..e8a9886a9 --- /dev/null +++ b/Algorithms/0386.lexicographical-numbers/README.md @@ -0,0 +1,7 @@ +# [386. Lexicographical Numbers](https://leetcode.com/problems/lexicographical-numbers/) + +Given an integer n, return 1 - n in lexicographical order. + +For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9]. + +Please optimize your algorithm to use less time and space. The input size may be as large as 5,000,000. \ No newline at end of file diff --git a/Algorithms/0386.lexicographical-numbers/lexicographical-numbers.go b/Algorithms/0386.lexicographical-numbers/lexicographical-numbers.go new file mode 100755 index 000000000..185a51cb2 --- /dev/null +++ b/Algorithms/0386.lexicographical-numbers/lexicographical-numbers.go @@ -0,0 +1,20 @@ +package problem0386 + +func lexicalOrder(max int) []int { + res := make([]int, 0, max) + + var dfs func(int) + dfs = func(x int) { + limit := (x + 10) / 10 * 10 + for x <= max && x < limit { + res = append(res, x) + if x*10 <= max { + dfs(x * 10) + } + x++ + } + } + + dfs(1) + return res +} diff --git a/Algorithms/0386.lexicographical-numbers/lexicographical-numbers_test.go b/Algorithms/0386.lexicographical-numbers/lexicographical-numbers_test.go new file mode 100755 index 000000000..ba54ba7a0 --- /dev/null +++ b/Algorithms/0386.lexicographical-numbers/lexicographical-numbers_test.go @@ -0,0 +1,42 @@ +package problem0386 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + max int + ans []int +}{ + + { + 120, + []int{1, 10, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 11, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 12, 120, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 5, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 6, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 7, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 8, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 9, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99}, + }, + + { + 13, + []int{1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9}, + }, + + // 可以有多个 testcase +} + +func Test_lexicalOrder(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, lexicalOrder(tc.max), "输入:%v", tc) + } +} + +func Benchmark_lexicalOrder(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + lexicalOrder(tc.max) + } + } +} diff --git a/Algorithms/0433.minimum-genetic-mutation/README.md b/Algorithms/0433.minimum-genetic-mutation/README.md new file mode 100755 index 000000000..e1cb213f1 --- /dev/null +++ b/Algorithms/0433.minimum-genetic-mutation/README.md @@ -0,0 +1,53 @@ +# [433. Minimum Genetic Mutation](https://leetcode.com/problems/minimum-genetic-mutation/) + +## 题目 + +A gene string can be represented by an 8-character long string, with choices from "A", "C", "G", "T". + +Suppose we need to investigate about a mutation (mutation from "start" to "end"), where ONE mutation is defined as ONE single character changed in the gene string. + +For example, "AACCGGTT" -> "AACCGGTA" is 1 mutation. + +Also, there is a given gene "bank", which records all the valid gene mutations. A gene must be in the bank to make it a valid gene string. + +Now, given 3 things - start, end, bank, your task is to determine what is the minimum number of mutations needed to mutate from "start" to "end". If there is no such a mutation, return -1. + +Note: + +1. Starting point is assumed to be valid, so it might not be included in the bank. +1. If multiple mutations are needed, all mutations during in the sequence must be valid. +1. You may assume start and end string is not the same. + +Example 1: + +```text +start: "AACCGGTT" +end: "AACCGGTA" +bank: ["AACCGGTA"] + +return: 1 +``` + +Example 2: + +```text +start: "AACCGGTT" +end: "AAACGGTA" +bank: ["AACCGGTA", "AACCGCTA", "AAACGGTA"] + +return: 2 +``` + +Example 3: + +```text +start: "AAAAACCC" +end: "AACCCCCC" +bank: ["AAAACCCC", "AAACCCCC", "AACCCCCC"] + +return: 3 +``` + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0433.minimum-genetic-mutation/minimum-genetic-mutation.go b/Algorithms/0433.minimum-genetic-mutation/minimum-genetic-mutation.go new file mode 100644 index 000000000..806bb7902 --- /dev/null +++ b/Algorithms/0433.minimum-genetic-mutation/minimum-genetic-mutation.go @@ -0,0 +1,48 @@ +package problem0433 + +func minMutation(start string, end string, bank []string) int { + if start == end { + return 1 + } + + cands := make([]string, 1, 1024) + cands[0] = start + res := 0 + + // 记录 bank 中的 gene 是否已经添加到 cands 中。 + // 避免重复添加 + isAdded := make([]bool, len(bank)) + + for len(cands) > 0 { + res++ + size := len(cands) + for i := 0; i < size; i++ { + cand := cands[i] + for i, gene := range bank { + if isAdded[i] || !isMutation(cand, gene) { + continue + } + if gene == end { + return res + } + cands = append(cands, gene) + isAdded[i] = true + } + } + cands = cands[size:] + } + return -1 +} + +func isMutation(cand, g string) bool { + count := 0 + size := len(g) + i := 0 + for count < 2 && i < size { + if cand[i] != g[i] { + count++ + } + i++ + } + return count == 1 +} diff --git a/Algorithms/0433.minimum-genetic-mutation/minimum-genetic-mutation_test.go b/Algorithms/0433.minimum-genetic-mutation/minimum-genetic-mutation_test.go new file mode 100644 index 000000000..f26ceb4d0 --- /dev/null +++ b/Algorithms/0433.minimum-genetic-mutation/minimum-genetic-mutation_test.go @@ -0,0 +1,78 @@ +package problem0433 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + start string + end string + bank []string + ans int +}{ + + { + "AACCGGTT", + "AAACGGTA", + []string{"AACCGATT", "AACCGATA", "AAACGATA", "AAACGGTA"}, + 4, + }, + + { + "AACCGGTT", + "AACCGGTA", + []string{}, + -1, + }, + + { + "AACCGGTT", + "AACCGGTT", + []string{"AACCGGTT"}, + 1, + }, + + { + "AACCGGTT", + "AACCGGTA", + []string{"AACCGGTA"}, + 1, + }, + + { + "AACCGGTT", + "AAACGGTA", + []string{"AACCGGTA", "AACCGCTA", "AAACGGTA"}, + 2, + }, + + { + "AAAAACCC", + "AACCCCCC", + []string{"AAAACCCC", "AAACCCCC", "AACCCCCC"}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_countSegments(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, minMutation(tc.start, tc.end, tc.bank), "输入:%v", tc) + } +} + +func Benchmark_countSegments(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minMutation(tc.start, tc.end, tc.bank) + } + } +} diff --git a/Algorithms/0457.circular-array-loop/README.md b/Algorithms/0457.circular-array-loop/README.md new file mode 100755 index 000000000..83b64635f --- /dev/null +++ b/Algorithms/0457.circular-array-loop/README.md @@ -0,0 +1,17 @@ +# [457. Circular Array Loop](https://leetcode.com/problems/circular-array-loop/) + +## 题目 + +You are given an array of positive and negative integers. If a number n at an index is positive, then move forward n steps. Conversely, if it's negative (-n), move backward n steps. Assume the first element of the array is forward next to the last element, and the last element is backward next to the first element. Determine if there is a loop in this array. A loop starts and ends at a particular index with more than 1 element along the loop. The loop must be "forward" or "backward'. + +Example 1: Given the array [2, -1, 1, 2, 2], there is a loop, from index 0 -> 2 -> 3 -> 0. + +Example 2: Given the array [-1, 2], there is no loop. + +Note: The given array is guaranteed to contain no element "0". + +Can you do it in O(n) time complexity and O(1) space complexity? + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0457.circular-array-loop/circular-array-loop.go b/Algorithms/0457.circular-array-loop/circular-array-loop.go new file mode 100644 index 000000000..590264048 --- /dev/null +++ b/Algorithms/0457.circular-array-loop/circular-array-loop.go @@ -0,0 +1,49 @@ +package problem0457 + +import ( + "unsafe" +) + +func circularArrayLoop(nums []int) bool { + size := len(nums) + + // 缩小 nums[i] 的范围 + for i := 0; i < size; i++ { + nums[i] %= size + } + + // 获取 int 型变量的位数 - 1 + bits := uint(unsafe.Sizeof(size) - 1) + + for i, n := range nums { + // 用于标记 nums[i] + // 每个外层 for 循环的 mark 必须不一样,才能检查此次路径是否闭合 + // mark 还需要与 n 同符号 + mark := (i + size) * (n>>bits | 1) + + // 每次内层 for 循环只需要检查未检查过的节点即可。 + // 他们的特点是 -size < n && n != 0 && n < size + for -size < n && n < size && n != 0 { + // nums[i] 通过了 for 的检查条件 + // 现在标记 i 节点 + nums[i] = mark + + // 跳转到下一个节点 + // 更新 i 和 n + i = (n + i + size) % size + n = nums[i] + + if n == mark { + // 发现闭环 + return true + } + + if n*mark < 0 { + // 出现转向 + break + } + } + } + + return false +} diff --git a/Algorithms/0457.circular-array-loop/circular-array-loop_test.go b/Algorithms/0457.circular-array-loop/circular-array-loop_test.go new file mode 100644 index 000000000..785ce5ff3 --- /dev/null +++ b/Algorithms/0457.circular-array-loop/circular-array-loop_test.go @@ -0,0 +1,59 @@ +package problem0457 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + nums []int + ans bool +}{ + + { + []int{-1, 2}, + false, + }, + + { + []int{2, -1, 1, -2, -2}, + false, + }, + + { + []int{-2, 1, -1, -2, -2}, + false, + }, + + { + []int{2, -1, 1, 2, 2}, + true, + }, + + { + []int{-1, -1}, + true, + }, + + // 可以有多个 testcase +} + +func Test_find132pattern(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, circularArrayLoop(tc.nums), "输入:%v", tc) + } +} + +func Benchmark_find132pattern(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + circularArrayLoop(tc.nums) + } + } +} diff --git a/Algorithms/0458.poor-pigs/README.md b/Algorithms/0458.poor-pigs/README.md new file mode 100755 index 000000000..ef110f8c8 --- /dev/null +++ b/Algorithms/0458.poor-pigs/README.md @@ -0,0 +1,15 @@ +# [458. Poor Pigs](https://leetcode.com/problems/poor-pigs/) + +## 题目 + +There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucket contains the poison within one hour. + +Answer this question, and write an algorithm for the follow-up general case. + +Follow-up: + +If there are n buckets and a pig drinking poison will die within m minutes, how many pigs (x) you need to figure out the "poison" bucket within p minutes? There is exact one bucket with poison. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0458.poor-pigs/poor-pigs.go b/Algorithms/0458.poor-pigs/poor-pigs.go new file mode 100755 index 000000000..97aa0aec6 --- /dev/null +++ b/Algorithms/0458.poor-pigs/poor-pigs.go @@ -0,0 +1,20 @@ +package problem0458 + +func poorPigs(buckets int, minutesToDie int, minutesToTest int) int { + // 15 分钟中毒身亡,总共 60 分钟的测试时间的话 + // 一只猪可以测试 5 组样品,从 0 分钟的时候喝一组,每过 15分钟没死就继续喝下一组 + // 猪在 60 分钟内死亡的话,就是刚刚喝的那一组有毒,没死的话,就是第 5 组有毒。 + base := minutesToTest/minutesToDie + 1 + // 然后,可以把猪的个数看成是空间的维度 + // 把 buckets 看成是多维空间中正立方体的体积 + // 正立方体的边长就是 base + power := 1 + res := 0 + + for power < buckets { + power *= base + res++ + } + + return res +} diff --git a/Algorithms/0458.poor-pigs/poor-pigs_test.go b/Algorithms/0458.poor-pigs/poor-pigs_test.go new file mode 100755 index 000000000..89a2d5bf5 --- /dev/null +++ b/Algorithms/0458.poor-pigs/poor-pigs_test.go @@ -0,0 +1,57 @@ +package problem0458 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + buckets int + minutesToDie int + minutesToTest int + ans int +}{ + + { + 1, + 1, + 1, + 0, + }, + + { + 1000, + 12, + 60, + 4, + }, + + { + 1000, + 15, + 60, + 5, + }, + + // 可以有多个 testcase +} + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, poorPigs(tc.buckets, tc.minutesToDie, tc.minutesToTest), "输入:%v", tc) + } +} + +func Benchmark_myFunc(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + poorPigs(tc.buckets, tc.minutesToDie, tc.minutesToTest) + } + } +} diff --git a/Algorithms/0470.implement-rand10-using-rand7/README.md b/Algorithms/0470.implement-rand10-using-rand7/README.md new file mode 100755 index 000000000..586702b80 --- /dev/null +++ b/Algorithms/0470.implement-rand10-using-rand7/README.md @@ -0,0 +1,42 @@ +# [470. Implement Rand10() Using Rand7()](https://leetcode.com/problems/implement-rand10-using-rand7/) + +## 题目 + +Given a function rand7 which generates a uniform random integer in the range 1 to 7, write a function rand10which generates a uniform random integer in the range 1 to 10. + +Do NOT use system's Math.random(). + +Example 1: + +```text +Input: 1 +Output: [7] +``` + +Example 2: + +```text +Input: 2 +Output: [8,4] +``` + +Example 3: + +```text +Input: 3 +Output: [8,1,10] +``` + +Note: + +1. rand7 is predefined. +1. Each testcase has one argument:n, the number of times that rand10 is called. + +Follow up: + +1. What is the expected valuefor the number of calls torand7()function? +1. Could you minimize the number of calls to rand7()? + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0470.implement-rand10-using-rand7/implement-rand10-using-rand7.go b/Algorithms/0470.implement-rand10-using-rand7/implement-rand10-using-rand7.go new file mode 100755 index 000000000..3efb88a8f --- /dev/null +++ b/Algorithms/0470.implement-rand10-using-rand7/implement-rand10-using-rand7.go @@ -0,0 +1,21 @@ +package problem0470 + +import "math/rand" + +func rand10() int { + t := 50 + for t > 39 { + t = 7*(rand7()-1) + (rand7() - 1) + // t 的取值范围为 [0,48],每个数字出现的概率都是为 1/49 + } + // t 的范围是 [0,39],t 出现在这个范围内的概率是 40/49 + // 当 t 为 3, 13, 23 或 33 的时候, t%10+1 == 4 + // 返回 4 的概率 = (4 * 1/49) / (40/49) == 1/10 + // 同理可知,返回 [1,10] 中每个数字的概率都是 1/10 + // 符合题意 + return t%10 + 1 +} + +func rand7() int { + return rand.Intn(7) + 1 +} diff --git a/Algorithms/0470.implement-rand10-using-rand7/implement-rand10-using-rand7_test.go b/Algorithms/0470.implement-rand10-using-rand7/implement-rand10-using-rand7_test.go new file mode 100755 index 000000000..a34dab804 --- /dev/null +++ b/Algorithms/0470.implement-rand10-using-rand7/implement-rand10-using-rand7_test.go @@ -0,0 +1,21 @@ +package problem0470 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_rand10(t *testing.T) { + ast := assert.New(t) + for i := 0; i < 100; i++ { + r := rand10() + ast.True(1 <= r && r <= 10) + } +} + +func Benchmark_rand10(b *testing.B) { + for i := 0; i < b.N; i++ { + rand10() + } +} diff --git a/Algorithms/0478.generate-random-point-in-a-circle/README.md b/Algorithms/0478.generate-random-point-in-a-circle/README.md new file mode 100755 index 000000000..2e8bc9426 --- /dev/null +++ b/Algorithms/0478.generate-random-point-in-a-circle/README.md @@ -0,0 +1,38 @@ +# [478. Generate Random Point in a Circle](https://leetcode.com/problems/generate-random-point-in-a-circle/) + +## 题目 + +Given the radius and x-y positions of the center of a circle, write a function `randPoint` which generates a uniform randompoint in the circle. + +Note: + +1. input and output values are in [floating-point](https://www.webopedia.com/TERM/F/floating_point_number.html). +1. radius and x-y position of the center of the circle is passed into the class constructor. +1. a point on the circumference of the circle is considered to bein the circle. +1. randPointreturnsa size 2 array containing x-position and y-position of the random point, in that order. + +Example 1: + +```text +Input: +["Solution","randPoint","randPoint","randPoint"] +[[1,0,0],[],[],[]] +Output: [null,[-0.72939,-0.65505],[-0.78502,-0.28626],[-0.83119,-0.19803]] +``` + +Example 2: + +```text +Input: +["Solution","randPoint","randPoint","randPoint"] +[[10,5,-7.5],[],[],[]] +Output: [null,[11.52438,-8.33273],[2.46992,-16.21705],[11.13430,-12.42337]] +``` + +Explanation of Input Syntax: + +The input is two lists:the subroutines calledand theirarguments.Solution'sconstructor has three arguments, the radius, x-position of the center, and y-position of the center of the circle. randPoint has no arguments.Argumentsarealways wrapped with a list, even if there aren't any. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0478.generate-random-point-in-a-circle/generate-random-point-in-a-circle.go b/Algorithms/0478.generate-random-point-in-a-circle/generate-random-point-in-a-circle.go new file mode 100755 index 000000000..fc4c1adb2 --- /dev/null +++ b/Algorithms/0478.generate-random-point-in-a-circle/generate-random-point-in-a-circle.go @@ -0,0 +1,33 @@ +package problem0478 + +import ( + "math/rand" +) + +// Solution object will be instantiated and called as such: +// obj := Constructor(radius, x_center, y_center); +// param_1 := obj.RandPoint(); +type Solution struct { + r, a, b float64 +} + +// Constructor 构建 Solution +func Constructor(radius, xCenter, yCenter float64) Solution { + return Solution{ + r: radius, + a: xCenter, + b: yCenter, + } +} + +// RandPoint 返回圆内的随机点 +func (s *Solution) RandPoint() []float64 { + xFactor, yFactor := 1., 1. + for xFactor*xFactor+yFactor*yFactor > 1 { + xFactor = 2*rand.Float64() - 1 + yFactor = 2*rand.Float64() - 1 + } + x := s.a + s.r*xFactor + y := s.b + s.r*yFactor + return []float64{x, y} +} diff --git a/Algorithms/0478.generate-random-point-in-a-circle/generate-random-point-in-a-circle_test.go b/Algorithms/0478.generate-random-point-in-a-circle/generate-random-point-in-a-circle_test.go new file mode 100755 index 000000000..c21ddc3ca --- /dev/null +++ b/Algorithms/0478.generate-random-point-in-a-circle/generate-random-point-in-a-circle_test.go @@ -0,0 +1,32 @@ +package problem0478 + +import ( + "math" + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_RandPoint(t *testing.T) { + ast := assert.New(t) + r, a, b := 3., 2., 1. + s := Constructor(r, a, b) + for i := 0; i < 100; i++ { + p := s.RandPoint() + x, y := p[0], p[1] + actual := math.Sqrt((x-a)*(x-a) + (y-b)*(y-b)) + ast.True(actual <= r) + } +} + +func Test_RandPoint_2(t *testing.T) { + ast := assert.New(t) + r, a, b := 0.01, -73839.1, -3289891. + s := Constructor(r, a, b) + for i := 0; i < 100; i++ { + p := s.RandPoint() + x, y := p[0], p[1] + actual := math.Sqrt((x-a)*(x-a) + (y-b)*(y-b)) + ast.True(actual <= r) + } +} diff --git a/Algorithms/0497.random-point-in-non-overlapping-rectangles/README.md b/Algorithms/0497.random-point-in-non-overlapping-rectangles/README.md new file mode 100755 index 000000000..f87e20c3b --- /dev/null +++ b/Algorithms/0497.random-point-in-non-overlapping-rectangles/README.md @@ -0,0 +1,43 @@ +# [497. Random Point in Non-overlapping Rectangles](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/) + +## 题目 + +Given a list of non-overlapping axis-aligned rectangles rects, write a function pick which randomly and uniformily picks an integer point in the spacecovered by the rectangles. + +Note: + +1. An integer pointis a point that has integer coordinates. +1. A pointon the perimeterof a rectangle isincluded in the space covered by the rectangles. +1. ith rectangle = rects[i] =[x1,y1,x2,y2], where [x1, y1]are the integer coordinates of the bottom-left corner, and [x2, y2]are the integer coordinates of the top-right corner. +1. length and width of each rectangle does not exceed 2000. +1. 1 <= rects.length<= 100 +1. pick return a point as an array of integer coordinates[p_x, p_y] +1. pick is called at most 10000times. + +Example 1: + +```text +Input: +["Solution","pick","pick","pick"] +[[[[1,1,5,5]]],[],[],[]] +Output: +[null,[4,1],[4,1],[3,3]] +``` + +Example 2: + +```text +Input: +["Solution","pick","pick","pick","pick","pick"] +[[[[-2,-2,-1,-1],[1,0,3,0]]],[],[],[],[],[]] +Output: +[null,[-1,-2],[2,0],[-2,-1],[3,0],[-2,-2]] +``` + +Explanation of Input Syntax: + +The input is two lists:the subroutines calledand theirarguments.Solution'sconstructor has one argument, the array of rectangles rects. pickhas no arguments.Argumentsarealways wrapped with a list, even if there aren't any. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0497.random-point-in-non-overlapping-rectangles/random-point-in-non-overlapping-rectangles.go b/Algorithms/0497.random-point-in-non-overlapping-rectangles/random-point-in-non-overlapping-rectangles.go new file mode 100755 index 000000000..07f5a7c76 --- /dev/null +++ b/Algorithms/0497.random-point-in-non-overlapping-rectangles/random-point-in-non-overlapping-rectangles.go @@ -0,0 +1,52 @@ +package problem0497 + +import ( + "math/rand" + "sort" +) + +// Solution object will be instantiated and called as such: +// obj := Constructor(rects); +// param_1 := obj.Pick(); +type Solution struct { + total int // 所有可能离散的点的个数 + counts []int // count[i] 记录了前 i 个矩形中所有点的个数 + rects [][]int +} + +// Constructor 创建 Solution +func Constructor(rects [][]int) Solution { + size := len(rects) + + total := 0 + counts := make([]int, size) + tmp := make([][]int, size) + + for i, r := range rects { + x1, y1, x2, y2 := r[0], r[1], r[2], r[3] + w, h := x2-x1+1, y2-y1+1 // +1 是因为 [a,b] 之间一共有 b-a+1 个离散的点 + total += w * h + counts[i] = total + tmp[i] = []int{x1, y1, w, h} // 修改 rect 的表达方式 + } + + return Solution{ + counts: counts, + rects: tmp, + total: total, + } +} + +// Pick 返回正方形内的点 +func (s *Solution) Pick() []int { + cand := rand.Intn(s.total) + 1 + // 根据 cand 找到需要返回那个矩形下的点 + i := sort.SearchInts(s.counts, cand) + + x1, y1, w, h := s.rects[i][0], s.rects[i][1], s.rects[i][2], s.rects[i][3] + + x := x1 + rand.Intn(w) + y := y1 + rand.Intn(h) + + return []int{x, y} +} diff --git a/Algorithms/0497.random-point-in-non-overlapping-rectangles/random-point-in-non-overlapping-rectangles_test.go b/Algorithms/0497.random-point-in-non-overlapping-rectangles/random-point-in-non-overlapping-rectangles_test.go new file mode 100755 index 000000000..2a3a9cd94 --- /dev/null +++ b/Algorithms/0497.random-point-in-non-overlapping-rectangles/random-point-in-non-overlapping-rectangles_test.go @@ -0,0 +1,90 @@ +package problem0497 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_Solution(t *testing.T) { + ast := assert.New(t) + + rects := [][]int{ + []int{1, 1, 5, 5}, + } + + s := Constructor(rects) + + for i := 0; i < 10000; i++ { + p := s.Pick() + actual := 0 + for _, r := range rects { + if isWithin(r, p) { + actual++ + } + } + ast.Equal(1, actual) + } +} + +func Test_Solution_2(t *testing.T) { + ast := assert.New(t) + + rects := [][]int{ + {-2, -2, -1, -1}, + {1, 0, 3, 0}, + } + + s := Constructor(rects) + + for i := 0; i < 10000; i++ { + p := s.Pick() + actual := 0 + for _, r := range rects { + if isWithin(r, p) { + actual++ + } + } + ast.Equal(1, actual) + } +} + +func Test_Solution_3(t *testing.T) { + ast := assert.New(t) + + rects := [][]int{ + {0, 0, 1, 1}, + {2, 0, 3, 1}, + } + + s := Constructor(rects) + + counts := make([]int, len(rects)) + picks := 1000000 + + for i := 0; i < picks; i++ { + p := s.Pick() + for i, r := range rects { + if isWithin(r, p) { + counts[i]++ + } + } + } + + delta := 0.001 + for i, c := range counts { + w, h := s.rects[i][2], s.rects[i][3] + expected := float64(w*h) / float64(s.total) + actual := float64(c) / float64(picks) + ast.InDelta(expected, actual, delta) + } + +} + +func isWithin(rect, point []int) bool { + x1, y1, x2, y2 := rect[0], rect[1], rect[2], rect[3] + x, y := point[0], point[1] + + return x1 <= x && x <= x2 && + y1 <= y && y <= y2 +} diff --git a/Algorithms/0509.fibonacci-number/README.md b/Algorithms/0509.fibonacci-number/README.md new file mode 100755 index 000000000..f93838e4f --- /dev/null +++ b/Algorithms/0509.fibonacci-number/README.md @@ -0,0 +1,38 @@ +# [509. Fibonacci Number](https://leetcode.com/problems/fibonacci-number/) + +The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is, + +```text +F(0) = 0, F(1) = 1 +F(N) = F(N - 1) + F(N - 2), for N > 1. +``` + +Given N, calculate F(N). + +Example 1: + +```text +Input: 2 +Output: 1 +Explanation: F(2) = F(1) + F(0) = 1 + 0 = 1. +``` + +Example 2: + +```text +Input: 3 +Output: 2 +Explanation: F(3) = F(2) + F(1) = 1 + 1 = 2. +``` + +Example 3: + +```text +Input: 4 +Output: 3 +Explanation: F(4) = F(3) + F(2) = 2 + 1 = 3. +``` + +Note: + +- 0 ≤ N ≤ 30. \ No newline at end of file diff --git a/Algorithms/0509.fibonacci-number/fibonacci-number.go b/Algorithms/0509.fibonacci-number/fibonacci-number.go new file mode 100755 index 000000000..863c1d97c --- /dev/null +++ b/Algorithms/0509.fibonacci-number/fibonacci-number.go @@ -0,0 +1,15 @@ +package problem0509 + +var fibs = make([]int, 31) + +func fib(N int) int { + if N == 0 || N == 1 { + return N + } + res := fibs[N] + if res == 0 { + res = fib(N-1) + fib(N-2) + fibs[N] = res + } + return res +} diff --git a/Algorithms/0509.fibonacci-number/fibonacci-number_test.go b/Algorithms/0509.fibonacci-number/fibonacci-number_test.go new file mode 100755 index 000000000..c52d13805 --- /dev/null +++ b/Algorithms/0509.fibonacci-number/fibonacci-number_test.go @@ -0,0 +1,57 @@ +package problem0509 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans int +}{ + + { + 30, + 832040, + }, + + { + 2, + 1, + }, + + { + 3, + 2, + }, + + { + 0, + 0, + }, + + { + 4, + 3, + }, + + // 可以有多个 testcase +} + +func Test_fib(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, fib(tc.N), "输入:%v", tc) + } +} + +func Benchmark_fib(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + fib(tc.N) + } + } +} diff --git a/Algorithms/0518.coin-change-2/README.md b/Algorithms/0518.coin-change-2/README.md new file mode 100755 index 000000000..447a90352 --- /dev/null +++ b/Algorithms/0518.coin-change-2/README.md @@ -0,0 +1,43 @@ +# [518. Coin Change 2](https://leetcode.com/problems/coin-change-2/) + +## 题目 + +You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin. + +Note: You can assume that + +- 0 <= amount <= 5000 +- 1 <= coin <= 5000 +- the number of coins is less than 500 +- the answer is guaranteed to fit into signed 32-bit integer + +Example 1: + +```text +Input: amount = 5, coins = [1, 2, 5] +Output: 4 +Explanation: there are four ways to make up the amount: +5=5 +5=2+2+1 +5=2+1+1+1 +5=1+1+1+1+1 +``` + +Example 2: + +```text +Input: amount = 3, coins = [2] +Output: 0 +Explanation: the amount of 3 cannot be made up just with coins of 2. +``` + +Example 3: + +```text +Input: amount = 10, coins = [10] +Output: 1 +``` + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0518.coin-change-2/coin-change-2.go b/Algorithms/0518.coin-change-2/coin-change-2.go new file mode 100755 index 000000000..1010802c2 --- /dev/null +++ b/Algorithms/0518.coin-change-2/coin-change-2.go @@ -0,0 +1,17 @@ +package problem0518 + +func change(amount int, coins []int) int { + // dp[i]表示总额为i时的方案数. + // 转移方程: dp[i] = Σdp[i - coins[j]]; 表示 总额为i时的方案数 = 总额为i-coins[j]的方案数的加和. + dp := make([]int, amount+1) + // 记得初始化dp[0] = 1; 表示总额为0时方案数为1. + dp[0] = 1 + + for _, coin := range coins { + for i := coin; i <= amount; i++ { // 从coin开始遍历,小于coin的值没有意义 + dp[i] += dp[i-coin] + } + } + + return dp[amount] +} diff --git a/Algorithms/0518.coin-change-2/coin-change-2_test.go b/Algorithms/0518.coin-change-2/coin-change-2_test.go new file mode 100755 index 000000000..9e2f60add --- /dev/null +++ b/Algorithms/0518.coin-change-2/coin-change-2_test.go @@ -0,0 +1,59 @@ +package problem0518 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + amount int + coins []int + ans int +}{ + + { + 5, + []int{1, 2, 5}, + 4, + }, + + { + 3, + []int{2}, + 0, + }, + + { + 10, + []int{10}, + 1, + }, + + { + 500, + []int{3, 5, 7, 8, 9, 10, 11}, + 35502874, + }, + + // 可以有多个 testcase +} + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, change(tc.amount, tc.coins), "输入:%v", tc) + } +} + +func Benchmark_myFunc(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + change(tc.amount, tc.coins) + } + } +} diff --git a/Algorithms/0519.random-flip-matrix/README.md b/Algorithms/0519.random-flip-matrix/README.md new file mode 100755 index 000000000..40d2ac102 --- /dev/null +++ b/Algorithms/0519.random-flip-matrix/README.md @@ -0,0 +1,38 @@ +# [519. Random Flip Matrix](https://leetcode.com/problems/random-flip-matrix/) + +## 题目 + +You are given the number of rows n_rowsand number of columns n_colsof a2Dbinary matrixwhere all values are initially 0.Write a function flipwhich choosesa 0 valueuniformly at random,changes it to 1,and then returns the position [row.id, col.id] of that value. Also, write a function reset which sets all values back to 0.Try to minimize the number of calls to system's Math.random() and optimize the time andspace complexity. + +Note: + +1. 1 <= n_rows, n_cols<= 10000 +1. 0 <= row.id < n_rows and 0 <= col.id < n_cols +1. flipwill not be called when the matrix has no0 values left. +1. the total number of calls toflipand resetwill not exceed1000. + +Example 1: + +```text +Input: +["Solution","flip","flip","flip","flip"] +[[2,3],[],[],[],[]] +Output: [null,[0,1],[1,2],[1,0],[1,1]] +``` + +Example 2: + +```text +Input: +["Solution","flip","flip","reset","flip"] +[[1,2],[],[],[],[]] +Output: [null,[0,0],[0,1],null,[0,0]] +``` + +Explanation of Input Syntax: + +The input is two lists:the subroutines calledand theirarguments. Solution's constructorhas two arguments, n_rows and n_cols.flipand reset havenoarguments.Argumentsarealways wrapped with a list, even if there aren't any. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0519.random-flip-matrix/random-flip-matrix.go b/Algorithms/0519.random-flip-matrix/random-flip-matrix.go new file mode 100755 index 000000000..4594b7578 --- /dev/null +++ b/Algorithms/0519.random-flip-matrix/random-flip-matrix.go @@ -0,0 +1,54 @@ +package problem0519 + +import "math/rand" + +// Solution object will be instantiated and called as such: +// obj := Constructor(n_rows, n_cols); +// param_1 := obj.Flip(); +// obj.Reset(); +type Solution struct { + rows, cols int + total int // 矩阵中剩余的 0 的个数 + rec map[int]int +} + +// Constructor 构建 Solution +func Constructor(rows, cols int) Solution { + r := make(map[int]int) + return Solution{ + rows: rows, + cols: cols, + total: rows * cols, + rec: r, + } +} + +// Flip 选择 rows * cols 矩阵中的某个 0 进行翻转 +func (s *Solution) Flip() []int { + if s.total == 0 { + return nil + } + + index := rand.Intn(s.total) + + cand := index + if change, isFound := s.rec[index]; isFound { + cand = change + } + r, c := cand/s.cols, cand%s.cols + + s.total-- + if change, isFound := s.rec[s.total]; isFound { + s.rec[index] = change + } else { + s.rec[index] = s.total + } + + return []int{r, c} +} + +// Reset 把 rows * cols 中的元素全部变成 0 +func (s *Solution) Reset() { + s.total = s.rows * s.cols + s.rec = make(map[int]int) +} diff --git a/Algorithms/0519.random-flip-matrix/random-flip-matrix_test.go b/Algorithms/0519.random-flip-matrix/random-flip-matrix_test.go new file mode 100755 index 000000000..d52b8d79b --- /dev/null +++ b/Algorithms/0519.random-flip-matrix/random-flip-matrix_test.go @@ -0,0 +1,71 @@ +package problem0519 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_Solution(t *testing.T) { + ast := assert.New(t) + + rows, cols := 2, 3 + s := Constructor(rows, cols) + + recorder := make([]bool, rows*cols) + for i := 0; i < rows*cols; i++ { + f := s.Flip() + r, c := f[0], f[1] + old := recorder[r*cols+c] + recorder[r*cols+c] = true + ast.False(old) + } + + s.Reset() + + recorder = make([]bool, rows*cols) + for i := 0; i < rows*cols; i++ { + f := s.Flip() + r, c := f[0], f[1] + old := recorder[r*cols+c] + recorder[r*cols+c] = true + ast.False(old) + } + +} +func Test_Solution_2(t *testing.T) { + ast := assert.New(t) + + rows, cols := 1, 2 + s := Constructor(rows, cols) + + recorder := make([]bool, rows*cols) + for i := 0; i < rows*cols; i++ { + f := s.Flip() + r, c := f[0], f[1] + old := recorder[r*cols+c] + recorder[r*cols+c] = true + ast.False(old) + } + + ast.Nil(s.Flip()) +} +func Test_Solution_3(t *testing.T) { + ast := assert.New(t) + + rows, cols := 10000, 10000 + s := Constructor(rows, cols) + + for times := 0; times < 200; times++ { + recorder := make([]bool, rows*cols) + s.Reset() + for i := 0; i < 4; i++ { + f := s.Flip() + r, c := f[0], f[1] + old := recorder[r*cols+c] + recorder[r*cols+c] = true + ast.False(old) + } + } + +} diff --git a/Algorithms/0528.random-pick-with-weight/README.md b/Algorithms/0528.random-pick-with-weight/README.md new file mode 100755 index 000000000..3535345a2 --- /dev/null +++ b/Algorithms/0528.random-pick-with-weight/README.md @@ -0,0 +1,37 @@ +# [528. Random Pick with Weight](https://leetcode.com/problems/random-pick-with-weight/) + +## 题目 + +Given an array w of positive integers, where w[i] describes the weight of index i,write a function pickIndexwhich randomlypicks an indexin proportionto its weight. + +Note: + +1. 1 <= w.length <= 10000 +1. 1 <= w[i] <= 10^5 +1. pickIndex will be called at most 10000 times. + +Example 1: + +```text +Input: +["Solution","pickIndex"] +[[[1]],[]] +Output: [null,0] +``` + +Example 2: + +```text +Input: +["Solution","pickIndex","pickIndex","pickIndex","pickIndex","pickIndex"] +[[[1,3]],[],[],[],[],[]] +Output: [null,0,1,1,1,0] +``` + +Explanation of Input Syntax: + +The input is two lists:the subroutines calledand theirarguments.Solution'sconstructor has one argument, thearray w. pickIndex has no arguments.Argumentsarealways wrapped with a list, even if there aren't any. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0528.random-pick-with-weight/random-pick-with-weight.go b/Algorithms/0528.random-pick-with-weight/random-pick-with-weight.go new file mode 100755 index 000000000..def74a565 --- /dev/null +++ b/Algorithms/0528.random-pick-with-weight/random-pick-with-weight.go @@ -0,0 +1,38 @@ +package problem0528 + +import ( + "math/rand" + "sort" +) + +// Solution object will be instantiated and called as such: +// obj := Constructor(w); +// param_1 := obj.PickIndex(); +type Solution struct { + counts []int + total int +} + +// Constructor 返回 Solution +func Constructor(w []int) Solution { + total := 0 + counts := make([]int, len(w)) + for i := range w { + total += w[i] + counts[i] = total + } + + return Solution{ + counts: counts, + total: total, + } +} + +// PickIndex 根据权重返回 索引号 +func (s *Solution) PickIndex() int { + cand := rand.Intn(s.total) + index := sort.Search(len(s.counts), func(i int) bool { + return s.counts[i] > cand + }) + return index +} diff --git a/Algorithms/0528.random-pick-with-weight/random-pick-with-weight_test.go b/Algorithms/0528.random-pick-with-weight/random-pick-with-weight_test.go new file mode 100755 index 000000000..6ccb4ead0 --- /dev/null +++ b/Algorithms/0528.random-pick-with-weight/random-pick-with-weight_test.go @@ -0,0 +1,60 @@ +package problem0528 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_Solution(t *testing.T) { + ast := assert.New(t) + + w := []int{1, 3} + total := 0. + for i := range w { + total += float64(w[i]) + } + + s := Constructor(w) + count := make([]int, len(w)) + + picks := 10000 + for i := 0; i < picks; i++ { + index := s.PickIndex() + count[index]++ + } + + for i, c := range count { + expected := float64(w[i]) / total + actual := float64(c) / float64(picks) + delta := 0.001 + ast.InDelta(expected, actual, delta) + } + +} +func Test_Solution_2(t *testing.T) { + ast := assert.New(t) + + w := []int{1, 3, 5, 7, 9, 11, 13, 15} + total := 0. + for i := range w { + total += float64(w[i]) + } + + s := Constructor(w) + count := make([]int, len(w)) + + picks := 1000000 + for i := 0; i < picks; i++ { + index := s.PickIndex() + count[index]++ + } + + for i, c := range count { + expected := float64(w[i]) / total + actual := float64(c) / float64(picks) + delta := 0.001 + ast.InDelta(expected, actual, delta) + } + +} diff --git a/Algorithms/0622.design-circular-queue/README.md b/Algorithms/0622.design-circular-queue/README.md new file mode 100755 index 000000000..58e0e2182 --- /dev/null +++ b/Algorithms/0622.design-circular-queue/README.md @@ -0,0 +1,42 @@ +# [622. Design Circular Queue](https://leetcode.com/problems/design-circular-queue/) + +## 题目 + +Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. It is also called "Ring Buffer". + +One of the benefits of the circular queue is that we can make use of the spaces in front of the queue. In a normal queue, once the queue becomes full, we cannot insert the next element even if there is a space in front of the queue. But using the circular queue, we can use the space to store new values. + +Your implementation should support following operations: + +- MyCircularQueue(k): Constructor, set the size of the queue to be k. +- Front: Get the front item from the queue. If the queue is empty, return -1. +- Rear: Get the last item from the queue. If the queue is empty, return -1. +- enQueue(value): Insert an element into the circular queue. Return true if the operation is successful. +- deQueue(): Delete an element from the circular queue. Return true if the operation is successful. +- isEmpty(): Checks whether the circular queue is empty or not. +- isFull(): Checks whether the circular queue is full or not. + +Example: + +```text +MyCircularQueue circularQueue = new MycircularQueue(3); // set the size to be 3 +circularQueue.enQueue(1); // return true +circularQueue.enQueue(2); // return true +circularQueue.enQueue(3); // return true +circularQueue.enQueue(4); // return false, the queue is full +circularQueue.Rear(); // return 3 +circularQueue.isFull(); // return true +circularQueue.deQueue(); // return true +circularQueue.enQueue(4); // return true +circularQueue.Rear(); // return 4 +``` + +Note: + +1. All values will be in the range of [0, 1000]. +1. The number of operations will be in the range of[1, 1000]. +1. Please do not use the built-in Queue library. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0622.design-circular-queue/design-circular-queue.go b/Algorithms/0622.design-circular-queue/design-circular-queue.go new file mode 100755 index 000000000..bb4bef36e --- /dev/null +++ b/Algorithms/0622.design-circular-queue/design-circular-queue.go @@ -0,0 +1,72 @@ +package problem0622 + +// MyCircularQueue 结构体 +type MyCircularQueue struct { + queue []int + k int +} + +// Constructor initialize your data structure here. Set the size of the queue to be k. +func Constructor(k int) MyCircularQueue { + return MyCircularQueue{ + queue: make([]int, 0, k*3), + k: k, + } +} + +// EnQueue insert an element into the circular queue. Return true if the operation is successful. +func (m *MyCircularQueue) EnQueue(value int) bool { + if len(m.queue) == m.k { + return false + } + m.queue = append(m.queue, value) + return true +} + +// DeQueue delete an element from the circular queue. Return true if the operation is successful. +func (m *MyCircularQueue) DeQueue() bool { + if len(m.queue) == 0 { + return false + } + + m.queue = m.queue[1:] + return true +} + +// Front get the front item from the queue. +func (m *MyCircularQueue) Front() int { + if len(m.queue) == 0 { + return -1 + } + + return m.queue[0] +} + +// Rear get the last item from the queue. */ +func (m *MyCircularQueue) Rear() int { + if len(m.queue) == 0 { + return -1 + } + return m.queue[len(m.queue)-1] +} + +// IsEmpty checks whether the circular queue is empty or not. */ +func (m *MyCircularQueue) IsEmpty() bool { + return len(m.queue) == 0 +} + +// IsFull checks whether the circular queue is full or not. */ +func (m *MyCircularQueue) IsFull() bool { + return len(m.queue) == m.k +} + +/** + * Your MyCircularQueue object will be instantiated and called as such: + * obj := Constructor(k); + * param_1 := obj.EnQueue(value); + * param_2 := obj.DeQueue(); + * param_3 := obj.Front(); + * param_4 := obj.Rear(); + * param_5 := obj.IsEmpty(); + * param_6 := obj.IsFull(); + */ diff --git a/Algorithms/0622.design-circular-queue/design-circular-queue_test.go b/Algorithms/0622.design-circular-queue/design-circular-queue_test.go new file mode 100755 index 000000000..35d4653d0 --- /dev/null +++ b/Algorithms/0622.design-circular-queue/design-circular-queue_test.go @@ -0,0 +1,44 @@ +package problem0622 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + m := Constructor(3) + + ast.True(m.IsEmpty(), "检查空数组的 IsEmpty()") + ast.False(m.IsFull(), "检查空数组的 IsFull()") + + ast.False(m.DeQueue(), "从空数组中删除元素") + + ast.Equal(-1, m.Front(), "检查空数组的首部元素") + ast.Equal(-1, m.Rear(), "检查空数组的尾部元素") + + for i := 1; i <= 3; i++ { + ast.True(m.EnQueue(i), "往数组中添加 %d", i) + } + + ast.False(m.EnQueue(4), "往满数组添加元素") + + ast.False(m.IsEmpty(), "检查满数组的 IsEmpty()") + ast.True(m.IsFull(), "检查满数组的 IsFull()") + + ast.Equal(3, m.Rear(), "检查数组尾部的元素") + + ast.True(m.DeQueue(), "从非空数组中删除元素") + + ast.Equal([]int{2, 3}, m.queue, "DeQueue 后,检查数组中的元素") + + ast.True(m.EnQueue(4), "往数组中添加新的元素") + + ast.Equal([]int{2, 3, 4}, m.queue, "EnQueue 后,检查数组中的元素") + + ast.Equal(4, m.Rear(), "检查数组尾部的元素") + + ast.Equal(2, m.Front(), "检查数组首部的元素") +} diff --git a/Algorithms/0641.design-circular-deque/README.md b/Algorithms/0641.design-circular-deque/README.md new file mode 100755 index 000000000..b06e95256 --- /dev/null +++ b/Algorithms/0641.design-circular-deque/README.md @@ -0,0 +1,42 @@ +# [641. Design Circular Deque](https://leetcode.com/problems/design-circular-deque/) + +## 题目 + +Design your implementation of the circular double-ended queue (deque). + +Your implementation should support following operations: + +- MyCircularDeque(k): Constructor, set the size of the deque to be k. +- insertFront(): Adds an item at the front of Deque. Return true if the operation is successful. +- insertLast(): Adds an item at the rear of Deque. Return true if the operation is successful. +- deleteFront(): Deletes an item from the front of Deque. Return true if the operation is successful. +- deleteLast(): Deletes an item from the rear of Deque. Return true if the operation is successful. +- getFront(): Gets the front item from the Deque. If the deque is empty, return -1. +- getRear(): Gets the last item from Deque. If the deque is empty, return -1. +- isEmpty(): Checks whether Deque is empty or not. +- isFull(): Checks whether Deque is full or not. + +Example: + +```text +MyCircularDeque circularDeque = new MycircularDeque(3); // set the size to be 3 +circularDeque.insertLast(1); // return true +circularDeque.insertLast(2); // return true +circularDeque.insertFront(3); // return true +circularDeque.insertFront(4); // return false, the queue is full +circularDeque.getRear(); // return 32 +circularDeque.isFull(); // return true +circularDeque.deleteLast(); // return true +circularDeque.insertFront(4); // return true +circularDeque.getFront(); // return 4 +``` + +Note: + +1. All values will be in the range of [0, 1000]. +1. The number of operations will be in the range of[1, 1000]. +1. Please do not use the built-in Deque library. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0641.design-circular-deque/design-circular-deque.go b/Algorithms/0641.design-circular-deque/design-circular-deque.go new file mode 100755 index 000000000..d0ab25572 --- /dev/null +++ b/Algorithms/0641.design-circular-deque/design-circular-deque.go @@ -0,0 +1,127 @@ +package problem0641 + +// MyCircularDeque 结构体 +type MyCircularDeque struct { + f, r *node + len, cap int +} +type node struct { + value int + pre, next *node +} + +// Constructor initialize your data structure here. Set the size of the deque to be k. +func Constructor(k int) MyCircularDeque { + return MyCircularDeque{ + cap: k, + } +} + +// InsertFront adds an item at the front of Deque. Return true if the operation is successful. +func (d *MyCircularDeque) InsertFront(value int) bool { + if d.len == d.cap { + return false + } + n := &node{ + value: value, + } + if d.len == 0 { + d.f = n + d.r = n + } else { + n.next = d.f + d.f.pre = n + d.f = n + } + d.len++ + return true +} + +// InsertLast adds an item at the rear of Deque. Return true if the operation is successful. +func (d *MyCircularDeque) InsertLast(value int) bool { + if d.len == d.cap { + return false + } + n := &node{ + value: value, + } + if d.len == 0 { + d.f = n + d.r = n + } else { + n.pre = d.r + d.r.next = n + d.r = n + } + d.len++ + return true +} + +// DeleteFront deletes an item from the front of Deque. Return true if the operation is successful. +func (d *MyCircularDeque) DeleteFront() bool { + if d.len == 0 { + return false + } + if d.len == 1 { + d.f, d.r = nil, nil + } else { + d.f = d.f.next + d.f.pre = nil + } + d.len-- + return true +} + +// DeleteLast deletes an item from the rear of Deque. Return true if the operation is successful. +func (d *MyCircularDeque) DeleteLast() bool { + if d.len == 0 { + return false + } + if d.len == 1 { + d.f, d.r = nil, nil + } else { + d.r = d.r.pre + d.r.next = nil + } + d.len-- + return true +} + +// GetFront get the front item from the deque. +func (d *MyCircularDeque) GetFront() int { + if d.len == 0 { + return -1 + } + return d.f.value +} + +// GetRear get the last item from the deque. +func (d *MyCircularDeque) GetRear() int { + if d.len == 0 { + return -1 + } + return d.r.value +} + +// IsEmpty checks whether the circular deque is empty or not. +func (d *MyCircularDeque) IsEmpty() bool { + return d.len == 0 +} + +// IsFull checks whether the circular deque is full or not. +func (d *MyCircularDeque) IsFull() bool { + return d.len == d.cap +} + +/** + * Your MyCircularDeque object will be instantiated and called as such: + * obj := Constructor(k); + * param_1 := obj.InsertFront(value); + * param_2 := obj.InsertLast(value); + * param_3 := obj.DeleteFront(); + * param_4 := obj.DeleteLast(); + * param_5 := obj.GetFront(); + * param_6 := obj.GetRear(); + * param_7 := obj.IsEmpty(); + * param_8 := obj.IsFull(); + */ diff --git a/Algorithms/0641.design-circular-deque/design-circular-deque_test.go b/Algorithms/0641.design-circular-deque/design-circular-deque_test.go new file mode 100755 index 000000000..71fff4af5 --- /dev/null +++ b/Algorithms/0641.design-circular-deque/design-circular-deque_test.go @@ -0,0 +1,57 @@ +package problem0641 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + d := Constructor(3) + + ast.False(d.IsFull(), "检查空数组") + ast.True(d.IsEmpty(), "检查空数组") + + ast.False(d.DeleteFront(), "从空数组中删除首部元素") + ast.False(d.DeleteLast(), "从空数组中删除尾部元素") + + ast.Equal(-1, d.GetFront(), "从空数组中获取首部元素") + ast.Equal(-1, d.GetRear(), "从空数组中获取尾部元素") + + for i := 0; i < 100; i++ { + ast.True(d.InsertFront(i), "在首部插入 %d", i) + ast.True(d.InsertFront(i), "在首部插入 %d", i) + ast.True(d.InsertFront(i), "在首部插入 %d", i) + ast.True(d.DeleteLast(), "删除尾部元素 %d", i) + ast.True(d.DeleteLast(), "删除尾部元素 %d", i) + ast.True(d.DeleteLast(), "删除尾部元素 %d", i) + } + + for i := 0; i < 100; i++ { + ast.True(d.InsertLast(i), "在尾部插入 %d", i) + ast.True(d.InsertLast(i), "在尾部插入 %d", i) + ast.True(d.InsertLast(i), "在尾部插入 %d", i) + ast.True(d.DeleteFront(), "删除首部元素 %d", i) + ast.True(d.DeleteFront(), "删除首部元素 %d", i) + ast.True(d.DeleteFront(), "删除首部元素 %d", i) + } + + ast.True(d.InsertLast(1), "往尾部插入 1") + ast.True(d.InsertLast(2), "往尾部插入 2") + ast.True(d.InsertFront(3), "往首部插入 3") + ast.False(d.InsertFront(4), "往首部插入 4") + ast.False(d.InsertLast(4), "往尾部插入 4") + + ast.Equal(2, d.GetRear(), "获取尾部元素") + ast.Equal(3, d.GetFront(), "获取首部元素") + + ast.True(d.IsFull(), "检查满数组") + ast.False(d.IsEmpty(), "检查满数组") + + ast.True(d.DeleteLast(), "删除尾部元素") + ast.True(d.InsertFront(4), "在首部添加 4") + + ast.Equal(4, d.GetFront(), "检查首部元素") +} diff --git a/Algorithms/0686.repeated-string-match/repeated-string-match.go b/Algorithms/0686.repeated-string-match/repeated-string-match.go index 3ef5c8bd7..260d266e0 100755 --- a/Algorithms/0686.repeated-string-match/repeated-string-match.go +++ b/Algorithms/0686.repeated-string-match/repeated-string-match.go @@ -1,15 +1,33 @@ package problem0686 -import "strings" - -func repeatedStringMatch(a string, b string) int { - times := max(len(b)/len(a), 1) - - if strings.Contains(strings.Repeat(a, times), b) { - return times +func repeatedStringMatch(A string, B string) int { + // ref: https://leetcode.com/problems/repeated-string-match/discuss/108084/C%2B%2B-4-lines-O(m-*-n)-or-O(1)-and-KMP-O(m-%2B-n)-or-O(n) + n, m := len(A), len(B) + prefTable := make([]int, m+1) + for sp, pp := 1, 0; sp < m; { + if B[pp] == B[sp] { + sp++ + pp++ + prefTable[sp] = pp + } else if pp == 0 { + sp++ + prefTable[sp] = pp + } else { + pp = prefTable[pp] + } } - if strings.Contains(strings.Repeat(a, times+1), b) { - return times + 1 + + for i, j := 0, 0; i < n; i, j = i+max(1, j-prefTable[j]), prefTable[j] { + for j < m && A[(i+j)%n] == B[j] { + j++ + } + if j == m { + if (i+j)%n == 0 { + return (i + j) / n + } else { + return (i+j)/n + 1 + } + } } return -1 } diff --git a/Algorithms/0686.repeated-string-match/repeated-string-match_test.go b/Algorithms/0686.repeated-string-match/repeated-string-match_test.go index 6cd646464..148546c0e 100755 --- a/Algorithms/0686.repeated-string-match/repeated-string-match_test.go +++ b/Algorithms/0686.repeated-string-match/repeated-string-match_test.go @@ -79,6 +79,11 @@ var tcs = []struct { 2, }, + { + "abc", + "cabcabca", + 4, + }, // 可以有多个 testcase } diff --git a/Algorithms/0700.search-in-a-binary-search-tree/README.md b/Algorithms/0700.search-in-a-binary-search-tree/README.md new file mode 100755 index 000000000..bf35cf755 --- /dev/null +++ b/Algorithms/0700.search-in-a-binary-search-tree/README.md @@ -0,0 +1,34 @@ +# [700. Search in a Binary Search Tree](https://leetcode.com/problems/search-in-a-binary-search-tree/) + +## 题目 + +Given the root node of a binary search tree (BST) and a value. You need to find the node in the BST that the node's value equals the given value. Return the subtree rooted with that node. If such node doesn't exist, you should return NULL. + +For example, + +```text +Given the tree: + 4 + / \ + 2 7 + / \ + 1 3 + +And the value to search: 2 +``` + +```text +You should return this subtree: + + 2 + / \ + 1 3 +``` + +In the example above, if we want to search the value 5, since there is no node with value 5, we should return NULL. + +Note that an empty tree is represented by NULL, therefore you would see the expected output (serialized tree format) as[], not null. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0700.search-in-a-binary-search-tree/search-in-a-binary-search-tree.go b/Algorithms/0700.search-in-a-binary-search-tree/search-in-a-binary-search-tree.go new file mode 100755 index 000000000..f2cafce0d --- /dev/null +++ b/Algorithms/0700.search-in-a-binary-search-tree/search-in-a-binary-search-tree.go @@ -0,0 +1,29 @@ +package problem0700 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ + +// TreeNode 是预定义的类型 +type TreeNode = kit.TreeNode + +func searchBST(root *TreeNode, val int) *TreeNode { + if root == nil { + return nil + } + switch { + case root.Val < val: + return searchBST(root.Right, val) + case val < root.Val: + return searchBST(root.Left, val) + default: + return root + } +} diff --git a/Algorithms/0700.search-in-a-binary-search-tree/search-in-a-binary-search-tree_test.go b/Algorithms/0700.search-in-a-binary-search-tree/search-in-a-binary-search-tree_test.go new file mode 100755 index 000000000..a96776929 --- /dev/null +++ b/Algorithms/0700.search-in-a-binary-search-tree/search-in-a-binary-search-tree_test.go @@ -0,0 +1,52 @@ +package problem0700 + +import ( + "fmt" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + val int + ans []int +}{ + + { + []int{4, 2, 7, 1, 3}, + 6, + nil, + }, + + { + []int{4, 2, 7, 1, 3}, + 2, + []int{2, 1, 3}, + }, + + // 可以有多个 testcase +} + +func Test_searchBST(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + root := kit.Ints2TreeNode(tc.root) + ans := kit.Tree2Preorder(searchBST(root, tc.val)) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_searchBST(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + searchBST(root, tc.val) + } + } +} diff --git a/Algorithms/0701.insert-into-a-binary-search-tree/README.md b/Algorithms/0701.insert-into-a-binary-search-tree/README.md new file mode 100755 index 000000000..62835acce --- /dev/null +++ b/Algorithms/0701.insert-into-a-binary-search-tree/README.md @@ -0,0 +1,45 @@ +# [701. Insert into a Binary Search Tree](https://leetcode.com/problems/insert-into-a-binary-search-tree/) + +## 题目 + +Given the root node of a binary search tree (BST) and a value to be inserted into the tree,insert the value into the BST. Return the root node of the BST after the insertion. It is guaranteed that the new value does not exist in the original BST. + +Note that there may existmultiple valid ways for theinsertion, as long as the tree remains a BST after insertion. You can return any of them. + +For example, + +```text +Given the tree: + 4 + / \ + 2 7 + / \ + 1 3 +And the value to insert: 5 +``` + +```text +You can return this binary search tree: + + 4 + / \ + 2 7 + / \ / + 1 3 5 +``` + +This tree is also valid: + +```text + 5 + / \ + 2 7 + / \ + 1 3 + \ + 4 +``` + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0701.insert-into-a-binary-search-tree/insert-into-a-binary-search-tree.go b/Algorithms/0701.insert-into-a-binary-search-tree/insert-into-a-binary-search-tree.go new file mode 100755 index 000000000..f1849e8ce --- /dev/null +++ b/Algorithms/0701.insert-into-a-binary-search-tree/insert-into-a-binary-search-tree.go @@ -0,0 +1,33 @@ +package problem0701 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ + +// TreeNode 是预定义的结构体 +type TreeNode = kit.TreeNode + +func insertIntoBST(root *TreeNode, val int) *TreeNode { + if root == nil { + return &TreeNode{ + Val: val, + } + } + + if root.Val <= val { + root.Right = insertIntoBST(root.Right, val) + } else { + root.Left = insertIntoBST(root.Left, val) + } + + return root +} diff --git a/Algorithms/0701.insert-into-a-binary-search-tree/insert-into-a-binary-search-tree_test.go b/Algorithms/0701.insert-into-a-binary-search-tree/insert-into-a-binary-search-tree_test.go new file mode 100755 index 000000000..68fa0cc1a --- /dev/null +++ b/Algorithms/0701.insert-into-a-binary-search-tree/insert-into-a-binary-search-tree_test.go @@ -0,0 +1,52 @@ +package problem0701 + +import ( + "fmt" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + val int + ans []int +}{ + + { + nil, + 4, + []int{4}, + }, + + { + []int{4, 2, 7, 1, 3}, + 5, + []int{4, 2, 1, 3, 7, 5}, // preorder + }, + + // 可以有多个 testcase +} + +func Test_insertIntoBST(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + root := kit.Ints2TreeNode(tc.root) + ans := kit.Tree2Preorder(insertIntoBST(root, tc.val)) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_insertIntoBST(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + insertIntoBST(root, tc.val) + } + } +} diff --git a/Algorithms/0703.kth-largest-element-in-a-stream/README.md b/Algorithms/0703.kth-largest-element-in-a-stream/README.md new file mode 100755 index 000000000..8429d307e --- /dev/null +++ b/Algorithms/0703.kth-largest-element-in-a-stream/README.md @@ -0,0 +1,25 @@ +# [703. Kth Largest Element in a Stream](https://leetcode.com/problems/kth-largest-element-in-a-stream/) + +## 题目 + +Design a class to findthe kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. + +YourKthLargestclass will have a constructor which accepts an integer k and an integer array nums, which contains initial elements fromthe stream. For each call to the method KthLargest.add, return the element representing the kth largest element in the stream. + +Example: + +int k = 3; +int[] arr = [4,5,8,2]; +KthLargest kthLargest = new KthLargest(3, arr); +kthLargest.add(3); // returns 4 +kthLargest.add(5); // returns 5 +kthLargest.add(10); // returns 5 +kthLargest.add(9); // returns 8 +kthLargest.add(4); // returns 8 + +Note: +You may assume thatnums' length>=k-1and k >=1. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0703.kth-largest-element-in-a-stream/kth-largest-element-in-a-stream.go b/Algorithms/0703.kth-largest-element-in-a-stream/kth-largest-element-in-a-stream.go new file mode 100755 index 000000000..605ab91d5 --- /dev/null +++ b/Algorithms/0703.kth-largest-element-in-a-stream/kth-largest-element-in-a-stream.go @@ -0,0 +1,66 @@ +package problem0703 + +import ( + "container/heap" +) + +// KthLargest object will be instantiated and called as such: +// obj := Constructor(k, nums); +// param_1 := obj.Add(val); +type KthLargest struct { + k int + heap intHeap +} + +// Constructor 创建 KthLargest +func Constructor(k int, nums []int) KthLargest { + h := intHeap(nums) + heap.Init(&h) + + for len(h) > k { + heap.Pop(&h) + } + + return KthLargest{ + k: k, + heap: h, + } +} + +// Add 负责添加元素 +func (kl *KthLargest) Add(val int) int { + heap.Push(&kl.heap, val) + + if len(kl.heap) > kl.k { + heap.Pop(&kl.heap) + } + + return kl.heap[0] +} + +type intHeap []int + +func (h intHeap) Len() int { + return len(h) +} + +func (h intHeap) Less(i, j int) bool { + return h[i] < h[j] +} + +func (h intHeap) Swap(i, j int) { + h[i], h[j] = h[j], h[i] +} +func (h *intHeap) Push(x interface{}) { + // Push 使用 *h,是因为 + // Push 增加了 h 的长度 + *h = append(*h, x.(int)) +} + +func (h *intHeap) Pop() interface{} { + // Pop 使用 *h ,是因为 + // Pop 减短了 h 的长度 + res := (*h)[len(*h)-1] + *h = (*h)[:len(*h)-1] + return res +} diff --git a/Algorithms/0703.kth-largest-element-in-a-stream/kth-largest-element-in-a-stream_test.go b/Algorithms/0703.kth-largest-element-in-a-stream/kth-largest-element-in-a-stream_test.go new file mode 100755 index 000000000..96e3fbd4e --- /dev/null +++ b/Algorithms/0703.kth-largest-element-in-a-stream/kth-largest-element-in-a-stream_test.go @@ -0,0 +1,41 @@ +package problem0703 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_kthLargest(t *testing.T) { + ast := assert.New(t) + k := 3 + nums := []int{4, 5, 8, 2} + + kl := Constructor(k, nums) + + adds := []int{3, 5, 10, 9, 4} + rets := []int{4, 5, 5, 8, 8} + + for i := range adds { + expected := rets[i] + actual := kl.Add(adds[i]) + ast.Equal(expected, actual, "kl.Add(%d) != %d\n", adds[i], expected) + } +} + +func Test_kthLargest_2(t *testing.T) { + ast := assert.New(t) + k := 1 + nums := []int{} + + kl := Constructor(k, nums) + + adds := []int{-3, -2, -4, 0, 4} + rets := []int{-3, -2, -2, 0, 4} + + for i := range adds { + expected := rets[i] + actual := kl.Add(adds[i]) + ast.Equal(expected, actual, "kl.Add(%d) != %d\n", adds[i], expected) + } +} diff --git a/Algorithms/0704.binary-search/README.md b/Algorithms/0704.binary-search/README.md new file mode 100755 index 000000000..9bacae75d --- /dev/null +++ b/Algorithms/0704.binary-search/README.md @@ -0,0 +1,31 @@ +# [704. Binary Search](https://leetcode.com/problems/binary-search/) + +## 题目 + +Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums. If target exists, then return its index, otherwise return -1. + +Example 1: + +```text +Input: nums = [-1,0,3,5,9,12], target = 9 +Output: 4 +Explanation: 9 exists in nums and its index is 4 +``` + +Example 2: + +```text +Input: nums = [-1,0,3,5,9,12], target = 2 +Output: -1 +Explanation: 2 does not exist in nums so return -1 +``` + +Note: + +1. You may assume that all elements in nums are unique. +1. n will be in the range [1, 10000]. +1. The value of each element in nums will be in the range [-9999, 9999]. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0704.binary-search/binary-search.go b/Algorithms/0704.binary-search/binary-search.go new file mode 100755 index 000000000..ed0790e90 --- /dev/null +++ b/Algorithms/0704.binary-search/binary-search.go @@ -0,0 +1,19 @@ +package problem0704 + +func search(a []int, target int) int { + l, r := 0, len(a)-1 + + for l <= r { + m := (l + r) / 2 + switch { + case a[m] < target: + l = m + 1 + case target < a[m]: + r = m - 1 + default: + return m + } + } + + return -1 +} diff --git a/Algorithms/0704.binary-search/binary-search_test.go b/Algorithms/0704.binary-search/binary-search_test.go new file mode 100755 index 000000000..9f278e682 --- /dev/null +++ b/Algorithms/0704.binary-search/binary-search_test.go @@ -0,0 +1,47 @@ +package problem0704 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + nums []int + target int + ans int +}{ + + { + []int{-1, 0, 3, 5, 9, 12}, + 9, + 4, + }, + + { + []int{-1, 0, 3, 5, 9, 12}, + 2, + -1, + }, + + // 可以有多个 testcase +} + +func Test_search(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, search(tc.nums, tc.target), "输入:%v", tc) + } +} + +func Benchmark_search(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + search(tc.nums, tc.target) + } + } +} diff --git a/Algorithms/0705.design-hashset/README.md b/Algorithms/0705.design-hashset/README.md new file mode 100755 index 000000000..6177a0369 --- /dev/null +++ b/Algorithms/0705.design-hashset/README.md @@ -0,0 +1,35 @@ +# [705. Design HashSet](https://leetcode.com/problems/design-hashset/) + +## 题目 + +Design a HashSetwithout using any built-in hash table libraries. + +To be specific, your design should include these functions: + +- add(value):Insert a value into the HashSet. +- contains(value) : Return whether the value exists in the HashSet or not. +- remove(value): Remove a value inthe HashSet. If the value does not exist in the HashSet, do nothing. + +Example: + +```text +MyHashSet hashSet = new MyHashSet(); +hashSet.add(1); +hashSet.add(2); +hashSet.contains(1); // returns true +hashSet.contains(3); // returns false (not found) +hashSet.add(2); +hashSet.contains(2); // returns true +hashSet.remove(2); +hashSet.contains(2); // returns false (already removed) +``` + +Note: + +- All values will be in the range of [0, 1000000]. +- The number of operations will be in the range of[1, 10000]. +- Please do not use the built-in HashSet library. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0705.design-hashset/design-hashset.go b/Algorithms/0705.design-hashset/design-hashset.go new file mode 100755 index 000000000..b604c9fe3 --- /dev/null +++ b/Algorithms/0705.design-hashset/design-hashset.go @@ -0,0 +1,30 @@ +package problem0705 + +// MyHashSet object will be instantiated and called as such: +// obj := Constructor(); +// obj.Add(key); +// obj.Remove(key); +// param_3 := obj.Contains(key); +type MyHashSet struct { + table []bool +} + +// Constructor initialize your data structure here. */ +func Constructor() MyHashSet { + return MyHashSet{table: make([]bool, 1000001)} +} + +// Add 添加 key +func (s *MyHashSet) Add(key int) { + s.table[key] = true +} + +// Remove 移除 key +func (s *MyHashSet) Remove(key int) { + s.table[key] = false +} + +// Contains returns true if this set contains the specified element */ +func (s *MyHashSet) Contains(key int) bool { + return s.table[key] +} diff --git a/Algorithms/0705.design-hashset/design-hashset_test.go b/Algorithms/0705.design-hashset/design-hashset_test.go new file mode 100755 index 000000000..859b44c43 --- /dev/null +++ b/Algorithms/0705.design-hashset/design-hashset_test.go @@ -0,0 +1,29 @@ +package problem0705 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + s := Constructor() + + s.Add(1) + s.Add(2) + + ast.True(s.Contains(1)) + + ast.False(s.Contains(3)) + + s.Add(2) + + ast.True(s.Contains(2)) + + s.Remove(2) + + ast.False(s.Contains(2)) + +} diff --git a/Algorithms/0706.design-hashmap/README.md b/Algorithms/0706.design-hashmap/README.md new file mode 100755 index 000000000..32248a9ed --- /dev/null +++ b/Algorithms/0706.design-hashmap/README.md @@ -0,0 +1,35 @@ +# [706. Design HashMap](https://leetcode.com/problems/design-hashmap/) + +## 题目 + +Design a HashMapwithout using any built-in hash table libraries. + +To be specific, your design should include these functions: + +- put(key, value) :Insert a (key, value) pair into the HashMap. If the value already exists in the HashMap, update the value. +- get(key): Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key. +- remove(key) :Remove the mapping for the value key if this map contains the mapping for the key. + +Example: + +```text +MyHashMap hashMap = new MyHashMap(); +hashMap.put(1, 1); +hashMap.put(2, 2); +hashMap.get(1); // returns 1 +hashMap.get(3); // returns -1 (not found) +hashMap.put(2, 1); // update the existing value +hashMap.get(2); // returns 1 +hashMap.remove(2); // remove the mapping for 2 +hashMap.get(2); // returns -1 (not found) +``` + +Note: + +- All keys and values will be in the range of [0, 1000000]. +- The number of operations will be in the range of[1, 10000]. +- Please do not use the built-in HashMap library. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0706.design-hashmap/design-hashmap.go b/Algorithms/0706.design-hashmap/design-hashmap.go new file mode 100755 index 000000000..52ed0910a --- /dev/null +++ b/Algorithms/0706.design-hashmap/design-hashmap.go @@ -0,0 +1,37 @@ +package problem0706 + +// NOTICE: 120 ms 的答案,使用了内置的数据结构 map,违反了题目的要求 + +// MyHashMap object will be instantiated and called as such: +// obj := Constructor(); +// obj.Put(key,value); +// param_2 := obj.Get(key); +// obj.Remove(key); +type MyHashMap struct { + table []int +} + +// Constructor initialize your data structure here. */ +func Constructor() MyHashMap { + return MyHashMap{ + table: make([]int, 1000001), + } +} + +// Put value will always be non-negative. */ +func (m *MyHashMap) Put(key int, value int) { + // value + 1 是为了让 m.table 的默认值 0 和 value+1 的取值范围区分开。 + // m.table[key] = 0 就表示了 key 没有对应值 + // m.table[key] = 1 表示,key 有对应的值是 1-1 = 0 + m.table[key] = value + 1 +} + +// Get returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key +func (m *MyHashMap) Get(key int) int { + return m.table[key] - 1 +} + +// Remove the mapping of the specified value key if this map contains a mapping for the key +func (m *MyHashMap) Remove(key int) { + m.table[key] = 0 +} diff --git a/Algorithms/0706.design-hashmap/design-hashmap_test.go b/Algorithms/0706.design-hashmap/design-hashmap_test.go new file mode 100755 index 000000000..2022f5585 --- /dev/null +++ b/Algorithms/0706.design-hashmap/design-hashmap_test.go @@ -0,0 +1,29 @@ +package problem0706 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + m := Constructor() + + m.Put(1, 1) + + m.Put(2, 2) + + ast.Equal(1, m.Get(1)) + + ast.Equal(-1, m.Get(3)) + + m.Put(2, 1) + + ast.Equal(1, m.Get(2)) + + m.Remove(2) + + ast.Equal(-1, m.Get(2)) +} diff --git a/Algorithms/0707.design-linked-list/README.md b/Algorithms/0707.design-linked-list/README.md new file mode 100755 index 000000000..cc5b34a4f --- /dev/null +++ b/Algorithms/0707.design-linked-list/README.md @@ -0,0 +1,35 @@ +# [707. Design Linked List](https://leetcode.com/problems/design-linked-list/) + +## 题目 + +Design yourimplementation of the linked list. You can choose to use the singly linked list or the doubly linked list. A node in a singlylinked list should have two attributes: valand next. val is the value of the current node, and nextisapointer/reference to the next node. If you want to use the doubly linked list,you will needone more attribute prev to indicate the previous node in the linked list. Assume all nodes in the linked list are 0-indexed. + +Implement these functions in your linked list class: + +- get(index) : Get the value ofthe index-thnode in the linked list. If the index is invalid, return -1. +- addAtHead(val) : Add a node of value valbefore the first element of the linked list. After the insertion, the new node will be the first node of the linked list. +- addAtTail(val) : Append a node of value valto the last element of the linked list. +- addAtIndex(index, val) : Add a node of value valbefore the index-thnode in the linked list.If indexequalsto the length oflinked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted. +- deleteAtIndex(index) : Deletethe index-thnode in the linked list, if the index is valid. + +Example: + +```text +MyLinkedList linkedList = new MyLinkedList(); +linkedList.addAtHead(1); +linkedList.addAtTail(3); +linkedList.addAtIndex(1, 2); // linked list becomes 1->2->3 +linkedList.get(1); // returns 2 +linkedList.deleteAtIndex(1); // now the linked list is 1->3 +linkedList.get(1); // returns 3 +``` + +Note: + +- All values will be in the range of [1, 1000]. +- The number of operations will be in the range of[1, 1000]. +- Please do not use the built-in LinkedList library. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0707.design-linked-list/design-linked-list.go b/Algorithms/0707.design-linked-list/design-linked-list.go new file mode 100755 index 000000000..67cd7fc1f --- /dev/null +++ b/Algorithms/0707.design-linked-list/design-linked-list.go @@ -0,0 +1,161 @@ +package problem0707 + +// MyLinkedList object will be instantiated and called as such: +// obj := Constructor(); +// param_1 := obj.Get(index); +// obj.AddAtHead(val); +// obj.AddAtTail(val); +// obj.AddAtIndex(index,val); +// obj.DeleteAtIndex(index); +type MyLinkedList struct { + size int + head, tail *node +} + +type node struct { + val int + next *node +} + +// Constructor initialize your data structure here. */ +func Constructor() MyLinkedList { + t := &node{} + h := &node{next: t} + // 把 head 和 tail 分别用空 node 单独表示 + // 会让 AddAtHead 和 AddAtTail 的逻辑非常简单 + // 可以试着让 size = 0 的时候, head 与 tail 为 nil + // 看看程序的结构有多复杂 + return MyLinkedList{ + head: h, + tail: t, + } +} + +// Get the value of the index-th node in the linked list. If the index is invalid, return -1. */ +func (l *MyLinkedList) Get(index int) int { + if index < 0 || l.size <= index { + return -1 + } + i, cur := 0, l.head.next + for i < index { + i++ + cur = cur.next + } + return cur.val +} + +// AddAtHead a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list. +func (l *MyLinkedList) AddAtHead(val int) { + nd := &node{val: val} + nd.next = l.head.next + l.head.next = nd + l.size++ +} + +// AddAtTail append a node of value val to the last element of the linked list. +func (l *MyLinkedList) AddAtTail(val int) { + l.tail.val = val + nd := &node{} + l.tail.next = nd + l.tail = nd + l.size++ +} + +// AddAtIndex add a node of value val before the index-th node in the linked list. If index equals to the length of linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted. +func (l *MyLinkedList) AddAtIndex(index int, val int) { + switch { + case index < 0 || l.size < index: + return + case index == 0: + l.AddAtHead(val) + return + case index == l.size: + l.AddAtTail(val) + return + } + + i, cur := -1, l.head + for i+1 < index { + i++ + cur = cur.next + } + + nd := &node{val: val} + nd.next = cur.next + cur.next = nd + + l.size++ +} + +// DeleteAtIndex delete the index-th node in the linked list, if the index is valid. +func (l *MyLinkedList) DeleteAtIndex(index int) { + if index < 0 || l.size <= index { + return + } + + i, cur := -1, l.head + for i+1 < index { + i++ + cur = cur.next + } + + cur.next = cur.next.next + + l.size-- +} + +// NOTICE: Get 的调用次数,远多余其他方法,以下实现方式更快 + +// type MyLinkedList struct { +// list []int +// } + +// // +// // Constructor initialize your data structure here. */ +// func Constructor() MyLinkedList { +// return MyLinkedList{list: make([]int, 0, 1000)} +// } + +// // +// // Get the value of the index-th node in the linked list. If the index is invalid, return -1. */ +// func (l *MyLinkedList) Get(index int) int { +// if len(l.list) <= index { +// return -1 +// } +// return l.list[index] +// } + +// // +// // AddAtHead a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list. +// func (l *MyLinkedList) AddAtHead(val int) { +// l.list = append([]int{val}, l.list...) +// } + +// // +// // AddAtTail append a node of value val to the last element of the linked list. +// func (l *MyLinkedList) AddAtTail(val int) { +// l.list = append(l.list, val) +// } + +// // +// // AddAtIndex add a node of value val before the index-th node in the linked list. If index equals to the length of linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted. +// func (l *MyLinkedList) AddAtIndex(index int, val int) { +// size := len(l.list) +// if index < 0 || size < index { +// return +// } +// l.list = append(l.list, 0) +// copy(l.list[index+1:], l.list[index:]) +// l.list[index] = val +// } + +// // +// // DeleteAtIndex delete the index-th node in the linked list, if the index is valid. +// func (l *MyLinkedList) DeleteAtIndex(index int) { +// size := len(l.list) +// if index < 0 || size <= index { +// return +// } +// copy(l.list[index:], l.list[index+1:]) +// l.list = l.list[:size-1] +// } diff --git a/Algorithms/0707.design-linked-list/design-linked-list_test.go b/Algorithms/0707.design-linked-list/design-linked-list_test.go new file mode 100755 index 000000000..986490f50 --- /dev/null +++ b/Algorithms/0707.design-linked-list/design-linked-list_test.go @@ -0,0 +1,67 @@ +package problem0707 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_myLinkedList(t *testing.T) { + ast := assert.New(t) + + l := Constructor() + + l.AddAtHead(1) + l.AddAtTail(3) + + l.AddAtIndex(5, 5) + ast.Equal(-1, l.Get(5)) + + l.AddAtIndex(1, 2) + + ast.Equal(2, l.Get(1)) + + l.DeleteAtIndex(1) + + ast.Equal(3, l.Get(1)) +} +func Test_myLinkedList_2(t *testing.T) { + ast := assert.New(t) + + l := Constructor() + + l.AddAtTail(2) + l.AddAtHead(1) + l.AddAtTail(4) + l.AddAtTail(5) + + l.AddAtIndex(2, 3) + l.AddAtIndex(0, 0) + l.AddAtIndex(6, 6) + + ast.Equal(1, l.Get(1)) + + l.DeleteAtIndex(5) + l.DeleteAtIndex(8) + + ast.Equal(6, l.Get(5)) + +} +func Test_myLinkedList_3(t *testing.T) { + ast := assert.New(t) + + l := Constructor() + + ast.Equal(-1, l.Get(0)) + + l.AddAtIndex(1, 2) + + ast.Equal(-1, l.Get(0)) + ast.Equal(-1, l.Get(1)) + + l.AddAtIndex(0, 1) + + ast.Equal(1, l.Get(0)) + ast.Equal(-1, l.Get(1)) + +} diff --git a/Algorithms/0709.to-lower-case/README.md b/Algorithms/0709.to-lower-case/README.md new file mode 100755 index 000000000..c76308786 --- /dev/null +++ b/Algorithms/0709.to-lower-case/README.md @@ -0,0 +1,30 @@ +# [709. To Lower Case](https://leetcode.com/problems/to-lower-case/) + +## 题目 + +Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase. + +Example 1: + +```text +Input: "Hello" +Output: "hello" +``` + +Example 2: + +```text +Input: "here" +Output: "here" +``` + +Example 3: + +```text +Input: "LOVELY" +Output: "lovely" +``` + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0709.to-lower-case/to-lower-case.go b/Algorithms/0709.to-lower-case/to-lower-case.go new file mode 100755 index 000000000..2d0817cca --- /dev/null +++ b/Algorithms/0709.to-lower-case/to-lower-case.go @@ -0,0 +1,7 @@ +package problem0709 + +import "strings" + +func toLowerCase(str string) string { + return strings.ToLower(str) +} diff --git a/Algorithms/0709.to-lower-case/to-lower-case_test.go b/Algorithms/0709.to-lower-case/to-lower-case_test.go new file mode 100755 index 000000000..c18e83f20 --- /dev/null +++ b/Algorithms/0709.to-lower-case/to-lower-case_test.go @@ -0,0 +1,49 @@ +package problem0709 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + str string + ans string +}{ + + { + "Hello", + "hello", + }, + + { + "here", + "here", + }, + + { + "LOVELY", + "lovely", + }, + + // 可以有多个 testcase +} + +func Test_toLowerCase(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, toLowerCase(tc.str), "输入:%v", tc) + } +} + +func Benchmark_toLowerCase(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + toLowerCase(tc.str) + } + } +} diff --git a/Algorithms/0710.random-pick-with-blacklist/README.md b/Algorithms/0710.random-pick-with-blacklist/README.md new file mode 100755 index 000000000..92a3ff998 --- /dev/null +++ b/Algorithms/0710.random-pick-with-blacklist/README.md @@ -0,0 +1,57 @@ +# [710. Random Pick with Blacklist](https://leetcode.com/problems/random-pick-with-blacklist/) + +## 题目 + +Given a blacklistB containing unique integersfrom [0, N), write a function to return a uniform random integer from [0, N) which is NOTin B. + +Optimize it such that it minimizes the call to system’s Math.random(). + +Note: + +- 1 <= N <= 1000000000 +- 0 <= B.length < min(100000, N) +- [0, N)does NOT include N. See interval notation. + +Example 1: + +```text +Input: +["Solution","pick","pick","pick"] +[[1,[]],[],[],[]] +Output: [null,0,0,0] +``` + +Example 2: + +```text +Input: +["Solution","pick","pick","pick"] +[[2,[]],[],[],[]] +Output: [null,1,1,1] +``` + +Example 3: + +```text +Input: +["Solution","pick","pick","pick"] +[[3,[1]],[],[],[]] +Output: [null,0,0,2] +``` + +Example 4: + +```text +Input: +["Solution","pick","pick","pick"] +[[4,[2]],[],[],[]] +Output: [null,1,3,1] +``` + +Explanation of Input Syntax: + +The input is two lists:the subroutines calledand theirarguments.Solution'sconstructor has two arguments,N and the blacklist B. pick has no arguments.Argumentsarealways wrapped with a list, even if there aren't any. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0710.random-pick-with-blacklist/random-pick-with-blacklist.go b/Algorithms/0710.random-pick-with-blacklist/random-pick-with-blacklist.go new file mode 100755 index 000000000..7774dac84 --- /dev/null +++ b/Algorithms/0710.random-pick-with-blacklist/random-pick-with-blacklist.go @@ -0,0 +1,66 @@ +package problem0710 + +import ( + "math/rand" + "time" +) + +// Solution 包含了 BlackList 和 N +type Solution struct { + M int + blackMap map[int]int +} + +// Constructor 构建了 Solution +func Constructor(N int, blacklist []int) Solution { + rand.Seed(time.Now().UnixNano()) + // M 是可以自由选择的数的个数 + M := N - len(blacklist) + + blackMap := make(map[int]int, len(blacklist)) + // 由于 blacklist 是乱序的,只好先把 blacklist 中的元素全部添加为 blackMap 的 key + for _, b := range blacklist { + blackMap[b] = b + } + + for _, b := range blacklist { + if b >= M { + continue + } + + // 对于所有的 b < M + // 与 [M,N) 中某个不在 BlackList 中的数,关联上 + + N-- + for blackMap[N] == N { + N-- + } + + blackMap[b] = N + } + + return Solution{ + M: M, + blackMap: blackMap, + } + +} + +// Pick 选取了不在 BlackList 中的值 +func (s *Solution) Pick() int { + // 在 [0,M) 中任意挑选一个数 r + r := rand.Intn(s.M) + if t, ok := s.blackMap[r]; ok { + // r 是 s.blackMap 的 key + // 说明 r 是 BlackList 中的值 + // 需要返回 与 r 相关联的值 + return t + } + return r +} + +/** + * Your Solution object will be instantiated and called as such: + * obj := Constructor(N, blacklist); + * param_1 := obj.Pick(); + */ diff --git a/Algorithms/0710.random-pick-with-blacklist/random-pick-with-blacklist_test.go b/Algorithms/0710.random-pick-with-blacklist/random-pick-with-blacklist_test.go new file mode 100755 index 000000000..62c535fa1 --- /dev/null +++ b/Algorithms/0710.random-pick-with-blacklist/random-pick-with-blacklist_test.go @@ -0,0 +1,46 @@ +package problem0710 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_Solution(t *testing.T) { + ast := assert.New(t) + + N := 100000 + blacklist := make([]int, 0, N) + for i := 1; i < N; i++ { + blacklist = append(blacklist, i) + } + s := Constructor(N, blacklist) + + for i := 0; i < 100000; i++ { + ast.Equal(0, s.Pick()) + } +} +func Test_Solution_2(t *testing.T) { + ast := assert.New(t) + + N := 2 + blacklist := make([]int, 0, N) + s := Constructor(N, blacklist) + + for i := 0; i < 10; i++ { + p := s.Pick() + ast.True(p == 1 || p == 0, "%d", i) + } +} + +func Test_Solution_3(t *testing.T) { + ast := assert.New(t) + + N := 10 + blacklist := []int{0, 2, 4, 6, 8} + s := Constructor(N, blacklist) + + for i := 0; i < 10; i++ { + ast.NotContains(blacklist, s.Pick()) + } +} diff --git a/Algorithms/0817.linked-list-components/linked-list-components.go b/Algorithms/0817.linked-list-components/linked-list-components.go index cd2efde33..021dd780c 100755 --- a/Algorithms/0817.linked-list-components/linked-list-components.go +++ b/Algorithms/0817.linked-list-components/linked-list-components.go @@ -1,8 +1,6 @@ package problem0817 import ( - "sort" - "github.com/aQuaYi/LeetCode-in-Go/kit" ) @@ -19,56 +17,29 @@ import ( type ListNode = kit.ListNode func numComponents(head *ListNode, G []int) int { - // 收集 list 中各个数的索引号 - // 方便以后判断连通性 - indexs := make(map[int]int, len(G)*2) - i := 0 - for head != nil { - indexs[head.Val] = i - i++ - head = head.Next + isInG := make(map[int]bool, len(G)) + for i := range G { + isInG[G[i]] = true } - // 初步统计连通性 - // temp[i][0] == 3 表示,第 i 个联通的链条 起点 是 3 - // temp[i][1] == 5 表示,第 i 个联通的链条 终点 是 5 - temp := make([][2]int, 0, len(G)) - for _, num := range G { - idx := indexs[num] - isConnected := false - for i := range temp { - // 如果 idx 与 temp[i] 的 起点 相连 - if idx+1 == temp[i][0] { - temp[i][0] = idx - isConnected = true - break - } - // 如果 idx 与 temp[i] 的 终点 相连 - if temp[i][1] == idx-1 { - temp[i][1] = idx - isConnected = true - break - } - } - // 如果 idx 不与 temp 中的任何链条相连 - if !isConnected { - temp = append(temp, [2]int{idx, idx}) - } - } - - // 按照链条的起点排序 - sort.Slice(temp, func(i int, j int) bool { - return temp[i][0] < temp[j][0] - }) + res := 0 - t := temp[0] - res := 1 - for i := 1; i < len(temp); i++ { - // 如果前后两个链条不相连 - if t[1]+1 != temp[i][0] { + for head != nil { + /** + * head: 0->1->2->3->4 + * G = [0, 3, 1, 4] + * 结果为 2 + * 可以按照 connected components 划分 head + * head: (0->1)->2->(3->4) + * 每个单独的 connected components 的特点是 + * 最后一个 node 的 Next.Val 不在 G 中,或者是 list 的结尾 + * 那么,统计下面 if 成立的次数,就是所需的结果了 + */ + if isInG[head.Val] && + (head.Next == nil || !isInG[head.Next.Val]) { res++ } - t = temp[i] + head = head.Next } return res diff --git a/Algorithms/0821.shortest-distance-to-a-character/README.md b/Algorithms/0821.shortest-distance-to-a-character/README.md index ce35a532e..f941d5f1b 100755 --- a/Algorithms/0821.shortest-distance-to-a-character/README.md +++ b/Algorithms/0821.shortest-distance-to-a-character/README.md @@ -7,7 +7,7 @@ Given a string S and a character C, return an array of integers representing the Example 1: ```text -Input: S = "loveleetcode", C = 'e' +Input: S = "loveleetcode", C = "e" Output: [3, 2, 1, 0, 1, 0, 0, 1, 2, 2, 1, 0] ``` diff --git a/Algorithms/0821.shortest-distance-to-a-character/shortest-distance-to-a-character.go b/Algorithms/0821.shortest-distance-to-a-character/shortest-distance-to-a-character.go index 7d3ecc254..30ffb574e 100755 --- a/Algorithms/0821.shortest-distance-to-a-character/shortest-distance-to-a-character.go +++ b/Algorithms/0821.shortest-distance-to-a-character/shortest-distance-to-a-character.go @@ -1,32 +1,28 @@ package problem0821 func shortestToChar(S string, C byte) []int { - res := make([]int, len(S)) - left, right := -len(S), next(-1, C, S) - for i := range S { - if i > right { - left = right - right = next(right, C, S) - } + n := len(S) - res[i] = min(i-left, right-i) + res := make([]int, n) + for i := range res { + res[i] = n } - return res -} + left, right := -n, 2*n -func next(right int, c byte, s string) int { - idx := right + 1 - for idx < len(s) { - if s[idx] == c { - return idx + for i := 0; i < n; i++ { + j := n - i - 1 + if S[i] == C { + left = i } - idx++ + if S[j] == C { + right = j + } + res[i] = min(res[i], dist(i, left)) + res[j] = min(res[j], dist(j, right)) } - // 由于 s[right+1:] 中不再含有 c - // 返回的 idx 需要达到 2*len(s) - // 来确保后续的 min 操作的正确性 - return len(s) * 2 + + return res } func min(a, b int) int { @@ -35,3 +31,10 @@ func min(a, b int) int { } return b } + +func dist(i, j int) int { + if i > j { + return i - j + } + return j - i +} diff --git a/Algorithms/0827.making-a-large-island/README.md b/Algorithms/0827.making-a-large-island/README.md new file mode 100755 index 000000000..cf26de4fe --- /dev/null +++ b/Algorithms/0827.making-a-large-island/README.md @@ -0,0 +1,40 @@ +# [827. Making A Large Island](https://leetcode.com/problems/making-a-large-island/) + +## 题目 + +In a 2D grid of 0s and 1s, we change at most one 0 to a 1. + +After, what is the size of the largest island?(An island is a 4-directionally connected group of 1s). + +Example 1: + +```text +Input: [[1, 0], [0, 1]] +Output: 3 +Explanation: Change one 0 to 1 and connect two 1s, then we get an island with area = 3. +``` + +Example 2: + +```text +Input: [[1, 1], [1, 0]] +Output: 4 +Explanation: Change the 0 to 1 and make the island bigger, only one island with area = 1. +``` + +Example 3: + +```text +Input: [[1, 1], [1, 1]] +Output: 4 +Explanation: Can't change any 0 to 1, only one island with area = 1. +``` + +Notes: + +1. 1 <= grid.length = grid[0].length <= 50. +1. 0 <= grid[i][j] <= 1. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0827.making-a-large-island/making-a-large-island.go b/Algorithms/0827.making-a-large-island/making-a-large-island.go new file mode 100755 index 000000000..403de68d3 --- /dev/null +++ b/Algorithms/0827.making-a-large-island/making-a-large-island.go @@ -0,0 +1,100 @@ +package problem0827 + +var dx = []int{-1, 1, 0, 0} +var dy = []int{0, 0, -1, 1} + +func largestIsland(grid [][]int) int { + m, n := len(grid), len(grid[0]) + + // 收集 grid 中的 0 + zeros := collectZero(grid) + if len(zeros) <= 1 { + return m * n + } + + colors := addColor(grid) + + res := 0 + + for _, z := range zeros { + i, j := z[0], z[1] + isConnected := make([]bool, len(colors)) + temp := 1 + for k := 0; k < 4; k++ { + x := i + dx[k] + y := j + dy[k] + if 0 <= x && x < m && + 0 <= y && y < n && + grid[x][y] > 1 && !isConnected[grid[x][y]] { + temp += colors[grid[x][y]] + isConnected[grid[x][y]] = true + } + } + res = max(res, temp) + } + + return res +} + +func collectZero(grid [][]int) [][]int { + res := make([][]int, 0, len(grid)) + for i := range grid { + for j := range grid[i] { + if grid[i][j] == 0 { + res = append(res, []int{i, j}) + } + } + } + return res +} + +// 返回每种色彩的数量 +func addColor(grid [][]int) []int { + m, n := len(grid), len(grid[0]) + res := make([]int, 2, m) + color := 2 + + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + if grid[i][j] == 1 { + res = append(res, bfs(i, j, color, grid)) + color++ + } + } + } + + return res +} + +func bfs(i, j, color int, grid [][]int) int { + m, n := len(grid), len(grid[0]) + queue := [][]int{[]int{i, j}} + grid[i][j] = color + res := 1 + + for len(queue) > 0 { + next := queue[0] + queue = queue[1:] + i, j := next[0], next[1] + for k := 0; k < 4; k++ { + x := i + dx[k] + y := j + dy[k] + if 0 <= x && x < m && + 0 <= y && y < n && + grid[x][y] == 1 { + queue = append(queue, []int{x, y}) + grid[x][y] = color + res++ + } + } + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0827.making-a-large-island/making-a-large-island_test.go b/Algorithms/0827.making-a-large-island/making-a-large-island_test.go new file mode 100755 index 000000000..853dd6525 --- /dev/null +++ b/Algorithms/0827.making-a-large-island/making-a-large-island_test.go @@ -0,0 +1,64 @@ +package problem0827 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + ans int +}{ + + { + [][]int{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}, + 1276, + }, + + { + [][]int{{1, 0}, {0, 1}}, + 3, + }, + + { + [][]int{{1, 1}, {1, 0}}, + 4, + }, + + { + [][]int{{1, 1}, {1, 1}}, + 4, + }, + + { + [][]int{ + {1, 1, 1, 1}, + {1, 1, 1, 0}, + {1, 1, 0, 0}, + {1, 0, 0, 1}, + }, + 11, + }, + + // 可以有多个 testcase +} + +func Test_largestIsland(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, largestIsland(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_largestIsland(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + largestIsland(tc.grid) + } + } +} diff --git a/Algorithms/0828.unique-letter-string/README.md b/Algorithms/0828.unique-letter-string/README.md new file mode 100755 index 000000000..99c793b40 --- /dev/null +++ b/Algorithms/0828.unique-letter-string/README.md @@ -0,0 +1,74 @@ +# [828. Unique Letter String](https://leetcode.com/problems/unique-letter-string/) + +## 题目 + +A character is unique in string S if it occurs exactly once in it. + +For example, in string S = "LETTER", the only unique characters are "L" and "R". + +Let's define UNIQ(S) as the number of unique characters in string S. + +For example, UNIQ("LETTER") = 2. + +Given a string S with only uppercases, calculate the sum of UNIQ(substring) over all non-empty substrings of S. + +If there are two or more equal substrings at different positions in S, we consider them different. + +Since the answer can be very large, retrun the answermodulo `10^9+7`. + +Example 1: + +```text +Input: "ABC" +Output: 10 +Explanation: All possible substrings are: "A","B","C","AB","BC" and "ABC". +Evey substring is composed with only unique letters. +Sum of lengths of all substring is 1 + 1 + 1 + 2 + 2 + 3 = 10 +``` + +Example 2: + +```text +Input: "ABA" +Output: 8 +Explanation: The same as example 1, except uni("ABA") = 1. +``` + +Note: 0 <= S.length <= 10000. + +## 解题思路 + +from + +Intuition: + +Let's think about how a character can be found as a unique character. + +Think about string "XAXAXXAX" and focus on making the second "A" a unique character. +We can take "XA(XAXX)AX" and between "()" is our substring. +We can see here, to make the second "A" counted as a uniq character, we need to: + +insert "(" somewhere between the first and second A +insert ")" somewhere between the second and third A +For step 1 we have "A(XA" and "AX(A", 2 possibility. +For step 2 we have "A)XXA", "AX)XA" and "AXX)A", 3 possibilities. + +So there are in total 2 * 3 = 6 ways to make the second A a unique character in a substring. +In other words, there are only 6 substring, in which this A contribute 1 point as unique string. + +Instead of counting all unique characters and struggling with all possible substrings, +we can count for every char in S, how many ways to be found as a unique char. +We count and sum, and it will be out answer. + +Explanation: + +index[26][2] record last two occurrence index for every upper characters. +Initialise all values in index to -1. +Loop on string S, for every character c, update its last two occurrence index to index[c]. +Count when loop. For example, if "A" appears twice at index 3, 6, 9 seperately, we need to count: +For the first "A": (6-3) * (3-(-1))" +For the second "A": (9-6) * (6-3)" +For the third "A": (N-9) * (9-6)" +Complexity: +One pass, time complexity O(N). +Space complexity O(1). \ No newline at end of file diff --git a/Algorithms/0828.unique-letter-string/unique-letter-string.go b/Algorithms/0828.unique-letter-string/unique-letter-string.go new file mode 100755 index 000000000..fb4f342e9 --- /dev/null +++ b/Algorithms/0828.unique-letter-string/unique-letter-string.go @@ -0,0 +1,35 @@ +package problem0828 + +const module = 1e9 + 7 + +func uniqueLetterString(s string) int { + size := len(s) + if size == 0 { + return 0 + } + + index := [26][]int{} + for i := range index { + index[i] = make([]int, 0, size) + } + + for i, b := range s { + index[b-'A'] = append(index[b-'A'], i) + } + + res := 0 + for i := range index { + if len(index[i]) == 0 { + continue + } + index[i] = append(index[i], size) + a, b, c := 0, -1, index[i][0] + for j := 1; j < len(index[i]); j++ { + a, b, c = b, c, index[i][j] + res += ((b - a) * (c - b)) % module + res %= module + } + } + + return res +} diff --git a/Algorithms/0828.unique-letter-string/unique-letter-string_test.go b/Algorithms/0828.unique-letter-string/unique-letter-string_test.go new file mode 100755 index 000000000..557d74dca --- /dev/null +++ b/Algorithms/0828.unique-letter-string/unique-letter-string_test.go @@ -0,0 +1,64 @@ +package problem0828 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans int +}{ + + { + "DELQGVWNZKIJJPSXOVWWIZUXCEGWSQLESNSRBMKZARFPAXSVWQEZDENDAHNNIBHGHTFDLPGDLFXMIYRFNLMXHNPIFUAXINXPXLCTTJNLGGMKJIOEWBECNOFQPVCIKIAZMNGHEHFMCPWSMJTMGVSXTOGCGUYKFMNCGLCBRAFJLJVPIVDOLJBURULPGXBVDCEWXXXLTRMSHPKSPFDGNVOCZWDXJUWVNAREDOKTZMIUDKDQWWWSAEUUDBHMWZELOSBIHMAYJEMGZPMDOOGSCKLVHTGMETHUISCLJKDOQEWGVBULEMUXGTRKGXYFDIZTZWMLOFTCANBGUARNWQEQWGMIKMORVQUZANJNRNPMJWYLVHWKDFLDDBBMILAKGFROEQAMEVONUVHOHGPKLBPNYZFPLXNBCIFENCGIMIDCXIIQJWPVVCOCJTSKSHVMQJNLHSQTEZQTTMOXUSKBMUJEJDBJQNXECJGSZUDENJCPTTSREKHPRIISXMWBUGMTOVOTRKQCFSDOTEFPSVQINYLHXYVZTVAMWGPNKIDLOPGAMWSKDXEPLPPTKUHEKBQAWEBMORRZHBLOGIYLTPMUVBPGOOOIEBJEGTKQKOUURHSEJCMWMGHXYIAOGKJXFAMRLGTPNSLERNOHSDFSSFASUJTFHBDMGBQOKZRBRAZEQQVWFRNUNHBGKRFNBETEDJIWCTUBJDPFRRVNZENGRANELPHSDJLKVHWXAXUTMPWHUQPLTLYQAATEFXHZARFAUDLIUDEHEGGNIYICVARQNRJJKQSLXKZZTFPVJMOXADCIGKUXCVMLPFJGVXMMBEKQXFNXNUWOHCSZSEZWZHDCXPGLROYPMUOBDFLQMTTERGSSGVGOURDWDSEXONCKWHDUOVDHDESNINELLCTURJHGCJWVIPNSISHRWTFSFNRAHJAJNNXKKEMESDWGIYIQQRLUUADAXOUEYURQRVZBCSHXXFLYWFHDZKPHAGYOCTYGZNPALAUZSTOU", + 629134, + }, + + { + "", + 0, + }, + + { + "BABABBABAA", + 35, + }, + + { + "AAA", + 3, + }, + + { + "ABC", + 10, + }, + + { + "ABA", + 8, + }, + + // 可以有多个 testcase +} + +func Test_uniqueLetterString(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, uniqueLetterString(tc.S), "输入:%v", tc) + } +} + +func Benchmark_uniqueLetterString(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + uniqueLetterString(tc.S) + } + } +} diff --git a/Algorithms/0831.masking-personal-information/README.md b/Algorithms/0831.masking-personal-information/README.md new file mode 100755 index 000000000..5d52d5d18 --- /dev/null +++ b/Algorithms/0831.masking-personal-information/README.md @@ -0,0 +1,76 @@ +# [831. Masking Personal Information](https://leetcode.com/problems/masking-personal-information/) + +## 题目 + +We are given apersonal information string S, which may representeither an email address or a phone number. + +We would like to mask thispersonal information according to thefollowing rules: + +1.Email address: + +We define aname to be a string of length >= 2 consistingof only lowercase lettersa-z or uppercaselettersA-Z. + +An email address starts with a name, followed by thesymbol '@', followed by a name, followed by thedot'.'andfollowed by a name. + +All email addresses areguaranteed to be valid and in the format of"name1@name2.name3". + +To mask an email, all names must be converted to lowercase and all letters between the first and last letter of the first name must be replaced by 5 asterisks '*'. + +2.Phone number: + +A phone number is a string consisting ofonly the digits 0-9 or the characters from the set {'+', '-', '(', ')', ''}.You may assume a phonenumber contains10 to 13 digits. + +The last 10 digits make up the localnumber, while the digits before those make up the country code. Note thatthe country code is optional. We want to expose only the last 4 digitsand mask all otherdigits. + +The localnumbershould be formatted and masked as "***-***-1111",where 1 represents the exposed digits. + +To mask a phone number with country code like "+111 111 111 1111", we write it in the form "+***-***-***-1111". The '+'sign and the first '-'sign before the local number should only exist if there is a country code. For example, a 12 digit phone number maskshould startwith "+**-". + +Note that extraneous characters like "(", ")", " ", as well asextra dashes or plus signs not part of the above formatting scheme should be removed. + +Return the correct "mask" of the information provided. + +Example 1: + +```text +Input: "LeetCode@LeetCode.com" +Output: "l*****e@leetcode.com" +Explanation:All names are converted to lowercase, and the letters between the + first and last letter of the first name is replaced by 5 asterisks. + Therefore, "leetcode" -> "l*****e". +``` + +Example 2: + +```text +Input: "AB@qq.com" +Output: "a*****b@qq.com" +Explanation:There must be 5 asterisks between the first and last letter + of the first name "ab". Therefore, "ab" -> "a*****b". +``` + +Example 3: + +```text +Input: "1(234)567-890" +Output: "***-***-7890" +Explanation:10 digits in the phone number, which means all digits make up the local number. +``` + +Example 4: + +```text +Input: "86-(10)12345678" +Output: "+**-***-***-5678" +Explanation:12 digits, 2 digits for country code and 10 digits for local number. +``` + +Notes: + +1. S.length<=40. +1. Emails have length at least 8. +1. Phone numbers have length at least 10. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0831.masking-personal-information/masking-personal-information.go b/Algorithms/0831.masking-personal-information/masking-personal-information.go new file mode 100755 index 000000000..92fc38031 --- /dev/null +++ b/Algorithms/0831.masking-personal-information/masking-personal-information.go @@ -0,0 +1,34 @@ +package problem0831 + +import "strings" + +func maskPII(s string) string { + if strings.ContainsRune(s, '@') { + return maskEmailAddress(strings.ToLower(s)) + } + return maskPhoneNumber(s) +} + +func maskEmailAddress(s string) string { + ss := strings.Split(s, "@") + ss[0] = ss[0][0:1] + "*****" + ss[0][len(ss[0])-1:] + return strings.Join(ss, "@") +} + +func maskPhoneNumber(s string) string { + tmp := make([]byte, 0, 13) + for i := range s { + if '0' <= s[i] && s[i] <= '9' { + tmp = append(tmp, s[i]) + } + } + + size := len(tmp) + s = string(tmp[size-4:]) + + if size == 10 { + return "***-***-" + s + } + + return "+" + strings.Repeat("*", size-10) + "-***-***-" + s +} diff --git a/Algorithms/0831.masking-personal-information/masking-personal-information_test.go b/Algorithms/0831.masking-personal-information/masking-personal-information_test.go new file mode 100755 index 000000000..e96c7c227 --- /dev/null +++ b/Algorithms/0831.masking-personal-information/masking-personal-information_test.go @@ -0,0 +1,54 @@ +package problem0831 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans string +}{ + + { + "LeetCode@LeetCode.com", + "l*****e@leetcode.com", + }, + + { + "AB@qq.com", + "a*****b@qq.com", + }, + + { + "1(234)567-890", + "***-***-7890", + }, + + { + "86-(10)12345678", + "+**-***-***-5678", + }, + + // 可以有多个 testcase +} + +func Test_maskPII(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, maskPII(tc.S), "输入:%v", tc) + } +} + +func Benchmark_maskPII(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maskPII(tc.S) + } + } +} diff --git a/Algorithms/0832.flipping-an-image/README.md b/Algorithms/0832.flipping-an-image/README.md new file mode 100755 index 000000000..21030c091 --- /dev/null +++ b/Algorithms/0832.flipping-an-image/README.md @@ -0,0 +1,36 @@ +# [832. Flipping an Image](https://leetcode.com/problems/flipping-an-image/) + +## 题目 + +Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image. + +To flip an image horizontally means that each row of the image is reversed. For example, flipping[1, 1, 0]horizontally results in[0, 1, 1]. + +To invert an image meansthat each 0 is replaced by 1, and each 1 is replaced by 0.For example, inverting[0, 1, 1]results in[1, 0, 0]. + +Example 1: + +```text +Input: [[1,1,0],[1,0,1],[0,0,0]] +Output: [[1,0,0],[0,1,0],[1,1,1]] +Explanation: First reverse each row: [[0,1,1],[1,0,1],[0,0,0]]. +Then, invert the image: [[1,0,0],[0,1,0],[1,1,1]] +``` + +Example 2: + +```text +Input: [[1,1,0,0],[1,0,0,1],[0,1,1,1],[1,0,1,0]] +Output: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]] +Explanation: First reverse each row: [[0,0,1,1],[1,0,0,1],[1,1,1,0],[0,1,0,1]]. +Then invert the image: [[1,1,0,0],[0,1,1,0],[0,0,0,1],[1,0,1,0]] +``` + +Notes: + +1. 1 <= A.length = A[0].length <= 20 +1. 0 <= A[i][j]<=1 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0832.flipping-an-image/flipping-an-image.go b/Algorithms/0832.flipping-an-image/flipping-an-image.go new file mode 100755 index 000000000..23d432760 --- /dev/null +++ b/Algorithms/0832.flipping-an-image/flipping-an-image.go @@ -0,0 +1,23 @@ +package problem0832 + +func flipAndInvertImage(A [][]int) [][]int { + for k := 0; k < len(A); k++ { + i, j := 0, len(A[k])-1 + for i < j { + A[k][i], A[k][j] = invert(A[k][j]), invert(A[k][i]) + i++ + j-- + } + if i == j { // 当 len(A[k]) 的长度为奇数时,处理正中间的数 + A[k][i] = invert(A[k][i]) + } + } + return A +} + +func invert(i int) int { + if i == 0 { + return 1 + } + return 0 +} diff --git a/Algorithms/0832.flipping-an-image/flipping-an-image_test.go b/Algorithms/0832.flipping-an-image/flipping-an-image_test.go new file mode 100755 index 000000000..d5ce3ab6b --- /dev/null +++ b/Algorithms/0832.flipping-an-image/flipping-an-image_test.go @@ -0,0 +1,44 @@ +package problem0832 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A [][]int + ans [][]int +}{ + + { + [][]int{{1, 1, 0}, {1, 0, 1}, {0, 0, 0}}, + [][]int{{1, 0, 0}, {0, 1, 0}, {1, 1, 1}}, + }, + + { + [][]int{{1, 1, 0, 0}, {1, 0, 0, 1}, {0, 1, 1, 1}, {1, 0, 1, 0}}, + [][]int{{1, 1, 0, 0}, {0, 1, 1, 0}, {0, 0, 0, 1}, {1, 0, 1, 0}}, + }, + + // 可以有多个 testcase +} + +func Test_flipAndInvertImage(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, flipAndInvertImage(tc.A), "输入:%v", tc) + } +} + +func Benchmark_flipAndInvertImage(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + flipAndInvertImage(tc.A) + } + } +} diff --git a/Algorithms/0833.find-and-replace-in-string/README.md b/Algorithms/0833.find-and-replace-in-string/README.md new file mode 100755 index 000000000..0141fe3b0 --- /dev/null +++ b/Algorithms/0833.find-and-replace-in-string/README.md @@ -0,0 +1,41 @@ +# [833. Find And Replace in String](https://leetcode.com/problems/find-and-replace-in-string/) + +## 题目 + +To some string S, we will perform somereplacementoperations that replace groups of letters with new ones (not necessarily the same size). + +Each replacement operation has 3 parameters: a starting index i, a source wordxand a target wordy. The rule is that if xstarts at position iin the original string S, then we will replace that occurrence ofxwithy. If not, we do nothing. + +For example, if we haveS = "abcd"and we have some replacement operationi = 2, x = "cd", y = "ffff", then because"cd"starts at position 2in the original string S, we will replace it with "ffff". + +Using another example on S = "abcd", if we have both the replacement operation i = 0, x = "ab", y = "eee", as well as another replacement operationi = 2, x = "ec", y = "ffff", this second operation does nothing because in the original stringS[2] = 'c', which doesn't matchx[0] = 'e'. + +All these operations occur simultaneously. It's guaranteed that there won't be any overlap in replacement: for example,S = "abc", indexes = [0, 1],sources = ["ab","bc"] is not a valid test case. + +Example 1: + +```text +Input: S = "abcd", indexes = [0,2], sources = ["a","cd"], targets = ["eee","ffff"] +Output: "eeebffff" +Explanation: "a" starts at index 0 in S, so it's replaced by "eee". +"cd" starts at index 2 in S, so it's replaced by "ffff". +``` + +Example 2: + +```text +Input: S = "abcd", indexes = [0,2], sources = ["ab","ec"], targets = ["eee","ffff"] +Output: "eeecd" +Explanation: "ab" starts at index 0 in S, so it's replaced by "eee". +"ec" doesn't starts at index 2 in the original S, so we do nothing. +``` + +Notes: + +1. 0 <=indexes.length =sources.length =targets.length <= 100 +1. 0 b { + return a + } + return b +} diff --git a/Algorithms/0835.image-overlap/image-overlap_test.go b/Algorithms/0835.image-overlap/image-overlap_test.go new file mode 100644 index 000000000..0978401fd --- /dev/null +++ b/Algorithms/0835.image-overlap/image-overlap_test.go @@ -0,0 +1,42 @@ +package problem0835 + +import "testing" + +type args struct { + A [][]int + B [][]int +} + +var tests = []struct { + name string + args args + want int +}{ + { + "3X3 image", + args{ + [][]int{{1, 1, 0}, {0, 1, 0}, {0, 1, 0}}, + [][]int{{0, 0, 0}, {0, 1, 1}, {0, 0, 1}}, + }, + 3, + }, +} + +func Test_largestOverlap(t *testing.T) { + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := largestOverlap(tt.args.A, tt.args.B); got != tt.want { + t.Errorf("largestOverlap() = %v, want %v", got, tt.want) + } + }) + } +} +func Benchmark_largestOverlap(b *testing.B) { + for i := 1; i < b.N; i++ { + for _, tt := range tests { + a, b := tt.args.A, tt.args.B + largestOverlap(a, b) + } + } +} diff --git a/Algorithms/0836.rectangle-overlap/README.md b/Algorithms/0836.rectangle-overlap/README.md new file mode 100755 index 000000000..d9a406652 --- /dev/null +++ b/Algorithms/0836.rectangle-overlap/README.md @@ -0,0 +1,32 @@ +# [836. Rectangle Overlap](https://leetcode.com/problems/rectangle-overlap/) + +## 题目 + +A rectangle isrepresented as alist [x1, y1, x2, y2], where(x1, y1)are the coordinates of its bottom-left corner, and (x2,y2)are the coordinates of its top-right corner. + +Two rectangles overlap if the area of their intersection is positive. To be clear, two rectangles that only touch at the corner or edges do not overlap. + +Given two (axis-aligned) rectangles, return whetherthey overlap. + +Example 1: + +```text +Input: rec1 = [0,0,2,2], rec2 = [1,1,3,3] +Output: true +``` + +Example 2: + +```text +Input: rec1 = [0,0,1,1], rec2 = [1,0,2,1] +Output: false +``` + +Notes: + +1. Both rectangles rec1 and rec2 are lists of 4 integers. +1. All coordinates in rectangles will be between-10^9 and 10^9. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0836.rectangle-overlap/rectangle-overlap.go b/Algorithms/0836.rectangle-overlap/rectangle-overlap.go new file mode 100755 index 000000000..5fc6f69af --- /dev/null +++ b/Algorithms/0836.rectangle-overlap/rectangle-overlap.go @@ -0,0 +1,20 @@ +package problem0836 + +func isRectangleOverlap(rec1 []int, rec2 []int) bool { + // 把 rec 分别投影到水平轴和竖直轴上 + h1, v1 := projecting(rec1) + h2, v2 := projecting(rec2) + // 两个投影线同时相交可以认为 rec 相交 + return isLineOverlap(h1, h2) && isLineOverlap(v1, v2) +} + +func projecting(rec []int) (h, v []int) { + h = []int{rec[0], rec[2]} + v = []int{rec[1], rec[3]} + return +} + +func isLineOverlap(a, b []int) bool { + // 没有分开,就是相交 + return !(a[1] <= b[0] || b[1] <= a[0]) +} diff --git a/Algorithms/0836.rectangle-overlap/rectangle-overlap_test.go b/Algorithms/0836.rectangle-overlap/rectangle-overlap_test.go new file mode 100755 index 000000000..3981530ec --- /dev/null +++ b/Algorithms/0836.rectangle-overlap/rectangle-overlap_test.go @@ -0,0 +1,47 @@ +package problem0836 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + rec1 []int + rec2 []int + ans bool +}{ + + { + []int{0, 0, 2, 2}, + []int{1, 1, 3, 3}, + true, + }, + + { + []int{0, 0, 1, 1}, + []int{1, 0, 2, 1}, + false, + }, + + // 可以有多个 testcase +} + +func Test_isRectangleOverlap(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, isRectangleOverlap(tc.rec1, tc.rec2), "输入:%v", tc) + } +} + +func Benchmark_isRectangleOverlap(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isRectangleOverlap(tc.rec1, tc.rec2) + } + } +} diff --git a/Algorithms/0837.new-21-game/README.md b/Algorithms/0837.new-21-game/README.md new file mode 100755 index 000000000..c5bdf80df --- /dev/null +++ b/Algorithms/0837.new-21-game/README.md @@ -0,0 +1,44 @@ +# [837. New 21 Game](https://leetcode.com/problems/new-21-game/) + +## 题目 + +Alice plays the following game, loosely based on the card game "21". + +Alice starts with 0 points, and draws numbers while she has less than K points. During each draw, she gains an integer number of points randomly from the range [1, W], where W is an integer. Each draw is independent and the outcomes have equal probabilities. + +Alice stops drawing numbers when she gets K or more points. What is the probabilitythat she has N or less points? + +Example 1: + +```text +Input: N = 10, K = 1, W = 10 +Output: 1.00000 +Explanation: Alice gets a single card, then stops. +``` + +Example 2: + +```text +Input: N = 6, K = 1, W = 10 +Output: 0.60000 +Explanation: Alice gets a single card, then stops. +In 6 out of W = 10 possibilities, she is at or below N = 6 points. +``` + +Example 3: + +```text +Input: N = 21, K = 17, W = 10 +Output: 0.73278 +``` + +Note: + +1. 0 <= K <= N <= 10000 +1. 1 <= W <= 10000 +1. Answers will be accepted as correct if they are within 10^-5 of the correct answer. +1. The judging time limit has been reduced for this question. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0837.new-21-game/new-21-game.go b/Algorithms/0837.new-21-game/new-21-game.go new file mode 100755 index 000000000..c0903e085 --- /dev/null +++ b/Algorithms/0837.new-21-game/new-21-game.go @@ -0,0 +1,45 @@ +package problem0837 + +func new21Game(N int, K int, W int) float64 { + if K == 0 || + N >= K+W { + return 1.0 + } + + // dp[i]: 获取分数 i 的概率 + // 假设 p 为抽取 [1,W] 中任意一个数的概率,即 p = 1/W + // + // dp[i] = dp[i-1]*p + dp[i-2]*p + ... + dp[i-W]*p + // = (dp[i-1] + dp[i-2] + ... + dp[i-W]) * p + // = (dp[i-1] + dp[i-2] + ... + dp[i-W]) / W + // 令 last= dp[i-1] + dp[i-2] + ... + dp[i-W] + // dp[i] = last/ W + // + // 由于 i 的取值范围为 [1,N] + // 当 W <= i < K 时 + // last= dp[i-1] + dp[i-2] + ... + dp[i-W] + // 当 i < W 时 + // last应为 dp[i-1] + dp[i-2] + ... + dp[0] + // 当 K <= i 时 + // last应为 dp[k-1] + dp[k-2] + ... + dp[i-W] + dp := make([]float64, N+1) + dp[0] = 1.0 + last := 1.0 // 初始概率为 1 + res := 0.0 + for i := 1; i <= N; i++ { + dp[i] = last / float64(W) + + if W <= i { + last -= dp[i-W] + } + + if i < K { + last += dp[i] + } else { + res += dp[i] + } + + } + + return res +} diff --git a/Algorithms/0837.new-21-game/new-21-game_test.go b/Algorithms/0837.new-21-game/new-21-game_test.go new file mode 100755 index 000000000..063cb9c1b --- /dev/null +++ b/Algorithms/0837.new-21-game/new-21-game_test.go @@ -0,0 +1,71 @@ +package problem0837 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + K int + W int + ans float64 +}{ + + { + 421, + 400, + 47, + 0.71188, + }, + + { + 3, + 1, + 1, + 1.00000, + }, + + { + 10, + 1, + 10, + 1.00000, + }, + + { + 6, + 1, + 10, + 0.60000, + }, + + { + 21, + 17, + 10, + 0.73278, + }, + + // 可以有多个 testcase +} + +func Test_new21Game(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.InEpsilon(tc.ans, new21Game(tc.N, tc.K, tc.W), 0.00001, "输入:%v", tc) + } +} + +func Benchmark_new21Game(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + new21Game(tc.N, tc.K, tc.W) + } + } +} diff --git a/Algorithms/0838.push-dominoes/README.md b/Algorithms/0838.push-dominoes/README.md new file mode 100755 index 000000000..b39cf4b6a --- /dev/null +++ b/Algorithms/0838.push-dominoes/README.md @@ -0,0 +1,45 @@ +# [838. Push Dominoes](https://leetcode.com/problems/push-dominoes/) + +## 题目 + +There areN dominoes in a line, and we place each domino vertically upright. + +In the beginning, we simultaneously pushsome of the dominoes either to the left or to the right. + +![domino](domino.png) + +After each second, each domino that is falling to the left pushes the adjacent domino on the left. + +Similarly, the dominoes falling to the right push their adjacent dominoes standing on the right. + +When a vertical domino has dominoes falling on it from both sides, it stays still due to the balance of the forces. + +For the purposes of this question, we will consider that a falling dominoexpends no additional force to a falling or already fallen domino. + +Given a string "S" representing the initial state.S[i] = 'L', if the i-th domino has been pushed to the left; S[i] = 'R', if the i-th domino has been pushed to the right; S[i] = '.',if the i-th domino has not been pushed. + +Return a string representing the final state. + +Example 1: + +```text +Input: ".L.R...LR..L.." +Output: "LL.RR.LLRRLL.." +``` + +Example 2: + +```text +Input: "RR.L" +Output: "RR.L" +Explanation: The first domino expends no additional force on the second domino. +``` + +Note: + +1. 0 <= N<= 10^5 +1. Stringdominoes contains only'L', 'R' and '.' + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0838.push-dominoes/domino.png b/Algorithms/0838.push-dominoes/domino.png new file mode 100644 index 000000000..78e3a36b0 Binary files /dev/null and b/Algorithms/0838.push-dominoes/domino.png differ diff --git a/Algorithms/0838.push-dominoes/push-dominoes.go b/Algorithms/0838.push-dominoes/push-dominoes.go new file mode 100755 index 000000000..7cc99004a --- /dev/null +++ b/Algorithms/0838.push-dominoes/push-dominoes.go @@ -0,0 +1,48 @@ +package problem0838 + +func pushDominoes(dominoes string) string { + d := "L" + dominoes + "R" + size := len(d) + res := make([]byte, 0, size) + + for i, j := 0, 1; j < size; j++ { + if d[j] == '.' { + continue + } + + if 0 < i { + res = append(res, d[i]) + } + + mid := j - i - 1 + + switch { + case d[i] == 'R' && d[j] == 'L': + // 'R......L' => 'RRRRLLLL' or 'RRRR.LLLL' + for k := 0; k < mid/2; k++ { + res = append(res, 'R') + } + if mid%2 == 1 { + res = append(res, '.') + } + for k := 0; k < mid/2; k++ { + res = append(res, 'L') + } + case d[i] == 'L' && d[j] == 'R': + // 'L......R' => 'L......R' + for k := 0; k < mid; k++ { + res = append(res, '.') + } + default: + // 'R......R' => 'RRRRRRRR' + // 'L......L' => 'LLLLLLLL' + for k := 0; k < mid; k++ { + res = append(res, d[i]) + } + } + + i = j + } + + return string(res) +} diff --git a/Algorithms/0838.push-dominoes/push-dominoes_test.go b/Algorithms/0838.push-dominoes/push-dominoes_test.go new file mode 100755 index 000000000..a50cc93fe --- /dev/null +++ b/Algorithms/0838.push-dominoes/push-dominoes_test.go @@ -0,0 +1,44 @@ +package problem0838 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + dominoes string + ans string +}{ + + { + ".L.R...LR..L..", + "LL.RR.LLRRLL..", + }, + + { + "RR.L", + "RR.L", + }, + + // 可以有多个 testcase +} + +func Test_pushDominoes(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, pushDominoes(tc.dominoes), "输入:%v", tc) + } +} + +func Benchmark_pushDominoes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + pushDominoes(tc.dominoes) + } + } +} diff --git a/Algorithms/0839.similar-string-groups/README.md b/Algorithms/0839.similar-string-groups/README.md new file mode 100755 index 000000000..5dd4a1e1b --- /dev/null +++ b/Algorithms/0839.similar-string-groups/README.md @@ -0,0 +1,31 @@ +# [839. Similar String Groups](https://leetcode.com/problems/similar-string-groups/) + +## 题目 + +Two strings Xand Yare similar if we can swap two letters (in different positions) of X, so thatit equals Y. + +For example, "tars"and "rats"are similar (swapping at positions 0 and 2), and "rats" and "arts" are similar, but "star" is not similar to "tars", "rats", or "arts". + +Together, these form two connected groups by similarity: {"tars", "rats", "arts"} and {"star"}. Notice that "tars" and "arts" are in the same group even though they are not similar. Formally, each group is such that a word is in the group if and only if it is similar to at least one other word in the group. + +We are given a list A of strings. Every string in A is an anagram of every other string in A. How many groups are there? + +Example 1: + +```text +Input: ["tars","rats","arts","star"] +Output: 2 +``` + +Note: + +1. A.length <= 2000 +1. A[i].length <= 1000 +1. A.length * A[i].length <= 20000 +1. All words in Aconsist of lowercase letters only. +1. All words in A have the same length and are anagrams of each other. +1. The judging time limit has been increased for this question. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0839.similar-string-groups/similar-string-groups.go b/Algorithms/0839.similar-string-groups/similar-string-groups.go new file mode 100755 index 000000000..7dc593b99 --- /dev/null +++ b/Algorithms/0839.similar-string-groups/similar-string-groups.go @@ -0,0 +1,53 @@ +package problem0839 + +func numSimilarGroups(A []string) int { + size := len(A) + count := size + + parent := make([]int, size) + for i := 0; i < size; i++ { + parent[i] = i + } + var find func(int) int + find = func(x int) int { + if x != parent[x] { + parent[x] = find(parent[x]) + } + return parent[x] + } + union := func(x, y int) { + x, y = find(x), find(y) + if x != y { + parent[y] = x + count-- + } + } + + for i := 0; i < size; i++ { + for j := i + 1; j < size; j++ { + if isSimilar(A[i], A[j]) { + union(i, j) + } + } + } + + return count +} + +func isSimilar(a, b string) bool { + hasSeen := [26]bool{} + hasDouble := false + count := 0 + for i := 0; i < len(a) && count < 3; i++ { + if a[i] != b[i] { + count++ + continue + } + if hasSeen[a[i]-'a'] { + hasDouble = true + } + hasSeen[a[i]-'a'] = true + } + + return count == 2 || (count == 0 && hasDouble) +} diff --git a/Algorithms/0839.similar-string-groups/similar-string-groups_test.go b/Algorithms/0839.similar-string-groups/similar-string-groups_test.go new file mode 100755 index 000000000..2b8bfb1a5 --- /dev/null +++ b/Algorithms/0839.similar-string-groups/similar-string-groups_test.go @@ -0,0 +1,49 @@ +package problem0839 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []string + ans int +}{ + + { + []string{"kccomwcgcs", "socgcmcwkc", "sgckwcmcoc", "coswcmcgkc", "cowkccmsgc", "cosgmccwkc", "sgmkwcccoc", "coswmccgkc", "kowcccmsgc", "kgcomwcccs"}, + 5, + }, + + { + []string{"aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa", "aaaaaaaaa"}, + 1, + }, + + { + []string{"tars", "rats", "arts", "star"}, + 2, + }, + + // 可以有多个 testcase +} + +func Test_numSimilarGroups(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, numSimilarGroups(tc.A), "输入:%v", tc) + } +} + +func Benchmark_numSimilarGroups(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numSimilarGroups(tc.A) + } + } +} diff --git a/Algorithms/0840.magic-squares-in-grid/README.md b/Algorithms/0840.magic-squares-in-grid/README.md new file mode 100755 index 000000000..07e37b6b8 --- /dev/null +++ b/Algorithms/0840.magic-squares-in-grid/README.md @@ -0,0 +1,38 @@ +# [840. Magic Squares In Grid](https://leetcode.com/problems/magic-squares-in-grid/) + +## 题目 + +A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. + +Given an gridof integers, how many 3 x 3 "magic square" subgrids are there? (Each subgrid is contiguous). + +Example 1: + +```text +Input: [[4,3,8,4], + [9,5,1,9], + [2,7,6,2]] +Output: 1 +Explanation: +The following subgrid is a 3 x 3 magic square: +438 +951 +276 + +while this one is not: +384 +519 +762 + +In total, there is only one magic square inside the given grid. +``` + +Note: + +1. 1 <= grid.length<= 10 +1. 1 <= grid[0].length<= 10 +1. 0 <= grid[i][j] <= 15 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0840.magic-squares-in-grid/magic-squares-in-grid.go b/Algorithms/0840.magic-squares-in-grid/magic-squares-in-grid.go new file mode 100755 index 000000000..c64b211c0 --- /dev/null +++ b/Algorithms/0840.magic-squares-in-grid/magic-squares-in-grid.go @@ -0,0 +1,48 @@ +package problem0840 + +func numMagicSquaresInside(g [][]int) int { + m, n := len(g), len(g[0]) + + res := 0 + + for i := 0; i+2 < m; i++ { + for j := 0; j+2 < n; j++ { + if !isAvailbleNum(i, j, g) { + continue + } + + if // 检查行 + g[i][j]+g[i][j+1]+g[i][j+2] == 15 && + g[i+1][j]+g[i+1][j+1]+g[i+1][j+2] == 15 && + g[i+2][j]+g[i+2][j+1]+g[i+2][j+2] == 15 && + // 检查列 + g[i][j]+g[i+1][j]+g[i+2][j] == 15 && + g[i][j+1]+g[i+1][j+1]+g[i+2][j+1] == 15 && + g[i][j+2]+g[i+1][j+2]+g[i+2][j+2] == 15 && + // 检查对角 + g[i][j]+g[i+1][j+1]+g[i+2][j+2] == 15 && + g[i][j+2]+g[i+1][j+1]+g[i+2][j] == 15 { + res++ + } + } + } + + return res +} + +func isAvailbleNum(x, y int, g [][]int) bool { + tmp := [16]int{} + + for i := x; i <= x+2; i++ { + for j := y; j <= y+2; j++ { + tmp[g[i][j]]++ + } + } + + for i := 1; i <= 9; i++ { + if tmp[i] != 1 { + return false + } + } + return true +} diff --git a/Algorithms/0840.magic-squares-in-grid/magic-squares-in-grid_test.go b/Algorithms/0840.magic-squares-in-grid/magic-squares-in-grid_test.go new file mode 100755 index 000000000..6031e1ea0 --- /dev/null +++ b/Algorithms/0840.magic-squares-in-grid/magic-squares-in-grid_test.go @@ -0,0 +1,63 @@ +package problem0840 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + ans int +}{ + + { + [][]int{ + {3, 2, 9, 2, 7}, + {6, 1, 8, 4, 2}, + {7, 5, 3, 2, 7}, + {2, 9, 4, 9, 6}, + {4, 3, 8, 2, 5}, + }, + 1, + }, + + { + [][]int{ + {4, 3, 8, 4}, + {9, 5, 1, 9}, + {2, 7, 6, 2}, + }, + 1, + }, + + { + [][]int{ + {1, 8, 6}, + {10, 5, 0}, + {4, 2, 9}, + }, + 0, + }, + + // 可以有多个 testcase +} + +func Test_numMagicSquaresInside(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, numMagicSquaresInside(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_numMagicSquaresInside(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numMagicSquaresInside(tc.grid) + } + } +} diff --git a/Algorithms/0841.keys-and-rooms/README.md b/Algorithms/0841.keys-and-rooms/README.md new file mode 100755 index 000000000..20fd8ebec --- /dev/null +++ b/Algorithms/0841.keys-and-rooms/README.md @@ -0,0 +1,43 @@ +# [841. Keys and Rooms](https://leetcode.com/problems/keys-and-rooms/) + +## 题目 + +There are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, ..., N-1, and each room may havesome keys to access the next room. + +Formally, each room ihas a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, ..., N-1] where N = rooms.length. A key rooms[i][j] = vopens the room with number v. + +Initially, all the rooms start locked (except for room 0). + +You can walk back and forth between rooms freely. + +Return trueif and only if you can enterevery room. + +Example 1: + +```text +Input: [[1],[2],[3],[]] +Output: true +Explanation: +We start in room 0, and pick up key 1. +We then go to room 1, and pick up key 2. +We then go to room 2, and pick up key 3. +We then go to room 3. Since we were able to go to every room, we return true. +``` + +Example 2: + +```text +Input: [[1,3],[3,0,1],[2],[0]] +Output: false +Explanation: We can't enter the room with number 2. +``` + +Note: + +1. 1 <= rooms.length <=1000 +1. 0 <= rooms[i].length <= 1000 +1. The number of keys in all rooms combined is at most3000. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0841.keys-and-rooms/keys-and-rooms.go b/Algorithms/0841.keys-and-rooms/keys-and-rooms.go new file mode 100755 index 000000000..e36cfbde2 --- /dev/null +++ b/Algorithms/0841.keys-and-rooms/keys-and-rooms.go @@ -0,0 +1,33 @@ +package problem0841 + +func canVisitAllRooms(rooms [][]int) bool { + N := len(rooms) + + next := make([]int, 1, N) + next[0] = 0 + + isEntered := make([]bool, N) + isEntered[0] = true + count := 1 + + for len(next) > 0 { + r := next[0] + next = next[1:] + + for _, x := range rooms[r] { + if isEntered[x] { + continue + } + next = append(next, x) + isEntered[x] = true + count++ + } + + if count == N { + return true + } + + } + + return count == N +} diff --git a/Algorithms/0841.keys-and-rooms/keys-and-rooms_test.go b/Algorithms/0841.keys-and-rooms/keys-and-rooms_test.go new file mode 100755 index 000000000..72e04e7d5 --- /dev/null +++ b/Algorithms/0841.keys-and-rooms/keys-and-rooms_test.go @@ -0,0 +1,44 @@ +package problem0841 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + rooms [][]int + ans bool +}{ + + { + [][]int{{1, 3}, {3, 0, 1}, {2}, {0}}, + false, + }, + + { + [][]int{{1}, {2}, {3}, {}}, + true, + }, + + // 可以有多个 testcase +} + +func Test_canVisitAllRooms(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, canVisitAllRooms(tc.rooms), "输入:%v", tc) + } +} + +func Benchmark_canVisitAllRooms(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + canVisitAllRooms(tc.rooms) + } + } +} diff --git a/Algorithms/0842.split-array-into-fibonacci-sequence/README.md b/Algorithms/0842.split-array-into-fibonacci-sequence/README.md new file mode 100755 index 000000000..3b4231300 --- /dev/null +++ b/Algorithms/0842.split-array-into-fibonacci-sequence/README.md @@ -0,0 +1,62 @@ +# [842. Split Array into Fibonacci Sequence](https://leetcode.com/problems/split-array-into-fibonacci-sequence/) + +## 题目 + +Given a string Sof digits, such as S = "123456579", we can split it into a Fibonacci-like sequence[123, 456, 579]. + +Formally, a Fibonacci-like sequence is a listF of non-negative integers such that: + +- 0 <= F[i] <= 2^31 - 1, (that is,each integer fits a 32-bit signed integer type); +- F.length >= 3; +- and F[i] + F[i+1] = F[i+2] for all 0 <= i < F.length - 2. + +Also, note that when splitting the string into pieces, each piece must not have extra leading zeroes, except if the piece is the number 0 itself. + +Return any Fibonacci-like sequence split from S, or return [] if it cannot be done. + +Example 1: + +```text +Input: "123456579" +Output: [123,456,579] +``` + +Example 2: + +```text +Input: "11235813" +Output: [1,1,2,3,5,8,13] +``` + +Example 3: + +```text +Input: "112358130" +Output: [] +Explanation: The task is impossible. +``` + +Example 4: + +```text +Input: "0123" +Output: [] +Explanation: Leading zeroes are not allowed, so "01", "2", "3" is not valid. +``` + +Example 5: + +```text +Input: "1101111" +Output: [110, 1, 111] +Explanation: The output [11, 0, 11, 11] would also be accepted. +``` + +Note: + +1. 1 <= S.length<= 200 +1. S contains only digits. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0842.split-array-into-fibonacci-sequence/split-array-into-fibonacci-sequence.go b/Algorithms/0842.split-array-into-fibonacci-sequence/split-array-into-fibonacci-sequence.go new file mode 100755 index 000000000..623dff4ca --- /dev/null +++ b/Algorithms/0842.split-array-into-fibonacci-sequence/split-array-into-fibonacci-sequence.go @@ -0,0 +1,58 @@ +package problem0842 + +import ( + "strconv" +) + +func splitIntoFibonacci(s string) []int { + for i := 1; i <= len(s)/2; i++ { + if isLeadingZero(s[:i]) { + break + } + for j := i + 1; max(i, j-i) <= len(s)-j; j++ { + if isLeadingZero(s[i:j]) { + break + } + a, _ := strconv.Atoi(s[:i]) + b, _ := strconv.Atoi(s[i:j]) + res := make([]int, 0, len(s)) + res = append(res, a, b) + if find(a, b, s[j:], &res) { + return res + } + } + } + return nil +} + +func find(a, b int, s string, res *[]int) bool { + for len(s) > 0 { + c := a + b + if c > 1<<31-1 { + return false + } + cs := strconv.Itoa(c) + csl := len(cs) + + if len(s) < csl || s[:csl] != cs { + return false + } + + *res = append(*res, c) + a, b = b, c + s = s[csl:] + } + + return true +} + +func isLeadingZero(s string) bool { + return len(s) > 1 && s[0] == '0' +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0842.split-array-into-fibonacci-sequence/split-array-into-fibonacci-sequence_test.go b/Algorithms/0842.split-array-into-fibonacci-sequence/split-array-into-fibonacci-sequence_test.go new file mode 100755 index 000000000..4be03a77c --- /dev/null +++ b/Algorithms/0842.split-array-into-fibonacci-sequence/split-array-into-fibonacci-sequence_test.go @@ -0,0 +1,69 @@ +package problem0842 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans []int +}{ + + { + "1320581321313221264343965566089105744171833277577", + []int{13205, 8, 13213, 13221, 26434, 39655, 66089, 105744, 171833, 277577}, + }, + + { + "123456579", + []int{123, 456, 579}, + }, + + { + "539834657215398346785398346991079669377161950407626991734534318677529701785098211336528511", + nil, + }, + + { + "11235813", + []int{1, 1, 2, 3, 5, 8, 13}, + }, + + { + "112358130", + nil, + }, + + { + "0123", + nil, + }, + + { + "1101111", + []int{11, 0, 11, 11}, + }, + + // 可以有多个 testcase +} + +func Test_splitIntoFibonacci(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, splitIntoFibonacci(tc.S), "输入:%v", tc) + } +} + +func Benchmark_splitIntoFibonacci(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + splitIntoFibonacci(tc.S) + } + } +} diff --git a/Algorithms/0843.guess-the-word/README.md b/Algorithms/0843.guess-the-word/README.md new file mode 100755 index 000000000..4222a5832 --- /dev/null +++ b/Algorithms/0843.guess-the-word/README.md @@ -0,0 +1,36 @@ +# [843. Guess the Word](https://leetcode.com/problems/guess-the-word/) + +## 题目 + +This problem is aninteractive problemnew to the LeetCode platform. + +We are given a word list of unique words, each word is 6 letters long, and one word in this list is chosen as secret. + +You may call master.guess(word)to guess a word. The guessed word should havetype stringand must be from the original listwith 6 lowercase letters. + +This function returns anintegertype, representingthe number of exact matches (value and position) of your guess to the secret word. Also, if your guess is not in the given wordlist, it will return -1 instead. + +For each test case, you have 10 guesses to guess the word. At the end of any number of calls, if you have made 10 or less calls to master.guessand at least one of these guesses was the secret, you pass the testcase. + +Besides the example test case below, there will be 5additional test cases, each with 100 words in the word list. The letters of each word in those testcases were chosenindependently at random from 'a' to 'z', such that every word in the given word lists is unique. + +```text +Example 1: +Input:secret = "acckzz", wordlist = ["acckzz","ccbazz","eiowzz","abcczz"] + +Explanation: + +master.guess("aaaaaa") returns -1, because"aaaaaa"is not in wordlist. +master.guess("acckzz") returns 6, because"acckzz" is secret and has all 6matches. +master.guess("ccbazz") returns 3, because"ccbazz"has 3 matches. +master.guess("eiowzz") returns 2, because"eiowzz"has 2matches. +master.guess("abcczz") returns 4, because"abcczz" has 4 matches. + +We made 5 calls tomaster.guess and one of them was the secret, so we pass the test case. +``` + +Note: Any solutions that attempt to circumvent the judgewill result in disqualification. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0843.guess-the-word/guess-the-word.go b/Algorithms/0843.guess-the-word/guess-the-word.go new file mode 100755 index 000000000..728a73e84 --- /dev/null +++ b/Algorithms/0843.guess-the-word/guess-the-word.go @@ -0,0 +1,67 @@ +package problem0843 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// Master is the Master's API interface. +// You should not implement it, or speculate about its implementation +// type Master struct {} +// func (this *Master) Guess(word string) int {} +type Master = kit.Master + +// 解答参考 https://leetcode.com/problems/guess-the-word/discuss/133862/Random-Guess-and-Minimax-Guess-with-Comparison + +func findSecretWord(wordList []string, master *Master) { + matches := 0 + // 题目默认是猜 10 次 + for i := 0; i < 10; i++ { + // count[w] 代表了 w 与 wordList 中单词的匹配程度 + // 数值越高,越匹配 + count := make(map[string]int, len(wordList)) + for _, w := range wordList { + for _, b := range wordList { + count[w] += match(w, b) + } + } + + key := "" + max := 0 + for _, w := range wordList { + if max < count[w] { + max = count[w] + key = w + } + } + // 现在 key 与 wordList 中别的单词最具有相似性 + + matches = master.Guess(key) + // wordList 中的单词长度都为 6 + if matches == 6 { + // 猜到了 + return + } + + // 没有猜到就缩小 wordList 的范围 + newList := make([]string, 0, len(wordList)) + for _, w := range wordList { + if match(key, w) == matches { + // 因为 matches = match(key, secret) + // 所以,符合 match(key, w) == matches 的 w 才有可能是 secret + newList = append(newList, w) + } + } + + wordList = newList + } +} + +// a, b 总是一样长 +func match(a, b string) int { + res := 0 + size := len(a) + for i := 0; i < size; i++ { + if a[i] == b[i] { + res++ + } + } + return res +} diff --git a/Algorithms/0843.guess-the-word/guess-the-word_test.go b/Algorithms/0843.guess-the-word/guess-the-word_test.go new file mode 100755 index 000000000..61aea6447 --- /dev/null +++ b/Algorithms/0843.guess-the-word/guess-the-word_test.go @@ -0,0 +1,43 @@ +package problem0843 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + secret string + wordList []string + count int +}{ + + { + "hbaczn", + []string{"gaxckt", "trlccr", "jxwhkz", "ycbfps", "peayuf", "yiejjw", "ldzccp", "nqsjoa", "qrjasy", "pcldos", "acrtag", "buyeia", "ubmtpj", "drtclz", "zqderp", "snywek", "caoztp", "ibpghw", "evtkhl", "bhpfla", "ymqhxk", "qkvipb", "tvmued", "rvbass", "axeasm", "qolsjg", "roswcb", "vdjgxx", "bugbyv", "zipjpc", "tamszl", "osdifo", "dvxlxm", "iwmyfb", "wmnwhe", "hslnop", "nkrfwn", "puvgve", "rqsqpq", "jwoswl", "tittgf", "evqsqe", "aishiv", "pmwovj", "sorbte", "hbaczn", "coifed", "hrctvp", "vkytbw", "dizcxz", "arabol", "uywurk", "ppywdo", "resfls", "tmoliy", "etriev", "oanvlx", "wcsnzy", "loufkw", "onnwcy", "novblw", "mtxgwe", "rgrdbt", "ckolob", "kxnflb", "phonmg", "egcdab", "cykndr", "lkzobv", "ifwmwp", "jqmbib", "mypnvf", "lnrgnj", "clijwa", "kiioqr", "syzebr", "rqsmhg", "sczjmz", "hsdjfp", "mjcgvm", "ajotcx", "olgnfv", "mjyjxj", "wzgbmg", "lpcnbj", "yjjlwn", "blrogv", "bdplzs", "oxblph", "twejel", "rupapy", "euwrrz", "apiqzu", "ydcroj", "ldvzgq", "zailgu", "xgqpsr", "wxdyho", "alrplq", "brklfk"}, + 10, + }, + + // 可以有多个 testcase +} + +func Test_findSecretWord(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + m := &Master{ + Secret: tc.secret, + WordList: tc.wordList, + Count: tc.count, + } + + m.Update() + + findSecretWord(tc.wordList, m) + + ast.True(m.Count > 0, "没有猜到 %s", tc.secret) + } +} diff --git a/Algorithms/0844.backspace-string-compare/README.md b/Algorithms/0844.backspace-string-compare/README.md new file mode 100755 index 000000000..7d9f06fd2 --- /dev/null +++ b/Algorithms/0844.backspace-string-compare/README.md @@ -0,0 +1,51 @@ +# [844. Backspace String Compare](https://leetcode.com/problems/backspace-string-compare/) + +## 题目 + +Given twostringsSand T,return if they are equal when both are typed into empty text editors. # means a backspace character. + +Example 1: + +```text +Input: S = "ab#c", T = "ad#c" +Output: true +Explanation: Both S and T become "ac". +``` + +Example 2: + +```text +Input: S = "ab##", T = "c#d#" +Output: true +Explanation: Both S and T become "". +``` + +Example 3: + +```text +Input: S = "a##c", T = "#a#c" +Output: true +Explanation: Both S and T become "c". +``` + +Example 4: + +```text +Input: S = "a#c", T = "b" +Output: false +Explanation: S becomes "c" while T becomes "b". +``` + +Note: + +1. 1 <= S.length <= 200 +1. 1 <= T.length <= 200 +1. Sand T only containlowercase letters and '#' characters. + +Follow up: + +1. Can you solve it in O(N) time and O(1) space? + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0844.backspace-string-compare/backspace-string-compare.go b/Algorithms/0844.backspace-string-compare/backspace-string-compare.go new file mode 100755 index 000000000..f4fc04586 --- /dev/null +++ b/Algorithms/0844.backspace-string-compare/backspace-string-compare.go @@ -0,0 +1,33 @@ +package problem0844 + +func backspaceCompare(S string, T string) bool { + i := len(S) + j := len(T) + + for i >= 0 || j >= 0 { + i = nextIndex(&S, i) + j = nextIndex(&T, j) + + if i >= 0 && j >= 0 && S[i] != T[j] { + return false + } + + } + + return i == j +} + +// 返回 s[:i] 中,不是 '#' 的字符的最大的索引号 +func nextIndex(s *string, i int) int { + i-- + count := 0 + for i >= 0 && ((*s)[i] == '#' || count > 0) { + if (*s)[i] == '#' { + count++ + } else { + count-- + } + i-- + } + return i +} diff --git a/Algorithms/0844.backspace-string-compare/backspace-string-compare_test.go b/Algorithms/0844.backspace-string-compare/backspace-string-compare_test.go new file mode 100755 index 000000000..e05a7166f --- /dev/null +++ b/Algorithms/0844.backspace-string-compare/backspace-string-compare_test.go @@ -0,0 +1,65 @@ +package problem0844 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + T string + ans bool +}{ + + { + "#ab#c", + "#ad#c", + true, + }, + + { + "ab#c", + "ad#c", + true, + }, + + { + "ab##", + "c#d#", + true, + }, + + { + "a##c", + "#a#c", + true, + }, + + { + "a#c", + "b", + false, + }, + + // 可以有多个 testcase +} + +func Test_backspaceCompare(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, backspaceCompare(tc.S, tc.T), "输入:%v", tc) + } +} + +func Benchmark_backspaceCompare(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + backspaceCompare(tc.S, tc.T) + } + } +} diff --git a/Algorithms/0845.longest-mountain-in-array/README.md b/Algorithms/0845.longest-mountain-in-array/README.md new file mode 100755 index 000000000..bbac6aecc --- /dev/null +++ b/Algorithms/0845.longest-mountain-in-array/README.md @@ -0,0 +1,44 @@ +# [845. Longest Mountain in Array](https://leetcode.com/problems/longest-mountain-in-array/) + +## 题目 + +Let's call any (contiguous) subarray B (of A)a mountain if the following properties hold: + +- B.length >= 3 +- There exists some 0 < i< B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] + +(Note that B could be any subarray of A, including the entire array A.) + +Given an array Aof integers,return the length of the longestmountain. + +Return 0 if there is no mountain. + +Example 1: + +```text +Input: [2,1,4,7,3,2,5] +Output: 5 +Explanation: The largest mountain is [1,4,7,3,2] which has length 5. +``` + +Example 2: + +```text +Input: [2,2,2] +Output: 0 +Explanation: There is no mountain. +``` + +Note: + +1. 0 <= A.length <= 10000 +1. 0 <= A[i] <= 10000 + +Follow up: + +- Can you solve it using only one pass? +- Can you solve it in O(1) space? + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0845.longest-mountain-in-array/longest-mountain-in-array.go b/Algorithms/0845.longest-mountain-in-array/longest-mountain-in-array.go new file mode 100755 index 000000000..40bc7927b --- /dev/null +++ b/Algorithms/0845.longest-mountain-in-array/longest-mountain-in-array.go @@ -0,0 +1,27 @@ +package problem0845 + +func longestMountain(A []int) int { + size := len(A) + if size <= 2 { + return 0 + } + + res, up, down := 0, 0, 0 + for i := 1; i < size; i++ { + if (down > 0 && A[i-1] < A[i]) || + A[i-1] == A[i] { + up, down = 0, 0 + } + if A[i-1] < A[i] { + up++ + } + if A[i-1] > A[i] { + down++ + } + if up > 0 && down > 0 && up+down+1 > res { + res = up + down + 1 + } + } + + return res +} diff --git a/Algorithms/0845.longest-mountain-in-array/longest-mountain-in-array_test.go b/Algorithms/0845.longest-mountain-in-array/longest-mountain-in-array_test.go new file mode 100755 index 000000000..695b55fc9 --- /dev/null +++ b/Algorithms/0845.longest-mountain-in-array/longest-mountain-in-array_test.go @@ -0,0 +1,59 @@ +package problem0845 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{2, 3, 3, 2, 0, 2}, + 0, + }, + + { + []int{1, 2, 0, 2, 0, 2}, + 3, + }, + + { + []int{2, 1, 4, 7, 3, 2, 5}, + 5, + }, + + { + []int{2, 2, 2}, + 0, + }, + + { + []int{2, 3}, + 0, + }, + + // 可以有多个 testcase +} + +func Test_longestMountain(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, longestMountain(tc.A), "输入:%v", tc) + } +} + +func Benchmark_longestMountain(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + longestMountain(tc.A) + } + } +} diff --git a/Algorithms/0846.hand-of-straights/README.md b/Algorithms/0846.hand-of-straights/README.md new file mode 100755 index 000000000..c2c526eec --- /dev/null +++ b/Algorithms/0846.hand-of-straights/README.md @@ -0,0 +1,35 @@ +# [846. Hand of Straights](https://leetcode.com/problems/hand-of-straights/) + +## 题目 + +Alice has a hand of cards, given as an array of integers. + +Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecutive cards. + +Return true if and only if she can. + +Example 1: + +```text +Input: hand = [1,2,3,6,2,3,4,7,8], W = 3 +Output: true +Explanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8]. +``` + +Example 2: + +```text +Input: hand = [1,2,3,4,5], W = 4 +Output: false +Explanation: Alice's hand can't be rearranged into groups of 4. +``` + +Note: + +1. 1 <= hand.length <= 10000 +1. 0 <= hand[i]<= 10^9 +1. 1 <= W <= hand.length + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0846.hand-of-straights/hand-of-straights.go b/Algorithms/0846.hand-of-straights/hand-of-straights.go new file mode 100755 index 000000000..555154404 --- /dev/null +++ b/Algorithms/0846.hand-of-straights/hand-of-straights.go @@ -0,0 +1,40 @@ +package problem0846 + +import ( + "sort" +) + +func isNStraightHand(hand []int, W int) bool { + if W == 1 { + return true + } + + if W > len(hand) || len(hand)%W != 0 { + return false + } + + size := len(hand) / W + + groups := make([][]int, size) + + sort.Ints(hand) + + for _, c := range hand { + i := 0 + for ; i < size; i++ { + if len(groups[i]) == W { + continue + } + last := len(groups[i]) - 1 + if last == -1 || groups[i][last]+1 == c { + groups[i] = append(groups[i], c) + break + } + } + if i == size { + return false + } + } + + return true +} diff --git a/Algorithms/0846.hand-of-straights/hand-of-straights_test.go b/Algorithms/0846.hand-of-straights/hand-of-straights_test.go new file mode 100755 index 000000000..5bbdec3b6 --- /dev/null +++ b/Algorithms/0846.hand-of-straights/hand-of-straights_test.go @@ -0,0 +1,59 @@ +package problem0846 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + hand []int + W int + ans bool +}{ + + { + []int{1, 2, 3}, + 1, + true, + }, + + { + []int{1, 2, 3, 7, 2, 3, 4, 7, 8}, + 3, + false, + }, + + { + []int{1, 2, 3, 6, 2, 3, 4, 7, 8}, + 3, + true, + }, + + { + []int{1, 2, 3, 4, 5}, + 4, + false, + }, + + // 可以有多个 testcase +} + +func Test_isNStraightHand(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, isNStraightHand(tc.hand, tc.W), "输入:%v", tc) + } +} + +func Benchmark_isNStraightHand(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isNStraightHand(tc.hand, tc.W) + } + } +} diff --git a/Algorithms/0847.shortest-path-visiting-all-nodes/README.md b/Algorithms/0847.shortest-path-visiting-all-nodes/README.md new file mode 100755 index 000000000..45fa26ef7 --- /dev/null +++ b/Algorithms/0847.shortest-path-visiting-all-nodes/README.md @@ -0,0 +1,34 @@ +# [847. Shortest Path Visiting All Nodes](https://leetcode.com/problems/shortest-path-visiting-all-nodes/) + +## 题目 + +An undirected, connected graph of N nodes (labeled0, 1, 2, ..., N-1) is given as graph. + +graph.length = N, and j != iis in the listgraph[i]exactly once, if and only if nodes i and j are connected. + +Return the length of the shortest path that visits every node. You may start and stop at any node, you may revisit nodes multiple times, and you may reuse edges. + +Example 1: + +```text +Input: [[1,2,3],[0],[0],[0]] +Output: 4 +Explanation: One possible path is [1,0,2,0,3] +``` + +Example 2: + +```text +Input: [[1],[0,2,4],[1,3,4],[2],[1,2]] +Output: 4 +Explanation: One possible path is [0,1,4,2,3] +``` + +Note: + +1. 1 <= graph.length <= 12 +1. 0 <= graph[i].length < graph.length + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0847.shortest-path-visiting-all-nodes/shortest-path-visiting-all-nodes.go b/Algorithms/0847.shortest-path-visiting-all-nodes/shortest-path-visiting-all-nodes.go new file mode 100755 index 000000000..41b7937c9 --- /dev/null +++ b/Algorithms/0847.shortest-path-visiting-all-nodes/shortest-path-visiting-all-nodes.go @@ -0,0 +1,68 @@ +package problem0847 + +func shortestPathLength(graph [][]int) int { + size := len(graph) + maskSize := 1 << uint(size) + maxInt := 1<<63 - 1 + + queue := make([]state, 0, size*size) + dp := make([][]int, size) + // dp[3][11(00...001011)] = 2 的含义是 + // 从 3 出发,包含了 0,1,3 点的路径距离是 2 + // 通过把二进制数 0,1,3 位上的值设置为 1,其余位为 0 ,来表示包含了 0,1,3 点的路径 + // 11 是其二进制 1011 的 mask + + for i := range dp { + dp[i] = make([]int, maskSize) + for j := range dp[i] { + // 先把每个路径都设置成最大值 + dp[i][j] = maxInt + } + mask := 1 << uint(i) + // 从自身出发到达自身的距离为 0 + dp[i][mask] = 0 + // 从每个节点出发都可以作为一个状态 + queue = append(queue, state{source: i, mask: mask}) + } + + // 搜索 + for len(queue) > 0 { + // 从 queue 中获取一个状态 + s := queue[0] + queue = queue[1:] + + // 检查从 s 状态的 source 能够到达的所有节点 + // 是否有新的更优状态产生 + // 有的话,就放入 queue 中 + + for _, next := range graph[s.source] { + // nextMask 很巧妙 + // nextMask 表示,s 状态所包含的节点,并上 next 节点 + nextMask := s.mask | 1< dp[s.source][s.mask]+1 { + dp[next][nextMask] = dp[s.source][s.mask] + 1 + // 注意,只有更优的状态才能放入 queue 中,避免了死循环 + queue = append(queue, state{source: next, mask: nextMask}) + } + } + } + + res := maxInt + traversalMask := maskSize - 1 + for i := 0; i < size; i++ { + res = min(res, dp[i][traversalMask]) + } + + return res +} + +type state struct { + source, mask int +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0847.shortest-path-visiting-all-nodes/shortest-path-visiting-all-nodes_test.go b/Algorithms/0847.shortest-path-visiting-all-nodes/shortest-path-visiting-all-nodes_test.go new file mode 100755 index 000000000..571575e40 --- /dev/null +++ b/Algorithms/0847.shortest-path-visiting-all-nodes/shortest-path-visiting-all-nodes_test.go @@ -0,0 +1,49 @@ +package problem0847 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + graph [][]int + ans int +}{ + + { + [][]int{{1}, {2}, {0}}, + 2, + }, + + { + [][]int{{1, 2, 3}, {0}, {0}, {0}}, + 4, + }, + + { + [][]int{{1}, {0, 2, 4}, {1, 3, 4}, {2}, {1, 2}}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_shortestPathLength(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, shortestPathLength(tc.graph), "输入:%v", tc) + } +} + +func Benchmark_shortestPathLength(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shortestPathLength(tc.graph) + } + } +} diff --git a/Algorithms/0848.shifting-letters/README.md b/Algorithms/0848.shifting-letters/README.md new file mode 100755 index 000000000..19e168dc1 --- /dev/null +++ b/Algorithms/0848.shifting-letters/README.md @@ -0,0 +1,34 @@ +# [848. Shifting Letters](https://leetcode.com/problems/shifting-letters/) + +## 题目 + +We have a string S of lowercase letters, and an integer array shifts. + +Call the shift of a letter, the next letter in the alphabet, (wrapping around so that 'z' becomes 'a'). + +For example, shift('a') = 'b', shift('t') = 'u', and shift('z') = 'a'. + +Now for each shifts[i] = x, we want to shift the first i+1letters of S, x times. + +Return the final stringafter all such shifts to S are applied. + +Example 1: + +```text +Input: S = "abc", shifts = [3,5,9] +Output: "rpl" +Explanation: +We start with "abc". +After shifting the first 1 letters of S by 3, we have "dbc". +After shifting the first 2 letters of S by 5, we have "igc". +After shifting the first 3 letters of S by 9, we have "rpl", the answer. +``` + +Note: + +1. 1 <= S.length = shifts.length <= 20000 +1. 0 <= shifts[i] <= 10 ^ 9 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0848.shifting-letters/shifting-letters.go b/Algorithms/0848.shifting-letters/shifting-letters.go new file mode 100755 index 000000000..c9975b611 --- /dev/null +++ b/Algorithms/0848.shifting-letters/shifting-letters.go @@ -0,0 +1,29 @@ +package problem0848 + +func shiftingLetters(S string, shifts []int) string { + size := len(S) + a := s2is(S) + shift := 0 + for i := size - 1; 0 <= i; i-- { + shift += shifts[i] + shift %= 26 + a[i] = (a[i] + shift) % 26 + } + return is2s(a) +} + +func s2is(s string) []int { + res := make([]int, len(s)) + for i := range s { + res[i] = int(s[i] - 'a') + } + return res +} + +func is2s(a []int) string { + bs := make([]byte, len(a)) + for i, n := range a { + bs[i] = byte(n + 'a') + } + return string(bs) +} diff --git a/Algorithms/0848.shifting-letters/shifting-letters_test.go b/Algorithms/0848.shifting-letters/shifting-letters_test.go new file mode 100755 index 000000000..fa63fa9a8 --- /dev/null +++ b/Algorithms/0848.shifting-letters/shifting-letters_test.go @@ -0,0 +1,41 @@ +package problem0848 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + shifts []int + ans string +}{ + + { + "abc", + []int{3, 5, 9}, + "rpl", + }, + + // 可以有多个 testcase +} + +func Test_shiftingLetters(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, shiftingLetters(tc.S, tc.shifts), "输入:%v", tc) + } +} + +func Benchmark_shiftingLetters(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shiftingLetters(tc.S, tc.shifts) + } + } +} diff --git a/Algorithms/0849.maximize-distance-to-closest-person/README.md b/Algorithms/0849.maximize-distance-to-closest-person/README.md new file mode 100755 index 000000000..ce9801fb7 --- /dev/null +++ b/Algorithms/0849.maximize-distance-to-closest-person/README.md @@ -0,0 +1,41 @@ +# [849. Maximize Distance to Closest Person](https://leetcode.com/problems/maximize-distance-to-closest-person/) + +## 题目 + +In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. + +There is at least one empty seat, and at least one person sitting. + +Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized. + +Return that maximum distance to closest person. + +Example 1: + +```text +Input: [1,0,0,0,1,0,1] +Output: 2 +Explanation: +If Alex sits in the second open seat (seats[2]), then the closest person has distance 2. +If Alex sits in any other open seat, the closest person has distance 1. +Thus, the maximum distance to the closest person is 2. +``` + +Example 2: + +```text +Input: [1,0,0,0] +Output: 3 +Explanation: +If Alex sits in the last seat, the closest person is 3 seats away. +This is the maximum distance possible, so the answer is 3. +``` + +Note: + +1. 1 <= seats.length <= 20000 +1. seatscontains only 0s or 1s, at least one 0, and at least one 1. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0849.maximize-distance-to-closest-person/maximize-distance-to-closest-person.go b/Algorithms/0849.maximize-distance-to-closest-person/maximize-distance-to-closest-person.go new file mode 100755 index 000000000..4ee4967b6 --- /dev/null +++ b/Algorithms/0849.maximize-distance-to-closest-person/maximize-distance-to-closest-person.go @@ -0,0 +1,34 @@ +package problem0849 + +func maxDistToClosest(seats []int) int { + size := len(seats) + maxDis := 0 + // e 代表了连续空位的个数 + // 当连续空位两边都有人的时候,maxDis = (e+e%2)/2 + // 如果有一边没人的话, maxDis = e + e := 0 + for i := 0; i < size; i++ { + if e == i { + // 说明 seats[0:i] 全是 0 + maxDis = e + } else { + maxDis = max(maxDis, (e+e%2)/2) + } + if seats[i] == 1 { + e = 0 + } else { + e++ + } + } + + // 当 seats[size-1]==0 的时候 + // e 最后的值,有可能 > maxDis + return max(maxDis, e) +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0849.maximize-distance-to-closest-person/maximize-distance-to-closest-person_test.go b/Algorithms/0849.maximize-distance-to-closest-person/maximize-distance-to-closest-person_test.go new file mode 100755 index 000000000..038ac8670 --- /dev/null +++ b/Algorithms/0849.maximize-distance-to-closest-person/maximize-distance-to-closest-person_test.go @@ -0,0 +1,49 @@ +package problem0849 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + seats []int + ans int +}{ + + { + []int{1, 0, 0, 0, 1, 0, 1}, + 2, + }, + + { + []int{0, 0, 0, 1}, + 3, + }, + + { + []int{1, 0, 0, 0}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_maxDistToClosest(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, maxDistToClosest(tc.seats), "输入:%v", tc) + } +} + +func Benchmark_maxDistToClosest(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxDistToClosest(tc.seats) + } + } +} diff --git a/Algorithms/0850.rectangle-area-ii/README.md b/Algorithms/0850.rectangle-area-ii/README.md new file mode 100755 index 000000000..d14716dbc --- /dev/null +++ b/Algorithms/0850.rectangle-area-ii/README.md @@ -0,0 +1,36 @@ +# [850. Rectangle Area II](https://leetcode.com/problems/rectangle-area-ii/) + +## 题目 + +We are given a list of (axis-aligned)rectangles. Eachrectangle[i] = [x1, y1, x2, y2], where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the ith rectangle. + +Find the total area covered by all rectangles in the plane. Since the answermay be too large, return it modulo 10^9 + 7. + +![pic](rectangle_area_ii_pic.png) + +Example 1: + +```text +Input: [[0,0,2,2],[1,0,2,3],[1,0,3,1]] +Output: 6 +Explanation: As illustrated in the picture. +``` + +Example 2: + +```text +Input: [[0,0,1000000000,1000000000]] +Output: 49 +Explanation: The answer is 10^18 modulo (10^9 + 7), which is (10^9)^2 = (-7)^2 = 49. +``` + +Note: + +1. 1 <= rectangles.length <= 200 +1. rectanges[i].length = 4 +1. 0 <= rectangles[i][j] <= 10^9 +1. The total area covered by all rectangles will never exceed2^63 - 1and thus will fit in a 64-bit signed integer. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0850.rectangle-area-ii/rectangle-area-ii.go b/Algorithms/0850.rectangle-area-ii/rectangle-area-ii.go new file mode 100755 index 000000000..ae50dfff2 --- /dev/null +++ b/Algorithms/0850.rectangle-area-ii/rectangle-area-ii.go @@ -0,0 +1,95 @@ +package problem0850 + +import ( + "sort" +) + +// 思路来自 https://leetcode.com/problems/rectangle-area-ii/discuss/137914/C++Python-Discretization-and-O(NlogN) +// +// 可以想象成, +// 根据 rectangles 中所有的 x 值,在平面上划 竖线 +// 根据 rectangles 中所有的 y 值,在平面上划 横线 +// 原先的长方形被划线分隔成更小的长方形 +// 这些小长方形,要么单独存在,要么与别的小长方形**完全重合** +// +// 然后,从下往上,依次统计每一行,所有小长方形的面积,重合的小长方形只统计一次 + +const mod = 1e9 + 7 + +func rectangleArea(rectangles [][]int) int { + // 提取 rectangles 中所有的 x 坐标值,并按照升序排列 + xs := getXs(rectangles) + + // idxs 记录了 x 在 xs 中的索引值,即 + // idxs[key]==val <==> xs[val]==key + idxs := make(map[int]int, 2*len(xs)) + for idx, x := range xs { + idxs[x] = idx + } + + // labels[i]=[y,x1,x2,sig] + // 其中 [y,[x1,x2]] 表示小长方形的一条横边 + // sig==1 为底边 + // sig==-1 为顶边 + labels := getLabels(rectangles) + + // 当 curY=j ,count[i]=5 时,意味着 + // 以 y=j,[xs[i],xs[i+1]] 为底边的小长方形,有 5 个 + count := make([]int, len(xs)) + + curY, curXSum, area := 0, 0, 0 + + for _, l := range labels { + y, x1, x2, sig := l[0], l[1], l[2], l[3] + area += (y - curY) * curXSum + curY = y + // 更新 curXSum + curXSum = 0 + for i := idxs[x1]; i < idxs[x2]; i++ { + // 更新每个小长方形的重合度 + count[i] += sig + } + for i := 0; i+1 < len(count); i++ { + if count[i] > 0 { + // curY 上 + // 所有小长方形**底边**长度相加 + curXSum += xs[i+1] - xs[i] + } + } + } + + return area % mod +} + +func getXs(rects [][]int) []int { + size := len(rects) + xs := make([]int, 0, size*2) + xMap := make(map[int]bool, size*2) + for _, r := range rects { + xMap[r[0]] = true + xMap[r[2]] = true + } + for k := range xMap { + xs = append(xs, k) + } + sort.Ints(xs) + return xs +} + +func getLabels(rects [][]int) [][]int { + labels := make([][]int, 0, 2*len(rects)) + for _, r := range rects { + x1, y1, x2, y2 := r[0], r[1], r[2], r[3] + labels = append(labels, + []int{y1, x1, x2, 1}, + []int{y2, x1, x2, -1}, + ) + } + + // 对 labels 进行排序 + sort.Slice(labels, func(i int, j int) bool { + return labels[i][0] < labels[j][0] + }) + + return labels +} diff --git a/Algorithms/0850.rectangle-area-ii/rectangle-area-ii_test.go b/Algorithms/0850.rectangle-area-ii/rectangle-area-ii_test.go new file mode 100755 index 000000000..df61f3ebc --- /dev/null +++ b/Algorithms/0850.rectangle-area-ii/rectangle-area-ii_test.go @@ -0,0 +1,54 @@ +package problem0850 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + rectangles [][]int + ans int +}{ + + { + [][]int{{0, 0, 2, 2}, {3, 0, 5, 2}}, + 8, + }, + + { + [][]int{{0, 0, 2, 2}, {1, 0, 2, 3}, {1, 0, 3, 1}}, + 6, + }, + + { + [][]int{{0, 0, 1000000000, 1000000000}}, + 49, + }, + + { + [][]int{{0, 0, 1000000000, 1000000000}, {0, 1000000000, 1000000000, 2000000000}}, + 98, + }, + + // 可以有多个 testcase +} + +func Test_rectangleArea(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, rectangleArea(tc.rectangles), "输入:%v", tc) + } +} + +func Benchmark_rectangleArea(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + rectangleArea(tc.rectangles) + } + } +} diff --git a/Algorithms/0850.rectangle-area-ii/rectangle_area_ii_pic.png b/Algorithms/0850.rectangle-area-ii/rectangle_area_ii_pic.png new file mode 100644 index 000000000..d9d772610 Binary files /dev/null and b/Algorithms/0850.rectangle-area-ii/rectangle_area_ii_pic.png differ diff --git a/Algorithms/0851.loud-and-rich/README.md b/Algorithms/0851.loud-and-rich/README.md new file mode 100755 index 000000000..e28e68adb --- /dev/null +++ b/Algorithms/0851.loud-and-rich/README.md @@ -0,0 +1,46 @@ +# [851. Loud and Rich](https://leetcode.com/problems/loud-and-rich/) + +## 题目 + +In a group of N people (labelled 0, 1, 2, ..., N-1), each person has different amounts of money, and different levels of quietness. + +For convenience, we'll call the person with label x, simply "person x". + +We'll say that richer[i] = [x, y] if person xdefinitely has more money than persony. Note that richermay only be a subset of valid observations. + +Also, we'll say quiet[x] = q if person xhas quietness q. + +Now, return answer, where answer[x] = y if y is the least quiet person (that is, the person y with the smallest value of quiet[y]), among all peoplewho definitely haveequal to or more money than person x. + +Example 1: + +```text +Input: richer = [[1,0],[2,1],[3,1],[3,7],[4,3],[5,3],[6,3]], quiet = [3,2,5,4,6,1,7,0] +Output: [5,5,2,5,4,5,6,7] +Explanation: +answer[0] = 5. +Person 5 has more money than 3, which has more money than 1, which has more money than 0. +The only person who is quieter (has lower quiet[x]) is person 7, but +it isn't clear if they have more money than person 0. + +answer[7] = 7. +Among all people that definitely have equal to or more money than person 7 +(which could be persons 3, 4, 5, 6, or 7), the person who is the quietest (has lower quiet[x]) +is person 7. + +The other answers can be filled out with similar reasoning. +``` + +Note: + +1. 1 <= quiet.length = N <= 500 +1. 0 <= quiet[i] < N, all quiet[i] are different. +1. 0 <= richer.length <= N * (N-1) / 2 +1. 0 <= richer[i][j] < N +1. richer[i][0] != richer[i][1] +1. richer[i]'s are all different. +1. Theobservations in richer are all logically consistent. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0851.loud-and-rich/loud-and-rich.go b/Algorithms/0851.loud-and-rich/loud-and-rich.go new file mode 100755 index 000000000..82205d35b --- /dev/null +++ b/Algorithms/0851.loud-and-rich/loud-and-rich.go @@ -0,0 +1,39 @@ +package problem0851 + +func loudAndRich(richer [][]int, quiet []int) []int { + size := len(quiet) + + // rs[y] 中保存了所有比 y 有钱的人 + rs := make([][]int, size) + for _, r := range richer { + x, y := r[0], r[1] + rs[y] = append(rs[y], x) + } + + res := make([]int, size) + // res 全部设置为 -1 + // 作为是否设置过的标记 + for i := range res { + res[i] = -1 + } + + var dfs func(int) int + dfs = func(i int) int { + if res[i] >= 0 { + return res[i] + } + res[i] = i + for _, j := range rs[i] { + if quiet[res[i]] > quiet[dfs(j)] { + res[i] = res[j] + } + } + return res[i] + } + + for i := 0; i < size; i++ { + dfs(i) + } + + return res +} diff --git a/Algorithms/0851.loud-and-rich/loud-and-rich_test.go b/Algorithms/0851.loud-and-rich/loud-and-rich_test.go new file mode 100755 index 000000000..11640a7d1 --- /dev/null +++ b/Algorithms/0851.loud-and-rich/loud-and-rich_test.go @@ -0,0 +1,41 @@ +package problem0851 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + richer [][]int + quiet []int + ans []int +}{ + + { + [][]int{{1, 0}, {2, 1}, {3, 1}, {3, 7}, {4, 3}, {5, 3}, {6, 3}}, + []int{3, 2, 5, 4, 6, 1, 7, 0}, + []int{5, 5, 2, 5, 4, 5, 6, 7}, + }, + + // 可以有多个 testcase +} + +func Test_loudAndRich(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, loudAndRich(tc.richer, tc.quiet), "输入:%v", tc) + } +} + +func Benchmark_loudAndRich(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + loudAndRich(tc.richer, tc.quiet) + } + } +} diff --git a/Algorithms/0852.peak-index-in-a-mountain-array/README.md b/Algorithms/0852.peak-index-in-a-mountain-array/README.md new file mode 100755 index 000000000..903e385eb --- /dev/null +++ b/Algorithms/0852.peak-index-in-a-mountain-array/README.md @@ -0,0 +1,34 @@ +# [852. Peak Index in a Mountain Array](https://leetcode.com/problems/peak-index-in-a-mountain-array/) + +## 题目 + +Let's call an array A a mountainif the following properties hold: + +- A.length >= 3 +- There exists some 0 < i< A.length - 1 such that A[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1] + +Given an array that is definitely a mountain, return anyisuch thatA[0] < A[1] < ... A[i-1] < A[i] > A[i+1] > ... > A[A.length - 1]. + +Example 1: + +```text +Input: [0,1,0] +Output: 1 +``` + +Example 2: + +```text +Input: [0,2,1,0] +Output: 1 +``` + +Note: + +1. 3 <= A.length <= 10000 +1. 0 <= A[i] <= 10^6 +1. Ais a mountain, as defined above. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0852.peak-index-in-a-mountain-array/peak-index-in-a-mountain-array.go b/Algorithms/0852.peak-index-in-a-mountain-array/peak-index-in-a-mountain-array.go new file mode 100755 index 000000000..7f775ea87 --- /dev/null +++ b/Algorithms/0852.peak-index-in-a-mountain-array/peak-index-in-a-mountain-array.go @@ -0,0 +1,26 @@ +package problem0852 + +func peakIndexInMountainArray(a []int) int { + l, r := 0, len(a)-1 + for { + m := (l + r) / 2 + switch { + case a[m] < a[m+1]: + l = m // 想想看,为什么不是 l = m+1 + case a[m-1] > a[m]: + r = m // 想想看,为什么不是 r = m-1 + default: + return m + } + } +} + +/** + * 通常的二分搜索, 正确值在 [l,r] 内, + * 当 m 不是正确值的时候,需要把 m 排除在新的 [l,r] 外 + * 所以,l = m+1 或 r = m-1,正确值依然在 [l,r] 内 + * + * 此题中的二分搜索,正确值在 (l,r) 内 + * 当 m 不是正确值的时候,需要把 m 排除在新的 (l,r) 外 + * 所以,l = m 或 r = m,正确值依然在 (l,r) 内 + */ diff --git a/Algorithms/0852.peak-index-in-a-mountain-array/peak-index-in-a-mountain-array_test.go b/Algorithms/0852.peak-index-in-a-mountain-array/peak-index-in-a-mountain-array_test.go new file mode 100755 index 000000000..fcc023b4f --- /dev/null +++ b/Algorithms/0852.peak-index-in-a-mountain-array/peak-index-in-a-mountain-array_test.go @@ -0,0 +1,59 @@ +package problem0852 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + +{ + []int{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,310,311,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,334,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,358,359,360,361,362,363,364,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,399,400,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,417,418,419,420,421,422,423,424,425,426,427,428,429,430,431,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448,449,450,451,452,453,454,455,456,457,458,459,460,461,462,463,464,465,466,467,468,469,470,471,472,473,474,475,476,477,478,479,480,481,482,483,484,485,486,487,488,489,490,491,492,493,494,495,496,497,498,499,500,501,502,503,504,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,546,547,548,549,550,551,552,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,572,573,574,575,576,577,578,579,580,581,582,583,584,585,586,587,588,589,590,591,592,593,594,595,596,597,598,599,600,601,602,603,604,605,606,607,608,609,610,611,612,613,614,615,616,617,618,619,620,621,622,623,624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,671,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,837,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,930,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,975,976,977,978,979,980,981,982,983,984,985,986,987,988,989,990,991,992,993,994,995,996,997,998,999,1000,1001,1002,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1104,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1121,1122,1123,1124,1125,1126,1127,1128,1129,1130,1131,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1150,1151,1152,1153,1154,1155,1156,1157,1158,1159,1160,1161,1162,1163,1164,1165,1166,1167,1168,1169,1170,1171,1172,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1191,1192,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1211,1212,1213,1214,1215,1216,1217,1218,1219,1220,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,1270,1271,1272,1273,1274,1275,1276,1277,1278,1279,1280,1281,1282,1283,1284,1285,1286,1287,1288,1289,1290,1291,1292,1293,1294,1295,1296,1297,1298,1299,1300,1301,1302,1303,1304,1305,1306,1307,1308,1309,1310,1311,1312,1313,1314,1315,1316,1317,1318,1319,1320,1321,1322,1323,1324,1325,1326,1327,1328,1329,1330,1331,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,1360,1361,1362,1363,1364,1365,1366,1367,1368,1369,1370,1371,1372,1373,1374,1375,1376,1377,1378,1379,1380,1381,1382,1383,1384,1385,1386,1387,1388,1389,1390,1391,1392,1393,1394,1395,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408,1409,1410,1411,1412,1413,1414,1415,1416,1417,1418,1419,1420,1421,1422,1423,1424,1425,1426,1427,1428,1429,1430,1431,1432,1433,1434,1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477,1478,1479,1480,1481,1482,1483,1484,1485,1486,1487,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1515,1516,1517,1518,1519,1520,1521,1522,1523,1524,1525,1526,1527,1528,1529,1530,1531,1532,1533,1534,1535,1536,1537,1538,1539,1540,1541,1542,1543,1544,1545,1546,1547,1548,1549,1550,1551,1552,1553,1554,1555,1556,1557,1558,1559,1560,1561,1562,1563,1564,1565,1566,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,1619,1620,1621,1622,1623,1624,1625,1626,1627,1628,1629,1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1642,1643,1644,1645,1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,1750,1751,1752,1753,1754,1755,1756,1757,1758,1759,1760,1761,1762,1763,1764,1765,1766,1767,1768,1769,1770,1771,1772,1773,1774,1775,1776,1777,1778,1779,1780,1781,1782,1783,1784,1785,1786,1787,1788,1789,1790,1791,1792,1793,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1806,1807,1808,1809,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,1855,1856,1857,1858,1859,1860,1861,1862,1863,1864,1865,1866,1867,1868,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,2080,2081,2082,2083,2084,2085,2086,2087,2088,2089,2090,2091,2092,2093,2094,2095,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2111,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2135,2136,2137,2138,2139,2140,2141,2142,2143,2144,2145,2146,2147,2148,2149,2150,2151,2152,2153,2154,2155,2156,2157,2158,2159,2160,2161,2162,2163,2164,2165,2166,2167,2168,2169,2170,2171,2172,2173,2174,2175,2176,2177,2178,2179,2180,2181,2182,2183,2184,2185,2186,2187,2188,2189,2190,2191,2192,2193,2194,2195,2196,2197,2198,2199,2200,2201,2202,2203,2204,2205,2206,2207,2208,2209,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,2221,2222,2223,2224,2225,2226,2227,2228,2229,2230,2231,2232,2233,2234,2235,2236,2237,2238,2239,2240,2241,2242,2243,2244,2245,2246,2247,2248,2249,2250,2251,2252,2253,2254,2255,2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2267,2268,2269,2270,2271,2272,2273,2274,2275,2276,2277,2278,2279,2280,2281,2282,2283,2284,2285,2286,2287,2288,2289,2290,2291,2292,2293,2294,2295,2296,2297,2298,2299,2300,2301,2302,2303,2304,2305,2306,2307,2308,2309,2310,2311,2312,2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,2329,2330,2331,2332,2333,2334,2335,2336,2337,2338,2339,2340,2341,2342,2343,2344,2345,2346,2347,2348,2349,2350,2351,2352,2353,2354,2355,2356,2357,2358,2359,2360,2361,2362,2363,2364,2365,2366,2367,2368,2369,2370,2371,2372,2373,2374,2375,2376,2377,2378,2379,2380,2381,2382,2383,2384,2385,2386,2387,2388,2389,2390,2391,2392,2393,2394,2395,2396,2397,2398,2399,2400,2401,2402,2403,2404,2405,2406,2407,2408,2409,2410,2411,2412,2413,2414,2415,2416,2417,2418,2419,2420,2421,2422,2423,2424,2425,2426,2427,2428,2429,2430,2431,2432,2433,2434,2435,2436,2437,2438,2439,2440,2441,2442,2443,2444,2445,2446,2447,2448,2449,2450,2451,2452,2453,2454,2455,2456,2457,2458,2459,2460,2461,2462,2463,2464,2465,2466,2467,2468,2469,2470,2471,2472,2473,2474,2475,2476,2477,2478,2479,2480,2481,2482,2483,2484,2485,2486,2487,2488,2489,2490,2491,2492,2493,2494,2495,2496,2497,2498,2499,2500,2501,2502,2503,2504,2505,2506,2507,2508,2509,2510,2511,2512,2513,2514,2515,2516,2517,2518,2519,2520,2521,2522,2523,2524,2525,2526,2527,2528,2529,2530,2531,2532,2533,2534,2535,2536,2537,2538,2539,2540,2541,2542,2543,2544,2545,2546,2547,2548,2549,2550,2551,2552,2553,2554,2555,2556,2557,2558,2559,2560,2561,2562,2563,2564,2565,2566,2567,2568,2569,2570,2571,2572,2573,2574,2575,2576,2577,2578,2579,2580,2581,2582,2583,2584,2585,2586,2587,2588,2589,2590,2591,2592,2593,2594,2595,2596,2597,2598,2599,2600,2601,2602,2603,2604,2605,2606,2607,2608,2609,2610,2611,2612,2613,2614,2615,2616,2617,2618,2619,2620,2621,2622,2623,2624,2625,2626,2627,2628,2629,2630,2631,2632,2633,2634,2635,2636,2637,2638,2639,2640,2641,2642,2643,2644,2645,2646,2647,2648,2649,2650,2651,2652,2653,2654,2655,2656,2657,2658,2659,2660,2661,2662,2663,2664,2665,2666,2667,2668,2669,2670,2671,2672,2673,2674,2675,2676,2677,2678,2679,2680,2681,2682,2683,2684,2685,2686,2687,2688,2689,2690,2691,2692,2693,2694,2695,2696,2697,2698,2699,2700,2701,2702,2703,2704,2705,2706,2707,2708,2709,2710,2711,2712,2713,2714,2715,2716,2717,2718,2719,2720,2721,2722,2723,2724,2725,2726,2727,2728,2729,2730,2731,2732,2733,2734,2735,2736,2737,2738,2739,2740,2741,2742,2743,2744,2745,2746,2747,2748,2749,2750,2751,2752,2753,2754,2755,2756,2757,2758,2759,2760,2761,2762,2763,2764,2765,2766,2767,2768,2769,2770,2771,2772,2773,2774,2775,2776,2777,2778,2779,2780,2781,2782,2783,2784,2785,2786,2787,2788,2789,2790,2791,2792,2793,2794,2795,2796,2797,2798,2799,2800,2801,2802,2803,2804,2805,2806,2807,2808,2809,2810,2811,2812,2813,2814,2815,2816,2817,2818,2819,2820,2821,2822,2823,2824,2825,2826,2827,2828,2829,2830,2831,2832,2833,2834,2835,2836,2837,2838,2839,2840,2841,2842,2843,2844,2845,2846,2847,2848,2849,2850,2851,2852,2853,2854,2855,2856,2857,2858,2859,2860,2861,2862,2863,2864,2865,2866,2867,2868,2869,2870,2871,2872,2873,2874,2875,2876,2877,2878,2879,2880,2881,2882,2883,2884,2885,2886,2887,2888,2889,2890,2891,2892,2893,2894,2895,2896,2897,2898,2899,2900,2901,2902,2903,2904,2905,2906,2907,2908,2909,2910,2911,2912,2913,2914,2915,2916,2917,2918,2919,2920,2921,2922,2923,2924,2925,2926,2927,2928,2929,2930,2931,2932,2933,2934,2935,2936,2937,2938,2939,2940,2941,2942,2943,2944,2945,2946,2947,2948,2949,2950,2951,2952,2953,2954,2955,2956,2957,2958,2959,2960,2961,2962,2963,2964,2965,2966,2967,2968,2969,2970,2971,2972,2973,2974,2975,2976,2977,2978,2979,2980,2981,2982,2983,2984,2985,2986,2987,2988,2989,2990,2991,2992,2993,2994,2995,2996,2997,2998,2999,3000,3001,3002,3003,3004,3005,3006,3007,3008,3009,3010,3011,3012,3013,3014,3015,3016,3017,3018,3019,3020,3021,3022,3023,3024,3025,3026,3027,3028,3029,3030,3031,3032,3033,3034,3035,3036,3037,3038,3039,3040,3041,3042,3043,3044,3045,3046,3047,3048,3049,3050,3051,3052,3053,3054,3055,3056,3057,3058,3059,3060,3061,3062,3063,3064,3065,3066,3067,3068,3069,3070,3071,3072,3073,3074,3075,3076,3077,3078,3079,3080,3081,3082,3083,3084,3085,3086,3087,3088,3089,3090,3091,3092,3093,3094,3095,3096,3097,3098,3099,3100,3101,3102,3103,3104,3105,3106,3107,3108,3109,3110,3111,3112,3113,3114,3115,3116,3117,3118,3119,3120,3121,3122,3123,3124,3125,3126,3127,3128,3129,3130,3131,3132,3133,3134,3135,3136,3137,3138,3139,3140,3141,3142,3143,3144,3145,3146,3147,3148,3149,3150,3151,3152,3153,3154,3155,3156,3157,3158,3159,3160,3161,3162,3163,3164,3165,3166,3167,3168,3169,3170,3171,3172,3173,3174,3175,3176,3177,3178,3179,3180,3181,3182,3183,3184,3185,3186,3187,3188,3189,3190,3191,3192,3193,3194,3195,3196,3197,3198,3199,3200,3201,3202,3203,3204,3205,3206,3207,3208,3209,3210,3211,3212,3213,3214,3215,3216,3217,3218,3219,3220,3221,3222,3223,3224,3225,3226,3227,3228,3229,3230,3231,3232,3233,3234,3235,3236,3237,3238,3239,3240,3241,3242,3243,3244,3245,3246,3247,3248,3249,3250,3251,3252,3253,3254,3255,3256,3257,3258,3259,3260,3261,3262,3263,3264,3265,3266,3267,3268,3269,3270,3271,3272,3273,3274,3275,3276,3277,3278,3279,3280,3281,3282,3283,3284,3285,3286,3287,3288,3289,3290,3291,3292,3293,3294,3295,3296,3297,3298,3299,3300,3301,3302,3303,3304,3305,3306,3307,3308,3309,3310,3311,3312,3313,3314,3315,3316,3317,3318,3319,3320,3321,3322,3323,3324,3325,3326,3327,3328,3329,3330,3331,3332,3333,3334,3335,3336,3337,3338,3339,3340,3341,3342,3343,3344,3345,3346,3347,3348,3349,3350,3351,3352,3353,3354,3355,3356,3357,3358,3359,3360,3361,3362,3363,3364,3365,3366,3367,3368,3369,3370,3371,3372,3373,3374,3375,3376,3377,3378,3379,3380,3381,3382,3383,3384,3385,3386,3387,3388,3389,3390,3391,3392,3393,3394,3395,3396,3397,3398,3399,3400,3401,3402,3403,3404,3405,3406,3407,3408,3409,3410,3411,3412,3413,3414,3415,3416,3417,3418,3419,3420,3421,3422,3423,3424,3425,3426,3427,3428,3429,3430,3431,3432,3433,3434,3435,3436,3437,3438,3439,3440,3441,3442,3443,3444,3445,3446,3447,3448,3449,3450,3451,3452,3453,3454,3455,3456,3457,3458,3459,3460,3461,3462,3463,3464,3465,3466,3467,3468,3469,3470,3471,3472,3473,3474,3475,3476,3477,3478,3479,3480,3481,3482,3483,3484,3485,3486,3487,3488,3489,3490,3491,3492,3493,3494,3495,3496,3497,3498,3499,3500,3501,3502,3503,3504,3505,3506,3507,3508,3509,3510,3511,3512,3513,3514,3515,3516,3517,3518,3519,3520,3521,3522,3523,3524,3525,3526,3527,3528,3529,3530,3531,3532,3533,3534,3535,3536,3537,3538,3539,3540,3541,3542,3543,3544,3545,3546,3547,3548,3549,3550,3551,3552,3553,3554,3555,3556,3557,3558,3559,3560,3561,3562,3563,3564,3565,3566,3567,3568,3569,3570,3571,3572,3573,3574,3575,3576,3577,3578,3579,3580,3581,3582,3583,3584,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,3643,3644,3645,3646,3647,3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,3676,3677,3678,3679,3680,3681,3682,3683,3684,3685,3686,3687,3688,3689,3690,3691,3692,3693,3694,3695,3696,3697,3698,3699,3700,3701,3702,3703,3704,3705,3706,3707,3708,3709,3710,3711,3712,3713,3714,3715,3716,3717,3718,3719,3720,3721,3722,3723,3724,3725,3726,3727,3728,3729,3730,3731,3732,3733,3734,3735,3736,3737,3738,3739,3740,3741,3742,3743,3744,3745,3746,3747,3748,3749,3750,3751,3752,3753,3754,3755,3756,3757,3758,3759,3760,3761,3762,3763,3764,3765,3766,3767,3768,3769,3770,3771,3772,3773,3774,3775,3776,3777,3778,3779,3780,3781,3782,3783,3784,3785,3786,3787,3788,3789,3790,3791,3792,3793,3794,3795,3796,3797,3798,3799,3800,3801,3802,3803,3804,3805,3806,3807,3808,3809,3810,3811,3812,3813,3814,3815,3816,3817,3818,3819,3820,3821,3822,3823,3824,3825,3826,3827,3828,3829,3830,3831,3832,3833,3834,3835,3836,3837,3838,3839,3840,3841,3842,3843,3844,3845,3846,3847,3848,3849,3850,3851,3852,3853,3854,3855,3856,3857,3858,3859,3860,3861,3862,3863,3864,3865,3866,3867,3868,3869,3870,3871,3872,3873,3874,3875,3876,3877,3878,3879,3880,3881,3882,3883,3884,3885,3886,3887,3888,3889,3890,3891,3892,3893,3894,3895,3896,3897,3898,3899,3900,3901,3902,3903,3904,3905,3906,3907,3908,3909,3910,3911,3912,3913,3914,3915,3916,3917,3918,3919,3920,3921,3922,3923,3924,3925,3926,3927,3928,3929,3930,3931,3932,3933,3934,3935,3936,3937,3938,3939,3940,3941,3942,3943,3944,3945,3946,3947,3948,3949,3950,3951,3952,3953,3954,3955,3956,3957,3958,3959,3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,3970,3971,3972,3973,3974,3975,3976,3977,3978,3979,3980,3981,3982,3983,3984,3985,3986,3987,3988,3989,3990,3991,3992,3993,3994,3995,3996,3997,3998,3999,4000,4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,4015,4016,4017,4018,4019,4020,4021,4022,4023,4024,4025,4026,4027,4028,4029,4030,4031,4032,4033,4034,4035,4036,4037,4038,4039,4040,4041,4042,4043,4044,4045,4046,4047,4048,4049,4050,4051,4052,4053,4054,4055,4056,4057,4058,4059,4060,4061,4062,4063,4064,4065,4066,4067,4068,4069,4070,4071,4072,4073,4074,4075,4076,4077,4078,4079,4080,4081,4082,4083,4084,4085,4086,4087,4088,4089,4090,4091,4092,4093,4094,4095,4096,4097,4098,4099,4100,4101,4102,4103,4104,4105,4106,4107,4108,4109,4110,4111,4112,4113,4114,4115,4116,4117,4118,4119,4120,4121,4122,4123,4124,4125,4126,4127,4128,4129,4130,4131,4132,4133,4134,4135,4136,4137,4138,4139,4140,4141,4142,4143,4144,4145,4146,4147,4148,4149,4150,4151,4152,4153,4154,4155,4156,4157,4158,4159,4160,4161,4162,4163,4164,4165,4166,4167,4168,4169,4170,4171,4172,4173,4174,4175,4176,4177,4178,4179,4180,4181,4182,4183,4184,4185,4186,4187,4188,4189,4190,4191,4192,4193,4194,4195,4196,4197,4198,4199,4200,4201,4202,4203,4204,4205,4206,4207,4208,4209,4210,4211,4212,4213,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,4224,4225,4226,4227,4228,4229,4230,4231,4232,4233,4234,4235,4236,4237,4238,4239,4240,4241,4242,4243,4244,4245,4246,4247,4248,4249,4250,4251,4252,4253,4254,4255,4256,4257,4258,4259,4260,4261,4262,4263,4264,4265,4266,4267,4268,4269,4270,4271,4272,4273,4274,4275,4276,4277,4278,4279,4280,4281,4282,4283,4284,4285,4286,4287,4288,4289,4290,4291,4292,4293,4294,4295,4296,4297,4298,4299,4300,4301,4302,4303,4304,4305,4306,4307,4308,4309,4310,4311,4312,4313,4314,4315,4316,4317,4318,4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,4330,4331,4332,4333,4334,4335,4336,4337,4338,4339,4340,4341,4342,4343,4344,4345,4346,4347,4348,4349,4350,4351,4352,4353,4354,4355,4356,4357,4358,4359,4360,4361,4362,4363,4364,4365,4366,4367,4368,4369,4370,4371,4372,4373,4374,4375,4376,4377,4378,4379,4380,4381,4382,4383,4384,4385,4386,4387,4388,4389,4390,4391,4392,4393,4394,4395,4396,4397,4398,4399,4400,4401,4402,4403,4404,4405,4406,4407,4408,4409,4410,4411,4412,4413,4414,4415,4416,4417,4418,4419,4420,4421,4422,4423,4424,4425,4426,4427,4428,4429,4430,4431,4432,4433,4434,4435,4436,4437,4438,4439,4440,4441,4442,4443,4444,4445,4446,4447,4448,4449,4450,4451,4452,4453,4454,4455,4456,4457,4458,4459,4460,4461,4462,4463,4464,4465,4466,4467,4468,4469,4470,4471,4472,4473,4474,4475,4476,4477,4478,4479,4480,4481,4482,4483,4484,4485,4486,4487,4488,4489,4490,4491,4492,4493,4494,4495,4496,4497,4498,4499,4500,4501,4502,4503,4504,4505,4506,4507,4508,4509,4510,4511,4512,4513,4514,4515,4516,4517,4518,4519,4520,4521,4522,4523,4524,4525,4526,4527,4528,4529,4530,4531,4532,4533,4534,4535,4536,4537,4538,4539,4540,4541,4542,4543,4544,4545,4546,4547,4548,4549,4550,4551,4552,4553,4554,4555,4556,4557,4558,4559,4560,4561,4562,4563,4564,4565,4566,4567,4568,4569,4570,4571,4572,4573,4574,4575,4576,4577,4578,4579,4580,4581,4582,4583,4584,4585,4586,4587,4588,4589,4590,4591,4592,4593,4594,4595,4596,4597,4598,4599,4600,4601,4602,4603,4604,4605,4606,4607,4608,4609,4610,4611,4612,4613,4614,4615,4616,4617,4618,4619,4620,4621,4622,4623,4624,4625,4626,4627,4628,4629,4630,4631,4632,4633,4634,4635,4636,4637,4638,4639,4640,4641,4642,4643,4644,4645,4646,4647,4648,4649,4650,4651,4652,4653,4654,4655,4656,4657,4658,4659,4660,4661,4662,4663,4664,4665,4666,4667,4668,4669,4670,4671,4672,4673,4674,4675,4676,4677,4678,4679,4680,4681,4682,4683,4684,4685,4686,4687,4688,4689,4690,4691,4692,4693,4694,4695,4696,4697,4698,4699,4700,4701,4702,4703,4704,4705,4706,4707,4708,4709,4710,4711,4712,4713,4714,4715,4716,4717,4718,4719,4720,4721,4722,4723,4724,4725,4726,4727,4728,4729,4730,4731,4732,4733,4734,4735,4736,4737,4738,4739,4740,4741,4742,4743,4744,4745,4746,4747,4748,4749,4750,4751,4752,4753,4754,4755,4756,4757,4758,4759,4760,4761,4762,4763,4764,4765,4766,4767,4768,4769,4770,4771,4772,4773,4774,4775,4776,4777,4778,4779,4780,4781,4782,4783,4784,4785,4786,4787,4788,4789,4790,4791,4792,4793,4794,4795,4796,4797,4798,4799,4800,4801,4802,4803,4804,4805,4806,4807,4808,4809,4810,4811,4812,4813,4814,4815,4816,4817,4818,4819,4820,4821,4822,4823,4824,4825,4826,4827,4828,4829,4830,4831,4832,4833,4834,4835,4836,4837,4838,4839,4840,4841,4842,4843,4844,4845,4846,4847,4848,4849,4850,4851,4852,4853,4854,4855,4856,4857,4858,4859,4860,4861,4862,4863,4864,4865,4866,4867,4868,4869,4870,4871,4872,4873,4874,4875,4876,4877,4878,4879,4880,4881,4882,4883,4884,4885,4886,4887,4888,4889,4890,4891,4892,4893,4894,4895,4896,4897,4898,4899,4900,4901,4902,4903,4904,4905,4906,4907,4908,4909,4910,4911,4912,4913,4914,4915,4916,4917,4918,4919,4920,4921,4922,4923,4924,4925,4926,4927,4928,4929,4930,4931,4932,4933,4934,4935,4936,4937,4938,4939,4940,4941,4942,4943,4944,4945,4946,4947,4948,4949,4950,4951,4952,4953,4954,4955,4956,4957,4958,4959,4960,4961,4962,4963,4964,4965,4966,4967,4968,4969,4970,4971,4972,4973,4974,4975,4976,4977,4978,4979,4980,4981,4982,4983,4984,4985,4986,4987,4988,4989,4990,4991,4992,4993,4994,4995,4996,4997,4998,4999,5000,5001,5002,5003,5004,5005,5006,5007,5008,5009,5010,5011,5012,5013,5014,5015,5016,5017,5018,5019,5020,5021,5022,5023,5024,5025,5026,5027,5028,5029,5030,5031,5032,5033,5034,5035,5036,5037,5038,5039,5040,5041,5042,5043,5044,5045,5046,5047,5048,5049,5050,5051,5052,5053,5054,5055,5056,5057,5058,5059,5060,5061,5062,5063,5064,5065,5066,5067,5068,5069,5070,5071,5072,5073,5074,5075,5076,5077,5078,5079,5080,5081,5082,5083,5084,5085,5086,5087,5088,5089,5090,5091,5092,5093,5094,5095,5096,5097,5098,5099,5100,5101,5102,5103,5104,5105,5106,5107,5108,5109,5110,5111,5112,5113,5114,5115,5116,5117,5118,5119,5120,5121,5122,5123,5124,5125,5126,5127,5128,5129,5130,5131,5132,5133,5134,5135,5136,5137,5138,5139,5140,5141,5142,5143,5144,5145,5146,5147,5148,5149,5150,5151,5152,5153,5154,5155,5156,5157,5158,5159,5160,5161,5162,5163,5164,5165,5166,5167,5168,5169,5170,5171,5172,5173,5174,5175,5176,5177,5178,5179,5180,5181,5182,5183,5184,5185,5186,5187,5188,5189,5190,5191,5192,5193,5194,5195,5196,5197,5198,5199,5200,5201,5202,5203,5204,5205,5206,5207,5208,5209,5210,5211,5212,5213,5214,5215,5216,5217,5218,5219,5220,5221,5222,5223,5224,5225,5226,5227,5228,5229,5230,5231,5232,5233,5234,5235,5236,5237,5238,5239,5240,5241,5242,5243,5244,5245,5246,5247,5248,5249,5250,5251,5252,5253,5254,5255,5256,5257,5258,5259,5260,5261,5262,5263,5264,5265,5266,5267,5268,5269,5270,5271,5272,5273,5274,5275,5276,5277,5278,5279,5280,5281,5282,5283,5284,5285,5286,5287,5288,5289,5290,5291,5292,5293,5294,5295,5296,5297,5298,5299,5300,5301,5302,5303,5304,5305,5306,5307,5308,5309,5310,5311,5312,5313,5314,5315,5316,5317,5318,5319,5320,5321,5322,5323,5324,5325,5326,5327,5328,5329,5330,5331,5332,5333,5334,5335,5336,5337,5338,5339,5340,5341,5342,5343,5344,5345,5346,5347,5348,5349,5350,5351,5352,5353,5354,5355,5356,5357,5358,5359,5360,5361,5362,5363,5364,5365,5366,5367,5368,5369,5370,5371,5372,5373,5374,5375,5376,5377,5378,5379,5380,5381,5382,5383,5384,5385,5386,5387,5388,5389,5390,5391,5392,5393,5394,5395,5396,5397,5398,5399,5400,5401,5402,5403,5404,5405,5406,5407,5408,5409,5410,5411,5412,5413,5414,5415,5416,5417,5418,5419,5420,5421,5422,5423,5424,5425,5426,5427,5428,5429,5430,5431,5432,5433,5434,5435,5436,5437,5438,5439,5440,5441,5442,5443,5444,5445,5446,5447,5448,5449,5450,5451,5452,5453,5454,5455,5456,5457,5458,5459,5460,5461,5462,5463,5464,5465,5466,5467,5468,5469,5470,5471,5472,5473,5474,5475,5476,5477,5478,5479,5480,5481,5482,5483,5484,5485,5486,5487,5488,5489,5490,5491,5492,5493,5494,5495,5496,5497,5498,5499,5500,5501,5502,5503,5504,5505,5506,5507,5508,5509,5510,5511,5512,5513,5514,5515,5516,5517,5518,5519,5520,5521,5522,5523,5524,5525,5526,5527,5528,5529,5530,5531,5532,5533,5534,5535,5536,5537,5538,5539,5540,5541,5542,5543,5544,5545,5546,5547,5548,5549,5550,5551,5552,5553,5554,5555,5556,5557,5558,5559,5560,5561,5562,5563,5564,5565,5566,5567,5568,5569,5570,5571,5572,5573,5574,5575,5576,5577,5578,5579,5580,5581,5582,5583,5584,5585,5586,5587,5588,5589,5590,5591,5592,5593,5594,5595,5596,5597,5598,5599,5600,5601,5602,5603,5604,5605,5606,5607,5608,5609,5610,5611,5612,5613,5614,5615,5616,5617,5618,5619,5620,5621,5622,5623,5624,5625,5626,5627,5628,5629,5630,5631,5632,5633,5634,5635,5636,5637,5638,5639,5640,5641,5642,5643,5644,5645,5646,5647,5648,5649,5650,5651,5652,5653,5654,5655,5656,5657,5658,5659,5660,5661,5662,5663,5664,5665,5666,5667,5668,5669,5670,5671,5672,5673,5674,5675,5676,5677,5678,5679,5680,5681,5682,5683,5684,5685,5686,5687,5688,5689,5690,5691,5692,5693,5694,5695,5696,5697,5698,5699,5700,5701,5702,5703,5704,5705,5706,5707,5708,5709,5710,5711,5712,5713,5714,5715,5716,5717,5718,5719,5720,5721,5722,5723,5724,5725,5726,5727,5728,5729,5730,5731,5732,5733,5734,5735,5736,5737,5738,5739,5740,5741,5742,5743,5744,5745,5746,5747,5748,5749,5750,5751,5752,5753,5754,5755,5756,5757,5758,5759,5760,5761,5762,5763,5764,5765,5766,5767,5768,5769,5770,5771,5772,5773,5774,5775,5776,5777,5778,5779,5780,5781,5782,5783,5784,5785,5786,5787,5788,5789,5790,5791,5792,5793,5794,5795,5796,5797,5798,5799,5800,5801,5802,5803,5804,5805,5806,5807,5808,5809,5810,5811,5812,5813,5814,5815,5816,5817,5818,5819,5820,5821,5822,5823,5824,5825,5826,5827,5828,5829,5830,5831,5832,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,5843,5844,5845,5846,5847,5848,5849,5850,5851,5852,5853,5854,5855,5856,5857,5858,5859,5860,5861,5862,5863,5864,5865,5866,5867,5868,5869,5870,5871,5872,5873,5874,5875,5876,5877,5878,5879,5880,5881,5882,5883,5884,5885,5886,5887,5888,5889,5890,5891,5892,5893,5894,5895,5896,5897,5898,5899,5900,5901,5902,5903,5904,5905,5906,5907,5908,5909,5910,5911,5912,5913,5914,5915,5916,5917,5918,5919,5920,5921,5922,5923,5924,5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,5935,5936,5937,5938,5939,5940,5941,5942,5943,5944,5945,5946,5947,5948,5949,5950,5951,5952,5953,5954,5955,5956,5957,5958,5959,5960,5961,5962,5963,5964,5965,5966,5967,5968,5969,5970,5971,5972,5973,5974,5975,5976,5977,5978,5979,5980,5981,5982,5983,5984,5985,5986,5987,5988,5989,5990,5991,5992,5993,5994,5995,5996,5997,5998,5999,6000,6001,6002,6003,6004,6005,6006,6007,6008,6009,6010,6011,6012,6013,6014,6015,6016,6017,6018,6019,6020,6021,6022,6023,6024,6025,6026,6027,6028,6029,6030,6031,6032,6033,6034,6035,6036,6037,6038,6039,6040,6041,6042,6043,6044,6045,6046,6047,6048,6049,6050,6051,6052,6053,6054,6055,6056,6057,6058,6059,6060,6061,6062,6063,6064,6065,6066,6067,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,6115,6116,6117,6118,6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,6130,6131,6132,6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,6145,6146,6147,6148,6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163,6164,6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,6175,6176,6177,6178,6179,6180,6181,6182,6183,6184,6185,6186,6187,6188,6189,6190,6191,6192,6193,6194,6195,6196,6197,6198,6199,6200,6201,6202,6203,6204,6205,6206,6207,6208,6209,6210,6211,6212,6213,6214,6215,6216,6217,6218,6219,6220,6221,6222,6223,6224,6225,6226,6227,6228,6229,6230,6231,6232,6233,6234,6235,6236,6237,6238,6239,6240,6241,6242,6243,6244,6245,6246,6247,6248,6249,6250,6251,6252,6253,6254,6255,6256,6257,6258,6259,6260,6261,6262,6263,6264,6265,6266,6267,6268,6269,6270,6271,6272,6273,6274,6275,6276,6277,6278,6279,6280,6281,6282,6283,6284,6285,6286,6287,6288,6289,6290,6291,6292,6293,6294,6295,6296,6297,6298,6299,6300,6301,6302,6303,6304,6305,6306,6307,6308,6309,6310,6311,6312,6313,6314,6315,6316,6317,6318,6319,6320,6321,6322,6323,6324,6325,6326,6327,6328,6329,6330,6331,6332,6333,6334,6335,6336,6337,6338,6339,6340,6341,6342,6343,6344,6345,6346,6347,6348,6349,6350,6351,6352,6353,6354,6355,6356,6357,6358,6359,6360,6361,6362,6363,6364,6365,6366,6367,6368,6369,6370,6371,6372,6373,6374,6375,6376,6377,6378,6379,6380,6381,6382,6383,6384,6385,6386,6387,6388,6389,6390,6391,6392,6393,6394,6395,6396,6397,6398,6399,6400,6401,6402,6403,6404,6405,6406,6407,6408,6409,6410,6411,6412,6413,6414,6415,6416,6417,6418,6419,6420,6421,6422,6423,6424,6425,6426,6427,6428,6429,6430,6431,6432,6433,6434,6435,6436,6437,6438,6439,6440,6441,6442,6443,6444,6445,6446,6447,6448,6449,6450,6451,6452,6453,6454,6455,6456,6457,6458,6459,6460,6461,6462,6463,6464,6465,6466,6467,6468,6469,6470,6471,6472,6473,6474,6475,6476,6477,6478,6479,6480,6481,6482,6483,6484,6485,6486,6487,6488,6489,6490,6491,6492,6493,6494,6495,6496,6497,6498,6499,6500,6501,6502,6503,6504,6505,6506,6507,6508,6509,6510,6511,6512,6513,6514,6515,6516,6517,6518,6519,6520,6521,6522,6523,6524,6525,6526,6527,6528,6529,6530,6531,6532,6533,6534,6535,6536,6537,6538,6539,6540,6541,6542,6543,6544,6545,6546,6547,6548,6549,6550,6551,6552,6553,6554,6555,6556,6557,6558,6559,6560,6561,6562,6563,6564,6565,6566,6567,6568,6569,6570,6571,6572,6573,6574,6575,6576,6577,6578,6579,6580,6581,6582,6583,6584,6585,6586,6587,6588,6589,6590,6591,6592,6593,6594,6595,6596,6597,6598,6599,6600,6601,6602,6603,6604,6605,6606,6607,6608,6609,6610,6611,6612,6613,6614,6615,6616,6617,6618,6619,6620,6621,6622,6623,6624,6625,6626,6627,6628,6629,6630,6631,6632,6633,6634,6635,6636,6637,6638,6639,6640,6641,6642,6643,6644,6645,6646,6647,6648,6649,6650,6651,6652,6653,6654,6655,6656,6657,6658,6659,6660,6661,6662,6663,6664,6665,6666,6667,6668,6669,6670,6671,6672,6673,6674,6675,6676,6677,6678,6679,6680,6681,6682,6683,6684,6685,6686,6687,6688,6689,6690,6691,6692,6693,6694,6695,6696,6697,6698,6699,6700,6701,6702,6703,6704,6705,6706,6707,6708,6709,6710,6711,6712,6713,6714,6715,6716,6717,6718,6719,6720,6721,6722,6723,6724,6725,6726,6727,6728,6729,6730,6731,6732,6733,6734,6735,6736,6737,6738,6739,6740,6741,6742,6743,6744,6745,6746,6747,6748,6749,6750,6751,6752,6753,6754,6755,6756,6757,6758,6759,6760,6761,6762,6763,6764,6765,6766,6767,6768,6769,6770,6771,6772,6773,6774,6775,6776,6777,6778,6779,6780,6781,6782,6783,6784,6785,6786,6787,6788,6789,6790,6791,6792,6793,6794,6795,6796,6797,6798,6799,6800,6801,6802,6803,6804,6805,6806,6807,6808,6809,6810,6811,6812,6813,6814,6815,6816,6817,6818,6819,6820,6821,6822,6823,6824,6825,6826,6827,6828,6829,6830,6831,6832,6833,6834,6835,6836,6837,6838,6839,6840,6841,6842,6843,6844,6845,6846,6847,6848,6849,6850,6851,6852,6853,6854,6855,6856,6857,6858,6859,6860,6861,6862,6863,6864,6865,6866,6867,6868,6869,6870,6871,6872,6873,6874,6875,6876,6877,6878,6879,6880,6881,6882,6883,6884,6885,6886,6887,6888,6889,6890,6891,6892,6893,6894,6895,6896,6897,6898,6899,6900,6901,6902,6903,6904,6905,6906,6907,6908,6909,6910,6911,6912,6913,6914,6915,6916,6917,6918,6919,6920,6921,6922,6923,6924,6925,6926,6927,6928,6929,6930,6931,6932,6933,6934,6935,6936,6937,6938,6939,6940,6941,6942,6943,6944,6945,6946,6947,6948,6949,6950,6951,6952,6953,6954,6955,6956,6957,6958,6959,6960,6961,6962,6963,6964,6965,6966,6967,6968,6969,6970,6971,6972,6973,6974,6975,6976,6977,6978,6979,6980,6981,6982,6983,6984,6985,6986,6987,6988,6989,6990,6991,6992,6993,6994,6995,6996,6997,6998,6999,7000,7001,7002,7003,7004,7005,7006,7007,7008,7009,7010,7011,7012,7013,7014,7015,7016,7017,7018,7019,7020,7021,7022,7023,7024,7025,7026,7027,7028,7029,7030,7031,7032,7033,7034,7035,7036,7037,7038,7039,7040,7041,7042,7043,7044,7045,7046,7047,7048,7049,7050,7051,7052,7053,7054,7055,7056,7057,7058,7059,7060,7061,7062,7063,7064,7065,7066,7067,7068,7069,7070,7071,7072,7073,7074,7075,7076,7077,7078,7079,7080,7081,7082,7083,7084,7085,7086,7087,7088,7089,7090,7091,7092,7093,7094,7095,7096,7097,7098,7099,7100,7101,7102,7103,7104,7105,7106,7107,7108,7109,7110,7111,7112,7113,7114,7115,7116,7117,7118,7119,7120,7121,7122,7123,7124,7125,7126,7127,7128,7129,7130,7131,7132,7133,7134,7135,7136,7137,7138,7139,7140,7141,7142,7143,7144,7145,7146,7147,7148,7149,7150,7151,7152,7153,7154,7155,7156,7157,7158,7159,7160,7161,7162,7163,7164,7165,7166,7167,7168,7169,7170,7171,7172,7173,7174,7175,7176,7177,7178,7179,7180,7181,7182,7183,7184,7185,7186,7187,7188,7189,7190,7191,7192,7193,7194,7195,7196,7197,7198,7199,7200,7201,7202,7203,7204,7205,7206,7207,7208,7209,7210,7211,7212,7213,7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7224,7225,7226,7227,7228,7229,7230,7231,7232,7233,7234,7235,7236,7237,7238,7239,7240,7241,7242,7243,7244,7245,7246,7247,7248,7249,7250,7251,7252,7253,7254,7255,7256,7257,7258,7259,7260,7261,7262,7263,7264,7265,7266,7267,7268,7269,7270,7271,7272,7273,7274,7275,7276,7277,7278,7279,7280,7281,7282,7283,7284,7285,7286,7287,7288,7289,7290,7291,7292,7293,7294,7295,7296,7297,7298,7299,7300,7301,7302,7303,7304,7305,7306,7307,7308,7309,7310,7311,7312,7313,7314,7315,7316,7317,7318,7319,7320,7321,7322,7323,7324,7325,7326,7327,7328,7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339,7340,7341,7342,7343,7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,7354,7355,7356,7357,7358,7359,7360,7361,7362,7363,7364,7365,7366,7367,7368,7369,7370,7371,7372,7373,7374,7375,7376,7377,7378,7379,7380,7381,7382,7383,7384,7385,7386,7387,7388,7389,7390,7391,7392,7393,7394,7395,7396,7397,7398,7399,7400,7401,7402,7403,7404,7405,7406,7407,7408,7409,7410,7411,7412,7413,7414,7415,7416,7417,7418,7419,7420,7421,7422,7423,7424,7425,7426,7427,7428,7429,7430,7431,7432,7433,7434,7435,7436,7437,7438,7439,7440,7441,7442,7443,7444,7445,7446,7447,7448,7449,7450,7451,7452,7453,7454,7455,7456,7457,7458,7459,7460,7461,7462,7463,7464,7465,7466,7467,7468,7469,7470,7471,7472,7473,7474,7475,7476,7477,7478,7479,7480,7481,7482,7483,7484,7485,7486,7487,7488,7489,7490,7491,7492,7493,7494,7495,7496,7497,7498,7499,7500,7501,7502,7503,7504,7505,7506,7507,7508,7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519,7520,7521,7522,7523,7524,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535,7536,7537,7538,7539,7540,7541,7542,7543,7544,7545,7546,7547,7548,7549,7550,7551,7552,7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567,7568,7569,7570,7571,7572,7573,7574,7575,7576,7577,7578,7579,7580,7581,7582,7583,7584,7585,7586,7587,7588,7589,7590,7591,7592,7593,7594,7595,7596,7597,7598,7599,7600,7601,7602,7603,7604,7605,7606,7607,7608,7609,7610,7611,7612,7613,7614,7615,7616,7617,7618,7619,7620,7621,7622,7623,7624,7625,7626,7627,7628,7629,7630,7631,7632,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,7658,7659,7660,7661,7662,7663,7664,7665,7666,7667,7668,7669,7670,7671,7672,7673,7674,7675,7676,7677,7678,7679,7680,7681,7682,7683,7684,7685,7686,7687,7688,7689,7690,7691,7692,7693,7694,7695,7696,7697,7698,7699,7700,7701,7702,7703,7704,7705,7706,7707,7708,7709,7710,7711,7712,7713,7714,7715,7716,7717,7718,7719,7720,7721,7722,7723,7724,7725,7726,7727,7728,7729,7730,7731,7732,7733,7734,7735,7736,7737,7738,7739,7740,7741,7742,7743,7744,7745,7746,7747,7748,7749,7750,7751,7752,7753,7754,7755,7756,7757,7758,7759,7760,7761,7762,7763,7764,7765,7766,7767,7768,7769,7770,7771,7772,7773,7774,7775,7776,7777,7778,7779,7780,7781,7782,7783,7784,7785,7786,7787,7788,7789,7790,7791,7792,7793,7794,7795,7796,7797,7798,7799,7800,7801,7802,7803,7804,7805,7806,7807,7808,7809,7810,7811,7812,7813,7814,7815,7816,7817,7818,7819,7820,7821,7822,7823,7824,7825,7826,7827,7828,7829,7830,7831,7832,7833,7834,7835,7836,7837,7838,7839,7840,7841,7842,7843,7844,7845,7846,7847,7848,7849,7850,7851,7852,7853,7854,7855,7856,7857,7858,7859,7860,7861,7862,7863,7864,7865,7866,7867,7868,7869,7870,7871,7872,7873,7874,7875,7876,7877,7878,7879,7880,7881,7882,7883,7884,7885,7886,7887,7888,7889,7890,7891,7892,7893,7894,7895,7896,7897,7898,7899,7900,7901,7902,7903,7904,7905,7906,7907,7908,7909,7910,7911,7912,7913,7914,7915,7916,7917,7918,7919,7920,7921,7922,7923,7924,7925,7926,7927,7928,7929,7930,7931,7932,7933,7934,7935,7936,7937,7938,7939,7940,7941,7942,7943,7944,7945,7946,7947,7948,7949,7950,7951,7952,7953,7954,7955,7956,7957,7958,7959,7960,7961,7962,7963,7964,7965,7966,7967,7968,7969,7970,7971,7972,7973,7974,7975,7976,7977,7978,7979,7980,7981,7982,7983,7984,7985,7986,7987,7988,7989,7990,7991,7992,7993,7994,7995,7996,7997,7998,7999,8000,8001,8002,8003,8004,8005,8006,8007,8008,8009,8010,8011,8012,8013,8014,8015,8016,8017,8018,8019,8020,8021,8022,8023,8024,8025,8026,8027,8028,8029,8030,8031,8032,8033,8034,8035,8036,8037,8038,8039,8040,8041,8042,8043,8044,8045,8046,8047,8048,8049,8050,8051,8052,8053,8054,8055,8056,8057,8058,8059,8060,8061,8062,8063,8064,8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,8078,8079,8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,8093,8094,8095,8096,8097,8098,8099,8100,8101,8102,8103,8104,8105,8106,8107,8108,8109,8110,8111,8112,8113,8114,8115,8116,8117,8118,8119,8120,8121,8122,8123,8124,8125,8126,8127,8128,8129,8130,8131,8132,8133,8134,8135,8136,8137,8138,8139,8140,8141,8142,8143,8144,8145,8146,8147,8148,8149,8150,8151,8152,8153,8154,8155,8156,8157,8158,8159,8160,8161,8162,8163,8164,8165,8166,8167,8168,8169,8170,8171,8172,8173,8174,8175,8176,8177,8178,8179,8180,8181,8182,8183,8184,8185,8186,8187,8188,8189,8190,8191,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8203,8204,8205,8206,8207,8208,8209,8210,8211,8212,8213,8214,8215,8216,8217,8218,8219,8220,8221,8222,8223,8224,8225,8226,8227,8228,8229,8230,8231,8232,8233,8234,8235,8236,8237,8238,8239,8240,8241,8242,8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255,8256,8257,8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271,8272,8273,8274,8275,8276,8277,8278,8279,8280,8281,8282,8283,8284,8285,8286,8287,8288,8289,8290,8291,8292,8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,8303,8304,8305,8306,8307,8308,8309,8310,8311,8312,8313,8314,8315,8316,8317,8318,8319,8320,8321,8322,8323,8324,8325,8326,8327,8328,8329,8330,8331,8332,8333,8334,8335,8336,8337,8338,8339,8340,8341,8342,8343,8344,8345,8346,8347,8348,8349,8350,8351,8352,8353,8354,8355,8356,8357,8358,8359,8360,8361,8362,8363,8364,8365,8366,8367,8368,8369,8370,8371,8372,8373,8374,8375,8376,8377,8378,8379,8380,8381,8382,8383,8384,8385,8386,8387,8388,8389,8390,8391,8392,8393,8394,8395,8396,8397,8398,8399,8400,8401,8402,8403,8404,8405,8406,8407,8408,8409,8410,8411,8412,8413,8414,8415,8416,8417,8418,8419,8420,8421,8422,8423,8424,8425,8426,8427,8428,8429,8430,8431,8432,8433,8434,8435,8436,8437,8438,8439,8440,8441,8442,8443,8444,8445,8446,8447,8448,8449,8450,8451,8452,8453,8454,8455,8456,8457,8458,8459,8460,8461,8462,8463,8464,8465,8466,8467,8468,8469,8470,8471,8472,8473,8474,8475,8476,8477,8478,8479,8480,8481,8482,8483,8484,8485,8486,8487,8488,8489,8490,8491,8492,8493,8494,8495,8496,8497,8498,8499,8500,8501,8502,8503,8504,8505,8506,8507,8508,8509,8510,8511,8512,8513,8514,8515,8516,8517,8518,8519,8520,8521,8522,8523,8524,8525,8526,8527,8528,8529,8530,8531,8532,8533,8534,8535,8536,8537,8538,8539,8540,8541,8542,8543,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554,8555,8556,8557,8558,8559,8560,8561,8562,8563,8564,8565,8566,8567,8568,8569,8570,8571,8572,8573,8574,8575,8576,8577,8578,8579,8580,8581,8582,8583,8584,8585,8586,8587,8588,8589,8590,8591,8592,8593,8594,8595,8596,8597,8598,8599,8600,8601,8602,8603,8604,8605,8606,8607,8608,8609,8610,8611,8612,8613,8614,8615,8616,8617,8618,8619,8620,8621,8622,8623,8624,8625,8626,8627,8628,8629,8630,8631,8632,8633,8634,8635,8636,8637,8638,8639,8640,8641,8642,8643,8644,8645,8646,8647,8648,8649,8650,8651,8652,8653,8654,8655,8656,8657,8658,8659,8660,8661,8662,8663,8664,8665,8666,8667,8668,8669,8670,8671,8672,8673,8674,8675,8676,8677,8678,8679,8680,8681,8682,8683,8684,8685,8686,8687,8688,8689,8690,8691,8692,8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8705,8706,8707,8708,8709,8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,8720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,8736,8737,8738,8739,8740,8741,8742,8743,8744,8745,8746,8747,8748,8749,8750,8751,8752,8753,8754,8755,8756,8757,8758,8759,8760,8761,8762,8763,8764,8765,8766,8767,8768,8769,8770,8771,8772,8773,8774,8775,8776,8777,8778,8779,8780,8781,8782,8783,8784,8785,8786,8787,8788,8789,8790,8791,8792,8793,8794,8795,8796,8797,8798,8799,8800,8801,8802,8803,8804,8805,8806,8807,8808,8809,8810,8811,8812,8813,8814,8815,8816,8817,8818,8819,8820,8821,8822,8823,8824,8825,8826,8827,8828,8829,8830,8831,8832,8833,8834,8835,8836,8837,8838,8839,8840,8841,8842,8843,8844,8845,8846,8847,8848,8849,8850,8851,8852,8853,8854,8855,8856,8857,8858,8859,8860,8861,8862,8863,8864,8865,8866,8867,8868,8869,8870,8871,8872,8873,8874,8875,8876,8877,8878,8879,8880,8881,8882,8883,8884,8885,8886,8887,8888,8889,8890,8891,8892,8893,8894,8895,8896,8897,8898,8899,8900,8901,8902,8903,8904,8905,8906,8907,8908,8909,8910,8911,8912,8913,8914,8915,8916,8917,8918,8919,8920,8921,8922,8923,8924,8925,8926,8927,8928,8929,8930,8931,8932,8933,8934,8935,8936,8937,8938,8939,8940,8941,8942,8943,8944,8945,8946,8947,8948,8949,8950,8951,8952,8953,8954,8955,8956,8957,8958,8959,8960,8961,8962,8963,8964,8965,8966,8967,8968,8969,8970,8971,8972,8973,8974,8975,8976,8977,8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,8993,8994,8995,8996,8997,8998,8999,9000,9001,9002,9003,9004,9005,9006,9007,9008,9009,9010,9011,9012,9013,9014,9015,9016,9017,9018,9019,9020,9021,9022,9023,9024,9025,9026,9027,9028,9029,9030,9031,9032,9033,9034,9035,9036,9037,9038,9039,9040,9041,9042,9043,9044,9045,9046,9047,9048,9049,9050,9051,9052,9053,9054,9055,9056,9057,9058,9059,9060,9061,9062,9063,9064,9065,9066,9067,9068,9069,9070,9071,9072,9073,9074,9075,9076,9077,9078,9079,9080,9081,9082,9083,9084,9085,9086,9087,9088,9089,9090,9091,9092,9093,9094,9095,9096,9097,9098,9099,9100,9101,9102,9103,9104,9105,9106,9107,9108,9109,9110,9111,9112,9113,9114,9115,9116,9117,9118,9119,9120,9121,9122,9123,9124,9125,9126,9127,9128,9129,9130,9131,9132,9133,9134,9135,9136,9137,9138,9139,9140,9141,9142,9143,9144,9145,9146,9147,9148,9149,9150,9151,9152,9153,9154,9155,9156,9157,9158,9159,9160,9161,9162,9163,9164,9165,9166,9167,9168,9169,9170,9171,9172,9173,9174,9175,9176,9177,9178,9179,9180,9181,9182,9183,9184,9185,9186,9187,9188,9189,9190,9191,9192,9193,9194,9195,9196,9197,9198,9199,9200,9201,9202,9203,9204,9205,9206,9207,9208,9209,9210,9211,9212,9213,9214,9215,9216,9217,9218,9219,9220,9221,9222,9223,9224,9225,9226,9227,9228,9229,9230,9231,9232,9233,9234,9235,9236,9237,9238,9239,9240,9241,9242,9243,9244,9245,9246,9247,9248,9249,9250,9251,9252,9253,9254,9255,9256,9257,9258,9259,9260,9261,9262,9263,9264,9265,9266,9267,9268,9269,9270,9271,9272,9273,9274,9275,9276,9277,9278,9279,9280,9281,9282,9283,9284,9285,9286,9287,9288,9289,9290,9291,9292,9293,9294,9295,9296,9297,9298,9299,9300,9301,9302,9303,9304,9305,9306,9307,9308,9309,9310,9311,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,9322,9323,9324,9325,9326,9327,9328,9329,9330,9331,9332,9333,9334,9335,9336,9337,9338,9339,9340,9341,9342,9343,9344,9345,9346,9347,9348,9349,9350,9351,9352,9353,9354,9355,9356,9357,9358,9359,9360,9361,9362,9363,9364,9365,9366,9367,9368,9369,9370,9371,9372,9373,9374,9375,9376,9377,9378,9379,9380,9381,9382,9383,9384,9385,9386,9387,9388,9389,9390,9391,9392,9393,9394,9395,9396,9397,9398,9399,9400,9401,9402,9403,9404,9405,9406,9407,9408,9409,9410,9411,9412,9413,9414,9415,9416,9417,9418,9419,9420,9421,9422,9423,9424,9425,9426,9427,9428,9429,9430,9431,9432,9433,9434,9435,9436,9437,9438,9439,9440,9441,9442,9443,9444,9445,9446,9447,9448,9449,9450,9451,9452,9453,9454,9455,9456,9457,9458,9459,9460,9461,9462,9463,9464,9465,9466,9467,9468,9469,9470,9471,9472,9473,9474,9475,9476,9477,9478,9479,9480,9481,9482,9483,9484,9485,9486,9487,9488,9489,9490,9491,9492,9493,9494,9495,9496,9497,9498,9499,9500,9501,9502,9503,9504,9505,9506,9507,9508,9509,9510,9511,9512,9513,9514,9515,9516,9517,9518,9519,9520,9521,9522,9523,9524,9525,9526,9527,9528,9529,9530,9531,9532,9533,9534,9535,9536,9537,9538,9539,9540,9541,9542,9543,9544,9545,9546,9547,9548,9549,9550,9551,9552,9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568,9569,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,9581,9582,9583,9584,9585,9586,9587,9588,9589,9590,9591,9592,9593,9594,9595,9596,9597,9598,9599,9600,9601,9602,9603,9604,9605,9606,9607,9608,9609,9610,9611,9612,9613,9614,9615,9616,9617,9618,9619,9620,9621,9622,9623,9624,9625,9626,9627,9628,9629,9630,9631,9632,9633,9634,9635,9636,9637,9638,9639,9640,9641,9642,9643,9644,9645,9646,9647,9648,9649,9650,9651,9652,9653,9654,9655,9656,9657,9658,9659,9660,9661,9662,9663,9664,9665,9666,9667,9668,9669,9670,9671,9672,9673,9674,9675,9676,9677,9678,9679,9680,9681,9682,9683,9684,9685,9686,9687,9688,9689,9690,9691,9692,9693,9694,9695,9696,9697,9698,9699,9700,9701,9702,9703,9704,9705,9706,9707,9708,9709,9710,9711,9712,9713,9714,9715,9716,9717,9718,9719,9720,9721,9722,9723,9724,9725,9726,9727,9728,9729,9730,9731,9732,9733,9734,9735,9736,9737,9738,9739,9740,9741,9742,9743,9744,9745,9746,9747,9748,9749,9750,9751,9752,9753,9754,9755,9756,9757,9758,9759,9760,9761,9762,9763,9764,9765,9766,9767,9768,9769,9770,9771,9772,9773,9774,9775,9776,9777,9778,9779,9780,9781,9782,9783,9784,9785,9786,9787,9788,9789,9790,9791,9792,9793,9794,9795,9796,9797,9798,9799,9800,9801,9802,9803,9804,9805,9806,9807,9808,9809,9810,9811,9812,9813,9814,9815,9816,9817,9818,9819,9820,9821,9822,9823,9824,9825,9826,9827,9828,9829,9830,9831,9832,9833,9834,9835,9836,9837,9838,9839,9840,9841,9842,9843,9844,9845,9846,9847,9848,9849,9850,9851,9852,9853,9854,9855,9856,9857,9858,9859,9860,9861,9862,9863,9864,9865,9866,9867,9868,9869,9870,9871,9872,9873,9874,9875,9876,9877,9878,9879,9880,9881,9882,9883,9884,9885,9886,9887,9888,9889,9890,9891,9892,9893,9894,9895,9896,9897,9898,9899,9900,9901,9902,9903,9904,9905,9906,9907,9908,9909,9910,9911,9912,9913,9914,9915,9916,9917,9918,9919,9920,9921,9922,9923,9924,9925,9926,9927,9928,9929,9930,9931,9932,9933,9934,9935,9936,9937,9938,9939,9940,9941,9942,9943,9944,9945,9946,9947,9948,9949,9950,9951,9952,9953,9954,9955,9956,9957,9958,9959,9960,9961,9962,9963,9964,9965,9966,9967,9968,9969,9970,9971,9972,9973,9974,9975,9976,9977,9978,9979,9980,9981,9982,9983,9984,9985,9986,9987,9988,9989,9990,9991,9992,9993,9994,9995,9996,9997,9998,1}, +9998, +}, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 8}, + 8, + }, + + { + []int{8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}, + 1, + }, + + { + []int{0, 1, 0}, + 1, + }, + + { + []int{0, 2, 1, 0}, + 1, + }, + + // 可以有多个 testcase +} + +func Test_peakIndexInMountainArray(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, peakIndexInMountainArray(tc.A), "输入:%v", tc) + } +} + +func Benchmark_peakIndexInMountainArray(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + peakIndexInMountainArray(tc.A) + } + } +} diff --git a/Algorithms/0853.car-fleet/README.md b/Algorithms/0853.car-fleet/README.md new file mode 100755 index 000000000..204d1890d --- /dev/null +++ b/Algorithms/0853.car-fleet/README.md @@ -0,0 +1,41 @@ +# [853. Car Fleet](https://leetcode.com/problems/car-fleet/) + +## 题目 + +N cars are going to the same destination along a one lane road. The destination is target miles away. + +Each car ihas a constant speed speed[i](in miles per hour), and initial position position[i]miles towards the target along the road. + +A car can never pass another car ahead of it, but it can catch up to it, and drive bumper to bumper at the same speed. + +The distance between these two cars is ignored - they are assumed to have the same position. + +A car fleet is some non-empty set of cars drivingat the same position and same speed. Note that a single car is also a car fleet. + +If a car catches up to a car fleet right at the destination point, it willstill beconsidered as one car fleet. + +How many car fleets will arrive at the destination? + +Example 1: + +```text +Input: target = 12, position = [10,8,0,5,3], speed = [2,4,1,1,3] +Output: 3 +Explanation: +The cars starting at 10 and 8 become a fleet, meeting each other at 12. +The car starting at 0 doesn't catch up to any other car, so it is a fleet by itself. +The cars starting at 5 and 3 become a fleet, meeting each other at 6. +Note that no other cars meet these fleets before the destination, so the answer is 3. +``` + +Note: + +1. 0 <= N <= 10 ^ 4 +1. 0 < target<= 10 ^ 6 +1. 0 rs[j].initPos + }) + + fleetTime := 0. + res := 0 + + for _, r := range rs { + at := r.arrivalTime + if fleetTime < at { + fleetTime = at + res++ + } + } + + return res +} + +type record struct { + initPos int + arrivalTime float64 +} diff --git a/Algorithms/0853.car-fleet/car-fleet_test.go b/Algorithms/0853.car-fleet/car-fleet_test.go new file mode 100755 index 000000000..d93fdeac8 --- /dev/null +++ b/Algorithms/0853.car-fleet/car-fleet_test.go @@ -0,0 +1,57 @@ +package problem0853 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + target int + position []int + speed []int + ans int +}{ + + { + 20, + []int{11, 10, 5}, + []int{9, 9, 10}, + 3, + }, + + { + 12, + []int{10, 8, 0, 5, 3}, + []int{2, 4, 1, 1, 3}, + 3, + }, + + { + 10000, + []int{10, 8, 0, 5, 3}, + []int{2, 4, 10000, 1, 3}, + 2, + }, + + // 可以有多个 testcase +} + +func Test_carFleet(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, carFleet(tc.target, tc.position, tc.speed), "输入:%v", tc) + } +} + +func Benchmark_carFleet(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + carFleet(tc.target, tc.position, tc.speed) + } + } +} diff --git a/Algorithms/0854.k-similar-strings/README.md b/Algorithms/0854.k-similar-strings/README.md new file mode 100755 index 000000000..37fd52697 --- /dev/null +++ b/Algorithms/0854.k-similar-strings/README.md @@ -0,0 +1,44 @@ +# [854. K-Similar Strings](https://leetcode.com/problems/k-similar-strings/) + +## 题目 + +StringsA and B are K-similar (for some non-negative integer K) if we can swap the positions of two letters in A exactly Ktimes so that the resulting string equals B. + +Given two anagrams A and B, return the smallest Kfor which A and B are K-similar. + +Example 1: + +```text +Input: A = "ab", B = "ba" +Output: 1 +``` + +Example 2: + +```text +Input: A = "abc", B = "bca" +Output: 2 +``` + +Example 3: + +```text +Input: A = "abac", B = "baca" +Output: 2 +``` + +Example 4: + +```text +Input: A = "aabc", B = "abca" +Output: 2 +``` + +Note: + +1. 1 <= A.length == B.length <= 20 +1. A and B contain only lowercase letters from the set {'a', 'b', 'c', 'd', 'e', 'f'} + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0854.k-similar-strings/k-similar-strings.go b/Algorithms/0854.k-similar-strings/k-similar-strings.go new file mode 100755 index 000000000..505186208 --- /dev/null +++ b/Algorithms/0854.k-similar-strings/k-similar-strings.go @@ -0,0 +1,56 @@ +package problem0854 + +func kSimilarity(a, b string) int { + if a == b { + return 0 + } + + hasSeen := make(map[string]bool, 4096) + hasSeen[a] = true + queue := make([]string, 1, 4096) + queue[0] = a + + strSize := len(a) + res := 0 + + // BFS + // 看见 shortest 就要想到 BFS + for { + res++ + for countDown := len(queue); countDown > 0; countDown-- { + // 从 queue 中取出一个候选字符串 + s := queue[0] + queue = queue[1:] + + // 跳过相等的字符 + i := 0 + for s[i] == b[i] { + i++ + } + for j := i + 1; j < strSize; j++ { + if s[j] == b[j] || // 依然跳过相等的字符 + // 还要保证 s 中的 i,j 互换后,s[j] == b[j] + // 要不然,就是没有意义的交换 + s[i] != b[j] { + continue + } + + temp := swap(s, i, j) + if temp == b { + return res + } + + if !hasSeen[temp] { + hasSeen[temp] = true + queue = append(queue, temp) + } + } + } + } +} + +func swap(s string, i, j int) string { + bs := []byte(s) + bs[i], bs[j] = bs[j], bs[i] + return string(bs) +} diff --git a/Algorithms/0854.k-similar-strings/k-similar-strings_test.go b/Algorithms/0854.k-similar-strings/k-similar-strings_test.go new file mode 100755 index 000000000..a3bc5f544 --- /dev/null +++ b/Algorithms/0854.k-similar-strings/k-similar-strings_test.go @@ -0,0 +1,65 @@ +package problem0854 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A string + B string + ans int +}{ + + { + "ab", + "ab", + 0, + }, + + { + "ab", + "ba", + 1, + }, + + { + "abc", + "bca", + 2, + }, + + { + "abac", + "baca", + 2, + }, + + { + "aabc", + "abca", + 2, + }, + + // 可以有多个 testcase +} + +func Test_kSimilarity(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, kSimilarity(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_kSimilarity(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + kSimilarity(tc.A, tc.B) + } + } +} diff --git a/Algorithms/0855.exam-room/README.md b/Algorithms/0855.exam-room/README.md new file mode 100755 index 000000000..69f748f37 --- /dev/null +++ b/Algorithms/0855.exam-room/README.md @@ -0,0 +1,34 @@ +# [855. Exam Room](https://leetcode.com/problems/exam-room/) + +## 题目 + +In an exam room, there are N seats in a single row, numbered 0, 1, 2, ..., N-1. + +When a student enters the room, they must sit in the seat that maximizes the distance to the closest person. If there are multiple such seats, they sit in the seat with the lowest number. (Also, if no one is in the room, then the student sits at seat number 0.) + +Return a class ExamRoom(int N)that exposes two functions: ExamRoom.seat()returning an intrepresenting what seat the student sat in, and ExamRoom.leave(int p)representing that the student in seat number pnow leaves the room. It is guaranteed that any calls to ExamRoom.leave(p) have a student sitting in seat p. + +Example 1: + +```text +Input: ["ExamRoom","seat","seat","seat","seat","leave","seat"], [[10],[],[],[],[],[4],[]] +Output: [null,0,9,4,2,null,5] +Explanation: +ExamRoom(10) -> null +seat() -> 0, no one is in the room, then the student sits at seat number 0. +seat() -> 9, the student sits at the last seat number 9. +seat() -> 4, the student sits at the last seat number 4. +seat() -> 2, the student sits at the last seat number 2. +leave(4) -> null +seat() -> 5, the student​​​​​​​ sits at the last seat number 5. +``` + +Note: + +1. 1 <= N <= 10^9 +1. ExamRoom.seat() and ExamRoom.leave() will be called at most 10^4 times across all test cases. +1. Calls to ExamRoom.leave(p) are guaranteed to have a student currently sitting in seat number p. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0855.exam-room/exam-room.go b/Algorithms/0855.exam-room/exam-room.go new file mode 100755 index 000000000..e8ede5d05 --- /dev/null +++ b/Algorithms/0855.exam-room/exam-room.go @@ -0,0 +1,74 @@ +package problem0855 + +// ExamRoom 是题目需要的结构体 +type ExamRoom struct { + seats *[]int + N int +} + +// Constructor 创建 ExamRoom +func Constructor(N int) ExamRoom { // 如果返回 *ExamRoom 后面可以写的好看一些 + t := make([]int, 0, 10000) + return ExamRoom{ + seats: &t, + N: N, + } +} + +// Seat 表示有人入座 +func (r *ExamRoom) Seat() int { + if len(*r.seats) == 0 { + *r.seats = append(*r.seats, 0) + return 0 + } + + f := -(*r.seats)[0] + *r.seats = append(*r.seats, 2*r.N-2-(*r.seats)[len(*r.seats)-1]) + idx := -1 + dis := -1 + seat := -1 + + for i := 0; i < len(*r.seats); i++ { + newDis := ((*r.seats)[i] - f) / 2 + if dis < newDis { + idx = i + dis = newDis + seat = f + dis + } + f = (*r.seats)[i] + } + + copy((*r.seats)[idx+1:], (*r.seats)[idx:]) + + (*r.seats)[idx] = seat + + return seat +} + +// Leave 表示有人离座 +func (r *ExamRoom) Leave(p int) { + size := len(*r.seats) + left, right := 0, size-1 + + for { // 题目保证了 p 一定在 r.seats 中 + m := (left + right) / 2 + mp := (*r.seats)[m] + switch { + case mp < p: + left = m + 1 + case p < mp: + right = m - 1 + default: + copy((*r.seats)[m:], (*r.seats)[m+1:]) + *r.seats = (*r.seats)[:size-1] + return + } + } +} + +/** + * Your ExamRoom object will be instantiated and called as such: + * obj := Constructor(N); + * param_1 := obj.Seat(); + * obj.Leave(p); + */ diff --git a/Algorithms/0855.exam-room/exam-room_test.go b/Algorithms/0855.exam-room/exam-room_test.go new file mode 100755 index 000000000..882ac265a --- /dev/null +++ b/Algorithms/0855.exam-room/exam-room_test.go @@ -0,0 +1,37 @@ +package problem0855 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_ExamRoom(t *testing.T) { + ast := assert.New(t) + + r := Constructor(10) + + seats := []int{0, 9, 4, 2} + + for i := 0; i < len(seats); i++ { + ast.Equal(seats[i], r.Seat(), "第 %d 次,入座了 %d", i, seats[i]) + } + + r.Leave(4) + + ast.Equal(5, r.Seat(), "4 号位离座后,应该是 5 号位入座") + + r.Leave(0) + + ast.Equal(0, r.Seat(), "0 号位离座后,应该是 0 号位入座") +} + +func Test_ExamRoom_2(t *testing.T) { + ast := assert.New(t) + r := Constructor(1000000000) + + for i := 0; i < 10; i++ { + ast.Equal(0, r.Seat(), "第 %d 次,入座了 %d", i, 0) + r.Leave(0) + } +} diff --git a/Algorithms/0856.score-of-parentheses/README.md b/Algorithms/0856.score-of-parentheses/README.md new file mode 100755 index 000000000..20c226712 --- /dev/null +++ b/Algorithms/0856.score-of-parentheses/README.md @@ -0,0 +1,46 @@ +# [856. Score of Parentheses](https://leetcode.com/problems/score-of-parentheses/) + +## 题目 + +Given a balanced parentheses string S, compute the score of the string based on the following rule: + +- () has score 1 +- AB has score A + B, where A and B are balanced parentheses strings. +- (A) has score 2 * A, where A is a balanced parentheses string. + +Example 1: + +```text +Input: "()" +Output: 1 +``` + +Example 2: + +```text +Input: "(())" +Output: 2 +``` + +Example 3: + +```text +Input: "()()" +Output: 2 +``` + +Example 4: + +```text +Input: "(()(()))" +Output: 6 +``` + +Note: + +1. S is a balanced parentheses string, containing only ( and ). +1. 2 <= S.length <= 50 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0856.score-of-parentheses/score-of-parentheses.go b/Algorithms/0856.score-of-parentheses/score-of-parentheses.go new file mode 100755 index 000000000..2c5638c10 --- /dev/null +++ b/Algorithms/0856.score-of-parentheses/score-of-parentheses.go @@ -0,0 +1,18 @@ +package problem0856 + +func scoreOfParentheses(s string) int { + res := 0 + factor := 1 + size := len(s) + for i := 0; i < size; i++ { + if s[i] == '(' { + factor *= 2 + } else { + factor /= 2 + } + if s[i] == '(' && s[i+1] == ')' { + res += factor / 2 + } + } + return res +} diff --git a/Algorithms/0856.score-of-parentheses/score-of-parentheses_test.go b/Algorithms/0856.score-of-parentheses/score-of-parentheses_test.go new file mode 100755 index 000000000..a656e0cfb --- /dev/null +++ b/Algorithms/0856.score-of-parentheses/score-of-parentheses_test.go @@ -0,0 +1,54 @@ +package problem0856 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans int +}{ + + { + "()", + 1, + }, + + { + "(())", + 2, + }, + + { + "()()", + 2, + }, + + { + "(()(()))", + 6, + }, + + // 可以有多个 testcase +} + +func Test_scoreOfParentheses(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, scoreOfParentheses(tc.S), "输入:%v", tc) + } +} + +func Benchmark_scoreOfParentheses(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + scoreOfParentheses(tc.S) + } + } +} diff --git a/Algorithms/0857.minimum-cost-to-hire-k-workers/README.md b/Algorithms/0857.minimum-cost-to-hire-k-workers/README.md new file mode 100755 index 000000000..000e02d15 --- /dev/null +++ b/Algorithms/0857.minimum-cost-to-hire-k-workers/README.md @@ -0,0 +1,39 @@ +# [857. Minimum Cost to Hire K Workers](https://leetcode.com/problems/minimum-cost-to-hire-k-workers/) + +## 题目 + +There are N workers. The i-th worker has a quality[i] and a minimum wage expectation wage[i]. + +Now we want to hire exactly Kworkers to form a paid group. When hiring a group of K workers, we must pay them according to the following rules: + +1. Every worker in the paid group should be paid in the ratio of their quality compared to other workers in the paid group. +1. Every worker in the paid group must be paid at least their minimum wage expectation. + +Return the least amount of money needed to form a paid group satisfying the above conditions. + +Example 1: + +```text +Input: quality = [10,20,5], wage = [70,50,30], K = 2 +Output: 105.00000 +Explanation: We pay 70 to 0-th worker and 35 to 2-th worker. +``` + +Example 2: + +```text +Input: quality = [3,1,10,10,1], wage = [4,8,2,2,7], K = 3 +Output: 30.66667 +Explanation: We pay 4 to 0-th worker, 13.33333 to 2-th and 3-th workers seperately. +``` + +Note: + +1. 1 <= K <= N <= 10000, where N = quality.length = wage.length +1. 1 <= quality[i] <= 10000 +1. 1 <= wage[i] <= 10000 +1. Answers within 10^-5 of the correct answer will be considered correct. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0857.minimum-cost-to-hire-k-workers/minimum-cost-to-hire-k-workers.go b/Algorithms/0857.minimum-cost-to-hire-k-workers/minimum-cost-to-hire-k-workers.go new file mode 100755 index 000000000..e4a163b28 --- /dev/null +++ b/Algorithms/0857.minimum-cost-to-hire-k-workers/minimum-cost-to-hire-k-workers.go @@ -0,0 +1,82 @@ +package problem0857 + +import ( + "container/heap" + "sort" +) + +func mincostToHireWorkers(quality []int, wage []int, K int) float64 { + size := len(quality) + + workers := make([][2]float64, size) + for i := 0; i < size; i++ { + w, q := float64(wage[i]), float64(quality[i]) + ratio := w / q + workers[i] = [2]float64{ratio, q} + } + sort.Slice(workers, func(i int, j int) bool { + return workers[i][0] < workers[j][0] + }) + + pq := make(PQ, 0, size) + qSum := 0. + for i := 0; i < K; i++ { + q := workers[i][1] + pq = append(pq, q) + qSum += q + } + + maxRatio := workers[K-1][0] + + cost := qSum * maxRatio + + heap.Init(&pq) + + for i := K; i < size; i++ { + maxRatio, q := workers[i][0], workers[i][1] + if q >= pq[0] { + /* q >= pq[0] 时,qSum 不变,maxRatio 变大,qSum*maxRatio 不会是新低 */ + continue + } + heap.Push(&pq, q) + qSum += q + qSum -= heap.Pop(&pq).(float64) + /* qSum 总是 workers[:i+1] 中 K 个最小的 q 之和 */ + cost = min(cost, qSum*maxRatio) + } + + return cost +} + +// PQ implements heap.Interface +type PQ []float64 + +func (pq PQ) Len() int { return len(pq) } + +func (pq PQ) Less(i, j int) bool { + return pq[i] > pq[j] +} + +func (pq PQ) Swap(i, j int) { + pq[i], pq[j] = pq[j], pq[i] +} + +// Push 往 pq 中放 x +func (pq *PQ) Push(x interface{}) { + temp := x.(float64) + *pq = append(*pq, temp) +} + +// Pop 从 pq 中取出最优先的 x +func (pq *PQ) Pop() interface{} { + temp := (*pq)[len(*pq)-1] + *pq = (*pq)[0 : len(*pq)-1] + return temp +} + +func min(a, b float64) float64 { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0857.minimum-cost-to-hire-k-workers/minimum-cost-to-hire-k-workers_test.go b/Algorithms/0857.minimum-cost-to-hire-k-workers/minimum-cost-to-hire-k-workers_test.go new file mode 100755 index 000000000..432bd9720 --- /dev/null +++ b/Algorithms/0857.minimum-cost-to-hire-k-workers/minimum-cost-to-hire-k-workers_test.go @@ -0,0 +1,72 @@ +package problem0857 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + quality []int + wage []int + K int + ans float64 +}{ + + { + []int{3000, 1, 20, 200, 1}, + []int{30000, 8, 5, 50, 7}, + 3, + 176, + }, + + { + []int{3000, 1, 20, 200, 1}, + []int{4000, 8, 5, 50, 7}, + 3, + 176, + }, + + { + []int{3000, 1, 10, 10, 1}, + []int{4000, 8, 2, 2, 7}, + 3, + 96, + }, + + { + []int{10, 20, 5}, + []int{70, 50, 30}, + 2, + 105.00000, + }, + + { + []int{3, 1, 10, 10, 1}, + []int{4, 8, 2, 2, 7}, + 3, + 30.66667, + }, + + // 可以有多个 testcase +} + +func Test_mincostToHireWorkers(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + res := mincostToHireWorkers(tc.quality, tc.wage, tc.K) + ast.InDelta(tc.ans, res, 0.00001, "输入:%v", tc) + } +} + +func Benchmark_mincostToHireWorkers(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + mincostToHireWorkers(tc.quality, tc.wage, tc.K) + } + } +} diff --git a/Algorithms/0858.mirror-reflection/README.md b/Algorithms/0858.mirror-reflection/README.md new file mode 100755 index 000000000..95d537de6 --- /dev/null +++ b/Algorithms/0858.mirror-reflection/README.md @@ -0,0 +1,28 @@ +# [858. Mirror Reflection](https://leetcode.com/problems/mirror-reflection/) + +## 题目 + +There isa special square room with mirrors on each of the fourwalls. Except for the southwestcorner, there are receptors on each of the remaining corners, numbered 0, 1, and 2. + +The square room has walls of length p, and a laser ray from the southwest cornerfirst meets the east wall at a distance qfrom the 0th receptor. + +Return the number of the receptor that the ray meets first. (It is guaranteed that the ray will meeta receptor eventually.) + +Example 1: + +```text +Input: p = 2, q = 1 +Output: 2 +Explanation: The ray meets receptor 2 the first time it gets reflected back to the left wall. +``` + +![reflection picture](reflection.png) + +Note: + +1. 1 <= p <= 1000 +1. 0 <= q <= p + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0858.mirror-reflection/mirror-reflection.go b/Algorithms/0858.mirror-reflection/mirror-reflection.go new file mode 100755 index 000000000..f2c1311a0 --- /dev/null +++ b/Algorithms/0858.mirror-reflection/mirror-reflection.go @@ -0,0 +1,27 @@ +package problem0858 + +// 在坐标系中,画上间距为 p 的网格 +// 按照题目中的镜像关系标注网格中的点为 0,1,2 +// 可以总结出以下规律 +func mirrorReflection(p int, q int) int { + l := lcm(p, q) + if (l/q)%2 == 0 { + return 2 + } + return (l / p) % 2 +} + +// p 和 q 的最小公倍数 +// p >= q +func lcm(p, q int) int { + return p * q / gcd(p, q) +} + +// p 和 q 的最大公约数 +// p >= q +func gcd(p, q int) int { + for q != 0 { + p, q = q, p%q + } + return p +} diff --git a/Algorithms/0858.mirror-reflection/mirror-reflection_test.go b/Algorithms/0858.mirror-reflection/mirror-reflection_test.go new file mode 100755 index 000000000..f45071a67 --- /dev/null +++ b/Algorithms/0858.mirror-reflection/mirror-reflection_test.go @@ -0,0 +1,47 @@ +package problem0858 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + p int + q int + ans int +}{ + + { + 2, + 2, + 1, + }, + + { + 2, + 1, + 2, + }, + + // 可以有多个 testcase +} + +func Test_mirrorReflection(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, mirrorReflection(tc.p, tc.q), "输入:%v", tc) + } +} + +func Benchmark_mirrorReflection(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + mirrorReflection(tc.p, tc.q) + } + } +} diff --git a/Algorithms/0858.mirror-reflection/reflection.png b/Algorithms/0858.mirror-reflection/reflection.png new file mode 100644 index 000000000..0b15f47aa Binary files /dev/null and b/Algorithms/0858.mirror-reflection/reflection.png differ diff --git a/Algorithms/0859.buddy-strings/README.md b/Algorithms/0859.buddy-strings/README.md new file mode 100755 index 000000000..ffcea1676 --- /dev/null +++ b/Algorithms/0859.buddy-strings/README.md @@ -0,0 +1,50 @@ +# [859. Buddy Strings](https://leetcode.com/problems/buddy-strings/) + +## 题目 + +Given two strings A and Bof lowercase letters, return true if and only if wecan swap two letters in A so that the result equals B. + +Example 1: + +```text +Input: A = "ab", B = "ba" +Output: true +``` + +Example 2: + +```text +Input: A = "ab", B = "ab" +Output: false +``` + +Example 3: + +```text +Input: A = "aa", B = "aa" +Output: true +``` + +Example 4: + +```text +Input: A = "aaaaaaabc", B = "aaaaaaacb" +Output: true +``` + +Example 5: + +```text +Input: A = "", B = "aa" +Output: false +``` + +Note: + +1. 0 <= A.length <= 20000 +1. 0 <= B.length <= 20000 +1. A andB consist only of lowercase letters. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0859.buddy-strings/buddy-strings.go b/Algorithms/0859.buddy-strings/buddy-strings.go new file mode 100755 index 000000000..fbd8c729f --- /dev/null +++ b/Algorithms/0859.buddy-strings/buddy-strings.go @@ -0,0 +1,38 @@ +package problem0859 + +func buddyStrings(A, B string) bool { + if len(A) != len(B) { + return false + } + + if A == B { + return hasDouble(A) + } + + size := len(A) + i := 0 + countDown := 2 + ca, cb := byte(0), byte(0) + for countDown > 0 && i < size { + if A[i] != B[i] { + ca += A[i] + cb += B[i] + countDown-- + } + i++ + } + + return ca == cb && A[i:] == B[i:] +} + +func hasDouble(s string) bool { + seen := [26]bool{} + for i := range s { + b := s[i] - 'a' + if seen[b] { + return true + } + seen[b] = true + } + return false +} diff --git a/Algorithms/0859.buddy-strings/buddy-strings_test.go b/Algorithms/0859.buddy-strings/buddy-strings_test.go new file mode 100755 index 000000000..65cdabafe --- /dev/null +++ b/Algorithms/0859.buddy-strings/buddy-strings_test.go @@ -0,0 +1,65 @@ +package problem0859 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A string + B string + ans bool +}{ + + { + "ab", + "ba", + true, + }, + + { + "ab", + "ab", + false, + }, + + { + "aa", + "aa", + true, + }, + + { + "aaaaaaabc", + "aaaaaaacb", + true, + }, + + { + "", + "aa", + false, + }, + + // 可以有多个 testcase +} + +func Test_buddyStrings(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, buddyStrings(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_buddyStrings(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + buddyStrings(tc.A, tc.B) + } + } +} diff --git a/Algorithms/0860.lemonade-change/README.md b/Algorithms/0860.lemonade-change/README.md new file mode 100755 index 000000000..566c85e0c --- /dev/null +++ b/Algorithms/0860.lemonade-change/README.md @@ -0,0 +1,60 @@ +# [860. Lemonade Change](https://leetcode.com/problems/lemonade-change/) + +## 题目 + +At a lemonade stand, each lemonade costs $5. + +Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bills). + +Each customer will only buy one lemonade andpay with either a $5, $10, or $20 bill. You must provide the correct change to each customer, so that the net transaction is that the customer pays $5. + +Note that you don't have any changein hand at first. + +Return trueif and only if you can provide every customer with correct change. + +Example 1: + +```text +Input: [5,5,5,10,20] +Output: true +Explanation: +From the first 3 customers, we collect three $5 bills in order. +From the fourth customer, we collect a $10 bill and give back a $5. +From the fifth customer, we give a $10 bill and a $5 bill. +Since all customers got correct change, we output true. +``` + +Example 2: + +```text +Input: [5,5,10] +Output: true +``` + +Example 3: + +```text +Input: [10,10] +Output: false +``` + +Example 4: + +```text +Input: [5,5,10,10,20] +Output: false +Explanation: +From the first two customers in order, we collect two $5 bills. +For the next two customers in order, we collect a $10 bill and give back a $5 bill. +For the last customer, we can't give change of $15 back because we only have two $10 bills. +Since not every customer received correct change, the answer is false. +``` + +Note: + +1. 0 <= bills.length <= 10000 +1. bills[i]will be either5, 10, or 20. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0860.lemonade-change/lemonade-change.go b/Algorithms/0860.lemonade-change/lemonade-change.go new file mode 100755 index 000000000..f91e3d7cf --- /dev/null +++ b/Algorithms/0860.lemonade-change/lemonade-change.go @@ -0,0 +1,29 @@ +package problem0860 + +func lemonadeChange(bills []int) bool { + fives, tens := 0, 0 + + for _, b := range bills { + switch b { + case 5: + fives++ + case 10: + fives-- + tens++ + case 20: + if tens > 0 { + // 找零的时候,尽量先给 10 元的整钱 + // 而不是两个 5 元 + tens-- + fives-- + } else { + fives -= 3 + } + } + if fives < 0 || tens < 0 { + return false + } + } + + return true +} diff --git a/Algorithms/0860.lemonade-change/lemonade-change_test.go b/Algorithms/0860.lemonade-change/lemonade-change_test.go new file mode 100755 index 000000000..6d4485a4b --- /dev/null +++ b/Algorithms/0860.lemonade-change/lemonade-change_test.go @@ -0,0 +1,59 @@ +package problem0860 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + bills []int + ans bool +}{ + + { + []int{5, 5, 5, 10, 20}, + true, + }, + + { + []int{5, 5, 5, 20, 10, 20}, + false, + }, + + { + []int{5, 5, 10}, + true, + }, + + { + []int{10, 10}, + false, + }, + + { + []int{5, 5, 10, 10, 20}, + false, + }, + + // 可以有多个 testcase +} + +func Test_lemonadeChange(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, lemonadeChange(tc.bills), "输入:%v", tc) + } +} + +func Benchmark_lemonadeChange(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + lemonadeChange(tc.bills) + } + } +} diff --git a/Algorithms/0861.score-after-flipping-matrix/README.md b/Algorithms/0861.score-after-flipping-matrix/README.md new file mode 100755 index 000000000..645761b59 --- /dev/null +++ b/Algorithms/0861.score-after-flipping-matrix/README.md @@ -0,0 +1,31 @@ +# [861. Score After Flipping Matrix](https://leetcode.com/problems/score-after-flipping-matrix/) + +## 题目 + +We have a two dimensional matrixA where each value is 0 or 1. + +A move consists of choosing any row or column, and toggling each value in that row or column: changing all 0s to 1s, and all 1s to 0s. + +After making any number of moves, every row of this matrix is interpreted as a binary number, and the score of the matrix is the sum of these numbers. + +Return the highest possiblescore. + +Example 1: + +```text +Input: [[0,0,1,1],[1,0,1,0],[1,1,0,0]] +Output: 39 +Explanation: +Toggled to [[1,1,1,1],[1,0,0,1],[1,1,1,1]]. +0b1111 + 0b1001 + 0b1111 = 15 + 9 + 15 = 39 +``` + +Note: + +1. 1 <= A.length <= 20 +1. 1 <= A[0].length <= 20 +1. A[i][j]is 0 or 1. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0861.score-after-flipping-matrix/score-after-flipping-matrix.go b/Algorithms/0861.score-after-flipping-matrix/score-after-flipping-matrix.go new file mode 100755 index 000000000..712cc3eb4 --- /dev/null +++ b/Algorithms/0861.score-after-flipping-matrix/score-after-flipping-matrix.go @@ -0,0 +1,41 @@ +package problem0861 + +func matrixScore(A [][]int) int { + m, n := len(A), len(A[0]) + + toggleRow := func(i int) { + for j := 0; j < n; j++ { + A[i][j] ^= 1 + } + } + + countCol := func(j int) int { + c := 0 + for i := 0; i < m; i++ { + c += A[i][j] + } + return c + } + + // 1. 保证每行的最高位是 1 + for i := 0; i < m; i++ { + if A[i][0] == 0 { + toggleRow(i) + } + } + + res := m // 因为 m 行的开头都是 1 + + // 2. 从第 1 列开始统计每列中 1 的个数 + // 当 1 的个数不足 m 的一半时,需要翻转此列 + // 翻转后的 1 的个数为 m-c + for j := 1; j < n; j++ { + c := countCol(j) + if 2*c < m { + c = m - c + } + res = res*2 + c + } + + return res +} diff --git a/Algorithms/0861.score-after-flipping-matrix/score-after-flipping-matrix_test.go b/Algorithms/0861.score-after-flipping-matrix/score-after-flipping-matrix_test.go new file mode 100755 index 000000000..28aa44f42 --- /dev/null +++ b/Algorithms/0861.score-after-flipping-matrix/score-after-flipping-matrix_test.go @@ -0,0 +1,44 @@ +package problem0861 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A [][]int + ans int +}{ + + { + [][]int{{0, 0, 1, 1}, {1, 0, 1, 0}, {1, 1, 0, 0}}, + 39, + }, + + { + [][]int{{1, 1}, {1, 1}, {0, 1}}, + 8, + }, + + // 可以有多个 testcase +} + +func Test_matrixScore(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, matrixScore(tc.A), "输入:%v", tc) + } +} + +func Benchmark_matrixScore(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + matrixScore(tc.A) + } + } +} diff --git a/Algorithms/0862.shortest-subarray-with-sum-at-least-k/README.md b/Algorithms/0862.shortest-subarray-with-sum-at-least-k/README.md new file mode 100755 index 000000000..00d1463e7 --- /dev/null +++ b/Algorithms/0862.shortest-subarray-with-sum-at-least-k/README.md @@ -0,0 +1,38 @@ +# [862. Shortest Subarray with Sum at Least K](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/) + +## 题目 + +Return the length of the shortest, non-empty, contiguoussubarray of A with sum at least K. + +If there is no non-empty subarray with sum at least K, return -1. + +Example 1: + +```text +Input: A = [1], K = 1 +Output: 1 +``` + +Example 2: + +```text +Input: A = [1,2], K = 4 +Output: -1 +``` + +Example 3: + +```text +Input: A = [2,-1,2], K = 3 +Output: 3 +``` + +Note: + +1. 1 <= A.length <= 50000 +1. -10 ^ 5<= A[i] <= 10 ^ 5 +1. 1 <= K <= 10 ^ 9 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0862.shortest-subarray-with-sum-at-least-k/shortest-subarray-with-sum-at-least-k.go b/Algorithms/0862.shortest-subarray-with-sum-at-least-k/shortest-subarray-with-sum-at-least-k.go new file mode 100755 index 000000000..e5bb98913 --- /dev/null +++ b/Algorithms/0862.shortest-subarray-with-sum-at-least-k/shortest-subarray-with-sum-at-least-k.go @@ -0,0 +1,55 @@ +package problem0862 + +func shortestSubarray(a []int, K int) int { + size := len(a) + + sums := make([]int, size+1) + s := 0 + for i, n := range a { + if n == K { + return 1 + } + s += n + sums[i+1] = s + } + + initialValue := size * 2 + res := initialValue + + deque := make([]int, size+1) + deque[0] = 0 + first, last := 0, 0 + // deque[first:last+1] 中保存了以后会用到的 sums 中元素的索引号 + + for i := 1; i <= size; i++ { + for first <= last && sums[i]-sums[deque[first]] >= K { + // 由于 i 递增 + // 即使以后会有 j>i 使得 sums[j] - sums[deque[first]] >= K + // 但是由于 j>i, 导致 j-deque[first] > i-deque[first] 不会是更短的答案。 + // 所以,可以把 deque[first] 删除 + res = min(res, i-deque[first]) + first++ + } + for first <= last && sums[i] <= sums[deque[last]] { + // 如果存在 j>i>deque[last] 使得 sums[j] - sums[deque[last]] >= K + // 由于 sums[deque[last]] >= sums[i] 则 + // sums[j] - sums[i] >= K 一定成立,并且 j-i < j-deque[last] + // 所以,没有必要把 deque[last] 放入队列中 + last-- + } + last++ + deque[last] = i + } + + if res == initialValue { + return -1 + } + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0862.shortest-subarray-with-sum-at-least-k/shortest-subarray-with-sum-at-least-k_test.go b/Algorithms/0862.shortest-subarray-with-sum-at-least-k/shortest-subarray-with-sum-at-least-k_test.go new file mode 100755 index 000000000..1e2ea43b8 --- /dev/null +++ b/Algorithms/0862.shortest-subarray-with-sum-at-least-k/shortest-subarray-with-sum-at-least-k_test.go @@ -0,0 +1,59 @@ +package problem0862 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans int +}{ + + { + []int{48, 99, 37, 4, -31}, + 140, + 2, + }, + + { + []int{1}, + 1, + 1, + }, + + { + []int{1, 2}, + 4, + -1, + }, + + { + []int{2, -1, 2}, + 3, + 3, + }, + + // 可以有多个 testcase +} + +func Test_shortestSubarray(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, shortestSubarray(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_shortestSubarray(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shortestSubarray(tc.A, tc.K) + } + } +} diff --git a/Algorithms/0863.all-nodes-distance-k-in-binary-tree/README.md b/Algorithms/0863.all-nodes-distance-k-in-binary-tree/README.md new file mode 100755 index 000000000..948a65837 --- /dev/null +++ b/Algorithms/0863.all-nodes-distance-k-in-binary-tree/README.md @@ -0,0 +1,35 @@ +# [863. All Nodes Distance K in Binary Tree](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/) + +## 题目 + +We are given a binary tree (with root noderoot), a target node, and an integer value K. + +Return a list of the values of allnodes that have a distance K from the target node. The answer can be returned in any order. + +Example 1: + +```text +Input: root = [3,5,1,6,2,0,8,null,null,7,4], target = 5, K = 2 + +Output: [7,4,1] + +Explanation: +The nodes that are a distance 2 from the target node (with value 5) +have values 7, 4, and 1. + +Note that the inputs "root" and "target" are actually TreeNodes. +The descriptions of the inputs above are just serializations of these objects. +``` + +![pic](pic.png) + +Note: + +1. The given tree is non-empty. +1. Each node in the tree has unique values0 <= node.val <= 500. +1. The targetnode is a node in the tree. +1. 0 <= K <= 1000. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0863.all-nodes-distance-k-in-binary-tree/all-nodes-distance-k-in-binary-tree.go b/Algorithms/0863.all-nodes-distance-k-in-binary-tree/all-nodes-distance-k-in-binary-tree.go new file mode 100755 index 000000000..eca46a3fe --- /dev/null +++ b/Algorithms/0863.all-nodes-distance-k-in-binary-tree/all-nodes-distance-k-in-binary-tree.go @@ -0,0 +1,69 @@ +package problem0863 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +/*TreeNode 是题目预定义的类型 + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +type TreeNode = kit.TreeNode + +func distanceK(root *TreeNode, target *TreeNode, k int) []int { + res := make([]int, 0, 2048) + search(root, target, k, &res) + return res +} + +// check 检查 root 到 target 的 dist 是否已经是 k 了 +func check(root *TreeNode, dist, k int, res *[]int) { + if root == nil || dist > k { + return + } + + if dist == k { + *res = append(*res, root.Val) + return + } + + check(root.Left, dist+1, k, res) + check(root.Right, dist+1, k, res) +} + +// search 返回从 root 到 target 的距离 +// 返回值 -1 表示 target 不在 root 及其子节点中 +func search(root, target *TreeNode, k int, res *[]int) (dist int) { + if root == nil { + return -1 + } + + if root == target { + check(root, 0, k, res) + return 0 + } + + isIn := func(child, theOther *TreeNode) bool { + childDist := search(child, target, k, res) + if childDist > -1 { + dist = childDist + 1 + if dist == k { + *res = append(*res, root.Val) + } else if dist < k { + check(theOther, dist+1, k, res) + } + return true + } + return false + } + + if !isIn(root.Left, root.Right) && !isIn(root.Right, root.Left) { + return -1 + } + + return dist +} diff --git a/Algorithms/0863.all-nodes-distance-k-in-binary-tree/all-nodes-distance-k-in-binary-tree_test.go b/Algorithms/0863.all-nodes-distance-k-in-binary-tree/all-nodes-distance-k-in-binary-tree_test.go new file mode 100755 index 000000000..dda883f26 --- /dev/null +++ b/Algorithms/0863.all-nodes-distance-k-in-binary-tree/all-nodes-distance-k-in-binary-tree_test.go @@ -0,0 +1,98 @@ +package problem0863 + +import ( + "fmt" + "sort" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + target int + K int + ans []int +}{ + + { + []int{0, kit.NULL, 1, 2, 5, kit.NULL, 3, kit.NULL, kit.NULL, kit.NULL, 4}, + 2, + 2, + []int{4, 5, 0}, + }, + + { + []int{3, 5, 1, 6, 2, 0, 8, kit.NULL, kit.NULL, 7, 4}, + 4, + 2, + []int{5, 7}, + }, + + { + []int{3, 5, 1, 6, 2, 0, 8, kit.NULL, kit.NULL, 7, 4}, + 5, + 1, + []int{2, 3, 6}, + }, + + { + []int{0, kit.NULL, 1, kit.NULL, 2, kit.NULL, 3}, + 1, + 2, + []int{3}, + }, + + { + []int{3, 5, 1, 6, 2, 0, 8, kit.NULL, kit.NULL, 7, 4}, + 5, + 0, + []int{5}, + }, + + { + []int{3, 5, 1, 6, 2, 0, 8, kit.NULL, kit.NULL, 7, 4}, + 5, + 2, + []int{7, 4, 1}, + }, + + { + []int{3}, + 3, + 0, + []int{3}, + }, + + // 可以有多个 testcase +} + +func Test_distanceK(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + + root := kit.Ints2TreeNode(tc.root) + target := kit.GetTargetNode(root, tc.target) + ans := distanceK(root, target, tc.K) + sort.Ints(ans) + sort.Ints(tc.ans) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_distanceK(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + + root := kit.Ints2TreeNode(tc.root) + target := kit.GetTargetNode(root, tc.target) + + distanceK(root, target, tc.K) + } + } +} diff --git a/Algorithms/0863.all-nodes-distance-k-in-binary-tree/pic.png b/Algorithms/0863.all-nodes-distance-k-in-binary-tree/pic.png new file mode 100644 index 000000000..b516fb3d9 Binary files /dev/null and b/Algorithms/0863.all-nodes-distance-k-in-binary-tree/pic.png differ diff --git a/Algorithms/0864.shortest-path-to-get-all-keys/README.md b/Algorithms/0864.shortest-path-to-get-all-keys/README.md new file mode 100755 index 000000000..dd8cfcf06 --- /dev/null +++ b/Algorithms/0864.shortest-path-to-get-all-keys/README.md @@ -0,0 +1,36 @@ +# [864. Shortest Path to Get All Keys](https://leetcode.com/problems/shortest-path-to-get-all-keys/) + +## 题目 + +We are given a 2-dimensionalgrid."." is an empty cell, "#" isa wall, "@" is the starting point, ("a", "b", ...) are keys, and ("A","B", ...) are locks. + +We start at the starting point, and one move consists of walking one space in one of the 4 cardinal directions. We cannot walk outside the grid, or walk into a wall. If we walk over a key, we pick it up. We can't walk over a lock unless we have the corresponding key. + +For some 1 <= K <= 6, there is exactly one lowercase and one uppercase letter of the first K letters of the English alphabet in the grid. This means that there is exactly one key for each lock, and one lock for each key; and also that the letters used to represent the keys and locks werechosen in the same order as the English alphabet. + +Return the lowest number of moves to acquire all keys. Ifit's impossible, return -1. + +Example 1: + +```text +Input: ["@.a.#","###.#","b.A.B"] +Output: 8 +``` + +Example 2: + +```text +Input: ["@..aA","..B#.","....b"] +Output: 6 +``` + +Note: + +1. 1 <= grid.length<= 30 +1. 1 <= grid[0].length<= 30 +1. grid[i][j] contains only '.', '#', '@','a'-'f' and 'A'-'F' +1. The number of keys is in [1, 6]. Each key has a different letter and opens exactly one lock. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0864.shortest-path-to-get-all-keys/shortest-path-to-get-all-keys.go b/Algorithms/0864.shortest-path-to-get-all-keys/shortest-path-to-get-all-keys.go new file mode 100755 index 000000000..5b555f1ed --- /dev/null +++ b/Algorithms/0864.shortest-path-to-get-all-keys/shortest-path-to-get-all-keys.go @@ -0,0 +1,96 @@ +package problem0864 + +var dx = [4]int{1, -1, 0, 0} +var dy = [4]int{0, 0, 1, -1} + +func shortestPathAllKeys(grid []string) int { + m, n := len(grid), len(grid[0]) + + /** 按照题目给出的条件,在 30*30 的矩阵中,最多 6 把 key, + * 使用 6 bit 的整数,就可以记录全部 2^6 = 64 种拥有钥匙的状态 + * 所以,30×30×64 的数组,就可以记录所有的状态。 */ + + hasSeen := [30][30][64]bool{} + queue := make([]int, 1, m*n*4) + allKeys := 0 + + // 获取起点位置,和所有 key 的信息 + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + b := grid[i][j] + if b >= 'a' { + allKeys |= 1 << uint(b-'a') + } else if b == '@' { + hasSeen[i][j][0] = true + queue[0] = encode(i, j, 0) + } + } + } + + steps := 1 + + /**bfs */ + for len(queue) > 0 { + size := len(queue) + + for i := 0; i < size; i++ { + x, y, keys := decode(queue[i]) + + for j := 0; j < 4; j++ { + nx, ny := x+dx[j], y+dy[j] + + inRange := 0 <= nx && nx < m && 0 <= ny && ny < n + if !inRange { + continue + } + + b := grid[nx][ny] + if b == '#' || // 遇见墙了,或者,没有钥匙开锁 + 'A' <= b && b <= 'F' && keys&(1<= 'a' { + nkeys |= 1 << uint(b-'a') // 带上这个钥匙 + if nkeys == allKeys { + return steps + } + } + + if hasSeen[nx][ny][nkeys] { + continue + } + + hasSeen[nx][ny][nkeys] = true + queue = append(queue, encode(nx, ny, nkeys)) + } + } + + queue = queue[size:] + steps++ + } + + return -1 +} + +const ( + xBits = 16 + yBits = 8 + mask = 0xFF +) + +/**由于 x, y, keys 的范围都很小 + * 可以用同一个 int 数字的不同的 bit 位段,来分别记录他们的值 + * 具体的记录方式,参考下方的 encode 和 decode 函数 */ + +func encode(x, y, keys int) int { + return x<> xBits + y = state >> yBits & mask + keys = state & mask + return +} diff --git a/Algorithms/0864.shortest-path-to-get-all-keys/shortest-path-to-get-all-keys_test.go b/Algorithms/0864.shortest-path-to-get-all-keys/shortest-path-to-get-all-keys_test.go new file mode 100755 index 000000000..f3cd1e97b --- /dev/null +++ b/Algorithms/0864.shortest-path-to-get-all-keys/shortest-path-to-get-all-keys_test.go @@ -0,0 +1,74 @@ +package problem0864 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid []string + ans int +}{ + + { + []string{"@...a", ".###A", "b.BCc"}, + 10, + }, + + { + []string{"@abcdeABCDEFf"}, + -1, + }, + + { + []string{"@..aA", "..B#.", "....b"}, + 6, + }, + + { + []string{"@.a.#", "###.#", "b.A.B"}, + 8, + }, + + { + []string{"@.....", ".####.", "....#.", ".##.#.", "BC#A#.", ".c#b#a"}, + 38, + }, + + { + []string{"@.....", ".####.", "....#.", ".##.#.", "BA#C#.", ".a#b#c"}, + 38, + }, + + { + []string{"@.....", ".####.", "....#.", ".##.#.", "BA#A#.", ".a#b#a"}, + 28, + }, + + { + []string{"@.....", ".####.", "....#.", ".##.#.", "CB#A#.", ".c#b#a"}, + -1, + }, + + // 可以有多个 testcase +} + +func Test_shortestPathAllKeys(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, shortestPathAllKeys(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_shortestPathAllKeys(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shortestPathAllKeys(tc.grid) + } + } +} diff --git a/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/README.md b/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/README.md new file mode 100755 index 000000000..ee765b115 --- /dev/null +++ b/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/README.md @@ -0,0 +1,36 @@ +# [865. Smallest Subtree with all the Deepest Nodes](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/) + +## 题目 + +Given a binary tree rooted at root, the depth of each node is the shortest distance to the root. + +A node is deepest if it has the largest depth possible amongany node in the entire tree. + +The subtree of a node is that node, plus the set of all descendants of that node. + +Return the node with the largest depth such that it contains all the deepest nodes in its subtree. + +Example 1: + +```text +Input: [3,5,1,6,2,0,8,null,null,7,4] +Output: [2,7,4] +Explanation: + +We return the node with value 2, colored in yellow in the diagram. +The nodes colored in blue are the deepest nodes of the tree. +The input "[3, 5, 1, 6, 2, 0, 8, null, null, 7, 4]" is a serialization of the given tree. +The output "[2, 7, 4]" is a serialization of the subtree rooted at the node with value 2. +Both the input and output have TreeNode type. +``` + +![pic](pic.png) + +Note: + +1. The number of nodes in the tree will be between 1 and 500. +1. The values of each node are unique. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/pic.png b/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/pic.png new file mode 100644 index 000000000..7d1a945b8 Binary files /dev/null and b/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/pic.png differ diff --git a/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/smallest-subtree-with-all-the-deepest-nodes.go b/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/smallest-subtree-with-all-the-deepest-nodes.go new file mode 100755 index 000000000..9a4d25167 --- /dev/null +++ b/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/smallest-subtree-with-all-the-deepest-nodes.go @@ -0,0 +1,41 @@ +package problem0865 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode 是预定义的数据结构 +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +type TreeNode = kit.TreeNode + +func subtreeWithAllDeepest(root *TreeNode) *TreeNode { + res, _ := walk(root) + return res +} + +// walk 就是 subtreeWithAllDeepest +// 只是多返回树的深度结果 +func walk(root *TreeNode) (*TreeNode, int) { + if root == nil { + return nil, 0 + } + + lst, l := walk(root.Left) + rst, r := walk(root.Right) + + switch { + case l > r: + return lst, l + 1 + case l < r: + return rst, r + 1 + default: + return root, r + 1 + } +} diff --git a/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/smallest-subtree-with-all-the-deepest-nodes_test.go b/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/smallest-subtree-with-all-the-deepest-nodes_test.go new file mode 100755 index 000000000..16d8565a0 --- /dev/null +++ b/Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes/smallest-subtree-with-all-the-deepest-nodes_test.go @@ -0,0 +1,50 @@ +package problem0865 + +import ( + "fmt" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans []int +}{ + + { + []int{3, 5, 1, 6, 2, 0, 8, kit.NULL, kit.NULL, 7, 4}, + []int{2, 7, 4}, + }, + + { + []int{3, 5, 1, 6, 2, 0, 8, kit.NULL, kit.NULL, 7, 4, 9, 10}, + []int{3, 5, 1, 6, 2, 0, 8, kit.NULL, kit.NULL, 7, 4, 9, 10}, + }, + + // 可以有多个 testcase +} + +func Test_subtreeWithAllDeepest(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + root := kit.Ints2TreeNode(tc.root) + actual := kit.Tree2Preorder(subtreeWithAllDeepest(root)) + expected := kit.Tree2Preorder(kit.Ints2TreeNode(tc.ans)) + ast.Equal(expected, actual, "输入:%v", tc) + } +} + +func Benchmark_subtreeWithAllDeepest(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + subtreeWithAllDeepest(root) + } + } +} diff --git a/Algorithms/0866.prime-palindrome/README.md b/Algorithms/0866.prime-palindrome/README.md new file mode 100755 index 000000000..353a7003a --- /dev/null +++ b/Algorithms/0866.prime-palindrome/README.md @@ -0,0 +1,43 @@ +# [866. Prime Palindrome](https://leetcode.com/problems/prime-palindrome/) + +## 题目 + +Find the smallest prime palindrome greater than or equal to N. + +Recall that anumber is prime if it's only divisors are 1 and itself, and it is greater than 1. + +For example, 2,3,5,7,11 and 13 areprimes. + +Recall that a number is a palindrome if it reads the same from left to right as it does from right to left. + +For example, 12321 is a palindrome. + +Example 1: + +```text +Input: 6 +Output: 7 +``` + +Example 2: + +```text +Input: 8 +Output: 11 +``` + +Example 3: + +```text +Input: 13 +Output: 101 +``` + +Note: + +1. 1 <= N <= 10^8 +1. The answer is guaranteed to exist and be less than 2 * 10^8. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0866.prime-palindrome/prime-palindrome.go b/Algorithms/0866.prime-palindrome/prime-palindrome.go new file mode 100755 index 000000000..e0bbed81f --- /dev/null +++ b/Algorithms/0866.prime-palindrome/prime-palindrome.go @@ -0,0 +1,82 @@ +package problem0866 + +import ( + "math" + "strconv" +) + +var special = []int{2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11} + +func primePalindrome(N int) int { + if N <= 11 { + return special[N] + } + + /** 由于 11 是偶数长度的 palindrome 的因子 + * 所以答案一定是奇数长度的 + * 假设答案的形式如 lmr (Left + Middle + Right) */ + lm := genLM(N) + + for { + p := genPalindrome(lm) + if p >= N && isPrime(p) { + /** 需要验证 p >= N,是因为 + * 刚开始的 p 可能会比 N 小, + * 例如,N = 98390 时,第一个 p 是 98389 */ + return p + } + lm++ + } +} + +// 根据 N 生成 palindrome 的 left + middle 部分 +func genLM(N int) int { + size := len(strconv.Itoa(N)) + base := int(math.Pow10(size / 2)) + + /** lm 是 N 的左边和中间部分 */ + lm := N / base + + if size&1 == 0 { + /** 如果 N 的长度是偶数, 把 base 当做 lm + * 直接从 10^size+1 开始检查*/ + lm = base + } + + return lm +} + +// 利用 left 和 middle 生成一个奇数位长度的 palindrome +func genPalindrome(lm int) int { + res := lm + /**把 l 按照相反的顺序放到 lm 的右边,就形成了奇数位的 palindrome */ + for l := lm / 10; l > 0; l /= 10 { + res = res*10 + l%10 + } + return res +} + +// https://blog.csdn.net/willduan1/article/details/50975381 +func isPrime(n int) bool { + if n <= 3 { + return n > 1 + } + if n%2 == 0 || n%3 == 0 { + return false + } + k := int(math.Sqrt(float64(n))) + 1 + for i := 5; i < k; i += 6 { + if n%i == 0 || n%(i+2) == 0 { + return false + } + } + return true +} + +/** + * 此题要点: + * 1. 利用数学知识简化需要处理的情况 + * 形如 abccba 等长度为偶数的回文数,都不是素数,因为有因子 11 + * 2. 把 res <= 101 这样的与后面处理方式不兼容的少数情况,单独处理。 + * 3. 没有把寻找 n 作为单独的函数,简化了判断条件。 + */ diff --git a/Algorithms/0866.prime-palindrome/prime-palindrome_test.go b/Algorithms/0866.prime-palindrome/prime-palindrome_test.go new file mode 100755 index 000000000..798d1c76b --- /dev/null +++ b/Algorithms/0866.prime-palindrome/prime-palindrome_test.go @@ -0,0 +1,123 @@ +package problem0866 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans int +}{ + + { + 1000000000, + 10000500001, + }, + + { + 11, + 11, + }, + + { + 8, + 11, + }, + + { + 98390, + 98689, + }, + + { + 983910, + 1003001, + }, + + { + 930, + 10301, + }, + + { + 192, + 313, + }, + + { + 102, + 131, + }, + + { + 12, + 101, + }, + + { + 13, + 101, + }, + + { + 9999, + 10301, + }, + + { + 6, + 7, + }, + + { + 2, + 2, + }, + + { + 3, + 3, + }, + + { + 5, + 5, + }, + + { + 7, + 7, + }, + + // 可以有多个 testcase +} + +func Test_primePalindrome(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, primePalindrome(tc.N), "输入:%v", tc) + } +} + +func Benchmark_primePalindrome(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + primePalindrome(tc.N) + } + } +} + +func Test_isPrime(t *testing.T) { + ast := assert.New(t) + + actual := isPrime(3) + expected := true + ast.Equal(expected, actual) + +} diff --git a/Algorithms/0867.transpose-matrix/README.md b/Algorithms/0867.transpose-matrix/README.md new file mode 100755 index 000000000..3155379cb --- /dev/null +++ b/Algorithms/0867.transpose-matrix/README.md @@ -0,0 +1,30 @@ +# [867. Transpose Matrix](https://leetcode.com/problems/transpose-matrix/) + +## 题目 + +Given amatrix A, return the transpose of A. + +The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. + +Example 1: + +```text +Input: [[1,2,3],[4,5,6],[7,8,9]] +Output: [[1,4,7],[2,5,8],[3,6,9]] +``` + +Example 2: + +```text +Input: [[1,2,3],[4,5,6]] +Output: [[1,4],[2,5],[3,6]] +``` + +Note: + +1. 1 <= A.length<= 1000 +1. 1 <= A[0].length<= 1000 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0867.transpose-matrix/transpose-matrix.go b/Algorithms/0867.transpose-matrix/transpose-matrix.go new file mode 100755 index 000000000..9a5a37191 --- /dev/null +++ b/Algorithms/0867.transpose-matrix/transpose-matrix.go @@ -0,0 +1,18 @@ +package problem0867 + +func transpose(A [][]int) [][]int { + m, n := len(A), len(A[0]) + + res := make([][]int, n) + for i := 0; i < n; i++ { + res[i] = make([]int, m) + } + + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + res[j][i] = A[i][j] + } + } + + return res +} diff --git a/Algorithms/0867.transpose-matrix/transpose-matrix_test.go b/Algorithms/0867.transpose-matrix/transpose-matrix_test.go new file mode 100755 index 000000000..ff08d328e --- /dev/null +++ b/Algorithms/0867.transpose-matrix/transpose-matrix_test.go @@ -0,0 +1,44 @@ +package problem0867 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A [][]int + ans [][]int +}{ + + { + [][]int{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, + [][]int{{1, 4, 7}, {2, 5, 8}, {3, 6, 9}}, + }, + + { + [][]int{{1, 2, 3}, {4, 5, 6}}, + [][]int{{1, 4}, {2, 5}, {3, 6}}, + }, + + // 可以有多个 testcase +} + +func Test_transpose(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, transpose(tc.A), "输入:%v", tc) + } +} + +func Benchmark_transpose(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + transpose(tc.A) + } + } +} diff --git a/Algorithms/0868.binary-gap/README.md b/Algorithms/0868.binary-gap/README.md new file mode 100755 index 000000000..8a5efbe04 --- /dev/null +++ b/Algorithms/0868.binary-gap/README.md @@ -0,0 +1,56 @@ +# [868. Binary Gap](https://leetcode.com/problems/binary-gap/) + +## 题目 + +Given a positiveinteger N, find and return the longest distance between two consecutive 1's in the binary representation of N. + +If there aren't two consecutive 1's, return 0. + +Example 1: + +```text +Input: 22 +Output: 2 +Explanation: +22 in binary is 0b10110. +In the binary representation of 22, there are three ones, and two consecutive pairs of 1's. +The first consecutive pair of 1's have distance 2. +The second consecutive pair of 1's have distance 1. +The answer is the largest of these two distances, which is 2. +``` + +Example 2: + +```text +Input: 5 +Output: 2 +Explanation: +5 in binary is 0b101. +``` + +Example 3: + +```text +Input: 6 +Output: 1 +Explanation: +6 in binary is 0b110. +``` + +Example 4: + +```text +Input: 8 +Output: 0 +Explanation: +8 in binary is 0b1000. +There aren't any consecutive pairs of 1's in the binary representation of 8, so we return 0. +``` + +Note: + +- 1 <= N <= 10^9 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0868.binary-gap/binary-gap.go b/Algorithms/0868.binary-gap/binary-gap.go new file mode 100755 index 000000000..f38c4e980 --- /dev/null +++ b/Algorithms/0868.binary-gap/binary-gap.go @@ -0,0 +1,27 @@ +package problem0868 + +func binaryGap(N int) int { + res := 0 + gap := 0 + + for N > 0 { + if N&1 == 1 { + res = max(res, gap) + gap = 1 + } else if gap > 0 { + // gap > 0 才 gap++ 是想要 + // 在遇到第一个 1 后,每次遇到 0 才 gap++ + gap++ + } + N >>= 1 + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0868.binary-gap/binary-gap_test.go b/Algorithms/0868.binary-gap/binary-gap_test.go new file mode 100755 index 000000000..a68164d67 --- /dev/null +++ b/Algorithms/0868.binary-gap/binary-gap_test.go @@ -0,0 +1,59 @@ +package problem0868 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans int +}{ + + { + 41, + 3, + }, + + { + 22, + 2, + }, + + { + 5, + 2, + }, + + { + 6, + 1, + }, + + { + 8, + 0, + }, + + // 可以有多个 testcase +} + +func Test_binaryGap(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, binaryGap(tc.N), "输入:%v", tc) + } +} + +func Benchmark_binaryGap(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + binaryGap(tc.N) + } + } +} diff --git a/Algorithms/0869.reordered-power-of-2/README.md b/Algorithms/0869.reordered-power-of-2/README.md new file mode 100755 index 000000000..ce1c98f76 --- /dev/null +++ b/Algorithms/0869.reordered-power-of-2/README.md @@ -0,0 +1,50 @@ +# [869. Reordered Power of 2](https://leetcode.com/problems/reordered-power-of-2/) + +## 题目 + +Starting with a positive integer N, we reorder the digits in any order (including the original order) such that the leading digit is not zero. + +Return trueif and only if we can do this in a way such that the resulting number is a power of 2. + +Example 1: + +```text +Input: 1 +Output: true +``` + +Example 2: + +```text +Input: 10 +Output: false +``` + +Example 3: + +```text +Input: 16 +Output: true +``` + +Example 4: + +```text +Input: 24 +Output: false +``` + +Example 5: + +```text +Input: 46 +Output: true +``` + +Note: + +1. 1 <= N <= 10^9 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0869.reordered-power-of-2/reordered-power-of-2.go b/Algorithms/0869.reordered-power-of-2/reordered-power-of-2.go new file mode 100755 index 000000000..daa959e6f --- /dev/null +++ b/Algorithms/0869.reordered-power-of-2/reordered-power-of-2.go @@ -0,0 +1,85 @@ +package problem0869 + +// 对 [1, 1e9] 中所有的 2^n 进行编码 +// 把 key 写成 16 进制, 对应关系更明显 +var isValid = map[int]bool{ + //9876543210 + 0x0000000010: true, // 2^0 = 1 + //9876543210 + 0x0000000100: true, // 2^1 = 2 + //9876543210 + 0x0000010000: true, // 2^2 = 4 + //9876543210 + 0x0100000000: true, // 2^3 = 8 + //9876543210 + 0x0001000010: true, // 2^4 = 16 + //9876543210 + 0x0000001100: true, // 2^5 = 32 + //9876543210 + 0x0001010000: true, // 2^6 = 64 + //9876543210 + 0x0100000110: true, // 2^7 = 128 + //9876543210 + 0x0001100100: true, // 2^8 = 256 + //9876543210 + 0x0000100110: true, // 2^9 = 512 + //9876543210 + 0x0000010111: true, // 2^10 = 1024 + //9876543210 + 0x0100010101: true, // 2^11 = 2048 + //9876543210 + 0x1001010001: true, // 2^12 = 4096 + //9876543210 + 0x1100000110: true, // 2^13 = 8192 + //9876543210 + 0x0101011010: true, // 2^14 = 16384 + //9876543210 + 0x0111001100: true, // 2^15 = 32768 + //9876543210 + 0x0002201000: true, // 2^16 = 65536 + //9876543210 + 0x0010001121: true, // 2^17 = 131072 + //9876543210 + 0x0001020210: true, // 2^18 = 262144 + //9876543210 + 0x0200110200: true, // 2^19 = 524288 + //9876543210 + 0x0111110011: true, // 2^20 = 1048576 + //9876543210 + 0x1010100211: true, // 2^21 = 2097152 + //9876543210 + 0x1000031011: true, // 2^22 = 4194304 + //9876543210 + 0x0401001001: true, // 2^23 = 8388608 + //9876543210 + 0x0032000120: true, // 2^24 = 16777216 + //9876543210 + 0x0000223100: true, // 2^25 = 33554432 + //9876543210 + 0x0212010011: true, // 2^26 = 67108864 + //9876543210 + 0x0120011220: true, // 2^27 = 134217728 + //9876543210 + 0x0102221100: true, // 2^28 = 268435456 + //9876543210 + 0x1111101111: true, // 2^29 = 536870912 +} + +func reorderedPowerOf2(N int) bool { + return isValid[encode(N)] +} + +// 由于 n 的范围是 [1,1e9] +// 每个数字出现的次数不会超过 10 次,可以用 4 bit 的二进制数记录 +// go 的 int 类型是 64 bit,足够记录 10 个数字的出现次数 +// 所以, res 的 [4*digit, 4*digit+4) 位代表的二进制数,表示 digit 在 n 中出现的次数 +func encode(N int) int { + res := 0 + n := uint(N) + for n > 0 { + digit := n % 10 + res += 1 << (4 * digit) + n /= 10 + } + return res +} diff --git a/Algorithms/0869.reordered-power-of-2/reordered-power-of-2_test.go b/Algorithms/0869.reordered-power-of-2/reordered-power-of-2_test.go new file mode 100755 index 000000000..6262ad03a --- /dev/null +++ b/Algorithms/0869.reordered-power-of-2/reordered-power-of-2_test.go @@ -0,0 +1,94 @@ +package problem0869 + +import ( + "fmt" + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans bool +}{ + + { + 160, + false, + }, + + { + 1, + true, + }, + + { + 10, + false, + }, + + { + 16, + true, + }, + + { + 24, + false, + }, + + { + 46, + true, + }, + + // 可以有多个 testcase +} + +func Test_reorderedPowerOf2(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, reorderedPowerOf2(tc.N), "输入:%v", tc) + } +} + +func Benchmark_reorderedPowerOf2(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + reorderedPowerOf2(tc.N) + } + } +} + +var val = 9876543210 + +func Benchmark_encode(b *testing.B) { + for i := 1; i < b.N; i++ { + encode(val) + } +} + +func encodeString(n int) string { + tmp := [10]int{} + for n > 0 { + tmp[n%10]++ + n /= 10 + } + ss := make([]string, 0, 10) + for n, c := range tmp { + if c > 0 { + ss = append(ss, fmt.Sprintf("%d_%d", n, c)) + } + } + return strings.Join(ss, "-") +} + +func Benchmark_encodeString(b *testing.B) { + for i := 1; i < b.N; i++ { + encodeString(val) + } +} diff --git a/Algorithms/0870.advantage-shuffle/README.md b/Algorithms/0870.advantage-shuffle/README.md new file mode 100755 index 000000000..94fbbad55 --- /dev/null +++ b/Algorithms/0870.advantage-shuffle/README.md @@ -0,0 +1,31 @@ +# [870. Advantage Shuffle](https://leetcode.com/problems/advantage-shuffle/) + +## 题目 + +Given two arrays A and B of equal size, the advantage of A with respect to B is the number of indices ifor which A[i] > B[i]. + +Return any permutation of A that maximizes its advantage with respect to B. + +Example 1: + +```text +Input: A = [2,7,11,15], B = [1,10,4,11] +Output: [2,11,7,15] +``` + +Example 2: + +```text +Input: A = [12,24,8,32], B = [13,25,32,11] +Output: [24,32,8,12] +``` + +Note: + +1. 1 <= A.length = B.length <= 10000 +1. 0 <= A[i] <= 10^9 +1. 0 <= B[i] <= 10^9 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0870.advantage-shuffle/advantage-shuffle.go b/Algorithms/0870.advantage-shuffle/advantage-shuffle.go new file mode 100755 index 000000000..ddbee142a --- /dev/null +++ b/Algorithms/0870.advantage-shuffle/advantage-shuffle.go @@ -0,0 +1,35 @@ +package problem0870 + +import ( + "sort" +) + +func advantageCount(A []int, B []int) []int { + size := len(A) + + BI := make([][2]int, size) + for i, n := range B { + BI[i][0], BI[i][1] = n, i + } + + sort.Slice(BI, func(i int, j int) bool { + return BI[i][0] < BI[j][0] + }) + + res := make([]int, size) + + sort.Ints(A) + + l, r := 0, size-1 + for _, a := range A { + if BI[l][0] < a { + res[BI[l][1]] = a + l++ + } else { + res[BI[r][1]] = a + r-- + } + } + + return res +} diff --git a/Algorithms/0870.advantage-shuffle/advantage-shuffle_test.go b/Algorithms/0870.advantage-shuffle/advantage-shuffle_test.go new file mode 100755 index 000000000..f9c89ea99 --- /dev/null +++ b/Algorithms/0870.advantage-shuffle/advantage-shuffle_test.go @@ -0,0 +1,53 @@ +package problem0870 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + B []int + ans []int +}{ + + { + []int{15448, 14234, 13574, 19893, 6475}, + []int{14234, 6475, 19893, 15448, 13574}, + []int{15448, 13574, 6475, 19893, 14234}, + }, + + { + []int{2, 7, 11, 15}, + []int{1, 10, 4, 11}, + []int{2, 11, 7, 15}, + }, + + { + []int{12, 24, 8, 32}, + []int{13, 25, 32, 11}, + []int{24, 32, 8, 12}, + }, + + // 可以有多个 testcase +} + +func Test_advantageCount(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, advantageCount(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_advantageCount(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + advantageCount(tc.A, tc.B) + } + } +} diff --git a/Algorithms/0871.minimum-number-of-refueling-stops/README.md b/Algorithms/0871.minimum-number-of-refueling-stops/README.md new file mode 100755 index 000000000..bd0e24205 --- /dev/null +++ b/Algorithms/0871.minimum-number-of-refueling-stops/README.md @@ -0,0 +1,54 @@ +# [871. Minimum Number of Refueling Stops](https://leetcode.com/problems/minimum-number-of-refueling-stops/) + +## 题目 + +A car travels from a starting position to a destination which is target miles east of the starting position. + +Along the way, there are gas stations. Each station[i]represents a gas station that is station[i][0] miles east of the starting position, and has station[i][1] liters of gas. + +The car starts with an infinite tank of gas, which initially hasstartFuelliters of fuel in it. It uses 1 liter of gas per 1 mile that it drives. + +When the carreaches a gas station, it may stop and refuel, transferring all the gas from the station into the car. + +What is the least number of refueling stops the car must make in order to reach its destination? If it cannot reach the destination, return -1. + +Note that if the car reaches a gas station with 0 fuel left, the car can still refuel there. If the car reaches the destination with 0 fuel left, it is still considered to have arrived. + +Example 1: + +```text +Input: target = 1, startFuel = 1, stations = [] +Output: 0 +Explanation: We can reach the target without refueling. +``` + +Example 2: + +```text +Input: target = 100, startFuel = 1, stations = [[10,100]] +Output: -1 +Explanation: We can't reach the target (or even the first gas station). +``` + +Example 3: + +```text +Input: target = 100, startFuel = 10, stations = [[10,60],[20,30],[30,30],[60,40]] +Output: 2 +Explanation: +We start with 10 liters of fuel. +We drive to position 10, expending 10 liters of fuel. We refuel from 0 liters to 60 liters of gas. +Then, we drive from position 10 to position 60 (expending 50 liters of fuel), +and refuel from 10 liters to 50 liters of gas. We then drive to and reach the target. +We made 2 refueling stops along the way, so we return 2. +``` + +Note: + +1. 1 <= target, startFuel, stations[i][1] <= 10^9 +1. 0 <= stations.length <= 500 +1. 0 < stations[0][0] < stations[1][0] < ... < stations[stations.length-1][0] < target + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0871.minimum-number-of-refueling-stops/minimum-number-of-refueling-stops.go b/Algorithms/0871.minimum-number-of-refueling-stops/minimum-number-of-refueling-stops.go new file mode 100755 index 000000000..9dba393aa --- /dev/null +++ b/Algorithms/0871.minimum-number-of-refueling-stops/minimum-number-of-refueling-stops.go @@ -0,0 +1,72 @@ +package problem0871 + +import "container/heap" + +// 把题目换一种说法,就好理解了。 +// 汽车在开往目的地的过程中, +// 会在沿路的加油站,都买上一箱汽油, +// 每个加油站的汽油大小还不一样。 +// 汽车每次没油的时候,就在买过的汽油中,挑一箱加上。 +// 问,汽车达到目的地的时候,最少需要加几次油? + +func minRefuelStops(target int, startFuel int, stations [][]int) int { + size := len(stations) + gases := make(intHeap, 0, size) + miles := startFuel + stops := 0 + i := 0 + + for { + if miles >= target { + // 到达了目的地 + return stops + } + + // 路过加油站的时候,买汽油 + for i < size && stations[i][0] <= miles { + heap.Push(&gases, stations[i][1]) + i++ + } + + if len(gases) == 0 { + break + } + + maxGas := heap.Pop(&gases).(int) + stops++ + miles += maxGas + + } + + return -1 +} + +// intHeap 实现了 heap 的接口 +type intHeap []int + +func (h intHeap) Len() int { + return len(h) +} + +func (h intHeap) Less(i, j int) bool { + // 返回堆中的最大值 + return h[i] > h[j] +} + +func (h intHeap) Swap(i, j int) { + h[i], h[j] = h[j], h[i] +} + +func (h *intHeap) Push(x interface{}) { + // Push 使用 *h,是因为 + // Push 增加了 h 的长度 + *h = append(*h, x.(int)) +} + +func (h *intHeap) Pop() interface{} { + // Pop 使用 *h ,是因为 + // Pop 减短了 h 的长度 + res := (*h)[len(*h)-1] + *h = (*h)[:len(*h)-1] + return res +} diff --git a/Algorithms/0871.minimum-number-of-refueling-stops/minimum-number-of-refueling-stops_test.go b/Algorithms/0871.minimum-number-of-refueling-stops/minimum-number-of-refueling-stops_test.go new file mode 100755 index 000000000..c33c94925 --- /dev/null +++ b/Algorithms/0871.minimum-number-of-refueling-stops/minimum-number-of-refueling-stops_test.go @@ -0,0 +1,78 @@ +package problem0871 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + target int + startFuel int + stations [][]int + ans int +}{ + + { + 1000, + 36, + [][]int{{7, 13}, {10, 11}, {12, 31}, {22, 14}, {32, 26}, {38, 16}, {50, 8}, {54, 13}, {75, 4}, {85, 2}, {88, 35}, {90, 9}, {96, 35}, {103, 16}, {115, 33}, {121, 6}, {123, 1}, {138, 2}, {139, 34}, {145, 30}, {149, 14}, {160, 21}, {167, 14}, {188, 7}, {196, 27}, {248, 4}, {256, 35}, {262, 16}, {264, 12}, {283, 23}, {297, 15}, {307, 25}, {311, 35}, {316, 6}, {345, 30}, {348, 2}, {354, 21}, {360, 10}, {362, 28}, {363, 29}, {367, 7}, {370, 13}, {402, 6}, {410, 32}, {447, 20}, {453, 13}, {454, 27}, {468, 1}, {470, 8}, {471, 11}, {474, 34}, {486, 13}, {490, 16}, {495, 10}, {527, 9}, {533, 14}, {553, 36}, {554, 23}, {605, 5}, {630, 17}, {635, 30}, {640, 31}, {646, 9}, {647, 12}, {659, 5}, {664, 34}, {667, 35}, {676, 6}, {690, 19}, {709, 10}, {721, 28}, {734, 2}, {742, 6}, {772, 22}, {777, 32}, {778, 36}, {794, 7}, {812, 24}, {813, 33}, {815, 14}, {816, 21}, {824, 17}, {826, 3}, {838, 14}, {840, 8}, {853, 29}, {863, 18}, {867, 1}, {881, 27}, {886, 27}, {894, 26}, {917, 3}, {953, 6}, {956, 3}, {957, 28}, {962, 33}, {967, 35}, {972, 34}, {984, 8}, {987, 12}}, + 32, + }, + + { + 1000, + 299, + [][]int{{14, 123}, {145, 203}, {344, 26}, {357, 68}, {390, 35}, {478, 135}, {685, 108}, {823, 186}, {934, 217}, {959, 80}}, + 5, + }, + + { + 100, + 25, + [][]int{{25, 25}, {50, 25}, {75, 25}}, + 3, + }, + + { + 100, + 10, + [][]int{{10, 60}, {20, 30}, {30, 30}, {60, 40}}, + 2, + }, + + { + 1, + 1, + [][]int{}, + 0, + }, + + { + 100, + 1, + [][]int{{10, 100}}, + -1, + }, + + // 可以有多个 testcase +} + +func Test_minRefuelStops(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, minRefuelStops(tc.target, tc.startFuel, tc.stations), "输入:%v", tc) + } +} + +func Benchmark_minRefuelStops(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minRefuelStops(tc.target, tc.startFuel, tc.stations) + } + } +} diff --git a/Algorithms/0872.leaf-similar-trees/README.md b/Algorithms/0872.leaf-similar-trees/README.md new file mode 100755 index 000000000..532c00890 --- /dev/null +++ b/Algorithms/0872.leaf-similar-trees/README.md @@ -0,0 +1,21 @@ +# [872. Leaf-Similar Trees](https://leetcode.com/problems/leaf-similar-trees/) + +## 题目 + +Consider all the leaves of a binary tree. Fromleft to right order, the values of thoseleaves form a leaf value sequence. + +![tree](tree.png) + +For example, in the given tree above, the leaf value sequence is (6, 7, 4, 9, 8). + +Two binary trees are considered leaf-similarif their leaf value sequence is the same. + +Return true if and only if the two given trees with head nodes root1 and root2 are leaf-similar. + +Note: + +- Both of the given trees will have between 1 and 100 nodes. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0872.leaf-similar-trees/leaf-similar-trees.go b/Algorithms/0872.leaf-similar-trees/leaf-similar-trees.go new file mode 100755 index 000000000..aabae66ad --- /dev/null +++ b/Algorithms/0872.leaf-similar-trees/leaf-similar-trees.go @@ -0,0 +1,42 @@ +package problem0872 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode definition for a binary tree node. +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func leafSimilar(root1 *TreeNode, root2 *TreeNode) bool { + // 因为题目说了,root 的全部节点不会超过 100 个 + // 那么 leaf 节点就更不会超过 100 个了 + // 所以 a 始终是 s 的底层数组,不会发生变更 + // 结尾比较 a1 和 a2 的异同就会很方便 + + a1 := [100]int{} + s1 := a1[:0] + search(root1, &s1) + + a2 := [100]int{} + s2 := a2[:0] + search(root2, &s2) + + return a1 == a2 +} + +func search(root *TreeNode, sp *[]int) { + if root == nil { + return + } + if root.Left == nil && root.Right == nil { + *sp = append(*sp, root.Val) + return + } + search(root.Left, sp) + search(root.Right, sp) +} diff --git a/Algorithms/0872.leaf-similar-trees/leaf-similar-trees_test.go b/Algorithms/0872.leaf-similar-trees/leaf-similar-trees_test.go new file mode 100755 index 000000000..6bcfc9371 --- /dev/null +++ b/Algorithms/0872.leaf-similar-trees/leaf-similar-trees_test.go @@ -0,0 +1,65 @@ +package problem0872 + +import ( + "fmt" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root1 []int + root2 []int + ans bool +}{ + + { + []int{44, 79, 25, kit.NULL, kit.NULL, 112, 7, 74, 49, 2, 122}, + []int{38, 86, 120, 49, 54, 2, 122, kit.NULL, kit.NULL, 74, 79}, + false, + }, + + { + []int{3, 5, 1, 6, 2, 9, 8, kit.NULL, kit.NULL, 7, 4}, + []int{3, 5, 1, 6, 7, 4, 2, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 9, 8}, + true, + }, + + { + []int{3, 5, 1, 6, 2, 9, 8, kit.NULL, kit.NULL, 7, 4}, + []int{3, 5, 1, 6, 7, 4, 2, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 9, 9}, + false, + }, + + { + []int{3, 5, 1, 6, 2, 9, 8, 3, kit.NULL, 7, 4}, + []int{3, 5, 1, 6, 7, 4, 2, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 9, 9}, + false, + }, + + // 可以有多个 testcase +} + +func Test_leafSimilar(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + root1 := kit.Ints2TreeNode(tc.root1) + root2 := kit.Ints2TreeNode(tc.root2) + ast.Equal(tc.ans, leafSimilar(root1, root2), "输入:%v", tc) + } +} + +func Benchmark_leafSimilar(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root1 := kit.Ints2TreeNode(tc.root1) + root2 := kit.Ints2TreeNode(tc.root2) + leafSimilar(root1, root2) + } + } +} diff --git a/Algorithms/0872.leaf-similar-trees/tree.png b/Algorithms/0872.leaf-similar-trees/tree.png new file mode 100644 index 000000000..9298a5759 Binary files /dev/null and b/Algorithms/0872.leaf-similar-trees/tree.png differ diff --git a/Algorithms/0873.length-of-longest-fibonacci-subsequence/README.md b/Algorithms/0873.length-of-longest-fibonacci-subsequence/README.md new file mode 100755 index 000000000..3ad6bcd67 --- /dev/null +++ b/Algorithms/0873.length-of-longest-fibonacci-subsequence/README.md @@ -0,0 +1,41 @@ +# [873. Length of Longest Fibonacci Subsequence](https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/) + +## 题目 + +A sequence X_1, X_2, ..., X_nis fibonacci-like if: + +- n >= 3 +- X_i + X_{i+1} = X_{i+2}for alli + 2 <= n + +Given a strictly increasingarrayA of positive integers forming a sequence, find the length of the longest fibonacci-like subsequence of A. If one does not exist, return 0. + +(Recall that a subsequence is derived from another sequence A bydeleting any number ofelements (including none)from A, without changing the order of the remaining elements. For example, [3, 5, 8] is a subsequence of [3, 4, 5, 6, 7, 8].) + +Example 1: + +```text +Input: [1,2,3,4,5,6,7,8] +Output: 5 +Explanation: +The longest subsequence that is fibonacci-like: [1,2,3,5,8]. +``` + +Example 2: + +```text +Input: [1,3,7,11,12,14,18] +Output: 3 +Explanation: +The longest subsequence that is fibonacci-like: +[1,11,12], [3,11,14] or [7,11,18]. +``` + +Note: + +1. 3 <= A.length <= 1000 +1. 1 <= A[0] < A[1] < ... < A[A.length - 1] <= 10^9 +1. (The time limit has been reduced by 50% for submissions in Java, C, and C++.) + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0873.length-of-longest-fibonacci-subsequence/length-of-longest-fibonacci-subsequence.go b/Algorithms/0873.length-of-longest-fibonacci-subsequence/length-of-longest-fibonacci-subsequence.go new file mode 100755 index 000000000..dc59d5dd9 --- /dev/null +++ b/Algorithms/0873.length-of-longest-fibonacci-subsequence/length-of-longest-fibonacci-subsequence.go @@ -0,0 +1,54 @@ +package problem0873 + +import "sort" + +func lenLongestFibSubseq(a []int) int { + size := len(a) + res := 0 + + // (size - k) + 2 > res 表示,此时的 k 至少还有可能让 res 变的更大 + // (size - k) + 2 > res ==> k < size - res + 2 + + for k := 2; k < size && k < size-res+2; k++ { + l, r := 0, k-1 + + for l < r { + s := a[l] + a[r] + + if s < a[k] { + l++ + continue + } else if a[k] < s { + r-- + continue + } + + // 此时找到了第一组 a[l] + a[r] = a[k] + count := 3 + i, j := r, k + // 反复利用二分查找法,查看下个数是否在 a 中 + for { + next := a[i] + a[j] + i, j = j, j+sort.SearchInts(a[j:], next) + if j == size || a[j] != next { + break + } + count++ + } + + res = max(res, count) + l++ + r-- + } + + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0873.length-of-longest-fibonacci-subsequence/length-of-longest-fibonacci-subsequence_test.go b/Algorithms/0873.length-of-longest-fibonacci-subsequence/length-of-longest-fibonacci-subsequence_test.go new file mode 100755 index 000000000..ac459871e --- /dev/null +++ b/Algorithms/0873.length-of-longest-fibonacci-subsequence/length-of-longest-fibonacci-subsequence_test.go @@ -0,0 +1,54 @@ +package problem0873 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{2, 4, 7, 8, 9, 10, 14, 15, 18, 23, 32, 50}, + 5, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000}, + 15, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8}, + 5, + }, + + { + []int{1, 3, 7, 11, 12, 14, 18}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_lenLongestFibSubseq(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, lenLongestFibSubseq(tc.A), "输入:%v", tc) + } +} + +func Benchmark_lenLongestFibSubseq(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + lenLongestFibSubseq(tc.A) + } + } +} diff --git a/Algorithms/0874.walking-robot-simulation/README.md b/Algorithms/0874.walking-robot-simulation/README.md new file mode 100755 index 000000000..8d88ace37 --- /dev/null +++ b/Algorithms/0874.walking-robot-simulation/README.md @@ -0,0 +1,45 @@ +# [874. Walking Robot Simulation](https://leetcode.com/problems/walking-robot-simulation/) + +## 题目 + +A robot on an infinite grid starts at point (0, 0) and faces north. The robot can receive one of three possible types of commands: + +- -2: turn left 90 degrees +- -1: turn right 90 degrees +- 1 <= x <= 9: move forward x units + +Some of the grid squares are obstacles. + +The i-th obstacle is at grid point (obstacles[i][0], obstacles[i][1]) + +If the robot would try to move onto them, the robot stays on the previous grid square instead (but still continues following the rest of the route.) + +Return the square of the maximum Euclidean distance that the robot will be from the origin. + +Example 1: + +```text +Input: commands = [4,-1,3], obstacles = [] +Output: 25 +Explanation: robot will go to (3, 4) +``` + +Example 2: + +```text +Input: commands = [4,-1,4,-2,4], obstacles = [[2,4]] +Output: 65 +Explanation: robot will be stuck at (1, 4) before turning left and going to (1, 8) +``` + +Note: + +- 0 <= commands.length <= 10000 +- 0 <= obstacles.length <= 10000 +- -30000 <= obstacle[i][0] <= 30000 +- -30000 <= obstacle[i][1] <= 30000 +- The answer is guaranteed to be less than 2 ^ 31. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0874.walking-robot-simulation/walking-robot-simulation.go b/Algorithms/0874.walking-robot-simulation/walking-robot-simulation.go new file mode 100755 index 000000000..a45747fe5 --- /dev/null +++ b/Algorithms/0874.walking-robot-simulation/walking-robot-simulation.go @@ -0,0 +1,174 @@ +package problem0874 + +var dxs = []int{0, 1, 0, -1} +var dys = []int{1, 0, -1, 0} + +func robotSim(commands []int, obstacles [][]int) int { + isBlocked := make(map[int]bool, 10000) + for _, o := range obstacles { + i, j := o[0], o[1] + isBlocked[encode(i, j)] = true + } + + x, y, res := 0, 0, 0 + index := 0 + + for _, c := range commands { + switch { + case c == -2: + index-- + case c == -1: + index++ + default: + if index < 0 { + index += 1<<63 - 4 + } + index %= 4 + dx, dy := dxs[index], dys[index] + for c > 0 && !isBlocked[encode(x+dx, y+dy)] { + c-- + x += dx + y += dy + } + res = max(res, x*x+y*y) + } + } + + return res +} + +func encode(x, y int) int { + x &= 0xFFFF + y &= 0xFFFF + return x<<16 | y +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +// 以下方法太繁琐了 +// 应该注意到,每次最多移动 9 步,所以,走一步看一步,也是一个好方法。 + +// func robotSim(commands []int, obstacles [][]int) int { + +// sort.Slice(obstacles, func(i int, j int) bool { +// if obstacles[i][0] == obstacles[j][0] { +// return obstacles[i][1] < obstacles[j][1] +// } +// return obstacles[i][0] < obstacles[j][0] +// }) +// oxs := make(map[int][]int, len(obstacles)) +// oys := make(map[int][]int, len(obstacles)) +// for _, o := range obstacles { +// if o[0] == 0 && o[1] == 0 { +// continue +// } +// oxs[o[0]] = append(oxs[o[0]], o[1]) +// oys[o[1]] = append(oys[o[1]], o[0]) +// } + +// x, y := 0, 0 + +// north := func(a int) { +// y += a +// ys, ok := oxs[x] +// if ok { +// i := sort.SearchInts(ys, y-a) +// if i < len(ys) { +// y = min(y, ys[i]-1) +// } +// } +// } + +// east := func(a int) { +// x += a +// xs, ok := oys[y] +// if ok { +// i := sort.SearchInts(xs, x-a) +// if i < len(xs) { +// x = min(x, xs[i]-1) +// } +// } +// } + +// south := func(a int) { +// y -= a +// ys, ok := oxs[x] +// if ok { +// i := sort.SearchInts(ys, y+a) +// if 0 < i { +// y = max(y, ys[i-1]+1) +// } +// } +// } + +// west := func(a int) { +// x -= a +// xs, ok := oys[y] +// if ok { +// i := sort.SearchInts(xs, x+a) +// if 0 < i { +// x = max(x, xs[i-1]+1) +// } +// } +// } + +// moves := []func(int){north, east, south, west} +// idx := 40000 +// mov := north + +// turn := func(c int) { +// if c == -2 { +// idx-- +// } else { +// idx++ +// } +// mov = moves[idx%4] +// } + +// // 合并同一个方向连续移动的步数 +// tmp := make([]int, 1, len(commands)) +// tmp[0] = commands[0] +// j := 0 +// for i := 1; i < len(commands); i++ { +// c := commands[i] +// if tmp[j] > 0 && c > 0 { +// tmp[j] += c +// } else { +// tmp = append(tmp, c) +// j++ +// } +// } +// commands = tmp + +// res := 0 + +// for _, c := range commands { +// if c < 0 { +// turn(c) +// } else { +// mov(c) +// res = max(res, x*x+y*y) +// } +// } + +// return res +// } + +// func max(a, b int) int { +// if a > b { +// return a +// } +// return b +// } + +// func min(a, b int) int { +// if a < b { +// return a +// } +// return b +// } diff --git a/Algorithms/0874.walking-robot-simulation/walking-robot-simulation_test.go b/Algorithms/0874.walking-robot-simulation/walking-robot-simulation_test.go new file mode 100755 index 000000000..00b925262 --- /dev/null +++ b/Algorithms/0874.walking-robot-simulation/walking-robot-simulation_test.go @@ -0,0 +1,107 @@ +package problem0874 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + commands []int + obstacles [][]int + ans int +}{ + + { + []int{3, 2, 4, 1, -2, -1, -1, 3, 8, 7, 5, -2, 5, 9, -2, 8, 3, -1, 8, 7, -2, 7, -2, 7, 4, 9, 5, 7, 9, 9, -1, 2, -1, -1, -2, -1, 8, -1, 7, -1, 2, 6, 6, 3, -1, 7, 5, 4, 4, 1, -2, 9, 4, -2, 5, 7, -2, -2, 5, 4, 3, 8, -2, 5, 5, 6, 6, 6, 8, -1, 1, -1, -1, 6, 3, 5, 8, 2, -1, 7, -2, 8, -2, -2, 2, 4, -1, -1, -2, 3, 4, -2, 1, 9, -1, -2, 4, 7, 5, 9}, + [][]int{{39, 83}, {1, 30}, {-62, -88}, {-82, -65}, {81, -88}, {-100, -74}, {-33, 64}, {96, -15}, {91, -71}, {27, 33}, {-66, 28}, {99, 83}, {80, 3}, {-65, -53}, {92, -47}, {14, -71}, {-70, -6}, {-42, -31}, {92, 73}, {-47, -59}, {-77, -8}, {-89, 8}, {-2, -22}, {-95, 61}, {-76, -75}, {5, -52}, {81, 32}, {12, -15}, {-69, -20}, {81, -77}, {-79, -42}, {13, -32}, {-6, 12}, {-6, 95}, {54, -17}, {-55, -76}, {9, -93}, {51, -27}, {73, -70}, {13, -3}, {-72, 38}, {8, 56}, {88, 56}, {62, 16}, {-5, -94}, {-55, 31}, {-21, 69}, {-32, 82}, {-80, 60}, {-1, 54}, {-52, 22}, {30, 52}, {-35, -55}, {-100, 75}, {98, 10}, {-67, 41}, {44, 38}, {18, -29}, {73, 0}, {-29, -62}, {-27, -67}, {-42, -64}, {-60, 20}, {-32, 18}, {60, -89}, {-31, 98}, {-27, 85}, {53, -38}, {-58, -33}, {9, -9}, {-66, -26}, {72, 46}, {49, 99}, {58, -80}, {-10, -76}, {-22, 13}, {-34, 100}, {-31, -43}, {89, -95}, {52, -49}, {61, -5}, {20, -94}, {-42, 79}, {-39, -60}, {-70, 39}, {-21, -10}, {-41, 51}, {-21, -51}, {82, 97}, {-81, -77}, {39, 63}, {24, 96}, {-73, 36}, {88, -92}, {-84, 27}, {-33, 78}, {96, 7}, {-19, 10}, {19, -40}, {-94, -25}, {32, 52}, {42, -22}, {77, 65}, {-64, -4}, {93, 94}, {21, 89}, {-90, 9}, {-74, -33}, {-30, -13}, {35, 2}, {-38, 84}, {-29, 96}, {73, 57}, {-43, -9}, {-9, -86}, {50, -64}, {24, -83}, {2, 18}, {-96, 52}, {77, 71}, {-93, -57}, {-88, -40}, {85, -40}, {2, -45}, {1, 47}, {89, 19}, {-27, 40}, {-6, -39}, {40, -19}, {35, 87}, {88, -37}, {31, -79}, {33, 8}, {-2, 56}, {25, 16}, {-60, -9}, {-7, -23}, {-24, 86}, {-79, 79}, {80, -69}, {10, -21}, {-93, -25}, {23, -59}, {-81, -50}, {-2, -46}, {-64, -91}, {82, 25}, {24, 8}, {-59, 53}, {-94, 61}, {-18, -67}, {47, 34}, {77, 11}, {11, -81}, {84, 29}, {-61, -12}, {-94, 41}, {-56, -1}, {-79, 10}, {-32, 67}, {17, 45}, {-11, -4}, {44, 66}, {-98, -55}, {67, 43}, {-28, -80}, {72, -97}, {-86, -99}, {1, 43}, {-75, -72}, {-24, -92}, {-42, -44}, {38, 33}, {-64, -12}, {-82, -60}, {38, -51}, {71, -47}, {40, 42}, {-85, 60}, {-46, -61}, {-25, 17}, {-13, -17}, {21, 84}, {-56, -72}, {95, 67}, {-28, 73}, {53, -4}, {-14, -92}, {21, -43}, {82, -63}, {-98, 42}, {65, -97}, {-78, 72}, {54, 65}, {44, -15}, {-88, 7}, {23, -62}, {-8, -6}, {-11, -93}, {43, 81}}, + 4328, + }, + + { + []int{5}, + [][]int{{0, 3}}, + 4, + }, + + { + []int{-2, -2, -2, 5}, + [][]int{{3, 0}}, + 4, + }, + + { + []int{-1, 5}, + [][]int{{3, 0}}, + 4, + }, + + { + []int{-2, -2, 5}, + [][]int{{0, -3}}, + 4, + }, + + { + []int{-1, -1, 5}, + [][]int{{0, -3}}, + 4, + }, + + { + []int{-2, 5}, + [][]int{{-3, 0}}, + 4, + }, + + { + []int{-1, -1, -1, 5}, + [][]int{{-3, 0}}, + 4, + }, + + { + []int{1, 2, -2, 5, -1, -2, -1, 8, 3, -1, 9, 4, -2, 3, 2, 4, 3, 9, 2, -1, -1, -2, 1, 3, -2, 4, 1, 4, -1, 1, 9, -1, -2, 5, -1, 5, 5, -2, 6, 6, 7, 7, 2, 8, 9, -1, 7, 4, 6, 9, 9, 9, -1, 5, 1, 3, 3, -1, 5, 9, 7, 4, 8, -1, -2, 1, 3, 2, 9, 3, -1, -2, 8, 8, 7, 5, -2, 6, 8, 4, 6, 2, 7, 2, -1, 7, -2, 3, 3, 2, -2, 6, 9, 8, 1, -2, -1, 1, 4, 7}, + [][]int{{-57, -58}, {-72, 91}, {-55, 35}, {-20, 29}, {51, 70}, {-61, 88}, {-62, 99}, {52, 17}, {-75, -32}, {91, -22}, {54, 33}, {-45, -59}, {47, -48}, {53, -98}, {-91, 83}, {81, 12}, {-34, -90}, {-79, -82}, {-15, -86}, {-24, 66}, {-35, 35}, {3, 31}, {87, 93}, {2, -19}, {87, -93}, {24, -10}, {84, -53}, {86, 87}, {-88, -18}, {-51, 89}, {96, 66}, {-77, -94}, {-39, -1}, {89, 51}, {-23, -72}, {27, 24}, {53, -80}, {52, -33}, {32, 4}, {78, -55}, {-25, 18}, {-23, 47}, {79, -5}, {-23, -22}, {14, -25}, {-11, 69}, {63, 36}, {35, -99}, {-24, 82}, {-29, -98}, {-50, -70}, {72, 95}, {80, 80}, {-68, -40}, {65, 70}, {-92, 78}, {-45, -63}, {1, 34}, {81, 50}, {14, 91}, {-77, -54}, {13, -88}, {24, 37}, {-12, 59}, {-48, -62}, {57, -22}, {-8, 85}, {48, 71}, {12, 1}, {-20, 36}, {-32, -14}, {39, 46}, {-41, 75}, {13, -23}, {98, 10}, {-88, 64}, {50, 37}, {-95, -32}, {46, -91}, {10, 79}, {-11, 43}, {-94, 98}, {79, 42}, {51, 71}, {4, -30}, {2, 74}, {4, 10}, {61, 98}, {57, 98}, {46, 43}, {-16, 72}, {53, -69}, {54, -96}, {22, 0}, {-7, 92}, {-69, 80}, {68, -73}, {-24, -92}, {-21, 82}, {32, -1}, {-6, 16}, {15, -29}, {70, -66}, {-85, 80}, {50, -3}, {6, 13}, {-30, -98}, {-30, 59}, {-67, 40}, {17, 72}, {79, 82}, {89, -100}, {2, 79}, {-95, -46}, {17, 68}, {-46, 81}, {-5, -57}, {7, 58}, {-42, 68}, {19, -95}, {-17, -76}, {81, -86}, {79, 78}, {-82, -67}, {6, 0}, {35, -16}, {98, 83}, {-81, 100}, {-11, 46}, {-21, -38}, {-30, -41}, {86, 18}, {-68, 6}, {80, 75}, {-96, -44}, {-19, 66}, {21, 84}, {-56, -64}, {39, -15}, {0, 45}, {-81, -54}, {-66, -93}, {-4, 2}, {-42, -67}, {-15, -33}, {1, -32}, {-74, -24}, {7, 18}, {-62, 84}, {19, 61}, {39, 79}, {60, -98}, {-76, 45}, {58, -98}, {33, 26}, {-74, -95}, {22, 30}, {-68, -62}, {-59, 4}, {-62, 35}, {-78, 80}, {-82, 54}, {-42, 81}, {56, -15}, {32, -19}, {34, 93}, {57, -100}, {-1, -87}, {68, -26}, {18, 86}, {-55, -19}, {-68, -99}, {-9, 47}, {24, 94}, {92, 97}, {5, 67}, {97, -71}, {63, -57}, {-52, -14}, {-86, -78}, {-17, 92}, {-61, -83}, {-84, -10}, {20, 13}, {-68, -47}, {7, 28}, {66, 89}, {-41, -17}, {-14, -46}, {-72, -91}, {4, 52}, {-17, -59}, {-85, -46}, {-94, -23}, {-48, -3}, {-64, -37}, {2, 26}, {76, 88}, {-8, -46}, {-19, -68}}, + 5140, + }, + + { + []int{2, 2, 5, -1, -1}, + [][]int{{-3, 5}, {-2, 5}, {3, 2}, {5, 0}, {-2, 0}, {-1, 5}, {5, -3}, {0, 0}, {-4, 4}, {-3, 4}}, + 81, + }, + + { + []int{4, -1, 4, -2, 4}, + [][]int{{2, 4}}, + 65, + }, + + { + []int{4, -1, 3}, + [][]int{}, + 25, + }, + + // 可以有多个 testcase +} + +func Test_robotSim(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, robotSim(tc.commands, tc.obstacles), "输入:%v", tc) + } +} + +func Benchmark_robotSim(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + robotSim(tc.commands, tc.obstacles) + } + } +} diff --git a/Algorithms/0875.koko-eating-bananas/README.md b/Algorithms/0875.koko-eating-bananas/README.md new file mode 100755 index 000000000..7a7521494 --- /dev/null +++ b/Algorithms/0875.koko-eating-bananas/README.md @@ -0,0 +1,42 @@ +# [875. Koko Eating Bananas](https://leetcode.com/problems/koko-eating-bananas/) + +## 题目 + +Koko loves to eat bananas. There are Npiles of bananas, the i-thpile has piles[i] bananas. The guards have gone and will come back in H hours. + +Koko can decide her bananas-per-hour eating speed of K. Each hour, she chooses some pile of bananas, and eats K bananas from that pile. If the pile has less than K bananas, she eats all of them instead, and won't eat any more bananas during this hour. + +Koko likes to eat slowly, but still wants to finish eating all the bananas before the guards come back. + +Return the minimum integer K such that she can eat all the bananas within H hours. + +Example 1: + +```text +Input: piles = [3,6,7,11], H = 8 +Output: 4 +``` + +Example 2: + +```text +Input: piles = [30,11,23,4,20], H = 5 +Output: 30 +``` + +Example 3: + +```text +Input: piles = [30,11,23,4,20], H = 6 +Output: 23 +``` + +Note: + +1. 1 <= piles.length <= 10^4 +1. piles.length <= H <= 10^9 +1. 1 <= piles[i] <= 10^9 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0875.koko-eating-bananas/koko-eating-bananas.go b/Algorithms/0875.koko-eating-bananas/koko-eating-bananas.go new file mode 100755 index 000000000..584119d39 --- /dev/null +++ b/Algorithms/0875.koko-eating-bananas/koko-eating-bananas.go @@ -0,0 +1,50 @@ +package problem0875 + +import ( + "math" +) + +func minEatingSpeed(piles []int, h int) int { + sum, r := sumAndMax(piles) + l := (sum + h - 1) / h + + for l < r { + m := (l + r) / 2 + if canEatAll(m, h, piles) { + r = m + } else { + l = m + 1 + } + } + + return r +} + +func sumAndMax(a []int) (int, int) { + sum := 0 + mx := 0 + for _, n := range a { + sum += n + mx = max(mx, n) + } + return sum, mx +} + +func canEatAll(k, h int, piles []int) bool { + r := 1 / float64(k) + for _, p := range piles { + fp := float64(p) + h -= int(math.Ceil(fp * r)) + if h < 0 { + return false + } + } + return true +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0875.koko-eating-bananas/koko-eating-bananas_test.go b/Algorithms/0875.koko-eating-bananas/koko-eating-bananas_test.go new file mode 100755 index 000000000..079327489 --- /dev/null +++ b/Algorithms/0875.koko-eating-bananas/koko-eating-bananas_test.go @@ -0,0 +1,65 @@ +package problem0875 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + piles []int + H int + ans int +}{ + + { + []int{1, 2, 3, 4, 100}, + 5, + 100, + }, + + { + []int{3, 6, 7, 10000}, + 8, + 2000, + }, + + { + []int{3, 6, 7, 11}, + 8, + 4, + }, + + { + []int{30, 11, 23, 4, 20}, + 5, + 30, + }, + + { + []int{30, 11, 23, 4, 20}, + 6, + 23, + }, + + // 可以有多个 testcase +} + +func Test_minEatingSpeed(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, minEatingSpeed(tc.piles, tc.H), "输入:%v", tc) + } +} + +func Benchmark_minEatingSpeed(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minEatingSpeed(tc.piles, tc.H) + } + } +} diff --git a/Algorithms/0876.middle-of-the-linked-list/README.md b/Algorithms/0876.middle-of-the-linked-list/README.md new file mode 100755 index 000000000..1eb7b5b19 --- /dev/null +++ b/Algorithms/0876.middle-of-the-linked-list/README.md @@ -0,0 +1,33 @@ +# [876. Middle of the Linked List](https://leetcode.com/problems/middle-of-the-linked-list/) + +## 题目 + +Given a non-empty, singlylinked list with head node head, returnamiddle node of linked list. + +If there are two middle nodes, return the second middle node. + +Example 1: + +```text +Input: [1,2,3,4,5] +Output: Node 3 from this list (Serialization: [3,4,5]) +The returned node has value 3. (The judge's serialization of this node is [3,4,5]). +Note that we returned a ListNode object ans, such that: +ans.val = 3, ans.next.val = 4, ans.next.next.val = 5, and ans.next.next.next = NULL. +``` + +Example 2: + +```text +Input: [1,2,3,4,5,6] +Output: Node 4 from this list (Serialization: [4,5,6]) +Since the list has two middle nodes with values 3 and 4, we return the second one. +``` + +Note: + +1. The number of nodes in the given list will be between 1and 100. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0876.middle-of-the-linked-list/middle-of-the-linked-list.go b/Algorithms/0876.middle-of-the-linked-list/middle-of-the-linked-list.go new file mode 100755 index 000000000..6429eb547 --- /dev/null +++ b/Algorithms/0876.middle-of-the-linked-list/middle-of-the-linked-list.go @@ -0,0 +1,21 @@ +package problem0876 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// ListNode defined for singly-linked list. +// type ListNode struct { +// Val int +// Next *ListNode +// } +type ListNode = kit.ListNode + +func middleNode(head *ListNode) *ListNode { + slow, fast := head, head + for fast != nil && fast.Next != nil { + slow = slow.Next + fast = fast.Next.Next + } + return slow +} diff --git a/Algorithms/0876.middle-of-the-linked-list/middle-of-the-linked-list_test.go b/Algorithms/0876.middle-of-the-linked-list/middle-of-the-linked-list_test.go new file mode 100755 index 000000000..488b9388f --- /dev/null +++ b/Algorithms/0876.middle-of-the-linked-list/middle-of-the-linked-list_test.go @@ -0,0 +1,49 @@ +package problem0876 + +import ( + "fmt" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + head []int + ans []int +}{ + + { + []int{1, 2, 3, 4, 5}, + []int{3, 4, 5}, + }, + + { + []int{1, 2, 3, 4, 5, 6}, + []int{4, 5, 6}, + }, + + // 可以有多个 testcase +} + +func Test_middleNode(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + head := kit.Ints2List(tc.head) + actual := kit.List2Ints(middleNode(head)) + ast.Equal(tc.ans, actual, "输入:%v", tc) + } +} + +func Benchmark_middleNode(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + head := kit.Ints2List(tc.head) + middleNode(head) + } + } +} diff --git a/Algorithms/0877.stone-game/README.md b/Algorithms/0877.stone-game/README.md new file mode 100755 index 000000000..d2861e4d4 --- /dev/null +++ b/Algorithms/0877.stone-game/README.md @@ -0,0 +1,35 @@ +# [877. Stone Game](https://leetcode.com/problems/stone-game/) + +## 题目 + +Alex and Lee play a game with piles of stones. There are an even number ofpiles arranged in a row, and each pile has a positive integer number of stones piles[i]. + +The objective of the game is to end with the moststones. The total number of stones is odd, so there are no ties. + +Alex and Lee take turns, with Alex starting first. Each turn, a playertakes the entire pile of stones from either the beginning or the end of the row. This continues until there are no more piles left, at which point the person with the most stones wins. + +Assuming Alex and Lee play optimally, return Trueif and only if Alex wins the game. + +Example 1: + +```text +Input: [5,3,4,5] +Output: true +Explanation: +Alex starts first, and can only take the first 5 or the last 5. +Say he takes the first 5, so that the row becomes [3, 4, 5]. +If Lee takes 3, then the board is [4, 5], and Alex takes 5 to win with 10 points. +If Lee takes the last 5, then the board is [3, 4], and Alex takes 4 to win with 9 points. +This demonstrated that taking the first 5 was a winning move for Alex, so we return true. +``` + +Note: + +1. 2 <= piles.length <= 500 +1. piles.length is even. +1. 1 <= piles[i] <= 500 +1. sum(piles) is odd. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0877.stone-game/stone-game.go b/Algorithms/0877.stone-game/stone-game.go new file mode 100755 index 000000000..1f488bbe6 --- /dev/null +++ b/Algorithms/0877.stone-game/stone-game.go @@ -0,0 +1,31 @@ +package problem0877 + +func stoneGame(p []int) bool { + size := len(p) + + // dp[i][j] = k 表示, 面对 p[i:j+1] 个石头,先拿的人会比后拿的人多 k 个 + dp := [501][501]int{} + for i := 0; i < size; i++ { + dp[i][i] = p[i] + } + + for d := 1; d < size; d++ { + for i := 0; i < size-d; i++ { + // p[i]-dp[i+1][i+d] 表示,如果拿了左边的会比后拿的人多的个数 + // p[i+d]-dp[i][i+d-1] 表示,如果拿了右边会比后拿的人多的个数 + // 注意 dp[i][i+d] 与 dp[i+1][i+d] (or dp[i][i+d-1]) 的先拿后拿的转换 + dp[i][i+d] = max(p[i]-dp[i+1][i+d], p[i+d]-dp[i][i+d-1]) + } + } + + return dp[0][size-1] > 0 +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +// https://leetcode.com/problems/stone-game/discuss/154610/C++JavaPython-DP-or-Just-return-true diff --git a/Algorithms/0877.stone-game/stone-game_test.go b/Algorithms/0877.stone-game/stone-game_test.go new file mode 100755 index 000000000..86b87f0bd --- /dev/null +++ b/Algorithms/0877.stone-game/stone-game_test.go @@ -0,0 +1,44 @@ +package problem0877 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + piles []int + ans bool +}{ + + { + []int{1, 100, 2, 4}, + true, + }, + + { + []int{5, 3, 4, 5}, + true, + }, + + // 可以有多个 testcase +} + +func Test_stoneGame(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, stoneGame(tc.piles), "输入:%v", tc) + } +} + +func Benchmark_stoneGame(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + stoneGame(tc.piles) + } + } +} diff --git a/Algorithms/0878.nth-magical-number/README.md b/Algorithms/0878.nth-magical-number/README.md new file mode 100755 index 000000000..b22a59a1b --- /dev/null +++ b/Algorithms/0878.nth-magical-number/README.md @@ -0,0 +1,45 @@ +# [878. Nth Magical Number](https://leetcode.com/problems/nth-magical-number/) + +## 题目 + +A positive integeris magicalif it is divisible by either Aor B. + +Return the N-th magical number. Since the answer may be very large, return it modulo 10^9 + 7. + +Example 1: + +```text +Input: N = 1, A = 2, B = 3 +Output: 2 +``` + +Example 2: + +```text +Input: N = 4, A = 2, B = 3 +Output: 6 +``` + +Example 3: + +```text +Input: N = 5, A = 2, B = 4 +Output: 10 +``` + +Example 4: + +```text +Input: N = 3, A = 6, B = 4 +Output: 8 +``` + +Note: + +1. 1 <= N<= 10^9 +1. 2 <= A<= 40000 +1. 2 <= B<= 40000 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0878.nth-magical-number/nth-magical-number.go b/Algorithms/0878.nth-magical-number/nth-magical-number.go new file mode 100755 index 000000000..740b07684 --- /dev/null +++ b/Algorithms/0878.nth-magical-number/nth-magical-number.go @@ -0,0 +1,53 @@ +package problem0878 + +const mod = 1e9 + 7 + +func nthMagicalNumber(n, a, b int) int { + if a > b { + a, b = b, a + } + + m := lcm(a, b) + l, r := a*n/2, b*n + + for { + med := (l + r) / 2 + count := magicalOf(med, a, b, m) + switch { + case count < n: + l = med + 1 + case n < count: + r = med - 1 + default: + res := med - min(med%a, med%b) + return res % mod + } + } +} + +func magicalOf(num, a, b, m int) int { + return num/a + num/b - num/m +} + +// 最小公倍数 +func lcm(a, b int) int { + return a * b / gcd(a, b) +} + +// 最大公约数 +func gcd(a, b int) int { + if a < b { + a, b = b, a + } + for b != 0 { + a, b = b, a%b + } + return a +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0878.nth-magical-number/nth-magical-number_test.go b/Algorithms/0878.nth-magical-number/nth-magical-number_test.go new file mode 100755 index 000000000..5ec0212e5 --- /dev/null +++ b/Algorithms/0878.nth-magical-number/nth-magical-number_test.go @@ -0,0 +1,71 @@ +package problem0878 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + A int + B int + ans int +}{ + + { + 1000000000, + 40000, + 40000, + 999720007, + }, + + { + 1, + 2, + 3, + 2, + }, + + { + 4, + 2, + 3, + 6, + }, + + { + 5, + 2, + 4, + 10, + }, + + { + 3, + 6, + 4, + 8, + }, + + // 可以有多个 testcase +} + +func Test_nthMagicalNumber(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, nthMagicalNumber(tc.N, tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_nthMagicalNumber(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + nthMagicalNumber(tc.N, tc.A, tc.B) + } + } +} diff --git a/Algorithms/0879.profitable-schemes/README.md b/Algorithms/0879.profitable-schemes/README.md new file mode 100755 index 000000000..c9bac7cc4 --- /dev/null +++ b/Algorithms/0879.profitable-schemes/README.md @@ -0,0 +1,45 @@ +# [879. Profitable Schemes](https://leetcode.com/problems/profitable-schemes/) + +## 题目 + +There are G people in a gang, and a list of various crimes they could commit. + +The i-th crime generates a profit[i] and requires group[i] gang members to participate. + +If a gang member participates in one crime, that member can't participate in another crime. + +Let's call a profitable schemeany subset of these crimes that generates at least P profit, and the total number of gang members participating in that subset of crimes is at most G. + +How many schemes can be chosen? Since the answer may be verylarge, return it modulo 10^9 + 7. + +Example 1: + +```text +Input: G = 5, P = 3, group = [2,2], profit = [2,3] +Output: 2 +Explanation: +To make a profit of at least 3, the gang could either commit crimes 0 and 1, or just crime 1. +In total, there are 2 schemes. +``` + +Example 2: + +```text +Input: G = 10, P = 5, group = [2,3,5], profit = [6,7,8] +Output: 7 +Explanation: +To make a profit of at least 5, the gang could commit any crimes, as long as they commit one. +There are 7 possible schemes: (0), (1), (2), (0,1), (0,2), (1,2), and (0,1,2). +``` + +Note: + +1. 1 <= G <= 100 +1. 0 <= P <= 100 +1. 1 <= group[i] <= 100 +1. 0 <= profit[i] <= 100 +1. 1 <= group.length = profit.length <= 100 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0879.profitable-schemes/profitable-schemes.go b/Algorithms/0879.profitable-schemes/profitable-schemes.go new file mode 100755 index 000000000..bb19bd7eb --- /dev/null +++ b/Algorithms/0879.profitable-schemes/profitable-schemes.go @@ -0,0 +1,48 @@ +package problem0879 + +const mod = 1e9 + 7 + +func profitableSchemes(G, P int, group, profit []int) int { + /* dp[p][g] = x 表示, + * g 个人想要获得收益 p ,一共有 x 种选择 + * 其中的 g 个人,每个人都有事情做,而且人和人之间没有区别。 + * 特别地, + * dp[P][g] = x 表示, + * g 个无差别的人,每个人都有事情做,总的收益 >=P 的选择数为 x + */ + dp := [101][101]int{} + dp[0][0] = 1 + + size := len(group) + + for k := 0; k < size; k++ { + gk := group[k] + pk := profit[k] + for i := P; i >= 0; i-- { + ip := min(i+pk, P) + for j := G - gk; j >= 0; j-- { + // 首先假设 dp 的行数有无穷多 + // 那么 dp[i+p][j+g] = dp[i][j] 的含义是 + // j+g 比 j 多 g 个人,可以取得 i+p 的收益 + // 可惜 dp 的行数没有无穷多,需要压缩 + // 需要把 dp[>=P][j] 求和放置到 dp[P][j] + // ip := min(i+p, P) 就是压缩过程 + dp[ip][j+gk] += dp[i][j] + dp[ip][j+gk] %= mod + } + } + } + + res := 0 + for i := 0; i <= G; i++ { + res += dp[P][i] + } + return res % mod +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0879.profitable-schemes/profitable-schemes_test.go b/Algorithms/0879.profitable-schemes/profitable-schemes_test.go new file mode 100755 index 000000000..62d2f344d --- /dev/null +++ b/Algorithms/0879.profitable-schemes/profitable-schemes_test.go @@ -0,0 +1,61 @@ +package problem0879 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + G int + P int + group []int + profit []int + ans int +}{ + + { + 10, + 5, + []int{2, 3, 5}, + []int{6, 7, 8}, + 7, + }, + + { + 5, + 3, + []int{2, 2}, + []int{2, 3}, + 2, + }, + + { + 5, + 0, + []int{2, 2}, + []int{2, 3}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_profitableSchemes(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, profitableSchemes(tc.G, tc.P, tc.group, tc.profit), "输入:%v", tc) + } +} + +func Benchmark_profitableSchemes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + profitableSchemes(tc.G, tc.P, tc.group, tc.profit) + } + } +} diff --git a/Algorithms/0880.decoded-string-at-index/README.md b/Algorithms/0880.decoded-string-at-index/README.md new file mode 100755 index 000000000..9fa221f03 --- /dev/null +++ b/Algorithms/0880.decoded-string-at-index/README.md @@ -0,0 +1,50 @@ +# [880. Decoded String at Index](https://leetcode.com/problems/decoded-string-at-index/) + +## 题目 + +An encoded string S is given. To find and write the decoded string to a tape, the encoded string is read one character at a timeand the following steps are taken: + +- If the character read is a letter, that letter is written onto the tape. +- If the character read is a digit (say d), the entire current tape is repeatedly writtend-1more times in total. + +Now for some encoded string S, and an index K, find and return the K-th letter (1 indexed) in the decoded string. + +Example 1: + +```text +Input: S = "leet2code3", K = 10 +Output: "o" +Explanation: +The decoded string is "leetleetcodeleetleetcodeleetleetcode". +The 10th letter in the string is "o". +``` + +Example 2: + +```text +Input: S = "ha22", K = 5 +Output: "h" +Explanation: +The decoded string is "hahahaha". The 5th letter is "h". +``` + +Example 3: + +```text +Input: S = "a2345678999999999999999", K = 1 +Output: "a" +Explanation: +The decoded string is "a" repeated 8301530446056247680 times. The 1st letter is "a". +``` + +Note: + +1. 2 <= S.length <= 100 +1. Swill only contain lowercase letters and digits 2 through 9. +1. Sstarts with a letter. +1. 1 <= K <= 10^9 +1. The decoded string is guaranteed to have less than 2^63 letters. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0880.decoded-string-at-index/decoded-string-at-index.go b/Algorithms/0880.decoded-string-at-index/decoded-string-at-index.go new file mode 100755 index 000000000..7d1721648 --- /dev/null +++ b/Algorithms/0880.decoded-string-at-index/decoded-string-at-index.go @@ -0,0 +1,35 @@ +package problem0880 + +func decodeAtIndex(S string, K int) string { + /** lenSi 是 S[:i] 展开后的长度。*/ + lenSi, i := 0, 0 + + for ; lenSi < K; i++ { + char := S[i] + if isDigit(char) { + lenSi *= int(char - '0') + } else { + lenSi++ + } + } + + for { + i-- + char := S[i] + if isDigit(char) { + lenSi /= int(char - '0') + K %= lenSi + } else { + if K == 0 || // "leet3code2" K = 8 会导致 K == 0 成立 + K == lenSi { + return string(char) + } + lenSi-- + } + } + +} + +func isDigit(b byte) bool { + return b <= '9' +} diff --git a/Algorithms/0880.decoded-string-at-index/decoded-string-at-index_test.go b/Algorithms/0880.decoded-string-at-index/decoded-string-at-index_test.go new file mode 100755 index 000000000..87fd2d26f --- /dev/null +++ b/Algorithms/0880.decoded-string-at-index/decoded-string-at-index_test.go @@ -0,0 +1,113 @@ +package problem0880 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + K int + ans string +}{ + + { + "a2345678999999999999999", + 12314145213412, + "a", + }, + + { + "a2b3c4d5e6f7g8h9", + 3, + "b", + }, + + { + "leet2code3for2you2", + 160, + "y", + }, + + { + "leet2code3for2you2", + 89, + "t", + }, + + { + "leet2code3for2you2", + 13, + "l", + }, + + { + "leet2code3for2you2", + 90, + "c", + }, + + { + "leet2code3", + 10, + "o", + }, + + { + "leet2code3for2you", + 16, + "t", + }, + + { + "leet2code3for2you2", + 85, + "t", + }, + + { + "ha22", + 5, + "h", + }, + + { + "a2345678999999999999999", + 1, + "a", + }, + + // 可以有多个 testcase +} + +func Test_decodeAtIndex(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, decodeAtIndex(tc.S, tc.K), "输入:%v", tc) + } +} + +func Test_decodeAtIndex_2(t *testing.T) { + ast := assert.New(t) + + s := "leat2code3for2you2" + ansStr := "leatleatcodeleatleatcodeleatleatcodeforleatleatcodeleatleatcodeleatleatcodeforyouleatleatcodeleatleatcodeleatleatcodeforleatleatcodeleatleatcodeleatleatcodeforyou" + for i := range ansStr { + expectd := ansStr[i : i+1] + actual := decodeAtIndex(s, i+1) + msg := fmt.Sprintf("%s 的第 %d 个字符应该是 %s", s, i+1, expectd) + ast.Equal(expectd, actual, msg) + } +} + +func Benchmark_decodeAtIndex(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + decodeAtIndex(tc.S, tc.K) + } + } +} diff --git a/Algorithms/0881.boats-to-save-people/README.md b/Algorithms/0881.boats-to-save-people/README.md new file mode 100755 index 000000000..611e2f605 --- /dev/null +++ b/Algorithms/0881.boats-to-save-people/README.md @@ -0,0 +1,42 @@ +# [881. Boats to Save People](https://leetcode.com/problems/boats-to-save-people/) + +## 题目 + +The i-th person has weight people[i], and each boat can carry a maximum weight of limit. + +Each boat carries at most 2 people at the same time, provided the sum of theweight of those people is at most limit. + +Return the minimum number of boats to carry every given person. (It is guaranteed each person can be carried by a boat.) + +Example 1: + +```text +Input: people = [1,2], limit = 3 +Output: 1 +Explanation: 1 boat (1, 2) +``` + +Example 2: + +```text +Input: people = [3,2,2,1], limit = 3 +Output: 3 +Explanation: 3 boats (1, 2), (2) and (3) +``` + +Example 3: + +```text +Input: people = [3,5,3,4], limit = 5 +Output: 4 +Explanation: 4 boats (3), (3), (4), (5) +``` + +Note: + +1. 1 <=people.length <= 50000 +1. 1 <= people[i] <=limit <= 30000 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0881.boats-to-save-people/boats-to-save-people.go b/Algorithms/0881.boats-to-save-people/boats-to-save-people.go new file mode 100755 index 000000000..3d1d401b1 --- /dev/null +++ b/Algorithms/0881.boats-to-save-people/boats-to-save-people.go @@ -0,0 +1,29 @@ +package problem0881 + +import ( + "sort" +) + +func numRescueBoats(people []int, limit int) int { + sort.Ints(people) + + thin, fat := 0, len(people)-1 + + res := 0 + + for thin <= fat { + // 如果,队列中最瘦的人,也可以上船的话,就跟上去 + if people[thin]+people[fat] <= limit { + thin++ + } + // 队列中,最胖的人肯定要上船 + fat-- + res++ + } + + return res +} + +// 首先看到 people.length <= 50000 就应该知道不可能使用动态规划。 +// 然后,还要注意到一个关键条件:每艘船只能坐两个人。 +// 可以使用贪心算法做 diff --git a/Algorithms/0881.boats-to-save-people/boats-to-save-people_test.go b/Algorithms/0881.boats-to-save-people/boats-to-save-people_test.go new file mode 100755 index 000000000..92816579d --- /dev/null +++ b/Algorithms/0881.boats-to-save-people/boats-to-save-people_test.go @@ -0,0 +1,71 @@ +package problem0881 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + people []int + limit int + ans int +}{ + + { + []int{2, 49, 10, 7, 11, 41, 47, 2, 22, 6, 13, 12, 33, 18, 10, 26, 2, 6, 50, 10}, + 50, + 11, + }, + + { + []int{1, 3, 3, 4}, + 5, + 3, + }, + + { + []int{2, 4}, + 5, + 2, + }, + + { + []int{1, 2}, + 3, + 1, + }, + + { + []int{3, 2, 2, 1}, + 3, + 3, + }, + + { + []int{3, 5, 3, 4}, + 5, + 4, + }, + + // 可以有多个 testcase +} + +func Test_numRescueBoats(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, numRescueBoats(tc.people, tc.limit), "输入:%v", tc) + } +} + +func Benchmark_numRescueBoats(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numRescueBoats(tc.people, tc.limit) + } + } +} diff --git a/Algorithms/0882.reachable-nodes-in-subdivided-graph/README.md b/Algorithms/0882.reachable-nodes-in-subdivided-graph/README.md new file mode 100755 index 000000000..5d42f4acb --- /dev/null +++ b/Algorithms/0882.reachable-nodes-in-subdivided-graph/README.md @@ -0,0 +1,50 @@ +# [882. Reachable Nodes In Subdivided Graph](https://leetcode.com/problems/reachable-nodes-in-subdivided-graph/) + +## 题目 + +Starting with anundirected graph (the "original graph") with nodes from 0 to N-1, subdivisions are made to some of the edges. + +The graph is given as follows: edges[k] is a list of integer pairs (i, j, n) such that (i, j) is an edge of the original graph, + +and n is the total number of new nodes on that edge. + +Then, the edge (i, j) is deleted from the original graph,nnew nodes (x_1, x_2, ..., x_n) are added to the original graph, + +and n+1 newedges (i, x_1), (x_1, x_2), (x_2, x_3), ..., (x_{n-1}, x_n), (x_n, j)are added to the originalgraph. + +Now, you start at node 0from the original graph, and in each move, you travel along oneedge. + +Return how many nodes you can reach in at most M moves. + +Example 1: + +```text +Input: edges = [[0,1,10],[0,2,1],[1,2,2]], M = 6, N = 3 +Output: 13 +Explanation: +The nodes that are reachable in the final graph after M = 6 moves are indicated below. +``` + +![original-to-final](origfinal.png) + +Example 2: + +```text +Input: edges = [[0,1,4],[1,2,6],[0,2,8],[1,3,1]], M = 10, N = 4 +Output: 23 +``` + +Note: + +1. 0 <= edges.length <= 10000 +1. 0 <= edges[i][0] 0 { + m := pq[0][0] + i := pq[0][1] + heap.Pop(&pq) + + if seen[i] { + continue + } + + seen[i] = true + maxRemainMoves[i] = m + res++ // 收获 edge 端点 i + + for _, j := range nextTo[i] { + if seen[j] { + continue + } + n := nodes[encode(i, j)] + jRemainMoves := m - n - 1 + if jRemainMoves >= 0 { + // 如果可以在 M 步内到达 j + heap.Push(&pq, []int{jRemainMoves, j}) + } + } + } + + /**统计 edge 上的点 */ + for _, e := range edges { + i, j, n := e[0], e[1], e[2] + mi := maxRemainMoves[i] // 表示达到 i 点后,最多还可以走 mi 步 + mj := maxRemainMoves[j] // 表示达到 j 点后,最多还可以走 mj 步 + // 如果 mi + mj >= n, 则 edge(i,j) 中间的 n 个点都可以被走到 + // 否则 edge(i,j) 中只有 mi+mj 个点被走到 + res += min(mi+mj, n) + } + + return res +} + +func encode(i, j int) int { + if i > j { + i, j = j, i + } + return i<<16 | j +} + +// PQ implements heap.Interface and holds entries. +type PQ [][]int + +func (pq PQ) Len() int { return len(pq) } + +func (pq PQ) Less(i, j int) bool { + return pq[i][0] > pq[j][0] +} + +func (pq PQ) Swap(i, j int) { + pq[i], pq[j] = pq[j], pq[i] +} + +// Push 往 pq 中放 entry +func (pq *PQ) Push(x interface{}) { + temp := x.([]int) + *pq = append(*pq, temp) +} + +// Pop 从 pq 中取出最优先的 entry +func (pq *PQ) Pop() interface{} { + temp := (*pq)[len(*pq)-1] + *pq = (*pq)[0 : len(*pq)-1] + return temp +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0882.reachable-nodes-in-subdivided-graph/reachable-nodes-in-subdivided-graph_test.go b/Algorithms/0882.reachable-nodes-in-subdivided-graph/reachable-nodes-in-subdivided-graph_test.go new file mode 100755 index 000000000..bb454ef00 --- /dev/null +++ b/Algorithms/0882.reachable-nodes-in-subdivided-graph/reachable-nodes-in-subdivided-graph_test.go @@ -0,0 +1,78 @@ +package problem0882 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + edges [][]int + M int + N int + ans int +}{ + + { + [][]int{{3, 4, 8}, {0, 1, 3}, {1, 4, 0}, {1, 2, 3}, {0, 3, 2}, {0, 4, 10}, {1, 3, 3}, {2, 4, 3}, {2, 3, 3}, {0, 2, 10}}, + 7, + 5, + 43, + }, + + { + [][]int{{4, 5, 21}, {2, 9, 19}, {5, 9, 12}, {3, 8, 17}, {4, 9, 2}, {1, 2, 19}, {2, 8, 6}, {8, 9, 20}, {3, 5, 16}, {5, 6, 13}, {0, 8, 13}, {5, 8, 1}, {0, 9, 1}, {6, 8, 0}, {1, 3, 20}, {7, 9, 3}, {6, 9, 3}, {1, 9, 10}, {5, 7, 25}, {3, 6, 23}, {4, 6, 8}, {4, 7, 21}, {0, 5, 2}, {0, 6, 10}, {4, 8, 15}}, + 20, + 10, + 282, + }, + + { + [][]int{{1, 2, 5}, {0, 3, 3}, {1, 3, 2}, {2, 3, 4}, {0, 4, 1}}, + 7, + 5, + 13, + }, + + { + [][]int{{1, 2, 4}, {1, 4, 5}, {1, 3, 1}, {2, 3, 4}, {3, 4, 5}}, + 17, + 5, + 1, + }, + + { + [][]int{{0, 1, 10}, {0, 2, 1}, {1, 2, 2}}, + 6, + 3, + 13, + }, + + { + [][]int{{0, 1, 4}, {1, 2, 6}, {0, 2, 8}, {1, 3, 1}}, + 10, + 4, + 23, + }, + + // 可以有多个 testcase +} + +func Test_reachableNodes(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, reachableNodes(tc.edges, tc.M, tc.N), "输入:%v", tc) + } +} + +func Benchmark_reachableNodes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + reachableNodes(tc.edges, tc.M, tc.N) + } + } +} diff --git a/Algorithms/0883.projection-area-of-3d-shapes/README.md b/Algorithms/0883.projection-area-of-3d-shapes/README.md new file mode 100755 index 000000000..6cf2101cc --- /dev/null +++ b/Algorithms/0883.projection-area-of-3d-shapes/README.md @@ -0,0 +1,63 @@ +# [883. Projection Area of 3D Shapes](https://leetcode.com/problems/projection-area-of-3d-shapes/) + +## 题目 + +On aN*N grid, we place some1 * 1 * 1cubes that are axis-aligned with the x, y, and z axes. + +Each valuev = grid[i][j]represents a tower ofvcubes placed on top of grid cell (i, j). + +Now we view theprojectionof these cubesonto the xy, yz, and zx planes. + +A projection is like a shadow, thatmaps our 3 dimensional figure to a 2 dimensional plane. + +Here, we are viewing the "shadow" when looking at the cubes from the top, the front, and the side. + +Return the total area of all three projections. + +Example 1: + +```text +Input: [[2]] +Output: 5 +``` + +Example 2: + +```text +Input: [[1,2],[3,4]] +Output: 17 +Explanation: +Here are the three projections ("shadows") of the shape made with each axis-aligned plane. +``` + +![shadow](shadow.png) + +Example 3: + +```text +Input: [[1,0],[0,2]] +Output: 8 +``` + +Example 4: + +```text +Input: [[1,1,1],[1,0,1],[1,1,1]] +Output: 14 +``` + +Example 5: + +```text +Input: [[2,2,2],[2,1,2],[2,2,2]] +Output: 21 +``` + +Note: + +1. 1 <= grid.length = grid[0].length<= 50 +1. 0 <= grid[i][j] <= 50 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0883.projection-area-of-3d-shapes/projection-area-of-3d-shapes.go b/Algorithms/0883.projection-area-of-3d-shapes/projection-area-of-3d-shapes.go new file mode 100755 index 000000000..a4b62060d --- /dev/null +++ b/Algorithms/0883.projection-area-of-3d-shapes/projection-area-of-3d-shapes.go @@ -0,0 +1,31 @@ +package problem0883 + +func projectionArea(grid [][]int) int { + xs := [51]int{} + ys := [51]int{} + res := 0 + + for i, line := range grid { + for j, k := range line { + if k == 0 { + continue + } + res++ + xs[i] = max(xs[i], k) + ys[j] = max(ys[j], k) + } + } + + for i := range xs { + res += xs[i] + ys[i] + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0883.projection-area-of-3d-shapes/projection-area-of-3d-shapes_test.go b/Algorithms/0883.projection-area-of-3d-shapes/projection-area-of-3d-shapes_test.go new file mode 100755 index 000000000..c1c5146c4 --- /dev/null +++ b/Algorithms/0883.projection-area-of-3d-shapes/projection-area-of-3d-shapes_test.go @@ -0,0 +1,59 @@ +package problem0883 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + ans int +}{ + + { + [][]int{{2}}, + 5, + }, + + { + [][]int{{1, 2}, {3, 4}}, + 17, + }, + + { + [][]int{{1, 0}, {0, 2}}, + 8, + }, + + { + [][]int{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}, + 14, + }, + + { + [][]int{{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}, + 21, + }, + + // 可以有多个 testcase +} + +func Test_projectionArea(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, projectionArea(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_projectionArea(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + projectionArea(tc.grid) + } + } +} diff --git a/Algorithms/0883.projection-area-of-3d-shapes/shadow.png b/Algorithms/0883.projection-area-of-3d-shapes/shadow.png new file mode 100644 index 000000000..6f0c5d48e Binary files /dev/null and b/Algorithms/0883.projection-area-of-3d-shapes/shadow.png differ diff --git a/Algorithms/0884.uncommon-words-from-two-sentences/README.md b/Algorithms/0884.uncommon-words-from-two-sentences/README.md new file mode 100755 index 000000000..2b15334c1 --- /dev/null +++ b/Algorithms/0884.uncommon-words-from-two-sentences/README.md @@ -0,0 +1,35 @@ +# [884. Uncommon Words from Two Sentences](https://leetcode.com/problems/uncommon-words-from-two-sentences/) + +## 题目 + +We are given two sentences A and B. (A sentenceis a string of space separated words. Each word consists only of lowercase letters.) + +A word is uncommonif it appears exactly once in one of the sentences, and does not appear in the other sentence. + +Return a list of all uncommon words. + +You may return the list in any order. + +Example 1: + +```text +Input: A = "this apple is sweet", B = "this apple is sour" +Output: ["sweet","sour"] +``` + +Example 2: + +```text +Input: A = "apple apple", B = "banana" +Output: ["banana"] +``` + +Note: + +1. 0 <= A.length <= 200 +1. 0 <= B.length <= 200 +1. A and B both contain only spaces and lowercase letters. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0884.uncommon-words-from-two-sentences/uncommon-words-from-two-sentences.go b/Algorithms/0884.uncommon-words-from-two-sentences/uncommon-words-from-two-sentences.go new file mode 100755 index 000000000..bfea0d0a3 --- /dev/null +++ b/Algorithms/0884.uncommon-words-from-two-sentences/uncommon-words-from-two-sentences.go @@ -0,0 +1,28 @@ +package problem0884 + +import ( + "sort" + "strings" +) + +func uncommonFromSentences(A string, B string) []string { + tmp := strings.Split(A, " ") + tmp = append(tmp, strings.Split(B, " ")...) + + // 排序完成后, "" 会在首, "~" 会在尾 + // 安排这两个不相干的单词进入 tmp ,有利于简化后面的判断逻辑 + tmp = append(tmp, "", "~") + sort.Strings(tmp) + + size := len(tmp) + + res := make([]string, 0, size) + + for i := 1; i+1 < size; i++ { + if tmp[i-1] != tmp[i] && tmp[i] != tmp[i+1] { + res = append(res, tmp[i]) + } + } + + return res +} diff --git a/Algorithms/0884.uncommon-words-from-two-sentences/uncommon-words-from-two-sentences_test.go b/Algorithms/0884.uncommon-words-from-two-sentences/uncommon-words-from-two-sentences_test.go new file mode 100755 index 000000000..96a6ca8cd --- /dev/null +++ b/Algorithms/0884.uncommon-words-from-two-sentences/uncommon-words-from-two-sentences_test.go @@ -0,0 +1,51 @@ +package problem0884 + +import ( + "fmt" + "sort" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A string + B string + ans []string +}{ + + { + "this apple is sweet", + "this apple is sour", + []string{"sweet", "sour"}, + }, + + { + "apple apple", + "banana", + []string{"banana"}, + }, + + // 可以有多个 testcase +} + +func Test_uncommonFromSentences(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + sort.Strings(tc.ans) + actual := uncommonFromSentences(tc.A, tc.B) + sort.Strings(actual) + ast.Equal(tc.ans, actual, "输入:%v", tc) + } +} + +func Benchmark_uncommonFromSentences(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + uncommonFromSentences(tc.A, tc.B) + } + } +} diff --git a/Algorithms/0885.spiral-matrix-iii/README.md b/Algorithms/0885.spiral-matrix-iii/README.md new file mode 100755 index 000000000..12d088ed1 --- /dev/null +++ b/Algorithms/0885.spiral-matrix-iii/README.md @@ -0,0 +1,44 @@ +# [885. Spiral Matrix III](https://leetcode.com/problems/spiral-matrix-iii/) + +## 题目 + +On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east. + +Here, the north-west corner of the grid is at thefirst row and column, and the south-east corner of the grid is at the last row and column. + +Now, we walk in a clockwise spiral shape to visit every position in this grid. + +Whenever we would move outside the boundary of the grid, we continue our walk outside the grid (but may return to the grid boundary later.) + +Eventually, we reach all R * C spaces of the grid. + +Return a list of coordinates representing the positions of the grid in the order they were visited. + +Example 1: + +```text +Input: R = 1, C = 4, r0 = 0, c0 = 0 +Output: [[0,0],[0,1],[0,2],[0,3]] +``` + +![Example 1 picture](p1.png) + +Example 2: + +```text +Input: R = 5, C = 6, r0 = 1, c0 = 4 +Output: [[1,4],[1,5],[2,5],[2,4],[2,3],[1,3],[0,3],[0,4],[0,5],[3,5],[3,4],[3,3],[3,2],[2,2],[1,2],[0,2],[4,5],[4,4],[4,3],[4,2],[4,1],[3,1],[2,1],[1,1],[0,1],[4,0],[3,0],[2,0],[1,0],[0,0]] +``` + +![Example 2 picture](p2.png) + +Note: + +1. 1 <= R <= 100 +1. 1 <= C <= 100 +1. 0 <= r0 < R +1. 0 <= c0 < C + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0885.spiral-matrix-iii/p1.png b/Algorithms/0885.spiral-matrix-iii/p1.png new file mode 100644 index 000000000..b7664fcf5 Binary files /dev/null and b/Algorithms/0885.spiral-matrix-iii/p1.png differ diff --git a/Algorithms/0885.spiral-matrix-iii/p2.png b/Algorithms/0885.spiral-matrix-iii/p2.png new file mode 100644 index 000000000..6fbd6734d Binary files /dev/null and b/Algorithms/0885.spiral-matrix-iii/p2.png differ diff --git a/Algorithms/0885.spiral-matrix-iii/spiral-matrix-iii.go b/Algorithms/0885.spiral-matrix-iii/spiral-matrix-iii.go new file mode 100755 index 000000000..345fc6cf2 --- /dev/null +++ b/Algorithms/0885.spiral-matrix-iii/spiral-matrix-iii.go @@ -0,0 +1,35 @@ +package problem0885 + +func spiralMatrixIII(R, C, x, y int) [][]int { + moves := R * C + + res := make([][]int, 1, moves) + res[0] = []int{x, y} + moves-- + + round := 2 + dx, dy := 0, 1 + + for moves > 0 { + for m := round / 2; m > 0; m-- { + x += dx + y += dy + if 0 <= x && x < R && 0 <= y && y < C { + res = append(res, []int{x, y}) + moves-- + } + } + round++ + /** + * 从向西开始,(dx,dy) 的变化如下 + * (0, 1) + * (1, 0) + * (0,-1) + * (-1,0) + * dx, dy = dy, -dx 可以实现以上变化 + */ + dx, dy = dy, -dx + } + + return res +} diff --git a/Algorithms/0885.spiral-matrix-iii/spiral-matrix-iii_test.go b/Algorithms/0885.spiral-matrix-iii/spiral-matrix-iii_test.go new file mode 100755 index 000000000..bf08e2dc1 --- /dev/null +++ b/Algorithms/0885.spiral-matrix-iii/spiral-matrix-iii_test.go @@ -0,0 +1,53 @@ +package problem0885 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + R int + C int + r0 int + c0 int + ans [][]int +}{ + + { + 1, + 4, + 0, + 0, + [][]int{{0, 0}, {0, 1}, {0, 2}, {0, 3}}, + }, + + { + 5, + 6, + 1, + 4, + [][]int{{1, 4}, {1, 5}, {2, 5}, {2, 4}, {2, 3}, {1, 3}, {0, 3}, {0, 4}, {0, 5}, {3, 5}, {3, 4}, {3, 3}, {3, 2}, {2, 2}, {1, 2}, {0, 2}, {4, 5}, {4, 4}, {4, 3}, {4, 2}, {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 1}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}}, + }, + + // 可以有多个 testcase +} + +func Test_spiralMatrixIII(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, spiralMatrixIII(tc.R, tc.C, tc.r0, tc.c0), "输入:%v", tc) + } +} + +func Benchmark_spiralMatrixIII(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + spiralMatrixIII(tc.R, tc.C, tc.r0, tc.c0) + } + } +} diff --git a/Algorithms/0886.possible-bipartition/README.md b/Algorithms/0886.possible-bipartition/README.md new file mode 100755 index 000000000..ba31eae58 --- /dev/null +++ b/Algorithms/0886.possible-bipartition/README.md @@ -0,0 +1,45 @@ +# [886. Possible Bipartition](https://leetcode.com/problems/possible-bipartition/) + +## 题目 + +Given a set of Npeople (numbered 1, 2, ..., N), we would like to split everyone into two groups of any size. + +Each person may dislike some other people, and they should not go into the same group. + +Formally, if dislikes[i] = [a, b], it means it is not allowed to put the people numbered a and b into the same group. + +Return trueif and only if it is possible to split everyone into two groups in this way. + +Example 1: + +```text +Input: N = 4, dislikes = [[1,2],[1,3],[2,4]] +Output: true +Explanation: group1 [1,4], group2 [2,3] +``` + +Example 2: + +```text +Input: N = 3, dislikes = [[1,2],[1,3],[2,3]] +Output: false +``` + +Example 3: + +```text +Input: N = 5, dislikes = [[1,2],[2,3],[3,4],[4,5],[1,5]] +Output: false +``` + +Note: + +1. 1 <= N <= 2000 +1. 0 <= dislikes.length <= 10000 +1. 1 <= dislikes[i][j] <= N +1. dislikes[i][0] < dislikes[i][1] +1. There does not exist i != j for which dislikes[i] == dislikes[j]. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0886.possible-bipartition/possible-bipartition.go b/Algorithms/0886.possible-bipartition/possible-bipartition.go new file mode 100755 index 000000000..d182fa846 --- /dev/null +++ b/Algorithms/0886.possible-bipartition/possible-bipartition.go @@ -0,0 +1,51 @@ +package problem0886 + +func possibleBipartition(N int, dislikes [][]int) bool { + /**转换 dislikes 到 diss + * 收集每个人 dislike 的所有人 + */ + diss := make([][]int, N+1) + for i := range diss { + diss[i] = make([]int, 0, 10) + } + for _, dl := range dislikes { + a, b := dl[0], dl[1] + diss[a] = append(diss[a], b) + diss[b] = append(diss[b], a) + } + + group := make([]int, N+1) + flag := 1 + + for i := 1; i <= N; i++ { + if group[i] != 0 { + continue + } + + /**bfs */ + + group[i] = flag + queue := make([]int, 1, N+1) + queue[0] = i + + for len(queue) > 0 { + flag = -flag + size := len(queue) + for j := 0; j < size; j++ { + qj := queue[j] + for _, p := range diss[qj] { + if group[p] == 0 { + group[p] = flag + queue = append(queue, p) + } else if group[p] != flag { + return false + } + } + } + queue = queue[size:] + } + + } + + return true +} diff --git a/Algorithms/0886.possible-bipartition/possible-bipartition_test.go b/Algorithms/0886.possible-bipartition/possible-bipartition_test.go new file mode 100755 index 000000000..c5aa2ac0c --- /dev/null +++ b/Algorithms/0886.possible-bipartition/possible-bipartition_test.go @@ -0,0 +1,53 @@ +package problem0886 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + dislikes [][]int + ans bool +}{ + + { + 4, + [][]int{{1, 2}, {1, 3}, {2, 4}}, + true, + }, + + { + 3, + [][]int{{1, 2}, {1, 3}, {2, 3}}, + false, + }, + + { + 5, + [][]int{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {1, 5}}, + false, + }, + + // 可以有多个 testcase +} + +func Test_possibleBipartition(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, possibleBipartition(tc.N, tc.dislikes), "输入:%v", tc) + } +} + +func Benchmark_possibleBipartition(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + possibleBipartition(tc.N, tc.dislikes) + } + } +} diff --git a/Algorithms/0887.super-egg-drop/README.md b/Algorithms/0887.super-egg-drop/README.md new file mode 100755 index 000000000..f203014cd --- /dev/null +++ b/Algorithms/0887.super-egg-drop/README.md @@ -0,0 +1,50 @@ +# [887. Super Egg Drop](https://leetcode.com/problems/super-egg-drop/) + +## 题目 + +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 itagain. + +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 (with1 <= X <= N). + +Your goal is to knowwith certaintywhat the value of F is. + +What is the minimum number of moves that you need to know with certaintywhat F is, regardless of the initial value of F? + +Example 1: + +```text +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: + +```text +Input: K = 2, N = 6 +Output: 3 +``` + +Example 3: + +```text +Input: K = 3, N = 14 +Output: 4 +``` + +Note: + +1. 1 <= K <= 100 +1. 1 <= N <= 10000 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0887.super-egg-drop/super-egg-drop.go b/Algorithms/0887.super-egg-drop/super-egg-drop.go new file mode 100755 index 000000000..f3951dc77 --- /dev/null +++ b/Algorithms/0887.super-egg-drop/super-egg-drop.go @@ -0,0 +1,24 @@ +package problem0887 + +func superEggDrop(K, N int) int { + moves := 0 + dp := [101]int{} // 1 <= K <= 100 + // dp[i] = n 表示, i 个鸡蛋,利用 moves 次移动,最多可以检测 n 层楼 + for dp[K] < N { + for i := K; i > 0; i-- { + dp[i] += dp[i-1] + 1 + // 以上计算式,是从以下转移方程简化而来 + // dp[moves][k] = 1 + dp[moves-1][k-1] + dp[moves-1][k] + // 假设 dp[moves-1][k-1] = n0, dp[moves-1][k] = n1 + // 首先检测,从第 n0+1 楼丢下鸡蛋会不会破。 + // 如果鸡蛋破了,F 一定是在 [1:n0] 楼中, + // 利用剩下的 moves-1 次机会和 k-1 个鸡蛋,可以把 F 找出来。 + // 如果鸡蛋没破,假如 F 在 [n0+2:n0+n1+1] 楼中 + // 利用剩下的 moves-1 次机会和 k 个鸡蛋把,也可以把 F 找出来。 + // 所以,当有 moves 个放置机会和 k 个鸡蛋的时候 + // F 在 [1, n0+n1+1] 中的任何一楼,都能够被检测出来。 + } + moves++ + } + return moves +} diff --git a/Algorithms/0887.super-egg-drop/super-egg-drop_test.go b/Algorithms/0887.super-egg-drop/super-egg-drop_test.go new file mode 100755 index 000000000..e617278b9 --- /dev/null +++ b/Algorithms/0887.super-egg-drop/super-egg-drop_test.go @@ -0,0 +1,71 @@ +package problem0887 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + K int + N int + ans int +}{ + + { + 2, + 10000, + 141, + }, + + { + 5, + 10000, + 18, + }, + + { + 100, + 10000, + 14, + }, + + { + 1, + 2, + 2, + }, + + { + 2, + 6, + 3, + }, + + { + 3, + 14, + 4, + }, + + // 可以有多个 testcase +} + +func Test_superEggDrop(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, superEggDrop(tc.K, tc.N), "输入:%v", tc) + } +} + +func Benchmark_superEggDrop(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + superEggDrop(tc.K, tc.N) + } + } +} diff --git a/Algorithms/0888.fair-candy-swap/README.md b/Algorithms/0888.fair-candy-swap/README.md new file mode 100755 index 000000000..d5429a60d --- /dev/null +++ b/Algorithms/0888.fair-candy-swap/README.md @@ -0,0 +1,52 @@ +# [888. Fair Candy Swap](https://leetcode.com/problems/fair-candy-swap/) + +## 题目 + +Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has. + +Since they are friends, they would like to exchange one candy bar each so that after the exchange, they both have the same totalamount of candy. (The total amount of candya person has is the sum of the sizes of candybars they have.) + +Return an integer array answhere ans[0] is the size of the candy bar that Alice must exchange, and ans[1] is the size of the candy bar that Bob must exchange. + +If there are multiple answers, you may return any one of them. It is guaranteed an answer exists. + +Example 1: + +```text +Input: A = [1,1], B = [2,2] +Output: [1,2] +``` + +Example 2: + +```text +Input: A = [1,2], B = [2,3] +Output: [1,2] +``` + +Example 3: + +```text +Input: A = [2], B = [1,3] +Output: [2,3] +``` + +Example 4: + +```text +Input: A = [1,2,5], B = [2,4] +Output: [5,4] +``` + +Note: + +1. 1 <= A.length <= 10000 +1. 1 <= B.length <= 10000 +1. 1 <= A[i] <= 100000 +1. 1 <= B[i] <= 100000 +1. It is guaranteed that Alice and Bob have different total amounts ofcandy. +1. It is guaranteed there exists ananswer. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0888.fair-candy-swap/fair-candy-swap.go b/Algorithms/0888.fair-candy-swap/fair-candy-swap.go new file mode 100755 index 000000000..6fa89778a --- /dev/null +++ b/Algorithms/0888.fair-candy-swap/fair-candy-swap.go @@ -0,0 +1,28 @@ +package problem0888 + +func fairCandySwap(A []int, B []int) []int { + + sumA := 0 + isExist := make(map[int]bool, len(A)) + for _, a := range A { + sumA += a + isExist[a] = true + } + + sumB := 0 + for _, b := range B { + sumB += b + } + + halfDiff := (sumA - sumB) / 2 + + a, b := 0, 0 + for _, b = range B { + a = b + halfDiff + if isExist[a] { + break + } + } + + return []int{a, b} +} diff --git a/Algorithms/0888.fair-candy-swap/fair-candy-swap_test.go b/Algorithms/0888.fair-candy-swap/fair-candy-swap_test.go new file mode 100755 index 000000000..21e320dec --- /dev/null +++ b/Algorithms/0888.fair-candy-swap/fair-candy-swap_test.go @@ -0,0 +1,59 @@ +package problem0888 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + B []int + ans []int +}{ + + { + []int{1, 1}, + []int{2, 2}, + []int{1, 2}, + }, + + { + []int{1, 2}, + []int{2, 3}, + []int{1, 2}, + }, + + { + []int{2}, + []int{1, 3}, + []int{2, 3}, + }, + + { + []int{1, 2, 5}, + []int{2, 4}, + []int{5, 4}, + }, + + // 可以有多个 testcase +} + +func Test_fairCandySwap(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, fairCandySwap(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_fairCandySwap(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + fairCandySwap(tc.A, tc.B) + } + } +} diff --git a/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/README.md b/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/README.md new file mode 100755 index 000000000..8de0eeeba --- /dev/null +++ b/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/README.md @@ -0,0 +1,24 @@ +# [889. Construct Binary Tree from Preorder and Postorder Traversal](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/) + +## 题目 + +Return any binary tree that matches the given preorder and postorder traversals. + +Values in the traversalspre and postare distinctpositive integers. + +Example 1: + +```text +Input: pre = [1,2,4,5,3,6,7], post = [4,5,2,6,7,3,1] +Output: [1,2,3,4,5,6,7] +``` + +Note: + +1. 1 <= pre.length == post.length <= 30 +1. pre[] and post[]are both permutations of 1, 2, ..., pre.length. +1. It is guaranteed an answer exists. If there exists multiple answers, you can return any of them. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/construct-binary-tree-from-preorder-and-postorder-traversal.go b/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/construct-binary-tree-from-preorder-and-postorder-traversal.go new file mode 100755 index 000000000..c15eceeda --- /dev/null +++ b/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/construct-binary-tree-from-preorder-and-postorder-traversal.go @@ -0,0 +1,43 @@ +package problem0889 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is definited for a binary tree node. +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func constructFromPrePost(pre []int, post []int) *TreeNode { + size := len(pre) + + if size == 0 { + return nil + } + + res := &TreeNode{ + Val: pre[0], + } + + if size == 1 { + return res + } + + leftVal := pre[1] + // 查找 leftVal 在 post 中的索引号 + i := 0 + for ; i < size; i++ { + if post[i] == leftVal { + break + } + } + + res.Left = constructFromPrePost(pre[1:i+2], post[0:i+1]) + res.Right = constructFromPrePost(pre[i+2:], post[i+1:size-1]) + + return res +} diff --git a/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/construct-binary-tree-from-preorder-and-postorder-traversal_test.go b/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/construct-binary-tree-from-preorder-and-postorder-traversal_test.go new file mode 100755 index 000000000..379690833 --- /dev/null +++ b/Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal/construct-binary-tree-from-preorder-and-postorder-traversal_test.go @@ -0,0 +1,49 @@ +package problem0889 + +import ( + "fmt" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + pre []int + post []int + ans []int +}{ + + { + []int{1, 2, 4, 5, 3, 6}, + []int{4, 5, 2, 6, 3, 1}, + []int{1, 2, 3, 4, 5, 6}, + }, + + { + []int{1, 2, 4, 5, 3, 6, 7}, + []int{4, 5, 2, 6, 7, 3, 1}, + []int{1, 2, 3, 4, 5, 6, 7}, + }, + + // 可以有多个 testcase +} + +func Test_constructFromPrePost(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ans := kit.Tree2ints(constructFromPrePost(tc.pre, tc.post)) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_constructFromPrePost(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + constructFromPrePost(tc.pre, tc.post) + } + } +} diff --git a/Algorithms/0890.find-and-replace-pattern/README.md b/Algorithms/0890.find-and-replace-pattern/README.md new file mode 100755 index 000000000..627667d0c --- /dev/null +++ b/Algorithms/0890.find-and-replace-pattern/README.md @@ -0,0 +1,32 @@ +# [890. Find and Replace Pattern](https://leetcode.com/problems/find-and-replace-pattern/) + +## 题目 + +You have a list ofwords and a pattern, and you want to know which words in words matches the pattern. + +A word matches the pattern if there exists a permutation of letters p so that after replacing every letter x in the pattern with p(x), we get the desired word. + +(Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.) + +Return a list of the words in wordsthat match the given pattern. + +You may return the answer in any order. + +Example 1: + +```text +Input: words = ["abc","deq","mee","aqq","dkd","ccc"], pattern = "abb" +Output: ["mee","aqq"] +Explanation: "mee" matches the pattern because there is a permutation {a -> m, b -> e, ...}. +"ccc" does not match the pattern because {a -> c, b -> c, ...} is not a permutation, +since a and b map to the same letter. +``` + +Note: + +1. 1 <= words.length <= 50 +1. 1 <= pattern.length = words[i].length<= 20 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0890.find-and-replace-pattern/find-and-replace-pattern.go b/Algorithms/0890.find-and-replace-pattern/find-and-replace-pattern.go new file mode 100755 index 000000000..a9062e5ec --- /dev/null +++ b/Algorithms/0890.find-and-replace-pattern/find-and-replace-pattern.go @@ -0,0 +1,29 @@ +package problem0890 + +func findAndReplacePattern(words []string, pattern string) []string { + np := normalize(pattern) + res := make([]string, 0, len(words)) + for _, w := range words { + if normalize(w) == np { + res = append(res, w) + } + } + return res +} + +// 把 str 标准化 +func normalize(str string) string { + m := make(map[rune]byte, len(str)) + /**按照字符在 s 中第一次出现的顺序,依次映射到 a,b,c,... */ + for _, c := range str { + if _, ok := m[c]; !ok { + m[c] = byte(len(m)) + 'a' + } + } + /**按照字符的映射关系,映射 s 到 res */ + res := make([]byte, len(str)) + for i, c := range str { + res[i] = m[c] + } + return string(res) +} diff --git a/Algorithms/0890.find-and-replace-pattern/find-and-replace-pattern_test.go b/Algorithms/0890.find-and-replace-pattern/find-and-replace-pattern_test.go new file mode 100755 index 000000000..627deb95b --- /dev/null +++ b/Algorithms/0890.find-and-replace-pattern/find-and-replace-pattern_test.go @@ -0,0 +1,53 @@ +package problem0890 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + words []string + pattern string + ans []string +}{ + + { + []string{"abc", "deq", ",ee", "aqq", "dkd", "ccc"}, + "abb", + []string{",ee", "aqq"}, + }, + + { + []string{"abc", "deq", "Mee", "aqq", "dkd", "ccc"}, + "abb", + []string{"Mee", "aqq"}, + }, + + { + []string{"abc", "deq", "mee", "aqq", "dkd", "ccc"}, + "abb", + []string{"mee", "aqq"}, + }, + + // 可以有多个 testcase +} + +func Test_findAndReplacePattern(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, findAndReplacePattern(tc.words, tc.pattern), "输入:%v", tc) + } +} + +func Benchmark_findAndReplacePattern(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + findAndReplacePattern(tc.words, tc.pattern) + } + } +} diff --git a/Algorithms/0891.sum-of-subsequence-widths/README.md b/Algorithms/0891.sum-of-subsequence-widths/README.md new file mode 100755 index 000000000..0ec0c620b --- /dev/null +++ b/Algorithms/0891.sum-of-subsequence-widths/README.md @@ -0,0 +1,31 @@ +# [891. Sum of Subsequence Widths](https://leetcode.com/problems/sum-of-subsequence-widths/) + +## 题目 + +Given an array of integers A, consider all non-empty subsequences of A. + +For any sequence S, let thewidthof S be the difference between the maximum and minimum element of S. + +Return the sum of the widths of all subsequences of A. + +As the answer may be very large, return the answer modulo 10^9 + 7. + +Example 1: + +```text +Input: [2,1,3] +Output: 6 +Explanation: +Subsequences are [1], [2], [3], [2,1], [2,3], [1,3], [2,1,3]. +The corresponding widths are 0, 0, 0, 1, 1, 2, 2. +The sum of these widths is 6. +``` + +Note: + +1. 1 <= A.length <= 20000 +1. 1 <= A[i] <= 20000 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0891.sum-of-subsequence-widths/sum-of-subsequence-widths.go b/Algorithms/0891.sum-of-subsequence-widths/sum-of-subsequence-widths.go new file mode 100755 index 000000000..8542caa14 --- /dev/null +++ b/Algorithms/0891.sum-of-subsequence-widths/sum-of-subsequence-widths.go @@ -0,0 +1,33 @@ +package problem0891 + +import ( + "sort" +) + +const mod = int(1e9 + 7) + +func sumSubseqWidths(a []int) int { + sort.Ints(a) + + n := len(a) + res := 0 + times := 1 + for i := 0; i < n; i++ { + res += (a[i] - a[n-i-1]) * times + res %= mod + times = (times << 1) % mod + } + + return res +} + +/** + * https://leetcode.com/problems/sum-of-subsequence-widths/discuss/161267/C++Java1-line-Python-Sort-and-One-Pass + * For A[i]: + * There are i smaller numbers, + * so there are 2 ^ i sequences in which A[i] is maximum. + * we should do res += A[i] * (2 ^ i) + * There are n - i - 1 bigger numbers, + * so there are 2 ^ (n - i - 1) sequences in which A[i] is minimum. + * we should do res -= A[i] * 2 ^ (n - i - 1) + */ diff --git a/Algorithms/0891.sum-of-subsequence-widths/sum-of-subsequence-widths_test.go b/Algorithms/0891.sum-of-subsequence-widths/sum-of-subsequence-widths_test.go new file mode 100755 index 000000000..e27e00e35 --- /dev/null +++ b/Algorithms/0891.sum-of-subsequence-widths/sum-of-subsequence-widths_test.go @@ -0,0 +1,59 @@ +package problem0891 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{1, 10001}, + 10000, + }, + + { + []int{96, 87, 191, 197, 40, 101, 108, 35, 169, 50, 168, 182, 95, 80, 144, 43, 18, 60, 174, 13, 77, 173, 38, 46, 80, 117, 13, 19, 11, 6, 13, 118, 39, 80, 171, 36, 86, 156, 165, 190, 53, 49, 160, 192, 57, 42, 97, 35, 124, 200, 84, 70, 145, 180, 54, 141, 159, 42, 66, 66, 25, 95, 24, 136, 140, 159, 71, 131, 5, 140, 115, 76, 151, 137, 63, 47, 69, 164, 60, 172, 153, 183, 6, 70, 40, 168, 133, 45, 116, 188, 20, 52, 70, 156, 44, 27, 124, 59, 42, 172}, + 136988321, + }, + + { + []int{160, 192, 57, 42, 97, 35, 124, 200, 84, 70, 145, 180, 54, 141, 159, 42, 66, 66, 25, 95, 24, 136, 140, 159, 71, 131, 5, 140, 115, 76, 151, 137, 63, 47, 69, 164, 60, 172, 153, 183, 6, 70, 40, 168, 133, 45, 116, 188, 20, 52, 70, 156, 44, 27, 124, 59, 42, 172}, + 350094743, + }, + + { + []int{2, 1, 3, 4}, + 23, + }, + + { + []int{2, 1, 3}, + 6, + }, + + // 可以有多个 testcase +} + +func Test_sumSubseqWidths(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, sumSubseqWidths(tc.A), "输入:%v", tc) + } +} + +func Benchmark_sumSubseqWidths(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + sumSubseqWidths(tc.A) + } + } +} diff --git a/Algorithms/0892.surface-area-of-3d-shapes/README.md b/Algorithms/0892.surface-area-of-3d-shapes/README.md new file mode 100755 index 000000000..3dbb060aa --- /dev/null +++ b/Algorithms/0892.surface-area-of-3d-shapes/README.md @@ -0,0 +1,53 @@ +# [892. Surface Area of 3D Shapes](https://leetcode.com/problems/surface-area-of-3d-shapes/) + +## 题目 + +On a `N*N` grid, we place some `1 * 1 * 1` cubes. + +Each value `v = grid[i][j]` represents a tower ofvcubes placed on top of grid cell(i, j). + +Return the total surface area of the resulting shapes. + +Example 1: + +```text +Input: [[2]] +Output: 10 +``` + +Example 2: + +```text +Input: [[1,2],[3,4]] +Output: 34 +``` + +Example 3: + +```text +Input: [[1,0],[0,2]] +Output: 16 +``` + +Example 4: + +```text +Input: [[1,1,1],[1,0,1],[1,1,1]] +Output: 32 +``` + +Example 5: + +```text +Input: [[2,2,2],[2,1,2],[2,2,2]] +Output: 46 +``` + +Note: + +- 1 <= N <= 50 +- 0 <= grid[i][j] <= 50 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0892.surface-area-of-3d-shapes/surface-area-of-3d-shapes.go b/Algorithms/0892.surface-area-of-3d-shapes/surface-area-of-3d-shapes.go new file mode 100755 index 000000000..ea38033a8 --- /dev/null +++ b/Algorithms/0892.surface-area-of-3d-shapes/surface-area-of-3d-shapes.go @@ -0,0 +1,29 @@ +package problem0892 + +func surfaceArea(grid [][]int) int { + N := len(grid) + res := 0 + for i := 0; i < N; i++ { + for j := 0; j < N; j++ { + v := grid[i][j] + if v == 0 { + continue + } + res += v*6 - (v-1)*2 /** 单独一个立柱的外表面面积 */ + if j+1 < N { + res -= min(v, grid[i][j+1]) * 2 /** 与右侧立柱贴合的面积 */ + } + if i+1 < N { + res -= min(v, grid[i+1][j]) * 2 /** 与下侧立柱贴合的面积 */ + } + } + } + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0892.surface-area-of-3d-shapes/surface-area-of-3d-shapes_test.go b/Algorithms/0892.surface-area-of-3d-shapes/surface-area-of-3d-shapes_test.go new file mode 100755 index 000000000..3be06b3d8 --- /dev/null +++ b/Algorithms/0892.surface-area-of-3d-shapes/surface-area-of-3d-shapes_test.go @@ -0,0 +1,59 @@ +package problem0892 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + ans int +}{ + + { + [][]int{{1, 0}, {0, 2}}, + 16, + }, + + { + [][]int{{2}}, + 10, + }, + + { + [][]int{{1, 2}, {3, 4}}, + 34, + }, + + { + [][]int{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}, + 32, + }, + + { + [][]int{{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}, + 46, + }, + + // 可以有多个 testcase +} + +func Test_surfaceArea(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, surfaceArea(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_surfaceArea(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + surfaceArea(tc.grid) + } + } +} diff --git a/Algorithms/0893.groups-of-special-equivalent-strings/README.md b/Algorithms/0893.groups-of-special-equivalent-strings/README.md new file mode 100755 index 000000000..e1acc3926 --- /dev/null +++ b/Algorithms/0893.groups-of-special-equivalent-strings/README.md @@ -0,0 +1,56 @@ +# [893. Groups of Special-Equivalent Strings](https://leetcode.com/problems/groups-of-special-equivalent-strings/) + +## 题目 + +You are given an array A of strings. + +Two strings S and T arespecial-equivalentif after any number of moves, S == T. + +A move consists of choosing two indices i and j with i % 2 == j % 2, and swapping S[i] with S[j]. + +Now, a group of special-equivalent strings from Ais anon-empty subset S of Asuch that any string not in Sis not special-equivalent with any string in S. + +Return the number of groups of special-equivalent strings from A. + +Example 1: + +```text +Input: ["a","b","c","a","c","c"] +Output: 3 +Explanation: 3 groups ["a","a"], ["b"], ["c","c","c"] +``` + +Example 2: + +```text +Input: ["aa","bb","ab","ba"] +Output: 4 +Explanation: 4 groups ["aa"], ["bb"], ["ab"], ["ba"] +``` + +Example 3: + +```text +Input: ["abc","acb","bac","bca","cab","cba"] +Output: 3 +Explanation: 3 groups ["abc","cba"], ["acb","bca"], ["bac","cab"] +``` + +Example 4: + +```text +Input: ["abcd","cdab","adcb","cbad"] +Output: 1 +Explanation: 1 group ["abcd","cdab","adcb","cbad"] +``` + +Note: + +1. 1 <= A.length <= 1000 +1. 1 <= A[i].length <= 20 +1. All A[i] have the same length. +1. All A[i] consist of only lowercase letters. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0893.groups-of-special-equivalent-strings/groups-of-special-equivalent-strings.go b/Algorithms/0893.groups-of-special-equivalent-strings/groups-of-special-equivalent-strings.go new file mode 100755 index 000000000..8a670dfe3 --- /dev/null +++ b/Algorithms/0893.groups-of-special-equivalent-strings/groups-of-special-equivalent-strings.go @@ -0,0 +1,23 @@ +package problem0893 + +func numSpecialEquivGroups(A []string) int { + strSize := len(A[0]) + groups := make(map[[26]int]bool, len(A)) + for _, a := range A { + count := [26]int{} + i := 0 + for i = 0; i+1 < strSize; i += 2 { + // 使用循环展开,避免了判断 i 的奇偶性的 mod 运算 + // 还减短了关键路径的长度。 + count[a[i]-'a']++ + // 由于题目条件限制了 strSize <= 20 + // 所以可以在同一个数据同时统计奇偶位上字母 + count[a[i+1]-'a'] += 100 + } + if i < strSize { + count[a[i]-'a']++ + } + groups[count] = true + } + return len(groups) +} diff --git a/Algorithms/0893.groups-of-special-equivalent-strings/groups-of-special-equivalent-strings_test.go b/Algorithms/0893.groups-of-special-equivalent-strings/groups-of-special-equivalent-strings_test.go new file mode 100755 index 000000000..330aba5e3 --- /dev/null +++ b/Algorithms/0893.groups-of-special-equivalent-strings/groups-of-special-equivalent-strings_test.go @@ -0,0 +1,59 @@ +package problem0893 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []string + ans int +}{ + + { + []string{"demp", "cfhp", "dzvf", "ggxe", "hkte", "clug", "nhgk", "hvwj", "zozr", "datm", "hisr", "gfry", "jknr", "laju", "emsf", "duwe", "ilta", "gjrd", "woaq", "zhdm", "ujmz", "jalu", "tkhe", "gexg", "hrsi", "tail", "ilta", "xegg", "srhi", "clug", "cgul", "gexg", "tehk", "ulcg", "xgge", "cgul", "hrsi", "aowq", "jalu", "laju", "vzdf", "gexg", "hpcf", "zhdm", "hfcp", "zhdm", "ulcg", "jalu", "ggxe", "gexg", "nkgh", "hrsi", "vfdz", "nkgh", "cgul", "hpcf", "hetk", "zrzo", "xegg", "nkgh", "srhi", "smef", "ulcg", "hrsi", "ggxe", "ggxe", "efsm", "ggxe", "jalu", "srhi", "dmzh", "laju", "zmdh", "sfem", "tehk", "srhi", "wqao", "gknh", "jalu", "iatl", "gexg", "ugcl", "nkgh", "hrsi", "srhi", "hkte", "gdrj", "zozr", "hisr", "sihr", "smef", "zmdh", "clug", "iatl", "cgul", "woaq", "jrnk", "sihr", "xegg", "luja"}, + 21, + }, + + { + []string{"a", "b", "c", "a", "c", "c"}, + 3, + }, + + { + []string{"aa", "bb", "ab", "ba"}, + 4, + }, + + { + []string{"abc", "acb", "bac", "bca", "cab", "cba"}, + 3, + }, + + { + []string{"abcd", "cdab", "adcb", "cbad"}, + 1, + }, + + // 可以有多个 testcase +} + +func Test_numSpecialEquivGroups(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, numSpecialEquivGroups(tc.A), "输入:%v", tc) + } +} + +func Benchmark_numSpecialEquivGroups(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numSpecialEquivGroups(tc.A) + } + } +} diff --git a/Algorithms/0894.all-possible-full-binary-trees/README.md b/Algorithms/0894.all-possible-full-binary-trees/README.md new file mode 100755 index 000000000..a3a0b60f1 --- /dev/null +++ b/Algorithms/0894.all-possible-full-binary-trees/README.md @@ -0,0 +1,29 @@ +# [894. All Possible Full Binary Trees](https://leetcode.com/problems/all-possible-full-binary-trees/) + +## 题目 + +A `full binary tree` is a binary tree where each node has exactly 0 or 2 children. + +Return a list of all possible full binary trees with `N` nodes. Each element of the answer is the root node of one possible tree. + +Each `node` of each tree in the answer must have node.Val = 0. + +You may return the final list of trees in any order. + +Example 1: + +```text +Input: 7 +Output: [[0,0,0,null,null,0,0,null,null,0,0],[0,0,0,null,null,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,null,null,null,null,0,0],[0,0,0,0,0,null,null,0,0]] +Explanation: +``` + +![trees](fivetrees.png) + +Note: + +- 1 <= N <= 20 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0894.all-possible-full-binary-trees/all-possible-full-binary-trees.go b/Algorithms/0894.all-possible-full-binary-trees/all-possible-full-binary-trees.go new file mode 100755 index 000000000..bb16ef862 --- /dev/null +++ b/Algorithms/0894.all-possible-full-binary-trees/all-possible-full-binary-trees.go @@ -0,0 +1,36 @@ +package problem0894 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode 是题目预定义的树结构 +type TreeNode = kit.TreeNode + +var forest = [10][]*TreeNode{[]*TreeNode{&TreeNode{Val: 0}}} + +func allPossibleFBT(N int) []*TreeNode { + if N%2 == 0 { + return nil + } else if forest[N/2] != nil { + return forest[N/2] + } + + trees := make([]*TreeNode, 0, N*2) + for les := 1; les <= N-2; les += 2 { + ris := N - 1 - les + for _, left := range allPossibleFBT(les) { + for _, right := range allPossibleFBT(ris) { + trees = append(trees, &TreeNode{ + Val: 0, + Left: left, + Right: right, + }) + } + } + } + + forest[N/2] = trees + + return forest[N/2] +} diff --git a/Algorithms/0894.all-possible-full-binary-trees/all-possible-full-binary-trees_test.go b/Algorithms/0894.all-possible-full-binary-trees/all-possible-full-binary-trees_test.go new file mode 100755 index 000000000..3d1df267d --- /dev/null +++ b/Algorithms/0894.all-possible-full-binary-trees/all-possible-full-binary-trees_test.go @@ -0,0 +1,70 @@ +package problem0894 + +import ( + "fmt" + "sort" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans [][]int +}{ + + { + 2, + [][]int{}, + }, + + { + 7, + [][]int{{0, 0, 0, kit.NULL, kit.NULL, 0, 0, kit.NULL, kit.NULL, 0, 0}, {0, 0, 0, kit.NULL, kit.NULL, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 0, 0}, {0, 0, 0, 0, 0, kit.NULL, kit.NULL, 0, 0}}, + }, + + // 可以有多个 testcase +} + +func Test_allPossibleFBT(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ans := allPossibleFBT(tc.N) + ansInts := make([][]int, 0, 20) + for _, tree := range ans { + ansInts = append(ansInts, kit.Tree2ints(tree)) + } + + sort.Slice(tc.ans, func(i int, j int) bool { + for k := 0; k < len(tc.ans[i]); k++ { + if tc.ans[i][k] != tc.ans[j][k] { + return tc.ans[i][k] < tc.ans[j][k] + } + } + return false + }) + + sort.Slice(ansInts, func(i int, j int) bool { + for k := 0; k < len(tc.ans[i]); k++ { + if ansInts[i][k] != ansInts[j][k] { + return ansInts[i][k] < ansInts[j][k] + } + } + return false + }) + + ast.Equal(tc.ans, ansInts, "输入:%v", tc) + } +} + +func Benchmark_allPossibleFBT(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + allPossibleFBT(tc.N) + } + } +} diff --git a/Algorithms/0894.all-possible-full-binary-trees/fivetrees.png b/Algorithms/0894.all-possible-full-binary-trees/fivetrees.png new file mode 100644 index 000000000..89d1fb33c Binary files /dev/null and b/Algorithms/0894.all-possible-full-binary-trees/fivetrees.png differ diff --git a/Algorithms/0895.maximum-frequency-stack/README.md b/Algorithms/0895.maximum-frequency-stack/README.md new file mode 100755 index 000000000..e6c0bbd46 --- /dev/null +++ b/Algorithms/0895.maximum-frequency-stack/README.md @@ -0,0 +1,46 @@ +# [895. Maximum Frequency Stack](https://leetcode.com/problems/maximum-frequency-stack/) + +## 题目 + +Implement FreqStack, a class which simulates the operation of a stack-like data structure. + +FreqStack`has two functions: + +- push(int x), which pushes an integer x onto the stack. +- pop(), which removes and returns the most frequent element in the stack. + - If there is a tie for most frequent element, the element closest to the top of the stack is removed and returned. + +Example 1: + +```text +Input: +["FreqStack","push","push","push","push","push","push","pop","pop","pop","pop"], +[[],[5],[7],[5],[7],[4],[5],[],[],[],[]] +Output: [null,null,null,null,null,null,null,5,7,5,4] +Explanation: +After making six .push operations, the stack is [5,7,5,7,4,5] from bottom to top. Then: + +pop() -> returns 5, as 5 is the most frequent. +The stack becomes [5,7,5,7,4]. + +pop() -> returns 7, as 5 and 7 is the most frequent, but 7 is closest to the top. +The stack becomes [5,7,5,4]. + +pop() -> returns 5. +The stack becomes [5,7,4]. + +pop() -> returns 4. +The stack becomes [5,7]. +``` + +Note: + +- Calls to FreqStack.push(int x)`will be such that 0 <= x <= 10^9. +- It is guaranteed that FreqStack.pop() won't be called if the stack has zero elements. +- The total number of FreqStack.push calls will not exceed 10000 in a single test case. +- The total number of FreqStack.pop`calls will not exceed 10000 in a single test case. +- The total number of FreqStack.push and FreqStack.pop calls will not exceed 150000 across all test cases. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0895.maximum-frequency-stack/maximum-frequency-stack.go b/Algorithms/0895.maximum-frequency-stack/maximum-frequency-stack.go new file mode 100755 index 000000000..93bf5dfc9 --- /dev/null +++ b/Algorithms/0895.maximum-frequency-stack/maximum-frequency-stack.go @@ -0,0 +1,77 @@ +package problem0895 + +import ( + "container/heap" +) + +// FreqStack object will be instantiated and called as such: +// obj := Constructor(); +// obj.Push(x); +// param_2 := obj.Pop(); +type FreqStack struct { + index int + freq map[int]int + pq *PQ +} + +// Constructor 构建 FreqStack +func Constructor() FreqStack { + pq := make(PQ, 0, 10000) + return FreqStack{ + freq: make(map[int]int, 10000), + pq: &pq, + } +} + +// Push 在 fs 中放入 x +func (fs *FreqStack) Push(x int) { + fs.index++ + fs.freq[x]++ + e := &entry{ + key: x, + index: fs.index, + freq: fs.freq[x], + } + heap.Push(fs.pq, e) +} + +// Pop 从 fs 中弹出元素 +func (fs *FreqStack) Pop() int { + x := heap.Pop(fs.pq).(*entry).key + fs.freq[x]-- + return x +} + +// entry 是 priorityQueue 中的元素 +type entry struct { + key, index, freq int +} + +// PQ implements heap.Interface and holds entries. +type PQ []*entry + +func (pq PQ) Len() int { return len(pq) } + +func (pq PQ) Less(i, j int) bool { + if pq[i].freq == pq[j].freq { + return pq[i].index > pq[j].index + } + return pq[i].freq > pq[j].freq +} + +func (pq PQ) Swap(i, j int) { + pq[i], pq[j] = pq[j], pq[i] +} + +// Push 往 pq 中放 entry +func (pq *PQ) Push(x interface{}) { + temp := x.(*entry) + *pq = append(*pq, temp) +} + +// Pop 从 pq 中取出最优先的 entry +func (pq *PQ) Pop() interface{} { + temp := (*pq)[len(*pq)-1] + *pq = (*pq)[0 : len(*pq)-1] + return temp +} diff --git a/Algorithms/0895.maximum-frequency-stack/maximum-frequency-stack_test.go b/Algorithms/0895.maximum-frequency-stack/maximum-frequency-stack_test.go new file mode 100755 index 000000000..03868eeaa --- /dev/null +++ b/Algorithms/0895.maximum-frequency-stack/maximum-frequency-stack_test.go @@ -0,0 +1,46 @@ +package problem0895 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_FreqStack_1(t *testing.T) { + ast := assert.New(t) + fs := Constructor() + pushes := []int{5, 7, 5, 7, 4, 5} + for _, p := range pushes { + fs.Push(p) + } + expecteds := []int{5, 7, 5, 4} + for _, expected := range expecteds { + actual := fs.Pop() + ast.Equal(expected, actual) + } +} + +func Test_FreqStack_2(t *testing.T) { + ast := assert.New(t) + fs := Constructor() + // + pushes := []int{1, 1, 1, 2} + for _, p := range pushes { + fs.Push(p) + } + expecteds := []int{1, 1} + for _, expected := range expecteds { + actual := fs.Pop() + ast.Equal(expected, actual) + } + // + pushes = []int{2, 2, 1} + for _, p := range pushes { + fs.Push(p) + } + expecteds = []int{2, 1, 2} + for _, expected := range expecteds { + actual := fs.Pop() + ast.Equal(expected, actual) + } +} diff --git a/Algorithms/0896.monotonic-array/README.md b/Algorithms/0896.monotonic-array/README.md new file mode 100755 index 000000000..b3f577a08 --- /dev/null +++ b/Algorithms/0896.monotonic-array/README.md @@ -0,0 +1,53 @@ +# [896. Monotonic Array](https://leetcode.com/problems/monotonic-array/) + +## 题目 + +An array is monotonic if it is either monotone increasing or monotone decreasing. + +An array `A` is monotone increasing if for all `i <= j, A[i] <= A[j].` An array `A` is monotone decreasing if for all `i <= j, A[i] >= A[j]`. + +Return `true` if and only if the given array `A` is monotonic. + +Example 1: + +```text +Input: [1,2,2,3] +Output: true +``` + +Example 2: + +```text +Input: [6,5,4,4] +Output: true +``` + +Example 3: + +```text +Input: [1,3,2] +Output: false +``` + +Example 4: + +```text +Input: [1,2,4,5] +Output: true +``` + +Example 5: + +```text +Input: [1,1,1] +Output: true +``` + +Note: + +- 1 <= A.length <= 50000 +- -100000 <= A[i] <= 100000 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0896.monotonic-array/monotonic-array.go b/Algorithms/0896.monotonic-array/monotonic-array.go new file mode 100755 index 000000000..240dbb6e4 --- /dev/null +++ b/Algorithms/0896.monotonic-array/monotonic-array.go @@ -0,0 +1,12 @@ +package problem0896 + +func isMonotonic(A []int) bool { + size := len(A) + inc, dec := true, true + for i := 1; i < size && (inc || dec); i++ { + inc = inc && A[i-1] <= A[i] + dec = dec && A[i-1] >= A[i] + } + + return inc || dec +} diff --git a/Algorithms/0896.monotonic-array/monotonic-array_test.go b/Algorithms/0896.monotonic-array/monotonic-array_test.go new file mode 100755 index 000000000..77ff98eaa --- /dev/null +++ b/Algorithms/0896.monotonic-array/monotonic-array_test.go @@ -0,0 +1,59 @@ +package problem0896 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans bool +}{ + + { + []int{1, 2, 2, 3}, + true, + }, + + { + []int{6, 5, 4, 4}, + true, + }, + + { + []int{1, 3, 2}, + false, + }, + + { + []int{1, 2, 4, 5}, + true, + }, + + { + []int{1, 1, 1}, + true, + }, + + // 可以有多个 testcase +} + +func Test_isMonotonic(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, isMonotonic(tc.A), "输入:%v", tc) + } +} + +func Benchmark_isMonotonic(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isMonotonic(tc.A) + } + } +} diff --git a/Algorithms/0897.increasing-order-search-tree/README.md b/Algorithms/0897.increasing-order-search-tree/README.md new file mode 100755 index 000000000..84470d304 --- /dev/null +++ b/Algorithms/0897.increasing-order-search-tree/README.md @@ -0,0 +1,47 @@ +# [897. Increasing Order Search Tree](https://leetcode.com/problems/increasing-order-search-tree/) + +## 题目 + +Given a tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has no left child and only 1 right child. + +```text +Example 1: +Input: [5,3,6,2,4,null,8,1,null,null,null,7,9] + + 5 + / \ + 3 6 + / \ \ + 2 4 8 + / / \ +1 7 9 + +Output: [1,null,2,null,3,null,4,null,5,null,6,null,7,null,8,null,9] + +1 + \ + 2 + \ + 3 + \ + 4 + \ + 5 + \ + 6 + \ + 7 + \ + 8 + \ + 9 +``` + +Note: + +- The number of nodes in the given tree will be between 1 and 100. +- Each node will have a unique integer value from 0 to 1000. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0897.increasing-order-search-tree/increasing-order-search-tree.go b/Algorithms/0897.increasing-order-search-tree/increasing-order-search-tree.go new file mode 100755 index 000000000..289bea012 --- /dev/null +++ b/Algorithms/0897.increasing-order-search-tree/increasing-order-search-tree.go @@ -0,0 +1,28 @@ +package problem0897 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode Definition for a binary tree node. +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func increasingBST(root *TreeNode) *TreeNode { + var head = &TreeNode{} + tail := head + var rec func(root *TreeNode) + rec = func(root *TreeNode) { + if root == nil { + return + } + rec(root.Left) + root.Left = nil // 切断 root 与其 Left 的连接,避免形成环 + tail.Right, tail = root, root // 把 root 接上 tail,并保持 tail 指向尾部 + rec(root.Right) + } + rec(root) + return head.Right +} diff --git a/Algorithms/0897.increasing-order-search-tree/increasing-order-search-tree_test.go b/Algorithms/0897.increasing-order-search-tree/increasing-order-search-tree_test.go new file mode 100755 index 000000000..7c8183b58 --- /dev/null +++ b/Algorithms/0897.increasing-order-search-tree/increasing-order-search-tree_test.go @@ -0,0 +1,45 @@ +package problem0897 + +import ( + "fmt" + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +var null = kit.NULL + +// tcs is testcase slice +var tcs = []struct { + p []int + ans []int +}{ + + { + []int{5, 3, 6, 2, 4, null, 8, 1, null, null, null, 7, 9}, + []int{1, null, 2, null, 3, null, 4, null, 5, null, 6, null, 7, null, 8, null, 9}, + }, + + // 可以有多个 testcase +} + +func Test_increasingBST(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + root := kit.Ints2TreeNode(tc.p) + ans := kit.Tree2ints(increasingBST(root)) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_myFunc(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.p) + increasingBST(root) + } + } +} diff --git a/Algorithms/0898.bitwise-ors-of-subarrays/README.md b/Algorithms/0898.bitwise-ors-of-subarrays/README.md new file mode 100755 index 000000000..91efeb7fa --- /dev/null +++ b/Algorithms/0898.bitwise-ors-of-subarrays/README.md @@ -0,0 +1,43 @@ +# [898. Bitwise ORs of SubArrays](https://leetcode.com/problems/bitwise-ors-of-subarrays/) + +## 题目 + +We have an array `A` of non-negative integers. + +For every (contiguous) sub array `B =[A[i], A[i+1], ..., A[j]]` (with i <= j), we take the bitwise OR of all the elements in B, obtaining a result `A[i] | A[i+1] | ... | A[j]`. + +Return the number of possible`results.` (Results that occur more than once are only counted once in the final answer.) + +Example 1: + +```text +Input: [0] +Output: 1 +Explanation: +There is only one possible result: 0. +``` + +Example 2: + +```text +Input: [1,1,2] +Output: 3 +Explanation: +The possible sub arrays are [1], [1], [2], [1, 1], [1, 2], [1, 1, 2]. +These yield the results 1, 1, 2, 1, 3, 3. +There are 3 unique values, so the answer is 3. +``` + +Example 3: + +```text +Input: [1,2,4] +Output: 6 +Explanation: +The possible results are 1, 2, 3, 4, 6, and 7. +``` + +Note: + +- 1 <= A.length <= 50000 +- 0 <= A[i] <= 10^9 diff --git a/Algorithms/0898.bitwise-ors-of-subarrays/bitwise-ors-of-subarrays.go b/Algorithms/0898.bitwise-ors-of-subarrays/bitwise-ors-of-subarrays.go new file mode 100755 index 000000000..1b9b1ffaf --- /dev/null +++ b/Algorithms/0898.bitwise-ors-of-subarrays/bitwise-ors-of-subarrays.go @@ -0,0 +1,22 @@ +package problem0898 + +func subarrayBitwiseORs(a []int) int { + unique := make(map[int]bool, len(a)) + var prev, next []int + for _, x := range a { + isInNext := make(map[int]bool, len(prev)) + isInNext[x], unique[x] = true, true + next = append(next, x) + for _, y := range prev { + y |= x + if !isInNext[y] { + isInNext[y], unique[y] = true, true + next = append(next, y) + } + } + // 假设 x 在 a 中的索引号是 j,BitwiseOR(a) 表示对 a 中所有元素依次取或的结果 + // 那么此时, next 是 BitwiseOR(a[i:j+1]) 的集合,其中 i=0,1,...,j + prev, next = next, prev[:0] + } + return len(unique) +} diff --git a/Algorithms/0898.bitwise-ors-of-subarrays/bitwise-ors-of-subarrays_test.go b/Algorithms/0898.bitwise-ors-of-subarrays/bitwise-ors-of-subarrays_test.go new file mode 100755 index 000000000..417f7953f --- /dev/null +++ b/Algorithms/0898.bitwise-ors-of-subarrays/bitwise-ors-of-subarrays_test.go @@ -0,0 +1,59 @@ +package problem0898 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{1, 3, 4}, + 4, + }, + + { + []int{0}, + 1, + }, + + { + []int{1, 1, 2}, + 3, + }, + + { + []int{1, 2, 4}, + 6, + }, + + { + []int{530655536, 928078641, 321189591, 433348369, 368148846, 244673843, 935344340, 420292413, 802812842, 135640995, 520631925, 999129109, 225698369, 600346256, 559988972, 839784923, 456990771, 178246718, 308836641, 9242427, 61293926, 444870028, 618485197, 430197532, 151462860, 756059866, 575618363, 980126270, 559249004, 278111112, 220022472, 873721074, 995495324, 680558741, 281152893, 228088262, 828192401, 409220507, 676333585, 61874245, 622417672, 319124744, 569998772, 21055136, 325998969, 816437667, 39728988, 865273979, 379564726, 666426462, 954173567, 620212914, 653921867, 396611097, 314381640, 192828845, 915350101, 538762791, 343732646, 454249966, 127449168, 336328759, 635965386, 253575860, 621845032, 524471161, 141500781, 19665639, 837705535, 888053144, 191136767, 243591733, 694994005, 634783856, 669090696, 202172146, 361953009, 558462431, 442270553, 603459833, 91745235, 296539372, 139571372, 459605680, 925409904, 870556316, 789969050, 114846316, 292394258, 400728851, 119952885, 318577840, 298673755, 866399606, 906840482, 258819285, 705827935, 356722865, 669344279, 625367269, 717179880, 607717299, 411333710, 698779345, 26241552, 35404654, 154674449, 452768565, 102125350, 104953608, 881647237, 20745039, 459112502, 584192613, 213059203, 489674007, 576169704, 179055717, 423121361, 98163359, 244758426, 783341838, 18342205, 629853039, 510618595, 397044210, 429283438, 300216262, 402011520, 802712481, 946957766, 605582898, 909742104, 741648369, 516885886, 538523761, 164786455, 831785761, 173534064, 96918956, 177349204, 924754694, 638114449, 276674630, 671554258, 141991901, 900765459, 141745953, 704038254, 424882954, 37306863, 472247511, 569758486, 518469037, 235911823, 846688692, 303848304, 313423879, 632939188, 331104243, 517167442, 571055004, 266597871, 532608599, 296550877, 71993133, 762653468, 902280359, 789429097, 280250899, 14522378, 12643255, 502708413, 121774119, 783841941, 256950120, 262811378, 443354332, 254757044, 302985827, 262962504, 225722777, 319973037, 535978045, 840021548, 776860444, 753730714, 294066027, 952586930, 6514649, 286004792, 172702655, 637057474, 228715955, 105126015, 631615602, 869546624, 621774628, 530823095, 850851686, 114273855, 938790033, 115853565, 4749870, 955668289, 654223219, 171395367, 980279694, 698312020, 181353540, 462277167, 545194856, 224866048, 630979957, 943463621, 30190301, 853262246, 882986362, 22847439, 364928740, 953901210, 633505688, 38747191, 170033807, 229801458, 676004518, 75797397, 671245659, 823752370, 190615238, 570427636, 305352045, 560907620, 547653017, 686443946, 793805564, 636437835, 799056222, 457277848, 775008212, 841952374, 228857728, 234822155, 934424262, 706342550, 705900503, 623388192, 990147572, 886178585, 836493633, 171673887, 831500449, 711161010, 132929746, 280635769, 733519030, 316220544, 290754059, 654146891, 137456046, 223722543, 206168321, 715538503, 289962750, 608810889, 161589860, 824289995, 847862068, 984131593, 115738291, 778750356, 773861760, 257069501, 486063852, 775076393, 176854587, 359223345, 482417861, 697396663, 855261682, 594439310, 648078429, 743733268, 636669294, 769690723, 926990758, 889896532, 123427813, 34741679, 916437670, 140719166, 69051506, 456106260, 256535700, 795166886, 417653361, 791926546, 180398247, 750671851, 346140241, 609215214, 694735107, 856435584, 134015212, 614119121, 120673547, 744054980, 837344526, 350047981, 423306961, 552443876, 634648822, 379984981, 730898698, 87932716, 181028315, 649326619, 467382122, 212012221, 389292635, 35623804, 740348959, 298027524, 843279976, 213016500, 459412052, 317721420, 77962264, 764693639, 649143437, 159422738, 837780372, 348136992, 236345789, 498119322, 715373253, 482423067, 655449219, 834193190, 304088958, 1399139, 991096681, 732703820, 325160663, 468819853, 271586829, 96535142, 503334694, 910374575, 82747567, 354731446, 283598043, 585477712, 245161151, 345776310, 245524170, 9971459, 710823468, 90343051, 123580293, 670899635, 901223684, 539344677, 942927808, 383344232, 775261154, 202458936, 364178337, 644496289, 420449342, 734707612, 518230769, 59344459, 113448314, 957764320, 722800277, 460574296, 250371045, 379915120, 599673628, 851147271, 695258038, 342136141, 363429491, 170826906, 109926145, 917978489, 295445029, 156304005, 356597317, 614824142, 372859922, 787394040, 235867284, 284707523, 7622007, 274575480, 622054108, 248793728, 339813479, 401838598, 441875846, 330115950, 269866102, 716286283, 286158638, 11572337, 563336190, 371870126, 742575522, 30438828, 937785813, 786710077, 823038461, 202384911, 342611080, 987709284, 624342632, 553949432, 8790920, 638595095, 693713228, 634231188, 502798901, 752111301, 866853308, 366337798, 543021245, 571228126, 10653565, 752019642, 215522510, 913531723, 32637793, 250432799, 468386440, 466275456, 558222995, 735968948, 484684316, 48069686, 319820898, 439098336, 849599740, 55716616, 988684711, 809762536, 23195589, 302168113, 624021401, 57717807, 205903394, 999606167, 719055284, 652468784, 182863872, 727267875, 809921633, 217314117, 722259144, 446443226, 557203139, 341526448, 787175204, 379807766, 528932772, 858483055, 473807317, 988310021, 949758851, 198406027, 170469128, 367240443, 846011417, 125237977, 115514749, 975852386, 175941972, 393486961, 227653615, 857088471, 564458163, 419985867, 562747630, 660951237, 418860726, 602360353, 693036985, 803839919, 826954844, 474935241, 359639502, 901839521, 363248174, 651299096, 957637512, 662961732, 303239473, 587068005, 416770784, 200458495, 607470333, 36616013, 376261616, 815543449, 13744402, 332491172, 27391235, 283190, 458407034, 554084351, 646130004, 886184356, 947514802, 163019319, 591340865, 735198697, 931436390, 318580482, 382355901, 364322477, 787220294, 400681363, 589019478, 414844354, 902082200, 278544545, 336678839, 829438385, 133085758, 566196035, 468622812, 580350240, 60444553, 555204701, 527383566, 15503986, 990278321, 889721921, 576344425, 318755567, 224221164, 509948579, 554986987, 75147931, 922426289, 283106239, 189875951, 861616928, 776146514, 374756970, 717185706, 18356631, 42843096, 991191958, 639721930, 641704156, 595588414, 924626440, 999390962, 24731231, 53605368, 572297980, 14743260, 593093618, 308948318, 20237996, 958028846, 792836214, 440038148, 289314269, 59830062, 949956134, 729562982, 607675645, 360754319, 406899445, 65147224, 730017685, 638674719, 148845434, 684562548, 501554616, 212546597, 29714791, 829248978, 700084153, 231681849, 682551026, 815857307, 541910003, 324532244, 3828316, 146555634, 351450133, 258264318, 529238058, 514101615, 19662010, 533216859, 245662089, 489270970, 385222250, 71376152, 650819972, 418880632, 98766933, 207769588, 305456855, 874347082, 615680533, 131077055, 20639584, 965119884, 867495264, 101489772, 967445546, 119909121, 600351654, 265456676, 625329404, 845939142, 662017247, 71878236, 704007773, 309871217, 325404462, 845413270, 370989970, 88184649, 215041482, 392046060, 998887102, 144292920, 799804293, 328066064, 484802949, 331125111, 800815394, 800552869, 434493667, 764383920, 752217734, 318875562, 718096149, 749514671, 824107725, 748843685, 551452301, 32721319, 749368009, 998468873, 537152148, 194355495, 620147611, 522647153, 117467940, 171189606, 826918795, 3036705, 196076417, 74231525, 356357753, 415152279, 877788469, 51953596, 901470380, 621144912, 709238436, 72003245, 144695588, 491175426, 832905436, 484353527, 476176576, 959348616, 775833579, 385084137, 507944891, 401962505, 753171262, 320547818, 774196305, 327158087, 329591059, 466599347, 613849165, 442875909, 32254071, 902697057, 498066042, 630326311, 337758217, 760335528, 795792494, 228786892, 518412676, 764133247, 996357455, 977770312, 557113569, 148841329, 608797940, 742035850, 624032983, 218017533, 330314539, 521199663, 768196027, 29579010, 68819648, 568441189, 725209156, 279394647, 602993677, 421141644, 612474045, 875286587, 91868159, 930036707, 767770911, 838578140, 734896235, 50841785, 182301226, 479525401, 909901538, 468148262, 364265478, 948114408, 364533780, 391303343, 262788662, 40909680, 166457508, 647101962, 609458181, 211396927, 321588558, 574216191, 390244310, 615873345, 217295610, 173844113, 866199617, 882828546, 568815891, 717250333, 351995417, 90364649, 167952330, 336309462, 947356469, 385152530, 448608774, 867945780, 228958890, 623665086, 815775429, 814053954, 908661438, 554001370, 51125794, 862275420, 245422157, 681675143, 123896515, 414006739, 304053904, 159229193, 981998191, 622389636, 954654685, 644072784, 282607360, 219203800, 330992129, 608619819, 972751698, 533313070, 838405999, 88858401, 942089097, 746977241, 926666961, 859159975, 292376727, 793660707, 698843271, 417891509, 802973267, 293553845, 987673554, 379595510, 851444472, 257055715, 927610025, 226987215, 895075910, 884570518, 283178936, 105243328, 377082077, 265517856, 956496706, 829941496, 472609076, 547087021, 685497271, 262437496, 499020508, 920214939, 202768447, 74060803, 5944497, 641997590, 691498033, 331150561, 427138570, 540153226, 370041113, 20622181, 849822694, 925800277, 190115626, 674645658, 715137059, 774928394, 886297438, 360231177, 931163449, 947769246, 51808442, 143604124, 858957600, 865332557, 530636426, 33324832, 442034085, 771058274, 61792852, 808074280, 898577167, 753786935, 134548388, 264378009, 787468173, 578194692, 681004264, 779787409, 542636893, 354627810, 689300623, 162865415, 533422759, 351032705, 881784116, 526248487, 758692081, 406013592, 943221155, 468193259, 844873781, 426602722, 13046711, 818942154, 919103237, 618174444, 967199004, 93062018, 174923809, 431468472, 283722938, 529491426, 467399914, 934021857, 799590369, 583621475, 227168235, 163250082, 555046937, 469005906, 769502955, 886534299, 580431492, 537942630, 959135032, 377811501, 125837998, 151102081, 325460524, 33676687, 168466534, 963089827, 488449525, 453939156, 641587723, 756071590, 161352189, 573227615, 879288550, 976419637, 76030495, 424952893, 498338146, 867774358, 175387564, 238601329, 84364223, 422257403, 1596289, 577153399, 440055681, 849470354, 353000862, 587949899, 569731125, 745841859, 637745065, 138525773, 731559083, 739735346, 574241801, 290241180, 735284880, 705674538, 742150263, 891677914, 632286711, 716601216, 277071972, 406073814, 488308568, 604891030, 305818763, 22800424, 717419668, 715193045, 197750926, 650559606, 520898789, 169586095, 86930839, 675363845, 996980937, 571847964, 869967309, 863997019, 724755524, 543635262, 764130212, 124244089, 698257841, 75734340, 381823241, 354193343, 257939491, 307178081, 390043222, 14427239, 23917935, 145523402, 574418021, 105552442, 670296397, 725419581, 931643778, 335776934, 435197956, 892718196, 62952343, 445081731, 765753742, 848659718, 853215425, 902977866, 291618482, 376031016, 83058178, 268193463, 635441685, 671959938, 171377448, 122567921, 507986154, 14625899, 197738764, 857568902, 971057288, 134102415, 871829033, 139554103, 342377734, 949676018, 247031829, 400122714, 386044179, 115983333, 330544640, 369667643, 524943597, 901852364, 465521890, 663195216, 841504393, 478140546, 437868847, 632234415, 89164537, 510732718, 506473529, 925857517, 844109696, 495445229, 687197802, 354761298, 657958227, 794128788, 253898174, 51707361, 663947575, 285202226, 51256555, 959773458, 985096661, 989115609, 838342002, 501319858, 505045818, 294397502, 719261035, 846908705, 719552689, 628557707, 788430877, 54114334, 649567609, 426853348, 63491914, 937067140, 337208166, 669248408, 164304553, 703112882, 362884566, 191391070, 879332134, 152391223, 44295138, 905725871, 542223549, 849580189, 472457880, 834300041, 828967768, 408429507, 960014898, 90278694, 313807136, 967027635, 541773323, 92312812, 242459550, 853057864, 73201279, 711298593, 350890103, 520249608, 958984192, 137243860, 982081484, 515046107, 864075286, 875144687, 905087170, 279703517, 37209153, 970478809, 499479499, 52076676, 658588039, 768738685, 524193201, 275900227, 212740220, 171551924, 734125356, 724451879, 35725830, 968038239, 758684378, 829633482, 564288467, 432477407, 551170704, 512597311, 159812008, 115080234, 211573377, 178491131, 448704720, 255618000, 428719345, 478509774, 715865570, 396537086, 403199030, 756158822, 19958648, 960772049, 509404505, 196210034, 901424631, 574582812, 776137808, 955573763, 392685885, 511473681, 749672950, 484736963, 374980119, 268509251, 519569263, 621018742, 73787980, 889159483, 437534712, 871591557, 276377422, 334880540, 490935183, 775521554, 769122914, 428801318, 559230512, 793304088, 190411977, 839822265, 909455697, 798982932, 165275244, 720465469, 85759159, 54437495, 191884595, 672590057, 400723689, 644099534, 428865253, 224896394, 659410733, 729849464, 560210890, 73314197, 805319102, 758181533, 50865572, 262303187, 309720239, 841747068, 248625386, 519678426, 942276119, 305505310, 467931837, 79479139, 863069758, 667609141, 707723480, 929149875, 730900623, 207697820, 644252853, 485261136, 259488812, 685211991, 535298084, 712058280, 648184791, 275314646, 459034493, 908123669, 735806843, 458617544, 774873614, 87258784, 358544966, 803731973, 998408230, 573293348, 950410096, 44391386, 227758737, 441887376, 508172639, 408170871, 839608845, 749072635, 54395790, 216135838, 27259691, 630010201, 682298607, 783101346, 592684605, 201312572, 886569216, 390349621, 228750058, 659328019, 352996465, 558343470, 218197823, 808159462, 576065254, 244121333, 280370719, 705678387, 160887305, 939986753, 668075000, 511839543, 121433748, 728782969, 9100162, 331252730, 629746210, 79918444, 444882351, 663035685, 26467866, 970616596, 322199017, 516064972, 404978495, 413804996, 909128669, 346028708, 826609848, 805419344, 97904041, 249736143, 206685558, 173666976, 544644487, 707724103, 689986879, 597359785, 262499187, 478508293, 853110529, 483417018, 993644699, 726019174, 576812057, 861551974, 350334155, 196166744, 306319461, 34395756, 182983381, 599041131, 793888565, 788794038, 415702043, 775462463, 756607891, 405782513, 30066009, 825062717, 445926726, 118297383, 842086362, 818032332, 619366899, 817042931, 588011379, 610997700, 459970639, 832188890, 762328733, 757623300, 609004761, 548498125, 441741551, 739960140, 344428292, 654202247, 191611327, 899335843, 102666973, 701874692, 498133768, 242207557, 660353767, 33798767, 405225431, 150916805, 767688694, 272574276, 61072023, 790224132, 764785932, 973340287, 133001892, 423623842, 395554769, 480781663, 42018563, 169517420, 504719737, 55810259, 183530435, 418427452, 586271906, 887014525, 317743590, 762660015, 103691670, 552875714, 288040573, 448661065, 118017526, 279232517, 394289998, 918443330, 708979402, 131212487, 161450506, 738395274, 297338228, 292736235, 620564307, 669658188, 888124241, 961482853, 159253706, 738730395, 662846350, 348104647, 15149077, 15040180, 547955582, 852895013, 172692938, 533077598, 28530281, 177751787, 268140559, 557687823, 635066467, 244529506, 563226026, 507041664, 603394281, 913876383, 988793122, 503116131, 248110238, 814146275, 859692693, 355628399, 635842539, 820526089, 647352418, 196564144, 116943652, 622204999, 990828691, 638920881, 151862189, 889612903, 745789040, 762371135, 206726240, 29037112, 210320485, 236184339, 757453925, 590350897, 170704488, 489378771, 518349322, 828840727, 384991563, 27330749, 671518838, 692962234, 160268461, 867682266, 932798449, 309874897, 943384033, 632174174, 128378884, 821751196, 278779465, 146542001, 311612236, 864241569, 128599250, 450001236, 830941553, 965101620, 820029265, 428770355, 934963565, 892942463, 26543336, 748440818, 273192827, 606285240, 171294765, 18385968, 173416477, 611930800, 323032337, 850094912, 698754471, 213472194, 386455206, 98878100, 16867588, 959943438, 687963711, 310432368, 627837228, 774656795, 343431953, 410484555, 227428598, 361762454, 23649964, 309470523, 809662023, 929501783, 665630893, 626017941, 446493142, 740500748, 826001700, 844188596, 162448182, 984746913, 255946037, 923902859, 792033510, 254921069, 13477293, 250299193, 146237838, 784031542, 210204714, 130918155, 228986292, 369049595, 889625378, 506569320, 522507209, 365960806, 382622078, 443720685, 830324289, 15261923, 205711340, 15323832, 871799113, 696205111, 750294271, 975990610, 153485431, 296156047, 919692289, 652479512, 773428875, 169240983, 698578810, 142517346, 685174458, 298074867, 104832401, 819431359, 65985310, 44404574, 422135419, 135124243, 310861583, 636349787, 75282449, 781826319, 559323301, 438116952, 163554023, 233715293, 224703721, 916211361, 207443247, 609513414, 768300139, 658844147, 568506210, 495537732, 180739366, 625169364, 109169121, 982686980, 393441826, 70911614, 526697727, 664349572, 50731453, 382504513, 210952948, 160753589, 616246550, 412339113, 695415820, 267298836, 215254348, 649141154, 811042789, 279526826, 81909736, 732680160, 652643570, 802579699, 863303092, 837148579, 906184587, 670926647, 917239717, 97580270, 234406450, 577354774, 352872339, 320452466, 497780315, 588784161, 908779798, 502099700, 774307059, 326664186, 606902131, 928604677, 566969749, 806176493, 325586691, 45455591, 502095128, 118790605, 83729077, 941569521, 396274251, 102741462, 382033834, 800503895, 225116762, 855853282, 850985067, 906096732, 216800396, 220035577, 725748857, 303918990, 165622030, 573273713, 7299062, 60711486, 249046529, 370730722, 272129223, 729145567, 537447982, 832624466, 698209660, 583274433, 769900342, 743918446, 558986699, 484159982, 938552445, 929900504, 669853082, 387068389, 700053058, 637158088, 997809191, 656791472, 427982003, 279135025, 699458209, 694953874, 164028672, 747407724, 287483322, 4800403, 235039817, 641804285, 515774874, 390953823, 602744039, 613092486, 796871222, 243116207, 972878934, 220790804, 958118550, 408193403, 210736493, 539314887, 345049706, 158417907, 554679724, 503764222, 598221415, 253692739, 245951789, 124317235, 342123517, 260052135, 709444593, 444741343, 480560792, 97270102, 593221065, 645567301, 144859661, 775500760, 759811013, 292823701, 332248910, 124771537, 972787629, 638909369, 278380896, 170199561, 628381488, 923954877, 849562324, 924987600, 341765076, 665243624, 619781817, 871407612, 895181067, 150404282, 954865788, 488955991, 356165993, 898798302, 110927181, 646767030, 182454193, 800780021, 965824091, 640597826, 264469272, 37504824, 799618475, 523354912, 146926535, 120806538, 624224960, 535878449, 551324502, 673448381, 705450531, 234011672, 882171498, 466694777, 711746632, 747005335, 165476350, 118714747, 636241889, 709602352, 482550331, 176078811, 590781481, 356174582, 644246516, 65078580, 786810925, 819313435, 129105070, 395935332, 790209347, 475305234, 926212160, 515470275, 927674602, 555353306, 119218784, 631466298, 595823719, 280218827, 67370855, 303386114, 391153221, 203779404, 246686879, 883992445, 981360850, 910542680, 67750873, 824568732, 467146269, 964842667, 762194758, 383637427, 98742072, 178483706, 59440986, 428707803, 252546104, 926209334, 21543310, 804358989, 87963226, 322188832, 430034099, 258885156, 797697651, 523092948, 475298539, 428738284, 11327608, 965621934, 523802759, 97480537, 559938585, 757376462, 468611695, 209927164, 621696521, 966530963, 338932325, 978434291, 175847137, 798010732, 461911263, 820883336, 992047866, 785440894, 818414607, 518833532, 729901137, 401657143, 134669556, 716971916, 639710792, 882272160, 378563920, 960015269, 552134774, 817213981, 172695419, 933476010, 828721858, 891248425, 447507490, 827140634, 205176045, 817576495, 129625625, 267337670, 640223363, 976484621, 438823203, 619321331, 72549610, 563909637, 786090074, 233195485, 282000408, 822322257, 732540837, 659018171, 730364098, 69161511, 91717990, 238678976, 394295957, 408525576, 792912910, 394302841, 711807371, 726774141, 995973354, 237343843, 391742131, 543839995, 574111282, 136772395, 659005921, 771122534, 607750377, 470683899, 636734664, 801184593, 812789400, 337626212, 224809214, 935934136, 823163420, 564452442, 962713789, 82269552, 468932607, 490172046, 687089529, 768277733, 336222352, 427957023, 581867042, 757160651, 937259497, 339476642, 638978097, 389212742, 477714383, 694932052, 588399211, 737894147, 83766649, 675409010, 615763214, 200459126, 870833028, 180777826, 269294076, 623017566, 286538156, 88124552, 682000641, 689606726, 918429007, 563507307, 873360562, 970133147, 980833321, 218496061, 414966033, 628801581, 833695725, 334323273, 945888523, 96260890, 808835191, 546305749, 17410437, 788505257, 117235238, 980535199, 696066423, 802063758, 46654191, 656288667, 117760215, 606837132, 779041380, 269256744, 934474781, 58302571, 973486974, 385093945, 402417524, 353733278, 715338240, 393165821, 541938705, 887722138, 510676130, 22887649, 191130572, 583585556, 285126289, 794508926, 629355353, 810812298, 11138788, 885751157, 801020720, 155832600, 443562373, 677529647, 532819221, 538057234, 861345991, 278129691, 235240013, 630224203, 513436010, 41969914, 315320771, 112512865, 304735790, 462299628, 263724880, 539359109, 367295235, 708352639, 273514634, 292527186, 203352191, 329958072, 225281078, 271286045, 573983549, 529222715, 854419519, 632234599, 936439778, 181344828, 400901962, 464266790, 614572029, 541551645, 803775030, 168433586, 740852788, 275654154, 275709948, 695707145, 156940333, 411434841, 483548197, 710535555, 622302255, 403099577, 584468017, 747258874, 488244736, 210779744, 905582486, 902066596, 957582593, 411206343, 483571625, 803543211, 976948901, 799259730, 394720218, 537391355, 622004441, 466512392, 503256717, 350264162, 911689384, 403108804, 378743139, 840456167, 473622153, 998034594, 70642958, 837682978, 361492462, 562960588, 47544889, 660059853, 487618158, 860826481, 834046500, 260848227, 761441833, 698060210, 268971753, 195993798, 214106622, 41265063, 469323422, 564150184, 741927954, 950007368, 361233027, 379803151, 74715037, 860741914, 127576419, 96862192, 195047536, 875876455, 353190304, 108672899, 81263957, 252308829, 757925787, 905099541, 716311184, 180654650, 333247786, 133236849, 789372981, 218976532, 949975655, 973893372, 780744998, 630033851, 451914471, 619790591, 139958015, 812559603, 860597950, 561283947, 66386643, 142168667, 615867857, 459105367, 904528454, 474073767, 550928997, 947534173, 149723272, 215416051, 691878341, 869753212, 399446378, 803375998, 965065721, 518866187, 201033706, 804449084, 858397460, 816850849, 951111453, 260747319, 142501296, 636115045, 280712431, 847034914, 156744459, 466665120, 56548829, 65680009, 695889090, 497804508, 523001131, 144216652, 88592160, 701619079, 377250083, 317451008, 194387734, 786221043, 207034718, 449503942, 549807191, 573890799, 138403017, 436558917, 591187498, 742753156, 877161889, 853326616, 818748336, 243753942, 131648694, 695225315, 129388228, 238418217, 648916129, 419435637, 67152945, 859353274, 309051543, 775819598, 554320869, 672329985, 629708486, 337555732, 85291431, 846566179, 56195921, 790708680, 916723429, 97062059, 404617193, 642713490, 978839672, 160427061, 464787674, 232658480, 140758624, 158426935, 306087777, 60146592, 739143149, 590691270, 480228944, 751021659, 183912288, 231405247, 761274058, 793156786, 339742941, 144346777, 887474383, 7355448, 765568771, 516666124, 803677562, 468765587, 916858179, 877528256, 419961677, 871611111, 123818806, 106897460, 198208616, 278659738, 576064081, 860207641, 495889609, 233892033, 401133501, 48266857, 48621606, 819794935, 792396372, 846567053, 654052331, 164582094, 817104977, 982569902, 633496245, 221390154, 843550784, 280055238, 281641297, 19023741, 211860725, 476861067, 353283503, 171924066, 12404874, 699392211, 817897657, 368046748, 666490894, 432304656, 213751827, 38221437, 156730461, 591421321, 560695259, 463158087, 506259472, 748014837, 336744332, 522850752, 853149834, 685924528, 50043174, 104374614, 776567583, 758410071, 132636843, 22783718, 400844101, 140951446, 498703700, 294201046, 195511629, 399145996, 265054378, 945241686, 880285229, 911002299, 558992962, 529948612, 985215175, 830710462, 775977662, 319184503, 753939465, 404439086, 737018999, 459536186, 82659815, 444203013, 657965787, 500255983, 539456806, 949840014, 331261442, 874770277, 69955892, 647940019, 731884343, 49686299, 144676304, 212716247, 794011141, 31236451, 589124411, 308478090, 533680125, 269175743, 1178750, 1461502, 957633006, 263694179, 805047960, 140021926, 287320034, 580524028, 886732852, 339603541, 978799317, 327334915, 182276857, 382253882, 335262465, 94828135, 902394678, 586384312, 251922363, 989222351, 119746409, 738020062, 241157582, 324131931, 943252307, 321626638, 410078825, 560767279, 311505875, 303153744, 670975663, 604064725, 711826981, 354427925, 100926691, 554748580, 753289254, 658003199, 526561583, 826109612, 482470102, 744130143, 595583840, 440224354, 33775172, 474609376, 862235902, 876351312, 801271143, 327575355, 288324896, 425787099, 941855052, 878748572, 652999311, 593926808, 323139753, 448866799, 761537768, 224788685, 564199740, 419950081, 138835325, 157162448, 918518463, 229781043, 162752546, 803985988, 36237700, 734801304, 943846762, 438254587, 650448003, 525091525, 703308020, 716237083, 672012293, 674350759, 76036496, 682901298, 226949829, 83558187, 452351953, 158815624, 504378526, 127514973, 906239825, 296394950, 19804473, 499630603, 956177746, 361234844, 248049773, 853700339, 485273656, 572333161, 291650424, 986117348, 463429370, 21203090, 339728783, 97564928, 237265248, 723808022, 748312590, 439550973, 55086048, 422234095, 516245775, 470201486, 833021621, 769068429, 630981441, 282387912, 656384006, 715639298, 906030725, 744589867, 425974272, 902457237, 652064056, 685928545, 538809869, 306003586, 902399949, 433349986, 365349227, 229465474, 570735010, 823956184, 207950081, 311098833, 282392534, 582014532, 668383264, 881999692, 433746032, 877343632, 859141793, 420520441, 934110487, 473949242, 646311718, 641467593, 325412904, 556643167, 757313170, 887773099, 373897157, 571608955, 394183179, 383029922, 831123899, 836157353, 122621507, 539259358, 180320576, 124219203, 670195088, 330374454, 330988348, 633952682, 187622880, 588375571, 594121601, 575448812, 49141022, 742917666, 577995615, 583814950, 600228498, 193744677, 604098053, 682915731, 625212201, 632937454, 502418584, 915332122, 115719042, 406749840, 280372534, 755044979, 319211009, 507384162, 296458390, 548147486, 249587698, 11836626, 25741671, 614543254, 471008564, 262507615, 235439497, 400588424, 828009396, 693282611, 629501143, 321920214, 175447744, 169740896, 322798049, 366247436, 842974619, 225178254, 473960048, 161312326, 867188547, 323196539, 604369303, 741656654, 187293173, 349234625, 577419728, 343232255, 243655869, 942638882, 594242091, 819468675, 28591772, 371584345, 81493995, 449559149, 576397975, 647576431, 139213469, 745109557, 202164493, 468746338, 496537915, 559944679, 191915494, 695282728, 277292042, 495947018, 641632755, 111497866, 263113405, 60826313, 577486286, 65246205, 156492408, 635473964, 559274791, 198229013, 423700390, 319353632, 366742291, 375383783, 870496329, 513843707, 326194231, 595738336, 773645857, 949405460, 860143850, 223896466, 902000944, 915537214, 641516217, 761377407, 194618847, 583494828, 128287219, 269409489, 654286347, 725175099, 389801571, 758828617, 164645813, 643686935, 624658648, 52575635, 973836399, 334185325, 101197129, 998719476, 568203797, 255637013, 717374115, 148088087, 994281088, 321497519, 580599870, 581340896, 502657196, 894834642, 286241267, 330527681, 944611010, 45047166, 603757743, 279920384, 173122333, 861599666, 762652681, 611880298, 829369331, 654691655, 874061435, 812171670, 762390787, 840972353, 200470598, 690109045, 357005864, 842683990, 696589229, 59541454, 614377729, 278275377, 384289648, 705968155, 305538789, 47934553, 950013145, 244492197, 252057714, 680560438, 685938568, 624166911, 217740838, 47278883, 930834901, 48851288, 460540927, 200822142, 827023229, 268859553, 640204474, 711196768, 333368062, 167503464, 656513964, 203634541, 488114969, 523119815, 191274317, 319331326, 21784920, 282447495, 37956495, 883632266, 521853859, 93178470, 326611905, 636394420, 413541517, 595699362, 536650623, 981921683, 356639116, 807233372, 645429209, 732500109, 868754682, 876290443, 437209008, 982352473, 804157149, 643628342, 899998635, 147931676, 141013527, 30444891, 831337751, 116241967, 583470112, 365550547, 352011543, 882772328, 485673721, 769633562, 228716613, 791779909, 296576623, 570698294, 161343662, 945706227, 910664298, 185871486, 313035872, 676006652, 850218993, 644419057, 301234523, 108527500, 265903438, 623086072, 639268535, 121489258, 696407503, 836425962, 635879149, 626893905, 439856257, 489197050, 577978659, 840334831, 245368825, 186251767, 69672784, 150057178, 210649992, 530374697, 849445731, 560212686, 804087514, 982790640, 547219182, 244204727, 270543947, 996766190, 834847921, 336526959, 422953445, 882194985, 226702683, 659167416, 813663031, 824750068, 472819178, 891930829, 620557260, 750329860, 516740580, 207609471, 450809564, 721470651, 184233427, 678505237, 449943848, 335575504, 265162202, 995408933, 579784500, 956703704, 602166613, 531933391, 130936607, 283623012, 39277062, 448366875, 59802673, 461986506, 625514081, 623399654, 762005744, 39675701, 667556033, 574189318, 17210625, 310108991, 989898502, 871869387, 989859631, 339161179, 388560578, 87905648, 298033092, 312361025, 805672973, 140810100, 894733112, 114270777, 292092244, 136784015, 532296915, 429072566, 827341044, 572283409, 527529427, 501069020, 158578686, 632464359, 685413722, 31535858, 668632987, 939829588, 569307653, 779475876, 811543771, 751289678, 518984201, 487023369, 488239212, 156533746, 846850481, 336775451, 695252617, 591588201, 836744840, 82875182, 379060315, 93234497, 925125863, 491899257, 70845007, 677259069, 563183140, 93402510, 654492866, 374887786, 783518810, 761261934, 576213361, 94481817, 517473087, 60541279, 812121480, 287554445, 841788832, 863830519, 619801960, 324371589, 206449474, 181061176, 591325562, 480634613, 85461687, 36117475, 748652612, 44734773, 133213883, 355620225, 454877956, 228191243, 409653629, 482978729, 119144207, 470088667, 177675395, 429833274, 123239539, 138838396, 248936871, 961302342, 30543171, 119269577, 481307040, 25839074, 351793734, 882279911, 347107057, 709605152, 754463858, 160685079, 289006372, 245692922, 811575906, 318080152, 37400343, 209224042, 964099891, 642527923, 957773983, 306688568, 351500170, 950944003, 749488824, 228917626, 442812589, 462546347, 818938142, 721927314, 246502694, 819047375, 533354231, 301804181, 155246761, 920990516, 398024301, 216247914, 185603586, 827755661, 132504547, 937097757, 159686896, 680201237, 489958849, 291247491, 605639390, 640712222, 624543937, 784617275, 78106260, 530249799, 573272665, 945274654, 929148479, 257760751, 404211526, 588056426, 121853785, 191284067, 20203606, 432769195, 904243497, 172250364, 197907593, 503246808, 405161796, 465384113, 657604492, 500273698, 18114348, 429530952, 43348543, 594700827, 226402418, 598310414, 512639075, 916330543, 984223477, 368618946, 359594479, 839786349, 421593141, 250147236, 529388695, 3550398, 842239962, 162161302, 447505625, 641456342, 792298733, 59612153, 152689952, 43551000, 274412964, 734725216, 60803514, 291740484, 983037869, 1311716, 450866934, 500281188, 981388781, 362569883, 367687476, 210463946, 31672911, 891000854, 701327821, 43663151, 471278789, 382289343, 523118106, 722461445, 583745832, 244786919, 796993687, 992033994, 112262111, 566744895, 824724357, 202696142, 697822234, 12764784, 346997762, 833129814, 787268594, 313535022, 99515101, 822477159, 668412387, 980894945, 849224786, 586866586, 597748541, 889523095, 607630218, 697868188, 842517598, 326473743, 869907983, 157686167, 781535684, 621203308, 600804641, 388024154, 796892388, 402222681, 614217751, 155093037, 581385882, 174603588, 717169520, 205642535, 586303315, 678740453, 428464059, 446245349, 933206239, 875491673, 682281731, 686252214, 232865348, 388595414, 766396521, 922532465, 191701854, 227927997, 360921459, 704250559, 456876037, 773444029, 383774679, 465722716, 160618902, 68600481, 40663849, 487778753, 832771726, 2633569, 355057638, 765774506, 56304033, 475966017, 508738407, 1166700, 920667150, 459758754, 95889623, 45688073, 843709184, 31050986, 836864964, 477178992, 333834646, 361313826, 696147208, 108306645, 692447914, 882216026, 446969737, 858772375, 416431544, 662977172, 881885302, 727297678, 98351451, 208692862, 837840014, 662783024, 458103202, 785528643, 212081005, 777939524, 947725060, 907766036, 322768732, 898912503, 277294436, 515409636, 632614375, 512114558, 752134983, 949642223, 705117151, 853851090, 742709285, 507469717, 434532748, 180052, 924612691, 70644757, 344138341, 138450043, 473646803, 20513509, 849737487, 525041828, 659788778, 721819179, 586125901, 821176124, 315025188, 138715635, 385342297, 819672377, 698177748, 47645272, 603555243, 170766371, 129547867, 291664176, 105726656, 169986169, 796846466, 778436450, 246153283, 214010804, 640353684, 999687936, 822832579, 869719149, 142793254, 740802080, 301025868, 530531016, 263503425, 896134515, 529884461, 319308821, 415710338, 936759717, 147805512, 33826834, 458515835, 302178300, 658962478, 268806969, 240454631, 352765263, 212175277, 753692670, 822502636, 132197363, 874545414, 579838682, 593129312, 164112662, 254625423, 843092934, 801619573, 946388189, 3596568, 538974994, 651359120, 872890956, 420448975, 303482060, 57242847, 514150474, 544789707, 168300513, 214259496, 673730347, 967542088, 379496204, 42945519, 395760268, 813918295, 335876073, 497801287, 646239999, 803865989, 901073627, 791406554, 244330478, 487746010, 447170004, 386551640, 838891740, 544766261, 226629213, 872186745, 932261977, 334424560, 201122084, 656323143, 873348042, 269987830, 91644718, 831471622, 464128561, 192331895, 671459075, 375783329, 688168588, 262421728, 709406516, 959847674, 726327804, 511264255, 41035399, 692504374, 275390575, 337671249, 113018216, 113180362, 172440826, 549235825, 944737029, 875164427, 933196399, 145138837, 274494926, 374517159, 272239745, 681113477, 841298381, 96719922, 605493561, 842637349, 468463264, 223371941, 145779732, 621237833, 817115860, 280521783, 670916090, 62779831, 162186617, 540662698, 465231245, 118732405, 725150874, 265342426, 492614658, 195246452, 868948560, 326217878, 30120209, 921755601, 267646300, 940895520, 250313648, 842267782, 688914872, 636659134, 406461880, 270291025, 819346506, 6775093, 485133474, 324365371, 408282623, 812623555, 859208784, 293250026, 98151864, 925268341, 918213101, 100090356, 55961186, 418816900, 753495549, 886594826, 421914696, 251725894, 326236021, 218291838, 91393947, 71933385, 786501313, 518240112, 450061161, 598592462, 711802289, 342915369, 594108618, 387402445, 308786020, 674791912, 332682590, 36809873, 274582534, 837151186, 184710866, 15967339, 629403717, 87966841, 444472370, 229074038, 46165552, 859723523, 735397400, 790056707, 550092544, 616387449, 601914095, 420093728, 999877784, 518114179, 586172965, 86929212, 327828681, 772529624, 441432296, 975543639, 859985407, 306078227, 401356795, 719702145, 792042541, 910411007, 995819256, 511326436, 56959075, 481231003, 158632156, 556434001, 435633362, 518847211, 188121729, 874953534, 5245616, 358865627, 941160105, 525982817, 307737821, 677139331, 620423843, 810741954, 534982263, 896628207, 545020618, 807446919, 783872387, 571988477, 920989942, 733037908, 156877485, 798974495, 380168081, 498713695, 102842576, 452417792, 139699834, 605030718, 220414067, 225036942, 956751179, 273663287, 926959201, 5671483, 426905995, 975075985, 797254696, 774972346, 171460980, 612254081, 657842918, 47618676, 709991740, 234168149, 456952050, 306536017, 600969034, 651518524, 167484435, 202503886, 911783775, 788840383, 644943333, 696631250, 558805048, 69865320, 803773277, 348630797, 168142925, 886486656, 438378225, 599083541, 456816581, 935098094, 493659378, 367292705, 1232245, 606451861, 792015328, 37537007, 105647226, 384738726, 992288064, 912227187, 874686392, 269803473, 842767156, 401296861, 967979335, 50202221, 730611407, 277011142, 440355006, 198178319, 906391954, 271377245, 979969848, 671352140, 838606563, 496318039, 765522032, 529372283, 209706909, 881113368, 554301445, 287153235, 853708705, 777500324, 431682823, 169951855, 96873812, 550448445, 645192688, 691170218, 478738719, 384581000, 847155047, 845263280, 477517958, 702932354, 945480292, 237847576, 777300714, 409159808, 873662373, 442064594, 409523810, 680820046, 633123026, 76604599, 552711621, 99511163, 819826875, 412655362, 518054614, 108873956, 264000122, 620392371, 825984322, 87019144, 660892253, 416648453, 914551651, 93439787, 546399336, 519861118, 671931819, 548005044, 422525703, 137634184, 212805312, 869824349, 866157754, 235816911, 446877404, 724147776, 957251692, 36888532, 277361976, 13703309, 804946204, 111472087, 188029241, 670158597, 467892649, 707099434, 953715809, 678442180, 828612636, 696143850, 862461018, 238548793, 64988052, 984526006, 449965788, 352025977, 458148713, 416975659, 850099020, 601320047, 123383130, 62834090, 78549220, 98579267, 59683850, 177929115, 16134918, 531036895, 856739881, 418395242, 950816507, 514232505, 977543466, 698846688, 130232695, 634460497, 766232430, 905962747, 634134799, 993401029, 251572998, 676486573, 654489732, 981380828, 47815241, 586601800, 20042899, 364638559, 154935407, 74060250, 270344602, 998521085, 963056464, 140790065, 843393435, 993295826, 871535267, 534772430, 98334372, 528495158, 294906382, 792645256, 309016123, 401864545, 235297029, 472750212, 996424010, 105341760, 420412184, 945571270, 779295380, 106556293, 103355753, 36230143, 181468769, 475321275, 183231147, 994898920, 331651276, 499985564, 207503846, 736148214, 611354962, 354928909, 991185503, 787448632, 823324736, 746083534, 819465161, 187532304, 432583396, 421167840, 879802773, 367208103, 540832694, 59136142, 956778591, 672044035, 880806707, 180233300, 385234332, 584806418, 953200890, 368339596, 411665993, 258108479, 373198053, 411031644, 872829449, 486642891, 2225594, 651216637, 216200232, 375536013, 344321887, 307697391, 434230854, 875380565, 837997241, 582892501, 5861281, 172160251, 19937778, 236149098, 28800795, 555081169, 329835072, 996050319, 789999878, 161020328, 539109259, 901529879, 590492958, 462779846, 906680399, 813158064, 947754104, 531145040, 624789154, 617682534, 155712091, 129337766, 149701592, 56650903, 784040531, 915483581, 623910704, 731506141, 391856092, 487171875, 92063875, 482209578, 357026910, 880294192, 747170733, 141407073, 881944086, 771904391, 533497178, 689499078, 593718566, 234144388, 963852220, 587372808, 398492831, 292131535, 646054685, 543299512, 258922278, 411848740, 917431603, 534178942, 944989636, 60982709, 153089973, 80295751, 130903635, 490185648, 366790761, 429843510, 64085106, 778903410, 781071717, 521286653, 757896559, 684337527, 532624635, 426787858, 293248259, 801880487, 378047990, 127996895, 717928101, 430612897, 103269544, 553384892, 901753373, 833899513, 863114644, 871028760, 117532800, 323447996, 117586713, 546992450, 611725986, 555737156, 964930133, 332924962, 524669778, 889935840, 898329785, 504747628, 500202599, 967320952, 780303143, 602744582, 108383141, 564665841, 231806541, 906091243, 593500914, 9219371, 404742053, 532241381, 412789539, 692959627, 404727219, 913855035, 977296766, 169497134, 127366359, 482982783, 769150939, 980820760, 478878381, 885117851, 172901064, 842437752, 572079074, 586575138, 207538904, 565863658, 338346702, 468351194, 242884698, 865946528, 865163156, 805811711, 372494334, 192139281, 943066073, 855092827, 609833251, 325969593, 198236605, 125209890, 451762084, 586267128, 233072657, 258280054, 113800915, 893434140, 108762223, 812851409, 633242015, 920448830, 170036844, 378219952, 510576250, 427160986, 292480736, 209465994, 796547027, 457835582, 531560456, 713907160, 333576540, 444866688, 242645128, 192482369, 109251370, 964773378, 111865844, 320812754, 100517957, 384918094, 143527722, 713068761, 22598183, 374967073, 799522713, 743155113, 259330669, 716801288, 769882662, 554425144, 563901400, 905911188, 864970670, 586073534, 389919068, 455328168, 420042212, 89329569, 614041725, 529154931, 911568272, 684124692, 35861969, 286675533, 526172708, 547234350, 373906704, 69034834, 158626168, 245153447, 448602753, 677768859, 881316941, 806536268, 44659730, 996592481, 565239374, 815923052, 919803451, 997828061, 648219685, 938491554, 749598235, 219257523, 227858012, 749769992, 783599982, 884589518, 300067411, 572674833, 376179574, 539483737, 67737458, 746954245, 565241350, 725709930, 258284241, 173027539, 177873064, 469930298, 54148396, 90145094, 839815004, 71896629, 377553215, 511775165, 859870052, 934427222, 844104709, 781665649, 288171231, 341557142, 769731175, 155376533, 289736346, 602644777, 499988094, 482142157, 905765097, 718593617, 919677967, 332349942, 280053085, 938306670, 958630611, 649562435, 830671300, 896072051, 162762783, 552141131, 424863933, 459545739, 66606178, 315292162, 256139658, 756512767, 206821732, 762070138, 606482390, 121810837, 660913399, 129402673, 933492167, 943041391, 788077201, 748330622, 265989911, 568945918, 817213724, 680134040, 83226625, 783111327, 789998755, 256798969, 426431581, 23087136, 180976413, 662538886, 3923227, 58926973, 876719809, 398700228, 104863177, 323999651, 531784783, 683491905, 51484472, 641541658, 432645242, 659022974, 579710324, 60865282, 341615178, 208915242, 699327442, 465600427, 247474658, 993815399, 343743464, 6548210, 3529874, 473658657, 403971918, 792212683, 910757416, 143300380, 791869596, 205618069, 747461584, 833281283, 777295920, 879660914, 830983721, 267886116, 420302138, 7167532, 65734033, 364965042, 895916440, 455185945, 723685816, 704588859, 289553801, 817198376, 361925995, 824499280, 780160863, 821402442, 636768070, 388392168, 685786718, 151759730, 327074411, 131321076, 157450803, 559054984, 313833371, 514245903, 121786188, 850720440, 2433945, 595370553, 483457449, 156224269, 424429879, 354338464, 986873091, 418595769, 596801355, 205515431, 687126830, 485740876, 307132889, 197038091, 372246142, 468621936, 137642318, 102819588, 703986556, 109014100, 710681929, 668120664, 987440443, 162389784, 982494261, 551067739, 422152441, 959497683, 394437930, 995025745, 127311714, 506307202, 129588099, 802684890, 701532157, 791020442, 20842068, 482025054, 35892130, 328604191, 339084115, 966216753, 796196264, 785343007, 223029061, 414583231, 523157608, 914520468, 608227254, 300039679, 755197673, 501662030, 195835363, 810040514, 623160582, 342410148, 219592898, 10358260, 227034517, 21611961, 43003706, 996268507, 252755805, 826913063, 533398942, 730096612, 615570581, 234601472, 294599143, 79199785, 147475685, 787464723, 263862821, 398554850, 545241422, 380986324, 680179859, 592136120, 608373575, 110246921, 778116089, 310296955, 762001485, 451646209, 139991283, 553728233, 44350891, 947401732, 276372022, 103337128, 997495587, 11976413, 76254517, 724296611, 410627640, 318008847, 425621433, 221550610, 638391760, 487761231, 445075121, 773320485, 587658077, 821762056, 587294858, 406692267, 287039278, 691553557, 653184465, 119570830, 941818398, 496127501, 18538357, 623610233, 24069549, 373087986, 668498655, 848621488, 101885328, 453781003, 18019489, 294185505, 713869682, 977172836, 907631531, 970298342, 168691919, 388272420, 799425250, 974169388, 294324646, 53005175, 329170381, 623786157, 324319036, 876771345, 369451495, 269694154, 400242685, 815302420, 293992773, 272822761, 471661089, 45848278, 541588497, 288424467, 963934844, 232603134, 898466110, 36007870, 704440929, 407363557, 811648626, 827820387, 731808565, 750934586, 485217590, 422790141, 729484465, 360856738, 3059306, 368101936, 120838999, 36678591, 592207169, 776390431, 819769689, 677958023, 761236548, 7977825, 475072399, 128518217, 46820800, 315968517, 887823605, 257615535, 44266461, 286900128, 539018505, 393019227, 50859974, 175540764, 226515631, 603321800, 433225139, 988863672, 688246765, 960411637, 822531363, 231615757, 119131685, 355879366, 251249285, 576290565, 477705138, 607617927, 585972435, 177943269, 583143427, 774534766, 868986368, 722056172, 889522541, 438862517, 600148340, 94689233, 142772181, 514620055, 595557543, 435512676, 36440987, 749250782, 602363754, 164276830, 584180568, 709528094, 990216699, 669522557, 238496508, 78949740, 301729352, 230413467, 959879981, 325230669, 550670209, 865128003, 546737162, 499235749, 777308647, 300346240, 500890858, 282170346, 488865405, 248791409, 334147287, 708388350, 816453285, 176114429, 957939063, 886047768, 708963144, 697977374, 704971232, 918025685, 632120122, 887531271, 206613128, 380832883, 706547402, 734619578, 378996759, 825975760, 494617547, 427347432, 659804776, 386773363, 52304702, 56924900, 310212051, 586691326, 90908552, 122390863, 716251656, 942248484, 682415058, 737074528, 436318097, 767305627, 819021923, 397877645, 363636954, 866056078, 479246540, 646928330, 592177953, 131864218, 707805721, 588661130, 819649589, 692117001, 644337523, 726171866, 575372698, 285579003, 563857792, 545663267, 305770135, 269299931, 43250086, 953969848, 383335298, 225568858, 813939478, 696767501, 439847794, 476097217, 895749299, 305320750, 104033263, 578392145, 113766013, 953740400, 872775389, 271840925, 623336895, 592115780, 851162017, 582768715, 341022716, 198703208, 177080762, 381955353, 30430394, 833266985, 723965441, 864032355, 944277486, 748385678, 509012418, 593693896, 335329096, 350631997, 569487549, 267443673, 833703097, 168296111, 795026893, 53475082, 209743814, 215050414, 314719065, 570500925, 610798556, 548014586, 93219050, 429735006, 907937966, 937839127, 297954056, 628331297, 801802585, 930528779, 826281378, 680190339, 960733802, 427535202, 20740255, 382981666, 486105223, 838351314, 212100613, 188528009, 211294762, 128019468, 907977594, 10205221, 250757692, 533958963, 356284943, 933489330, 473547811, 895551926, 387173515, 108015703, 183586968, 19446759, 196913431, 482787458, 747269219, 37899043, 90700746, 184220044, 433428930, 419779650, 700461814, 375816557, 636982812, 56327803, 771275194, 414396165, 392666456, 830820859, 630977952, 913261644, 654782456, 851203558, 172849301, 199175644, 158712322, 202973249, 228958858, 639335656, 933651652, 694498898, 931852394, 940598537, 661107129, 313457555, 548316638, 651038241, 156256065, 454065506, 646271223, 660430208, 944512758, 997836610, 807588258, 861770194, 631032200, 198767246, 149612733, 946007698, 332125353, 767160056, 256725611, 61915975, 796523526, 6461577, 888532238, 682840214, 989254528, 529007925, 871500558, 972311554, 49136173, 940966952, 609881654, 346058363, 258601583, 822705382, 555619968, 546495208, 33355632, 582158518, 376094423, 377314877, 109012397, 562625298, 460675835, 72848863, 40175791, 500986535, 605668884, 328914416, 679186061, 787332209, 966259518, 874952833, 907768858, 548995440, 910852962, 216373601, 741069045, 842835493, 669237279, 268927126, 620207641, 496485599, 405590386, 260835794, 93381747, 28069217, 230151615, 925376271, 946197680, 49519012, 760051398, 185733717, 750686951, 934176884, 999690003, 737620331, 336994517, 880193083, 115067519, 387151027, 71933570, 915430219, 690019207, 70415381, 84430381, 618510196, 341258986, 759839554, 448521996, 146685527, 543712436, 352763876, 93107738, 825085744, 894186729, 686951667, 971024177, 508711332, 926126173, 970500519, 221978322, 870385137, 934250717, 739401950, 363083566, 43378335, 453042975, 847720290, 125879658, 745171024, 82104732, 683403978, 373561365, 340085436, 962297864, 935576511, 185489514, 99739329, 977232798, 430526400, 565570301, 461509967, 300107580, 798317091, 570463834, 359349925, 989743110, 497096487, 331995104, 754339462, 614050726, 869316332, 77064807, 764157035, 810422477, 164784290, 896246113, 650915167, 388737822, 702314708, 964609734, 209685027, 189971786, 324616996, 106540882, 608830818, 119563576, 3058914, 308836524, 278081051, 576172772, 251887389, 713418859, 349490038, 720379091, 365105188, 775159137, 152588694, 100912429, 832849921, 507885523, 737697148, 725994404, 744328532, 198906889, 480578480, 54805002, 54474587, 919906015, 265051738, 462280777, 810550510, 804357584, 603824122, 655421135, 968270273, 696764835, 601397497, 986710172, 137934441, 730296669, 181876371, 195284852, 156587911, 280151811, 79668537, 618758786, 912255998, 36763440, 468918542, 261842521, 124742670, 402181587, 956307800, 359302215, 224687918, 618757581, 409588132, 457357683, 652276564, 82641982, 3000029, 940376792, 750137092, 319384231, 475481080, 834055693, 164416300, 601000540, 50424970, 333721078, 354848138, 765407464, 882498361, 403648102, 836079123, 248038824, 351275683, 294884371, 609519174, 952334941, 536694766, 130453658, 687970810, 306131845, 855571363, 529868521, 865671170, 749044693, 716672811, 923884347, 546151229, 867313129, 353889640, 364975371, 306622369, 468733099, 642473829, 914125240, 412097603, 292154597, 950687500, 843237528, 791025913, 516221152, 199933385, 961029432, 308014700, 397820273, 115997954, 533956215, 560114662, 96508152, 5657528, 965570091, 560103363, 471910206, 90381073, 993960455, 344158979, 423462656, 498536712, 216795332, 4788407, 502795944, 769754181, 406454389, 731645472, 520806212, 696301111, 185796972, 690052977, 75044155, 600813974, 806497114, 732227888, 378416075, 133744649, 136396823, 586052600, 57296287, 479039736, 744997979, 855597174, 86667473, 938405734, 677472929, 556784569, 998181506, 149194723, 676607822, 272597146, 130301873, 554428409, 732689840, 20874904, 908283204, 722489186, 841665236, 376145436, 929535614, 363832905, 337319497, 625944178, 70758268, 951903862, 551344434, 810462249, 536468603, 219503118, 687169808, 929574489, 808101058, 359486553, 347225643, 576930946, 417360386, 3329032, 197693666, 975162746, 801714206, 895794803, 886270285, 66369355, 435382822, 205933435, 106138794, 808619969, 676033730, 176796226, 722283829, 161063191, 383174325, 200158330, 186008006, 247435890, 668610562, 845328954, 217211323, 451985424, 666497651, 293995987, 511506481, 348377533, 47582578, 157815818, 41103456, 60000092, 695443282, 93800930, 784839550, 968145173, 752837652, 466189147, 35554215, 362917443, 551733399, 639175762, 369141514, 469459025, 733529711, 540366352, 846075197, 108123819, 402057496, 791121975, 673122780, 765959199, 119874001, 317238847, 877248235, 105673171, 789353252, 572656305, 967624498, 492153789, 65887084, 219919253, 776534108, 390692757, 196433474, 978342517, 35069065, 291353487, 599911979, 676946446, 312032250, 447463174, 241512195, 890378606, 53777113, 185858508, 985091242, 665725801, 90670500, 840049223, 220783907, 17799964, 212554815, 814765489, 923606375, 503829867, 422846930, 419597683, 541334861, 138816727, 678920213, 16168517, 892631744, 337980182, 450691114, 810998497, 955955638, 927578939, 768290526, 401284843, 314003245, 158101178, 991720754, 683732062, 214303153, 184766129, 222302705, 778113421, 504354270, 162637291, 530710674, 362262307, 2811227, 516679778, 361436582, 523992068, 457519531, 54740508, 909096148, 967440652, 665324618, 888764591, 876946744, 593106900, 891056000, 929801901, 57758754, 267471814, 43873246, 992740082, 26772310, 643786251, 883390177, 797945328, 65252516, 469078816, 527220000, 201720227, 460210846, 158289008, 59245903, 692324063, 925710201, 459606499, 606580397, 825597607, 824971214, 201517398, 960610461, 907056275, 329879060, 812571337, 387508805, 991193196, 725418735, 606527342, 987943992, 49050524, 356556895, 771219714, 418499614, 871783994, 118389254, 275338430, 466006625, 369862772, 203833368, 14917929, 517127402, 455312181, 572398452, 446101184, 716265411, 855927469, 871359111, 140369135, 437100015, 484276304, 449477358, 525372459, 309115248, 326277795, 200269228, 838113260, 840976052, 746405029, 16862725, 244606888, 851679845, 138677504, 828914179, 560422196, 320942742, 183913669, 928794993, 813603445, 762030432, 525683804, 309698327, 784779396, 34930254, 38658947, 10532888, 479215749, 569047154, 190876422, 181148058, 161501724, 115666163, 665675032, 877942480, 995932315, 116621881, 273362134, 291234249, 262095098, 674764553, 484405473, 828616584, 189193455, 290047178, 229388324, 463136059, 243595123, 741268707, 978943108, 473866544, 953889606, 621381682, 913182612, 284711891, 605228304, 264465044, 662466665, 127754639, 882528438, 568090482, 973284017, 205351333, 280529046, 887860832, 738853831, 690079520, 294994340, 593686044, 31614554, 47956520, 487648986, 480908507, 183228239, 347576595, 128124270, 792925712, 7158718, 351916494, 366954372, 490133813, 329079626, 992837333, 716721800, 92561043, 72861809, 865693480, 443406576, 572478109, 739883009, 740775384, 661080773, 703180555, 341679433, 515858621, 978352891, 480071698, 508297069, 529652227, 746684292, 268442032, 17041056, 18149147, 687895777, 955887455, 766479705, 490146579, 645783608, 30300672, 201844195, 692631914, 589990283, 284781791, 773150348, 529208618, 97282823, 912843566, 189329436, 756282046, 490400174, 226641219, 653069797, 746597682, 694267620, 844880489, 365159711, 171116257, 751576250, 171245715, 774554815, 876348962, 72679, 550625494, 112647398, 480766880, 131795033, 203730735, 133151145, 911000868, 175853718, 915669304, 138661461, 452864047, 520929322, 392888914, 747299979, 622592554, 758709846, 301106092, 899503065, 566677368, 75366924, 711105319, 741204122, 699275276, 726402394, 882320213, 307687771, 676058177, 877243591, 189056754, 205933950, 875168003, 725607634, 975934046, 244758754, 682495709, 5545997, 205042174, 386621049, 652799295, 930637125, 594018854, 110627697, 243894831, 680287391, 598264048, 601088940, 925041594, 767028491, 478194261, 689016228, 591386459, 978267456, 291197508, 962496188, 699207052, 566502831, 326772939, 758834882, 32744888, 519293618, 620000224, 127912367, 584090246, 798003011, 680376153, 115576611, 655464422, 805752499, 874299241, 793646546, 983050504, 470407199, 665687598, 845365695, 675258725, 893328504, 544855772, 941363551, 591235690, 750342949, 227344141, 657069598, 229537726, 596511890, 812829831, 18593149, 878206561, 78858138, 81852260, 385322041, 449677685, 324659787, 87460357, 216240448, 686223360, 529299231, 900891317, 971537431, 171719009, 333573854, 759776731, 556673911, 980060872, 480289478, 992517097, 637425330, 927043462, 359308972, 198226729, 150150203, 717078614, 869889309, 372445613, 963090584, 887152663, 523665476, 396429886, 180966881, 138343946, 125228861, 975930048, 537747175, 151830395, 895644995, 374147006, 30179012, 112442473, 438060220, 348787293, 659020304, 217474080, 272084072, 778679954, 92132532, 220558153, 225194975, 884517919, 209759140, 229702360, 884899658, 936679721, 901097174, 687690273, 684753724, 442961424, 388472872, 72257155, 289517989, 356082114, 602719494, 105857575, 820490502, 663490136, 959644718, 805616097, 594014096, 745474639, 81893404, 126379358, 667338088, 697970197, 653312497, 132406261, 734736602, 198516421, 302338237, 195954723, 670411472, 716295487, 176369790, 323400315, 236806827, 356519813}, + 14861, + }, + + // 可以有多个 testcase +} + +func Test_subarrayBitwiseORs(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, subarrayBitwiseORs(tc.A), "输入:%v", tc) + } +} + +func Benchmark_subarrayBitwiseORs(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + subarrayBitwiseORs(tc.A) + } + } +} diff --git a/Algorithms/0899.orderly-queue/README.md b/Algorithms/0899.orderly-queue/README.md new file mode 100755 index 000000000..7e86f2c88 --- /dev/null +++ b/Algorithms/0899.orderly-queue/README.md @@ -0,0 +1,38 @@ +# [899. Orderly Queue](https://leetcode.com/problems/orderly-queue/) + +## 题目 + +A string `S` of lowercase letters is given. Then, we may make any number of moves. + +In each move, we choose one of the first `K` letters (starting from the left), remove it,`and place it at the end of the string. + +Return the lexicographically smallest string we could have after any number of moves. + +Example 1: + +```text +Input: S = "cba", K = 1 +Output: "acb" +Explanation: +In the first move, we move the 1st character ("c") to the end, obtaining the string "bac". +In the second move, we move the 1st character ("b") to the end, obtaining the final result "acb". +``` + +Example 2: + +```text +Input: S = "baaca", K = 3 +Output: "aaabc" +Explanation: +In the first move, we move the 1st character ("b") to the end, obtaining the string "aacab". +In the second move, we move the 3rd character ("c") to the end, obtaining the final result "aaabc". +``` + +Note: + +- `1 <= K <= S.length<= 1000` +- `S`consists of lowercase letters only. + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0899.orderly-queue/orderly-queue.go b/Algorithms/0899.orderly-queue/orderly-queue.go new file mode 100755 index 000000000..3faef2042 --- /dev/null +++ b/Algorithms/0899.orderly-queue/orderly-queue.go @@ -0,0 +1,42 @@ +package problem0899 + +import ( + "sort" +) + +func orderlyQueue(s string, k int) string { + if k == 1 { + return minRotated(s) + } + // 当 k >=2 时 + // 前两个位置上的字母,总是把较小的字母移到末尾 + // 经过 len(s)-1 次比较后,s 中最大的字母,一定在前两个位置中, + // 此时,把 s 中最大的字母移到末尾。 + // 以此类推,可以形成一个冒泡排序。 + // 所以,当 k >= 2 时,可以直接对 s 进行排序 + // 当 k = 1 时,无法进行比较 + // 就只能通过回转 s 来查看最小的字符串了 + return sorted(s) +} + +func minRotated(s string) string { + min := s + bytes := []byte(s) + bytes = append(bytes, bytes...) + size := len(s) + for i := 1; i < size; i++ { + rs := string(bytes[i : i+size]) + if min > rs { + min = rs + } + } + return min +} + +func sorted(s string) string { + bytes := []byte(s) + sort.Slice(bytes, func(i int, j int) bool { + return bytes[i] < bytes[j] + }) + return string(bytes) +} diff --git a/Algorithms/0899.orderly-queue/orderly-queue_test.go b/Algorithms/0899.orderly-queue/orderly-queue_test.go new file mode 100755 index 000000000..62c01e244 --- /dev/null +++ b/Algorithms/0899.orderly-queue/orderly-queue_test.go @@ -0,0 +1,59 @@ +package problem0899 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + K int + ans string +}{ + + { + "cba", + 1, + "acb", + }, + + { + "edcba", + 5, + "abcde", + }, + + { + "dasfkasdlkfasdlkjflaksdjflksdajflkasdjflksdajflkasdjflkasdj", + 3, + "aaaaaaaaadddddddddffffffffjjjjjjjkkkkkkkkkllllllllsssssssss", + }, + + { + "baaca", + 3, + "aaabc", + }, + + // 可以有多个 testcase +} + +func Test_orderlyQueue(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, orderlyQueue(tc.S, tc.K), "输入:%v", tc) + } +} + +func Benchmark_orderlyQueue(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + orderlyQueue(tc.S, tc.K) + } + } +} diff --git a/Algorithms/0900.rle-iterator/README.md b/Algorithms/0900.rle-iterator/README.md new file mode 100755 index 000000000..f32e93efa --- /dev/null +++ b/Algorithms/0900.rle-iterator/README.md @@ -0,0 +1,39 @@ +# [900. RLE Iterator](https://leetcode.com/problems/rle-iterator/) + +## 题目 + +Write an iterator that iterates through a run-length encoded sequence. + +The iterator is initialized by `RLEIterator(int[] A)`, where `A` is a run-length encoding of some `sequence.` More specifically, for all even `i, A[i]` tells us the number of times that the non-negative integer value `A[i+1]` is repeated in the sequence. + +The iterator supports one function:`next(int n)`, which exhausts the next `n` elements (`n >= 1`) and returns the last element exhausted in this way. If there is no element left to exhaust, `next` returns `-1` instead. + +For example, we start with `A = [3,8,0,9,2,5]`, which is a run-length encoding of the sequence `[8,8,8,5,5]`. This is because the sequence can be read as "three eights, zero nines, two fives". + +Example 1: + +```text +Input: ["RLEIterator","next","next","next","next"], [[[3,8,0,9,2,5]],[2],[1],[1],[2]] +Output: [null,8,8,5,-1] +Explanation: +RLEIterator is initialized with RLEIterator([3,8,0,9,2,5]). +This maps to the sequence [8,8,8,5,5]. +RLEIterator.next is then called 4 times: + +.next(2) exhausts 2 terms of the sequence, returning 8. The remaining sequence is now [8, 5, 5]. + +.next(1) exhausts 1 term of the sequence, returning 8. The remaining sequence is now [5, 5]. + +.next(1) exhausts 1 term of the sequence, returning 5. The remaining sequence is now [5]. + +.next(2) exhausts 2 terms, returning -1. This is because the first term exhausted was 5, +but the second term did not exist. Since the last term exhausted does not exist, we return -1. +``` + +Note: + +- 0 <= A.length <= 1000 +- A.length`is an even integer. +- 0 <= A[i] <= 10^9 +- There are at most 1000 calls to `RLEIterator.next(int n)` per test case. +- Each call to `RLEIterator.next(int n)` will have 1 <= n <= 10^9. diff --git a/Algorithms/0900.rle-iterator/rle-iterator.go b/Algorithms/0900.rle-iterator/rle-iterator.go new file mode 100755 index 000000000..3f4fefa99 --- /dev/null +++ b/Algorithms/0900.rle-iterator/rle-iterator.go @@ -0,0 +1,50 @@ +package problem0900 + +// RLEIterator object will be instantiated and called as such: +// obj := Constructor(A); +// param_1 := obj.Next(n); +type RLEIterator struct { + es []entry +} + +type entry struct { + count, number int +} + +// Constructor is +func Constructor(a []int) RLEIterator { + size := len(a) + es := make([]entry, 0, size/2) + for i := 0; i+1 < size; i += 2 { + if a[i] == 0 { + continue + } + es = append(es, entry{ + count: a[i], + number: a[i+1], + }) + } + return RLEIterator{ + es: es, + } +} + +// Next is +func (r *RLEIterator) Next(n int) int { + var prev entry + for len(r.es) > 0 && r.es[0].count <= n { + n -= r.es[0].count + prev, r.es = r.es[0], r.es[1:] + } + + if len(r.es) == 0 && n > 0 { + return -1 + } + + if n == 0 { + return prev.number + } + + r.es[0].count -= n + return r.es[0].number +} diff --git a/Algorithms/0900.rle-iterator/rle-iterator_test.go b/Algorithms/0900.rle-iterator/rle-iterator_test.go new file mode 100755 index 000000000..7fadf095e --- /dev/null +++ b/Algorithms/0900.rle-iterator/rle-iterator_test.go @@ -0,0 +1,24 @@ +package problem0900 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_RLEIterator(t *testing.T) { + ast := assert.New(t) + + ints := []int{3, 8, 0, 9, 2, 5} + + r := Constructor(ints) + + nums := []int{2, 1, 1, 2} + expecteds := []int{8, 8, 5, -1} + + for i, n := range nums { + expected := expecteds[i] + actual := r.Next(n) + ast.Equal(expected, actual) + } +} diff --git a/Algorithms/0901.online-stock-span/README.md b/Algorithms/0901.online-stock-span/README.md new file mode 100755 index 000000000..d75d74d69 --- /dev/null +++ b/Algorithms/0901.online-stock-span/README.md @@ -0,0 +1,35 @@ +# [901. Online Stock Span](https://leetcode.com/problems/online-stock-span/) + +## 题目 + +Write a class `StockSpanner` which collects daily price quotes for some stock, and returns the span of that stock's price for the current day. + +The span of the stock's price today is defined as the maximum number of consecutive days (starting from today and going backwards) for which the price of the stock was less than or equal to today's price. + +For example, if the price of a stock over the next 7 days were `[100, 80, 60, 70, 60, 75, 85]`, then the stock spans would be `[1, 1, 1, 2, 1, 4, 6]`. + +Example 1: + +```text +Input: ["StockSpanner","next","next","next","next","next","next","next"], [[],[100],[80],[60],[70],[60],[75],[85]] +Output: [null,1,1,1,2,1,4,6] +Explanation: +First, S = StockSpanner() is initialized. Then: +S.next(100) is called and returns 1, +S.next(80) is called and returns 1, +S.next(60) is called and returns 1, +S.next(70) is called and returns 2, +S.next(60) is called and returns 1, +S.next(75) is called and returns 4, +S.next(85) is called and returns 6. + +Note that (for example) S.next(75) returned 4, because the last 4 prices +(including today's price of 75) were less than or equal to today's price. +``` + +Note: + +- Calls to StockSpanner.next(int price) will have 1 <= price <= 10^5. +- There will be at most 10000 calls to StockSpanner.next per test case. +- There will be at most 150000 calls to StockSpanner.next across all test cases. +- The total time limit for this problem has been reduced by 75% for C++, and 50% for all other languages. \ No newline at end of file diff --git a/Algorithms/0901.online-stock-span/online-stock-span.go b/Algorithms/0901.online-stock-span/online-stock-span.go new file mode 100755 index 000000000..f2d040aaf --- /dev/null +++ b/Algorithms/0901.online-stock-span/online-stock-span.go @@ -0,0 +1,43 @@ +package problem0901 + +// StockSpanner object will be instantiated and called as such: +// obj := Constructor(); +// param_1 := obj.Next(price); +type StockSpanner struct { + prices []int // stack + days []int // stack +} + +// Constructor is +func Constructor() StockSpanner { + ps := make([]int, 1, 10000) + ds := make([]int, 1, 10000) + ps[0] = 1<<63 - 1 // more than max-price + ds[0] = -1 // the day before first-day + return StockSpanner{ + prices: ps, + days: ds, + } +} + +// Next is +func (s *StockSpanner) Next(price int) int { + i := len(s.prices) - 1 + // s.prices[i] 中保存了昨天的 price + // s.days[i] 中保存了昨天的 日期 + today := s.days[i] + 1 + + for i >= 0 { + if s.prices[i] > price { + // 深入 s.prices 栈,直到找到比 price 大的价格 + break + } + i-- + } + + res := today - s.days[i] + i++ + s.prices = append(s.prices[:i], price) + s.days = append(s.days[:i], today) + return res +} diff --git a/Algorithms/0901.online-stock-span/online-stock-span_test.go b/Algorithms/0901.online-stock-span/online-stock-span_test.go new file mode 100755 index 000000000..2b6c16ac5 --- /dev/null +++ b/Algorithms/0901.online-stock-span/online-stock-span_test.go @@ -0,0 +1,35 @@ +package problem0901 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_StockSpanner(t *testing.T) { + ast := assert.New(t) + // + nexts := []int{100, 80, 60, 70, 60, 75, 85} + expecteds := []int{1, 1, 1, 2, 1, 4, 6} + // + s := Constructor() + for i, n := range nexts { + expected := expecteds[i] + actual := s.Next(n) + ast.Equal(expected, actual) + } +} + +func Test_StockSpanner_2(t *testing.T) { + ast := assert.New(t) + // + nexts := []int{29, 91, 62, 76, 51} + expecteds := []int{1, 2, 1, 2, 1} + // + s := Constructor() + for i, n := range nexts { + expected := expecteds[i] + actual := s.Next(n) + ast.Equal(expected, actual) + } +} diff --git a/Algorithms/0902.numbers-at-most-n-given-digit-set/README.md b/Algorithms/0902.numbers-at-most-n-given-digit-set/README.md new file mode 100755 index 000000000..2e51d266a --- /dev/null +++ b/Algorithms/0902.numbers-at-most-n-given-digit-set/README.md @@ -0,0 +1,36 @@ +# [902. Numbers At Most N Given Digit Set](https://leetcode.com/problems/numbers-at-most-n-given-digit-set/) + +## 题目 + +We have a sorted set of digits `D`, a non-empty subset of `{'1','2','3','4','5','6','7','8','9'}.` (Note that '0' is not included.) + +Now, we write numbers using these digits, using each digit as many times as we want. For example, if `D = {'1','3','5'}`, we may write numbers such as `'13', '551', '1351315'`. + +Return the number of positive integers that can be written (using the digits of `D`) that are less than or equal to `N`. + +Example 1: + +```text +Input: D = ["1","3","5","7"], N = 100 +Output: 20 +Explanation: +The 20 numbers that can be written are: +1, 3, 5, 7, 11, 13, 15, 17, 31, 33, 35, 37, 51, 53, 55, 57, 71, 73, 75, 77. +``` + +Example 2: + +```text +Input: D = ["1","4","9"], N = 1000000000 +Output: 29523 +Explanation: +We can write 3 one digit numbers, 9 two digit numbers, 27 three digit numbers, +81 four digit numbers, 243 five digit numbers, 729 six digit numbers, +2187 seven digit numbers, 6561 eight digit numbers, and 19683 nine digit numbers. +In total, this is 29523 integers that can be written using the digits of D. +``` + +Note: + +- `D` is a subset of digits `'1'-'9'` in sorted order. +- `1 <= N <= 10^9` diff --git a/Algorithms/0902.numbers-at-most-n-given-digit-set/numbers-at-most-n-given-digit-set.go b/Algorithms/0902.numbers-at-most-n-given-digit-set/numbers-at-most-n-given-digit-set.go new file mode 100755 index 000000000..af854fe8c --- /dev/null +++ b/Algorithms/0902.numbers-at-most-n-given-digit-set/numbers-at-most-n-given-digit-set.go @@ -0,0 +1,57 @@ +package problem0902 + +import ( + "strconv" +) + +func atMostNGivenDigitSet(D []string, N int) int { + ns := strconv.Itoa(N) + size := len(D) + res := zeroLead(size, len(ns)) + return res + equal(D, ns) +} + +// 从 N 的高位往低位防止 D 中的数字,分为 3 种情况 +// 1. 可以选择不放置数字,但是一旦放置了,后续低位就不能不放置了,这一类数的特点是以 0 开头,其个数使用 zeroLead 函数计算。 +// 2. 比 N 对应位上的数字小,其后续低位可以任意放置 D 中的数字,其个数使用 less 函数计算。 +// 3. 与 N 对应位上的数字一样大,其后续低位上的数字需要分情况讨论,这一类数的个数,使用 equal 函数,递归计算。 + +func equal(D []string, ns string) int { + if len(ns) == 0 { + return 1 + } + size := len(D) + res := 0 + head := ns[0:1] + for _, d := range D { + switch { + case d < head: + res += less(size, len(ns)) + case d == head: + res += equal(D, ns[1:]) + } + } + return res +} + +// size 个数,组合成低于 length 位的数字的组合数 +func zeroLead(size, length int) int { + p := size + res := 0 + for length > 1 { + res += p + p *= size + length-- + } + return res +} + +// size 个数,组成 length-1 位数字的组合数 +func less(size, length int) int { + res := 1 + for length > 1 { + res *= size + length-- + } + return res +} diff --git a/Algorithms/0902.numbers-at-most-n-given-digit-set/numbers-at-most-n-given-digit-set_test.go b/Algorithms/0902.numbers-at-most-n-given-digit-set/numbers-at-most-n-given-digit-set_test.go new file mode 100755 index 000000000..dfb92f87b --- /dev/null +++ b/Algorithms/0902.numbers-at-most-n-given-digit-set/numbers-at-most-n-given-digit-set_test.go @@ -0,0 +1,128 @@ +package problem0902 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + D []string + N int + ans int +}{ + + { + []string{"9"}, + 55, + 1, + }, + + { + []string{"7"}, + 8, + 1, + }, + + { + []string{"1", "3", "5", "7"}, + 1357, + 112, + }, + + { + []string{"1", "3", "5", "7"}, + 200, + 36, + }, + + { + []string{"1", "3", "5", "7"}, + 100, + 20, + }, + + { + []string{"1", "4", "9"}, + 1000000000, + 29523, + }, + + // 可以有多个 testcase +} + +func Test_atMostNGivenDigitSet(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, atMostNGivenDigitSet(tc.D, tc.N), "输入:%v", tc) + } +} + +func Benchmark_atMostNGivenDigitSet(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + atMostNGivenDigitSet(tc.D, tc.N) + } + } +} + +func Test_zeroLead(t *testing.T) { + type args struct { + size int + length int + } + tests := []struct { + name string + args args + want int + }{ + + { + "4 个数字,组成最多 2 位数的组合数", + args{ + 4, + 3, + }, + 20, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := zeroLead(tt.args.size, tt.args.length); got != tt.want { + t.Errorf("empty() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_less(t *testing.T) { + type args struct { + size int + length int + } + tests := []struct { + name string + args args + want int + }{ + { + "4 个不同的数,组合 5 位数的组合数", + args{ + 4, + 6, // 5+1 + }, + 1024, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := less(tt.args.size, tt.args.length); got != tt.want { + t.Errorf("less() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/Algorithms/0903.valid-permutations-for-di-sequence/README.md b/Algorithms/0903.valid-permutations-for-di-sequence/README.md new file mode 100755 index 000000000..207be7c80 --- /dev/null +++ b/Algorithms/0903.valid-permutations-for-di-sequence/README.md @@ -0,0 +1,29 @@ +# [903. Valid Permutations for DI Sequence](https://leetcode.com/problems/valid-permutations-for-di-sequence/) + +We are given `S`, a length `n` string of characters from the set `{'D', 'I'}`. (These letters stand for "decreasing" and "increasing".) + +A *valid permutation* is a permutation `P[0], P[1], ..., P[n]` of integers `{0, 1, ..., n}`, such that for all i: + +- If `S[i] == 'D'`, then `P[i] > P[i+1]`, and; +- If `S[i] == 'I'`, then `P[i] < P[i+1]`. + +How many valid permutations are there?  Since the answer may be large, **return your answer modulo** `10^9 + 7`. + +Example 1: + +```text +Input: "DID" +Output: 5 +Explanation: +The 5 valid permutations of (0, 1, 2, 3) are: +(1, 0, 3, 2) +(2, 0, 3, 1) +(2, 1, 3, 0) +(3, 0, 2, 1) +(3, 1, 2, 0) +``` + +Note: + +- `1 <= S.length <= 200` +- `S` consists only of characters from the set `{'D', 'I'}`. diff --git a/Algorithms/0903.valid-permutations-for-di-sequence/valid-permutations-for-di-sequence.go b/Algorithms/0903.valid-permutations-for-di-sequence/valid-permutations-for-di-sequence.go new file mode 100755 index 000000000..f6e5e6106 --- /dev/null +++ b/Algorithms/0903.valid-permutations-for-di-sequence/valid-permutations-for-di-sequence.go @@ -0,0 +1,32 @@ +package problem0903 + +const mod = 1e9 + 7 + +// ref: https://leetcode.com/problems/valid-permutations-for-di-sequence/discuss/168278/C++JavaPython-DP-Solution-O(N2) +func numPermsDISequence(S string) int { + n := len(S) + + dp := [201][201]int{} + + for j := 0; j <= n; j++ { + dp[0][j] = 1 + } + + for i := 0; i < n; i++ { + count := 0 + if S[i] == 'I' { + for j := 0; j < n-i; j++ { + count += dp[i][j] + dp[i+1][j] = count % mod + + } + } else { + for j := n - i - 1; j >= 0; j-- { + count += dp[i][j+1] + dp[i+1][j] = count % mod + } + } + } + + return dp[n][0] +} diff --git a/Algorithms/0903.valid-permutations-for-di-sequence/valid-permutations-for-di-sequence_test.go b/Algorithms/0903.valid-permutations-for-di-sequence/valid-permutations-for-di-sequence_test.go new file mode 100755 index 000000000..e1e609211 --- /dev/null +++ b/Algorithms/0903.valid-permutations-for-di-sequence/valid-permutations-for-di-sequence_test.go @@ -0,0 +1,44 @@ +package problem0903 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans int +}{ + + { + "DID", + 5, + }, + + { + "DIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDDDIDD", + 795732224, + }, + + // 可以有多个 testcase +} + +func Test_numPermsDISequence(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, numPermsDISequence(tc.S), "输入:%v", tc) + } +} + +func Benchmark_numPermsDISequence(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numPermsDISequence(tc.S) + } + } +} diff --git a/Algorithms/0904.fruit-into-baskets/README.md b/Algorithms/0904.fruit-into-baskets/README.md new file mode 100755 index 000000000..c7cbe0c7c --- /dev/null +++ b/Algorithms/0904.fruit-into-baskets/README.md @@ -0,0 +1,54 @@ +# [904. Fruit Into Baskets](https://leetcode.com/problems/fruit-into-baskets/) + +In a row of trees, the `i`-th tree produces fruit with type`tree[i]`. + +You **start at any tree of your choice**, then repeatedly perform the following steps: + +1. Add one piece of fruit from this tree to your baskets.` If you cannot, stop. +1. Move to the next tree to the right of the current tree.` If there is no tree to the right, stop. + +Note that you do not have any choice after the initial choice of starting tree:`you must perform step 1, then step 2, then back to step 1, then step 2, and so on until you stop. + +You have two baskets, and each basket can carry any quantity of fruit, but you want each basket to only carry one type of fruit each. + +What is the total amount of fruit you can collect with this procedure? + +Example 1: + +```text +Input: [1,2,1] +Output: 3 +Explanation: We can collect [1,2,1]. +``` + +Example 2: + +```text +Input: [0,1,2,2] +Output: 3 +Explanation: We can collect [1,2,2]. +If we started at the first tree, we would only collect [0, 1]. +``` + +Example 3: + +```text +Input: [1,2,3,2,2] +Output: 4 +Explanation: We can collect [2,3,2,2]. +If we started at the first tree, we would only collect [1, 2]. +``` + +Example 4: + +```text +Input: [3,3,3,1,2,1,1,2,3,3,4] +Output: 5 +Explanation: We can collect [1,2,1,1,2]. +If we started at the first tree or the eighth tree, we would only collect 4 fruits. +``` + +Note: + +- `1 <= tree.length <= 40000` +- `0 <= tree[i] < tree.length` diff --git a/Algorithms/0904.fruit-into-baskets/fruit-into-baskets.go b/Algorithms/0904.fruit-into-baskets/fruit-into-baskets.go new file mode 100755 index 000000000..17a34727d --- /dev/null +++ b/Algorithms/0904.fruit-into-baskets/fruit-into-baskets.go @@ -0,0 +1,40 @@ +package problem0904 + +// 找到最长的 tree 的子数组,要求最多只能含有两种数字 +func totalFruit(trees []int) int { + // 子数组 "252555" 中, tail 是尾部的 "555" + // tailType 是 “5” + // tailCount 是 3 + tailType, theOther := -1, -1 + tailCount, count := 0, 0 // 子数组尾部相同类型水果的长度,子数组的长度 + res := 0 + + for _, t := range trees { + count++ + if t != tailType && t != theOther { + // t 是新的类型 + // 原先的子数组的 tail 加上 t 组成新的子数组 + count = tailCount + 1 + } + + res = max(res, count) + + tailCount++ + if t != tailType { + // t 成为新的 tail,需要更新 tailType 和 tailCount + theOther, tailType = tailType, t + tailCount = 1 + } + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +// ref: https://leetcode.com/problems/fruit-into-baskets/discuss/170745/Problem:-Longest-Subarray-With-2-Elements diff --git a/Algorithms/0904.fruit-into-baskets/fruit-into-baskets_test.go b/Algorithms/0904.fruit-into-baskets/fruit-into-baskets_test.go new file mode 100755 index 000000000..85656d694 --- /dev/null +++ b/Algorithms/0904.fruit-into-baskets/fruit-into-baskets_test.go @@ -0,0 +1,59 @@ +package problem0904 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + tree []int + ans int +}{ + + { + []int{0}, + 1, + }, + + { + []int{1, 2, 1}, + 3, + }, + + { + []int{0, 1, 2, 2}, + 3, + }, + + { + []int{1, 2, 3, 2, 2}, + 4, + }, + + { + []int{3, 3, 3, 1, 2, 1, 1, 2, 3, 3, 4}, + 5, + }, + + // 可以有多个 testcase +} + +func Test_totalFruit(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, totalFruit(tc.tree), "输入:%v", tc) + } +} + +func Benchmark_totalFruit(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + totalFruit(tc.tree) + } + } +} diff --git a/Algorithms/0905.sort-array-by-parity/README.md b/Algorithms/0905.sort-array-by-parity/README.md new file mode 100755 index 000000000..ee2ce9771 --- /dev/null +++ b/Algorithms/0905.sort-array-by-parity/README.md @@ -0,0 +1,24 @@ +# [905. Sort Array By Parity](https://leetcode.com/problems/sort-array-by-parity/) + +## 题目 + +Given an array `A` of non-negative integers, return an array consisting of all the even elements of `A`, followed by all the odd elements of `A`. + +You may return any answer array that satisfies this condition. + +Example 1: + +```text +Input: [3,1,2,4] +Output: [2,4,3,1] +The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted. +``` + +Note: + +- 1 <= A.length <= 5000 +- 0 <= A[i] <= 5000 + +## 解题思路 + +见程序注释 diff --git a/Algorithms/0905.sort-array-by-parity/sort-array-by-parity.go b/Algorithms/0905.sort-array-by-parity/sort-array-by-parity.go new file mode 100755 index 000000000..3aa2a2943 --- /dev/null +++ b/Algorithms/0905.sort-array-by-parity/sort-array-by-parity.go @@ -0,0 +1,21 @@ +package problem0905 + +func sortArrayByParity(a []int) []int { + i, j := 0, len(a)-1 + for { + for i < j && a[i]%2 == 0 { + i++ + } + for i < j && a[j]%2 == 1 { + j-- + } + + if i < j { + a[i], a[j] = a[j], a[i] + } else { + break + } + + } + return a +} diff --git a/Algorithms/0905.sort-array-by-parity/sort-array-by-parity_test.go b/Algorithms/0905.sort-array-by-parity/sort-array-by-parity_test.go new file mode 100755 index 000000000..d224ea716 --- /dev/null +++ b/Algorithms/0905.sort-array-by-parity/sort-array-by-parity_test.go @@ -0,0 +1,69 @@ +package problem0905 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int +}{ + + { + []int{3, 1, 2, 4}, + }, + + // 可以有多个 testcase +} + +func split(a []int) (evens, odds []int) { + size := len(a) + var i int + for i = 0; i < size; i++ { + if a[i]%2 == 1 { + break + } + } + return a[:i], a[i:] +} + +func isAllEven(a []int) bool { + for _, n := range a { + if n%2 == 1 { + return false + } + } + return true +} + +func isAllOdd(a []int) bool { + for _, n := range a { + if n%2 == 0 { + return false + } + } + return true +} + +func Test_sortArrayByParity(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ans := sortArrayByParity(tc.A) + evens, odds := split(ans) + ast.True(isAllEven(evens)) + ast.True(isAllOdd(odds)) + } +} + +func Benchmark_sortArrayByParity(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + sortArrayByParity(tc.A) + } + } +} diff --git a/Algorithms/0906.super-palindromes/README.md b/Algorithms/0906.super-palindromes/README.md new file mode 100755 index 000000000..a635d3e8c --- /dev/null +++ b/Algorithms/0906.super-palindromes/README.md @@ -0,0 +1,21 @@ +# [906. Super Palindromes](https://leetcode.com/problems/super-palindromes/) + +Let's say a positive integer is a *superpalindrome* if it is a palindrome, and it is also the square of a palindrome. + +Now, given two positive integers `L` and `R` (represented as strings), return the number of *superpalindromes* in the inclusive range `[L, R]`. + +Example 1: + +```text +Input: L = "4", R = "1000" +Output: 4 +Explanation: 4, 9, 121, and 484 are *superpalindromes*. +Note that 676 is not a *superpalindrome*: 26 * 26 = 676, but 26 is not a palindrome. +``` + +Note: + +1. `1 <= len(L) <= 18` +1. `1 <= len(R) <= 18` +1. `L` and `R` are strings representing integers in the range `[1, 10^18)`. +1. `int(L) <= int(R)` \ No newline at end of file diff --git a/Algorithms/0906.super-palindromes/super-palindromes.go b/Algorithms/0906.super-palindromes/super-palindromes.go new file mode 100755 index 000000000..f0ba7ed74 --- /dev/null +++ b/Algorithms/0906.super-palindromes/super-palindromes.go @@ -0,0 +1,39 @@ +package problem0906 + +import ( + "sort" + "strconv" +) + +// square root of all superpalindrome +// 以下这些数的特点是,各个位上的所有数字的平方和,不超过 9 +// 才能保证自身平方后,还是回文。 +// 例如, 212 是 2*2 + 1*1 + 2*2 = 9 没有超过 9 +// 212*212 = 44944 还是回文。 +// 在题目规定的范围内,符合条件的数字,只有以下 70 个,干脆就都列举出来好了 +var palindromes = []int{ + 1, 2, 3, + 11, 22, + 101, 111, 121, 202, 212, + 1001, 1111, 2002, + 10001, 10101, 10201, 11011, 11111, 11211, 20002, 20102, + 100001, 101101, 110011, 111111, 200002, + 1000001, 1001001, 1002001, 1010101, 1011101, 1012101, 1100011, 1101011, 1102011, 1110111, 1111111, 2000002, 2001002, + 10000001, 10011001, 10100101, 10111101, 11000011, 11011011, 11100111, 11111111, 20000002, + 100000001, 100010001, 100020001, 100101001, 100111001, 100121001, 101000101, 101010101, 101020101, 101101101, 101111101, 110000011, 110010011, 110020011, 110101011, 110111011, 111000111, 111010111, 111101111, 111111111, 200000002, 200010002, +} + +func superpalindromesInRange(L, R string) int { + l, _ := strconv.Atoi(L) + r, _ := strconv.Atoi(R) + + li := sort.Search(len(palindromes), func(i int) bool { + return l <= palindromes[i]*palindromes[i] + }) + + ri := sort.Search(len(palindromes), func(i int) bool { + return r <= palindromes[i]*palindromes[i] + }) + + return ri - li +} diff --git a/Algorithms/0906.super-palindromes/super-palindromes_test.go b/Algorithms/0906.super-palindromes/super-palindromes_test.go new file mode 100755 index 000000000..689c9895f --- /dev/null +++ b/Algorithms/0906.super-palindromes/super-palindromes_test.go @@ -0,0 +1,58 @@ +package problem0906 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + L, R string + ans int +}{ + + { + "1020762146323", + "142246798855636", + 17, + }, + + { + "398904669", + "13479046850", + 6, + }, + + { + "1", + "2", + 1, + }, + + { + "4", + "1000", + 4, + }, + + // 可以有多个 testcase +} + +func Test_superpalindromesInRange(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, superpalindromesInRange(tc.L, tc.R), "输入:%v", tc) + } +} + +func Benchmark_myFunc(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + superpalindromesInRange(tc.L, tc.R) + } + } +} diff --git a/Algorithms/0907.sum-of-subarray-minimums/README.md b/Algorithms/0907.sum-of-subarray-minimums/README.md new file mode 100755 index 000000000..08eb923b8 --- /dev/null +++ b/Algorithms/0907.sum-of-subarray-minimums/README.md @@ -0,0 +1,19 @@ +# [907. Sum of Subarray Minimums](https://leetcode.com/problems/sum-of-subarray-minimums/) + +Given an array of integers `A`, find the sum of `min(B)`, where `B` ranges over every (contiguous) subarray of `A`. + +Since the answer may be large, return the answer modulo `10^9 + 7`. + +Example 1: + +```text +Input: [3,1,2,4] +Output: 17 +Explanation: Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4]. +Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1. Sum is 17. +``` + +Note: + +- `1 <= A.length <= 30000` +- `1 <= A[i] <= 30000` \ No newline at end of file diff --git a/Algorithms/0907.sum-of-subarray-minimums/sum-of-subarray-minimums.go b/Algorithms/0907.sum-of-subarray-minimums/sum-of-subarray-minimums.go new file mode 100755 index 000000000..44d4b73f9 --- /dev/null +++ b/Algorithms/0907.sum-of-subarray-minimums/sum-of-subarray-minimums.go @@ -0,0 +1,65 @@ +package problem0907 + +const modulo = 1e9 + 7 + +// 求解 A 的所有子数组的最小值之和 +func sumSubarrayMins(A []int) int { + minOfA := 1 // 题目规定了 A[i]>=1 + A = append(A, minOfA-1) // 加入低过 A 下限的值,是为了简化代码 + // 以下是没有添加元素时候的代码,可以观察两者的区别 + // https://github.com/aQuaYi/LeetCode-in-Go/blob/6122433cf04f1d9ab0925b3eddf2b6750c1ba3d1/Algorithms/0907.sum-of-subarray-minimums/sum-of-subarray-minimums.go + + size := len(A) + sum := 0 + s := new(stack) + + for k := 0; k < size; k++ { + for s.len() > 0 && A[s.top()] > A[k] { + j := s.pop() + i := s.top() + sum += (j - i) * (k - j) * A[j] + // 由题意可知, + // 为了找到全部以 A[j] 为最小值的子数组, + // 需要找到这些子数组左右端点的个数 + // anyoneOf(A[i+1:j]) > A[j],但是 A[i] < A[j] + // 所以,A[i+1:j+1] 中的数,都可以做左端点,共有 j-i 个 + // anyoneOf(A[j+1:k]) > A[j],但是 A[j] > A[k] + // 所以,A[j:k] 中的数,都可以做右端点,共有 k-j 个 + // 两边的端点可以任意组合,所以是乘法关系 + // (j-i) * (k-j) 是所有以 A[j] 为最小值的子数组的个数 + } + s.push(k) + } + + return sum % modulo +} + +// stack 用于存放 A 中元素的 index +// 并且越往上的 index, A[index] 越大 +type stack []int + +func (s *stack) top() int { + size := len(*s) + if size == 0 { + // 按照上面的分析, A[i+1:j] 中的元素都可以做左端点 + // 当 size=0 且调用 top 的时候, A[0:j] 中的元素都可以做左端点 + // 所以, i+1=0 → i=-1 + // 需要返回 -1 + return -1 + } + return (*s)[size-1] +} + +func (s *stack) push(index int) { + *s = append(*s, index) +} + +func (s *stack) pop() (index int) { + size := len(*s) + *s, index = (*s)[:size-1], (*s)[size-1] + return +} + +func (s *stack) len() int { + return len(*s) +} diff --git a/Algorithms/0907.sum-of-subarray-minimums/sum-of-subarray-minimums_test.go b/Algorithms/0907.sum-of-subarray-minimums/sum-of-subarray-minimums_test.go new file mode 100755 index 000000000..ab6ede676 --- /dev/null +++ b/Algorithms/0907.sum-of-subarray-minimums/sum-of-subarray-minimums_test.go @@ -0,0 +1,44 @@ +package problem0907 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{48, 87, 27}, + 264, + }, + + { + []int{3, 1, 2, 4}, + 17, + }, + + // 可以有多个 testcase +} + +func Test_sumSubarrayMins(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, sumSubarrayMins(tc.A), "输入:%v", tc) + } +} + +func Benchmark_sumSubarrayMins(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + sumSubarrayMins(tc.A) + } + } +} diff --git a/Algorithms/0908.smallest-range-i/README.md b/Algorithms/0908.smallest-range-i/README.md new file mode 100755 index 000000000..2571dc36f --- /dev/null +++ b/Algorithms/0908.smallest-range-i/README.md @@ -0,0 +1,39 @@ +# [908. Smallest Range I](https://leetcode.com/problems/smallest-range-i/) + +## 题目 + +Given an array `A` of integers, for each integer `A[i]` we may choose any `x` with `-K <= x <= K`, and add x to `A[i]`. + +After this process, we have some array `B`. + +Return the smallest possible difference between the maximum value of `B`and the minimum value of `B`. + +Example 1: + +```text +Input: A = [1], K = 0 +Output: 0 +Explanation: B = [1] +``` + +Example 2: + +```text +Input: A = [0,10], K = 2 +Output: 6 +Explanation: B = [2,8] +``` + +Example 3: + +```text +Input: A = [1,3,6], K = 3 +Output: 0 +Explanation: B = [3,3,3] or B = [4,4,4] +``` + +Note: + +- `1 <= A.length <= 10000` +- `0 <= A[i] <= 10000` +- `0 <= K <= 10000` diff --git a/Algorithms/0908.smallest-range-i/smallest-range-i.go b/Algorithms/0908.smallest-range-i/smallest-range-i.go new file mode 100755 index 000000000..7901145be --- /dev/null +++ b/Algorithms/0908.smallest-range-i/smallest-range-i.go @@ -0,0 +1,18 @@ +package problem0908 + +func smallestRangeI(A []int, K int) int { + min, max := A[0], A[0] + for i := range A { + if A[i] < min { + min = A[i] + } else if max < A[i] { + max = A[i] + } + } + + if min+K >= max-K { + return 0 + } + + return max - min - K*2 +} diff --git a/Algorithms/0908.smallest-range-i/smallest-range-i_test.go b/Algorithms/0908.smallest-range-i/smallest-range-i_test.go new file mode 100755 index 000000000..edd9bd1af --- /dev/null +++ b/Algorithms/0908.smallest-range-i/smallest-range-i_test.go @@ -0,0 +1,59 @@ +package problem0908 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans int +}{ + + { + []int{1}, + 0, + 0, + }, + + { + []int{0, 10}, + 2, + 6, + }, + + { + []int{1, 0, 3, 6}, + 3, + 0, + }, + + { + []int{1, 3, 6}, + 3, + 0, + }, + + // 可以有多个 testcase +} + +func Test_smallestRangeI(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, smallestRangeI(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_smallestRangeI(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + smallestRangeI(tc.A, tc.K) + } + } +} diff --git a/Algorithms/0909.snakes-and-ladders/README.md b/Algorithms/0909.snakes-and-ladders/README.md new file mode 100755 index 000000000..a3d35a791 --- /dev/null +++ b/Algorithms/0909.snakes-and-ladders/README.md @@ -0,0 +1,44 @@ +# [909. Snakes and Ladders](https://leetcode.com/problems/snakes-and-ladders/) + +On an N x N `board`, the numbers from `1` to `N*N` are written *boustrophedonically* **starting from the bottom left of the board**, and alternating direction each row. For example, for a 6 x 6 board, the numbers are written as follows: + +![snakes](snakes.png) + +You start on square `1` of the board (which is always in the last row and first column). Each move, starting from square `x`, consists of the following: + +- You choose a destination square `S` with number `x+1`, `x+2`, `x+3`, `x+4`, `x+5`, or `x+6`, provided this number is `<= N*N`. + - (This choice simulates the result of a standard 6-sided die roll: ie., there are always at most 6 destinations.) +- If `S` has a snake or ladder, you move to the destination of that snake or ladder. Otherwise, you move to `S`. + +A board square on row `r` and column `c` has a "snake or ladder" if `board[r][c] != -1`. The destination of that snake or ladder is `board[r][c]`. + +Note that you only take a snake or ladder at most once per move: if the destination to a snake or ladder is the start of another snake or ladder, you do **not** continue moving. (For example, if the board is `[[4,-1],[-1,3]]`, and on the first move your destination square is `2`, then you finish your first move at `3`, because you do **not** continue moving to `4`.) + +Return the least number of moves required to reach square `N*N`. If it is not possible, return `-1`. + +Example 1: + +```text +Input: [ +[-1,-1,-1,-1,-1,-1], +[-1,-1,-1,-1,-1,-1], +[-1,-1,-1,-1,-1,-1], +[-1,35,-1,-1,13,-1], +[-1,-1,-1,-1,-1,-1], +[-1,15,-1,-1,-1,-1]] +Output: 4 +Explanation: +At the beginning, you start at square 1 [at row 5, column 0]. +You decide to move to square 2, and must take the ladder to square 15. +You then decide to move to square 17 (row 3, column 5), and must take the snake to square 13. +You then decide to move to square 14, and must take the ladder to square 35. +You then decide to move to square 36, ending the game. +It can be shown that you need at least 4 moves to reach the N*N-th square, so the answer is 4. +``` + +Note: + +- `2 <= board.length = board[0].length <= 20` +- `board[i][j]` is between `1` and `N*N` or is equal to `-1`. +- The board square with number `1` has no snake or ladder. +- The board square with number `N*N` has no snake or ladder. \ No newline at end of file diff --git a/Algorithms/0909.snakes-and-ladders/snakes-and-ladders.go b/Algorithms/0909.snakes-and-ladders/snakes-and-ladders.go new file mode 100755 index 000000000..5c5972419 --- /dev/null +++ b/Algorithms/0909.snakes-and-ladders/snakes-and-ladders.go @@ -0,0 +1,55 @@ +package problem0909 + +func snakesAndLadders(p [][]int) int { + n := len(p) + destination := n * n + + squares := make([]int, 400) + isChecked := [401]bool{} + + squares[0] = 1 + isChecked[1] = true + + steps := 0 + + // BFS + for len(squares) > 0 { + steps++ + size := len(squares) + for j := 0; j < size; j++ { + s := squares[j] + for i := 1; i <= 6; i++ { + si := s + i + x, y := position(si, n) + if p[x][y] != -1 { + // jump + isChecked[si] = true + si = p[x][y] + } + if si == destination { + return steps + } + if !isChecked[si] { + squares = append(squares, si) + isChecked[si] = true + } + } + } + squares = squares[size:] + } + + return -1 +} + +func position(square, n int) (x, y int) { + square-- + // 首先计算正常的位置 + x, y = square/n, square%n + if x%2 == 1 { + // 行号为奇数的行,需要左右翻转 + y = n - 1 - y + } + // 整体上下翻转 + x = n - 1 - x + return +} diff --git a/Algorithms/0909.snakes-and-ladders/snakes-and-ladders_test.go b/Algorithms/0909.snakes-and-ladders/snakes-and-ladders_test.go new file mode 100755 index 000000000..023b3e621 --- /dev/null +++ b/Algorithms/0909.snakes-and-ladders/snakes-and-ladders_test.go @@ -0,0 +1,135 @@ +package problem0909 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + board [][]int + ans int +}{ + + { + [][]int{ + {1, 1, -1}, + {1, 1, 1}, + {-1, 1, 1}, + }, + -1, + }, + + { + [][]int{ + {1, -1, -1, -1, 48, 5, -1}, + {12, 29, 13, 9, -1, 2, 32}, + {-1, -1, 21, 7, -1, 12, 49}, + {42, 37, 21, 40, -1, 22, 12}, + {42, -1, 2, -1, -1, -1, 6}, + {39, -1, 35, -1, -1, 39, -1}, + {-1, 36, -1, -1, -1, -1, 5}, + }, + 3, + }, + + { + [][]int{ + {-1, -1, 27, 13, -1, 25, -1}, + {-1, -1, -1, -1, -1, -1, -1}, + {44, -1, 8, -1, -1, 2, -1}, + {-1, 30, -1, -1, -1, -1, -1}, + {3, -1, 20, -1, 46, 6, -1}, + {-1, -1, -1, -1, -1, -1, 29}, + {-1, 29, 21, 33, -1, -1, -1}, + }, + 4, + }, + + { + [][]int{ + {-1, 1, 2, -1}, + {2, 13, 15, -1}, + {-1, 10, -1, -1}, + {-1, 6, 2, 8}, + }, + 2, + }, + + { + [][]int{ + {-1, -1, -1, -1, 162, -1, -1, -1, -1, -1, -1, -1, 256, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, 396, -1, 184, 120, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, 384, -1, -1, -1, -1, -1, 76, -1, -1, -1, 196, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1, 152, -1, -1, -1, -1, -1, 40, -1, -1, -1, 30, 159}, + {-1, 86, -1, -1, 25, 307, 280, -1, -1, -1, -1, -1, -1, -1, 6, -1, -1, -1, 330, -1}, + {-1, -1, -1, -1, -1, 266, -1, -1, -1, -1, -1, -1, -1, -1, -1, 213, 57, 36, -1, 399}, + {-1, -1, -1, -1, -1, -1, -1, -1, 149, -1, -1, 27, -1, -1, -1, -1, -1, -1, -1, -1}, + {-1, 366, -1, -1, -1, -1, -1, 140, 247, -1, -1, -1, -1, 396, -1, -1, 347, -1, -1, -1}, + {-1, -1, 73, -1, -1, -1, 120, 178, -1, -1, -1, -1, -1, -1, -1, 24, -1, -1, 22, -1}, + {-1, 394, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1, 208, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, -1, -1, -1, 370, 345, -1}, + {-1, -1, -1, -1, 356, -1, 28, -1, -1, -1, -1, -1, -1, 102, -1, 312, -1, 242, -1, -1}, + {-1, -1, -1, 235, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, 81, -1, -1, 177, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, 306, -1, -1, -1, -1, -1, 62, -1, -1, -1, -1, -1, 236, 395}, + {-1, -1, -1, -1, -1, -1, -1, 291, -1, -1, -1, -1, -1, -1, 40, 387, -1, -1, -1, -1}, + {-1, -1, -1, 151, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 222, 230, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 186, -1, -1, -1, -1, -1, 236, -1, -1, -1}, + }, + 6, + }, + + { + [][]int{ + {-1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1}, + {-1, -1, -1, -1, -1, -1}, + {-1, 35, -1, -1, 13, -1}, + {-1, -1, -1, -1, -1, -1}, + {-1, 15, -1, -1, -1, -1}}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_snakesAndLadders(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, snakesAndLadders(tc.board), "输入:%v", tc) + } +} + +func Benchmark_snakesAndLadders(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + snakesAndLadders(tc.board) + } + } +} +func Test_position(t *testing.T) { + ast := assert.New(t) + // + const ( + n = 3 + ) + // + expected := [n][n]int{ + {7, 8, 9}, + {6, 5, 4}, + {1, 2, 3}, + } + actual := [n][n]int{} + for i := 1; i <= 9; i++ { + x, y := position(i, n) + actual[x][y] = i + } + ast.Equal(expected, actual) +} diff --git a/Algorithms/0909.snakes-and-ladders/snakes.png b/Algorithms/0909.snakes-and-ladders/snakes.png new file mode 100644 index 000000000..dde4d8290 Binary files /dev/null and b/Algorithms/0909.snakes-and-ladders/snakes.png differ diff --git a/Algorithms/0910.smallest-range-ii/README.md b/Algorithms/0910.smallest-range-ii/README.md new file mode 100755 index 000000000..ee47c9b03 --- /dev/null +++ b/Algorithms/0910.smallest-range-ii/README.md @@ -0,0 +1,37 @@ +# [910. Smallest Range II](https://leetcode.com/problems/smallest-range-ii/) + +Given an array `A` of integers, for each integer `A[i]` we need to choose **either** `x = -K` **or** `x = K`, and add `x` to `A[i] (only once)`. + +After this process, we have some array `B`. + +Return the smallest possible difference between the maximum value of `B` and the minimum value of `B`. + +Example 1: + +```text +Input: A = [1], K = 0 +Output: 0 +Explanation: `B` = [1] +``` + +Example 2: + +```text +Input: A = [0,10], K = 2 +Output: 6 +Explanation: `B` = [2,8] +``` + +Example 3: + +```text +Input: A = [1,3,6], K = 3 +Output: 3 +Explanation: `B` = [4,6,3] +``` + +Note: + +- `1 <= A.length <= 10000` +- `0 <= A[i] <= 10000` +- `0 <= K <= 10000` \ No newline at end of file diff --git a/Algorithms/0910.smallest-range-ii/smallest-range-ii.go b/Algorithms/0910.smallest-range-ii/smallest-range-ii.go new file mode 100755 index 000000000..701458c53 --- /dev/null +++ b/Algorithms/0910.smallest-range-ii/smallest-range-ii.go @@ -0,0 +1,37 @@ +package problem0910 + +import ( + "sort" +) + +// ref: https://leetcode.com/problems/smallest-range-ii/discuss/173377/C++JavaPython-Add-0-or-2-*-K + +func smallestRangeII(A []int, k int) int { + sort.Ints(A) + + n := len(A) + mx, mn := A[n-1], A[0] + res := mx - mn + + for i := 0; i+1 < n; i++ { + mx = max(mx, A[i]+2*k) + mn = min(A[i+1], A[0]+2*k) + res = min(res, mx-mn) + } + + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0910.smallest-range-ii/smallest-range-ii_test.go b/Algorithms/0910.smallest-range-ii/smallest-range-ii_test.go new file mode 100755 index 000000000..bbe3b5915 --- /dev/null +++ b/Algorithms/0910.smallest-range-ii/smallest-range-ii_test.go @@ -0,0 +1,53 @@ +package problem0910 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + k int + ans int +}{ + + { + []int{1}, + 0, + 0, + }, + + { + []int{0, 10}, + 2, + 6, + }, + + { + []int{1, 3, 6}, + 3, + 3, + }, + + // 可以有多个 testcase +} + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, smallestRangeII(tc.A, tc.k), "输入:%v", tc) + } +} + +func Benchmark_myFunc(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + smallestRangeII(tc.A, tc.k) + } + } +} diff --git a/Algorithms/0911.online-election/README.md b/Algorithms/0911.online-election/README.md new file mode 100755 index 000000000..c00077691 --- /dev/null +++ b/Algorithms/0911.online-election/README.md @@ -0,0 +1,27 @@ +# [911. Online Election](https://leetcode.com/problems/online-election/) + +In an election, the `i`-th vote was cast for `persons[i]` at time `times[i]`. + +Now, we would like to implement the following query function: `TopVotedCandidate.q(int t)` will return the number of the person that was leading the election at time `t`. + +Votes cast at time `t` will count towards our query. In the case of a tie, the most recent vote (among tied candidates) wins. + +Example 1: + +```text +Input: ["TopVotedCandidate","q","q","q","q","q","q"], [[[0,1,1,0,0,1,0],[0,5,10,15,20,25,30]],[3],[12],[25],[15],[24],[8]] +Output: [null,0,1,1,0,0,1] +Explanation: +At time 3, the votes are [0], and 0 is leading. +At time 12, the votes are [0,1,1], and 1 is leading. +At time 25, the votes are [0,1,1,0,0,1], and 1 is leading (as ties go to the most recent vote.) +This continues for 3 more queries at time 15, 24, and 8. +``` + +Note: + +1. `1 <= persons.length = times.length <= 5000` +1. `0 <= persons[i] <= persons.length` +1. `times` is a strictly increasing array with all elements in `[0, 10^9]`. +1. `TopVotedCandidate.q` is called at most `10000` times per test case. +1. `TopVotedCandidate.q(int t)` is always called with `t >= times[0]`. \ No newline at end of file diff --git a/Algorithms/0911.online-election/online-election.go b/Algorithms/0911.online-election/online-election.go new file mode 100755 index 000000000..e6f39cf46 --- /dev/null +++ b/Algorithms/0911.online-election/online-election.go @@ -0,0 +1,39 @@ +package problem0911 + +import "sort" + +// TopVotedCandidate object will be instantiated and called as such: +// obj := Constructor(persons, times); +// param_1 := obj.Q(t); +type TopVotedCandidate struct { + times []int + leaders []int +} + +// Constructor returns TopVotedCandidate +func Constructor(persons []int, times []int) TopVotedCandidate { + size := len(persons) + + votes := make([]int, size) + leaders := make([]int, size) + + leader := persons[0] + for i := 0; i < size; i++ { + p := persons[i] + votes[p]++ + if votes[p] >= votes[leader] { + leader = p + } + leaders[i] = leader + } + return TopVotedCandidate{times, leaders} +} + +// Q is quest +func (tvc *TopVotedCandidate) Q(t int) int { + i := sort.SearchInts(tvc.times, t) + if i == len(tvc.times) || t != tvc.times[i] { + i-- + } + return tvc.leaders[i] +} diff --git a/Algorithms/0911.online-election/online-election_test.go b/Algorithms/0911.online-election/online-election_test.go new file mode 100755 index 000000000..19125b60f --- /dev/null +++ b/Algorithms/0911.online-election/online-election_test.go @@ -0,0 +1,26 @@ +package problem0911 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + persons := []int{0, 1, 1, 0, 0, 1, 0} + times := []int{0, 5, 10, 15, 20, 25, 30} + + qs := []int{3, 12, 25, 15, 24, 8} + as := []int{0, 1, 1, 0, 0, 1} + + tvc := Constructor(persons, times) + + for i, q := range qs { + expected := tvc.Q(q) + actual := as[i] + + ast.Equal(expected, actual) + } +} diff --git a/Algorithms/0912.sort-an-array/README.md b/Algorithms/0912.sort-an-array/README.md new file mode 100755 index 000000000..1b5609ef9 --- /dev/null +++ b/Algorithms/0912.sort-an-array/README.md @@ -0,0 +1,22 @@ +# [912. Sort an Array](https://leetcode.com/problems/sort-an-array/) + +Given an array of integers nums, sort the array in ascending order. + +Example 1: + +```text +Input: [5,2,3,1] +Output: [1,2,3,5] +``` + +Example 2: + +```text +Input: [5,1,1,2,0,0] +Output: [0,0,1,1,2,5] +``` + +Note: + +- 1 <= A.length <= 10000 +- -50000 <= A[i] <= 50000 diff --git a/Algorithms/0912.sort-an-array/sort-an-array.go b/Algorithms/0912.sort-an-array/sort-an-array.go new file mode 100755 index 000000000..c88a4208f --- /dev/null +++ b/Algorithms/0912.sort-an-array/sort-an-array.go @@ -0,0 +1,30 @@ +package problem0912 + +func sortArray(nums []int) []int { + quick3way(nums, 0, len(nums)-1) + return nums +} + +// 3 way quick sort +func quick3way(nums []int, lo, hi int) { + if lo >= hi { + return + } + lt, i, gt := lo, lo+1, hi + v := nums[lo] + for i <= gt { + switch { + case nums[i] < v: + nums[lt], nums[i] = nums[i], nums[lt] + lt++ + i++ + case nums[i] > v: + nums[i], nums[gt] = nums[gt], nums[i] + gt-- + default: + i++ + } + } + quick3way(nums, lo, lt-1) + quick3way(nums, gt+1, hi) +} diff --git a/Algorithms/0912.sort-an-array/sort-an-array_test.go b/Algorithms/0912.sort-an-array/sort-an-array_test.go new file mode 100755 index 000000000..362e63b46 --- /dev/null +++ b/Algorithms/0912.sort-an-array/sort-an-array_test.go @@ -0,0 +1,42 @@ +package problem0912 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + nums []int + ans []int +}{ + + { + []int{5, 2, 3, 1}, + []int{1, 2, 3, 5}, + }, + + { + []int{5, 1, 1, 2, 0, 0}, + []int{0, 0, 1, 1, 2, 5}, + }, + + // 可以有多个 testcase +} + +func Test_sortArray(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, sortArray(tc.nums), "输入:%v", tc) + } +} + +func Benchmark_sortArray(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + sortArray(tc.nums) + } + } +} diff --git a/Algorithms/0913.cat-and-mouse/README.md b/Algorithms/0913.cat-and-mouse/README.md new file mode 100755 index 000000000..1d070bcef --- /dev/null +++ b/Algorithms/0913.cat-and-mouse/README.md @@ -0,0 +1,38 @@ +# [913. Cat and Mouse](https://leetcode.com/problems/cat-and-mouse/) + +A game on an **undirected** graph is played by two players, Mouse and Cat, who alternate turns. + +The graph is given as follows: `graph[a]` is a list of all nodes `b` such that `ab` is an edge of the graph. + +Mouse starts at node 1 and goes first, Cat starts at node 2 and goes second, and there is a Hole at node 0. + +During each player's turn, they **must** travel along one edge of the graph that meets where they are. For example, if the Mouse is at node `1`, it **must** travel to any node in `graph[1]`. + +Additionally, it is not allowed for the Cat to travel to the Hole (node 0.) + +Then, the game can end in 3 ways: + +- If ever the Cat occupies the same node as the Mouse, the Cat wins. +- If ever the Mouse reaches the Hole, the Mouse wins. +- If ever a position is repeated (ie. the players are in the same position as a previous turn, and it is the same player's turn to move), the game is a draw. + +Given a `graph`, and assuming both players play optimally, return `1` if the game is won by Mouse, `2` if the game is won by Cat, and `0` if the game is a draw. + +Example 1: + +```text +Input: [[2,5],[3],[0,4,5],[1,4,5],[2,3],[0,2,3]] +Output: 0 +Explanation: +4---3---1 +| | +2---5 + \ / + 0 +``` + +Note: + +1. `3 <= graph.length <= 50` +1. It is guaranteed that `graph[1]` is non-empty. +1. It is guaranteed that `graph[2]` contains a non-zero element. \ No newline at end of file diff --git a/Algorithms/0913.cat-and-mouse/cat-and-mouse.go b/Algorithms/0913.cat-and-mouse/cat-and-mouse.go new file mode 100755 index 000000000..1dc275be4 --- /dev/null +++ b/Algorithms/0913.cat-and-mouse/cat-and-mouse.go @@ -0,0 +1,79 @@ +package problem0913 + +// ref: https://leetcode.com/problems/cat-and-mouse/discuss/176177/Most-of-the-DFS-solutions-are-WRONG-check-this-case + +func catMouseGame(graph [][]int) int { + n := len(graph) + colors := [50][50][2]int{} + outdegree := [50][50][2]int{} + + for i := 0; i < n; i++ { // cat + for j := 0; j < n; j++ { // mouse + outdegree[i][j][0] = len(graph[j]) + outdegree[i][j][1] = len(graph[i]) + for _, k := range graph[i] { + if k == 0 { + outdegree[i][j][1]-- + break + } + } + } + } + + queue := make([][4]int, 0, n) + + colorizeAndPush := func(cat, mouse, mouseMove, color int) { + colors[cat][mouse][mouseMove] = color + queue = append(queue, [4]int{cat, mouse, mouseMove, color}) + } + + for k := 1; k < n; k++ { + for m := 0; m < 2; m++ { + colorizeAndPush(k, 0, m, 1) + colorizeAndPush(k, k, m, 2) + } + } + + var cur [4]int + + for len(queue) > 0 { + cur, queue = queue[0], queue[1:] + cat, mouse, mouseMove, color := cur[0], cur[1], cur[2], cur[3] + if cat == 2 && + mouse == 1 && + mouseMove == 0 { + return color + } + prevMouseMove := 1 - mouseMove + animal := mouse + if prevMouseMove == 1 { + animal = cat + } + for _, prev := range graph[animal] { + prevCat := cat + prevMouse := prev + if prevMouseMove == 1 { + prevCat = prev + prevMouse = mouse + } + + if prevCat == 0 { + continue + } + + if colors[prevCat][prevMouse][prevMouseMove] > 0 { + continue + } + + outdegree[prevCat][prevMouse][prevMouseMove]-- + if (prevMouseMove == 1 && color == 2) || + (prevMouseMove == 0 && color == 1) || + (outdegree[prevCat][prevMouse][prevMouseMove] == 0) { + colors[prevCat][prevMouse][prevMouseMove] = color + queue = append(queue, [4]int{prevCat, prevMouse, prevMouseMove, color}) + } + } + } + + return colors[2][1][0] +} diff --git a/Algorithms/0913.cat-and-mouse/cat-and-mouse_test.go b/Algorithms/0913.cat-and-mouse/cat-and-mouse_test.go new file mode 100755 index 000000000..bf1f97939 --- /dev/null +++ b/Algorithms/0913.cat-and-mouse/cat-and-mouse_test.go @@ -0,0 +1,48 @@ +package problem0913 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + graph [][]int + ans int +}{ + + { + [][]int{ + {2, 5}, {3}, {0, 4, 5}, {1, 4, 5}, {2, 3}, {0, 2, 3}, + }, + 0, + }, + + { + [][]int{ + {6}, {4}, {9}, {5}, {1, 5}, {3, 4, 6}, {0, 5, 10}, {8, 9, 10}, {7}, {2, 7}, {6, 7}, + }, + 1, + }, + + // 可以有多个 testcase +} + +func Test_catMouseGame(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, catMouseGame(tc.graph), "输入:%v", tc) + } +} + +func Benchmark_catMouseGame(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + catMouseGame(tc.graph) + } + } +} diff --git a/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/README.md b/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/README.md new file mode 100755 index 000000000..4e8387872 --- /dev/null +++ b/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/README.md @@ -0,0 +1,53 @@ +# [914. X of a Kind in a Deck of Cards](https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/) + +In a deck of cards, each card has an integer written on it. + +Return `true` if and only if you can choose `X >= 2` such that it is possible to split the entire deck into 1 or more groups of cards, where: + +- Each group has exactly X cards. +- All the cards in each group have the same integer. + +Example 1: + +```text +Input: [1,2,3,4,4,3,2,1] +Output: true +Explanation: Possible partition [1,1],[2,2],[3,3],[4,4] +``` + +Example 2: + +```text +Input: [1,1,1,2,2,2,3,3] +Output: false +Explanation: No possible partition. +``` + +Example 3: + +```text +Input: [1] +Output: false +Explanation: No possible partition. +``` + +Example 4: + +```text +Input: [1,1] +Output: true +Explanation: Possible partition [1,1] +``` + +Example 5: + +```text +Input: [1,1,2,2,2,2] +Output: true +Explanation: Possible partition [1,1],[2,2],[2,2] +``` + +Note: + +- `1 <= deck.length <= 10000` +- `0 <= deck[i] < 10000` \ No newline at end of file diff --git a/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/x-of-a-kind-in-a-deck-of-cards.go b/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/x-of-a-kind-in-a-deck-of-cards.go new file mode 100755 index 000000000..41ede5376 --- /dev/null +++ b/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/x-of-a-kind-in-a-deck-of-cards.go @@ -0,0 +1,33 @@ +package problem0914 + +func hasGroupsSizeX(deck []int) bool { + size := len(deck) // 题目说了 size >= 1 + + // 统计 deck 中相同数字的数量 + count := make(map[int]int, size) + for _, card := range deck { + count[card]++ + } + + d := count[deck[0]] + + for _, c := range count { + d = gcd(d, c) + if d == 1 { + return false + } + } + + return true +} + +// 最大公约数 +func gcd(a, b int) int { + if a < b { + a, b = b, a + } + for b != 0 { + a, b = b, a%b + } + return a +} diff --git a/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/x-of-a-kind-in-a-deck-of-cards_test.go b/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/x-of-a-kind-in-a-deck-of-cards_test.go new file mode 100755 index 000000000..4897f8c03 --- /dev/null +++ b/Algorithms/0914.x-of-a-kind-in-a-deck-of-cards/x-of-a-kind-in-a-deck-of-cards_test.go @@ -0,0 +1,59 @@ +package problem0914 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + deck []int + ans bool +}{ + + { + []int{1, 2, 3, 4, 4, 3, 2, 1}, + true, + }, + + { + []int{1, 1, 1, 2, 2, 2, 3, 3}, + false, + }, + + { + []int{1}, + false, + }, + + { + []int{1, 1}, + true, + }, + + { + []int{1, 1, 2, 2, 2, 2}, + true, + }, + + // 可以有多个 testcase +} + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, hasGroupsSizeX(tc.deck), "输入:%v", tc) + } +} + +func Benchmark_myFunc(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + hasGroupsSizeX(tc.deck) + } + } +} diff --git a/Algorithms/0915.partition-array-into-disjoint-intervals/README.md b/Algorithms/0915.partition-array-into-disjoint-intervals/README.md new file mode 100755 index 000000000..a02777e8c --- /dev/null +++ b/Algorithms/0915.partition-array-into-disjoint-intervals/README.md @@ -0,0 +1,31 @@ +# [915. Partition Array into Disjoint Intervals](https://leetcode.com/problems/partition-array-into-disjoint-intervals/) + +Given an array `A`, partition it into two (contiguous) subarrays `left` and `right` so that: + +- Every element in `left` is less than or equal to every element in `right`. +- `left` and `right` are non-empty. +- `left` has the smallest possible size. + +Return the **length** of `left` after such a partitioning. It is guaranteed that such a partitioning exists. + +Example 1: + +```text +Input: [5,0,3,8,6] +Output: 3 +Explanation: left = [5,0,3], right = [8,6] +``` + +Example 2: + +```text +Input: [1,1,1,0,6,12] +Output: 4 +Explanation: left = [1,1,1,0], right = [6,12] +``` + +Note: + +1. `2 <= A.length <= 30000` +1. `0 <= A[i] <= 10^6` +1. It is guaranteed there is at least one way to partition `A` as described. diff --git a/Algorithms/0915.partition-array-into-disjoint-intervals/partition-array-into-disjoint-intervals.go b/Algorithms/0915.partition-array-into-disjoint-intervals/partition-array-into-disjoint-intervals.go new file mode 100755 index 000000000..afbc70219 --- /dev/null +++ b/Algorithms/0915.partition-array-into-disjoint-intervals/partition-array-into-disjoint-intervals.go @@ -0,0 +1,25 @@ +package problem0915 + +func partitionDisjoint(A []int) int { + leftMax, nextMax, rightBegin := A[0], A[0], 1 + + for i := 1; i < len(A); i++ { + if leftMax > A[i] { + // 此时,A[i] 比在 left 中, + leftMax = nextMax + // right 的起点,至少是 i+1 + rightBegin = i + 1 + } else { + nextMax = max(nextMax, A[i]) + } + } + + return rightBegin +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0915.partition-array-into-disjoint-intervals/partition-array-into-disjoint-intervals_test.go b/Algorithms/0915.partition-array-into-disjoint-intervals/partition-array-into-disjoint-intervals_test.go new file mode 100755 index 000000000..84b0627c0 --- /dev/null +++ b/Algorithms/0915.partition-array-into-disjoint-intervals/partition-array-into-disjoint-intervals_test.go @@ -0,0 +1,54 @@ +package problem0915 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{90, 47, 69, 10, 43, 92, 31, 73, 61, 97}, + 9, + }, + + { + []int{1, 1}, + 1, + }, + + { + []int{5, 0, 3, 8, 6}, + 3, + }, + + { + []int{1, 1, 1, 0, 6, 12}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_partitionDisjoint(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, partitionDisjoint(tc.A), "输入:%v", tc) + } +} + +func Benchmark_partitionDisjoint(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + partitionDisjoint(tc.A) + } + } +} diff --git a/Algorithms/0916.word-subsets/README.md b/Algorithms/0916.word-subsets/README.md new file mode 100755 index 000000000..e58c54555 --- /dev/null +++ b/Algorithms/0916.word-subsets/README.md @@ -0,0 +1,51 @@ +# [916. Word Subsets](https://leetcode.com/problems/word-subsets/) + +We are given two arrays `A` and `B` of words. Each word is a string of lowercase letters. + +Now, say that word `b` is a subset of word `a` if every letter in `b` occurs in `a`, **including multiplicity**. For example, `"wrr"` is a subset of `"warrior"`, but is not a subset of `"world"`. + +Now say a word `a` from `A` is *universal* if for every `b` in `B`, `b` is a subset of `a`. + +Return a list of all universal words in `A`. You can return the words in any order. + +Example 1: + +```text +Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["e","o"] +Output: ["facebook","google","leetcode"] +``` + +Example 2: + +```text +Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["l","e"] +Output: ["apple","google","leetcode"] +``` + +Example 3: + +```text +Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["e","oo"] +Output: ["facebook","google"] +``` + +Example 4: + +```text +Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["lo","eo"] +Output: ["google","leetcode"] +``` + +Example 5: + +```text +Input: A = ["amazon","apple","facebook","google","leetcode"], B = ["ec","oc","ceo"] +Output: ["facebook","leetcode"] +``` + +Note: + +1. `1 <= A.length, B.length <= 10000` +1. `1 <= A[i].length, B[i].length <= 10` +1. `A[i]` and `B[i]` consist only of lowercase letters. +1. All words in `A[i]` are unique: there isn't `i != j` with `A[i] == A[j]`. \ No newline at end of file diff --git a/Algorithms/0916.word-subsets/word-subsets.go b/Algorithms/0916.word-subsets/word-subsets.go new file mode 100755 index 000000000..0eccad20d --- /dev/null +++ b/Algorithms/0916.word-subsets/word-subsets.go @@ -0,0 +1,49 @@ +package problem0916 + +func wordSubsets(A, B []string) []string { + clt := new([26]int) + for _, b := range B { + collect(clt, count(b)) + } + + res := make([]string, 0, len(A)) + for _, a := range A { + if isSubset(count(a), clt) { + res = append(res, a) + } + } + + return res +} + +func count(s string) *[26]int { + res := [26]int{} + for _, b := range s { + res[b-'a']++ + } + return &res +} + +func isSubset(s, clt *[26]int) bool { + isSubset := true + i := 0 + for isSubset && i < 26 { + isSubset = isSubset && (s[i] >= clt[i]) + i++ + } + return isSubset +} + +// collect to clt +func collect(clt, b *[26]int) { + for i := range clt { + clt[i] = max(clt[i], b[i]) + } +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0916.word-subsets/word-subsets_test.go b/Algorithms/0916.word-subsets/word-subsets_test.go new file mode 100755 index 000000000..e33b7485a --- /dev/null +++ b/Algorithms/0916.word-subsets/word-subsets_test.go @@ -0,0 +1,64 @@ +package problem0916 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A, B []string + ans []string +}{ + + { + []string{"amazon", "apple", "facebook", "google", "leetcode"}, + []string{"e", "o"}, + []string{"facebook", "google", "leetcode"}, + }, + + { + []string{"amazon", "apple", "facebook", "google", "leetcode"}, + []string{"l", "e"}, + []string{"apple", "google", "leetcode"}, + }, + + { + []string{"amazon", "apple", "facebook", "google", "leetcode"}, + []string{"e", "oo"}, + []string{"facebook", "google"}, + }, + + { + []string{"amazon", "apple", "facebook", "google", "leetcode"}, + []string{"lo", "eo"}, + []string{"google", "leetcode"}, + }, + + { + []string{"amazon", "apple", "facebook", "google", "leetcode"}, + []string{"ec", "oc", "ceo"}, + []string{"facebook", "leetcode"}, + }, + + // 可以有多个 testcase +} + +func Test_wordSubsets(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, wordSubsets(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_wordSubsets(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + wordSubsets(tc.A, tc.B) + } + } +} diff --git a/Algorithms/0917.reverse-only-letters/README.md b/Algorithms/0917.reverse-only-letters/README.md new file mode 100755 index 000000000..64e38b7ed --- /dev/null +++ b/Algorithms/0917.reverse-only-letters/README.md @@ -0,0 +1,30 @@ +# [917. Reverse Only Letters](https://leetcode.com/problems/reverse-only-letters/) + +Given a string `S`, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions. + +Example 1: + +```text +Input: "ab-cd" +Output: "dc-ba" +``` + +Example 2: + +```text +Input: "a-bC-dEf-ghIj" +Output: "j-Ih-gfE-dCba" +``` + +Example 3: + +```text +Input: "Test1ng-Leet=code-Q!" +Output: "Qedo1ct-eeLg=ntse-T!" +``` + +Note: + +1. `S.length <= 100` +1. `33 <= S[i].ASCIIcode <= 122` +1. `S` doesn't contain `\` or `"` diff --git a/Algorithms/0917.reverse-only-letters/reverse-only-letters.go b/Algorithms/0917.reverse-only-letters/reverse-only-letters.go new file mode 100755 index 000000000..9655020df --- /dev/null +++ b/Algorithms/0917.reverse-only-letters/reverse-only-letters.go @@ -0,0 +1,25 @@ +package problem0917 + +func reverseOnlyLetters(S string) string { + bs := []byte(S) + + left, right := 0, len(bs)-1 + for left < right { + for left < right && !isLetter(bs[left]) { + left++ + } + for left < right && !isLetter(bs[right]) { + right-- + } + bs[left], bs[right] = bs[right], bs[left] + left++ + right-- + } + + return string(bs) +} + +func isLetter(b byte) bool { + return 'a' <= b && b <= 'z' || + 'A' <= b && b <= 'Z' +} diff --git a/Algorithms/0917.reverse-only-letters/reverse-only-letters_test.go b/Algorithms/0917.reverse-only-letters/reverse-only-letters_test.go new file mode 100755 index 000000000..a091469b0 --- /dev/null +++ b/Algorithms/0917.reverse-only-letters/reverse-only-letters_test.go @@ -0,0 +1,49 @@ +package problem0917 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans string +}{ + + { + "ab-cd", + "dc-ba", + }, + + { + "a-bC-dEf-ghIj", + "j-Ih-gfE-dCba", + }, + + { + "Test1ng-Leet=code-Q!", + "Qedo1ct-eeLg=ntse-T!", + }, + + // 可以有多个 testcase +} + +func Test_reverseOnlyLetters(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, reverseOnlyLetters(tc.S), "输入:%v", tc) + } +} + +func Benchmark_reverseOnlyLetters(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + reverseOnlyLetters(tc.S) + } + } +} diff --git a/Algorithms/0918.maximum-sum-circular-subarray/README.md b/Algorithms/0918.maximum-sum-circular-subarray/README.md new file mode 100755 index 000000000..56b15cea5 --- /dev/null +++ b/Algorithms/0918.maximum-sum-circular-subarray/README.md @@ -0,0 +1,52 @@ +# [918. Maximum Sum Circular Subarray](https://leetcode.com/problems/maximum-sum-circular-subarray/) + +Given a **circular array C** of integers represented by `A`, find the maximum possible sum of a non-empty subarray of **C**. + +Here, a circular array means the end of the array connects to the beginning of the array.  (Formally, `C[i] = A[i]` when `0 <= i < A.length`, and `C[i+A.length] = C[i]` when `i >= 0`.) + +Also, a subarray may only include each element of the fixed buffer `A` at most once.  (Formally, for a subarray `C[i], C[i+1], ..., C[j]`, there does not exist `i <= k1, k2 <= j` with `k1 % A.length = k2 % A.length`.) + +Example 1: + +```text +Input: [1,-2,3,-2] +Output: 3 +Explanation: Subarray [3] has maximum sum 3 +``` + +Example 2: + +```text +Input: [5,-3,5] +Output: 10 +Explanation: Subarray [5,5] has maximum sum 5 + 5 = 10 +``` + +Example 3: + +```text +Input: [3,-1,2,-1] +Output: 4 +Explanation: Subarray [2,-1,3] has maximum sum 2 + (-1) + 3 = 4 +``` + +Example 4: + +```text +Input: [3,-2,2,-3] +Output: 3 +Explanation: Subarray [3] and [3,-2,2] both have maximum sum 3 +``` + +Example 5: + +```text +Input: [-2,-3,-1] +Output: -1 +Explanation: Subarray [-1] has maximum sum -1 +``` + +Note: + +1. `-30000 <= A[i] <= 30000` +1. `1 <= A.length <= 30000` diff --git a/Algorithms/0918.maximum-sum-circular-subarray/maximum-sum-circular-subarray.go b/Algorithms/0918.maximum-sum-circular-subarray/maximum-sum-circular-subarray.go new file mode 100755 index 000000000..4d23d2f11 --- /dev/null +++ b/Algorithms/0918.maximum-sum-circular-subarray/maximum-sum-circular-subarray.go @@ -0,0 +1,35 @@ +package problem0918 + +// ref: https://leetcode.com/problems/maximum-sum-circular-subarray/discuss/178422/C++JavaPython-One-Pass + +func maxSubarraySumCircular(A []int) int { + total, curMax, curMin := 0, 0, 0 + maxSum, minSum := -30001, 30001 + + for _, a := range A { + curMax = max(curMax+a, a) + maxSum = max(maxSum, curMax) + curMin = min(curMin+a, a) + minSum = min(minSum, curMin) + total += a + } + + if maxSum > 0 { + return max(maxSum, total-minSum) + } + return maxSum +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0918.maximum-sum-circular-subarray/maximum-sum-circular-subarray_test.go b/Algorithms/0918.maximum-sum-circular-subarray/maximum-sum-circular-subarray_test.go new file mode 100755 index 000000000..664fa58e4 --- /dev/null +++ b/Algorithms/0918.maximum-sum-circular-subarray/maximum-sum-circular-subarray_test.go @@ -0,0 +1,59 @@ +package problem0918 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{1, -2, 3, -2}, + 3, + }, + + { + []int{5, -3, 5}, + 10, + }, + + { + []int{3, -1, 2, -1}, + 4, + }, + + { + []int{3, -2, 2, -3}, + 3, + }, + + { + []int{-2, -3, -1}, + -1, + }, + + // 可以有多个 testcase +} + +func Test_maxSubarraySumCircular(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, maxSubarraySumCircular(tc.A), "输入:%v", tc) + } +} + +func Benchmark_maxSubarraySumCircular(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxSubarraySumCircular(tc.A) + } + } +} diff --git a/Algorithms/0919.complete-binary-tree-inserter/README.md b/Algorithms/0919.complete-binary-tree-inserter/README.md new file mode 100755 index 000000000..925fc21e8 --- /dev/null +++ b/Algorithms/0919.complete-binary-tree-inserter/README.md @@ -0,0 +1,29 @@ +# [919. Complete Binary Tree Inserter](https://leetcode.com/problems/complete-binary-tree-inserter/) + +A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. + +Write a data structure CBTInserter that is initialized with a complete binary tree and supports the following operations: + +- CBTInserter(TreeNode root) initializes the data structure on a given tree with head node root; +- CBTInserter.insert(int v) will insert a TreeNode into the tree with value node.val = v so that the tree remains complete, and returns the value of the parent of the inserted TreeNode; +- CBTInserter.get_root() will return the head node of the tree. + +Example 1: + +```text +Input: inputs = ["CBTInserter","insert","get_root"], inputs = [[[1]],[2],[]] +Output: [null,1,[1,2]] +``` + +Example 2: + +```text +Input: inputs = ["CBTInserter","insert","insert","get_root"], inputs = [[[1,2,3,4,5,6]],[7],[8],[]] +Output: [null,3,4,[1,2,3,4,5,6,7,8]] +``` + +Note: + +1. The initial given tree is complete and contains between 1 and 1000 nodes. +1. CBTInserter.insert is called at most 10000 times per test case. +1. Every value of a given or inserted node is between 0 and 5000. \ No newline at end of file diff --git a/Algorithms/0919.complete-binary-tree-inserter/complete-binary-tree-inserter.go b/Algorithms/0919.complete-binary-tree-inserter/complete-binary-tree-inserter.go new file mode 100755 index 000000000..713c1929c --- /dev/null +++ b/Algorithms/0919.complete-binary-tree-inserter/complete-binary-tree-inserter.go @@ -0,0 +1,53 @@ +package problem0919 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is defined in kit +type TreeNode = kit.TreeNode + +// CBTInserter is ... +type CBTInserter struct { + root *TreeNode +} + +// Constructor is ... +func Constructor(root *TreeNode) CBTInserter { + return CBTInserter{root: root} +} + +// Insert is +func (c *CBTInserter) Insert(v int) int { + nds := []*TreeNode{c.root} + + var parent *TreeNode + added := false + +ALL: + for len(nds) > 0 { + size := len(nds) + for i := 0; i < size; i++ { + parent = nds[i] + if parent.Left == nil { + parent.Left = &TreeNode{Val: v} + added = true + } else if parent.Right == nil { + parent.Right = &TreeNode{Val: v} + added = true + } + + if added { + break ALL + } + nds = append(nds, parent.Left, parent.Right) + } + nds = nds[size:] + } + return parent.Val +} + +// Get_root is ... +func (c *CBTInserter) Get_root() *TreeNode { + return c.root +} diff --git a/Algorithms/0919.complete-binary-tree-inserter/complete-binary-tree-inserter_test.go b/Algorithms/0919.complete-binary-tree-inserter/complete-binary-tree-inserter_test.go new file mode 100755 index 000000000..537f54bd5 --- /dev/null +++ b/Algorithms/0919.complete-binary-tree-inserter/complete-binary-tree-inserter_test.go @@ -0,0 +1,45 @@ +package problem0919 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + . "github.com/smartystreets/goconvey/convey" +) + +func Test_CBTInserter(t *testing.T) { + Convey("insert [1]", t, func() { + root := &TreeNode{Val: 1} + c := Constructor(root) + + parent := c.Insert(2) + So(parent, ShouldEqual, 1) + + actual := c.Get_root() + expected := &TreeNode{ + Val: 1, + Left: &TreeNode{ + Val: 2, + }, + } + So(actual, ShouldResemble, expected) + }) + + Convey("insert [1,2,3,4,5,6]", t, func() { + root := kit.Ints2TreeNode([]int{1, 2, 3, 4, 5, 6}) + c := Constructor(root) + + parent := c.Insert(7) + So(parent, ShouldEqual, 3) + + parent = c.Insert(8) + So(parent, ShouldEqual, 4) + + actual := c.Get_root() + expected := kit.Ints2TreeNode([]int{1, 2, 3, 4, 5, 6, 7, 8}) + So(actual, ShouldResemble, expected) + }) + + // +} diff --git a/Algorithms/0920.number-of-music-playlists/README.md b/Algorithms/0920.number-of-music-playlists/README.md new file mode 100755 index 000000000..0fbe86fdc --- /dev/null +++ b/Algorithms/0920.number-of-music-playlists/README.md @@ -0,0 +1,36 @@ +# [920. Number of Music Playlists](https://leetcode.com/problems/number-of-music-playlists/) + +Your music player contains `N` different songs and she wants to listen to `L` (not necessarily different) songs during your trip. You create a playlist so that: + +- Every song is played at least once +- A song can only be played again only if `K` other songs have been played + +Return the number of possible playlists. **As the answer can be very large, return it modulo** `10^9 + 7`. + +Example 1: + +```text +Input: N = 3, L = 3, K = 1 +Output: 6 +Explanation: There are 6 possible playlists. [1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]. +``` + +Example 2: + +```text +Input: N = 2, L = 3, K = 0 +Output: 6 +Explanation: There are 6 possible playlists. [1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 1], [2, 1, 2], [1, 2, 2] +``` + +Example 3: + +```text +Input: N = 2, L = 3, K = 1 +Output: 2 +Explanation: There are 2 possible playlists. [1, 2, 1], [2, 1, 2] +``` + +Note: + +1. 0 <= K < N <= L <= 100 diff --git a/Algorithms/0920.number-of-music-playlists/number-of-music-playlists.go b/Algorithms/0920.number-of-music-playlists/number-of-music-playlists.go new file mode 100755 index 000000000..97fe5df66 --- /dev/null +++ b/Algorithms/0920.number-of-music-playlists/number-of-music-playlists.go @@ -0,0 +1,39 @@ +package problem0920 + +// ref: https://leetcode.com/problems/number-of-music-playlists/discuss/178415/C++JavaPython-DP-Solution + +const mod = 1e9 + 7 + +func numMusicPlaylists(N int, L int, K int) int { + dp := [101][101]int{} + // dp[n][l] means n songs in l lines and K other songs has been played when some song wants to play again + + // 0 <= K < N <= L <= 100 + for n := K + 1; n <= N; n++ { + // when n songs in n lines, + // just factorial n conditions + dp[n][n] = factorial(n) + // when n songs in n+ lines, + for l := n + 1; l <= L; l++ { + count := dp[n-1][l-1]*n + dp[n][l-1]*(n-K) + // dp[n-1][l-1] *n + // dp[n-1][l-1] means n-1 songs has been in [1,l-1] lines, + // want to add a new song which is not in n-1 songs to l line + // the new song could be anyone of n songs, So *n + // dp[n][l-1] *(n-K) + // dp[n][l-1] means n songs has been in [1,l-1] lines, + // add one of n songs to l line + // the song to add must be different with [l-k, l-1] line songs + // only choose from (n-k) songs, So *(n-k) + dp[n][l] = count % mod + } + } + return dp[N][L] +} + +func factorial(n int) int { + if n == 1 { + return 1 + } + return (n * factorial(n-1)) % mod +} diff --git a/Algorithms/0920.number-of-music-playlists/number-of-music-playlists_test.go b/Algorithms/0920.number-of-music-playlists/number-of-music-playlists_test.go new file mode 100755 index 000000000..8f13233df --- /dev/null +++ b/Algorithms/0920.number-of-music-playlists/number-of-music-playlists_test.go @@ -0,0 +1,69 @@ +package problem0920 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + L int + K int + ans int +}{ + + { + 25, + 28, + 5, + 906368459, + }, + + { + 16, + 16, + 4, + 789741546, + }, + + { + 3, + 3, + 1, + 6, + }, + + { + 2, + 3, + 0, + 6, + }, + + { + 2, + 3, + 1, + 2, + }, + + // 可以有多个 testcase +} + +func Test_numMusicPlaylists(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numMusicPlaylists(tc.N, tc.L, tc.K), "输入:%v", tc) + } +} + +func Benchmark_numMusicPlaylists(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numMusicPlaylists(tc.N, tc.L, tc.K) + } + } +} diff --git a/Algorithms/0921.minimum-add-to-make-parentheses-valid/README.md b/Algorithms/0921.minimum-add-to-make-parentheses-valid/README.md new file mode 100755 index 000000000..44b6dd2fc --- /dev/null +++ b/Algorithms/0921.minimum-add-to-make-parentheses-valid/README.md @@ -0,0 +1,44 @@ +# [921. Minimum Add to Make Parentheses Valid](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/) + +Given a string S of `(` and `)` parentheses, we add the minimum number of parentheses ( `(` or `)`, and in any positions ) so that the resulting parentheses string is valid. + +Formally, a parentheses string is valid if and only if: + +- It is the empty string, or +- It can be written as AB (A concatenated with B), where A and B are valid strings, or +- It can be written as (A), where A is a valid string. + +Given a parentheses string, return the minimum number of parentheses we must add to make the resulting string valid. + +Example 1: + +```text +Input: "())" +Output: 1 +``` + +Example 2: + +```text +Input: "(((" +Output: 3 +``` + +Example 3: + +```text +Input: "()" +Output: 0 +``` + +Example 4: + +```text +Input: "()))((" +Output: 4 +``` + +Note: + +1. S.length <= 1000 +1. S only consists of `(` and `)` characters. \ No newline at end of file diff --git a/Algorithms/0921.minimum-add-to-make-parentheses-valid/minimum-add-to-make-parentheses-valid.go b/Algorithms/0921.minimum-add-to-make-parentheses-valid/minimum-add-to-make-parentheses-valid.go new file mode 100755 index 000000000..314d96fbb --- /dev/null +++ b/Algorithms/0921.minimum-add-to-make-parentheses-valid/minimum-add-to-make-parentheses-valid.go @@ -0,0 +1,10 @@ +package problem0921 + +import "strings" + +func minAddToMakeValid(S string) int { + for strings.Contains(S, "()") { + S = strings.Replace(S, "()", "", -1) + } + return len(S) +} diff --git a/Algorithms/0921.minimum-add-to-make-parentheses-valid/minimum-add-to-make-parentheses-valid_test.go b/Algorithms/0921.minimum-add-to-make-parentheses-valid/minimum-add-to-make-parentheses-valid_test.go new file mode 100755 index 000000000..7e35cf293 --- /dev/null +++ b/Algorithms/0921.minimum-add-to-make-parentheses-valid/minimum-add-to-make-parentheses-valid_test.go @@ -0,0 +1,54 @@ +package problem0921 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans int +}{ + + { + "())", + 1, + }, + + { + "(((", + 3, + }, + + { + "()", + 0, + }, + + { + "()))((", + 4, + }, + + // 可以有多个 testcase +} + +func Test_minAddToMakeValid(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Printf("~~%v~~\n", tc) + ast.Equal(tc.ans, minAddToMakeValid(tc.S), "输入:%v", tc) + } +} + +func Benchmark_minAddToMakeValid(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minAddToMakeValid(tc.S) + } + } +} diff --git a/Algorithms/0922.sort-array-by-parity-ii/README.md b/Algorithms/0922.sort-array-by-parity-ii/README.md new file mode 100755 index 000000000..4a37db79f --- /dev/null +++ b/Algorithms/0922.sort-array-by-parity-ii/README.md @@ -0,0 +1,21 @@ +# [922. Sort Array By Parity II](https://leetcode.com/problems/sort-array-by-parity-ii/) + +Given an array `A` of non-negative integers, half of the integers in A are odd, and half of the integers are even. + +Sort the array so that whenever `A[i]` is odd, `i` is odd; and whenever `A[i]` is even, `i` is even. + +You may return any answer array that satisfies this condition. + +Example 1: + +```text +Input: [4,2,5,7] +Output: [4,5,2,7] +Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted. +``` + +Note: + +1. `2 <= A.length <= 20000` +1. `A.length % 2 == 0` +1. `0 <= A[i] <= 1000` \ No newline at end of file diff --git a/Algorithms/0922.sort-array-by-parity-ii/sort-array-by-parity-ii.go b/Algorithms/0922.sort-array-by-parity-ii/sort-array-by-parity-ii.go new file mode 100755 index 000000000..7bb0cfcac --- /dev/null +++ b/Algorithms/0922.sort-array-by-parity-ii/sort-array-by-parity-ii.go @@ -0,0 +1,19 @@ +package problem0922 + +func sortArrayByParityII(A []int) []int { + size := len(A) + res := make([]int, size) + even, odd := 0, 1 + + for _, a := range A { + if a%2 == 0 { + res[even] = a + even += 2 + } else { + res[odd] = a + odd += 2 + } + } + + return res +} diff --git a/Algorithms/0922.sort-array-by-parity-ii/sort-array-by-parity-ii_test.go b/Algorithms/0922.sort-array-by-parity-ii/sort-array-by-parity-ii_test.go new file mode 100755 index 000000000..b9bef97f8 --- /dev/null +++ b/Algorithms/0922.sort-array-by-parity-ii/sort-array-by-parity-ii_test.go @@ -0,0 +1,44 @@ +package problem0922 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int +}{ + + { + []int{4, 2, 5, 7}, + }, + + // 可以有多个 testcase +} + +func Test_sortArrayByParityII(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.True(check(sortArrayByParityII(tc.A))) + } +} + +func Benchmark_sortArrayByParityII(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + sortArrayByParityII(tc.A) + } + } +} + +func check(a []int) bool { + for i := range a { + if a[i]%2 != i%2 { + return false + } + } + return true +} diff --git a/Algorithms/0923.3sum-with-multiplicity/3sum-with-multiplicity.go b/Algorithms/0923.3sum-with-multiplicity/3sum-with-multiplicity.go new file mode 100755 index 000000000..11abec354 --- /dev/null +++ b/Algorithms/0923.3sum-with-multiplicity/3sum-with-multiplicity.go @@ -0,0 +1,53 @@ +package problem0923 + +// refer: https://leetcode.com/problems/3sum-with-multiplicity/discuss/181131/C++JavaPython-O(1012) + +const mod = 1e9 + 7 + +// first of all, swap will NOT change answer +// for example +// A[0]=0, A[1]=1, A[2]=2 , A[0]+A[1]+A[2]=3 +// A[0]=1, A[1]=0, A[2]=2 , A[0]+A[1]+A[2]=3 +// i, j, k and A[i]+A[j]+A[k] don't change, answer don't change +// if we sort A +// then, i A[i]<=A[j]<=A[k] +// but we do not need sort A +// just count it + +func threeSumMulti(A []int, target int) int { + count := [101]int{} + for _, a := range A { + count[a]++ + } + + res := 0 + + for Ai := 0; Ai <= 100; Ai++ { + for Aj := Ai; Aj <= 100; Aj++ { // so always Ai<=Aj + Ak := target - Ai - Aj + if Ak < 0 || 100 < Ak { // need 0<= A[k] <= 100 + continue + } + + // remember, i A[i]<=A[j]<=A[k] + // A[i]<=A[j]<=A[k] has 4 conditions + // 按照以下情况分别计算组合数的话 + // 可以确保 A[i]<=A[j]<=A[k] => i malware:恶意软件 + +In a network of nodes, each node `i` is directly connected to another node `j` if and only if `graph[i][j] = 1`. + +Some nodes `initial` are initially infected by malware. Whenever two nodes are directly connected and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner. + +Suppose `M(initial)` is the final number of nodes infected with malware in the entire network, after the spread of malware stops. + +We will remove one node from the initial list. Return the node that if removed, would minimize `M(initial)`. If multiple nodes could be removed to minimize `M(initial)`, return such a node with the smallest index. + +Note that if a node was removed from the `initial` list of infected nodes, it may still be infected later as a result of the malware spread. + +Example 1: + +```text +Input: graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1] +Output: 0 +``` + +Example 2: + +```text +Input: graph = [[1,0,0],[0,1,0],[0,0,1]], initial = [0,2] +Output: 0 +``` + +Example 3: + +```text +Input: graph = [[1,1,1],[1,1,1],[1,1,1]], initial = [1,2] +Output: 1 +``` + +Note: + +1. `1 < graph.length = graph[0].length <= 300` +1. `0 <= graph[i][j] == graph[j][i] <= 1` +1. `graph[i][i] = 1` +1. `1 <= initial.length < graph.length` +1. `0 <= initial[i] < graph.length` \ No newline at end of file diff --git a/Algorithms/0924.minimize-malware-spread/minimize-malware-spread.go b/Algorithms/0924.minimize-malware-spread/minimize-malware-spread.go new file mode 100755 index 000000000..d88977ee0 --- /dev/null +++ b/Algorithms/0924.minimize-malware-spread/minimize-malware-spread.go @@ -0,0 +1,75 @@ +package problem0924 + +// 题目的意思是,在 graph 中寻找包含 initial 点的连通区域 +// 如果,所有包含 initial 点的连通区域,都不止一个 initial 点 +// 返回,initial 中的最小值。 +// 如果,存在只包含一个 initial 点的连通区域, +// 找到只包含一个 initial 点且最大的连通区域 +// 返回其中 initial 点的值。 + +func minMalwareSpread(graph [][]int, initial []int) int { + size := len(graph) + + maxCount := -1 + res := size + + // 记录 initial 中的点,并找到其中的最小值作为 res 备选 + isInitial := [301]bool{} + for _, n := range initial { + isInitial[n] = true + res = min(res, n) + } + + for candidate := 0; candidate < size; candidate++ { + if !isInitial[candidate] { + continue + } + + // 从 initial 中的点,可以寻找连通区域 + + queue := make([]int, 1, size) + queue[0] = candidate + + hasSeen := [301]bool{} + hasSeen[candidate] = true + isUnique := true // 标记此连通区域中,只有一个 initial 点 + count := 1 // 记录此连通区域中点的数目 + + // BFS + for len(queue) > 0 { + queueSize := len(queue) + for idx := 0; idx < queueSize; idx++ { + i := queue[idx] + for j := 0; j < size; j++ { + if !hasSeen[j] && graph[i][j] == 1 { + hasSeen[j] = true + count++ + queue = append(queue, j) + if isInitial[j] { + isUnique = false + isInitial[j] = false + // 这样就不会再次搜索此连通区域,可以加快速度 + // 并且可以保证 i 就是此连通区域中最小的 initial 点 + } + } + } + } + queue = queue[queueSize:] + } + + if isUnique && // 只有一个 initial 点时,才有必要更新 res + maxCount < count { + maxCount = count + res = candidate + } + } + + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0924.minimize-malware-spread/minimize-malware-spread_test.go b/Algorithms/0924.minimize-malware-spread/minimize-malware-spread_test.go new file mode 100755 index 000000000..ca97255e9 --- /dev/null +++ b/Algorithms/0924.minimize-malware-spread/minimize-malware-spread_test.go @@ -0,0 +1,63 @@ +package problem0924 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + graph [][]int + initial []int + ans int +}{ + + { + [][]int{{1, 1, 0}, {1, 1, 0}, {0, 0, 1}}, + []int{0, 1, 2}, + 2, + }, + + { + [][]int{{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 1}, {0, 0, 1, 1}}, + []int{3, 1}, + 3, + }, + + { + [][]int{{1, 1, 0}, {1, 1, 0}, {0, 0, 1}}, + []int{0, 1}, + 0, + }, + + { + [][]int{{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, + []int{0, 2}, + 0, + }, + + { + [][]int{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, + []int{1, 2}, + 1, + }, + + // 可以有多个 testcase +} + +func Test_minMalwareSpread(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minMalwareSpread(tc.graph, tc.initial), "输入:%v", tc) + } +} + +func Benchmark_minMalwareSpread(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minMalwareSpread(tc.graph, tc.initial) + } + } +} diff --git a/Algorithms/0925.long-pressed-name/README.md b/Algorithms/0925.long-pressed-name/README.md new file mode 100755 index 000000000..68d2dcef9 --- /dev/null +++ b/Algorithms/0925.long-pressed-name/README.md @@ -0,0 +1,42 @@ +# [925. Long Pressed Name](https://leetcode.com/problems/long-pressed-name/) + +Your friend is typing his `name` into a keyboard. Sometimes, when typing a character `c`, the key might get long pressed, and the character will be typed 1 or more times. + +You examine the `typed` characters of the keyboard. Return `True` if it is possible that it was your friends name, with some characters (possibly none) being long pressed. + +Example 1: + +```text +Input: name = "alex", typed = "aaleex" +Output: true +Explanation: 'a' and 'e' in 'alex' were long pressed. +``` + +Example 2: + +```text +Input: name = "saeed", typed = "ssaaedd" +Output: false +Explanation: 'e' must have been pressed twice, but it wasn't in the typed output. +``` + +Example 3: + +```text +Input: name = "leelee", typed = "lleeelee" +Output: true +``` + +Example 4: + +```text +Input: name = "laiden", typed = "laiden" +Output: true +Explanation: It's not necessary to long press any character. +``` + +Note: + +1. `name.length <= 1000` +1. `typed.length <= 1000` +1. The characters of `name` and `typed` are lowercase letters. \ No newline at end of file diff --git a/Algorithms/0925.long-pressed-name/long-pressed-name.go b/Algorithms/0925.long-pressed-name/long-pressed-name.go new file mode 100755 index 000000000..8a16c60df --- /dev/null +++ b/Algorithms/0925.long-pressed-name/long-pressed-name.go @@ -0,0 +1,34 @@ +package problem0925 + +func isLongPressedName(name, typed string) bool { + if name == typed { + return true + } + + nameSize := len(name) + typedSize := len(typed) + + i, j := 0, 0 + + for i < nameSize && j < typedSize { + c := name[i] + need, pressed := 0, 0 + + for i < nameSize && name[i] == c { + need++ + i++ + } + + for j < typedSize && typed[j] == c { + pressed++ + j++ + } + + if pressed < need { + return false + } + + } + + return i == nameSize && j == typedSize +} diff --git a/Algorithms/0925.long-pressed-name/long-pressed-name_test.go b/Algorithms/0925.long-pressed-name/long-pressed-name_test.go new file mode 100755 index 000000000..8ce6df705 --- /dev/null +++ b/Algorithms/0925.long-pressed-name/long-pressed-name_test.go @@ -0,0 +1,75 @@ +package problem0925 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + name string + typed string + ans bool +}{ + + { + "alex", + "aaaaaaaaaaaallllllllllllllleeeeeeeeeeeeeeeexxxxxxxxx", + true, + }, + + { + "alex", + "aal", + false, + }, + + { + "alex", + "aaleexOK", + false, + }, + + { + "alex", + "aaleex", + true, + }, + + { + "saeed", + "ssaaedd", + false, + }, + + { + "leelee", + "lleeelee", + true, + }, + + { + "laiden", + "laiden", + true, + }, + + // 可以有多个 testcase +} + +func Test_isLongPressedName(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, isLongPressedName(tc.name, tc.typed), "输入:%v", tc) + } +} + +func Benchmark_isLongPressedName(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isLongPressedName(tc.name, tc.typed) + } + } +} diff --git a/Algorithms/0926.flip-string-to-monotone-increasing/README.md b/Algorithms/0926.flip-string-to-monotone-increasing/README.md new file mode 100755 index 000000000..815e7b334 --- /dev/null +++ b/Algorithms/0926.flip-string-to-monotone-increasing/README.md @@ -0,0 +1,36 @@ +# [926. Flip String to Monotone Increasing](https://leetcode.com/problems/flip-string-to-monotone-increasing/) + +A string of `0`s and `1`s is monotone increasing if it consists of some number of `0`s (possibly 0), followed by some number of `1`s (also possibly 0.) + +We are given a string `S` of `0`s and `1`s, and we may flip any `0` to a `1` or a `1` to a `0`. + +Return the minimum number of flips to make `S` monotone increasing. + +Example 1: + +```text +Input: "00110" +Output: 1 +Explanation: We flip the last digit to get 00111. +``` + +Example 2: + +```text +Input: "010110" +Output: 2 +Explanation: We flip to get 011111, or alternatively 000111. +``` + +Example 3: + +```text +Input: "00011000" +Output: 2 +Explanation: We flip to get 00000000. +``` + +Note: + +1. `1 <= S.length <= 20000` +1. `S` only consists of `0` and `1` characters. \ No newline at end of file diff --git a/Algorithms/0926.flip-string-to-monotone-increasing/flip-string-to-monotone-increasing.go b/Algorithms/0926.flip-string-to-monotone-increasing/flip-string-to-monotone-increasing.go new file mode 100755 index 000000000..4ced736cd --- /dev/null +++ b/Algorithms/0926.flip-string-to-monotone-increasing/flip-string-to-monotone-increasing.go @@ -0,0 +1,36 @@ +package problem0926 + +func minFlipsMonoIncr(S string) int { + size := len(S) + + count := make([]int, size+1) + for i := 0; i < size; i++ { + count[i+1] = count[i] + if S[i] == '1' { + count[i+1]++ + } + } + + res := size + for i := 0; i <= size; i++ { + // for S[:i] is all 0 + // need flip 1 to 0 in S[:i], + // there are count[i] 1s in S[i:] + // for S[i:] is all 1 + // need flip 0 to 1 in S[i:], + // length of S[i:] is size-i, + // count of 1s in S[i:] is count[size]-count[i], + // there are (size-i)-(count[size]-count[i]) 0s in S[i:] + tmp := count[i] + ((size - i) - (count[size] - count[i])) + res = min(res, tmp) + } + + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0926.flip-string-to-monotone-increasing/flip-string-to-monotone-increasing_test.go b/Algorithms/0926.flip-string-to-monotone-increasing/flip-string-to-monotone-increasing_test.go new file mode 100755 index 000000000..f286a0b61 --- /dev/null +++ b/Algorithms/0926.flip-string-to-monotone-increasing/flip-string-to-monotone-increasing_test.go @@ -0,0 +1,57 @@ +package problem0926 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans int +}{ + + { + "01000011110", + 2, + }, + + { + "00110", + 1, + }, + + { + "00110", + 1, + }, + + { + "010110", + 2, + }, + + { + "00011000", + 2, + }, + + // 可以有多个 testcase +} + +func Test_minFlipsMonoIncr(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minFlipsMonoIncr(tc.S), "输入:%v", tc) + } +} + +func Benchmark_minFlipsMonoIncr(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minFlipsMonoIncr(tc.S) + } + } +} diff --git a/Algorithms/0927.three-equal-parts/README.md b/Algorithms/0927.three-equal-parts/README.md new file mode 100755 index 000000000..9c6760b04 --- /dev/null +++ b/Algorithms/0927.three-equal-parts/README.md @@ -0,0 +1,33 @@ +# [927. Three Equal Parts](https://leetcode.com/problems/three-equal-parts/) + +Given an array `A` of `0`s and `1`s, divide the array into 3 non-empty parts such that all of these parts represent the same binary value. + +If it is possible, return **any** `[i, j]` with `i+1 < j`, such that: + +- `A[0], A[1], ..., A[i]` is the first part; +- `A[i+1], A[i+2], ..., A[j-1]` is the second part, and +- `A[j], A[j+1], ..., A[A.length - 1]` is the third part. +- All three parts have equal binary value. + +If it is not possible, return `[-1, -1]`. + +Note that the entire part is used when considering what binary value it represents. For example, `[1,1,0]` represents `6` in decimal, not `3`. Also, leading zeros are allowed, so `[0,1,1]` and `[1,1]` represent the same value. + +Example 1: + +```text +Input: [1,0,1,0,1] +Output: [0,3] +``` + +Example 2: + +```text +Input: [1,1,0,1,1] +Output: [-1,-1] +``` + +Note: + +1. `3 <= A.length <= 30000` +1. `A[i] == 0` or `A[i] == 1` \ No newline at end of file diff --git a/Algorithms/0927.three-equal-parts/three-equal-parts.go b/Algorithms/0927.three-equal-parts/three-equal-parts.go new file mode 100755 index 000000000..9022c918e --- /dev/null +++ b/Algorithms/0927.three-equal-parts/three-equal-parts.go @@ -0,0 +1,52 @@ +package problem0927 + +// ref: https://leetcode.com/problems/three-equal-parts/discuss/183922/C++-O(n)-time-O(1)-space-12-ms-with-explanation-and-comments + +var noPossible = []int{-1, -1} + +func threeEqualParts(A []int) []int { + size := len(A) + + indexs := make([]int, 0, size) + for i, val := range A { + if val == 1 { + indexs = append(indexs, i) + } + } + + count := len(indexs) + + if count == 0 { + return []int{0, 2} + } + + if count%3 != 0 { + // 此时,无法保证每个部分都有相同数目的 1 + // 所以,不可能出现可行解 + return noPossible + } + + c1, c2 := count/3, count/3*2 + s0, s1, s2 := indexs[0], indexs[c1], indexs[c2] + + // 此时 A[s0:s1], A[s1:s2] 和 A[s2:] 中分别有三分之一的 1 + // 且 + // A[s0]==A[s1]==A[s2]==1 三个部分的第一个 1 已经对齐 + // 可以开始逐个比较 + for s2 < size && + A[s0] == A[s1] && + A[s1] == A[s2] { + s0++ + s1++ + s2++ + } + + if s2 == size { + // 此时, 所有的 1 都被比较过了 + // 且三段中的 1 分布相同。 + // 没有被比较的元素都是 0 + return []int{s0 - 1, s1} + } + + return noPossible +} diff --git a/Algorithms/0927.three-equal-parts/three-equal-parts_test.go b/Algorithms/0927.three-equal-parts/three-equal-parts_test.go new file mode 100755 index 000000000..23b971352 --- /dev/null +++ b/Algorithms/0927.three-equal-parts/three-equal-parts_test.go @@ -0,0 +1,52 @@ +package problem0927 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans []int +}{ + + { + []int{0, 0, 0, 0, 0}, + []int{0, 2}, + }, + + { + []int{1, 0, 1, 0, 1, 0, 0}, + []int{-1, -1}, + }, + + { + []int{1, 0, 1, 0, 1}, + []int{0, 3}, + }, + + { + []int{1, 1, 0, 1, 1}, + []int{-1, -1}, + }, + + // 可以有多个 testcase +} + +func Test_threeEqualParts(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, threeEqualParts(tc.A), "输入:%v", tc) + } +} + +func Benchmark_threeEqualParts(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + threeEqualParts(tc.A) + } + } +} diff --git a/Algorithms/0928.minimize-malware-spread-ii/README.md b/Algorithms/0928.minimize-malware-spread-ii/README.md new file mode 100755 index 000000000..750fd267d --- /dev/null +++ b/Algorithms/0928.minimize-malware-spread-ii/README.md @@ -0,0 +1,40 @@ +# [928. Minimize Malware Spread II](https://leetcode.com/problems/minimize-malware-spread-ii/) + +(This problem is the same as Minimize Malware Spread, with the differences bolded.) + +In a network of nodes, each node `i` is directly connected to another node `j` if and only if `graph[i][j] = 1`. + +Some nodes `initial` are initially infected by malware. Whenever two nodes are directly connected and at least one of those two nodes is infected by malware, both nodes will be infected by malware. This spread of malware will continue until no more nodes can be infected in this manner. + +Suppose `M(initial)` is the final number of nodes infected with malware in the entire network, after the spread of malware stops. + +We will remove one node from the initial list, **completely removing it and any connections from this node to any other node**. Return the node that if removed, would minimize `M(initial)`. If multiple nodes could be removed to minimize `M(initial)`, return such a node with the smallest index. + +Example 1: + +```text +Input: graph = [[1,1,0],[1,1,0],[0,0,1]], initial = [0,1] +Output: 0 +``` + +Example 2: + +```text +Input: graph = [[1,1,0],[1,1,1],[0,1,1]], initial = [0,1] +Output: 1 +``` + +Example 3: + +```text +Input: graph = [[1,1,0,0],[1,1,1,0],[0,1,1,1],[0,0,1,1]], initial = [0,1] +Output: 1 +``` + +Note: + +1. `1 < graph.length = graph[0].length <= 300` +1. `0 <= graph[i][j] == graph[j][i] <= 1` +1. `graph[i][i] = 1` +1. `1 <= initial.length < graph.length` +1. `0 <= initial[i] < graph.length` diff --git a/Algorithms/0928.minimize-malware-spread-ii/minimize-malware-spread-ii.go b/Algorithms/0928.minimize-malware-spread-ii/minimize-malware-spread-ii.go new file mode 100755 index 000000000..ff2591318 --- /dev/null +++ b/Algorithms/0928.minimize-malware-spread-ii/minimize-malware-spread-ii.go @@ -0,0 +1,60 @@ +package problem0928 + +func minMalwareSpread(graph [][]int, initial []int) int { + size := len(graph) + + infected := make([]bool, size) + for _, i := range initial { + infected[i] = true + } + + seen := make([]bool, size) + + var dfs func(int) int + // 返回 0 表示遇到了 infected 计算机 + dfs = func(i int) int { + if infected[i] { + return 0 + } + count := 1 // 1 是代表了 i 本身 + seen[i] = true + for j := 0; j < size; j++ { + if seen[j] || graph[i][j] == 0 { + continue + } + c := dfs(j) + if c == 0 { + // 深入过程中,遇到了 infected + // 就把 i 标记为 infected,可以加快后续的步骤 + // 但需要同时标记 seen[i]=false + // 因为 dfs 不会检查 seen[i]=true 的点是否已经感染。 + infected[i] = true + seen[i] = false + return 0 + } + count += c + } + return count + } + + maxCount := -1 + res := size + + for _, i := range initial { + count := 0 + seen[i] = true + for j := 0; j < size; j++ { + if seen[j] || graph[i][j] == 0 { + continue + } + count += dfs(j) + } + if (maxCount < count) || + (maxCount == count && res > i) { + maxCount = count + res = i + } + } + + return res +} diff --git a/Algorithms/0928.minimize-malware-spread-ii/minimize-malware-spread-ii_test.go b/Algorithms/0928.minimize-malware-spread-ii/minimize-malware-spread-ii_test.go new file mode 100755 index 000000000..55887fa7d --- /dev/null +++ b/Algorithms/0928.minimize-malware-spread-ii/minimize-malware-spread-ii_test.go @@ -0,0 +1,144 @@ +package problem0928 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + graph [][]int + initial []int + ans int +}{ + + { + [][]int{ + {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, + {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0}, + {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, + {1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}}, + []int{18, 5, 3, 37, 10, 19}, + 3, + }, + + { + [][]int{ + {1, 1, 0, 1, 0, 0}, + {1, 1, 1, 1, 0, 0}, + {0, 1, 1, 0, 0, 0}, + {1, 1, 0, 1, 0, 0}, + {0, 0, 0, 0, 1, 1}, + {0, 0, 0, 0, 1, 1}, + }, + []int{0, 2, 4}, + 4, + }, + + { + [][]int{ + {1, 1, 0, 1, 0}, + {1, 1, 1, 1, 0}, + {0, 1, 1, 0, 0}, + {1, 1, 0, 1, 0}, + {0, 0, 0, 0, 1}, + }, + []int{0, 2, 4}, + 0, + }, + + { + [][]int{{1, 1, 0}, {1, 1, 1}, {0, 1, 1}}, + []int{0, 1}, + 1, + }, + + { + [][]int{ + {1, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 1, 0, 1, 0, 0}, + {0, 0, 0, 1, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 1, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 1, 0, 0, 0}, + {0, 0, 1, 0, 0, 0, 1, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 1, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 1}, + }, + []int{6, 0, 4}, + 0, + }, + + { + [][]int{{1, 1, 0, 0}, {1, 1, 1, 0}, {0, 1, 1, 1}, {0, 0, 1, 1}}, + []int{0, 1}, + 1, + }, + + { + [][]int{{1, 1, 0}, {1, 1, 0}, {0, 0, 1}}, + []int{0}, + 0, + }, + + { + [][]int{{1, 1, 0}, {1, 1, 0}, {0, 0, 1}}, + []int{0, 1}, + 0, + }, + + // 可以有多个 testcase +} + +func Test_minMalwareSpread(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minMalwareSpread(tc.graph, tc.initial), "输入:%v", tc) + } +} + +func Benchmark_minMalwareSpread(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minMalwareSpread(tc.graph, tc.initial) + } + } +} diff --git a/Algorithms/0929.unique-email-addresses/README.md b/Algorithms/0929.unique-email-addresses/README.md new file mode 100755 index 000000000..33803928b --- /dev/null +++ b/Algorithms/0929.unique-email-addresses/README.md @@ -0,0 +1,29 @@ +# [929. Unique Email Addresses](https://leetcode.com/problems/unique-email-addresses/) + +Every email consists of a local name and a domain name, separated by the @ sign. + +For example, in `alice@leetcode.com`, `alice` is the local name, and `leetcode.com` is the domain name. + +Besides lowercase letters, these emails may contain `.`s or `+`s. + +If you add periods (`.`) between some characters in the **local name** part of an email address, mail sent there will be forwarded to the same address without dots in the **local name**. For example, `"alice.z@leetcode.com"` and `"alicez@leetcode.com"` forward to the same email address. (Note that this rule does not apply for domain names.) + +If you add a plus (`+`) in the **local name**, everything after the first plus sign will be ignored. This allows certain emails to be filtered, for example `m.y+name@email.com` will be forwarded to `my@email.com`. (Again, this rule does not apply for domain names.) + +It is possible to use both of these rules at the same time. + +Given a list of `emails`, we send one email to each address in the list. How many different addresses actually receive mails? + +Example 1: + +```text +Input: ["test.email+alex@leetcode.com","test.e.mail+bob.cathy@leetcode.com","testemail+david@lee.tcode.com"] +Output: 2 +Explanation: "testemail@leetcode.com" and "testemail@lee.tcode.com" actually receive mails +``` + +Note: + +1. `1 <= emails[i].length <= 100` +1. `1 <= emails.length <= 100` +1. Each `emails[i]` contains exactly one `@` character. diff --git a/Algorithms/0929.unique-email-addresses/unique-email-addresses.go b/Algorithms/0929.unique-email-addresses/unique-email-addresses.go new file mode 100755 index 000000000..33f1eace0 --- /dev/null +++ b/Algorithms/0929.unique-email-addresses/unique-email-addresses.go @@ -0,0 +1,31 @@ +package problem0929 + +import ( + "strings" +) + +func numUniqueEmails(emails []string) int { + hasSeen := make(map[string]bool, 100) + for _, email := range emails { + hasSeen[clean(email)] = true + } + return len(hasSeen) +} + +func clean(email string) string { + i := strings.IndexByte(email, '@') + user, atDomain := email[:i], email[i:] + return deleteDot(trim(user)) + atDomain +} + +func deleteDot(username string) string { + return strings.Replace(username, ".", "", -1) +} + +func trim(username string) string { + i := strings.IndexByte(username, '+') + if i == -1 { + return username + } + return username[:i] +} diff --git a/Algorithms/0929.unique-email-addresses/unique-email-addresses_test.go b/Algorithms/0929.unique-email-addresses/unique-email-addresses_test.go new file mode 100755 index 000000000..68ee2950d --- /dev/null +++ b/Algorithms/0929.unique-email-addresses/unique-email-addresses_test.go @@ -0,0 +1,47 @@ +package problem0929 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + emails []string + ans int +}{ + + { + []string{"test.email@leetcode.com", "test.e.mai+bob.cathy@leetcode.com"}, + 2, + }, + + { + []string{"test.email+alex@leetcode.com", "test.e.mai+bob.cathy@leetcode.com"}, + 2, + }, + + { + []string{"test.email+alex@leetcode.com", "test.e.mail+bob.cathy@leetcode.com", "testemail+david@lee.tcode.com"}, + 2, + }, + + // 可以有多个 testcase +} + +func Test_numUniqueEmails(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numUniqueEmails(tc.emails), "输入:%v", tc) + } +} + +func Benchmark_numUniqueEmails(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numUniqueEmails(tc.emails) + } + } +} diff --git a/Algorithms/0930.binary-subarrays-with-sum/README.md b/Algorithms/0930.binary-subarrays-with-sum/README.md new file mode 100755 index 000000000..ef4f7ad7b --- /dev/null +++ b/Algorithms/0930.binary-subarrays-with-sum/README.md @@ -0,0 +1,22 @@ +# [930. Binary Subarrays With Sum](https://leetcode.com/problems/binary-subarrays-with-sum/) + +In an array A of 0s and 1s, how many non-empty subarrays have sum S? + +Example 1: + +```text +Input: A = [1,0,1,0,1], S = 2 +Output: 4 +Explanation: +The 4 subarrays are bolded below: +[1,0,1,0,1] +[1,0,1,0,1] +[1,0,1,0,1] +[1,0,1,0,1] +``` + +Note: + +1. `A.length <= 30000` +1. `0 <= S <= A.length` +1. `A[i] is either 0 or 1.` \ No newline at end of file diff --git a/Algorithms/0930.binary-subarrays-with-sum/binary-subarrays-with-sum.go b/Algorithms/0930.binary-subarrays-with-sum/binary-subarrays-with-sum.go new file mode 100755 index 000000000..1733d92e0 --- /dev/null +++ b/Algorithms/0930.binary-subarrays-with-sum/binary-subarrays-with-sum.go @@ -0,0 +1,17 @@ +package problem0930 + +// ref: https://leetcode.com/problems/binary-subarrays-with-sum/discuss/186683/C%2B%2BJavaPython-Straight-Forward + +func numSubarraysWithSum(A []int, S int) int { + preSum, res := 0, 0 + count := make([]int, len(A)+1) + count[0] = 1 + for _, n := range A { + preSum += n + if preSum >= S { + res += count[preSum-S] + } + count[preSum]++ + } + return res +} diff --git a/Algorithms/0930.binary-subarrays-with-sum/binary-subarrays-with-sum_test.go b/Algorithms/0930.binary-subarrays-with-sum/binary-subarrays-with-sum_test.go new file mode 100755 index 000000000..ebb6baa21 --- /dev/null +++ b/Algorithms/0930.binary-subarrays-with-sum/binary-subarrays-with-sum_test.go @@ -0,0 +1,63 @@ +package problem0930 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + S int + ans int +}{ + + { + []int{1, 1, 1, 1, 1, 1, 1, 1}, + 6, + 3, + }, + + { + []int{0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, + 0, + 27, + }, + + { + []int{0, 0, 0, 0, 1}, + 2, + 0, + }, + + { + []int{0, 0, 0, 0, 0}, + 0, + 15, + }, + + { + []int{1, 0, 1, 0, 1}, + 2, + 4, + }, + + // 可以有多个 testcase +} + +func Test_numSubarraysWithSum(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numSubarraysWithSum(tc.A, tc.S), "输入:%v", tc) + } +} + +func Benchmark_numSubarraysWithSum(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numSubarraysWithSum(tc.A, tc.S) + } + } +} diff --git a/Algorithms/0931.minimum-falling-path-sum/README.md b/Algorithms/0931.minimum-falling-path-sum/README.md new file mode 100755 index 000000000..1228d815e --- /dev/null +++ b/Algorithms/0931.minimum-falling-path-sum/README.md @@ -0,0 +1,25 @@ +# [931. Minimum Falling Path Sum](https://leetcode.com/problems/minimum-falling-path-sum/) + +Given a **square** array of integers `A`, we want the **minimum** sum of a *falling* path through `A`. + +A falling path starts at any element in the first row, and chooses one element from each row. The next row's choice must be in a column that is different from the previous row's column by at most one. + +Example 1: + +```text +Input: [[1,2,3],[4,5,6],[7,8,9]] +Output: 12 +Explanation: +The possible falling paths are: +``` + +- `[1,4,7], [1,4,8], [1,5,7], [1,5,8], [1,5,9]` +- `[2,4,7], [2,4,8], [2,5,7], [2,5,8], [2,5,9], [2,6,8], [2,6,9]` +- `[3,5,7], [3,5,8], [3,5,9], [3,6,8], [3,6,9]` + +The falling path with the smallest sum is `[1,4,7]`, so the answer is `12`. + +Note: + +1. `1 <= A.length == A[0].length <= 100` +1. `-100 <= A[i][j] <= 100` diff --git a/Algorithms/0931.minimum-falling-path-sum/minimum-falling-path-sum.go b/Algorithms/0931.minimum-falling-path-sum/minimum-falling-path-sum.go new file mode 100755 index 000000000..03b618195 --- /dev/null +++ b/Algorithms/0931.minimum-falling-path-sum/minimum-falling-path-sum.go @@ -0,0 +1,44 @@ +package problem0931 + +const maxSum = 10000 + +func minFallingPathSum(A [][]int) int { + size := len(A) + + dp := make([]int, size) + copy(dp, A[0]) + + for i := 1; i < size; i++ { + tmps := [100]int{} + for j := 0; j < size; j++ { + a, tmp := A[i][j], maxSum + l, r := max(j-1, 0), min(j+1, size-1) + for k := l; k <= r; k++ { + tmp = min(tmp, a+dp[k]) + } + tmps[j] = tmp + } + dp = tmps[:size] + } + + res := maxSum + for i := 0; i < size; i++ { + res = min(res, dp[i]) + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0931.minimum-falling-path-sum/minimum-falling-path-sum_test.go b/Algorithms/0931.minimum-falling-path-sum/minimum-falling-path-sum_test.go new file mode 100755 index 000000000..a0c8b0b89 --- /dev/null +++ b/Algorithms/0931.minimum-falling-path-sum/minimum-falling-path-sum_test.go @@ -0,0 +1,68 @@ +package problem0931 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A [][]int + ans int +}{ + + { + [][]int{ + {1, 2, 3}, + {4, 5, 6}, + {7, 8, 9}, + }, + 12, + }, + + { + [][]int{ + {-19, -1, -96, 48, -94, 36, 16, 55, -42, 37, -59, 6, -32, 96, 95, -58, 13, -34, 94, 85}, + {17, 44, 36, -29, 84, 80, -34, 50, -99, 64, 13, 91, -27, 25, -36, 57, 20, 98, -100, -72}, + {-92, -75, 86, 90, -4, 90, 64, 56, 50, -63, 10, -15, 90, -66, -66, 32, -69, -78, 1, 60}, + {21, 51, -47, -43, -14, 99, 44, 90, 8, 11, 99, -62, 57, 59, 69, 50, -69, 32, 85, 13}, + {-28, 90, 12, -18, 23, 61, -55, -97, 6, 89, 36, 26, 26, -1, 46, -50, 79, -45, 89, 86}, + {-85, -10, 49, -10, 2, 62, 41, 92, -67, 85, 86, 27, 89, -50, 77, 55, 22, -82, -94, -98}, + {-50, 53, -23, 55, 25, -22, 76, -93, -7, 66, -75, 42, -35, -96, -5, 4, -92, 13, -31, -100}, + {-62, -78, 8, -92, 86, 69, 90, -37, 81, 97, 53, -45, 34, 19, -19, -39, -88, -75, -74, -4}, + {29, 53, -91, 65, -92, 11, 49, 26, 90, -31, 17, -84, 12, 63, -60, -48, 40, -49, -48, 88}, + {100, -69, 80, 11, -93, 17, 28, -94, 52, 64, -86, 30, -9, -53, -8, -68, -33, 31, -5, 11}, + {9, 64, -31, 63, -84, -15, -30, -10, 67, 2, 98, 73, -77, -37, -96, 47, -97, 78, -62, -17}, + {-88, -38, -22, -90, 54, 42, -29, 67, -85, -90, -29, 81, 52, 35, 13, 61, -18, -94, 61, -62}, + {-23, -29, -76, -30, -65, 23, 31, -98, -9, 11, 75, -1, -84, -90, 73, 58, 72, -48, 30, -81}, + {66, -33, 91, -6, -94, 82, 25, -43, -93, -25, -69, 10, -71, -65, 85, 28, -52, 76, 25, 90}, + {-3, 78, 36, -92, -52, -44, -66, -53, -55, 76, -7, 76, -73, 13, -98, 86, -99, -22, 61, 100}, + {-97, 65, 2, -93, 56, -78, 22, 56, 35, -24, -95, -13, 83, -34, -51, -73, 2, 7, -86, -19}, + {32, 94, -14, -13, -6, -55, -21, 29, -21, 16, 67, 100, 77, -26, -96, 22, -5, -53, -92, -36}, + {60, 93, -79, 76, -91, 43, -95, -16, 74, -21, 85, 43, 21, -68, -32, -18, 18, 100, -43, 1}, + {87, -31, 26, 53, 26, 51, -61, 92, -65, 17, -41, 27, -42, -14, 37, -46, 46, -31, -74, 23}, + {-67, -14, -20, -85, 42, 36, 56, 9, 11, -66, -59, -55, 5, 64, -29, 77, 47, 44, -33, -77}, + }, + -1428, + }, + + // 可以有多个 testcase +} + +func Test_minFallingPathSum(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + + ast.Equal(tc.ans, minFallingPathSum(tc.A), "输入:%v", tc) + } +} + +func Benchmark_minFallingPathSum(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minFallingPathSum(tc.A) + } + } +} diff --git a/Algorithms/0932.beautiful-array/README.md b/Algorithms/0932.beautiful-array/README.md new file mode 100755 index 000000000..477e87499 --- /dev/null +++ b/Algorithms/0932.beautiful-array/README.md @@ -0,0 +1,25 @@ +# [932. Beautiful Array](https://leetcode.com/problems/beautiful-array/) + +For some fixed `N`, an array `A` is *beautiful* if it is a permutation of the integers `1, 2, ..., N`, such that: + +For every `i < j`, there is **no** `k` with `i < k < j` such that `A[k] * 2 = A[i] + A[j]`. + +Given `N`, return **any** beautiful array `A`. (It is guaranteed that one exists.) + +Example 1: + +```text +Input: 4 +Output: [2,1,4,3] +``` + +Example 2: + +```text +Input: 5 +Output: [3,1,2,5,4] +``` + +Note: + +- `1 <= N <= 1000` diff --git a/Algorithms/0932.beautiful-array/beautiful-array.go b/Algorithms/0932.beautiful-array/beautiful-array.go new file mode 100755 index 000000000..f90cf08b7 --- /dev/null +++ b/Algorithms/0932.beautiful-array/beautiful-array.go @@ -0,0 +1,46 @@ +package problem0932 + +// ref: https://leetcode.com/problems/beautiful-array/discuss/186679/C%2B%2BJavaPython-Odd-%2B-Even-Pattern-O(N) +// + +func beautifulArray(N int) []int { + res := []int{1} + for len(res) < N { + tmp := make([]int, 0, len(res)*2) + for _, v := range res { + if v*2-1 <= N { + tmp = append(tmp, v*2-1) + } + } + for _, v := range res { + if v*2 <= N { + tmp = append(tmp, v*2) + } + } + res = tmp + } + + return res +} + +/** + * 以 N == 10 为例,res 的变化过程是 + * [1] + * [1 2] + * [1 3 2 4] + * [1 5 3 7 2 6 4 8] + * [1 9 5 13 3 11 7 15 2 10 6 14 4 12 8 16] + * 长度超过 N,进行裁剪,删除 >N=10 的数字。裁剪不改变 beautiful + * [1 9 5 3 7 2 10 6 4 8] + * + * 每个下一行的 + * 左半部分,都是 上一行×2-1 + * 右半部分,都是 上一行×2 + * 由文章中证明,× 和 - 不会改变 beautiful + * 所以,左右两边都是 beautiful 的 + * + * 左右合并的时候,只需要讨论 Ai 和 Aj 分别位于左右两边的情况。 + * 左边的 Ai 是奇数,右边的 Aj 是偶数。所以 Ai+Aj 是奇数。 + * 而 Ak×2 是偶数,所以,不存在 Ak×2 == Ai+Aj + * A 仍然是 beautiful 的 + */ diff --git a/Algorithms/0932.beautiful-array/beautiful-array_test.go b/Algorithms/0932.beautiful-array/beautiful-array_test.go new file mode 100755 index 000000000..b384843d2 --- /dev/null +++ b/Algorithms/0932.beautiful-array/beautiful-array_test.go @@ -0,0 +1,78 @@ +package problem0932 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int +}{ + + { + 4, + }, + + { + 5, + }, + + { + 10, + }, + + { + 1000, + }, + + // 可以有多个 testcase +} + +func isBeautiful(A []int) bool { + size := len(A) + for i := 0; i < size; i++ { + for j := i + 2; j < size; j++ { + AiPlusAj := A[i] + A[j] + for k := i + 1; k < j; k++ { + Ak := A[k] + if Ak*2 == AiPlusAj || Ak > size { + fmt.Println(A[i], A[k], A[j]) + return false + } + } + } + } + return true +} + +func Test_checkArray(t *testing.T) { + ast := assert.New(t) + + results := [][]int{ + {2, 1, 4, 5, 3}, + {3, 5, 1, 2, 4}, + } + + for _, r := range results { + ast.True(isBeautiful(r)) + } +} + +func Test_beautifulArray(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.True(isBeautiful(beautifulArray(tc.N)), "输入:%v", tc) + } +} + +func Benchmark_beautifulArray(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + beautifulArray(tc.N) + } + } +} diff --git a/Algorithms/0933.number-of-recent-calls/README.md b/Algorithms/0933.number-of-recent-calls/README.md new file mode 100755 index 000000000..a3ea4f659 --- /dev/null +++ b/Algorithms/0933.number-of-recent-calls/README.md @@ -0,0 +1,24 @@ +# [933. Number of Recent Calls](https://leetcode.com/problems/number-of-recent-calls/) + +Write a class `RecentCounter` to count recent requests. + +It has only one method: `ping(int t)`, where t represents some time in milliseconds. + +Return the number of `pings` that have been made from 3000 milliseconds ago until now. + +Any ping with time in `[t - 3000, t]` will count, including the current ping. + +It is guaranteed that every call to `ping` uses a strictly larger value of `t` than before. + +Example 1: + +```text +Input: inputs = ["RecentCounter","ping","ping","ping","ping"], inputs = [[],[1],[100],[3001],[3002]] +Output: [null,1,2,3,3] +``` + +Note: + +1. Each test case will have at most 10000 calls to ping. +1. Each test case will call ping with strictly increasing values of t. +1. Each call to ping will have 1 <= t <= 10^9. \ No newline at end of file diff --git a/Algorithms/0933.number-of-recent-calls/number-of-recent-calls.go b/Algorithms/0933.number-of-recent-calls/number-of-recent-calls.go new file mode 100755 index 000000000..43580838d --- /dev/null +++ b/Algorithms/0933.number-of-recent-calls/number-of-recent-calls.go @@ -0,0 +1,27 @@ +package problem0933 + +import "sort" + +/** + * Your RecentCounter object will be instantiated and called as such: + * obj := Constructor(); + * param_1 := obj.Ping(t); + */ + +// RecentCounter ... +type RecentCounter struct { + times []int +} + +// Constructor ... +func Constructor() RecentCounter { + return RecentCounter{ + times: make([]int, 0, 10000), + } +} + +// Ping use binary search +func (rc *RecentCounter) Ping(t int) int { + rc.times = append(rc.times, t) + return len(rc.times) - sort.SearchInts(rc.times, t-3000) +} diff --git a/Algorithms/0933.number-of-recent-calls/number-of-recent-calls_test.go b/Algorithms/0933.number-of-recent-calls/number-of-recent-calls_test.go new file mode 100755 index 000000000..8c7fbb5bc --- /dev/null +++ b/Algorithms/0933.number-of-recent-calls/number-of-recent-calls_test.go @@ -0,0 +1,21 @@ +package problem0933 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_myFunc(t *testing.T) { + ast := assert.New(t) + + rc := Constructor() + + times := []int{1, 100, 3001, 3002} + counters := []int{1, 2, 3, 3} + + for i := range times { + t, c := times[i], counters[i] + ast.Equal(c, rc.Ping(t)) + } +} diff --git a/Algorithms/0934.shortest-bridge/README.md b/Algorithms/0934.shortest-bridge/README.md new file mode 100755 index 000000000..25ed6cb49 --- /dev/null +++ b/Algorithms/0934.shortest-bridge/README.md @@ -0,0 +1,33 @@ +# [934. Shortest Bridge](https://leetcode.com/problems/shortest-bridge/) + +In a given 2D binary array `A`, there are two islands. (An island is a 4-directionally connected group of `1s` not connected to any other 1s.) + +Now, we may change `0s` to `1s` so as to connect the two islands together to form 1 island. + +Return the smallest number of `0s` that must be flipped. (It is guaranteed that the answer is at least 1.) + +Example 1: + +```text +Input: [[0,1],[1,0]] +Output: 1 +``` + +Example 2: + +```text +Input: [[0,1,0],[0,0,0],[0,0,1]] +Output: 2 +``` + +Example 3: + +```text +Input: [[1,1,1,1,1],[1,0,0,0,1],[1,0,1,0,1],[1,0,0,0,1],[1,1,1,1,1]] +Output: 1 +``` + +Note: + +1. `1 <= A.length = A[0].length <= 100` +1. `A[i][j] == 0` or `A[i][j] == 1` diff --git a/Algorithms/0934.shortest-bridge/shortest-bridge.go b/Algorithms/0934.shortest-bridge/shortest-bridge.go new file mode 100755 index 000000000..65c96b0ab --- /dev/null +++ b/Algorithms/0934.shortest-bridge/shortest-bridge.go @@ -0,0 +1,73 @@ +package problem0934 + +var dx = []int{1, -1, 0, 0} +var dy = []int{0, 0, 1, -1} + +func shortestBridge(A [][]int) int { + m, n := len(A), len(A[0]) + + p, q := searchForIsland(A) + + isChecked := [100][100]bool{} + isChecked[p][q] = true + + island := make([][]int, 0, 1024) + island = append(island, []int{p, q}) + + // bfs 查找岛中全部的点 + for idx := 0; idx < len(island); idx++ { + i, j := island[idx][0], island[idx][1] + for l := 0; l < 4; l++ { + x, y := i+dx[l], j+dy[l] + if 0 <= x && x < m && + 0 <= y && y < n && + A[x][y] == 1 && + !isChecked[x][y] { + island = append(island, []int{x, y}) + isChecked[x][y] = true + } + } + } + + bridge := island + length := 0 + + // 此时, bridge 中所有的点,在 isChecked 中都被标记为 true + + // bfs 查找最短的桥 + for len(bridge) > 0 { + size := len(bridge) + for idx := 0; idx < size; idx++ { + land := bridge[idx] + i, j := land[0], land[1] + for l := 0; l < 4; l++ { + x, y := i+dx[l], j+dy[l] + if 0 <= x && x < m && + 0 <= y && y < n && + !isChecked[x][y] { + if A[x][y] == 1 { + return length + } + A[x][y] = 1 + bridge = append(bridge, []int{x, y}) + isChecked[x][y] = true + } + } + } + bridge = bridge[size:] + length++ + } + + panic("A has only one island") +} + +func searchForIsland(A [][]int) (int, int) { + for i := 0; i < len(A); i++ { + for j := 0; j < len(A[0]); j++ { + if A[i][j] == 1 { + return i, j + } + } + } + panic("A has NO island.") +} diff --git a/Algorithms/0934.shortest-bridge/shortest-bridge_test.go b/Algorithms/0934.shortest-bridge/shortest-bridge_test.go new file mode 100755 index 000000000..3d8840c56 --- /dev/null +++ b/Algorithms/0934.shortest-bridge/shortest-bridge_test.go @@ -0,0 +1,69 @@ +package problem0934 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A [][]int + ans int +}{ + + { + [][]int{ + {0, 1, 0}, + {0, 0, 0}, + {0, 0, 1}, + }, + 2, + }, + + { + [][]int{ + {0, 1}, + {1, 0}, + }, + 1, + }, + + { + [][]int{ + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 1, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 1}, + }, + 1, + }, + + // 可以有多个 testcase +} + +func Test_shortestBridge(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + ast.Equal(tc.ans, shortestBridge(tc.A), "输入:%v", tc) + } +} + +func Benchmark_shortestBridge(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shortestBridge(tc.A) + } + } +} + +func Test_searchForIsland_panicWithNoIsland(t *testing.T) { + ast := assert.New(t) + ast.Panics(func() { searchForIsland([][]int{}) }) +} + +func Test_shortestBridge_panicWithOnlyOneIsland(t *testing.T) { + ast := assert.New(t) + ast.Panics(func() { shortestBridge([][]int{{1, 0}}) }) +} diff --git a/Algorithms/0935.knight-dialer/README.md b/Algorithms/0935.knight-dialer/README.md new file mode 100755 index 000000000..0c3b85908 --- /dev/null +++ b/Algorithms/0935.knight-dialer/README.md @@ -0,0 +1,51 @@ +# [935. Knight Dialer](https://leetcode.com/problems/knight-dialer/) + +A chess knight can move as indicated in the chess diagram below: + +![knight](knight.png) + +![keypad](keypad.png) + +This time, we place our chess knight on any numbered key of a phone pad (indicated above), and the knight makes `N-1` hops. Each hop must be from one key to another numbered key. + +Each time it lands on a key (including the initial placement of the knight), it presses the number of that key, pressing N digits total. + +How many distinct numbers can you dial in this manner? + +Since the answer may be large, **output the answer modulo 10^9 + 7**. + +Example 1: + +```text +Input: 1 +Output: 10 +``` + +Example 2: + +```text +Input: 2 +Output: 20 +``` + +Example 3: + +```text +Input: 3 +Output: 46 +``` + +Note: + +- `1 <= N <= 5000` + +## 提醒 + +```text +1 2 3 +4 5 6 +7 8 9 +* 0 # +``` + +4 可以到达 0, 4 -> 7 -> * -> 0。同理,6 也可以达到 0。 diff --git a/Algorithms/0935.knight-dialer/keypad.png b/Algorithms/0935.knight-dialer/keypad.png new file mode 100644 index 000000000..4dae52779 Binary files /dev/null and b/Algorithms/0935.knight-dialer/keypad.png differ diff --git a/Algorithms/0935.knight-dialer/knight-dialer.go b/Algorithms/0935.knight-dialer/knight-dialer.go new file mode 100755 index 000000000..d16060cec --- /dev/null +++ b/Algorithms/0935.knight-dialer/knight-dialer.go @@ -0,0 +1,56 @@ +package problem0935 + +const mod = 1e9 + 7 + +var rec = [5000][10]int{} + +var hop = [][]int{ + {4, 6}, // from 0 + {6, 8}, // from 1 + {7, 9}, // from 2 + {4, 8}, // from 3 + {3, 9, 0}, // from 4, 4 -> 7 -> * -> 0 + {}, // from 5 + {0, 1, 7}, // from 6 + {2, 6}, // from 7 + {1, 3}, // from 8 + {2, 4}, // from 9 +} + +func knightDialer(N int) int { + if N == 1 { + // now can chose 5 + return 10 + } + + res := 0 + for i := 0; i < 10; i++ { + res += recur(N-1, i, &rec) + } + + return res % mod +} + +func recur(N, digit int, rec *[5000][10]int) int { + r := (*rec)[N][digit] + if r > 0 { + return r + } + + h := hop[digit] + + if N == 1 { + l := len(h) + (*rec)[N][digit] = l + return l + } + + res := 0 + for _, d := range h { + res += recur(N-1, d, rec) + } + res %= mod + + (*rec)[N][digit] = res + return res +} diff --git a/Algorithms/0935.knight-dialer/knight-dialer_test.go b/Algorithms/0935.knight-dialer/knight-dialer_test.go new file mode 100755 index 000000000..55f8ba6f4 --- /dev/null +++ b/Algorithms/0935.knight-dialer/knight-dialer_test.go @@ -0,0 +1,52 @@ +package problem0935 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans int +}{ + + { + 1, + 10, + }, + + { + 2, + 20, + }, + + { + 3, + 46, + }, + + { + 5000, + 406880451, + }, + + // 可以有多个 testcase +} + +func Test_knightDialer(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, knightDialer(tc.N), "输入:%v", tc) + } +} + +func Benchmark_knightDialer(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + knightDialer(tc.N) + } + } +} diff --git a/Algorithms/0935.knight-dialer/knight.png b/Algorithms/0935.knight-dialer/knight.png new file mode 100644 index 000000000..b3cd5dd8e Binary files /dev/null and b/Algorithms/0935.knight-dialer/knight.png differ diff --git a/Algorithms/0936.stamping-the-sequence/README.md b/Algorithms/0936.stamping-the-sequence/README.md new file mode 100755 index 000000000..d2af83621 --- /dev/null +++ b/Algorithms/0936.stamping-the-sequence/README.md @@ -0,0 +1,35 @@ +# [936. Stamping The Sequence](https://leetcode.com/problems/stamping-the-sequence/) + +You want to form a target string of lowercase letters. + +At the beginning, your sequence is target.length '?' marks. You also have a stamp of lowercase letters. + +On each turn, you may place the stamp over the sequence, and replace every letter in the sequence with the corresponding letter from the stamp. You can make up to 10 * target.length turns. + +For example, if the initial sequence is "?????", and your stamp is "abc", then you may make "abc??", "?abc?", "??abc" in the first turn. (Note that the stamp must be fully contained in the boundaries of the sequence in order to stamp.) + +If the sequence is possible to stamp, then return an array of the index of the left-most letter being stamped at each turn. If the sequence is not possible to stamp, return an empty array. + +For example, if the sequence is "ababc", and the stamp is "abc", then we could return the answer [0, 2], corresponding to the moves "?????" -> "abc??" -> "ababc". + +Also, if the sequence is possible to stamp, it is guaranteed it is possible to stamp within 10 * target.length moves. Any answers specifying more than this number of moves will not be accepted. + +Example 1: + +```text +Input: stamp = "abc", target = "ababc" +Output: [0,2] +([1,0,2] would also be accepted as an answer, as well as some other answers.) +``` + +Example 2: + +```text +Input: stamp = "abca", target = "aabcaca" +Output: [3,0,1] +``` + +Note: + +- 1 <= stamp.length <= target.length <= 1000 +- stamp and target only contain lowercase letters. diff --git a/Algorithms/0936.stamping-the-sequence/stamping-the-sequence.go b/Algorithms/0936.stamping-the-sequence/stamping-the-sequence.go new file mode 100755 index 000000000..7f054eb32 --- /dev/null +++ b/Algorithms/0936.stamping-the-sequence/stamping-the-sequence.go @@ -0,0 +1,62 @@ +package problem0936 + +import "strings" + +// ref: https://leetcode.com/problems/stamping-the-sequence/discuss/189254/Python-Greedy-and-DFS + +func movesToStamp(stamp string, target string) []int { + s, t := []byte(stamp), []byte(target) + sSize, tSize := len(stamp), len(target) + + res := make([]int, 0, 1000) + + // isStamped return true if stamped since i + isStamped := func(i int) bool { + canStamp := false + for j := 0; j < sSize; j++ { + if t[i+j] == '?' { + continue + } + if t[i+j] != s[j] { + return false + } + canStamp = true + } + if canStamp { + for k := i; k < i+sSize; k++ { + t[k] = '?' + } + res = append(res, i) + } + return canStamp + } + + maxIndex := tSize - sSize + 1 + + for { + isChanged := false + for i := 0; i < maxIndex; i++ { + isChanged = isChanged || isStamped(i) + } + if !isChanged { + // no more place to stamp + break + } + } + + reverse(res) + + if string(t) == strings.Repeat("?", tSize) { + return res + } + return nil +} + +func reverse(a []int) { + l, r := 0, len(a)-1 + for l < r { + a[l], a[r] = a[r], a[l] + l++ + r-- + } +} diff --git a/Algorithms/0936.stamping-the-sequence/stamping-the-sequence_test.go b/Algorithms/0936.stamping-the-sequence/stamping-the-sequence_test.go new file mode 100755 index 000000000..37cf81785 --- /dev/null +++ b/Algorithms/0936.stamping-the-sequence/stamping-the-sequence_test.go @@ -0,0 +1,72 @@ +package problem0936 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + stamp string + target string +}{ + + { + "ab", + "aba", + }, + + { + "abc", + "ababc", + }, + + { + "abca", + "aabcaca", + }, + + // +} + +func isCorrect(stamp, target string, sequence []int) bool { + if len(sequence) > 10*len(target) { + return false + } + sb := []byte(stamp) + lt := len(target) + tb := make([]byte, lt*2) + for _, i := range sequence { + copy(tb[i:], sb) + } + stb := string(tb[:lt]) + if stb != target && len(sequence) != 0 { + fmt.Println(stamp, target, sequence) + return false + } + return true +} + +func Test_isCorrect(t *testing.T) { + ast := assert.New(t) + ast.True(isCorrect("aba", "ababa", []int{0, 2})) + ast.True(isCorrect("aba", "ababa", []int{2, 0})) +} + +func Test_movesToStamp(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + seq := movesToStamp(tc.stamp, tc.target) + ast.True(isCorrect(tc.stamp, tc.target, seq)) + } +} + +func Benchmark_movesToStamp(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + movesToStamp(tc.stamp, tc.target) + } + } +} diff --git a/Algorithms/0937.reorder-log-files/README.md b/Algorithms/0937.reorder-log-files/README.md new file mode 100755 index 000000000..bc9ef86c7 --- /dev/null +++ b/Algorithms/0937.reorder-log-files/README.md @@ -0,0 +1,27 @@ +# [937. Reorder Log Files](https://leetcode.com/problems/reorder-log-files/) + +You have an array of `logs`. Each log is a space delimited string of words. + +For each log, the first word in each log is an alphanumeric identifier. Then, either: + +- Each word after the identifier will consist only of lowercase letters, or; +- Each word after the identifier will consist only of digits. + +We will call these two varieties of logs letter-logs and digit-logs. It is guaranteed that each log has at least one word after its identifier. + +Reorder the logs so that all of the letter-logs come before any digit-log. The letter-logs are ordered lexicographically ignoring identifier, with the identifier used in case of ties. The digit-logs should be put in their original order. + +Return the final order of the logs. + +Example 1: + +```text +Input: ["a1 9 2 3 1","g1 act car","zo4 4 7","ab1 off key dog","a8 act zoo"] +Output: ["g1 act car","a8 act zoo","ab1 off key dog","a1 9 2 3 1","zo4 4 7"] +``` + +Note: + +1. `0 <= logs.length <= 100` +1. `3 <= logs[i].length <= 100` +1. `logs[i]` is guaranteed to have an identifier, and a word after the identifier. diff --git a/Algorithms/0937.reorder-log-files/reorder-log-files.go b/Algorithms/0937.reorder-log-files/reorder-log-files.go new file mode 100755 index 000000000..5c1255a35 --- /dev/null +++ b/Algorithms/0937.reorder-log-files/reorder-log-files.go @@ -0,0 +1,23 @@ +package problem0937 + +import ( + "sort" + "strings" + "unicode" +) + +func reorderLogFiles(logs []string) []string { + sort.SliceStable(logs, func(i, j int) bool { + s1 := strings.SplitN(logs[i], " ", 2) + s2 := strings.SplitN(logs[j], " ", 2) + f1, f2 := "0"+s1[1], "0"+s2[1] + if unicode.IsNumber(rune(f1[1])) { + f1 = "1" + } + if unicode.IsNumber(rune(f2[1])) { + f2 = "1" + } + return f1 < f2 + }) + return logs +} diff --git a/Algorithms/0937.reorder-log-files/reorder-log-files_test.go b/Algorithms/0937.reorder-log-files/reorder-log-files_test.go new file mode 100755 index 000000000..ec304f762 --- /dev/null +++ b/Algorithms/0937.reorder-log-files/reorder-log-files_test.go @@ -0,0 +1,37 @@ +package problem0937 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + logs []string + ans []string +}{ + + { + []string{"a1 9 2 3 1", "g1 act car", "zo4 4 7", "ab1 off key dog", "a8 act zoo"}, + []string{"g1 act car", "a8 act zoo", "ab1 off key dog", "a1 9 2 3 1", "zo4 4 7"}, + }, + + // 可以有多个 testcase +} + +func Test_reorderLogFiles(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, reorderLogFiles(tc.logs), "输入:%v", tc) + } +} + +func Benchmark_reorderLogFiles(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + reorderLogFiles(tc.logs) + } + } +} diff --git a/Algorithms/0938.range-sum-of-bst/README.md b/Algorithms/0938.range-sum-of-bst/README.md new file mode 100755 index 000000000..1cc4b3929 --- /dev/null +++ b/Algorithms/0938.range-sum-of-bst/README.md @@ -0,0 +1,24 @@ +# [938. Range Sum of BST](https://leetcode.com/problems/range-sum-of-bst/) + +Given the `root` node of a binary search tree, return the sum of values of all nodes with value between `L` and `R` (inclusive). + +The binary search tree is guaranteed to have unique values. + +Example 1: + +```text +Input: root = [10,5,15,3,7,null,18], L = 7, R = 15 +Output: 32 +``` + +Example 2: + +```text +Input: root = [10,5,15,3,7,13,18,1,null,6], L = 6, R = 10 +Output: 23 +``` + +Note: + +1. The number of nodes in the tree is at most `10000`. +1. The final answer is guaranteed to be less than `2^31`. \ No newline at end of file diff --git a/Algorithms/0938.range-sum-of-bst/range-sum-of-bst.go b/Algorithms/0938.range-sum-of-bst/range-sum-of-bst.go new file mode 100755 index 000000000..89e2e4090 --- /dev/null +++ b/Algorithms/0938.range-sum-of-bst/range-sum-of-bst.go @@ -0,0 +1,27 @@ +package problem0938 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is Definition for a binary tree node. +type TreeNode = kit.TreeNode + +func rangeSumBST(root *TreeNode, L int, R int) int { + if root == nil { + return 0 + } + + sum := 0 + + switch { + case root.Val < L: + sum = rangeSumBST(root.Right, L, R) + case R < root.Val: + sum = rangeSumBST(root.Left, L, R) + default: + sum = root.Val + sum += rangeSumBST(root.Left, L, R) + sum += rangeSumBST(root.Right, L, R) + } + + return sum +} diff --git a/Algorithms/0938.range-sum-of-bst/range-sum-of-bst_test.go b/Algorithms/0938.range-sum-of-bst/range-sum-of-bst_test.go new file mode 100755 index 000000000..b1797edff --- /dev/null +++ b/Algorithms/0938.range-sum-of-bst/range-sum-of-bst_test.go @@ -0,0 +1,51 @@ +package problem0938 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + L int + R int + ans int +}{ + + { + []int{10, 5, 15, 3, 7, kit.NULL, 18}, + 7, + 15, + 32, + }, + + { + []int{10, 5, 15, 3, 7, 13, 18, 1, kit.NULL, 6}, + 6, + 10, + 23, + }, + + // 可以有多个 testcase +} + +func Test_rangeSumBST(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, rangeSumBST(root, tc.L, tc.R), "输入:%v", tc) + } +} + +func Benchmark_rangeSumBST(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + rangeSumBST(root, tc.L, tc.R) + } + } +} diff --git a/Algorithms/0939.minimum-area-rectangle/README.md b/Algorithms/0939.minimum-area-rectangle/README.md new file mode 100755 index 000000000..ef722d0dd --- /dev/null +++ b/Algorithms/0939.minimum-area-rectangle/README.md @@ -0,0 +1,26 @@ +# [939. Minimum Area Rectangle](https://leetcode.com/problems/minimum-area-rectangle/) + +Given a set of points in the xy-plane, determine the minimum area of a rectangle formed from these points, with sides parallel to the x and y axes. + +If there isn't any rectangle, return 0. + +Example 1: + +```text +Input: [[1,1],[1,3],[3,1],[3,3],[2,2]] +Output: 4 +``` + +Example 2: + +```text +Input: [[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]] +Output: 2 +``` + +Note: + +1. `1 <= points.length <= 500` +1. `0 <= points[i][0] <= 40000` +1. `0 <= points[i][1] <= 40000` +1. All points are distinct. \ No newline at end of file diff --git a/Algorithms/0939.minimum-area-rectangle/minimum-area-rectangle.go b/Algorithms/0939.minimum-area-rectangle/minimum-area-rectangle.go new file mode 100755 index 000000000..1f4d475ec --- /dev/null +++ b/Algorithms/0939.minimum-area-rectangle/minimum-area-rectangle.go @@ -0,0 +1,44 @@ +package problem0939 + +const initialArea = 2000000000 // > 40000*40000 + +func minAreaRect(points [][]int) int { + size := len(points) + + isExisting := make(map[[2]int]bool, size) + for _, p := range points { + x, y := p[0], p[1] + isExisting[[2]int{x, y}] = true + } + + minArea := initialArea + + for i := 0; i < size; i++ { + xi, yi := points[i][0], points[i][1] + for j := i + 1; j < size; j++ { + xj, yj := points[j][0], points[j][1] + if xi == xj || yi == yj { + continue + } + area := abs((xi - xj) * (yi - yj)) + if area >= minArea || // NOTICE: delay heavy operation + !isExisting[[2]int{xi, yj}] || + !isExisting[[2]int{xj, yi}] { + continue + } + minArea = area + } + } + + if minArea == initialArea { + return 0 + } + return minArea +} + +func abs(n int) int { + if n < 0 { + return -n + } + return n +} diff --git a/Algorithms/0939.minimum-area-rectangle/minimum-area-rectangle_test.go b/Algorithms/0939.minimum-area-rectangle/minimum-area-rectangle_test.go new file mode 100755 index 000000000..c30f86242 --- /dev/null +++ b/Algorithms/0939.minimum-area-rectangle/minimum-area-rectangle_test.go @@ -0,0 +1,54 @@ +package problem0939 + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + points [][]int + ans int +}{ + + { + [][]int{{3, 2}, {1, 3}, {3, 0}, {3, 4}, {2, 1}, {0, 4}, {0, 3}, {4, 1}, {2, 4}}, + 0, + }, + + { + [][]int{{1, 1}, {1, 3}, {3, 1}, {3, 3}, {2, 2}}, + 4, + }, + + { + [][]int{{1, 1}, {1, 3}, {3, 1}, {3, 3}, {4, 1}, {4, 3}}, + 2, + }, + + { + [][]int{{3, 2}, {3, 1}, {4, 4}, {1, 1}, {4, 3}, {0, 3}, {0, 2}, {4, 0}}, + 0, + }, + + // 可以有多个 testcase +} + +func Test_minAreaRect(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + fmt.Println("====") + ast.Equal(tc.ans, minAreaRect(tc.points), "输入:%v", tc) + } +} + +func Benchmark_minAreaRect(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minAreaRect(tc.points) + } + } +} diff --git a/Algorithms/0940.distinct-subsequences-ii/README.md b/Algorithms/0940.distinct-subsequences-ii/README.md new file mode 100755 index 000000000..d6be61b5d --- /dev/null +++ b/Algorithms/0940.distinct-subsequences-ii/README.md @@ -0,0 +1,34 @@ +# [940. Distinct Subsequences II](https://leetcode.com/problems/distinct-subsequences-ii/) + +Given a string S, count the number of distinct, non-empty subsequences of S . + +Since the result may be large, return the answer modulo 10^9 + 7. + +Example 1: + +```text +Input: "abc" +Output: 7 +Explanation: The 7 distinct subsequences are "a", "b", "c", "ab", "ac", "bc", and "abc". +``` + +Example 2: + +```text +Input: "aba" +Output: 6 +Explanation: The 6 distinct subsequences are "a", "b", "ab", "ba", "aa" and "aba". +``` + +Example 3: + +```text +Input: "aaa" +Output: 3 +Explanation: The 3 distinct subsequences are "a", "aa" and "aaa". +``` + +Note: + +1. `S contains only lowercase letters.` +1. `1 <= S.length <= 2000` diff --git a/Algorithms/0940.distinct-subsequences-ii/distinct-subsequences-ii.go b/Algorithms/0940.distinct-subsequences-ii/distinct-subsequences-ii.go new file mode 100755 index 000000000..fba77bdd1 --- /dev/null +++ b/Algorithms/0940.distinct-subsequences-ii/distinct-subsequences-ii.go @@ -0,0 +1,23 @@ +package problem0940 + +// ref: https://www.jianshu.com/p/02501f516437 + +const mod = 1e9 + 7 + +func distinctSubseqII(S string) int { + tail := make([]int, 26) + + total := func() int { + count := 0 + for i := 0; i < 26; i++ { + count += tail[i] + } + return count % mod + } + + for _, r := range S { + tail[r-'a'] = total() + 1 + } + + return total() +} diff --git a/Algorithms/0940.distinct-subsequences-ii/distinct-subsequences-ii_test.go b/Algorithms/0940.distinct-subsequences-ii/distinct-subsequences-ii_test.go new file mode 100755 index 000000000..b051dc6b6 --- /dev/null +++ b/Algorithms/0940.distinct-subsequences-ii/distinct-subsequences-ii_test.go @@ -0,0 +1,52 @@ +package problem0940 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans int +}{ + + { + "adsflkasldgalksdglakdsfjlakjdsglkasjdlkasdadsflkdsfldaslfjsdaldadsabc", + 589422165, + }, + + { + "abc", + 7, + }, + + { + "aba", + 6, + }, + + { + "aaa", + 3, + }, + + // 可以有多个 testcase +} + +func Test_distinctSubseqII(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, distinctSubseqII(tc.S), "输入:%v", tc) + } +} + +func Benchmark_distinctSubseqII(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + distinctSubseqII(tc.S) + } + } +} diff --git a/Algorithms/0941.valid-mountain-array/README.md b/Algorithms/0941.valid-mountain-array/README.md new file mode 100755 index 000000000..e2efd670b --- /dev/null +++ b/Algorithms/0941.valid-mountain-array/README.md @@ -0,0 +1,36 @@ +# [941. Valid Mountain Array](https://leetcode.com/problems/valid-mountain-array/) + +Given an array `A` of integers, return `true` if and only if it is a valid mountain array. + +Recall that A is a mountain array if and only if: + +- `A.length >= 3` +- There exists some i with `0 < i < A.length - 1` such that: + - `A[0] < A[1] < ... A[i-1] < A[i]` + - `A[i] > A[i+1] > ... > A[B.length - 1]` + +Example 1: + +```text +Input: [2,1] +Output: false +``` + +Example 2: + +```text +Input: [3,5,5] +Output: false +``` + +Example 3: + +```text +Input: [0,3,2,1] +Output: true +``` + +Note: + +1. `0 <= A.length <= 10000` +1. `0 <= A[i] <= 10000` \ No newline at end of file diff --git a/Algorithms/0941.valid-mountain-array/valid-mountain-array.go b/Algorithms/0941.valid-mountain-array/valid-mountain-array.go new file mode 100755 index 000000000..e8b608ba4 --- /dev/null +++ b/Algorithms/0941.valid-mountain-array/valid-mountain-array.go @@ -0,0 +1,22 @@ +package problem0941 + +func validMountainArray(A []int) bool { + size := len(A) + + if size < 3 { + return false + } + + i := 1 + for i < size && A[i-1] < A[i] { + i++ + } + + top := i - 1 + + for i < size && A[i-1] > A[i] { + i++ + } + + return 0 < top && top < size-1 && i == size +} diff --git a/Algorithms/0941.valid-mountain-array/valid-mountain-array_test.go b/Algorithms/0941.valid-mountain-array/valid-mountain-array_test.go new file mode 100755 index 000000000..a6f13a8f0 --- /dev/null +++ b/Algorithms/0941.valid-mountain-array/valid-mountain-array_test.go @@ -0,0 +1,57 @@ +package problem0941 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans bool +}{ + + { + []int{9,8,7,6,5,4,3,2,1,0}, + false, + }, + + { + []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, + false, + }, + + { + []int{2, 1}, + false, + }, + + { + []int{3, 5, 5}, + false, + }, + + { + []int{0, 3, 2, 1}, + true, + }, + + // 可以有多个 testcase +} + +func Test_validMountainArray(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, validMountainArray(tc.A), "输入:%v", tc) + } +} + +func Benchmark_validMountainArray(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + validMountainArray(tc.A) + } + } +} diff --git a/Algorithms/0942.di-string-match/README.md b/Algorithms/0942.di-string-match/README.md new file mode 100755 index 000000000..0db2b06b8 --- /dev/null +++ b/Algorithms/0942.di-string-match/README.md @@ -0,0 +1,34 @@ +# [942. DI String Match](https://leetcode.com/problems/di-string-match/) + +Given a string `S` that **only** contains "I" (increase) or "D" (decrease), let N = S.length. + +Return **any** permutation `A` of `[0, 1, ..., N]` such that for all `i = 0, ..., N-1`: + +- If `S[i] == "I"`, then `A[i] < A[i+1]` +- If `S[i] == "D"`, then `A[i] > A[i+1]` + +Example 1: + +```text +Input: "IDID" +Output: [0,4,1,3,2] +``` + +Example 2: + +```text +Input: "III" +Output: [0,1,2,3] +``` + +Example 3: + +```text +Input: "DDI" +Output: [3,2,0,1] +``` + +Note: + +1. `1 <= S.length <= 10000` +1. `S` only contains characters "I" or "D". diff --git a/Algorithms/0942.di-string-match/di-string-match.go b/Algorithms/0942.di-string-match/di-string-match.go new file mode 100755 index 000000000..318c0899e --- /dev/null +++ b/Algorithms/0942.di-string-match/di-string-match.go @@ -0,0 +1,21 @@ +package problem0942 + +func diStringMatch(S string) []int { + size := len(S) + l, r := 0, size + a := make([]int, size+1) + for i, b := range S { + if b == 'I' { + a[i] = l + l++ + } else { + a[i] = r + r-- + } + i++ + } + + a[size] = l + + return a +} diff --git a/Algorithms/0942.di-string-match/di-string-match_test.go b/Algorithms/0942.di-string-match/di-string-match_test.go new file mode 100755 index 000000000..3f60087b5 --- /dev/null +++ b/Algorithms/0942.di-string-match/di-string-match_test.go @@ -0,0 +1,62 @@ +package problem0942 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string +}{ + + { + "IDID", + }, + + { + "III", + }, + + { + "DDI", + }, + + // 可以有多个 testcase +} + +func isCorrect(s string, a []int) bool { + for i, b := range s { + switch b { + case 'I': + if !(a[i] < a[i+1]) { + return false + } + case 'D': + if !(a[i] > a[i+1]) { + return false + } + default: + panic("s contain not only I and D") + } + } + return true +} + +func Test_diStringMatch(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + a := diStringMatch(tc.S) + ast.True(isCorrect(tc.S, a)) + } +} + +func Benchmark_diStringMatch(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + diStringMatch(tc.S) + } + } +} diff --git a/Algorithms/0943.find-the-shortest-superstring/README.md b/Algorithms/0943.find-the-shortest-superstring/README.md new file mode 100755 index 000000000..209509929 --- /dev/null +++ b/Algorithms/0943.find-the-shortest-superstring/README.md @@ -0,0 +1,25 @@ +# [943. Find the Shortest Superstring](https://leetcode.com/problems/find-the-shortest-superstring/) + +Given an array A of strings, find any smallest string that contains each string in A as a substring. + +We may assume that no string in A is substring of another string in A. + +Example 1: + +```text +Input: ["alex","loves","leetcode"] +Output: "alexlovesleetcode" +Explanation: All permutations of "alex","loves","leetcode" would also be accepted. +``` + +Example 2: + +```text +Input: ["catg","ctaagt","gcta","ttca","atgcatc"] +Output: "gctaagttcatgcatc" +``` + +Note: + +1. 1 <= A.length <= 12 +1. 1 <= A[i].length <= 20 diff --git a/Algorithms/0943.find-the-shortest-superstring/find-the-shortest-superstring.go b/Algorithms/0943.find-the-shortest-superstring/find-the-shortest-superstring.go new file mode 100755 index 000000000..3846afb0f --- /dev/null +++ b/Algorithms/0943.find-the-shortest-superstring/find-the-shortest-superstring.go @@ -0,0 +1,101 @@ +package problem0943 + +import ( + "strings" +) + +func shortestSuperstring(A []string) string { + size := len(A) + indexs := make([]int, 0, size) + isUsed := make([]bool, size) + suffixes := getSuffixes(A) + res := make([]int, size) + minLen := 241 // > 12*20 + for i := 0; i < size; i++ { + isUsed[i] = true + greedy(len(A[i]), &minLen, append(indexs, i), res, A, isUsed, suffixes) + isUsed[i] = false + } + return connect(A, res, suffixes) +} + +// indexs 按顺序记录了 super string 中单词的 index +// length 记录了 super string 的长度 +// 传入 suffixes 是为了避免重复多次计算两个单词之间的重叠关系 +func greedy(length int, minLen *int, indexs, res []int, A []string, isUsed []bool, suffixes [][]int) { + if len(indexs) == len(A) { + if *minLen > length { + *minLen = length + copy(res, indexs) + } + return + } + + tail := indexs[len(indexs)-1] + // get max suffix length of UNUSED string + maxLen := -1 + lens := suffixes[tail] + for i, sl := range lens { + if maxLen >= sl || isUsed[i] { + continue + } + maxLen = sl + } + + // only connect string with max suffix length + for i, sl := range lens { + if sl < maxLen || isUsed[i] { + continue + } + isUsed[i] = true + greedy(length+len(A[i])-maxLen, minLen, append(indexs, i), res, A, isUsed, suffixes) + isUsed[i] = false + } +} + +// res[i][j] == 3 means A[j][:3] is A[i]'s suffix +func getSuffixes(A []string) [][]int { + size := len(A) + res := make([][]int, size) + for i := 0; i < size; i++ { + res[i] = make([]int, size) + for j := 0; j < size; j++ { + if i == j { + continue + } + res[i][j] = suffix(A[i], A[j]) + } + } + return res +} + +func suffix(a, b string) int { + // none is substring of another, so can -1 + i := min(len(a), len(b)) - 1 + for !strings.HasSuffix(a, b[:i]) { + i-- + } + return i +} + +func connect(A []string, indexs []int, suffixes [][]int) string { + size := len(A) + var sb strings.Builder + sb.Grow(240) + i := indexs[0] + sb.WriteString(A[i]) + for k := 1; k < size; k++ { + j := indexs[k] + s := suffixes[i][j] + sb.WriteString(A[j][s:]) + i = j + } + return sb.String() +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0943.find-the-shortest-superstring/find-the-shortest-superstring_test.go b/Algorithms/0943.find-the-shortest-superstring/find-the-shortest-superstring_test.go new file mode 100755 index 000000000..a130d02fc --- /dev/null +++ b/Algorithms/0943.find-the-shortest-superstring/find-the-shortest-superstring_test.go @@ -0,0 +1,71 @@ +package problem0943 + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []string + expected string +}{ + + { + []string{"fgbabcde", "abcdefgb", "bcdei"}, + "abcdefgbabcdei", + }, + + { + []string{"cedefifgstkyxfcuajfa", "ooncedefifgstkyxfcua", "assqjfwarvjcjedqtoz", "fcuajfassqjfwarvjc", "fwarvjcjedqtozctcd", "zppedxfumcfsngp", "kyxfcuajfassqjfwa", "fumcfsngphjyfhhwkqa", "fassqjfwarvjcjedq", "ppedxfumcfsngphjyf", "dqtozctcdk"}, + "ooncedefifgstkyxfcuajfassqjfwarvjcjedqtozctcdkzppedxfumcfsngphjyfhhwkqa", + }, + { + []string{"alex", "loves", "leetcode"}, + "alexlovesleetcode", + }, + + { + []string{"catg", "ctaagt", "gcta", "ttca", "atgcatc"}, + "gctaagttcatgcatc", + }, + + // 可以有多个 testcase +} + +func isCorrect(A []string, expected, actual string) bool { + if expected == actual { + return true + } + + if len(expected) != len(actual) { + return false + } + + for _, sub := range A { + if !strings.Contains(actual, sub) { + return false + } + } + + return true +} + +func Test_shortestSuperstring(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + actual := shortestSuperstring(tc.A) + ast.True(isCorrect(tc.A, tc.expected, actual), "输入:%v", tc) + } +} + +func Benchmark_shortestSuperstring(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shortestSuperstring(tc.A) + } + } +} diff --git a/Algorithms/0944.delete-columns-to-make-sorted/README.md b/Algorithms/0944.delete-columns-to-make-sorted/README.md new file mode 100755 index 000000000..f23eb8e17 --- /dev/null +++ b/Algorithms/0944.delete-columns-to-make-sorted/README.md @@ -0,0 +1,42 @@ +# [944. Delete Columns to Make Sorted](https://leetcode.com/problems/delete-columns-to-make-sorted/) + +We are given an array `A` of `N` lowercase letter strings, all of the same length. + +Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. + +For example, if we have an array `A = ["abcdef","uvwxyz"]` and deletion indices `{0, 2, 3}`, then the final array after deletions is `["bef", "vyz"]`, and the remaining columns of A are `["b","v"]`, `["e","y"]`, and `["f","z"]`. (Formally, the c-th column is `[A[0][c], A[1][c], ..., A[A.length-1][c]]`.) + +Suppose we chose a set of deletion indices `D` such that after deletions, each remaining column in A is in **non-decreasing** sorted order. + +Return the minimum possible value of `D.length`. + +Example 1: + +```text +Input: ["cba","daf","ghi"] +Output: 1 +Explanation: +After choosing D = {1}, each column ["c","d","g"] and ["a","f","i"] are in non-decreasing sorted order. +If we chose D = {}, then a column ["b","a","h"] would not be in non-decreasing sorted order. +``` + +Example 2: + +```text +Input: ["a","b"] +Output: 0 +Explanation: D = {} +``` + +Example 3: + +```text +Input: ["zyx","wvu","tsr"] +Output: 3 +Explanation: D = {0, 1, 2} +``` + +Note: + +- `1 <= A.length <= 100` +- `1 <= A[i].length <= 1000` \ No newline at end of file diff --git a/Algorithms/0944.delete-columns-to-make-sorted/delete-columns-to-make-sorted.go b/Algorithms/0944.delete-columns-to-make-sorted/delete-columns-to-make-sorted.go new file mode 100755 index 000000000..36446c124 --- /dev/null +++ b/Algorithms/0944.delete-columns-to-make-sorted/delete-columns-to-make-sorted.go @@ -0,0 +1,15 @@ +package problem0944 + +func minDeletionSize(A []string) int { + m, n := len(A), len(A[0]) + res := 0 + for j := 0; j < n; j++ { + for i := 1; i < m; i++ { + if A[i-1][j] > A[i][j] { + res++ + break + } + } + } + return res +} diff --git a/Algorithms/0944.delete-columns-to-make-sorted/delete-columns-to-make-sorted_test.go b/Algorithms/0944.delete-columns-to-make-sorted/delete-columns-to-make-sorted_test.go new file mode 100755 index 000000000..bbed8b950 --- /dev/null +++ b/Algorithms/0944.delete-columns-to-make-sorted/delete-columns-to-make-sorted_test.go @@ -0,0 +1,47 @@ +package problem0944 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []string + ans int +}{ + + { + []string{"cba", "daf", "ghi"}, + 1, + }, + + { + []string{"a", "b"}, + 0, + }, + + { + []string{"zyx", "wvu", "tsr"}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_minDeletionSize(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minDeletionSize(tc.A), "输入:%v", tc) + } +} + +func Benchmark_minDeletionSize(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minDeletionSize(tc.A) + } + } +} diff --git a/Algorithms/0945.minimum-increment-to-make-array-unique/README.md b/Algorithms/0945.minimum-increment-to-make-array-unique/README.md new file mode 100755 index 000000000..00b829819 --- /dev/null +++ b/Algorithms/0945.minimum-increment-to-make-array-unique/README.md @@ -0,0 +1,27 @@ +# [945. Minimum Increment to Make Array Unique](https://leetcode.com/problems/minimum-increment-to-make-array-unique/) + +Given an array of integers A, a move consists of choosing any A[i], and incrementing it by 1. + +Return the least number of moves to make every value in A unique. + +Example 1: + +```text +Input: [1,2,2] +Output: 1 +Explanation: After 1 move, the array could be [1, 2, 3]. +``` + +Example 2: + +```text +Input: [3,2,1,2,1,7] +Output: 6 +Explanation: After 6 moves, the array could be [3, 4, 1, 2, 5, 7]. +It can be shown with 5 or less moves that it is impossible for the array to have all unique values. +``` + +Note: + +1. 0 <= A.length <= 40000 +1. 0 <= A[i] < 40000 diff --git a/Algorithms/0945.minimum-increment-to-make-array-unique/minimum-increment-to-make-array-unique.go b/Algorithms/0945.minimum-increment-to-make-array-unique/minimum-increment-to-make-array-unique.go new file mode 100755 index 000000000..55d794ea1 --- /dev/null +++ b/Algorithms/0945.minimum-increment-to-make-array-unique/minimum-increment-to-make-array-unique.go @@ -0,0 +1,30 @@ +package problem0945 + +func minIncrementForUnique(A []int) int { + counts := [40001]int{} + max := 0 + + for _, n := range A { + counts[n]++ + if max < n { + max = n + } + } + + res := 0 + + for n := 0; n < max; n++ { + if counts[n] <= 1 { // no redundance + continue + } + redundance := counts[n] - 1 + // move all redundance to n+1 + res += redundance + counts[n+1] += redundance + } + + redundance := counts[max] - 1 + res += (redundance + 1) * redundance / 2 + + return res +} diff --git a/Algorithms/0945.minimum-increment-to-make-array-unique/minimum-increment-to-make-array-unique_test.go b/Algorithms/0945.minimum-increment-to-make-array-unique/minimum-increment-to-make-array-unique_test.go new file mode 100755 index 000000000..d15a1f079 --- /dev/null +++ b/Algorithms/0945.minimum-increment-to-make-array-unique/minimum-increment-to-make-array-unique_test.go @@ -0,0 +1,47 @@ +package problem0945 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{}, + 0, + }, + + { + []int{1, 2, 2}, + 1, + }, + + { + []int{3, 2, 1, 2, 1, 7}, + 6, + }, + + // 可以有多个 testcase +} + +func Test_minIncrementForUnique(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minIncrementForUnique(tc.A), "输入:%v", tc) + } +} + +func Benchmark_minIncrementForUnique(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minIncrementForUnique(tc.A) + } + } +} diff --git a/Algorithms/0946.validate-stack-sequences/README.md b/Algorithms/0946.validate-stack-sequences/README.md new file mode 100755 index 000000000..9a1c99331 --- /dev/null +++ b/Algorithms/0946.validate-stack-sequences/README.md @@ -0,0 +1,28 @@ +# [946. Validate Stack Sequences](https://leetcode.com/problems/validate-stack-sequences/) + +Given two sequences pushed and popped with distinct values, return true if and only if this could have been the result of a sequence of push and pop operations on an initially empty stack. + +Example 1: + +```text +Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1] +Output: true +Explanation: We might do the following sequence: +push(1), push(2), push(3), push(4), pop() -> 4, +push(5), pop() -> 5, pop() -> 3, pop() -> 2, pop() -> 1 +``` + +Example 2: + +```text +Input: pushed = [1,2,3,4,5], popped = [4,3,5,1,2] +Output: false +Explanation: 1 cannot be popped before 2. +``` + +Note: + +1. 0 <= pushed.length == popped.length <= 1000 +1. 0 <= pushed[i], popped[i] < 1000 +1. pushed is a permutation of popped. +1. pushed and popped have distinct values. \ No newline at end of file diff --git a/Algorithms/0946.validate-stack-sequences/validate-stack-sequences.go b/Algorithms/0946.validate-stack-sequences/validate-stack-sequences.go new file mode 100755 index 000000000..1f48d44bb --- /dev/null +++ b/Algorithms/0946.validate-stack-sequences/validate-stack-sequences.go @@ -0,0 +1,23 @@ +package problem0946 + +func validateStackSequences(pushed, popped []int) bool { + size := len(pushed) + + stack := make([]int, size) + top := -1 + + for in, out := 0, 0; in < size; in++ { + if pushed[in] != popped[out] { + top++ + stack[top] = pushed[in] + } else { + out++ + for top >= 0 && stack[top] == popped[out] { + top-- + out++ + } + } + } + + return top == -1 +} diff --git a/Algorithms/0946.validate-stack-sequences/validate-stack-sequences_test.go b/Algorithms/0946.validate-stack-sequences/validate-stack-sequences_test.go new file mode 100755 index 000000000..86c8ad9f8 --- /dev/null +++ b/Algorithms/0946.validate-stack-sequences/validate-stack-sequences_test.go @@ -0,0 +1,51 @@ +package problem0946 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + pushed []int + popped []int + ans bool +}{ + + { + []int{0, 2, 1}, + []int{0, 1, 2}, + true, + }, + + { + []int{1, 2, 3, 4, 5}, + []int{4, 5, 3, 2, 1}, + true, + }, + + { + []int{1, 2, 3, 4, 5}, + []int{4, 3, 5, 1, 2}, + false, + }, + + // 可以有多个 testcase +} + +func Test_validateStackSequences(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, validateStackSequences(tc.pushed, tc.popped), "输入:%v", tc) + } +} + +func Benchmark_validateStackSequences(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + validateStackSequences(tc.pushed, tc.popped) + } + } +} diff --git a/Algorithms/0947.most-stones-removed-with-same-row-or-column/README.md b/Algorithms/0947.most-stones-removed-with-same-row-or-column/README.md new file mode 100755 index 000000000..19de12457 --- /dev/null +++ b/Algorithms/0947.most-stones-removed-with-same-row-or-column/README.md @@ -0,0 +1,33 @@ +# [947. Most Stones Removed with Same Row or Column](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/) + +On a 2D plane, we place stones at some integer coordinate points. Each coordinate point may have at most one stone. + +Now, a move consists of removing a stone that shares a column or row with another stone on the grid. + +What is the largest possible number of moves we can make? + +Example 1: + +```text +Input: stones = [[0,0],[0,1],[1,0],[1,2],[2,1],[2,2]] +Output: 5 +``` + +Example 2: + +```text +Input: stones = [[0,0],[0,2],[1,1],[2,0],[2,2]] +Output: 3 +``` + +Example 3: + +```text +Input: stones = [[0,0]] +Output: 0 +``` + +Note: + +1. 1 <= stones.length <= 1000 +1. 0 <= stones[i][j] < 10000 diff --git a/Algorithms/0947.most-stones-removed-with-same-row-or-column/most-stones-removed-with-same-row-or-column.go b/Algorithms/0947.most-stones-removed-with-same-row-or-column/most-stones-removed-with-same-row-or-column.go new file mode 100755 index 000000000..b8f4549c4 --- /dev/null +++ b/Algorithms/0947.most-stones-removed-with-same-row-or-column/most-stones-removed-with-same-row-or-column.go @@ -0,0 +1,48 @@ +package problem0947 + +// 如果把相同行或者列上的点,看作是联通的 +// 那么本题的本质就是,每个联通区域只保留一个点,则可以删除多少个点 + +func removeStones(stones [][]int) int { + u := newUnion(20000) + for _, s := range stones { + // 把一个点的 x 和 y 坐标进行连通,可以把复杂度从 O^2 降低到 O + // 当为了避免坐标轴的重叠,需要把每个 y 坐标的值 +10000 + u.union(s[0], s[1]+10000) + } + + keeps := make(map[int]int, 1000) + for _, s := range stones { + root := u.find(s[0]) + keeps[root]++ + } + + return len(stones) - len(keeps) +} + +type union struct { + parent []int +} + +func newUnion(size int) *union { + parent := make([]int, size) + for i := range parent { + parent[i] = i + } + return &union{ + parent: parent, + } +} + +func (u *union) find(i int) int { + if u.parent[i] == i { + return i + } + u.parent[i] = u.find(u.parent[i]) + return u.parent[i] +} + +func (u *union) union(x, y int) { + xp, yp := u.find(x), u.find(y) + u.parent[yp] = xp +} diff --git a/Algorithms/0947.most-stones-removed-with-same-row-or-column/most-stones-removed-with-same-row-or-column_test.go b/Algorithms/0947.most-stones-removed-with-same-row-or-column/most-stones-removed-with-same-row-or-column_test.go new file mode 100755 index 000000000..7b8925435 --- /dev/null +++ b/Algorithms/0947.most-stones-removed-with-same-row-or-column/most-stones-removed-with-same-row-or-column_test.go @@ -0,0 +1,53 @@ +package problem0947 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + stones [][]int + ans int +}{ + { + [][]int{{0, 1}, {1, 0}, {1, 1}}, + 2, + }, + + {[][]int{{0, 0}, {0, 1}, {1, 0}, {1, 2}, {2, 1}, {2, 2}}, + 5, + }, + + {[][]int{{0, 0}, {0, 2}, {1, 1}, {2, 0}, {2, 2}}, + 3, + }, + + {[][]int{{0, 0}}, + 0, + }, + + { + [][]int{{279, 2814}, {2343, 975}, {2680, 1479}, {1922, 451}, {1538, 2188}, {2180, 1620}, {2452, 1425}, {1626, 1625}, {2697, 1281}, {1450, 339}, {1252, 219}, {2256, 1772}, {150, 1442}, {691, 2958}, {2477, 1565}, {1730, 1884}, {1077, 291}, {641, 1267}, {1196, 1419}, {2590, 2078}, {1285, 2006}, {2608, 2610}, {173, 438}, {191, 2537}, {1240, 1797}, {1681, 2174}, {1145, 1306}, {2623, 2705}, {421, 538}, {2114, 428}, {1270, 2004}, {2091, 2376}, {754, 2827}, {2816, 1698}, {2606, 1299}, {1881, 1299}, {1511, 420}, {2929, 44}, {1945, 258}, {2700, 2455}, {36, 1556}, {1049, 1545}, {1242, 1486}, {893, 2322}, {2117, 2955}, {269, 1299}, {497, 2145}, {2495, 1110}, {2851, 1273}, {1221, 864}, {16, 1491}, {403, 2549}, {2125, 1281}, {160, 2062}, {2887, 141}, {2583, 2216}, {2247, 754}, {504, 1141}, {2372, 2404}, {1711, 1047}, {751, 2211}, {1232, 244}, {2309, 961}, {2943, 488}, {822, 1485}, {1273, 0}, {2306, 2209}, {2223, 712}, {2596, 86}, {2245, 128}, {2567, 727}, {2526, 2479}, {44, 2623}, {968, 735}, {1256, 1831}, {234, 1302}, {2181, 586}, {2365, 1033}, {529, 2910}, {822, 777}, {131, 489}, {729, 2030}, {1621, 299}, {932, 1589}, {1589, 1649}, {498, 1813}, {1218, 366}, {2309, 2754}, {2709, 2553}, {1671, 795}, {2851, 700}, {1944, 1143}, {2430, 2714}, {2283, 1291}, {2730, 838}, {257, 146}, {2862, 1167}, {2093, 2561}, {1379, 2025}, {901, 1019}, {2261, 2414}, {1597, 2796}, {1221, 2543}, {2688, 2399}, {1927, 363}, {113, 720}, {241, 411}, {2507, 668}, {1984, 2278}, {409, 1460}, {2916, 2547}, {1576, 2495}, {737, 1125}, {2566, 1241}, {2040, 344}, {2600, 2363}, {2798, 1218}, {1424, 2763}, {2180, 1459}, {2532, 2072}, {2493, 2318}, {595, 1889}, {1860, 353}, {2880, 1402}, {1191, 2453}, {1488, 392}, {777, 1609}, {1879, 180}, {2189, 2377}, {458, 1878}, {2350, 1404}, {1936, 779}, {615, 512}, {1562, 2045}, {1052, 2307}, {1024, 520}, {894, 1624}, {1733, 773}, {1807, 222}, {914, 563}, {2719, 448}, {1059, 520}, {340, 742}, {1951, 2170}, {2066, 2825}, {104, 604}, {2836, 1969}, {1676, 2523}, {961, 1456}, {1390, 647}, {2703, 2911}, {955, 2698}, {849, 183}, {1376, 2044}, {740, 2163}, {2577, 2983}, {688, 1846}, {328, 753}, {1177, 2262}, {1149, 1682}, {1837, 90}, {313, 2584}, {880, 1181}, {351, 2241}, {298, 2527}, {2260, 1626}, {2185, 1390}, {1019, 1915}, {2213, 600}, {2840, 1166}, {22, 722}, {2435, 2438}, {1829, 1793}, {1190, 1733}, {986, 815}, {1467, 2135}, {2255, 2238}, {826, 1067}, {1807, 1723}, {1355, 345}, {728, 184}, {2908, 174}, {312, 73}, {2878, 1597}, {1881, 14}, {306, 2664}, {2944, 3}, {2063, 2607}, {2403, 1494}, {1797, 549}, {2691, 2615}, {2118, 1281}, {1214, 1329}, {1655, 885}, {2973, 2797}, {365, 968}, {777, 1458}, {2922, 1403}, {1444, 2366}, {1573, 2718}, {1979, 1655}, {1869, 1847}, {184, 1298}, {1357, 1123}, {1744, 2903}, {2892, 2386}, {2798, 193}, {2126, 706}, {718, 2582}, {215, 220}, {2428, 1921}, {321, 1705}, {852, 2383}, {293, 771}, {1294, 933}, {961, 1037}, {2892, 2951}, {1026, 875}, {1642, 155}, {349, 824}, {2910, 2343}, {780, 726}, {1861, 2576}, {1456, 227}, {1961, 2710}, {2035, 2853}, {2179, 902}, {2295, 1126}, {62, 1761}, {378, 1722}, {2254, 505}, {203, 2621}, {209, 2429}, {2226, 2085}, {1412, 827}, {790, 755}, {2375, 893}, {968, 1049}, {457, 1696}, {2999, 244}, {1164, 2494}, {2850, 132}, {1556, 304}, {2104, 1394}, {2276, 2504}, {1856, 1838}, {1677, 893}, {221, 2677}, {2784, 2818}, {779, 1153}, {2962, 1161}, {2489, 85}, {37, 279}, {1033, 870}, {1502, 2978}, {1495, 1391}, {2700, 2851}, {45, 46}, {1335, 2155}, {2859, 296}, {2380, 447}, {1957, 328}, {562, 2135}, {2070, 1078}, {233, 48}, {407, 2666}, {1981, 564}, {250, 485}, {857, 2496}, {2194, 73}, {765, 261}, {2045, 1768}, {773, 1612}, {2728, 2325}, {1830, 640}, {2618, 1253}, {1392, 1088}, {2258, 1000}, {2738, 478}, {1735, 2406}, {600, 1774}, {1682, 1222}, {161, 2918}, {1887, 599}, {1498, 2535}, {1213, 612}, {2915, 795}, {2845, 976}, {424, 260}, {1075, 639}, {264, 2945}, {855, 715}, {1130, 2745}, {2562, 1625}, {763, 360}, {1724, 1043}, {2813, 1930}, {384, 2363}, {197, 275}, {914, 2153}, {809, 2885}, {143, 2347}, {659, 2872}, {2855, 2995}, {2686, 2122}, {623, 1043}, {2263, 2172}, {2634, 2672}, {990, 1897}, {1628, 672}, {863, 1034}, {1216, 129}, {1268, 2810}, {1858, 2332}, {2061, 632}, {1851, 2069}, {696, 1381}, {659, 859}, {2299, 322}, {2109, 989}, {65, 763}, {1873, 515}, {2954, 1859}, {544, 887}, {691, 1224}, {927, 968}, {433, 1468}, {2781, 1977}, {1435, 2594}, {275, 2802}, {523, 324}, {1266, 2146}, {10, 1139}, {1708, 121}, {2367, 2481}, {2663, 862}, {1068, 2308}, {2861, 2962}, {637, 1667}, {632, 2781}, {2685, 2013}, {1268, 1591}, {678, 1511}, {2365, 2337}, {1903, 2032}, {913, 275}, {710, 1831}, {719, 338}, {2089, 655}, {2179, 2849}, {2292, 2253}, {765, 1246}, {961, 926}, {1309, 1459}, {1856, 2023}, {601, 1582}, {156, 2969}, {1504, 1473}, {244, 2074}, {1472, 1647}, {445, 1769}, {1815, 2070}, {2084, 1787}, {1205, 2895}, {151, 1647}, {340, 368}, {2664, 2296}, {280, 667}, {49, 1935}, {1578, 2696}, {526, 2172}, {487, 673}, {2054, 1884}, {2236, 1559}, {823, 2519}, {861, 1870}, {2032, 1947}, {390, 450}, {654, 803}, {1985, 1291}, {336, 368}, {1124, 2793}, {968, 117}, {943, 2655}, {606, 1483}, {1126, 130}, {2155, 1903}, {2614, 874}, {1493, 1090}, {1699, 907}, {359, 1374}, {1104, 1391}, {2701, 2259}, {2242, 1176}, {2238, 569}, {492, 1431}, {232, 110}, {14, 1962}, {403, 113}, {1451, 2821}, {912, 2753}, {1160, 1590}, {576, 2686}, {2497, 2859}, {1217, 1186}, {2321, 1629}, {2024, 169}, {651, 1429}, {935, 2049}, {2980, 2642}, {2802, 1412}, {1946, 1963}, {1305, 801}, {2952, 1858}, {457, 276}, {2806, 667}, {1011, 2407}, {2861, 1668}, {190, 2286}, {1267, 2597}, {923, 369}, {698, 691}, {1398, 84}, {1174, 90}, {1540, 2547}, {370, 1549}, {2983, 114}, {1160, 1962}, {772, 1517}, {1230, 1953}, {2337, 1546}, {2122, 2784}, {1477, 2012}, {1991, 2178}, {1370, 2680}, {2207, 1009}, {588, 1200}, {1700, 139}, {1884, 1720}, {75, 2688}, {2171, 327}, {1038, 929}, {584, 1958}, {2458, 2163}, {1468, 2194}, {2348, 1135}, {557, 1244}, {2608, 1495}, {1754, 2722}, {2776, 2969}, {2699, 1236}, {225, 777}, {821, 397}, {271, 1004}, {540, 555}, {1590, 1583}, {557, 2920}, {1217, 1053}, {755, 2122}, {2758, 47}, {2868, 1563}, {1986, 2891}, {833, 369}, {2779, 1709}, {1132, 685}, {318, 2527}, {1461, 1803}, {1088, 1481}, {1694, 7}, {2805, 2829}, {2620, 2654}, {1355, 1701}, {1109, 414}, {766, 221}, {2617, 916}, {2155, 693}, {2918, 18}, {2830, 2616}, {1266, 346}, {2774, 2537}, {937, 126}, {1550, 864}, {2429, 2628}, {1048, 1460}, {1170, 2752}, {1484, 372}, {149, 571}, {983, 1184}, {2240, 2570}, {199, 625}, {2014, 975}, {1215, 730}, {1233, 2562}, {1589, 457}, {2392, 1592}, {2925, 882}, {25, 2940}, {261, 836}, {1806, 842}, {1828, 262}, {1776, 445}, {1047, 98}, {1196, 1624}, {1316, 2965}, {455, 1315}, {2324, 727}, {761, 1444}, {500, 852}, {1646, 2747}, {2339, 1074}, {919, 2837}, {2993, 1869}, {202, 2774}, {2857, 2298}, {1759, 605}, {1408, 1722}, {936, 1143}, {540, 1385}, {2770, 2769}, {2281, 1136}, {1672, 1138}, {2862, 1692}, {2729, 2369}, {643, 1205}, {911, 144}, {288, 618}, {2666, 2239}, {1589, 2969}, {2110, 655}, {2522, 2775}, {1227, 604}, {979, 2606}, {2797, 2395}, {2053, 1465}, {1765, 2688}, {2349, 62}, {866, 1912}, {2670, 2018}, {691, 683}, {2358, 308}, {1162, 2660}, {170, 2666}, {1641, 376}, {1696, 1367}, {231, 384}, {2915, 875}, {2675, 2499}, {212, 2735}, {1879, 1008}, {2958, 2053}, {544, 212}, {605, 2281}, {1390, 2014}, {1559, 1218}, {1194, 2222}, {1533, 1881}, {1863, 1736}, {2746, 473}, {2129, 481}, {2340, 1229}, {1394, 1040}, {1736, 2567}, {2442, 489}, {2388, 1453}, {226, 2027}, {1512, 1514}, {812, 2057}, {526, 992}, {1935, 1527}, {1167, 793}, {2236, 1763}, {740, 1623}, {619, 1777}, {2118, 763}, {2123, 19}, {2026, 32}, {1211, 697}, {73, 916}, {2847, 2372}, {559, 1180}, {2244, 1271}, {1632, 2730}, {1859, 2109}, {2701, 2367}, {2978, 1360}, {288, 1940}, {792, 356}, {1530, 936}, {891, 254}, {2943, 57}, {177, 1168}, {2095, 1910}, {1268, 2508}, {95, 23}, {2275, 838}, {1754, 1002}, {1634, 2616}, {69, 2285}, {1538, 1309}, {1135, 1559}, {2356, 1315}, {2568, 1483}, {2311, 2669}, {174, 943}, {669, 2851}, {1976, 2820}, {2526, 2874}, {656, 2117}, {227, 547}, {945, 508}, {2731, 355}, {443, 11}, {928, 1193}, {911, 1104}, {1760, 1363}, {897, 2599}, {810, 768}, {1911, 2502}, {1712, 2744}, {449, 1172}, {1189, 772}, {2195, 956}, {2938, 438}, {810, 915}, {2377, 2410}, {1437, 766}, {1804, 2212}, {2880, 1635}, {741, 2082}, {2180, 1998}, {635, 1480}, {2709, 909}, {1145, 2743}, {761, 2922}, {2117, 2770}, {477, 1934}, {838, 2609}, {1531, 1891}, {2553, 1820}, {2819, 463}, {1727, 637}, {1401, 1363}, {2652, 1603}, {942, 1435}, {1891, 2820}, {759, 274}, {796, 280}, {580, 1767}, {2929, 1671}, {1072, 2595}, {1952, 583}, {1346, 1962}, {2687, 2356}, {928, 2499}, {2427, 1071}, {1928, 447}, {2967, 1539}, {1901, 2602}, {2233, 1015}, {1104, 166}, {2696, 1837}, {2573, 2289}, {408, 881}, {1574, 1855}, {88, 25}, {1655, 160}, {2745, 2089}, {2155, 903}, {360, 1453}, {2967, 906}, {20, 1333}, {1765, 2285}, {2126, 1236}, {2466, 345}, {1427, 1245}, {1106, 1636}, {2459, 689}, {242, 566}, {2776, 1650}, {2890, 1202}, {1985, 2269}, {2563, 2833}, {2261, 1715}, {559, 2412}, {1371, 1338}, {1686, 708}, {1808, 29}, {944, 1019}, {852, 1661}, {2098, 2032}, {1787, 867}, {2477, 608}, {2098, 279}, {400, 1405}, {2170, 1705}, {1135, 836}, {870, 2092}, {1339, 2071}, {919, 1279}, {1704, 1879}, {686, 2482}, {1500, 701}, {239, 2148}, {2324, 2179}, {2560, 1501}, {117, 2421}, {298, 2481}, {2664, 769}, {752, 608}, {2647, 2313}, {1490, 734}, {48, 2751}, {1806, 1921}, {2756, 315}, {2105, 2459}, {1062, 813}, {364, 2856}, {2689, 407}, {1187, 2580}, {2023, 2663}, {682, 2132}, {1280, 2985}, {2356, 1307}, {1602, 48}, {173, 452}, {2337, 942}, {1106, 1318}, {597, 813}, {1446, 1973}, {2846, 904}, {730, 2033}, {950, 1240}, {620, 2804}, {395, 5}, {1212, 1391}, {1581, 2961}, {1317, 1943}, {2930, 1003}, {805, 707}, {277, 1946}, {775, 1007}, {2654, 2254}, {2885, 1105}, {1154, 20}, {578, 2710}, {2114, 2627}, {80, 1711}, {1320, 1423}, {1728, 288}, {1220, 388}, {2377, 2076}, {817, 415}, {797, 2945}, {1653, 874}, {1882, 352}, {632, 2710}, {1091, 369}, {1162, 1609}, {162, 688}, {1231, 1717}, {838, 1097}, {1270, 1538}, {1313, 2652}, {530, 2265}, {1408, 979}, {301, 1822}, {2754, 2531}, {904, 161}, {1201, 957}, {747, 1066}, {2248, 2394}, {2501, 420}, {2215, 762}, {2665, 2095}, {1311, 351}, {2478, 2880}, {708, 2645}, {24, 2614}, {1625, 828}, {1992, 717}, {889, 1540}, {241, 1249}, {971, 2074}, {550, 2130}, {2633, 1640}, {2726, 575}, {1962, 783}, {2649, 514}, {21, 1745}, {2892, 1890}, {2638, 330}, {1344, 2413}, {210, 2941}, {2819, 2809}, {2241, 2336}, {1592, 606}, {2706, 365}, {1046, 91}, {2342, 2389}, {224, 844}, {1159, 873}, {1584, 1361}, {2224, 1195}, {101, 235}, {2009, 1089}, {1812, 740}, {1002, 905}, {759, 2527}, {1879, 1692}, {1476, 145}, {791, 2624}, {992, 1226}, {1864, 1862}, {481, 843}, {2830, 609}, {2520, 2309}, {2716, 1251}, {867, 2325}, {1507, 296}, {1423, 1874}, {2869, 1931}, {1684, 978}, {2216, 633}, {381, 2781}, {2238, 1070}, {1048, 1743}, {2931, 239}, {960, 2239}, {2803, 2197}, {1065, 288}, {1263, 1613}, {1052, 2334}, {2594, 1928}, {1880, 731}, {919, 253}, {458, 2380}, {2995, 1935}, {1614, 1696}, {899, 113}, {2489, 2550}, {159, 1582}, {1597, 1843}, {2008, 459}, {2270, 1032}, {1522, 2951}, {1201, 2104}, {1626, 1259}, {943, 668}, {756, 2739}, {1954, 1445}, {1079, 1969}, {614, 1664}, {1437, 555}, {1169, 1237}, {1356, 701}, {2253, 1280}, {42, 703}, {36, 2410}, {887, 1361}, {1027, 2880}, {2835, 986}, {503, 1576}, {2059, 1524}, {1868, 1080}, {1371, 1693}, {2330, 2421}, {829, 1225}, {2836, 1127}, {2473, 1387}, {1431, 1792}, {1551, 1696}, {1354, 2738}, {2304, 1674}, {1707, 1536}, {382, 1494}, {99, 220}, {2832, 271}, {682, 1275}, {840, 1210}, {5, 2820}, {1615, 1184}, {959, 905}, {2853, 1400}, {863, 1659}, {50, 2878}, {1065, 2297}, {2818, 1648}, {2791, 2965}, {1049, 2712}, {1101, 1148}, {2140, 1633}, {1799, 1963}, {1361, 2671}, {2832, 1739}, {2468, 1363}, {2129, 2101}, {1631, 249}, {2953, 58}, {2888, 1897}, {504, 1586}, {2671, 318}, {160, 1234}, {245, 2858}, {227, 1050}, {180, 2340}, {980, 2320}, {1897, 2317}, {2735, 2166}, {2559, 2298}, {1767, 1904}, {1769, 2460}, {2953, 357}, {2548, 1841}, {1925, 2654}, {2888, 1166}, {814, 2826}, {1434, 2871}, {1949, 2558}, {1726, 2570}, {373, 1322}, {181, 108}, {79, 241}, {18, 1876}, {654, 512}, {2648, 105}, {1289, 1325}, {2679, 692}, {2139, 1187}, {1942, 629}, {1434, 788}, {2963, 2768}, {645, 2388}, {2841, 2644}, {693, 1025}, {89, 2428}, {2202, 893}, {2286, 2523}, {1492, 2991}, {1090, 59}, {806, 2384}, {1681, 644}, {156, 785}, {13, 184}, {775, 2648}, {353, 2961}, {2440, 596}, {1297, 2608}, {1829, 358}, {2893, 2372}, {2322, 1979}, {592, 1953}, {2543, 267}, {827, 970}, {1926, 2840}, {1041, 400}, {1098, 323}, {1281, 1141}, {40, 1635}, {588, 609}, {1067, 2920}, {2597, 1293}, {298, 2586}, {1450, 1495}, {1375, 2238}, {97, 459}, {742, 1641}, {2652, 2923}, {2343, 1798}, {796, 1344}, {1103, 2592}, {2314, 1836}, {388, 1371}, {1126, 1731}, {176, 949}, {115, 2420}, {435, 2632}, {2243, 515}, {2689, 1527}, {422, 569}, {406, 1426}, {2039, 2458}, {781, 1278}, {1557, 913}, {969, 1382}, {18, 1942}, {832, 575}, {2952, 2348}, {1162, 2023}, {2508, 651}, {2494, 1182}, {2626, 1962}, {1253, 2288}, {1840, 137}, {1709, 2308}, {121, 1287}, {371, 2745}, {2458, 178}, {1470, 1691}, {1994, 1061}, {288, 2325}}, + 288, + }, + + // 可以有多个 testcase +} + +func Test_removeStones(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, removeStones(tc.stones), "输入:%v", tc) + } +} + +func Benchmark_removeStones(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + removeStones(tc.stones) + } + } +} diff --git a/Algorithms/0948.bag-of-tokens/README.md b/Algorithms/0948.bag-of-tokens/README.md new file mode 100755 index 000000000..142526d88 --- /dev/null +++ b/Algorithms/0948.bag-of-tokens/README.md @@ -0,0 +1,37 @@ +# [948. Bag of Tokens](https://leetcode.com/problems/bag-of-tokens/) + +You have an initial power P, an initial score of 0 points, and a bag of tokens. + +Each token can be used at most once, has a value token[i], and has potentially two ways to use it. + +- If we have at least token[i] power, we may play the token face up, losing token[i] power, and gaining 1 point. +- If we have at least 1 point, we may play the token face down, gaining token[i] power, and losing 1 point. + +Return the largest number of points we can have after playing any number of tokens. + +Example 1: + +```text +Input: tokens = [100], P = 50 +Output: 0 +``` + +Example 2: + +```text +Input: tokens = [100,200], P = 150 +Output: 1 +``` + +Example 3: + +```text +Input: tokens = [100,200,300,400], P = 200 +Output: 2 +``` + +Note: + +1. tokens.length <= 1000 +1. 0 <= tokens[i] < 10000 +1. 0 <= P < 10000 \ No newline at end of file diff --git a/Algorithms/0948.bag-of-tokens/bag-of-tokens.go b/Algorithms/0948.bag-of-tokens/bag-of-tokens.go new file mode 100755 index 000000000..f9efd4113 --- /dev/null +++ b/Algorithms/0948.bag-of-tokens/bag-of-tokens.go @@ -0,0 +1,34 @@ +package problem0948 + +import "sort" + +// ref: https://leetcode.com/problems/bag-of-tokens/discuss/197696/C%2B%2BJavaPython-Greedy-%2B-Two-Pointers + +func bagOfTokensScore(tokens []int, P int) int { + sort.Ints(tokens) + + maxScore, score := 0, 0 + i, j := 0, len(tokens)-1 + + for i <= j { + if P >= tokens[i] { + P -= tokens[i] + score++ + maxScore = score + // 因为 tokens 是升序排列 + // 所以,卖了 tokens[j] 后,肯定应该买得起 tokens[i] + // 除非 i==j,会导致 score-- 后, score 比真正的结果小 1 + // 于是,每次 score++ 后,score 肯定是最大值。 + // 使用 maxScore 记录一下,避免错误的结果。 + i++ + } else if score > 0 { + P += tokens[j] + score-- + j-- + } else { + break + } + } + + return maxScore +} diff --git a/Algorithms/0948.bag-of-tokens/bag-of-tokens_test.go b/Algorithms/0948.bag-of-tokens/bag-of-tokens_test.go new file mode 100755 index 000000000..2f51f8cd4 --- /dev/null +++ b/Algorithms/0948.bag-of-tokens/bag-of-tokens_test.go @@ -0,0 +1,63 @@ +package problem0948 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + tokens []int + P int + ans int +}{ + + { + []int{33, 4, 28, 24, 96}, + 35, + 3, + }, + + { + []int{26}, + 51, + 1, + }, + + { + []int{100, 200, 300, 400}, + 200, + 2, + }, + + { + []int{100}, + 50, + 0, + }, + + { + []int{100, 200}, + 150, + 1, + }, + + // 可以有多个 testcase +} + +func Test_bagOfTokensScore(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, bagOfTokensScore(tc.tokens, tc.P), "输入:%v", tc) + } +} + +func Benchmark_bagOfTokensScore(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + bagOfTokensScore(tc.tokens, tc.P) + } + } +} diff --git a/Algorithms/0949.largest-time-for-given-digits/README.md b/Algorithms/0949.largest-time-for-given-digits/README.md new file mode 100755 index 000000000..4548c1573 --- /dev/null +++ b/Algorithms/0949.largest-time-for-given-digits/README.md @@ -0,0 +1,26 @@ +# [949. Largest Time for Given Digits](https://leetcode.com/problems/largest-time-for-given-digits/) + +Given an array of 4 digits, return the largest 24 hour time that can be made. + +The smallest 24 hour time is 00:00, and the largest is 23:59. Starting from 00:00, a time is larger if more time has elapsed since midnight. + +Return the answer as a string of length 5. If no valid time can be made, return an empty string. + +Example 1: + +```text +Input: [1,2,3,4] +Output: "23:41" +``` + +Example 2: + +```text +Input: [5,5,5,5] +Output: "" +``` + +Note: + +1. A.length == 4 +1. 0 <= A[i] <= 9 diff --git a/Algorithms/0949.largest-time-for-given-digits/largest-time-for-given-digits.go b/Algorithms/0949.largest-time-for-given-digits/largest-time-for-given-digits.go new file mode 100755 index 000000000..aa2cd9a6c --- /dev/null +++ b/Algorithms/0949.largest-time-for-given-digits/largest-time-for-given-digits.go @@ -0,0 +1,47 @@ +package problem0949 + +import "fmt" + +var permutations = [][]int{ + {0, 1, 2, 3}, + {0, 1, 3, 2}, + {0, 2, 1, 3}, + {0, 2, 3, 1}, + {0, 3, 1, 2}, + {0, 3, 2, 1}, + {1, 0, 2, 3}, + {1, 0, 3, 2}, + {1, 2, 0, 3}, + {1, 2, 3, 0}, + {1, 3, 0, 2}, + {1, 3, 2, 0}, + {2, 0, 1, 3}, + {2, 0, 3, 1}, + {2, 1, 0, 3}, + {2, 1, 3, 0}, + {2, 3, 1, 0}, + {2, 3, 0, 1}, + {3, 0, 2, 1}, + {3, 0, 1, 2}, + {3, 1, 0, 2}, + {3, 1, 2, 0}, + {3, 2, 0, 1}, + {3, 2, 1, 0}, +} + +func largestTimeFromDigits(A []int) string { + h, m := -1, -1 + res := "" + for _, p := range permutations { + a, b, c, d := A[p[0]], A[p[1]], A[p[2]], A[p[3]] + ab, cd := a*10+b, c*10+d + if ab > 23 || + cd > 59 || + ab*60+cd <= h*60+m { + continue + } + h, m = ab, cd + res = fmt.Sprintf("%02d:%02d", h, m) + } + return res +} diff --git a/Algorithms/0949.largest-time-for-given-digits/largest-time-for-given-digits_test.go b/Algorithms/0949.largest-time-for-given-digits/largest-time-for-given-digits_test.go new file mode 100755 index 000000000..7b3d39fff --- /dev/null +++ b/Algorithms/0949.largest-time-for-given-digits/largest-time-for-given-digits_test.go @@ -0,0 +1,42 @@ +package problem0949 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans string +}{ + + { + []int{1, 2, 3, 4}, + "23:41", + }, + + { + []int{5, 5, 5, 5}, + "", + }, + + // 可以有多个 testcase +} + +func Test_largestTimeFromDigits(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, largestTimeFromDigits(tc.A), "输入:%v", tc) + } +} + +func Benchmark_largestTimeFromDigits(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + largestTimeFromDigits(tc.A) + } + } +} diff --git a/Algorithms/0950.reveal-cards-in-increasing-order/README.md b/Algorithms/0950.reveal-cards-in-increasing-order/README.md new file mode 100755 index 000000000..be69923ea --- /dev/null +++ b/Algorithms/0950.reveal-cards-in-increasing-order/README.md @@ -0,0 +1,39 @@ +# [950. Reveal Cards In Increasing Order](https://leetcode.com/problems/reveal-cards-in-increasing-order/) + +In a deck of cards, every card has a unique integer. You can order the deck in any order you want. + +Initially, all the cards start face down (unrevealed) in one deck. + +Now, you do the following steps repeatedly, until all cards are revealed: + +1. Take the top card of the deck, reveal it, and take it out of the deck. +1. If there are still cards in the deck, put the next top card of the deck at the bottom of the deck. +1. If there are still unrevealed cards, go back to step 1. Otherwise, stop. + +Return an ordering of the deck that would reveal the cards in increasing order. + +The first entry in the answer is considered to be the top of the deck. + +Example 1: + +```text +Input: [17,13,11,2,3,5,7] +Output: [2,13,3,11,5,17,7] +Explanation: +We get the deck in the order [17,13,11,2,3,5,7] (this order doesn't matter), and reorder it. +After reordering, the deck starts as [2,13,3,11,5,17,7], where 2 is the top of the deck. +We reveal 2, and move 13 to the bottom. The deck is now [3,11,5,17,7,13]. +We reveal 3, and move 11 to the bottom. The deck is now [5,17,7,13,11]. +We reveal 5, and move 17 to the bottom. The deck is now [7,13,11,17]. +We reveal 7, and move 13 to the bottom. The deck is now [11,17,13]. +We reveal 11, and move 17 to the bottom. The deck is now [13,17]. +We reveal 13, and move 17 to the bottom. The deck is now [17]. +We reveal 17. +Since all the cards revealed are in increasing order, the answer is correct. +``` + +Note: + +1. 1 <= A.length <= 1000 +1. 1 <= A[i] <= 10^6 +1. A[i] != A[j] for all i != j \ No newline at end of file diff --git a/Algorithms/0950.reveal-cards-in-increasing-order/reveal-cards-in-increasing-order.go b/Algorithms/0950.reveal-cards-in-increasing-order/reveal-cards-in-increasing-order.go new file mode 100755 index 000000000..6873035ad --- /dev/null +++ b/Algorithms/0950.reveal-cards-in-increasing-order/reveal-cards-in-increasing-order.go @@ -0,0 +1,26 @@ +package problem0950 + +import "sort" + +func deckRevealedIncreasing(deck []int) []int { + sort.Ints(deck) + + size := len(deck) + + t := make([]int, 0, size*2) + b := 0 + + for i := size - 1; i >= 0; i-- { + t = append(t, deck[i]) + if i > 0 { + t = append(t, t[b]) + b++ + } + } + + for i, j := b, len(t)-1; i < j; i, j = i+1, j-1 { + t[i], t[j] = t[j], t[i] + } + + return t[b:] +} diff --git a/Algorithms/0950.reveal-cards-in-increasing-order/reveal-cards-in-increasing-order_test.go b/Algorithms/0950.reveal-cards-in-increasing-order/reveal-cards-in-increasing-order_test.go new file mode 100755 index 000000000..b4220e677 --- /dev/null +++ b/Algorithms/0950.reveal-cards-in-increasing-order/reveal-cards-in-increasing-order_test.go @@ -0,0 +1,47 @@ +package problem0950 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + deck []int + ans []int +}{ + + { + []int{340521, 308195, 414778, 856972, 402441, 590007, 348211, 666707, 657054, 539706, 632693, 816862, 711470, 94728, 153338, 4286, 49872, 437601, 642859, 98097, 240413, 865721, 253342, 29202, 166074, 766869, 740302, 929275, 770347, 702724, 703473, 85883, 686240, 452695, 584763, 307510, 382863, 818141, 891101, 939491, 654978, 588723, 19897, 341156, 495496, 925312, 414621, 600282, 494990, 102613, 830016, 95336, 718899, 584098, 85743, 127515, 194913, 504435, 619536, 674062, 394671, 307059, 552652, 37397, 206997, 71302, 587679, 872713, 425546, 436031, 539342, 931335, 7600, 801921, 330906, 233278, 496999, 373899, 487057, 898883, 330963, 940553, 25987, 238485, 423698, 194849, 608311, 445219, 995936, 848906, 821059, 813703, 736693, 618701, 710857, 829800, 161868, 918154, 514008, 741717, 210984, 313832, 159840, 931417, 9404, 779463, 715888, 33556, 473923, 497947, 734030, 205989, 57639, 252021, 622960, 477220, 410129, 330717, 995079, 493527, 325212, 706586, 467464, 678015, 204661, 923419, 83697, 501294, 694380, 650356, 18040, 775123, 985098, 696033, 135021, 900201, 321210, 736992, 860780, 589050, 904337, 416678, 678543, 384659, 585690, 937425, 863284, 93500, 699230, 565558, 803849, 664563, 411466, 273941, 464969, 813014, 388201, 543906, 257491, 953585, 284639, 994903, 654452, 968406, 864690, 700492, 557408, 59526, 920627, 895148, 25935, 510862, 995462, 4051, 127725, 195442, 880672, 363279, 785698, 259859, 73946, 817942, 393343, 58646, 82301, 890345, 220885, 179888, 814860, 969864, 339504, 223187, 945205, 844426, 780437, 822363, 433177, 281681, 921182, 96892, 413479, 302542, 584987, 581634, 777990, 643900, 443506, 491403, 370994, 600813, 521805, 444146, 917884, 302210, 172349, 558656, 670895, 454672, 47022, 257713, 210127, 564948, 274188, 859890, 73486, 453778, 22221, 957568, 186766, 129198, 412534, 316800, 649427, 45770, 496858, 763717, 764335, 468273, 840758, 866858, 845948, 303613, 127089, 964039, 678645, 991330, 290125, 975124, 591517, 307205, 664374, 52078, 178376, 451273, 503299, 456959, 309875, 960401, 320969, 309113, 844773, 940860, 823394, 329033, 200901, 755305, 119814, 892458, 59675, 178342, 897569, 293224, 834182, 745647, 15282, 641829, 638633, 342063, 474011, 316077, 653069, 550770, 821574, 357066, 104559, 254575, 955750, 938860, 828818, 959576, 242038, 733465, 539238, 654012, 127896, 741289, 409857, 205603, 315410, 306062, 966299, 414132, 868398, 499681, 272766, 91058, 818720, 24, 636007, 922632, 371509, 880679, 880348, 297788, 746839, 298507, 621113, 594894, 333655, 159347, 952368, 613085, 14538, 138433, 144488, 117404, 386082, 812662, 428489, 609566, 136480, 129656, 881380, 736917, 803733, 169759, 97531, 724019, 23867, 718245, 709275, 204992, 309979, 912104, 826418, 940412, 284839, 217358, 998517, 651632, 929402, 626008, 217257, 150049, 273217, 823909, 522085, 476558, 802766, 481609, 538128, 73869, 77995, 524597, 712191, 526303, 903786, 293051, 283533, 444298, 678509, 565341, 131944, 849449, 415543, 679279, 699487, 468216, 696630, 915086, 999832, 524212, 844066, 292383, 855336, 502486, 962935, 389168, 165263, 539223, 931090, 944144, 604706, 77857, 421858, 12322, 56167, 227907, 801951, 863613, 263982, 803706, 732394, 120924, 841596, 942599, 866843, 515069, 505075, 709508, 365828, 539119, 935822, 52403, 384068, 36137, 329331, 190246, 979081, 515881, 387377, 457384, 698759, 50214, 323059, 225206, 256988, 862672, 772897, 530895, 677918, 882647, 921559, 549915, 708462, 309665, 649081, 129902, 381934, 446383, 962920, 724557, 776473, 306948, 922841, 584825, 680870, 847321, 552370, 690900, 968662, 464930, 788520, 832026, 527725, 213744, 534899, 884579, 153871, 174164, 414753, 880381, 172408, 585299, 821450, 684523, 424280, 978543, 678648, 568765, 88098, 628021, 46897, 560387, 923096, 355942, 289721, 255527, 303699, 608368, 540830, 243289, 105347, 96833, 475437, 175954, 310999, 233396, 13274, 660571, 401096, 704722, 563450, 266468, 635987, 317967, 392048, 350999, 561057, 335538, 648327, 226509, 42185, 231038, 791283, 722087, 799410, 952751, 873448, 373329, 923612, 295029, 609712, 592772, 177609, 97584, 42022, 317549, 37368, 39211, 602764, 449014, 170668, 84246, 274211, 996592, 509178, 408916, 864999, 646886, 706351, 588061, 898946, 794804, 627699, 220735, 834784, 436922, 144896, 842435, 495157, 384749, 696641, 52719, 402570, 382215, 855528, 741741, 992277, 615091, 810558, 880743, 365840, 570713, 73147, 340168, 928037, 569566, 419484, 311613, 441233, 44048, 103169, 452623, 415175, 340954, 391322, 932083, 151701, 894617, 916722, 34527, 925736, 984694, 773548, 192016, 862092, 657710, 988582, 114761, 277002, 403344, 458117, 816925, 646096, 150555, 265813, 687119, 136548, 799320, 427446, 422710, 942682, 978670, 524964, 90961, 933814, 214770, 444577, 26149, 256622, 815776, 67614, 222127, 791955, 62518, 347830, 573207, 933852, 943510, 50312, 744310, 406884, 373020, 227023, 134105, 85642, 543225, 4219, 478229, 331031, 833705, 886039, 215980, 154957, 887585, 703564, 360167, 197129, 546325, 237829, 372919, 502454, 968537, 294018, 702134, 166473, 865832, 760017, 720863, 881253, 160268, 297009, 890740, 900954, 855793, 195406, 473842, 146865, 179929, 955179, 407097, 975225, 562796, 305073, 888321, 698197, 816558, 39082, 882732, 449932, 861691, 91652, 269099, 262645, 153554, 495586, 893186, 967400, 749496, 871174, 512042, 332084, 821155, 97423, 483425, 833967, 295381, 120141, 735117, 383739, 302516, 825418, 306564, 656643, 823259, 759161, 878374, 296726, 304647, 31557, 728298, 112024, 373665, 942563, 902277, 705325, 166897, 650301, 10088, 76990, 210118, 661290, 625930, 420631, 616514, 819513, 69325, 125068, 490640, 495636, 111094, 231715, 98372, 990421, 651332, 259782, 883282, 459704, 8034, 411191, 567683, 163158, 939733, 613989, 311030, 639938, 200594, 985851, 913200, 783381, 973639, 404978, 565317, 169306, 542229, 544121, 488696, 364125, 918286, 154315, 664568, 724737, 946235, 19809, 449481, 404159, 180205, 540240, 665439, 888298, 360643, 401417, 24997, 153728, 480714, 400335, 543323, 14853, 4453, 19163, 991379, 79148, 418146, 315301, 458752, 765658, 147227, 259435, 295569, 556553, 784997, 434398, 610043, 276507, 336216, 190657, 286593, 352698, 235756, 2737, 20626, 647496, 492822, 785401, 298967, 275046, 726903, 701700, 749909, 362234, 921627, 213122, 949182, 892242, 597387, 762784, 53661, 881204, 312569, 435667, 178265, 224147, 737721, 727778, 911410, 487210, 259523, 811532, 510532, 227777, 151870, 377834, 220628, 522457, 576772, 268011, 556101, 451092, 290341, 335381, 826715, 189403, 631702, 965884, 237771, 149048, 544539, 171573, 3378, 499233, 408339, 514495, 568249, 612337, 413729, 361787, 345549, 472826, 679129, 528852, 679054, 886876, 332700, 687939, 684652, 798870, 712731, 453954, 129383, 941555, 754331, 155371, 225400, 249987, 534722, 465349, 80735, 417217, 296985, 80101, 33837, 581373, 926520, 507839, 223949, 976053, 226328, 17439, 828614, 269768, 606731, 687685, 830672, 68819, 259277, 15294, 496390, 392444, 343187, 146893, 636091, 715526, 164207, 392748, 276056, 602607, 369190, 462401, 962986, 840142, 853993, 179269, 619809, 504247, 94169, 376790, 860117, 441111}, + []int{24, 749909, 2737, 495157, 3378, 995936, 4051, 495496, 4219, 754331, 4286, 495586, 4453, 882647, 7600, 495636, 8034, 755305, 9404, 496390, 10088, 938860, 12322, 496858, 13274, 759161, 14538, 496999, 14853, 882732, 15282, 497947, 15294, 760017, 17439, 499233, 18040, 966299, 19163, 499681, 19809, 762784, 19897, 501294, 20626, 883282, 22221, 502454, 23867, 763717, 24997, 502486, 25935, 939491, 25987, 503299, 26149, 764335, 29202, 504247, 31557, 884579, 33556, 504435, 33837, 765658, 34527, 505075, 36137, 985098, 37368, 507839, 37397, 766869, 39082, 509178, 39211, 886039, 42022, 510532, 42185, 770347, 44048, 510862, 45770, 939733, 46897, 512042, 47022, 772897, 49872, 514008, 50214, 886876, 50312, 514495, 52078, 773548, 52403, 515069, 52719, 967400, 53661, 515881, 56167, 775123, 57639, 521805, 58646, 887585, 59526, 522085, 59675, 776473, 62518, 522457, 67614, 940412, 68819, 524212, 69325, 777990, 71302, 524597, 73147, 888298, 73486, 524964, 73869, 779463, 73946, 526303, 76990, 994903, 77857, 527725, 77995, 780437, 79148, 528852, 80101, 888321, 80735, 530895, 82301, 783381, 83697, 534722, 84246, 940553, 85642, 534899, 85743, 784997, 85883, 538128, 88098, 890345, 90961, 539119, 91058, 785401, 91652, 539223, 93500, 968406, 94169, 539238, 94728, 785698, 95336, 539342, 96833, 890740, 96892, 539706, 97423, 788520, 97531, 540240, 97584, 940860, 98097, 540830, 98372, 791283, 102613, 542229, 103169, 891101, 104559, 543225, 105347, 791955, 111094, 543323, 112024, 985851, 114761, 543906, 117404, 794804, 119814, 544121, 120141, 892242, 120924, 544539, 125068, 798870, 127089, 546325, 127515, 941555, 127725, 549915, 127896, 799320, 129198, 550770, 129383, 892458, 129656, 552370, 129902, 799410, 131944, 552652, 134105, 968537, 135021, 556101, 136480, 801921, 136548, 556553, 138433, 893186, 144488, 557408, 144896, 801951, 146865, 558656, 146893, 942563, 147227, 560387, 149048, 802766, 150049, 561057, 150555, 894617, 151701, 562796, 151870, 803706, 153338, 563450, 153554, 998517, 153728, 564948, 153871, 803733, 154315, 565317, 154957, 895148, 155371, 565341, 159347, 803849, 159840, 565558, 160268, 942599, 161868, 567683, 163158, 810558, 164207, 568249, 165263, 897569, 166074, 568765, 166473, 811532, 166897, 569566, 169306, 968662, 169759, 570713, 170668, 812662, 171573, 573207, 172349, 898883, 172408, 576772, 174164, 813014, 175954, 581373, 177609, 942682, 178265, 581634, 178342, 813703, 178376, 584098, 179269, 898946, 179888, 584763, 179929, 814860, 180205, 584825, 186766, 988582, 189403, 584987, 190246, 815776, 190657, 585299, 192016, 900201, 194849, 585690, 194913, 816558, 195406, 587679, 195442, 943510, 197129, 588061, 200594, 816862, 200901, 588723, 204661, 900954, 204992, 589050, 205603, 816925, 205989, 590007, 206997, 969864, 210118, 591517, 210127, 817942, 210984, 592772, 213122, 902277, 213744, 594894, 214770, 818141, 215980, 597387, 217257, 944144, 217358, 600282, 220628, 818720, 220735, 600813, 220885, 903786, 222127, 602607, 223187, 819513, 223949, 602764, 224147, 995079, 225206, 604706, 225400, 821059, 226328, 606731, 226509, 904337, 227023, 608311, 227777, 821155, 227907, 608368, 231038, 945205, 231715, 609566, 233278, 821450, 233396, 609712, 235756, 911410, 237771, 610043, 237829, 821574, 238485, 612337, 240413, 973639, 242038, 613085, 243289, 822363, 249987, 613989, 252021, 912104, 253342, 615091, 254575, 823259, 255527, 616514, 256622, 946235, 256988, 618701, 257491, 823394, 257713, 619536, 259277, 913200, 259435, 619809, 259523, 823909, 259782, 621113, 259859, 990421, 262645, 622960, 263982, 825418, 265813, 625930, 266468, 915086, 268011, 626008, 269099, 826418, 269768, 627699, 272766, 949182, 273217, 628021, 273941, 826715, 274188, 631702, 274211, 916722, 275046, 632693, 276056, 828614, 276507, 635987, 277002, 975124, 281681, 636007, 283533, 828818, 284639, 636091, 284839, 917884, 286593, 638633, 289721, 829800, 290125, 639938, 290341, 952368, 292383, 641829, 293051, 830016, 293224, 642859, 294018, 918154, 295029, 643900, 295381, 830672, 295569, 646096, 296726, 996592, 296985, 646886, 297009, 832026, 297788, 647496, 298507, 918286, 298967, 648327, 302210, 833705, 302516, 649081, 302542, 952751, 303613, 649427, 303699, 833967, 304647, 650301, 305073, 920627, 306062, 650356, 306564, 834182, 306948, 651332, 307059, 975225, 307205, 651632, 307510, 834784, 308195, 653069, 309113, 921182, 309665, 654012, 309875, 840142, 309979, 654452, 310999, 953585, 311030, 654978, 311613, 840758, 312569, 656643, 313832, 921559, 315301, 657054, 315410, 841596, 316077, 657710, 316800, 991330, 317549, 660571, 317967, 842435, 320969, 661290, 321210, 921627, 323059, 664374, 325212, 844066, 329033, 664563, 329331, 955179, 330717, 664568, 330906, 844426, 330963, 665439, 331031, 922632, 332084, 666707, 332700, 844773, 333655, 670895, 335381, 976053, 335538, 674062, 336216, 845948, 339504, 677918, 340168, 922841, 340521, 678015, 340954, 847321, 341156, 678509, 342063, 955750, 343187, 678543, 345549, 848906, 347830, 678645, 348211, 923096, 350999, 678648, 352698, 849449, 355942, 679054, 357066, 995462, 360167, 679129, 360643, 853993, 361787, 679279, 362234, 923419, 363279, 680870, 364125, 855336, 365828, 684523, 365840, 957568, 369190, 684652, 370994, 855528, 371509, 686240, 372919, 923612, 373020, 687119, 373329, 855793, 373665, 687685, 373899, 978543, 376790, 687939, 377834, 856972, 381934, 690900, 382215, 925312, 382863, 694380, 383739, 859890, 384068, 696033, 384659, 959576, 384749, 696630, 386082, 860117, 387377, 696641, 388201, 925736, 389168, 698197, 391322, 860780, 392048, 698759, 392444, 991379, 392748, 699230, 393343, 861691, 394671, 699487, 400335, 926520, 401096, 700492, 401417, 862092, 402441, 701700, 402570, 960401, 403344, 702134, 404159, 862672, 404978, 702724, 406884, 928037, 407097, 703473, 408339, 863284, 408916, 703564, 409857, 978670, 410129, 704722, 411191, 863613, 411466, 705325, 412534, 929275, 413479, 706351, 413729, 864690, 414132, 706586, 414621, 962920, 414753, 708462, 414778, 864999, 415175, 709275, 415543, 929402, 416678, 709508, 417217, 865721, 418146, 710857, 419484, 999832, 420631, 711470, 421858, 865832, 422710, 712191, 423698, 931090, 424280, 712731, 425546, 866843, 427446, 715526, 428489, 962935, 433177, 715888, 434398, 866858, 435667, 718245, 436031, 931335, 436922, 718899, 437601, 868398, 441111, 720863, 441233, 979081, 443506, 722087, 444146, 871174, 444298, 724019, 444577, 931417, 445219, 724557, 446383, 872713, 449014, 724737, 449481, 962986, 449932, 726903, 451092, 873448, 451273, 727778, 452623, 932083, 452695, 728298, 453778, 878374, 453954, 732394, 454672, 992277, 456959, 733465, 457384, 880348, 458117, 734030, 458752, 933814, 459704, 735117, 462401, 880381, 464930, 736693, 464969, 964039, 465349, 736917, 467464, 880672, 468216, 736992, 468273, 933852, 472826, 737721, 473842, 880679, 473923, 740302, 474011, 984694, 475437, 741289, 476558, 880743, 477220, 741717, 478229, 935822, 480714, 741741, 481609, 881204, 483425, 744310, 487057, 965884, 487210, 745647, 488696, 881253, 490640, 746839, 491403, 937425, 492822, 749496, 493527, 881380, 494990}, + }, + + { + []int{17, 13, 11, 2, 3, 5, 7}, + []int{2, 13, 3, 11, 5, 17, 7}, + }, + + { + []int{1}, + []int{1}, + }, + + // 可以有多个 testcase +} + +func Test_deckRevealedIncreasing(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, deckRevealedIncreasing(tc.deck), "输入:%v", tc) + } +} + +func Benchmark_deckRevealedIncreasing(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + deckRevealedIncreasing(tc.deck) + } + } +} diff --git a/Algorithms/0951.flip-equivalent-binary-trees/README.md b/Algorithms/0951.flip-equivalent-binary-trees/README.md new file mode 100755 index 000000000..994d28ba4 --- /dev/null +++ b/Algorithms/0951.flip-equivalent-binary-trees/README.md @@ -0,0 +1,23 @@ +# [951. Flip Equivalent Binary Trees](https://leetcode.com/problems/flip-equivalent-binary-trees/) + +For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees. + +A binary tree X is flip equivalent to a binary tree Y if and only if we can make X equal to Y after some number of flip operations. + +Write a function that determines whether two binary trees are flip equivalent. The trees are given by root nodes root1 and root2. + +Example 1: + +```text +Input: root1 = [1,2,3,4,5,6,null,null,null,7,8], root2 = [1,3,2,null,6,4,5,null,null,null,null,8,7] +Output: true +Explanation: We flipped at nodes with values 1, 3, and 5. +Flipped Trees Diagram +``` + +![tree](tree.png) + +Note: + +1. Each tree will have at most 100 nodes. +1. Each value in each tree will be a unique integer in the range [0, 99]. \ No newline at end of file diff --git a/Algorithms/0951.flip-equivalent-binary-trees/flip-equivalent-binary-trees.go b/Algorithms/0951.flip-equivalent-binary-trees/flip-equivalent-binary-trees.go new file mode 100755 index 000000000..fc1e72a48 --- /dev/null +++ b/Algorithms/0951.flip-equivalent-binary-trees/flip-equivalent-binary-trees.go @@ -0,0 +1,25 @@ +package problem0951 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined in kit library +type TreeNode = kit.TreeNode + +func flipEquiv(r1, r2 *TreeNode) bool { + if r1 == nil && r2 == nil { + return true + } + + if (r1 != nil && r2 == nil) || + (r1 == nil && r2 != nil) || + r1.Val != r2.Val { + return false + } + + if (flipEquiv(r1.Left, r2.Left) && flipEquiv(r1.Right, r2.Right)) || + (flipEquiv(r1.Left, r2.Right) && flipEquiv(r1.Right, r2.Left)) { + return true + } + + return false +} diff --git a/Algorithms/0951.flip-equivalent-binary-trees/flip-equivalent-binary-trees_test.go b/Algorithms/0951.flip-equivalent-binary-trees/flip-equivalent-binary-trees_test.go new file mode 100755 index 000000000..95f200a91 --- /dev/null +++ b/Algorithms/0951.flip-equivalent-binary-trees/flip-equivalent-binary-trees_test.go @@ -0,0 +1,50 @@ +package problem0951 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root1 []int + root2 []int + ans bool +}{ + + { + []int{1, 2, 3, 4, 5, 6, kit.NULL, kit.NULL, kit.NULL, 7, 8}, + []int{1, 3, 2, kit.NULL, 6, 4, 5, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 8, 7}, + true, + }, + + { + []int{1, 2, 3, 4, 5, 6, kit.NULL, kit.NULL, kit.NULL, 7, 9}, + []int{1, 3, 2, kit.NULL, 6, 4, 5, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 8, 7}, + false, + }, + + // 可以有多个 testcase +} + +func Test_flipEquiv(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root1 := kit.Ints2TreeNode(tc.root1) + root2 := kit.Ints2TreeNode(tc.root2) + ast.Equal(tc.ans, flipEquiv(root1, root2), "输入:%v", tc) + } +} + +func Benchmark_flipEquiv(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root1 := kit.Ints2TreeNode(tc.root1) + root2 := kit.Ints2TreeNode(tc.root2) + flipEquiv(root1, root2) + } + } +} diff --git a/Algorithms/0951.flip-equivalent-binary-trees/tree.png b/Algorithms/0951.flip-equivalent-binary-trees/tree.png new file mode 100644 index 000000000..c834f0bbf Binary files /dev/null and b/Algorithms/0951.flip-equivalent-binary-trees/tree.png differ diff --git a/Algorithms/0952.largest-component-size-by-common-factor/1.png b/Algorithms/0952.largest-component-size-by-common-factor/1.png new file mode 100644 index 000000000..259ef1e9f Binary files /dev/null and b/Algorithms/0952.largest-component-size-by-common-factor/1.png differ diff --git a/Algorithms/0952.largest-component-size-by-common-factor/2.png b/Algorithms/0952.largest-component-size-by-common-factor/2.png new file mode 100644 index 000000000..947894807 Binary files /dev/null and b/Algorithms/0952.largest-component-size-by-common-factor/2.png differ diff --git a/Algorithms/0952.largest-component-size-by-common-factor/3.png b/Algorithms/0952.largest-component-size-by-common-factor/3.png new file mode 100644 index 000000000..bc9678c6c Binary files /dev/null and b/Algorithms/0952.largest-component-size-by-common-factor/3.png differ diff --git a/Algorithms/0952.largest-component-size-by-common-factor/README.md b/Algorithms/0952.largest-component-size-by-common-factor/README.md new file mode 100755 index 000000000..0160bdef1 --- /dev/null +++ b/Algorithms/0952.largest-component-size-by-common-factor/README.md @@ -0,0 +1,40 @@ +# [952. Largest Component Size by Common Factor](https://leetcode.com/problems/largest-component-size-by-common-factor/) + +Given a non-empty array of unique positive integers `A`, consider the following graph: + +- There are `A.length` nodes, labelled `A[0]` to `A[A.length - 1]`; +- There is an edge between `A[i]` and `A[j]` if and only if `A[i]` and `A[j]` share a common factor greater than 1. + +Return the size of the largest connected component in the graph. + +Example 1: + +```text +Input: [4,6,15,35] +Output: 4 +``` + +![example1](1.png) + +Example 2: + +```text +Input: [20,50,9,63] +Output: 2 +``` + +![example2](2.png) + +Example 3: + +```text +Input: [2,3,6,7,4,12,21,39] +Output: 8 +``` + +![example3](3.png) + +Note: + +1. `1 <= A.length <= 20000` +1. `1 <= A[i] <= 100000` diff --git a/Algorithms/0952.largest-component-size-by-common-factor/largest-component-size-by-common-factor.go b/Algorithms/0952.largest-component-size-by-common-factor/largest-component-size-by-common-factor.go new file mode 100755 index 000000000..59e33f0c5 --- /dev/null +++ b/Algorithms/0952.largest-component-size-by-common-factor/largest-component-size-by-common-factor.go @@ -0,0 +1,94 @@ +package problem0952 + +func largestComponentSize(A []int) int { + size := len(A) + u := newUnion(size) + + // rec = map[factor]index + rec := make(map[int]int, size*2) + + for i := 0; i < size; i++ { + a := A[i] + for f := 2; f*f <= a; f++ { + if a%f != 0 { + continue + } + if j, ok := rec[f]; ok { + u.union(i, j) + } else { + rec[f] = i + } + d := a / f + if j, ok := rec[d]; ok { + u.union(i, j) + } else { + rec[d] = i + } + } + // a 本身还可以作为 factor + if j, ok := rec[a]; ok { + u.union(i, j) + } else { + rec[a] = i + } + } + + return u.max +} + +// Robert Sedgewick 算法(第4版) 1.5.2.7 +// union-find (加权 quick-union),还作了路径压缩优化 + +type union struct { + parents []int // 父链接数组(由触点索引) + sizes []int // (由触点索引的) 各个根节点所对应的分量的大小 + max int +} + +func newUnion(N int) *union { + parents := make([]int, N) + for i := range parents { + parents[i] = i + } + counts := make([]int, N) + for i := range counts { + counts[i] = 1 + } + return &union{ + parents: parents, + sizes: counts, + max: 1, + } +} + +func (u *union) find(p int) int { + // 跟随连接找到根节点 + if u.parents[p] != p { + u.parents[p] = u.find(u.parents[p]) + } + return u.parents[p] +} + +func (u *union) union(p, q int) { + i, j := u.find(p), u.find(q) + if i == j { + return + } + + if u.sizes[i] > u.sizes[j] { + i, j = j, i + } + + // 将小树的根节点连接到大树的根节点 + u.parents[i] = j + u.sizes[j] += u.sizes[i] + u.max = max(u.max, u.sizes[j]) + return +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0952.largest-component-size-by-common-factor/largest-component-size-by-common-factor_test.go b/Algorithms/0952.largest-component-size-by-common-factor/largest-component-size-by-common-factor_test.go new file mode 100755 index 000000000..adcd8f54d --- /dev/null +++ b/Algorithms/0952.largest-component-size-by-common-factor/largest-component-size-by-common-factor_test.go @@ -0,0 +1,56 @@ +package problem0952 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{4, 6, 15, 35}, + 4, + }, + + { + []int{20, 50, 9, 63}, + 2, + }, + + { + []int{2, 3, 6, 7, 4, 12, 21, 39}, + 8, + }, + + { + []int{2, 7, 522, 526, 535, 26, 944, 35, 519, 45, 48, 567, 266, 68, 74, 591, 81, 86, 602, 93, 610, 621, 111, 114, 629, 641, 131, 651, 142, 659, 669, 161, 674, 163, 180, 187, 190, 194, 195, 206, 207, 218, 737, 229, 240, 757, 770, 260, 778, 270, 272, 785, 274, 290, 291, 292, 296, 810, 816, 314, 829, 833, 841, 349, 880, 369, 147, 897, 387, 390, 905, 405, 406, 407, 414, 416, 417, 425, 938, 429, 432, 926, 959, 960, 449, 963, 966, 929, 457, 463, 981, 985, 79, 487, 1000, 494, 508}, + 84, + }, + + { + []int{5803, 6153, 13, 2062, 6161, 2068, 7172, 8219, 6174, 2080, 36, 4138, 6188, 8237, 46, 8240, 8242, 4151, 6202, 8253, 8269, 2126, 6226, 2135, 4187, 97, 102, 9233, 6263, 126, 3776, 2178, 4233, 8330, 9581, 8342, 152, 6297, 5487, 4253, 8350, 2208, 6308, 4262, 4263, 6314, 1053, 8373, 184, 4281, 2242, 8388, 6346, 6352, 2258, 6355, 2261, 2084, 4815, 6365, 2270, 225, 4330, 4333, 6525, 4341, 6390, 3455, 4355, 262, 8456, 6410, 2318, 6873, 4379, 6435, 297, 2439, 302, 2364, 2372, 334, 4431, 2387, 340, 8590, 345, 2400, 8548, 6508, 367, 4466, 371, 6516, 2429, 2662, 391, 2442, 8589, 398, 8595, 2452, 4506, 415, 2467, 8612, 8615, 4525, 6578, 8627, 4535, 2489, 445, 4542, 447, 8644, 4558, 629, 6611, 4567, 6564, 6620, 4582, 6638, 496, 4596, 2549, 4605, 513, 6660, 8714, 4620, 2579, 2585, 6685, 544, 4644, 557, 8816, 6717, 8767, 6723, 2628, 582, 4679, 3853, 4689, 2643, 599, 4700, 614, 8807, 618, 4882, 6768, 626, 4724, 2677, 2689, 642, 4740, 6790, 4749, 158, 8848, 5913, 4769, 2724, 2730, 4779, 8897, 717, 2206, 719, 2769, 8916, 6871, 4825, 2788, 8934, 6890, 751, 6898, 4855, 2811, 8960, 4915, 8967, 4877, 786, 2835, 2843, 2848, 6945, 2851, 8997, 2856, 6958, 6961, 9011, 9012, 9014, 6976, 4931, 4932, 842, 7309, 4947, 9046, 7001, 2910, 9055, 2917, 1169, 7017, 874, 7655, 9072, 2931, 9078, 2935, 9024, 7044, 9103, 912, 9105, 923, 5021, 7071, 1520, 5029, 2982, 5033, 2987, 7089, 7667, 2997, 950, 7533, 7096, 954, 6033, 5059, 970, 9719, 973, 3023, 1669, 5075, 3034, 2895, 5084, 9181, 7141, 7142, 3050, 9196, 7150, 9201, 1015, 5116, 9220, 9223, 3083, 1036, 1041, 175, 7197, 1055, 1057, 3108, 3109, 7212, 3123, 5173, 7223, 1081, 7007, 1085, 3143, 9293, 5424, 5205, 1893, 7266, 1128, 9325, 1146, 1157, 5258, 9357, 1166, 9361, 7325, 9385, 9392, 7346, 3254, 1208, 5309, 9412, 9416, 5321, 1229, 7374, 1238, 5339, 9436, 5344, 1254, 9451, 5368, 3326, 5376, 1282, 2945, 3341, 3343, 7440, 7441, 1298, 3348, 5397, 5398, 3351, 3633, 5416, 7465, 3975, 1325, 3376, 1335, 3385, 9536, 7492, 5445, 3399, 3402, 3408, 5462, 9559, 9934, 5474, 1383, 3437, 7535, 9593, 9597, 1406, 5503, 7555, 5511, 3464, 1423, 7568, 7570, 3651, 7573, 3481, 1437, 7589, 3496, 9649, 5559, 9665, 1474, 7627, 1487, 7632, 1495, 5592, 9126, 3558, 593, 7657, 9708, 3568, 5618, 595, 3575, 5625, 3583, 1536, 1537, 5634, 9131, 7685, 5646, 3601, 1556, 7705, 9757, 1572, 9777, 3635, 7736, 5692, 9795, 3656, 7773, 6758, 7783, 7792, 9842, 9847, 1667, 7813, 8813, 9873, 1682, 1683, 9880, 1648, 9899, 3756, 1710, 5811, 3769, 9916, 7114, 4725, 1728, 9924, 5835, 3790, 4387, 740, 7906, 5859, 1778, 3828, 3830, 1784, 9983, 1799, 9994, 5901, 1807, 1810, 5909, 8836, 1818, 5919, 5921, 1827, 7978, 5931, 3900, 1853, 7998, 3907, 8005, 8012, 3925, 8030, 3935, 3940, 5989, 8038, 3730, 5998, 3953, 8054, 1914, 6020, 6023, 1931, 1934, 6031, 8080, 1688, 8516, 1955, 4006, 4007, 6059, 6064, 1981, 4037, 6087, 1999, 2002, 4054, 8159, 4072, 6124, 2032, 4083, 2037, 8186}, + 439, + }, + // 可以有多个 testcase +} + +func Test_largestComponentSize(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, largestComponentSize(tc.A), "输入:%v", tc) + } +} + +func Benchmark_largestComponentSize(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + largestComponentSize(tc.A) + } + } +} diff --git a/Algorithms/0953.verifying-an-alien-dictionary/README.md b/Algorithms/0953.verifying-an-alien-dictionary/README.md new file mode 100755 index 000000000..ef4fd5d09 --- /dev/null +++ b/Algorithms/0953.verifying-an-alien-dictionary/README.md @@ -0,0 +1,36 @@ +# [953. Verifying an Alien Dictionary](https://leetcode.com/problems/verifying-an-alien-dictionary/) + +In an alien language, surprisingly they also use english lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters. + +Given a sequence of words written in the alien language, and the order of the alphabet, return true if and only if the given words are sorted lexicographicaly in this alien language. + +Example 1: + +```text +Input: words = ["hello","leetcode"], order = "hlabcdefgijkmnopqrstuvwxyz" +Output: true +Explanation: As 'h' comes before 'l' in this language, then the sequence is sorted. +``` + +Example 2: + +```text +Input: words = ["word","world","row"], order = "worldabcefghijkmnpqstuvxyz" +Output: false +Explanation: As 'd' comes after 'l' in this language, then words[0] > words[1], hence the sequence is unsorted. +``` + +Example 3: + +```text +Input: words = ["apple","app"], order = "abcdefghijklmnopqrstuvwxyz" +Output: false +Explanation: The first three characters "app" match, and the second string is shorter (in size.) According to lexicographical rules "apple" > "app", because 'l' > '∅', where '∅' is defined as the blank character which is less than any other character (More info). +``` + +Note: + +1. 1 <= words.length <= 100 +1. 1 <= words[i].length <= 20 +1. order.length == 26 +1. All characters in words[i] and order are english lowercase letters. diff --git a/Algorithms/0953.verifying-an-alien-dictionary/verifying-an-alien-dictionary.go b/Algorithms/0953.verifying-an-alien-dictionary/verifying-an-alien-dictionary.go new file mode 100755 index 000000000..7b02db1b3 --- /dev/null +++ b/Algorithms/0953.verifying-an-alien-dictionary/verifying-an-alien-dictionary.go @@ -0,0 +1,29 @@ +package problem0953 + +func isAlienSorted(words []string, order string) bool { + indexs := make([]int, 123) + for i, c := range order { + indexs[c] = i + } + + less := func(i, j int) bool { + si, sj := len(words[i]), len(words[j]) + for k := 0; k < si && k < sj; k++ { + ii, ij := indexs[words[i][k]], indexs[words[j][k]] + switch { + case ii < ij: + return true + case ii > ij: + return false + } + } + return si <= sj + } + + for i := 1; i < len(words); i++ { + if !less(i-1, i) { + return false + } + } + return true +} diff --git a/Algorithms/0953.verifying-an-alien-dictionary/verifying-an-alien-dictionary_test.go b/Algorithms/0953.verifying-an-alien-dictionary/verifying-an-alien-dictionary_test.go new file mode 100755 index 000000000..d05f185fb --- /dev/null +++ b/Algorithms/0953.verifying-an-alien-dictionary/verifying-an-alien-dictionary_test.go @@ -0,0 +1,57 @@ +package problem0953 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + words []string + order string + ans bool +}{ + + { + []string{"skuxofhyqffmvem", "pivlrvyixuwkteq", "alsgqypugsbbobl", "aaeognfoaxhcfii", "mpyonsmytxdnysa", "midsibtcmyeshoy", "ozqieboykydhjlz", "bolwcxirutfkovw", "kmbgtngnzhldnql", "xrxbriikmpxrprn", "xasnbmzcyncynqf", "srvryjpvrkjfwum", "kxcytrfssxrrksl", "foiaripeubtyyox", "yyhnjykzexgksob", "tykvetxwxbnaghl", "pkfmfhnboutbzry", "mlxxxcpeapjhwvx", "jmtcevkbcurjqhp", "hpowpmxkjiufoyz", "trbrldyxjbthcwi", "elkqzwcdljzzilp", "xuututciwchdtgp", "dznknlxbhjqlnfp", "usvebdafpehvhnn", "vgztrhsazakvkoy", "ppeowsoiwauodrd", "rwfnkmwpowiilmn", "gnptotnrcujhobx", "rfesptvhuiwtzuv", "nncoygoxusmskdj", "zrdmgclmxuygrfa", "ccuprnhgisbhnlo", "iwwnyuooaxciddu", "kyyzpnkywltfyqf", "fwvfdgyhgwnedww", "inleqhipjuvaipy", "ggwajwbrmbsvzto", "smfnzvhxnzlttqq", "hgolraueyiveyff", "bcitwifwgcvnfiz", "tporichlcybalot", "axjnikarmsedfkf", "takwnduamciroyg", "jtoikpsttsdiusp", "tlwzeycxdkigmia", "gvktgerybyghsoi", "gexklhkdamzxsar", "eaescmsyvbfhjki", "izkzehqhdpfkcfd", "riygtdcgibpigjr", "hxnngtftblikoan", "hqeyivtoimdmcgw", "srgbehdjwgvkwfd", "syrqpdzhbwrohvw", "ulghcdyoaaimdsk", "yotgykrwulptddt", "vmujiultrruvicw", "bvgazhtfaxopncl", "tlygnypwvdpqruq", "gwghjruwprmaywb", "tmjlyehemrjllsf", "jbtollpqxhcxipc", "urryhtrjdcyyxgk", "fovuiicvzbvopje", "iocnnebdisktpto", "dizpowvljuxcuyp", "lmbryijbblvbfew", "hsbdhkhaqjsyezo", "xuzrakcohgkzvja", "rqytcuxmbexynso", "muvxuufnbdxpgqp", "kazzhqfnoerazdp", "ydcbxbysbzqavgq", "uvswbtjojzodhxx", "ogficmoxohwmacf", "rsxarauxrlsugzl", "ivxddltcdfqnsku", "flxhjxcbldrhmtg", "gwcgyybialciiaz", "euizzqwnnefihcz", "ttlzrgnwhgzkirj", "geomyyrdrhkimzv", "wfoxpjisclyoygt", "iunuvuqdkeqqacf", "vfftvmtoaanoafp", "ogzwqioazjyedjq", "iltzlygzsreqlkw", "paighhiwamnafai", "aslchefeszbmokl", "opvtsdbqxgppvmj", "kfjaofmhvgfjxja", "xiwykodfpgizgky", "qsznrasrvabazev", "qpevsngotolecsi"}, + "fhgbavxiyjpueqkodmtzncslwr", + false, + }, + + { + []string{"hello", "leetcode"}, + "hlabcdefgijkmnopqrstuvwxyz", + true, + }, + + { + []string{"word", "world", "row"}, + "worldabcefghijkmnpqstuvxyz", + false, + }, + + { + []string{"apple", "app"}, + "abcdefghijklmnopqrstuvwxyz", + false, + }, + + // 可以有多个 testcase +} + +func Test_isAlienSorted(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, isAlienSorted(tc.words, tc.order), "输入:%v", tc) + } +} + +func Benchmark_isAlienSorted(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isAlienSorted(tc.words, tc.order) + } + } +} diff --git a/Algorithms/0954.array-of-doubled-pairs/README.md b/Algorithms/0954.array-of-doubled-pairs/README.md new file mode 100755 index 000000000..0be09b3fa --- /dev/null +++ b/Algorithms/0954.array-of-doubled-pairs/README.md @@ -0,0 +1,38 @@ +# [954. Array of Doubled Pairs](https://leetcode.com/problems/array-of-doubled-pairs/) + +Given an array of integers A with even length, return true if and only if it is possible to reorder it such that `A[2 * i + 1] = 2 * A[2 * i]` for every 0 <= i < len(A) / 2. + +Example 1: + +```text +Input: [3,1,3,6] +Output: false +``` + +Example 2: + +```text +Input: [2,1,2,6] +Output: false +``` + +Example 3: + +```text +Input: [4,-2,2,-4] +Output: true +Explanation: We can take two groups, [-2,-4] and [2,4] to form [-2,-4,2,4] or [2,4,-2,-4]. +``` + +Example 4: + +```text +Input: [1,2,4,16,8,4] +Output: false +``` + +Note: + +1. 0 <= A.length <= 30000 +1. A.length is even +1. -100000 <= A[i] <= 100000 diff --git a/Algorithms/0954.array-of-doubled-pairs/array-of-doubled-pairs.go b/Algorithms/0954.array-of-doubled-pairs/array-of-doubled-pairs.go new file mode 100755 index 000000000..b4b0fa9cb --- /dev/null +++ b/Algorithms/0954.array-of-doubled-pairs/array-of-doubled-pairs.go @@ -0,0 +1,50 @@ +package problem0954 + +import "sort" + +func canReorderDoubled(A []int) bool { + size := len(A) + A1, A2 := make([]int, 0, size), make([]int, 0, size) + for _, v := range A { + if v >= 0 { + A1 = append(A1, v) + } else { + A2 = append(A2, -v) + } + } + // 把负数单独分出来,并转换成正数的数列 + // 两个部分,就可以用相同的逻辑来处理了。 + return isPossible(A1) && isPossible(A2) +} + +func isPossible(A []int) bool { + size := len(A) + + if size%2 == 1 { + return false + } + + sort.Ints(A) + + count := 0 + i, j := 0, 1 + for j < size { + for A[i] < 0 { + i++ + } + double := A[i] * 2 + for (j < size && A[j] < double) || + j <= i { + j++ + } + if j == size || A[j] != double { + return false + } + A[j] = -1 + count++ + i++ + j++ + } + + return count == size/2 +} diff --git a/Algorithms/0954.array-of-doubled-pairs/array-of-doubled-pairs_test.go b/Algorithms/0954.array-of-doubled-pairs/array-of-doubled-pairs_test.go new file mode 100755 index 000000000..39db2932a --- /dev/null +++ b/Algorithms/0954.array-of-doubled-pairs/array-of-doubled-pairs_test.go @@ -0,0 +1,72 @@ +package problem0954 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans bool +}{ + + { + []int{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, + true, + }, + + { + []int{0, 0, 0, 0, 0, 0}, + true, + }, + + { + []int{1, 2, 4, 8}, + true, + }, + + { + []int{3, 1, 3, 6}, + false, + }, + + { + []int{2, 1, 2, 6}, + false, + }, + + { + []int{4, -2 }, + false, + }, + + { + []int{4, -2, 2, -4}, + true, + }, + + { + []int{1, 2, 4, 16, 8, 4}, + false, + }, + + // 可以有多个 testcase +} + +func Test_canReorderDoubled(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, canReorderDoubled(tc.A), "输入:%v", tc) + } +} + +func Benchmark_canReorderDoubled(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + canReorderDoubled(tc.A) + } + } +} diff --git a/Algorithms/0955.delete-columns-to-make-sorted-ii/README.md b/Algorithms/0955.delete-columns-to-make-sorted-ii/README.md new file mode 100755 index 000000000..01b9f91f3 --- /dev/null +++ b/Algorithms/0955.delete-columns-to-make-sorted-ii/README.md @@ -0,0 +1,47 @@ +# [955. Delete Columns to Make Sorted II](https://leetcode.com/problems/delete-columns-to-make-sorted-ii/) + +We are given an array A of N lowercase letter strings, all of the same length. + +Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. + +For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices {0, 2, 3}, then the final array after deletions is ["bef","vyz"]. + +Suppose we chose a set of deletion indices D such that after deletions, the final array has its elements in lexicographic order (A[0] <= A[1] <= A[2] ... <= A[A.length - 1]). + +Return the minimum possible value of D.length. + +Example 1: + +```text +Input: ["ca","bb","ac"] +Output: 1 +Explanation: +After deleting the first column, A = ["a", "b", "c"]. +Now A is in lexicographic order (ie. A[0] <= A[1] <= A[2]). +We require at least 1 deletion since initially A was not in lexicographic order, so the answer is 1. +``` + +Example 2: + +```text +Input: ["xc","yb","za"] +Output: 0 +Explanation: +A is already in lexicographic order, so we don't need to delete anything. +Note that the rows of A are not necessarily in lexicographic order: +ie. it is NOT necessarily true that (A[0][0] <= A[0][1] <= ...) +``` + +Example 3: + +```text +Input: ["zyx","wvu","tsr"] +Output: 3 +Explanation: +We have to delete every column. +``` + +Note: + +1. 1 <= A.length <= 100 +1. 1 <= A[i].length <= 100 \ No newline at end of file diff --git a/Algorithms/0955.delete-columns-to-make-sorted-ii/delete-columns-to-make-sorted-ii.go b/Algorithms/0955.delete-columns-to-make-sorted-ii/delete-columns-to-make-sorted-ii.go new file mode 100755 index 000000000..8b6888d44 --- /dev/null +++ b/Algorithms/0955.delete-columns-to-make-sorted-ii/delete-columns-to-make-sorted-ii.go @@ -0,0 +1,32 @@ +package problem0955 + +func minDeletionSize(A []string) int { + m, n := len(A), len(A[0]) + + // isBigger[i]=true means A[i]>A[i-1] + isBigger := make([]bool, m) + res := 0 + + for j := 0; j < n; j++ { + t := make([]bool, m) + i, count := 1, 1 + for ; i < m; i++ { + if isBigger[i] || + A[i][j] > A[i-1][j] { + t[i] = true + count++ + } else if A[i-1][j] > A[i][j] { + res++ + break + } + } + if count == m { // for now, all is sorted. + break + } + if i == m { // every string is checked + isBigger = t + } + } + + return res +} diff --git a/Algorithms/0955.delete-columns-to-make-sorted-ii/delete-columns-to-make-sorted-ii_test.go b/Algorithms/0955.delete-columns-to-make-sorted-ii/delete-columns-to-make-sorted-ii_test.go new file mode 100755 index 000000000..bd20b033c --- /dev/null +++ b/Algorithms/0955.delete-columns-to-make-sorted-ii/delete-columns-to-make-sorted-ii_test.go @@ -0,0 +1,62 @@ +package problem0955 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []string + ans int +}{ + + { + []string{"nobhttjnanwsfjaoythqlziymsvpqgxsfvpzmgoloppabwuzxyxrtvleozeffvuiobsnwrejqzaxrapmgcvnguugpqwaktbjuowr", "vnzaupgircggfdazttarjooyggjjfwgoezdesayffmfpdyfqzknbvkeunsxgfkvilmqzqxyxymbfklqowvqshwgrhqqutovxdquj", "jrxxdrlmeyfcsmsaxntrbxjjhsjitgdfsjdsqmzkaajhupidktqiwopbthaaukvgpzphgwsrzobmolgamoegiprphpnuyswvmrer", "rvqsgytjnymsuhpthsfixvsmaaffmjzczrcaviodivzxzjafdwzaftnmfneopzfucbvvwzzzorbpdnbxynsazmtgszimvmnlkzei", "qwcuafxeawbekrgkqzqjdjlygxasmmydkrpidnxezawcblqhdcldymxxytpllanuylgzdfsporccczayczwolxszolqgouaftebw", "hgacebtnnorodnjbwzfrxodcoexgcoljheypkswucrdwuzykrzttviuyooirscmazliqkzqtjucgfoewzlrufmuipnzihmrewrgp", "poiiqlckvgqjguiloqsambwtazngpkbxlxuyudpazegfjovdhcbexqyuzfphoaqqxgdqncqukxcnqzxqrnztogafefllnooldvzd", "saxjgvpdzvducqohlhviviigqwnvdfbjwfzudrskobxoxcnwkgkgkljwayazrdvbbbguhskcuhcpqrmgjqtwnsxubzxzcdyrfurh", "nlyhfleljrgkvcfrttbhxhsvqlehskvfkemzqlptfanctrgazyacjchfrwmxjbkdezpgyhkbtecputkbelracwgwqsmzumtnqazx", "xyfdjkzugkhliomgpmwxewrqqptenajhwmlnahepjzjnzybqlnkzzolvnvvijdnavmykpygksocyxqcmvargirtngaeubransrjz", "hmauiygfrvtallotnwhtweykggifyocnygxbibbishkwkshkbkobhwfohssxdlihknzzlcbfafddiqqznhqlgeycpzpdzkgwlqpl", "dqnorvruwcmrprqfucwtxqwjdtxonctgoypyqlhfkqsuvtbmfcfrbjjdglenteyzkksqcwhkgxdgafzgnecforlmsffpvqwhciaw", "dkcdkpttoxajqnbihprlrdkwwiivuyvxlbcdnfeclaqmiprvptahupvddgphhunjwmremymsnudpwnxdaovvfavxdmgfaotqbijx", "ojgssedmspxmftngpnicmysghydvlbfsxzmayhtjcqtvudnrlffnpuvlslcihxexqgpvrzcamzdsouzupaxhafjogryatvnsrmgt", "xqrjxzgowfzphmolckctnslrdmpvymmjrkmcabqnzebkbsqjuzifmvbuthdvpfkrqglldsyrmedwkyxzqjpggtwhiguefekcgqrz", "umvcxsfbqfypamhfqrhrifdtbkxpfjwfrmnfxdvghwgmlqhlotddlkgdbktzzmxyzbrvexwxwxdzzjynoojcuuyfljdwsnjupouj", "jxzhumhaecvsnolmzyjwxdxuvmcfnarfpqobjvvrguzekmwdgrqqwfwjdabcmbdgphzkkvckxbejkbgnphtiwtuwympkgqzyevaz", "ryrkzfjrvphycmhqovxdodjzcfhfisbsyxcxhgrolbqqsjmzpndgxjlpyiiarxbspnshcjjcfkemfjdkrtzmtbypymrpwckgksax", "xbnhcitibihydssekxkuxqxxnsypykwejmpbpfaajpippykfupcanqsrvuzjeqlwyxfkbhmvdteunxpecjduyiwdzjrwirtgffhr", "hlznpdalynzlzpvhwczfssdvblgdujzqmdietyrghrvfrlmtjvpjgxcycmzsucbbwlthbrsqbrewpqyfskitalevfsuyytdkvgfq", "zxmetstwhjgqbkcnuaqhtjilzwwuzuwvwcbeoqfvzohgbnsqadazmupycngvsqrtforvebxlhzfljbxldpjuprpsmjzfrcrdmeaq", "kbulkjgdfokeybdomgseeyblnhwlsptzvhygakzbzjptnnyhtlhgdmzfepsokakmcaeeytlhqyfquxpcktxqlxpfhfehksocgvfv", "zzzngsbzpamxbgkmedczejbaaafjvtisepbkrvstsabncxsthfjfioizxvppfqwazaaknyhxhufvvywusfqiblokjpqbeqmawilx", "opjagfdtqsgsodzbidjimyblcpqivrmcrfaulbuzulfwavimkmjrjfzbeuvtdpphspptrncuyefxsoctgrbziicpenckxitdsxev", "bxgrnjveicjmtgzthacrmmhhbhapmyakfkfbmldtvjdsuqyydkkwstaekeaxbazxleaapkbrzhfyonrqeuxeqgyreqhelkhvxebt", "wppdwufbsdcwxqufibzydwspjtjoygkhckvbnhtkaxcarrilgggdjdpqxaoopswvwnmqpnjlvqfyopsdemdblrkhkjhubmqpcnqa", "mkyrpfeyouhbcrrgrjtcxwafzpkghjcnelwikbbgktybexkyhbmkvplwpebormqhhdszdcmzdwgmvhmmimyfrqfhomcbjsxvgdrg", "jbpbchsjzbfrptibifazielpzrrosxxrkcrnyimmetmjejmkneihvsvphkutryrwsihvgdfkufiagtilhzxyjdiygqbzanjqrhfx", "cjzlxpnzfsmqzrbgkwdxtozaotwhajsngxqztkzkvzfkcjfcjnbztydhwdqvynpbtvhywocjflicratlgvgmojwzonpczjbybynm", "irudzaapcaakadlchpwuringeavwxzpnvkkefpovuhomjkfkbktmytfjcrnqaptkbacoozbbhuiqsklagfyksrxveetmokxtsaeq", "ohirkpimrbaickgzbejrbxmcsxpwydchtdwhiiyqiaiohqwolhhbvafkkneowxmaqrhaalyaffjxreazftdtnyylobbbxgswskew", "uqbbuhgywtkoqyuaygegxoeowczivecgkciabypgfgplmqowmojqtdknonxqkfyhfwomzdirbvkukmdequrezaqtuojmicaxcpfk", "cpduibajwldtjzkbigjxrpfhyzjvoewookzgnfuwhamrrypfsjzzquharpcevjzsbljixfiupwljcjxrtrrftiepsgoruykgcior", "saddyfxdpvctiotakglrdbaowduvvupqdwkmnealwxgpntvtdsfmriessrwwidbwratmebfreqlnahcphjvionmidxuzwjziggsr", "hhdpgzrbidmwzsswbnjzaiudxxkbbbuoezszvyqkdcucgahuwzdvghlhdnevuslzhdhspqpxqilpigojohzlrokaqkjpawhylpzk", "nrqlfenyomdhmxqvtqjfcphqfqjtduxijencdvudyqqhtygaziylucuuvkuciwrmttagrnfojslwgchdogdoupsbsbglhdzdufnn", "dhbgukrrrnioxivpfciaseovghiiqfiadvmojeyzdbszsoumehowbxhwnyvuxhyqgzgygfflvflyofodjoittschlurcdamlgjww", "calhlfhgppsikxpcpkjjoqjwivrdpsvwtmhgrjonnbzcyvmqzwxcddyixururvrbpnpbfjiadflzhvycgoivncoteplodztiugon", "oeoayqpytrbqogrpjqrftyuwrnmxqtzrudzgvbjedaguokeighusaoomgevpywragjgrlixkanmgzctgsdhkbxjsfbpodtoqisfe", "qcyaosryeclcqsyywgbmmnmtudytqbiwneemyyswssgjnasxyhsmkbjbjrpgtrruymyjewfwkomlzusvihpxuettmhjraroyklrx", "zixpuufjugkgaardcudctjkijaehtstncoircazqxhvbcfughqhlwatxbyfmeugbmseivolistmmkzhdtkfebexdusgjszwamcvx", "twiqzwqxfsgdhkdwjalejfzxudwvqpclxzqwzmfkxllzunmfmunnbjnfpzxkznmxwefyfvnhhrngiiagzvwgxlureiyhbteycsnl", "aibbqdrtsvhhnrqofawwdbqmphalczvyjlrotqkhttjnifbqkwotpphnjfyikfvssmgsnhkgjinkypzrdlxfsohmwnoynbehgcxz", "pxvfwtwlafycvqzozebolsompldxfhmnomnjddakhmdysyjmlalmkmmpcshvsclpfbmhviksbrogjrdooixctqlgalayioezshxo", "obzvnqimmvyxxjgnysrowbypfoolfkygbosbvroecunahoxtqtlvxweinutubcuaxmnpterplxokvbykabpmgfandumwsmqfiovj", "vdvvoukuisnggrahehjvmcffjqssorszpgvlyqkwdxfkfcyrpdyiihrzngvsolacrqluphbsgbolaxwqyxuhgrkzkkyacxxrcwtq", "xfvsfetyfzidgkcvraplasyzspypkpyeidpmnxodwjzrsvsxzbfmoemyvvzhtbsnnbmztaiijcpapxukeqcyjokvvzlwpfnjluiz", "jcndqdmqyrzphvhmzqwrfqbujzcovpprrvamuvtxpmacdppfpstjcjqehvlhkhlnrmcqdcjgdppdbziqczwtrnuxlahtljtbzjgn", "juotqnaeqsispfezjmkvzroivnnczpzxwnwbzodsyzjpqvieylmyiqejdsiloeatycacrcpgaapkpeafuoorjrymrqevfaqfczpa", "iblikloirsywhdmnfjwwozryvcwogrihgqfjqyfemaasfbosqielhseuplcxpvelercddvnyhcpqvlpjwqcbgnsmmlbusgirlzzb", "pezrxkgtsgoyxlfncnviteszrjcympupxestdeiirjamnhkulmcsubjonvjmhplunjtppalypoqfxvewhqxoiexlzgdcpanxfzup", "qmrzspkklimygtkpfdwjhnahhfndliodqpjmnftwqlqaaqgqvcyupljhrowivjylzyirftjvonqhitnzyaigntuijzkxtncqhksm", "juvuznetreylakribucjywjsckpiggnlwrjffabzjmuegdvxzyrjlclitllsayxwquagfgogtyqqgotntbxyobemvskwwpfchskz", "sxpusrsqduguxjzcmaaemqifazwmohbtfepzzwwsysmmsfbnihhluiahkoyhszcowjpfzzrizfrilpicxgiibipamzyznjhicfdi", "seyqpopooecldhydmqambxnxxiachmfdvcfefslfgxneownavqvzktfhqlldcvkopcvowduundrmurwcvtavkujkgsjvxqnmvoio", "xuqwkgeaugprlrqvxbynubpqxmrtzbgskkvhmmftyqxwksipefywfwbzkbyndufzrrnijqhhhasjagkunaanexpnrkxvwnmfneaf", "rsprllqjicbujdedunyeaasiwkvxeehszjjqwaqtlgyyoslilvomismzxzmtsnqdxnhfshzpuysjtwacwrfgxfvetcxribrshtbr", "onixzpwuxaelchmzvzzhezijjwyvwcesizwaarvlubjobxemlrpiosxtuocfbpnacbnrsuvhekskskqbrrmvomzrcjezunmzchlj", "xatqvgufdguhenbdqxhqyqlnsoflukpcsybpqkhqmvhamxnrzohejfddwhdhotwexbqppnlksgsuvqfgwwpouvgqcmmlxbksqgjd", "uvgcwzkmnrazrvfyffwsguooygpmqwsurgvxfjnfrywwfczmikhfymuyluflwchxsfhkmbbzslsvlhicfxomhmmohcfdmzkaahbm", "qgmqgzqkmmwuoveyvjcffebidcwvldmoszgzzrwdynzdmjuqgvfnaiykdhtonssyekywpmbeuftijgdvugvhvmurdhblohmvjxbd", "vyjiooeamfklryjkaofokbcurltjujrnniltrfrafgcmowwyspylckvbaoawahsdkdtsfsgzixtmwsqqylfddjcobbhiudsuermr", "istwcyruifilmalcynnpseuvdapbcrsowblopftdufiwoqytbzddfeuvcfkjcgmaoqmaqjkakatpronphslvsyhpcttwqqgdydcb", "onuapbtebwhjjxclktndnguegxdtenpipndduzavsxmhetykqqdbksvtdskmjojpjbzbgpawlvtrnxrmfhsttihyhgzhskgzfhxa", "sbtceulryccnzzuyzhmasuxpvibykoealyylaaxyxuzfqduppjjrjpbgyhkkitrpetncltrnapuaewnwssroctfbkuigrlutetjj", "uvfgtiaeieiybeslslxpzqtnrqteooxsrxgfoihuefuwwqdfoxxaneqfnsqzvdpbilvyyhmaeauewaolcambienmubdanhkuxcge", "ensmqnrzjltbdtyiaxzxzegyxpoypskxtunahevcxfqkcpbytdsysndgctalnlijhhrxbcgqviuhwbprllxciruyijvxxhpzscgo", "dynidnxljmbijllwwvjqcjoqgalikgzomxmlvoveyzshfvotjnbmdbyeipopmvlrbassfdvuqrukwjaxqgwxlqrcyxueykznnxjz", "rkxuubhscwjocyelteklgxifnorblunyadrjidsefscqznkwmhxkmztemaiajkciromvyfzzwiunyjrzmlwmldlhfthajvklatvl", "cgnlgaqrpqgktrylnthagdmsnhkggvyaqckfincsnavmdtuwjsrjrrskfrslrgxqcklgbwtlxduttvqttikfjrbskmwjqtbyavmo", "ewzflfemetkqqrnsnusbloyqwyvktkrhysxypsniiynivognelvujwcrlgjxiorglayuglbuiyuuydukdjrhzjiafupdibkcbgrk", "wjqtoxsvljfesolvkdyfqxmmpzvoocnyvxhwjpwvlhjpienyepflpnngzmvmztmgjawqegcvkzuyacmqipwulphnjaboldifpcoh", "tmckqvfumjtpmjmijytbuhrnnfltyqjagozieqgswyfpjgudduipqnfogorfugtjojmjdsautwvhivsylevfoznwnwbrjfknrrxg", "jhzqwbukqsbqfhnbvfftreqqjkzxbtvxfkeaxxccohsesdnttfgasqyiqsszwvdsjwmldnxvrwvyzeeagtjxxhklquyfruwurbsi", "tzuwyyojswwldxpzzhlylvhodsxirmwqklsmedegmbnzatchzlivdzzcqnmctclyxaiwmkinzuwjiehhjblrcevtpvjxzpkrkprb", "lsfzutypbznpiuplegezeouhltefsmqafycudgumetkmqqqmccxiuplmreegatxzsxxosmiepdwougsglifctzeifnvgiikuerea", "fwnmtllbophqgwikkmglnxvcftseyyuthnsnzazyptrqmaoukmuqkfrhzegnzpcowkzyyozmlqwqprgmhlgmiqxifbjvjyfvhtmp", "esnqustifizyijbngkwmkeworaathlqkenmdacnrcsdplkeipdjjditjofjmaylerlankqxelywqshookugwrcedzafxheuhpich", "pchwcigplovuhyqfdljqvmixrzinzmjkwzbshtcrupjcqejyrzeipibuqyiexfhxhsgvvmaqgtwwnmuclhvfnjsfozxcndelgyib", "zxrjngumnjhzdavthekeadsugmjnanyecxinulhcpfkynyncavbyeuyccyxpcxgxotjpjxfdgaxcwerybtpuhxgofircivkkjqzd", "yuaobmfqiunwovzyulkkhsrsarrauykfdkkcipjojfjmarlzhahcwwxdhknoybmxyinlivwupsxemzqrwxekbbogjsfebjucoxxq", "ammhctpsepgbagoafnpwaumammlcjcfbxqmztvzjumwujeylpotaswwtgwnkacngvsyikffefdxgcnvvqbayyrjvudrtgdhpuglj", "edknamctunqcijhnfcdiuseuvopwhkiwxcxdepstzesfyobvkmnrmfxgsybpdotwjtjvakwvhzximtiskkwzydehsthhyplbnhrc", "sifrawqfgcgbykecxppsiwxszqumdtxquguynqmevamwirhsdxvwfuytaljabhzrqoybwiyvywxmquwjboqqkprdxwblzzgsrqvi", "zopzxtlxsytnycerbtlbsokjadatritemzbvwmxxfdkyzamlezqekudwprprnlnszmfapweczixmzwuzgsbnkktlogfvvsajuwoe", "kfknjfcnqletleexwhwaiigsztoqczbpopsjcshjjoqmvposltoshvdtrxnoalfvvptmaaszxexyycnsivjdrwijzkzhpyucdfik", "yebnuukkmsldxswocmqhjsrmpymyeiyjyirbxfzpwjdqpbtiaaqnpuyifurtvjhieudsymmnpxydasmgitzzzcgnctyckzsohlwm", "dymvgjducexyedlbtponapnebmdkfdogouqpyibhuhsfprntcxxzykawvrprjzceaydjlozevpyeaxvckuqmxxjegfkvmxouyukz", "ulkhumuqnrxeusndjcjqxqjaivcsvktgdlxbmyydijrugqwhckxdghxanirqlzmufpnhnmkdsiymuqurtoodmqotufmyrgkvvlpl", "sxzkgmtehoqeouqbaeopsfratiekrelbfpqyrfhraxbkkiqmusrqcdtswbfnjndeehaawzlgayynzqywtudugdwyeupnraptwjjf", "hoxexviivuqqmggfxhsqxjmaqqnbunovmrbcakkhdqjkpopkhdaylpfrezzeckfgbijdunxpdzyveansmqpnfmydczzpmxtlxkbp", "xywmzjvuexvcnrbjeuaxabecistwssxeqxhldvpmbyehiyampuzqpagjebgmtetjmmcjncioegyvvilzrcwphkhhfxcxhnmuukwq", "avgqdewdnczmhjlxdvuejphbjjtqplsbrrunsknsushattrwbgugugeqembvahdkxhwvphkwtnzcfycoclwwzctcubmibztupbgb", "fowggwthyyvgdheaogzhlyiysnzujudxmfjvuwspqqdwdgzlxljursdsesyvfasqtmtzmohjehzfafilrlwwvchfwksqyrwizakx", "eubkidkyoqikppqlwealwdqkhimuvzuqnjbkjhwrojiurpukonttxnmkwlwtvujpyzxcyxutugzmjlpylrliiwbihsjsanaazofh", "jhagizqiwepckxdzxufccslxizelsgmmzzxymouzttrxoeshxqypqzrbuthsbqbnfczlnecxeczqgoxsbsleitmwpofwaxwvkmmn", "ophsohylthngescjeddixbgmtrhvnysmmylucbgwlpdqnljsztebfqcahjeqeeozsssfuisualzrgbihpdckrqarsylkklmnevpg", "czhvbrbjropeoagempmmsicdmtqimvtbkmndujqcgfqidsnvqphffdhwdoelmwiustgnadcgpzzrluxgfrjcsqmurdlzkactiqvm", "xddmrmupfsnqlidwsxopxbpbmkiklhqzmfxkpvfuebvwnkrjhmpxxmbrkplihiabctzoqavsilzsmeoujlbhcnclaohphekvwuhq", "cchrefbftixmfiekisqezsbvlcrtiihlgjuahdocpasplultieammaqmzqaqrefakecyvuhwiyztzemkbezpjbpocxirqwcyzjdj"}, + 74, + }, + + { + []string{"abx", "agz", "bgc", "bfc"}, + 1, + }, + + { + []string{"ca", "bb", "ac"}, + 1, + }, + + { + []string{"xga", "xfb", "yfa"}, + 1, + }, + + { + []string{"xc", "yb", "za"}, + 0, + }, + + { + []string{"zyx", "wvu", "tsr"}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_minDeletionSize(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minDeletionSize(tc.A), "输入:%v", tc) + } +} + +func Benchmark_minDeletionSize(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minDeletionSize(tc.A) + } + } +} diff --git a/Algorithms/0956.tallest-billboard/README.md b/Algorithms/0956.tallest-billboard/README.md new file mode 100755 index 000000000..abcf60bc2 --- /dev/null +++ b/Algorithms/0956.tallest-billboard/README.md @@ -0,0 +1,37 @@ +# [956. Tallest Billboard](https://leetcode.com/problems/tallest-billboard/) + +You are installing a billboard and want it to have the largest height. The billboard will have two steel supports, one on each side. Each steel support must be an equal height. + +You have a collection of `rods` which can be welded together. For example, if you have rods of lengths 1, 2, and 3, you can weld them together to make a support of length 6. + +Return the largest possible height of your billboard installation. If you cannot support the billboard, return 0. + +Example 1: + +```text +Input: [1,2,3,6] +Output: 6 +Explanation: We have two disjoint subsets {1,2,3} and {6}, which have the same sum = 6. +``` + +Example 2: + +```text +Input: [1,2,3,4,5,6] +Output: 10 +Explanation: We have two disjoint subsets {2,3,5} and {4,6}, which have the same sum = 10. +``` + +Example 3: + +```text +Input: [1,2] +Output: 0 +Explanation: The billboard cannot be supported, so we return 0. +``` + +Note: + +1. `0 <= rods.length <= 20` +1. `1 <= rods[i] <= 1000` +1. `The sum of rods is at most 5000.` diff --git a/Algorithms/0956.tallest-billboard/tallest-billboard.go b/Algorithms/0956.tallest-billboard/tallest-billboard.go new file mode 100755 index 000000000..0409226c9 --- /dev/null +++ b/Algorithms/0956.tallest-billboard/tallest-billboard.go @@ -0,0 +1,48 @@ +package problem0956 + +// ref: https://leetcode.com/problems/tallest-billboard/discuss/203181/JavaC%2B%2BPython-DP-min(O(SN2)-O(3N2-*-N) + +const maxDiff = 5001 + +func tallestBillboard(rods []int) int { + dp := [maxDiff]int{} + // a pair of sum (a, b) with a > b, then dp[a - b] = b + // 每次都用更大的值去更新 dp[diff] + // 最后想要求的解在 dp[0] 中 + for d := 1; d < maxDiff; d++ { + dp[d] = -10000 + } + // NOTICE: dp[0]=0 + for _, r := range rods { + cur := dp + for d := 0; d+r < maxDiff; d++ { + // add r to the tall side + dp[d+r] = max(dp[d+r], cur[d]) + // add r to the low side + adr := abs(d - r) + dp[adr] = max(dp[adr], cur[d]+min(d, r)) + } + } + return dp[0] +} + +func abs(n int) int { + if n < 0 { + return -n + } + return n +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0956.tallest-billboard/tallest-billboard_test.go b/Algorithms/0956.tallest-billboard/tallest-billboard_test.go new file mode 100755 index 000000000..c68d4846e --- /dev/null +++ b/Algorithms/0956.tallest-billboard/tallest-billboard_test.go @@ -0,0 +1,47 @@ +package problem0956 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + rods []int + ans int +}{ + + { + []int{1, 2, 3, 6}, + 6, + }, + + { + []int{1, 2, 3, 4, 5, 6}, + 10, + }, + + { + []int{1, 2}, + 0, + }, + + // 可以有多个 testcase +} + +func Test_tallestBillboard(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, tallestBillboard(tc.rods), "输入:%v", tc) + } +} + +func Benchmark_tallestBillboard(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + tallestBillboard(tc.rods) + } + } +} diff --git a/Algorithms/0957.prison-cells-after-n-days/README.md b/Algorithms/0957.prison-cells-after-n-days/README.md new file mode 100755 index 000000000..6e1c3fc29 --- /dev/null +++ b/Algorithms/0957.prison-cells-after-n-days/README.md @@ -0,0 +1,44 @@ +# [957. Prison Cells After N Days](https://leetcode.com/problems/prison-cells-after-n-days/) + +There are 8 prison cells in a row, and each cell is either occupied or vacant. + +Each day, whether the cell is occupied or vacant changes according to the following rules: + +- If a cell has two adjacent neighbors that are both occupied or both vacant, then the cell becomes occupied. +- Otherwise, it becomes vacant. + +(Note that because the prison is a row, the first and the last cells in the row can't have two adjacent neighbors.) + +We describe the current state of the prison in the following way: cells[i] == 1 if the i-th cell is occupied, else cells[i] == 0. + +Given the initial state of the prison, return the state of the prison after N days (and N such changes described above.) + +Example 1: + +```text +Input: cells = [0,1,0,1,1,0,0,1], N = 7 +Output: [0,0,1,1,0,0,0,0] +Explanation: +The following table summarizes the state of the prison on each day: +Day 0: [0, 1, 0, 1, 1, 0, 0, 1] +Day 1: [0, 1, 1, 0, 0, 0, 0, 0] +Day 2: [0, 0, 0, 0, 1, 1, 1, 0] +Day 3: [0, 1, 1, 0, 0, 1, 0, 0] +Day 4: [0, 0, 0, 0, 0, 1, 0, 0] +Day 5: [0, 1, 1, 1, 0, 1, 0, 0] +Day 6: [0, 0, 1, 0, 1, 1, 0, 0] +Day 7: [0, 0, 1, 1, 0, 0, 0, 0] +``` + +Example 2: + +```text +Input: cells = [1,0,0,1,0,0,1,0], N = 1000000000 +Output: [0,0,1,1,1,1,1,0] +``` + +Note: + +1. cells.length == 8 +1. cells[i] is in {0, 1} +1. 1 <= N <= 10^9 \ No newline at end of file diff --git a/Algorithms/0957.prison-cells-after-n-days/prison-cells-after-n-days.go b/Algorithms/0957.prison-cells-after-n-days/prison-cells-after-n-days.go new file mode 100755 index 000000000..5827eb658 --- /dev/null +++ b/Algorithms/0957.prison-cells-after-n-days/prison-cells-after-n-days.go @@ -0,0 +1,36 @@ +package problem0957 + +func prisonAfterNDays(cells []int, N int) []int { + N = (N-1)%14 + 1 // every 14 steps is a loop + + n := cells2int(cells) + + for i := 0; i < N; i++ { + n = (^((n >> 1) ^ (n << 1))) & 0x7e + } + + return int2cells(n) +} + +func cells2int(cells []int) int { + res, size := 0, len(cells) + for i := 0; i < size; i++ { + res = res<<1 + cells[i] + } + return res +} + +func int2cells(n int) []int { + bits := uint(8) + cells := make([]int, bits) + i := 0 + for n > 0 { + cells[i] = n & 1 + n >>= 1 + i++ + } + for i, j := 0, int(bits-1); i < j; i, j = i+1, j-1 { + cells[i], cells[j] = cells[j], cells[i] + } + return cells +} diff --git a/Algorithms/0957.prison-cells-after-n-days/prison-cells-after-n-days_test.go b/Algorithms/0957.prison-cells-after-n-days/prison-cells-after-n-days_test.go new file mode 100755 index 000000000..c38959f61 --- /dev/null +++ b/Algorithms/0957.prison-cells-after-n-days/prison-cells-after-n-days_test.go @@ -0,0 +1,57 @@ +package problem0957 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + cells []int + N int + ans []int +}{ + + { + []int{1, 0, 0, 1, 0, 0, 0, 1}, + 826, + []int{0, 1, 1, 0, 1, 1, 1, 0}, + }, + + { + []int{0, 1, 0, 1, 1, 0, 0, 1}, + 1, + []int{0, 1, 1, 0, 0, 0, 0, 0}, + }, + + { + []int{0, 1, 0, 1, 1, 0, 0, 1}, + 7, + []int{0, 0, 1, 1, 0, 0, 0, 0}, + }, + + { + []int{1, 0, 0, 1, 0, 0, 1, 0}, + 1000000000, + []int{0, 0, 1, 1, 1, 1, 1, 0}, + }, + + // 可以有多个 testcase +} + +func Test_prisonAfterNDays(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, prisonAfterNDays(tc.cells, tc.N), "输入:%v", tc) + } +} + +func Benchmark_prisonAfterNDays(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + prisonAfterNDays(tc.cells, tc.N) + } + } +} diff --git a/Algorithms/0958.check-completeness-of-a-binary-tree/README.md b/Algorithms/0958.check-completeness-of-a-binary-tree/README.md new file mode 100755 index 000000000..1e0134676 --- /dev/null +++ b/Algorithms/0958.check-completeness-of-a-binary-tree/README.md @@ -0,0 +1,31 @@ +# [958. Check Completeness of a Binary Tree](https://leetcode.com/problems/check-completeness-of-a-binary-tree/) + +Given a binary tree, determine if it is a complete binary tree. + +Definition of a complete binary tree from [Wikipedia](http://en.wikipedia.org/wiki/Binary_tree#Types_of_binary_trees): + +> In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h. + +Example 1: + +![ex1](ex1.png) + +```text +Input: [1,2,3,4,5,6] +Output: true +Explanation: Every level before the last is full (ie. levels with node-values {1} and {2, 3}), and all nodes in the last level ({4, 5, 6}) are as far left as possible. +``` + +Example 2: + +![ex2](ex2.png) + +```text +Input: [1,2,3,4,5,null,7] +Output: false +Explanation: The node with value 7 isn't as far left as possible. +``` + +Note: + +1. The tree will have between 1 and 100 nodes. \ No newline at end of file diff --git a/Algorithms/0958.check-completeness-of-a-binary-tree/check-completeness-of-a-binary-tree.go b/Algorithms/0958.check-completeness-of-a-binary-tree/check-completeness-of-a-binary-tree.go new file mode 100755 index 000000000..4f3a1d1f9 --- /dev/null +++ b/Algorithms/0958.check-completeness-of-a-binary-tree/check-completeness-of-a-binary-tree.go @@ -0,0 +1,33 @@ +package problem0958 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined. +type TreeNode = kit.TreeNode + +func isCompleteTree(root *TreeNode) bool { + queue := make([]*TreeNode, 1, 128) + + queue[0] = root + hasSeenNil := false + + for len(queue) > 0 { + size := len(queue) + for i := 0; i < size; i++ { + node := queue[i] + if node == nil { + hasSeenNil = true + continue + } + if hasSeenNil { + return false + } + queue = append(queue, node.Left, node.Right) + } + queue = queue[size:] + } + + return true +} diff --git a/Algorithms/0958.check-completeness-of-a-binary-tree/check-completeness-of-a-binary-tree_test.go b/Algorithms/0958.check-completeness-of-a-binary-tree/check-completeness-of-a-binary-tree_test.go new file mode 100755 index 000000000..7c5085f37 --- /dev/null +++ b/Algorithms/0958.check-completeness-of-a-binary-tree/check-completeness-of-a-binary-tree_test.go @@ -0,0 +1,45 @@ +package problem0958 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans bool +}{ + + { + []int{1, 2, 3, 4, 5, 6}, + true, + }, + + { + []int{1, 2, 3, 4, 5, kit.NULL, 7}, + false, + }, + + // 可以有多个 testcase +} + +func Test_isCompleteTree(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, isCompleteTree(root), "输入:%v", tc) + } +} + +func Benchmark_isCompleteTree(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + isCompleteTree(root) + } + } +} diff --git a/Algorithms/0958.check-completeness-of-a-binary-tree/ex1.png b/Algorithms/0958.check-completeness-of-a-binary-tree/ex1.png new file mode 100644 index 000000000..9189e2cf9 Binary files /dev/null and b/Algorithms/0958.check-completeness-of-a-binary-tree/ex1.png differ diff --git a/Algorithms/0958.check-completeness-of-a-binary-tree/ex2.png b/Algorithms/0958.check-completeness-of-a-binary-tree/ex2.png new file mode 100644 index 000000000..9067fe328 Binary files /dev/null and b/Algorithms/0958.check-completeness-of-a-binary-tree/ex2.png differ diff --git a/Algorithms/0959.regions-cut-by-slashes/1.png b/Algorithms/0959.regions-cut-by-slashes/1.png new file mode 100644 index 000000000..eeed41bb0 Binary files /dev/null and b/Algorithms/0959.regions-cut-by-slashes/1.png differ diff --git a/Algorithms/0959.regions-cut-by-slashes/2.png b/Algorithms/0959.regions-cut-by-slashes/2.png new file mode 100644 index 000000000..4bce5fb85 Binary files /dev/null and b/Algorithms/0959.regions-cut-by-slashes/2.png differ diff --git a/Algorithms/0959.regions-cut-by-slashes/3.png b/Algorithms/0959.regions-cut-by-slashes/3.png new file mode 100644 index 000000000..84909b990 Binary files /dev/null and b/Algorithms/0959.regions-cut-by-slashes/3.png differ diff --git a/Algorithms/0959.regions-cut-by-slashes/4.png b/Algorithms/0959.regions-cut-by-slashes/4.png new file mode 100644 index 000000000..278de2030 Binary files /dev/null and b/Algorithms/0959.regions-cut-by-slashes/4.png differ diff --git a/Algorithms/0959.regions-cut-by-slashes/5.png b/Algorithms/0959.regions-cut-by-slashes/5.png new file mode 100644 index 000000000..8f02f3896 Binary files /dev/null and b/Algorithms/0959.regions-cut-by-slashes/5.png differ diff --git a/Algorithms/0959.regions-cut-by-slashes/README.md b/Algorithms/0959.regions-cut-by-slashes/README.md new file mode 100755 index 000000000..5eaeb18dd --- /dev/null +++ b/Algorithms/0959.regions-cut-by-slashes/README.md @@ -0,0 +1,85 @@ +# [959. Regions Cut By Slashes](https://leetcode.com/problems/regions-cut-by-slashes/) + +In a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, \, or blank space. These characters divide the square into contiguous regions. + +(Note that backslash characters are escaped, so a \ is represented as "\\".) + +Return the number of regions. + +Example 1: + +```text +Input: +[ + " /", + "/ " +] + +Output: 2 +Explanation: The 2x2 grid is as follows: +``` + +![1](1.png) + +Example 2: + +```text +Input: +[ + " /", + " " +] +Output: 1 +Explanation: The 2x2 grid is as follows: +``` + +![2](2.png) + +Example 3: + +```text +Input: +[ + "\\/", + "/\\" +] +Output: 4 +Explanation: (Recall that because \ characters are escaped, "\\/" refers to \/, and "/\\" refers to /\.) +The 2x2 grid is as follows: +``` + +![3](3.png) + +Example 4: + +```text +Input: +[ + "/\\", + "\\/" +] +Output: 5 +Explanation: (Recall that because \ characters are escaped, "/\\" refers to /\, and "\\/" refers to \/.) +The 2x2 grid is as follows: +``` + +![4](4.png) + +Example 5: + +```text +Input: +[ + "//", + "/ " +] +Output: 3 +Explanation: The 2x2 grid is as follows: +``` + +![5](5.png) + +Note: + +1. 1 <= grid.length == grid[0].length <= 30 +1. grid[i][j] is either '/', '\', or ' '. \ No newline at end of file diff --git a/Algorithms/0959.regions-cut-by-slashes/regions-cut-by-slashes.go b/Algorithms/0959.regions-cut-by-slashes/regions-cut-by-slashes.go new file mode 100755 index 000000000..59a4c66c1 --- /dev/null +++ b/Algorithms/0959.regions-cut-by-slashes/regions-cut-by-slashes.go @@ -0,0 +1,81 @@ +package problem0959 + +func regionsBySlashes(grid []string) int { + m := len(grid) + + size := m * m * 4 + u := newUnion(size) + + // cut every square to 4 parts, and mark them + // \top/ + // \0/ + // left 3 X 1 right + // /2\ + // /down\ + for i := 0; i < m; i++ { + for j := 0; j < m; j++ { + baseIndex := (i*m + j) * 4 + top := baseIndex + 0 + right := baseIndex + 1 + down := baseIndex + 2 + left := baseIndex + 3 + switch grid[i][j] { + case '\\': + u.unite(top, right) + u.unite(down, left) + case '/': + u.unite(top, left) + u.unite(down, right) + default: + u.unite(top, right) + u.unite(right, down) + u.unite(down, left) + } + // right part unites right square's left + if j+1 < m { + rsl := baseIndex + 4 + 3 + u.unite(right, rsl) + } + // down part unites down square's top + if i+1 < m { + dst := baseIndex + 4*m + u.unite(down, dst) + } + } + } + + return u.count +} + +type union struct { + parent []int + count int +} + +func newUnion(size int) *union { + parent := make([]int, size) + for i := range parent { + parent[i] = i + } + return &union{ + parent: parent, + count: size, + } +} + +func (u *union) find(i int) int { + if u.parent[i] == i { + return i + } + u.parent[i] = u.find(u.parent[i]) + return u.parent[i] +} + +func (u *union) unite(x, y int) { + xp, yp := u.find(x), u.find(y) + if xp == yp { + return + } + u.parent[yp] = xp + u.count-- +} diff --git a/Algorithms/0959.regions-cut-by-slashes/regions-cut-by-slashes_test.go b/Algorithms/0959.regions-cut-by-slashes/regions-cut-by-slashes_test.go new file mode 100755 index 000000000..b0a1d7964 --- /dev/null +++ b/Algorithms/0959.regions-cut-by-slashes/regions-cut-by-slashes_test.go @@ -0,0 +1,79 @@ +package problem0959 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid []string + ans int +}{ + + { + []string{ + " /", + "/ ", + }, + 2, + }, + + { + []string{ + "/", + }, + 2, + }, + + { + []string{ + " /", + " ", + }, + 1, + }, + + { + []string{ + "\\/", + "/\\", + }, + 4, + }, + + { + []string{ + "/\\", + "\\/", + }, + 5, + }, + + { + []string{ + "//", + "/ ", + }, + 3, + }, + + // // 可以有多个 testcase +} + +func Test_regionsBySlashes(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, regionsBySlashes(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_regionsBySlashes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + regionsBySlashes(tc.grid) + } + } +} diff --git a/Algorithms/0960.delete-columns-to-make-sorted-iii/README.md b/Algorithms/0960.delete-columns-to-make-sorted-iii/README.md new file mode 100755 index 000000000..90c496a9e --- /dev/null +++ b/Algorithms/0960.delete-columns-to-make-sorted-iii/README.md @@ -0,0 +1,44 @@ +# [960. Delete Columns to Make Sorted III](https://leetcode.com/problems/delete-columns-to-make-sorted-iii/) + +We are given an array `A` of `N` lowercase letter strings, all of the same length. + +Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. + +For example, if we have an array `A = ["babca","bbazb"]` and deletion indices `{0, 1, 4}`, then the final array after deletions is `["bc","az"]`. + +Suppose we chose a set of deletion indices D such that after deletions, the final array has **every element (row) in lexicographic order**. + +For clarity, `A[0]` is in lexicographic order (ie. `A[0][0] <= A[0][1] <= ... <= A[0][A[0].length - 1]), A[1]` is in lexicographic order (ie. `A[1][0] <= A[1][1] <= ... <= A[1][A[1].length - 1]`), and so on. + +Return the minimum possible value of `D.length`. + +Example 1: + +```text +Input: ["babca","bbazb"] +Output: 3 +Explanation: After deleting columns 0, 1, and 4, the final array is A = ["bc", "az"]. +Both these rows are individually in lexicographic order (ie. A[0][0] <= A[0][1] and A[1][0] <= A[1][1]). +Note that A[0] > A[1] - the array A isn't necessarily in lexicographic order. +``` + +Example 2: + +```text +Input: ["edcba"] +Output: 4 +Explanation: If we delete less than 4 columns, the only row won't be lexicographically sorted. +``` + +Example 3: + +```text +Input: ["ghi","def","abc"] +Output: 0 +Explanation: All rows are already lexicographically sorted. +``` + +Note: + +1. 1 <= A.length <= 100 +1. 1 <= A[i].length <= 100 \ No newline at end of file diff --git a/Algorithms/0960.delete-columns-to-make-sorted-iii/delete-columns-to-make-sorted-iii.go b/Algorithms/0960.delete-columns-to-make-sorted-iii/delete-columns-to-make-sorted-iii.go new file mode 100755 index 000000000..57cd0fd89 --- /dev/null +++ b/Algorithms/0960.delete-columns-to-make-sorted-iii/delete-columns-to-make-sorted-iii.go @@ -0,0 +1,40 @@ +package problem0960 + +// ref: https://leetcode.com/problems/delete-columns-to-make-sorted-iii/discuss/205679/C%2B%2BJavaPython-Maximum-Increasing-Subsequence + +func minDeletionSize(A []string) int { + m, n := len(A), len(A[0]) + res := n - 1 + + dp := make([]int, n) + // dp[i] means the longest subsequence ends with i-th element. + // For all i < j, if A[][i] <= A[][j], then dp[j] = max(dp[j], dp[i] + 1) + for i := 0; i < n; i++ { + dp[i] = 1 + } + + for j := 0; j < n; j++ { + for i := 0; i < j; i++ { + k := 0 + for ; k < m; k++ { + if A[k][i] > A[k][j] { + break + } + } + if k == m && // compared all strings + dp[j] < dp[i]+1 { // find longer sub string + dp[j] = dp[i] + 1 + } + } + res = min(res, n-dp[j]) + } + + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0960.delete-columns-to-make-sorted-iii/delete-columns-to-make-sorted-iii_test.go b/Algorithms/0960.delete-columns-to-make-sorted-iii/delete-columns-to-make-sorted-iii_test.go new file mode 100755 index 000000000..925375890 --- /dev/null +++ b/Algorithms/0960.delete-columns-to-make-sorted-iii/delete-columns-to-make-sorted-iii_test.go @@ -0,0 +1,73 @@ +package problem0960 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []string + ans int +}{ + + { + []string{"aaaabaa"}, + 1, + }, + + { + []string{"babca", "bbazb"}, + 3, + }, + + { + []string{"edcba"}, + 4, + }, + + { + []string{"ghi", "def", "abc"}, + 0, + }, + + { + []string{ + "deehdecfcgegffegghfhfaagcaaffbfahcfaghgdfggbbddbff", + "dchhgcbahdbdgbbaafhbgfggcbebfacdebhfgcfaafcgbgbggg", + "hehdggagfabdfbhegebhaaddcaghhegeegdgegagehhdhheecd", + "fhbbagbdffedafacbeahddbgagggdafceeabaffhhhhcedcfbh", + "caaefgdgefeahcgfgccaacdfabdgdbdhdbhbhfadbeaegbbdce", + "habgbahaeebeacccbdhfhddegfebheeffdbcbgfahhgbhcheeb", + "gfaaedgcachcehgdghebbhegbfagdgcdcgebddbdccbedbbhcd", + "badaebdbdgeadbfgchaegaddgdhdgaeaaedagacgbdecfdghca", + "eefcceffcggeefbecaceadbdcfccgbfgffgahfgeebafdcfhhb", + "aeebdahabfecbafgbcchbhdeecaadaccbahghcbdcfaeagehha", + }, + 48, + }, + + { + []string{"phmanpfeerddicoacphbpmkfdhjjokpapcfimqiaimrrrbiikhfafjlnsimblbogopfostsosfkebcioimpepaojer", "otpdmoeqqfaohfihkfeqqekhmoeiftkiqscnspshdbbhdgshbgllqqloirbghcdijsiboscqedjnppgltfftcbppdf", "ameslfrhjroforrsiagccbjngeetljsohijaslqccascnmbotaqcneccctfkormncfahfthgghimianlmgfedapngp", "rhafnippttlifdfmgpbrirfnklickrbaabnhjkqlseicsrmnpagakrcjsgrbfctdtifdreeitkqopnfjaggelgbhri", "nbtimdrfbdamdoigmkoccfljkndqefagioitjqskmbgejfihlqjmppsfehhqofrohnbqbklrsllkdstbrqpagfihoc", "gedokkanbsmnobeqakitkfsanafgfsdpmcmfofjcasgkbtffaoagpkdkbchlscergoqasqsekseatcjilmdliisjnb", "isohlmsspfqjjatqjhjgimjhcindfrqcnnjcojoebqsoajatbiottjhielqpaophidljbdohdddgohmpmgjjmdtbfl", "hffrakhnrgcgehaiispoijhjfrfpqmkqjqsrrogqbjdooriotiptoqajlccmdefpomggsetbkmkedphfgptaaasgjm", "fckgathcofjtadfjksphjfitoanrgfcqejdqsikjmrqtmtplmshbhdkaemblcncmgsmeisrrkgcqhdjhcarticolkn", "blikjgtmrfjgagtmpckjsdlkltbccpkileprmjmlmmidfbdplclatjdgqqmdrmoagharoshthpmjkahahtqfceshbg", "pciskclgnoteonjmcqgbscgbrsrafnrfbobgmqldmimorelgebnqebemqrlsdjaskhodkqprathdkahojgepfkjjpj", "qnicoehgsfhfcasqsipfhojbsmsdcdbdfbmepptjoideanhcadtqkeektgggskgbncmhqqskafohcdabgtoardhhhf", "bsncdfabthigiaglfipcastarjglrcccpadmsogjfnpfkmtkhgdkettshitbgoblfpftbnqckagrgjqkqfktgcsget", "lmgddsctcplqfedrhgophebkjgmpidieteogqhkqsjjfbedkenkschaakofmkndkrnfkbijckdgtimorfrecedhpta", "klljccpmdhntecipglsoijakoaoashagnhdjeseafbaprtgajhmogclrdpoldrpoqqgdomajrjciojltdjfspbrqdd", "odqaopclftopeljclltneknakqdiojdqbiaaijmsddcqdpaqaconptcbfpkghmspqkdnnnepenbrjelhidrhgkcoqm", "bqcdehrsjiggekrihmsojddoplmfcjgjhlrqnqgldqoadneebjtfffgrfdsonfpqmatoolknafndokpbnctgcamorf", "getpaimcjjnosietldpqkafnkqnfrarastqrqfmrogjtmnqhbbmppmbrahaofheaotqfpmpgshhrghsifiimiftoct", "kbqmgnarmsbmfejoabpoicnfabeabmpndrlsqecqdbhnthptrgqksfnkceltkmdedkjrnmdefqidtlninehmccdfmj", "beonkipjkbffprdjitprshflopstjjjclogpfrobhcmecqeppaolklhledbskocfekfshaishrlpjiapcgntkmbbgi", "llkbnfahptmeoisbjalrtttjcjmkoqgpeagnikmfmrmboimgclalbbqgdhgsgictnpbsgfgqeiapcafrgomlpirptl", "etcrribptmqaaimiolnlkfclaaabaghainraelqbeeqfngdsndmkggnblkacttrkmnlijophqiemsbjbgsnsnadabs", "qbfqpkdgmnopmtispdnntjkbgialiqcccfhpilfmnqsfjalgsiilqgkcthsmfktqidldfngpihorgposlshbenrdgi", "tcmnppsrtrimllheanbcpqerijhrqtfflglnkmcrktdihncoopadmdmknokkjddekokprcscedrokipctokbqtdhjf", "tnomaqbmdogejfsmdjfeidmldelnsgmfiastibhdqspnlihsmfhgeqdilbsietssnbodaamtihpsbndgttmetqsldh", "qinaamidenlabreftbbpshdsiikeitkofjnlntplkprnrdsrrbjljnjshkmsorignmrtnifldtsdmhislsjhcehdci", "rnshsmiliqfocjqehhojbiampbmjioqifrohotlektpblahthhpdbarefaqhefnbfkfeoljtlcbnonogkomdjmargn", "totcgptritgadkitcpfkmpfreaagldcokgcbnljrrcqppdqohsqbfnkrlgkngocnaaaaalhoshcpdflbtsjnkjptco", "tghpensgnjpjpbgnhmoafgciktkbtomsiairkdssrterdeobdoqrtmagckrpphfeqtmelbkenkbrgfmnokstmljorr", "dgfqrmlhdnijboqtbpidodfkdciaoemlblpljebajgmgdcsfiogltktadotbssonkefdtghdhjpbflhiostdmheqcm", "oincdrsdfqffedirnqcgiqqtpjpqfamcarhhhsbhflhbmiidknkbmfrcsjsdakgcnsrroeqiqttttppjphfghajcbf", "nppnlarjsenpktoatososblhiibenttdojkcpkfjgntihhtsoshtqsgdgtpkekakpmplpoakkpekliqgadecbbrjhe", "aacgacsteskloracbrdoiksbnfnblqdceahlhdknecabtqcljjgkhmkjqkbfqjlnlflfkgmptarbmnaeepehfecghi", "iiesrnktlemospboogeqipoobrdqoqbholpjtpmpgfgpktlgjmphqqqsgaioiqhpqecjrgrdipootsqhatrelraprf", "inkjdrqcipjkjrkoorkjinhmlsniecrpeoltteanjrjpbjgpjgngqnebejsaastckhdcsqtnorekefomligmcojiak", "pngtnomclgqoghcgkjkdktnamlemrbldldejjqjsfigqtgrrakmciiceqtshqkssklffbdgphlhaqslenfekgrskan", "gqljatqmbcblfcrppcqpmbnaiqpifkoecgjnfigsbqhamonjoiegjlabphteqgjifnsorpdgqmjdhpbebqscrpplsh", "snjisfprkjftlsoqglqbimtjqtmdflpqnqophiqpkbmahmlgtmrborqlkcdrolildtdlgqngmgslnltfckjniaacgn", "qqcbqkqasqsjrgkelodadsjsepqpepkkjjkiepngnhqhaheiitfckhplodiqhrnagsaqscrotdchdoaimsrfmcfbih", "idjqlejjkgqjatmqkmqjispfjjccbmjbsssjqmqnmjnksbnghgfltgfoesdqjjfiepllrcgdmngmpabkkjsnbgtegb", "tsqdeirrckbsdrikrhemedrgfqlaphlngkdopsjengmsefpraeekcntqmbedmqmsjleonfjrmhcelckjgctribetgl", "qhdfeicofasrdgnsitcjhkankjinmdhdtbgmlqlofglkjrssflbaeafblljlerphsmtmkjqcitgbtkgdfmcniemcac", "qldmtrdejgdhtnlenbhhkomlhppqibjcghbecaifnfmhkqjshopgarlpthckkbipabkrqfjajbihqbssrmgssgnqcp", "aoiclbfitikoatdgajrlghohadtqcgrnbcbrjjgipisbhismlrcgskbecgpalggmjefjcsnfgrcrftleanncrjnscj", "tfchpjfpmsoqimapoosclrstiqtgtkotgtnjiktqpasikegpqrlpthcsptairccfmgtqtjcrnmfepnpqonhjgpckep", "jicqaibcjbcrtqsqtsidtklcserqbtfqnekhsjcafdaldaksbsalgjteenoghkfdqcflhpklfkbrtbkogchqncoebl", "tbecetgjafhcnhadrbcefsnarolejrccdbjdtaqccqhthjhqbcfadqbplsqhhdkctlfkbcrdlmrbftjdmjgbephlhs", "ehmckejgmngkjgdfmicpftkilhbpfbdierbhaclcpggdakdmracfkbintdjbkpdhlaqrotamerjndeoajnrpfqnlse", "qiohbqfehmtmnhrimiisajraihalfdbggmcmhsgncihgmhrncnoospairaorapprmfetebledstkdafthtopskcrss", "llkbigjdctajlqaictbgigakfocdaapfdhmeitrpdmqoonefibdkssmtmrfnbmsolqrrigamiclbaqtsrndlhitqko", "ejjnrassbsdhhhmjbrkpbnjkdbhtjhiqkfelpdmnbnfijgtocspmdefigflhtlmpcpognefgebchgdfihetgmrmpbg", "cbpjaepsidnjcmspddsfslcaggmagicmqldldkkkbnbagdtbkfketakrfgidejhpjhdpobrejfmjntljjhjrdceptq", "kajbttoefedrhlrrkcpnlkqtlgsrblipecjjtrothhadqpalmnjmgbbqjnfjshmqckmsnarhqsicqqcgbrcimaocns", "ossbaroctfpaaamtakedlsbcsgorkgbddrgaticemnqkjoeroptkpeiacqglfhaoefefribhndjborprqsredkhqem", "cgmfpghgctochmgbarlcnongsgsgnfcnstoaapkrtnlianbrpokqgtnppniaohpimndrrsqitcdijiegrabpkhrfdk", "coclqpoqlhnofrtdcfjagidilpsdiboqtogelepehgrtsigkqqqftmpnefrngorithrgscpssspffhmschpqandpae", "depikqsrtfmstreabeeebhdmmiqlgheijimdpsejqfohfjjksrgorrlgbbtoaitosbaapjgrjthqpsksltafrbogkt", "bcgofiomhshnpdeokefjnactfomsforldadrtibefnkldppkganfeofhfllilmiatlhblspflbacthoiasrslkljqs", "mmalsspekhhmfdeprokntcsjeiqhjissreiatntjfgoaoleordieqclfomrsgmqmfkejtcjetonrhmtorsnaadlgab", "fnfojpijdepiheaqktkkglmrrcmcgbqdrcrerphgrrcdmfahpcrfqocgnrckfniktihbjmndkcmtmeqdelhgrndnan", "elpsetrdbshkggtnsfqmhahnaifdiqccfraeobginifkgtpqghhjrkgebdbbefienqqimigcsedtcqogsdfpcoijql", "lbdljabrerneobnbtfahiigncgthnkhjkbstbjmtthrcbrqtdfctgeihlptfjrsahpptqtgobpajphchgkiqleghgj", "knrgleatafghlhklpfmsdqilmcthtqrfisidmglpimeqaihjfsfslkopickkhhifoicciqsjaqfsqhpisrqllrkdlt", "ftocrlllikdeneosnntacblnqckcgjrbdnftcothadsjsjinnfnbjohkcnqhnatbeqlbokcbifiqhosbmdtqgrsmds", "jcamabaeerjefqhnfppbccsspqloaiifshsoetqcbbadtmgorelncrpombhdnrmmsmpedghrepkhioammcbhfilmld", "pkotmbfpdeclrfpgdimnjehcpbtjlhrdboggkpphscqaggcklcenfaroiniqghlatdfpelrermnltbleoclcaokmns", "fhbaacenerjdshderihnetnpratblmmjbmcdrsnjcajjcpqjibogahtgsarohmtimolgiobotibmfibppaimtmrftf", "kmsgjjgfpdhmhilkeiasqkfmgijljkttslqmddasgcjastgbcsgjhdlndjdlrmodopgblpbinjtilejblfhocnlppt", "aeedambescttbpsotgikpsabpihaltggmscmkodpkjkfjphmtfananigdtibgiblqsiodnrlgneqlbqtondfjrhroa", "ahqklnslrrpnrmeogafedeionhjgjnqkpkkbqamffrotjckqtokisbgntkeilosbfgtceasqmgjsnctatrdbmitreg", "ketmofdhlmakcjgbpcptpncbgmnjloeadndactassdtfkgebmanrltbcnhgsofpgadlajbeofajrnojlihkbnklbee", "fnjbssaojginmdcrschkcrmlsbihmrrdmntcqllhtkbhpotqdrqhjrtmbhjrasschsmarsgfikgrjberdbnkmobcet", "bemeodanetbndqmesjcspoksbcsicootbipabjrjieboqqqlssknkbmamapalhhracjftirkckirjcdeaisaebkehg", "qfhbpacfklbbiabnsimnbrsmjbrshjaoltofliajdgktdlsoejlnkapblpoedpnttoqrsrbsdlsciegtmljoleqhnk", "oiccnkflglqmjjsffcjkggqggblbpsjlrbbdbroikhsqqbmqimobnkpslnkagsfqhhhjiotttdkrcgkaktfkeaseoc", "emqardrgiqsalmongmefggdhqajlptfmcnoppinhiqltsjnicpbqtjamodkhqteicdkqnnoragtqfqcaeegfkftkpt", "gmimbbotkrsmfahrlcleagctndasggiiscapotkqoagelnfbcfqbqelkmdgrihdpaottsoegeabfroltebqiemhtsd", "dfsggtglaanlsrgjatsnhfcpaisccndjecsjnalbclmbtooqodpftbcoojqmfqaqteossldjkgneatdtpqolkokoil", "kqpilrcqoqtttnchomtscaakronjbhgtkraogsqielhicdjnskopnhaopkkiakspgtnrnrchoqosmdtjojeatoplqd", "trcckrjtmngokchcrcbharbnflqdjbnftdhlbrqhhpddolpngsknjdtsglircerrpplnlbjfbblkfmobdeoqjsijkb", "aqlqecbhofrhgjlnknaifhimrmetinfdtrlocalfnbkkofekfhnmlrtehncjqchlrpcndtqmhmkgsdprlbsragkonq", "iphmfigoffaqrfelreqgtnmbsmetennijejargpocdagagremtkcjkigfmqjrjcbrblfkktalrifdnirfphqhapmmk", "drctfeaeqdftkcqrkonnlisaegqtctsmjsbjplpqqodrmkltaltprfdhlkiqeililjmjbqrnlhficmkbbkpfdksosm", "lgfkpjtellkdghbjoblgenjodnmjjpqosjkjhedfirlcpltelhlkrojegkmbhcckifgfolglnbclgeaacsotrempjr", "tpafgdnpfleqnsjofjfgqkfcjrrqkccarrrskbskpcroddeatqhfmjhqlfqedqhrpfnarrfsjocopjhmbefoljqsqg", "oomodtqsalqfaqnpgcqmbmrsrqnkjomieohkhdmbkajhksjcbqlmgsfrbhsbreihjsgtbdeapcotigfkddkksoabaq", "graoppjibblfkrirsdrithbamqfogllfcgckjjmlgiaeepqjgnbsjnonfnqmikfmfeihpeoldjjbbgqleqmccnkirg", "ghrknahmbgtaiadhitotcroqkhsgjabahdnpcsrnfrlkjtgslrcbabhcansiecmmmjifrejtmcgbfhrhjobmrleqre", "qabesfqqhjimbshinbbadaplpmrrtinrhidelqdmjoogbhmdsktdmdtoisbbckaligtnqtfjgmpadfnihbrpqtlnrf", "asqqlsmjdtemglsmtmbekktqpmqjshfjkesentmcnhlgldkmlngannlrdohpjjmshiofcmplhaorhiacohooqbjetb"}, + 89, + }, + + // 可以有多个 testcase +} + +func Test_minDeletionSize(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minDeletionSize(tc.A), "输入:%v", tc) + } +} + +func Benchmark_minDeletionSize(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minDeletionSize(tc.A) + } + } +} diff --git a/Algorithms/0961.n-repeated-element-in-size-2n-array/README.md b/Algorithms/0961.n-repeated-element-in-size-2n-array/README.md new file mode 100755 index 000000000..1a7db68f5 --- /dev/null +++ b/Algorithms/0961.n-repeated-element-in-size-2n-array/README.md @@ -0,0 +1,32 @@ +# [961. N-Repeated Element in Size 2N Array](https://leetcode.com/problems/n-repeated-element-in-size-2n-array/) + +In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeated N times. + +Return the element repeated N times. + +Example 1: + +```text +Input: [1,2,3,3] +Output: 3 +``` + +Example 2: + +```text +Input: [2,1,2,5,3,2] +Output: 2 +``` + +Example 3: + +```text +Input: [5,1,5,2,5,3,5,4] +Output: 5 +``` + +Note: + +1. 4 <= A.length <= 10000 +1. 0 <= A[i] < 10000 +1. A.length is even \ No newline at end of file diff --git a/Algorithms/0961.n-repeated-element-in-size-2n-array/n-repeated-element-in-size-2n-array.go b/Algorithms/0961.n-repeated-element-in-size-2n-array/n-repeated-element-in-size-2n-array.go new file mode 100755 index 000000000..557cd8a07 --- /dev/null +++ b/Algorithms/0961.n-repeated-element-in-size-2n-array/n-repeated-element-in-size-2n-array.go @@ -0,0 +1,13 @@ +package problem0961 + +func repeatedNTimes(A []int) int { + hasSeen := [10000]bool{} + var res int + for _, res = range A { + if hasSeen[res] { + break + } + hasSeen[res] = true + } + return res +} diff --git a/Algorithms/0961.n-repeated-element-in-size-2n-array/n-repeated-element-in-size-2n-array_test.go b/Algorithms/0961.n-repeated-element-in-size-2n-array/n-repeated-element-in-size-2n-array_test.go new file mode 100755 index 000000000..05e328cfe --- /dev/null +++ b/Algorithms/0961.n-repeated-element-in-size-2n-array/n-repeated-element-in-size-2n-array_test.go @@ -0,0 +1,47 @@ +package problem0961 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{1, 2, 3, 3}, + 3, + }, + + { + []int{2, 1, 2, 5, 3, 2}, + 2, + }, + + { + []int{5, 1, 5, 2, 5, 3, 5, 4}, + 5, + }, + + // 可以有多个 testcase +} + +func Test_repeatedNTimes(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, repeatedNTimes(tc.A), "输入:%v", tc) + } +} + +func Benchmark_repeatedNTimes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + repeatedNTimes(tc.A) + } + } +} diff --git a/Algorithms/0962.maximum-width-ramp/README.md b/Algorithms/0962.maximum-width-ramp/README.md new file mode 100755 index 000000000..bc29f2c09 --- /dev/null +++ b/Algorithms/0962.maximum-width-ramp/README.md @@ -0,0 +1,28 @@ +# [962. Maximum Width Ramp](https://leetcode.com/problems/maximum-width-ramp/) + +Given an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i] <= A[j]. The width of such a ramp is j - i. + +Find the maximum width of a ramp in A. If one doesn't exist, return 0. + +Example 1: + +```text +Input: [6,0,8,2,1,5] +Output: 4 +Explanation: +The maximum width ramp is achieved at (i, j) = (1, 5): A[1] = 0 and A[5] = 5. +``` + +Example 2: + +```text +Input: [9,8,1,0,1,9,4,0,4,1] +Output: 7 +Explanation: +The maximum width ramp is achieved at (i, j) = (2, 9): A[2] = 1 and A[9] = 1. +``` + +Note: + +- 2 <= A.length <= 50000 +- 0 <= A[i] <= 50000 \ No newline at end of file diff --git a/Algorithms/0962.maximum-width-ramp/maximum-width-ramp.go b/Algorithms/0962.maximum-width-ramp/maximum-width-ramp.go new file mode 100755 index 000000000..daa0a7d0c --- /dev/null +++ b/Algorithms/0962.maximum-width-ramp/maximum-width-ramp.go @@ -0,0 +1,34 @@ +package problem0962 + +func maxWidthRamp(A []int) int { + size := len(A) + + stack := make([]int, 1, size) + top := 0 + for i := 1; i < size; i++ { + if A[stack[top]] > A[i] { + stack = append(stack, i) + top++ + } + } + + res := 0 + for j := size - 1; j >= 0 && top >= 0; j-- { + width := 0 + for top >= 0 && A[stack[top]] <= A[j] { + width = j - stack[top] + stack = stack[:top] + top-- + } + res = max(res, width) + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0962.maximum-width-ramp/maximum-width-ramp_test.go b/Algorithms/0962.maximum-width-ramp/maximum-width-ramp_test.go new file mode 100755 index 000000000..60da4939b --- /dev/null +++ b/Algorithms/0962.maximum-width-ramp/maximum-width-ramp_test.go @@ -0,0 +1,56 @@ +package problem0962 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{6, 7, 8, 8, 6, 5, 5, 8, 2, 2}, + 7, + }, + + { + []int{312, 433, 973, 998, 384, 703, 589, 547, 234, 781, 447, 22, 865, 613, 683, 851, 564, 845, 430, 440, 898, 383, 244, 643, 808, 304, 650, 847, 314, 378, 494, 487, 417, 323, 837, 570, 799, 460, 2, 903, 83, 226, 835, 146, 666, 154, 602, 705, 336, 40, 801, 19, 448, 726, 539, 72, 511, 694, 527, 79, 69, 394, 875, 415, 942, 756, 398, 347, 899, 228, 952, 119, 187, 92, 335, 64, 577, 929, 100, 933, 893, 513, 799, 742, 913, 928, 400, 450, 289, 67, 434, 853, 817, 967, 452, 796, 309, 188, 728, 497, 977, 726, 618, 987, 445, 395, 636, 209, 285, 788, 63, 329, 289, 826, 2, 450, 990, 126, 394, 380, 438, 900, 738, 549, 625, 657, 732, 700, 768, 523, 711, 328, 337, 179, 960, 660, 873, 739, 247, 326, 608, 281, 337, 337, 578, 441, 185, 199, 379, 292, 963, 724, 424, 252, 594, 110, 227, 921, 538, 849, 212, 22, 898, 163, 132, 911, 91, 206, 183, 879, 723, 919, 276, 257, 734, 395, 122, 104, 818, 987, 554, 679, 373, 127, 953, 847, 443, 509, 471, 657, 53, 686, 532, 393, 596, 918, 643, 777, 192, 10, 512, 490, 371, 363, 67, 861, 898, 555, 942, 35, 725, 584, 941, 767, 340, 89, 702, 207, 195, 386, 510, 233, 80, 434, 940, 804, 767, 618, 382, 310, 977, 527, 683, 8, 46, 233, 712, 310, 847, 111, 545, 405, 224, 29, 126, 407, 623, 466, 775, 131, 364, 588, 591, 982, 902, 354, 871, 554, 808, 118, 993, 176, 496, 903, 350, 370, 749, 941, 581, 988, 532, 984, 537, 404, 297, 750, 654, 580, 162, 976, 42, 153, 694, 194, 235, 773, 291, 102, 556, 795, 457, 113, 466, 432, 569, 2, 206, 746, 94, 77, 712, 758, 550, 451, 107, 493, 695, 386, 615, 767, 560, 175, 65, 599, 314, 77, 175, 611, 550, 210, 457, 122, 769, 411, 330, 163, 692, 504, 475, 297, 618, 360, 875, 291, 933, 766, 394, 965, 447, 478, 85, 577, 123, 445, 584, 525, 634, 883, 221, 618, 69, 167, 907, 751, 176, 375, 491, 780, 677, 696, 106, 317, 406, 29, 546, 457, 870, 621, 868, 951, 442, 570, 958, 331, 346, 194, 378, 944, 400, 739, 120, 665, 403, 267, 952, 71, 833, 486, 322, 494, 333, 402, 315, 159, 429, 104, 606, 0, 922, 745, 419, 45, 313, 99, 396, 928, 246, 139, 88, 55, 239, 158, 487, 313, 409, 708, 107, 967, 6, 192, 301, 100, 25, 121, 596, 233, 669, 571, 614, 662, 149, 715, 505, 558, 817, 122, 269, 643, 584, 137, 749, 846, 605, 33, 897, 233, 349, 209, 991, 932, 448, 699, 310, 223, 460, 501, 751, 605, 694, 970, 0, 758, 540, 261, 4, 458, 89, 75, 565, 63, 672, 306, 149, 452, 163, 971, 392, 603, 590, 134, 250, 47, 738, 472, 17, 160, 855, 80, 499, 950, 338, 355, 241, 599, 580, 666, 901, 21, 999, 197, 695, 771, 599, 278, 883, 334, 385, 482, 286, 62, 968, 149, 29, 259, 889, 890, 265, 882, 436, 397, 160, 268, 973, 57, 284, 296, 576, 242, 836, 204, 344, 782, 539, 327, 542, 795, 825, 813, 475, 430, 145, 481, 508, 613, 348, 954, 827, 258, 469, 417, 933, 629, 242, 90, 425, 686, 494, 47, 202, 320, 804, 834, 3, 914, 722, 798, 868, 48, 595, 973, 533, 786, 834, 852, 621, 45, 458, 953, 347, 390, 135, 405, 596, 47, 112, 433, 854, 522, 575, 961, 18, 131, 445, 964, 237, 893, 279, 237, 415, 741, 712, 832, 428, 190, 288, 291, 648, 724, 583, 952, 575, 893, 250, 221, 471, 128, 921, 200, 855, 684, 258, 835, 86, 689, 777, 122, 974, 115, 575, 196, 739, 996, 572, 355, 202, 280, 333, 650, 520, 286, 409, 174, 976, 852, 335, 812, 147, 297, 666, 828, 234, 763, 61, 132, 550, 124, 105, 511, 438, 997, 199, 31, 471, 760, 134, 283, 283, 494, 312, 405, 767, 225, 944, 214, 512, 206, 738, 720, 833, 212, 65, 225, 495, 380, 71, 852, 309, 345, 723, 857, 825, 109, 649, 901, 356, 324, 903, 654, 953, 180, 777, 142, 321, 929, 654, 583, 145, 878, 632, 519, 648, 766, 64, 239, 892, 898, 498, 883, 645, 567, 307, 342, 356, 97, 882, 548, 589, 780, 755, 672, 768, 494, 175, 379, 155, 115, 121, 148, 887, 876, 49, 898, 81, 617, 976, 401, 781, 308, 220, 74, 698, 569, 976, 407, 500, 389, 18, 69, 344, 712, 37, 198, 398, 708, 982, 500, 407, 632, 39, 900, 967, 675, 730, 69, 266, 75, 158, 732, 854, 34, 697, 528, 936, 721, 329, 460, 891, 595, 902, 774, 306, 109, 51, 253, 597, 648, 318, 571, 419, 915, 266, 803, 39, 851, 369, 482, 857, 616, 858, 301, 978, 389, 888, 594, 609, 843, 919, 349, 283, 112, 270, 118, 644, 598, 424, 431, 559, 475, 43, 784, 49, 451, 224, 869, 582, 789, 140, 443, 975, 190, 313, 621, 480, 502, 349, 55, 945, 596, 725, 115, 104, 155, 29, 396, 104, 258, 702, 753, 572, 948, 936, 570, 458, 310, 253, 951, 46, 814, 257, 156, 140, 40, 438, 682, 657, 833, 920, 514, 473, 21, 920, 267, 318, 297, 296, 86, 650, 481, 480, 225, 547, 265, 747, 994, 36, 0, 584, 982, 181, 680, 141, 505, 2, 298, 83, 901, 513, 66, 242, 787, 961, 851, 516, 638, 697, 38, 234, 771, 542, 89, 947, 682, 799, 338, 358, 695, 395, 440, 892, 357, 546, 518, 468, 874, 456, 654, 716, 369, 325, 621, 943, 314, 225, 664, 423, 413, 461, 485, 56, 77, 524, 626, 89, 670, 792, 607, 553, 860, 673, 300, 248, 375, 76, 417, 865, 236, 274, 129, 658, 954, 167, 52, 594, 308, 22, 758, 539, 477, 599, 695, 310, 947, 945, 428, 844, 812, 920, 146, 684, 418, 466, 239, 537, 800, 918, 577, 515, 502, 708, 366}, + 999, + }, + + { + []int{2, 3, 1, 4}, + 3, + }, + { + []int{6, 0, 8, 2, 1, 5}, + 4, + }, + + { + []int{9, 8, 1, 0, 1, 9, 4, 0, 4, 1}, + 7, + }, + + // 可以有多个 testcase +} + +func Test_maxWidthRamp(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxWidthRamp(tc.A), "输入:%v", tc) + } +} + +func Benchmark_maxWidthRamp(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxWidthRamp(tc.A) + } + } +} diff --git a/Algorithms/0963.minimum-area-rectangle-ii/1.png b/Algorithms/0963.minimum-area-rectangle-ii/1.png new file mode 100644 index 000000000..f54541fa2 Binary files /dev/null and b/Algorithms/0963.minimum-area-rectangle-ii/1.png differ diff --git a/Algorithms/0963.minimum-area-rectangle-ii/2.png b/Algorithms/0963.minimum-area-rectangle-ii/2.png new file mode 100644 index 000000000..348ad9062 Binary files /dev/null and b/Algorithms/0963.minimum-area-rectangle-ii/2.png differ diff --git a/Algorithms/0963.minimum-area-rectangle-ii/3.png b/Algorithms/0963.minimum-area-rectangle-ii/3.png new file mode 100644 index 000000000..837eecc31 Binary files /dev/null and b/Algorithms/0963.minimum-area-rectangle-ii/3.png differ diff --git a/Algorithms/0963.minimum-area-rectangle-ii/4.png b/Algorithms/0963.minimum-area-rectangle-ii/4.png new file mode 100644 index 000000000..016c824a8 Binary files /dev/null and b/Algorithms/0963.minimum-area-rectangle-ii/4.png differ diff --git a/Algorithms/0963.minimum-area-rectangle-ii/README.md b/Algorithms/0963.minimum-area-rectangle-ii/README.md new file mode 100755 index 000000000..1343cfd12 --- /dev/null +++ b/Algorithms/0963.minimum-area-rectangle-ii/README.md @@ -0,0 +1,53 @@ +# [963. Minimum Area Rectangle II](https://leetcode.com/problems/minimum-area-rectangle-ii/) + +Given a set of points in the xy-plane, determine the minimum area of any rectangle formed from these points, with sides not necessarily parallel to the x and y axes. + +If there isn't any rectangle, return 0. + +Example 1: + +![1](1.png) + +```text +Input: [[1,2],[2,1],[1,0],[0,1]] +Output: 2.00000 +Explanation: The minimum area rectangle occurs at [1,2],[2,1],[1,0],[0,1], with an area of 2. +``` + +Example 2: + +![2](2.png) + +```text +Input: [[0,1],[2,1],[1,1],[1,0],[2,0]] +Output: 1.00000 +Explanation: The minimum area rectangle occurs at [1,0],[1,1],[2,1],[2,0], with an area of 1. +``` + +Example 3: + +![3](3.png) + +```text +Input: [[0,3],[1,2],[3,1],[1,3],[2,1]] +Output: 0 +Explanation: There is no possible rectangle to form from these points. +``` + +Example 4: + +![4](4.png) + +```text +Input: [[3,1],[1,1],[0,1],[2,1],[3,3],[3,2],[0,2],[2,3]] +Output: 2.00000 +Explanation: The minimum area rectangle occurs at [2,1],[2,3],[3,3],[3,1], with an area of 2. +``` + +Note: + +- 1 <= points.length <= 50 +- 0 <= points[i][0] <= 40000 +- 0 <= points[i][1] <= 40000 +- All points are distinct. +- Answers within 10^-5 of the actual value will be accepted as correct. \ No newline at end of file diff --git a/Algorithms/0963.minimum-area-rectangle-ii/minimum-area-rectangle-ii.go b/Algorithms/0963.minimum-area-rectangle-ii/minimum-area-rectangle-ii.go new file mode 100755 index 000000000..230ed0998 --- /dev/null +++ b/Algorithms/0963.minimum-area-rectangle-ii/minimum-area-rectangle-ii.go @@ -0,0 +1,47 @@ +package problem0963 + +import "math" + +func minAreaFreeRect(points [][]int) float64 { + size := len(points) + res := math.MaxFloat64 + + check := make(map[[2]int]struct{}, size) + for _, p := range points { + check[[2]int{p[0], p[1]}] = struct{}{} + } + + for i := 0; i < size; i++ { + o := points[i] + for j := i + 1; j < size; j++ { + p := points[j] + x1, y1 := p[0]-o[0], p[1]-o[1] // vector form o to p + for k := j + 1; k < size; k++ { + q := points[k] + x2, y2 := q[0]-o[0], q[1]-o[1] // vector form o to q + + if x1*x2+y1*y2 != 0 { // not a rectangle + continue + } + + p4 := [2]int{q[0] - o[0] + p[0], q[1] - o[1] + p[1]} + if _, ok := check[p4]; !ok { // miss fourth point + continue + } + + area := length(x1, y1) * length(x2, y2) + res = math.Min(res, area) + } + } + } + + if res == math.MaxFloat64 { + return 0 + } + return res +} + +// length of vector +func length(x, y int) float64 { + return math.Sqrt(float64(x*x + y*y)) +} diff --git a/Algorithms/0963.minimum-area-rectangle-ii/minimum-area-rectangle-ii_test.go b/Algorithms/0963.minimum-area-rectangle-ii/minimum-area-rectangle-ii_test.go new file mode 100755 index 000000000..46fc547ab --- /dev/null +++ b/Algorithms/0963.minimum-area-rectangle-ii/minimum-area-rectangle-ii_test.go @@ -0,0 +1,52 @@ +package problem0963 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + points [][]int + ans float64 +}{ + + { + [][]int{{1, 2}, {2, 1}, {1, 0}, {0, 1}}, + 2.00000, + }, + + { + [][]int{{0, 1}, {2, 1}, {1, 1}, {1, 0}, {2, 0}}, + 1.00000, + }, + + { + [][]int{{0, 3}, {1, 2}, {3, 1}, {1, 3}, {2, 1}}, + 0, + }, + + { + [][]int{{3, 1}, {1, 1}, {0, 1}, {2, 1}, {3, 3}, {3, 2}, {0, 2}, {2, 3}}, + 2.00000, + }, + + // 可以有多个 testcase +} + +func Test_minAreaFreeRect(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.InDelta(tc.ans, minAreaFreeRect(tc.points), 0.00001, "输入:%v", tc) + } +} + +func Benchmark_minAreaFreeRect(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minAreaFreeRect(tc.points) + } + } +} diff --git a/Algorithms/0964.least-operators-to-express-number/README.md b/Algorithms/0964.least-operators-to-express-number/README.md new file mode 100755 index 000000000..dca96997b --- /dev/null +++ b/Algorithms/0964.least-operators-to-express-number/README.md @@ -0,0 +1,41 @@ +# [964. Least Operators to Express Number](https://leetcode.com/problems/least-operators-to-express-number/) + +Given a single positive integer `x`, we will write an expression of the form `x (op1) x (op2) x (op3) x ...` where each operator `op1`, `op2`, etc. is either addition, subtraction, multiplication, or division `(+, -, *, or /)`. For example, with `x = 3`, we might write `3 * 3 / 3 + 3 - 3` which is a value of 3. + +When writing such an expression, we adhere to the following conventions: + +1. The division operator (/) returns rational numbers. +1. There are no parentheses placed anywhere. +1. We use the usual order of operations: multiplication and division happens before addition and subtraction. +1. It's not allowed to use the unary negation operator (-). For example, "x - x" is a valid expression as it only uses subtraction, but "-x + x" is not because it uses negation. + +We would like to write an expression with the least number of operators such that the expression equals the given target. Return the least number of operators used. + +Example 1: + +```text +Input: x = 3, target = 19 +Output: 5 +Explanation: 3 * 3 + 3 * 3 + 3 / 3. The expression contains 5 operations. +``` + +Example 2: + +```text +Input: x = 5, target = 501 +Output: 8 +Explanation: 5 * 5 * 5 * 5 - 5 * 5 * 5 + 5 / 5. The expression contains 8 operations. +``` + +Example 3: + +```text +Input: x = 100, target = 100000000 +Output: 3 +Explanation: 100 * 100 * 100 * 100. The expression contains 3 operations. +``` + +Note: + +- 2 <= x <= 100 +- 1 <= target <= 2 * 10^8 \ No newline at end of file diff --git a/Algorithms/0964.least-operators-to-express-number/least-operators-to-express-number.go b/Algorithms/0964.least-operators-to-express-number/least-operators-to-express-number.go new file mode 100755 index 000000000..f85ed2f4b --- /dev/null +++ b/Algorithms/0964.least-operators-to-express-number/least-operators-to-express-number.go @@ -0,0 +1,38 @@ +package problem0964 + +// ref: https://leetcode.com/problems/least-operators-to-express-number/discuss/208376/python2-O(log-target)-chinese + +// 由于不能有括号,所以每一位(x进制)必须是由自己组成或者由下一位减自己余数组成,所以首先短除法求出每一位的余数 +// 在个位的时候,必须用x/x表示1,所以*2,但其它位不用,所以单独先提出 +// 正数表示时,可用自己+剩下的正数表示或者多加一个本位然后减去上一位的余数表示 +// 负数表示时,可用自己的余数加上剩下的正数表示或者用自己的余数+剩下的余数,但此时可以合并同级项减少运算符 +// 如在10进制下,86可表示为 +// 80 + 6 (6 为下一位正数表示 +// 80 + 10 - 4 (4 为下一位负数表示) +// 100 - 20 + 6 (100-20为本位余数表示,6为下一位正数表示 +// 100 - 20 + 10 - 4 (100-20为本位余数表示,10 -4 为下一位余数表示 +// 在此时, 20 和 10注定为同一位且符号相反,可以省去两个符号(一个符号在该位用i 个符号表示(如100为第二位,所以表示为+10 * 10,用两个符号,在此时所有符号均带自己的正负号 +// 因为在前面算法中所有位都带自己的正负号,所以第一位应该减去自己的符号,所以总量减1 +// 或者在余数表示法中,加上一个更高位的减去自己表示本位余数 +// 所以此题归根结底还是考察对进制的理解而不是简单的理解bfs, dfs,那样复杂度远远高于此,但是是对惯性思维者的一种挑战 + +func leastOpsExpressTarget(x int, target int) int { + target, r := target/x, target%x + pos, neg := r*2, (x-r)*2 // 处理个位上的数 + + bit := 1 + for target > 0 { + target, r = target/x, target%x + pos, neg = min(r*bit+pos, (r+1)*bit+neg), min((x-r)*bit+pos, (x-r-1)*bit+neg) + bit++ + } + + return min(pos, bit+neg) - 1 +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0964.least-operators-to-express-number/least-operators-to-express-number_test.go b/Algorithms/0964.least-operators-to-express-number/least-operators-to-express-number_test.go new file mode 100755 index 000000000..d98df5aea --- /dev/null +++ b/Algorithms/0964.least-operators-to-express-number/least-operators-to-express-number_test.go @@ -0,0 +1,104 @@ +package problem0964 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + x int + target int + ans int +}{ + + { + 3, + 6, + 1, + }, + + { + 3, + 55125018, + 105, + }, + + { + 30, + 281347, + 81, + }, + + { + 97, + 49, + 96, + }, + + { + 11, + 19, + 7, + }, + + { + 11, + 500041, + 41, + }, + + { + 2, + 6125100, + 104, + }, + { + 3, + 2, + 2, + }, + + { + 3, + 365, + 17, + }, + + { + 100, + 100000000, + 3, + }, + + { + 3, + 19, + 5, + }, + + { + 5, + 501, + 8, + }, + + // 可以有多个 testcase +} + +func Test_leastOpsExpressTarget(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, leastOpsExpressTarget(tc.x, tc.target), "输入:%v", tc) + } +} + +func Benchmark_leastOpsExpressTarget(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + leastOpsExpressTarget(tc.x, tc.target) + } + } +} diff --git a/Algorithms/0965.univalued-binary-tree/README.md b/Algorithms/0965.univalued-binary-tree/README.md new file mode 100755 index 000000000..ac9e02609 --- /dev/null +++ b/Algorithms/0965.univalued-binary-tree/README.md @@ -0,0 +1,28 @@ +# [965. Univalued Binary Tree](https://leetcode.com/problems/univalued-binary-tree/) + +A binary tree is univalued if every node in the tree has the same value. + +Return true if and only if the given tree is univalued. + +Example 1: + +![ex1](ex1.png) + +```text +Input: [1,1,1,1,1,null,1] +Output: true +``` + +Example 2: + +![ex2](ex2.png) + +```text +Input: [2,2,2,5,2] +Output: false +``` + +Note: + +1. The number of nodes in the given tree will be in the range [1, 100]. +1. Each node's value will be an integer in the range [0, 99]. diff --git a/Algorithms/0965.univalued-binary-tree/ex1.png b/Algorithms/0965.univalued-binary-tree/ex1.png new file mode 100644 index 000000000..155325f2b Binary files /dev/null and b/Algorithms/0965.univalued-binary-tree/ex1.png differ diff --git a/Algorithms/0965.univalued-binary-tree/ex2.png b/Algorithms/0965.univalued-binary-tree/ex2.png new file mode 100644 index 000000000..c7073b651 Binary files /dev/null and b/Algorithms/0965.univalued-binary-tree/ex2.png differ diff --git a/Algorithms/0965.univalued-binary-tree/univalued-binary-tree.go b/Algorithms/0965.univalued-binary-tree/univalued-binary-tree.go new file mode 100755 index 000000000..ce2939742 --- /dev/null +++ b/Algorithms/0965.univalued-binary-tree/univalued-binary-tree.go @@ -0,0 +1,19 @@ +package problem0965 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined in kit +type TreeNode = kit.TreeNode + +func isUnivalTree(root *TreeNode) bool { + if root == nil { + return true + } + + if (root.Left != nil && root.Val != root.Left.Val) || + (root.Right != nil && root.Val != root.Right.Val) { + return false + } + + return isUnivalTree(root.Left) && isUnivalTree(root.Right) +} diff --git a/Algorithms/0965.univalued-binary-tree/univalued-binary-tree_test.go b/Algorithms/0965.univalued-binary-tree/univalued-binary-tree_test.go new file mode 100755 index 000000000..5c89c94d4 --- /dev/null +++ b/Algorithms/0965.univalued-binary-tree/univalued-binary-tree_test.go @@ -0,0 +1,45 @@ +package problem0965 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans bool +}{ + + { + []int{1, 1, 1, 1, 1, kit.NULL, 1}, + true, + }, + + { + []int{2, 2, 2, 5, 2}, + false, + }, + + // 可以有多个 testcase +} + +func Test_isUnivalTree(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, isUnivalTree(root), "输入:%v", tc) + } +} + +func Benchmark_isUnivalTree(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + isUnivalTree(root) + } + } +} diff --git a/Algorithms/0966.vowel-spellchecker/README.md b/Algorithms/0966.vowel-spellchecker/README.md new file mode 100755 index 000000000..a2c931446 --- /dev/null +++ b/Algorithms/0966.vowel-spellchecker/README.md @@ -0,0 +1,38 @@ +# [966. Vowel Spellchecker](https://leetcode.com/problems/vowel-spellchecker/) + +Given a `wordlist`, we want to implement a spellchecker that converts a query word into a correct word. + +For a given `query` word, the spell checker handles two categories of spelling mistakes: + +- Capitalization: If the query matches a word in the wordlist (**case-insensitive**), then the query word is returned with the same case as the case in the wordlist. + - Example: `wordlist = ["yellow"], query = "YellOw": correct = "yellow"` + - Example: `wordlist = ["Yellow"], query = "yellow": correct = "Yellow"` + - Example: `wordlist = ["yellow"], query = "yellow": correct = "yellow"` +- Vowel Errors: If after replacing the vowels ('a', 'e', 'i', 'o', 'u') of the query word with any vowel individually, it matches a word in the wordlist (case-insensitive), then the query word is returned with the same case as the match in the wordlist. + - Example: `wordlist = ["YellOw"], query = "yollow": correct = "YellOw"` + - Example: `wordlist = ["YellOw"], query = "yeellow": correct = ""` (no match) + - Example: `wordlist = ["YellOw"], query = "yllw": correct = ""` (no match) + +In addition, the spell checker operates under the following precedence rules: + +- When the query exactly matches a word in the wordlist (**case-sensitive**), you should return the same word back. +- When the query matches a word up to capitlization, you should return the first such match in the wordlist. +- When the query matches a word up to vowel errors, you should return the first such match in the wordlist. +- If the query has no matches in the wordlist, you should return the empty string. + +Given some `queries`, return a list of words `answer`, where `answer[i]` is the correct word for `query = queries[i]`. + +Example 1: + +```text +Input: wordlist = ["KiTe","kite","hare","Hare"], queries = ["kite","Kite","KiTe","Hare","HARE","Hear","hear","keti","keet","keto"] +Output: ["kite","KiTe","KiTe","Hare","hare","","","KiTe","","KiTe"] +``` + +Note: + +- 1 <= wordlist.length <= 5000 +- 1 <= queries.length <= 5000 +- 1 <= wordlist[i].length <= 7 +- 1 <= queries[i].length <= 7 +- All strings in wordlist and queries consist only of english letters. \ No newline at end of file diff --git a/Algorithms/0966.vowel-spellchecker/vowel-spellchecker.go b/Algorithms/0966.vowel-spellchecker/vowel-spellchecker.go new file mode 100755 index 000000000..bef77bef0 --- /dev/null +++ b/Algorithms/0966.vowel-spellchecker/vowel-spellchecker.go @@ -0,0 +1,43 @@ +package problem0966 + +import "strings" + +func spellchecker(wordlist []string, queries []string) []string { + isExactlyMatch := make(map[string]bool, len(wordlist)) + cap := make(map[string]int, len(wordlist)) + vow := make(map[string]int, len(wordlist)) + for i := len(wordlist) - 1; i >= 0; i-- { // 必须从大到小 + w := wordlist[i] + isExactlyMatch[w] = true // case sensitive + w = strings.ToLower(w) + cap[w] = i // case insensitive + vow[replacingVowel(w)] = i + } + + corrects := make([]string, len(queries)) + for i, q := range queries { + if isExactlyMatch[q] { + corrects[i] = q + } else if j, ok := cap[strings.ToLower(q)]; ok { + corrects[i] = wordlist[j] + } else if k, ok := vow[replacingVowel(q)]; ok { + corrects[i] = wordlist[k] + } + } + + return corrects +} + +func replacingVowel(s string) string { + var sb strings.Builder + for _, b := range s { + if 'A' <= b && b <= 'Z' { + b += 'a' - 'A' // case insensitive + } + if b == 'a' || b == 'e' || b == 'i' || b == 'o' || b == 'u' { + b = '*' + } + sb.WriteRune(b) + } + return sb.String() +} diff --git a/Algorithms/0966.vowel-spellchecker/vowel-spellchecker_test.go b/Algorithms/0966.vowel-spellchecker/vowel-spellchecker_test.go new file mode 100755 index 000000000..d7ebeccea --- /dev/null +++ b/Algorithms/0966.vowel-spellchecker/vowel-spellchecker_test.go @@ -0,0 +1,57 @@ +package problem0966 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + wordlist []string + queries []string + ans []string +}{ + + { + []string{"ae", "aa"}, + []string{"UU"}, + []string{"ae"}, + }, + + { + []string{"kkk", "hrt", "fze", "awj", "dfn", "kec", "zss", "dkp", "pdx", "pgm", "ozl", "dhj", "uqm", "eks", "opv", "cxo", "okq", "wym", "fjp", "yyo", "awz", "lsp", "quk", "hhe", "sth", "mpo", "mbg", "smj", "cpm", "dno", "miq", "fld", "zxa", "fdu", "ige", "lmt", "gyh", "wcu", "wiv", "zad", "tjk", "ync", "voc", "gqw", "fzk", "ehs", "kgp", "hde", "kkp", "tko", "uae", "uax", "xhm", "anh", "oph", "lws", "amw", "vyi", "lec", "exq", "dbx", "gee", "cbp", "pfu", "uya", "loi", "zba", "qdo", "cfv", "oxg", "him", "aoj", "uob", "kxs", "odx", "qtu", "xbg", "bqy", "imr", "dzo", "ona", "hat", "jxd", "bae", "ops", "len", "fof", "wlt", "fxa", "ryu", "qay", "asd", "shj", "wbi", "moz", "gsi", "hdc", "abt", "yfd", "ptc", "dyj", "dhg", "qwj", "zme", "enn", "lfc", "pdn", "vcx", "aig", "ywr", "txj", "ngl", "mro", "rqc", "baf", "vbr", "box", "wgv", "ifa", "ogw", "ikg", "aai", "qeg", "bgs", "cmo", "prf", "trt", "rqq", "sep", "uqx", "xvn", "uzw", "fof", "mzz", "qug", "pnq", "kwd", "igf", "yly", "ecb", "bcz", "osc", "onq", "khy", "ubi", "iik", "cee", "ora", "iyt", "soa", "qdo", "cmr", "hty", "jap", "ghn", "gwh", "cqd", "tre", "hix", "ztg", "zhf", "mbx", "esc", "hzo", "tic", "mpi", "gvt", "gmm", "tnp", "qgb", "riv", "yrw", "bvu", "uia", "mnx", "lnh", "wao", "pxz", "haw", "bix", "qmr", "kga", "umh", "lmk", "noi", "mjx", "erj", "yda", "dny", "zsk", "qla", "ndq", "atn", "hkb", "svh", "tvi", "pyw", "foa", "zuo", "ort", "ous", "orx", "vfk", "vus", "fwz", "nfg", "vsd", "opn", "nqm", "hru", "jrt", "ymi", "xty", "dph", "etf", "kiu", "dpa", "paa", "oug", "vca", "ejn", "hrl", "auc", "idt", "vuz", "dxr", "dzc", "crg", "cyw", "eiq", "owp", "qye", "aiy", "rmb", "laf", "fmu", "csn", "ray", "ckd", "rhg", "dvf", "guk", "suw", "nfv", "poe", "qpj", "tlg", "rxv", "iuu", "adj", "sjh", "ocw", "ytn", "ptt", "kdg", "anu", "dsl", "nhb", "ywm", "bok", "nlb", "wcf", "tor", "hlr", "rvw", "xui", "hxc", "knm", "oyb", "dgz", "puu", "ovo", "obi", "neb", "zfo", "ouz", "mcc", "fcd", "xzd", "mtu", "dpg", "zre", "tba", "hsz", "lqv", "tfv", "pbp", "glf", "dhc", "dzw", "zso", "cuf", "jek", "gqd", "wyr", "gip", "wsp", "wus", "emv", "kbc", "ssg", "gvu", "eme", "fwa", "zeo", "ljy", "rkv", "iiw", "ljl", "iwn", "oqo", "kcd", "bhl", "dyo", "mho", "scr", "zfg", "iqr", "zxo", "unq", "omd", "vck", "cux", "ivh", "xrw", "ata", "jgd", "mtu", "zhb", "ahd", "zcl", "zvi", "fgq", "htq", "epe", "vgi", "khc", "mdm", "nwq", "bbx", "iqz", "eys", "irl", "ihz", "zhd", "nsa", "ele", "pst", "xyq", "kox", "qys", "tlv", "uwr", "boi", "fdt", "amb", "lyq", "nej", "xxr", "ixx", "ust", "hwe", "hla", "ykp", "qyf", "sny", "bci", "yid", "gii", "dci", "irn", "mjp", "wvk", "zys", "cxs", "hua", "uji", "oxn", "flj", "uac", "yoz", "qcx", "fsk", "wvp", "vtq", "zsw", "uvw", "zqi", "bgu", "udg", "dnb", "ehz", "dtu", "atp", "cop", "unj", "zse", "vzv", "mjx", "xwr", "mlv", "mlv", "vky", "dkl", "kat", "ufp", "hyi", "vzd", "zok", "bel", "saz", "aba", "jgx", "uvc", "yir", "lid", "zph", "uuh", "gti", "lcl", "oxf", "yib", "xpa", "bwf", "udc", "bom", "nkm", "lkz", "rqw", "ihl", "bwy", "jmf", "pfy", "hbu", "imn", "eyf", "nkz", "gje", "svc", "ovt", "pdd", "ukl", "zxb", "mdr", "kzp", "oxi", "gtv", "raw", "shy", "cau", "vgx", "nrg", "bfg", "qzn", "knc", "srq", "qdx", "lij", "ixc", "ogc", "noj", "jxo", "usr", "ytl", "muv", "uti", "pbe", "dzb", "rvp", "fqt", "hhx", "mhe", "cga", "gtd", "yat", "zac", "lbt", "gke", "tuh", "obz", "vuv", "gmq", "dki", "skv", "qbm", "nbb", "ugv", "hxt", "uxn", "uaq", "qqa", "koe", "fxc", "sgj", "hvx", "nae", "wtp", "njm", "mnb", "rge"}, + []string{"pue", "kZp", "hjs", "HBu", "rsp", "epp", "wsz", "AuC", "gsi", "yfz", "ohi", "huu", "xbu", "Xih", "bfg", "gap", "bvu", "okq", "ote", "jlp", "nij", "awz", "Zys", "nvf", "hdr", "ndo", "lkg", "zaq", "iyy", "xjk", "iik", "fom", "evp", "pEB", "arx", "jpd", "rqc", "ynt", "rka", "aWJ", "bdq", "qle", "btc", "ybs", "kjj", "dzW", "tka", "jnj", "rok", "aqm", "brn", "ztg", "bgU", "jpv", "tre", "two", "gih", "rja", "cyu", "ips", "qks", "uVw", "vog", "sjk", "dxv", "hqi", "ezw", "GWH", "jru", "ivm", "fPy", "iXc", "ckd", "swl", "knm", "EYs", "ibv", "ugn", "emv", "epi", "zia", "qsa", "hvx", "mNB", "wcz", "vcg", "ozl", "oar", "shj", "amd", "ibp", "ntw", "qno", "dfn", "bel", "nnm", "szu", "nqm", "fam", "zal", "osd", "uDc", "jzn", "xyq", "stu", "vum", "ShJ", "wvi", "aiy", "rcf", "gue", "lij", "fmn", "Mpo", "hwa", "khc", "qnn", "pni", "ust", "isr", "dzw", "aqg", "etd", "bhl", "Rpv", "Zeo", "xxr", "ups", "cxs", "ckd", "nAe", "fif", "oRX", "rnt", "llv", "xaf", "ais", "mlw", "obz", "wqq", "LkD", "oib", "FjP", "hoq", "zhf", "Foa", "kwi", "kji", "jpr", "vzv", "ans", "kvp", "uaq", "xxr", "lya", "msz", "zhd", "mdz", "qve", "rmb", "jjm", "srf", "nib", "non", "zPH", "zCl", "paa", "zos", "rej", "ubg", "xeq", "meq", "kbC", "fxa", "nse", "lnh", "khy", "qyz", "shj", "gtk", "MdM", "jdg", "gEe", "aza", "btt", "rQc", "edp", "egq", "tvI", "knb", "yir", "vge", "hau", "lws", "ahn", "dvf", "vfe", "miq", "nrt", "ypj", "mhn", "cwz", "wrc", "vna", "sof", "hyk", "hmw", "HIY", "aia", "mbx", "hqu", "vfd", "vkr", "MzZ", "dNy", "cnn", "paa", "ybj", "sgb", "vvl", "jtr", "ioi", "maz", "uui", "LWs", "kBc", "cuq", "plj", "qos", "wvk", "apn", "rlu", "icX", "cge", "opt", "jez", "eow", "VGx", "mhu", "bjx", "UUh", "fmv", "eqg", "fpa", "ckp", "bka", "Vck", "onQ", "pvo", "fkf", "uQM", "yoz", "vus", "amz", "aub", "zrE", "jfm", "zzm", "hlp", "lfl", "qtu", "lvo", "tsn", "ohp", "stq", "aWz", "zii", "jek", "vtq", "bVu", "ZQI", "rap", "ljy", "grj", "vum", "frp", "wus", "frx", "tkh", "qbM", "qlz", "nEb", "gky", "lsp", "qug", "pdd", "khg", "CmO", "ngl", "IKg", "cfl", "qmR", "bol", "ebc", "yys", "sys", "pnq", "iqr", "vuz", "xxo", "btk", "tez", "pqw", "dzo", "kus", "lan", "xui", "HLA", "qpj", "sth", "FwZ", "ZsS", "vkc", "biw", "tko", "KYP", "tkr", "oli", "qvh", "mev", "lpq", "nsa", "hlk", "bgh", "giu", "gnp", "IKi", "jqe", "rav", "bch", "ztg", "cov", "pst", "fyu", "efm", "zth", "yqc", "nsa", "mro", "eyq", "Hty", "bKo", "MEh", "siu", "wzm", "nlb", "uae", "lba", "ioj", "ovT", "gYH", "pts", "drj", "eco", "cia", "xko", "mpo", "gvx", "qgb", "thd", "qef", "fqd", "gde", "mqg", "uqx", "mbg", "ocw", "pyw", "qol", "sKV", "imr", "gri", "QBG", "dlk", "ids", "eba", "qqi", "xew", "egc", "uqm", "rge", "itv", "baj", "cop", "jor", "bcz", "zkd", "fav", "pee", "qdd", "err", "any", "yzn", "nkc", "bmh", "hey", "lcb", "jgx", "mtz", "ecz", "aai", "bwy", "ckc", "zeu", "uum", "mao", "wvP", "svc", "nhs", "jeb", "upv", "noi", "crm", "bch", "nbj", "geh", "aia", "woq", "kel", "amw", "nhn", "hxv", "lxt", "hyf", "wSP", "iyz", "htw", "fnz", "zsx", "okq", "owp", "cqD", "eof", "hjm", "kOe", "gej", "CAz", "zba", "gyh", "beu", "isd", "gql", "miz", "xwm", "wxr", "foa", "ZtG", "wrb", "foo", "faf", "nsl", "prf", "dqi", "dkI", "hty", "kCd", "dzo", "gja", "rey", "unb", "zsw", "yhf", "xui", "kxs", "mag", "zpx", "fjp", "kob", "tnp", "afu", "zuv", "rbq", "qdr", "rvp", "hrt", "vzv", "MXN", "xcl", "wic", "wqm", "gir", "wfd", "JXo", "zss", "wnf", "opv", "rvk", "pdd", "uvh", "GmQ", "FUm", "gyc", "veu", "pjj", "dnb", "ipp", "pla", "dci", "ldr", "eyi"}, + []string{"paa", "kzp", "", "hbu", "", "", "", "auc", "gsi", "", "", "hua", "", "", "bfg", "gip", "bvu", "okq", "ata", "", "nej", "awz", "zys", "", "", "", "", "", "", "", "iik", "", "", "", "orx", "", "rqc", "", "", "awj", "", "qla", "", "", "", "dzw", "tko", "", "", "uqm", "", "ztg", "bgu", "", "tre", "", "", "", "", "ops", "", "uvw", "", "", "", "", "uzw", "gwh", "", "", "", "ixc", "ckd", "", "knm", "eys", "", "", "emv", "epe", "zuo", "", "hvx", "mnb", "", "", "ozl", "", "shj", "omd", "", "", "", "dfn", "bel", "", "", "nqm", "", "", "asd", "udc", "", "xyq", "", "", "shj", "", "aiy", "", "gee", "lij", "", "mpo", "hwe", "khc", "", "", "ust", "usr", "dzw", "", "", "bhl", "", "zeo", "xxr", "ops", "cxs", "ckd", "nae", "fof", "orx", "", "", "", "ous", "", "obz", "", "", "uob", "fjp", "", "zhf", "foa", "", "", "", "vzv", "", "", "uaq", "xxr", "", "", "zhd", "", "", "rmb", "", "", "neb", "", "zph", "zcl", "paa", "", "", "", "", "miq", "kbc", "fxa", "nsa", "lnh", "khy", "", "shj", "", "mdm", "", "gee", "", "", "rqc", "", "", "tvi", "", "yir", "vgi", "hua", "lws", "", "dvf", "", "miq", "", "", "", "", "", "", "", "", "", "", "uae", "mbx", "", "", "", "mzz", "dny", "", "paa", "", "", "", "", "uae", "moz", "uae", "lws", "kbc", "", "", "", "wvk", "opn", "", "", "cga", "", "", "iiw", "vgx", "mho", "", "uuh", "", "", "", "", "", "vck", "onq", "", "", "uqm", "yoz", "vus", "", "uob", "zre", "", "", "", "", "qtu", "", "", "", "", "awz", "zuo", "jek", "vtq", "bvu", "zqi", "", "ljy", "", "", "", "wus", "", "", "qbm", "", "neb", "", "lsp", "qug", "pdd", "", "cmo", "ngl", "ikg", "", "qmr", "bel", "", "", "", "pnq", "iqr", "vuz", "", "", "", "", "dzo", "", "len", "xui", "hla", "qpj", "sth", "fwz", "zss", "", "", "tko", "", "", "ele", "", "muv", "", "nsa", "", "", "gee", "", "", "", "riv", "", "ztg", "", "pst", "", "", "", "", "nsa", "mro", "", "hty", "", "", "soa", "", "nlb", "uae", "", "aoj", "ovt", "gyh", "", "", "", "cee", "", "mpo", "", "qgb", "", "", "", "", "", "uqx", "mbg", "ocw", "pyw", "", "skv", "imr", "", "", "", "", "ubi", "qqa", "", "ogc", "uqm", "rge", "", "", "cop", "", "bcz", "", "", "paa", "", "", "", "", "", "", "", "", "jgx", "", "", "aai", "bwy", "", "zuo", "", "", "wvp", "svc", "", "", "opv", "noi", "", "", "", "", "uae", "", "", "amw", "", "", "", "", "wsp", "", "", "", "", "okq", "owp", "cqd", "", "", "koe", "", "", "zba", "gyh", "bae", "asd", "", "moz", "", "", "foa", "ztg", "", "foa", "fof", "", "prf", "", "dki", "hty", "kcd", "dzo", "gje", "ray", "", "zsw", "", "xui", "kxs", "", "", "fjp", "", "tnp", "ifa", "", "", "", "rvp", "hrt", "vzv", "", "", "", "", "", "", "jxo", "zss", "", "opv", "", "pdd", "ivh", "gmq", "", "", "", "", "dnb", "", "", "dci", "", "uya"}, + }, + + { + []string{"YellOw"}, + []string{"yollew"}, + []string{"YellOw"}, + }, + + { + []string{"KiTe", "kite", "hare", "Hare"}, + []string{"kite", "Kite", "KiTe", "Hare", "HARE", "Hear", "hear", "keti", "keet", "keto"}, + []string{"kite", "KiTe", "KiTe", "Hare", "hare", "", "", "KiTe", "", "KiTe"}, + }, + + // 可以有多个 testcase +} + +func Test_spellchecker(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, spellchecker(tc.wordlist, tc.queries), "输入:%v", tc) + } +} + +func Benchmark_spellchecker(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + spellchecker(tc.wordlist, tc.queries) + } + } +} diff --git a/Algorithms/0967.numbers-with-same-consecutive-differences/README.md b/Algorithms/0967.numbers-with-same-consecutive-differences/README.md new file mode 100755 index 000000000..4c5d26ee2 --- /dev/null +++ b/Algorithms/0967.numbers-with-same-consecutive-differences/README.md @@ -0,0 +1,27 @@ +# [967. Numbers With Same Consecutive Differences](https://leetcode.com/problems/numbers-with-same-consecutive-differences/) + +Return all non-negative integers of length N such that the absolute difference between every two consecutive digits is K. + +Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid. + +You may return the answer in any order. + +Example 1: + +```text +Input: N = 3, K = 7 +Output: [181,292,707,818,929] +Explanation: Note that 070 is not a valid number, because it has leading zeroes. +``` + +Example 2: + +```text +Input: N = 2, K = 1 +Output: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98] +``` + +Note: + +- 1 <= N <= 9 +- 0 <= K <= 9 diff --git a/Algorithms/0967.numbers-with-same-consecutive-differences/numbers-with-same-consecutive-differences.go b/Algorithms/0967.numbers-with-same-consecutive-differences/numbers-with-same-consecutive-differences.go new file mode 100755 index 000000000..cd750f566 --- /dev/null +++ b/Algorithms/0967.numbers-with-same-consecutive-differences/numbers-with-same-consecutive-differences.go @@ -0,0 +1,27 @@ +package problem0967 + +func numsSameConsecDiff(N int, K int) []int { + nums := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} + if N == 1 { + // when N is 1, whatever K is, the answer is nums + return nums + } + + res := nums[1:] // when N>1, delete 0 + // bfs + for n := 1; n < N; n++ { + tmp := make([]int, 0, len(res)*2) + for _, v := range res { + r := v % 10 + if r-K >= 0 { + tmp = append(tmp, v*10+r-K) + } + if K > 0 && r+K <= 9 { + tmp = append(tmp, v*10+r+K) + } + } + res = tmp + } + + return res +} diff --git a/Algorithms/0967.numbers-with-same-consecutive-differences/numbers-with-same-consecutive-differences_test.go b/Algorithms/0967.numbers-with-same-consecutive-differences/numbers-with-same-consecutive-differences_test.go new file mode 100755 index 000000000..6f95acc53 --- /dev/null +++ b/Algorithms/0967.numbers-with-same-consecutive-differences/numbers-with-same-consecutive-differences_test.go @@ -0,0 +1,69 @@ +package problem0967 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + K int + ans []int +}{ + + { + 3, + 1, + []int{101, 121, 123, 210, 212, 232, 234, 321, 323, 343, 345, 432, 434, 454, 456, 543, 545, 565, 567, 654, 656, 676, 678, 765, 767, 787, 789, 876, 878, 898, 987, 989}, + }, + + { + 2, + 0, + []int{11, 22, 33, 44, 55, 66, 77, 88, 99}, + }, + + { + 1, + 6, + []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, + }, + + { + 1, + 0, + []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, + }, + + { + 3, + 7, + []int{181, 292, 707, 818, 929}, + }, + + { + 2, + 1, + []int{10, 12, 21, 23, 32, 34, 43, 45, 54, 56, 65, 67, 76, 78, 87, 89, 98}, + }, + + // 可以有多个 testcase +} + +func Test_numsSameConsecDiff(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numsSameConsecDiff(tc.N, tc.K), "输入:%v", tc) + } +} + +func Benchmark_numsSameConsecDiff(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numsSameConsecDiff(tc.N, tc.K) + } + } +} diff --git a/Algorithms/0968.binary-tree-cameras/1.png b/Algorithms/0968.binary-tree-cameras/1.png new file mode 100644 index 000000000..83acd7a1d Binary files /dev/null and b/Algorithms/0968.binary-tree-cameras/1.png differ diff --git a/Algorithms/0968.binary-tree-cameras/2.png b/Algorithms/0968.binary-tree-cameras/2.png new file mode 100644 index 000000000..9ded3b941 Binary files /dev/null and b/Algorithms/0968.binary-tree-cameras/2.png differ diff --git a/Algorithms/0968.binary-tree-cameras/README.md b/Algorithms/0968.binary-tree-cameras/README.md new file mode 100755 index 000000000..1a1c8878a --- /dev/null +++ b/Algorithms/0968.binary-tree-cameras/README.md @@ -0,0 +1,32 @@ +# [968. Binary Tree Cameras](https://leetcode.com/problems/binary-tree-cameras/) + +Given a binary tree, we install cameras on the nodes of the tree. + +Each camera at a node can monitor its parent, itself, and its immediate children. + +Calculate the minimum number of cameras needed to monitor all nodes of the tree. + +Example 1: + +![1](1.png) + +```text +Input: [0,0,null,0,0] +Output: 1 +Explanation: One camera is enough to monitor all nodes if placed as shown. +``` + +Example 2: + +![2](2.png) + +```text +Input: [0,0,null,0,null,0,null,null,0] +Output: 2 +Explanation: At least two cameras are needed to monitor all nodes of the tree. The above image shows one of the valid configurations of camera placement. +``` + +Note: + +- The number of nodes in the given tree will be in the range [1, 1000]. +- Every node has value 0. \ No newline at end of file diff --git a/Algorithms/0968.binary-tree-cameras/binary-tree-cameras.go b/Algorithms/0968.binary-tree-cameras/binary-tree-cameras.go new file mode 100755 index 000000000..a8f028936 --- /dev/null +++ b/Algorithms/0968.binary-tree-cameras/binary-tree-cameras.go @@ -0,0 +1,44 @@ +package problem0968 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +type status int + +// every node just has one status of three +const ( + hasACamera status = iota + isMonitoredByChild + isMonitoredByParent +) + +func minCameraCover(root *TreeNode) int { + res := 0 + s := check(root, &res) + if s == isMonitoredByParent { + // root has no parent + // so need itself has a camera + res++ + } + return res +} + +func check(root *TreeNode, res *int) status { + if root == nil { + // nil don't need be monitored. + // so we think it's monitored by his child + return isMonitoredByChild + } + l, r := check(root.Left, res), check(root.Right, res) + switch { + case l == isMonitoredByParent || r == isMonitoredByParent: + *res++ + return hasACamera + case l == hasACamera || r == hasACamera: + return isMonitoredByChild + default: + return isMonitoredByParent + } +} diff --git a/Algorithms/0968.binary-tree-cameras/binary-tree-cameras_test.go b/Algorithms/0968.binary-tree-cameras/binary-tree-cameras_test.go new file mode 100755 index 000000000..2c2430b02 --- /dev/null +++ b/Algorithms/0968.binary-tree-cameras/binary-tree-cameras_test.go @@ -0,0 +1,65 @@ +package problem0968 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans int +}{ + + { + []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + 5, + }, + + { + []int{0, 0, 0, 0, 0, kit.NULL, kit.NULL, 0}, + 3, + }, + + { + []int{0, 0, 0, 0, 0, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 0, 0}, + 3, + }, + + { + []int{0}, + 1, + }, + + { + []int{0, 0, kit.NULL, 0, 0}, + 1, + }, + + { + []int{0, 0, kit.NULL, 0, kit.NULL, 0, kit.NULL, kit.NULL, 0}, + 2, + }, + + // 可以有多个 testcase +} + +func Test_minCameraCover(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, minCameraCover(root), "输入:%v", tc) + } +} + +func Benchmark_minCameraCover(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + minCameraCover(root) + } + } +} diff --git a/Algorithms/0969.pancake-sorting/README.md b/Algorithms/0969.pancake-sorting/README.md new file mode 100755 index 000000000..9fc3a8ec7 --- /dev/null +++ b/Algorithms/0969.pancake-sorting/README.md @@ -0,0 +1,33 @@ +# [969. Pancake Sorting](https://leetcode.com/problems/pancake-sorting/) + +Given an array A, we can perform a pancake flip: We choose some positive integer k <= A.length, then reverse the order of the first k elements of A. We want to perform zero or more pancake flips (doing them one after another in succession) to sort the array A. + +Return the k-values corresponding to a sequence of pancake flips that sort A. Any valid answer that sorts the array within 10 * A.length flips will be judged as correct. + +Example 1: + +```text +Input: [3,2,4,1] +Output: [4,2,4,3] +Explanation: +We perform 4 pancake flips, with k values 4, 2, 4, and 3. +Starting state: A = [3, 2, 4, 1] +After 1st flip (k=4): A = [1, 4, 2, 3] +After 2nd flip (k=2): A = [4, 1, 2, 3] +After 3rd flip (k=4): A = [3, 2, 1, 4] +After 4th flip (k=3): A = [1, 2, 3, 4], which is sorted. +``` + +Example 2: + +```text +Input: [1,2,3] +Output: [] +Explanation: The input is already sorted, so there is no need to flip anything. +Note that other answers, such as [3, 3], would also be accepted. +``` + +Note: + +- 1 <= A.length <= 100 +- A[i] is a permutation of [1, 2, ..., A.length] \ No newline at end of file diff --git a/Algorithms/0969.pancake-sorting/pancake-sorting.go b/Algorithms/0969.pancake-sorting/pancake-sorting.go new file mode 100755 index 000000000..de1a5b531 --- /dev/null +++ b/Algorithms/0969.pancake-sorting/pancake-sorting.go @@ -0,0 +1,29 @@ +package problem0969 + +func pancakeSort(A []int) []int { + size := len(A) + res := make([]int, 0, size*2) + for Ai := size; Ai > 1; Ai-- { + // every round makes A[i-1] is i + if A[Ai-1] == Ai { + continue + } + i := Ai - 2 + for A[i] != Ai { + i-- + } + if i != 0 { + reverse(A, i+1) // move Ai to A[0] + res = append(res, i+1) + } + reverse(A, Ai) // move Ai to A[Ai-1] + res = append(res, Ai) + } + return res +} + +func reverse(A []int, k int) { + for i, j := 0, k-1; i < j; i, j = i+1, j-1 { + A[i], A[j] = A[j], A[i] + } +} diff --git a/Algorithms/0969.pancake-sorting/pancake-sorting_test.go b/Algorithms/0969.pancake-sorting/pancake-sorting_test.go new file mode 100755 index 000000000..889b36ba8 --- /dev/null +++ b/Algorithms/0969.pancake-sorting/pancake-sorting_test.go @@ -0,0 +1,51 @@ +package problem0969 + +import ( + "sort" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int +}{ + + { + []int{3, 2, 4, 1}, + }, + + { + []int{1, 2, 3}, + }, + + { + []int{4, 1, 2, 3}, + }, + + // 可以有多个 testcase +} + +func Test_pancakeSort(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + A := make([]int, len(tc.A)) + copy(A, tc.A) + ans := pancakeSort(A) + copy(A, tc.A) + for _, k := range ans { + reverse(A, k) + } + ast.True(sort.IntsAreSorted(A), "输入 %v, 结果 %v, 转换后 %v", tc.A, ans, A) + } +} + +func Benchmark_pancakeSort(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + pancakeSort(tc.A) + } + } +} diff --git a/Algorithms/0970.powerful-integers/README.md b/Algorithms/0970.powerful-integers/README.md new file mode 100755 index 000000000..dd07792f3 --- /dev/null +++ b/Algorithms/0970.powerful-integers/README.md @@ -0,0 +1,35 @@ +# [970. Powerful Integers](https://leetcode.com/problems/powerful-integers/) + +Given two positive integers x and y, an integer is powerful if it is equal to x^i + y^j for some integers i >= 0 and j >= 0. + +Return a list of all powerful integers that have value less than or equal to bound. + +You may return the answer in any order. In your answer, each value should occur at most once. + +Example 1: + +```text +Input: x = 2, y = 3, bound = 10 +Output: [2,3,4,5,7,9,10] +Explanation: +2 = 2^0 + 3^0 +3 = 2^1 + 3^0 +4 = 2^0 + 3^1 +5 = 2^1 + 3^1 +7 = 2^2 + 3^1 +9 = 2^3 + 3^0 +10 = 2^0 + 3^2 +``` + +Example 2: + +```text +Input: x = 3, y = 5, bound = 15 +Output: [2,4,6,8,10,14] +``` + +Note: + +- 1 <= x <= 100 +- 1 <= y <= 100 +- 0 <= bound <= 10^6 \ No newline at end of file diff --git a/Algorithms/0970.powerful-integers/powerful-integers.go b/Algorithms/0970.powerful-integers/powerful-integers.go new file mode 100755 index 000000000..1de2d8fad --- /dev/null +++ b/Algorithms/0970.powerful-integers/powerful-integers.go @@ -0,0 +1,39 @@ +package problem0970 + +import ( + "sort" +) + +func powerfulIntegers(x int, y int, bound int) []int { + if x == 1 { + x = bound + 1 + } + if y == 1 { + y = bound + 1 + } + + res := make([]int, 0, 128) + for i := 1; i < bound; i *= x { + for j := 1; i+j <= bound; j *= y { + res = append(res, i+j) + } + } + + return removeRepeated(res) +} + +func removeRepeated(nums []int) []int { + sort.Ints(nums) + + size := len(nums) + + last, j := -1, -1 + for i := 0; i < size; i++ { + if last == nums[i] { // nums[i]>0 for any i + continue + } + j++ + nums[j], last = nums[i], nums[i] + } + return nums[:j+1] +} diff --git a/Algorithms/0970.powerful-integers/powerful-integers_test.go b/Algorithms/0970.powerful-integers/powerful-integers_test.go new file mode 100755 index 000000000..ec1f0070c --- /dev/null +++ b/Algorithms/0970.powerful-integers/powerful-integers_test.go @@ -0,0 +1,99 @@ +package problem0970 + +import ( + "sort" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + x int + y int + bound int + ans []int +}{ + + { + 1, + 1, + 0, + []int{}, + }, + + { + 2, + 1, + 10, + []int{2, 3, 5, 9}, + }, + + { + 2, + 3, + 10, + []int{2, 3, 4, 5, 7, 9, 10}, + }, + + { + 3, + 5, + 15, + []int{2, 4, 6, 8, 10, 14}, + }, + + // 可以有多个 testcase +} + +func Test_powerfulIntegers(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + sort.Ints(tc.ans) + ans := powerfulIntegers(tc.x, tc.y, tc.bound) + sort.Ints(ans) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_powerfulIntegers(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + powerfulIntegers(tc.x, tc.y, tc.bound) + } + } +} + +func Benchmark_removeRepeated(b *testing.B) { + nums := []int{1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9} + for i := 1; i < b.N; i++ { + removeRepeated(nums) + } +} + +func Benchmark_removeRepeated2(b *testing.B) { + nums := []int{1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9} + for i := 1; i < b.N; i++ { + removeRepeated2(nums) + } +} + +func removeRepeated2(nums []int) []int { + sort.Ints(nums) + + size := len(nums) + if size == 0 { + return nums + } + + i := 0 + for j := 1; j < size; j++ { + if nums[i] == nums[j] { + continue + } + i++ + nums[i] = nums[j] + } + return nums[:i+1] +} diff --git a/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/1.png b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/1.png new file mode 100644 index 000000000..d04161846 Binary files /dev/null and b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/1.png differ diff --git a/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/2.png b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/2.png new file mode 100644 index 000000000..64e1acc46 Binary files /dev/null and b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/2.png differ diff --git a/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/3.png b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/3.png new file mode 100644 index 000000000..64e1acc46 Binary files /dev/null and b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/3.png differ diff --git a/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/README.md b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/README.md new file mode 100755 index 000000000..66043e0ed --- /dev/null +++ b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/README.md @@ -0,0 +1,46 @@ +# [971. Flip Binary Tree To Match Preorder Traversal](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal/) + +Given a binary tree with N nodes, each node has a different value from {1, ..., N}. + +A node in this binary tree can be flipped by swapping the left child and the right child of that node. + +Consider the sequence of N values reported by a preorder traversal starting from the root. Call such a sequence of N values the voyage of the tree. + +(Recall that a preorder traversal of a node means we report the current node's value, then preorder-traverse the left child, then preorder-traverse the right child.) + +Our goal is to flip the least number of nodes in the tree so that the voyage of the tree matches the voyage we are given. + +If we can do so, then return a list of the values of all nodes flipped. You may return the answer in any order. + +If we cannot do so, then return the list [-1]. + +Example 1: + +![1](1.png) + +```text +Input: root = [1,2], voyage = [2,1] +Output: [-1] +``` + +Example 2: + +![2](2.png) + +```text +Input: root = [1,2,3], voyage = [1,3,2] +Output: [1] +``` + +Example 3: + +![3](3.png) + +```text +Input: root = [1,2,3], voyage = [1,2,3] +Output: [] +``` + +Note: + +- 1 <= N <= 100 \ No newline at end of file diff --git a/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/flip-binary-tree-to-match-preorder-traversal.go b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/flip-binary-tree-to-match-preorder-traversal.go new file mode 100755 index 000000000..53bf67a15 --- /dev/null +++ b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/flip-binary-tree-to-match-preorder-traversal.go @@ -0,0 +1,38 @@ +package problem0971 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined. +/** + * Definition for a binary tree node. + * type TreeNode struct { + * Val int + * Left *TreeNode + * Right *TreeNode + * } + */ +type TreeNode = kit.TreeNode + +func flipMatchVoyage(root *TreeNode, voyage []int) []int { + res := make([]int, 0, len(voyage)) + index := 0 + var dfs func(*TreeNode) bool + dfs = func(node *TreeNode) bool { + if node == nil { + return true + } + if node.Val != voyage[index] { + return false + } + index++ + if node.Left != nil && node.Left.Val != voyage[index] { + res = append(res, node.Val) + return dfs(node.Right) && dfs(node.Left) + } + return dfs(node.Left) && dfs(node.Right) + } + if dfs(root) { + return res + } + return []int{-1} +} diff --git a/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/flip-binary-tree-to-match-preorder-traversal_test.go b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/flip-binary-tree-to-match-preorder-traversal_test.go new file mode 100755 index 000000000..36dde26ae --- /dev/null +++ b/Algorithms/0971.flip-binary-tree-to-match-preorder-traversal/flip-binary-tree-to-match-preorder-traversal_test.go @@ -0,0 +1,67 @@ +package problem0971 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + voyage []int + ans []int +}{ + + { + []int{1, 2}, + []int{1, 2}, + []int{}, + }, + + { + []int{1, kit.NULL, 2}, + []int{1, 2}, + []int{}, + }, + + { + []int{1, 2, 3}, + []int{1, 3, 2}, + []int{1}, + }, + + { + []int{1, 2}, + []int{2, 1}, + []int{-1}, + }, + + { + []int{1, 2, 3}, + []int{1, 2, 3}, + []int{}, + }, + + // 可以有多个 testcase +} + +func Test_flipMatchVoyage(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, flipMatchVoyage(root, tc.voyage), "输入:%v", tc) + } +} + +func Benchmark_flipMatchVoyage(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + flipMatchVoyage(root, tc.voyage) + } + } +} diff --git a/Algorithms/0972.equal-rational-numbers/README.md b/Algorithms/0972.equal-rational-numbers/README.md new file mode 100755 index 000000000..561b82782 --- /dev/null +++ b/Algorithms/0972.equal-rational-numbers/README.md @@ -0,0 +1,49 @@ +# [972. Equal Rational Numbers](https://leetcode.com/problems/equal-rational-numbers/) + +Given two strings S and T, each of which represents a non-negative rational number, return True if and only if they represent the same number. The strings may use parentheses to denote the repeating part of the rational number. + +In general a rational number can be represented using up to three parts: an integer part, a non-repeating part, and a repeating part. The number will be represented in one of the following three ways: + +- (e.g. 0, 12, 123) +- <.> (e.g. 0.5, 1., 2.12, 2.0001) +- <.><(><)> (e.g. 0.1(6), 0.9(9), 0.00(1212)) + +The repeating portion of a decimal expansion is conventionally denoted within a pair of round brackets. For example: + +1 / 6 = 0.16666666... = 0.1(6) = 0.1666(6) = 0.166(66) + +Both 0.1(6) or 0.1666(6) or 0.166(66) are correct representations of 1 / 6. + +Example 1: + +```text +Input: S = "0.(52)", T = "0.5(25)" +Output: true +Explanation: +Because "0.(52)" represents 0.52525252..., and "0.5(25)" represents 0.52525252525..... , the strings represent the same number. +``` + +Example 2: + +```text +Input: S = "0.1666(6)", T = "0.166(66)" +Output: true +``` + +Example 3: + +```text +Input: S = "0.9(9)", T = "1." +Output: true +Explanation: +"0.9(9)" represents 0.999999999... repeated forever, which equals 1. [See this link for an explanation.] +"1." represents the number 1, which is formed correctly: (IntegerPart) = "1" and (NonRepeatingPart) = "". +``` + +Note: + +- Each part consists only of digits. +- The will not begin with 2 or more zeros. (There is no other restriction on the digits of each part.) +- 1 <= .length <= 4 +- 0 <= .length <= 4 +- 1 <= .length <= 4 \ No newline at end of file diff --git a/Algorithms/0972.equal-rational-numbers/equal-rational-numbers.go b/Algorithms/0972.equal-rational-numbers/equal-rational-numbers.go new file mode 100755 index 000000000..32b88b9da --- /dev/null +++ b/Algorithms/0972.equal-rational-numbers/equal-rational-numbers.go @@ -0,0 +1,33 @@ +package problem0972 + +import ( + "strconv" + "strings" +) + +// 首先,牢记 note 中提到的 3 点 +// 3. 1 <= .length <= 4 +// 4. 0 <= .length <= 4 +// 5. 1 <= .length <= 4 +// 再根据 IEEE 754 中 https://zh.wikipedia.org/wiki/IEEE_754#%E8%AE%A8%E8%AE%BA%E4%B8%80 提到的 64 bit 双精度可以准确地表示 15 位十进制数 +// 分两种情况讨论: +// 1: 没有重复部分,可以直接精准地转换成 float64 +// 2: 存在重复部分,可以延展 S 到 20 位长度后,再近似地转换成 float64 +// 因为 note 中规定了各个部分的长度, +// A: 重复部分不为 9 的话,在 15 位以内就会出现差别 +// B: 重复部分为 9 的话, 至少 S[9:20] 中皆为 9,会在四舍五入时进位,与数学规定一致 + +func isRationalEqual(S string, T string) bool { + return convert(S) == convert(T) +} + +func convert(s string) float64 { + i := strings.IndexByte(s, '(') + if i != -1 { + base, repeat := s[:i], s[i+1:len(s)-1] + s = base + strings.Repeat(repeat, (20-len(base))/len(repeat)+1) + s = s[:20] // 20 could be 19, but not 18 + } + res, _ := strconv.ParseFloat(s, 64) + return res +} diff --git a/Algorithms/0972.equal-rational-numbers/equal-rational-numbers_test.go b/Algorithms/0972.equal-rational-numbers/equal-rational-numbers_test.go new file mode 100755 index 000000000..44c96f4b4 --- /dev/null +++ b/Algorithms/0972.equal-rational-numbers/equal-rational-numbers_test.go @@ -0,0 +1,93 @@ +package problem0972 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + T string + ans bool +}{ + + { + "1.0", + "1", + true, + }, + + { + "350.(111)", + "350.(11)", + true, + }, + + { + "15.(9)", + "16", + true, + }, + + { + "1.0(9)", + "1.1", + true, + }, + + { + "0.9(9)", + "1.", + true, + }, + + { + "1.9(0)", + "1.8(9)", + true, + }, + + { + "0", + "0.", + true, + }, + + { + "0.(0)", + "0", + true, + }, + + { + "0.(52)", + "0.5(25)", + true, + }, + + { + "0.1666(6)", + "0.166(66)", + true, + }, + + // 可以有多个 testcase +} + +func Test_isRationalEqual(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, isRationalEqual(tc.S, tc.T), "输入:%v", tc) + } +} + +func Benchmark_isRationalEqual(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isRationalEqual(tc.S, tc.T) + } + } +} diff --git a/Algorithms/0973.k-closest-points-to-origin/README.md b/Algorithms/0973.k-closest-points-to-origin/README.md new file mode 100755 index 000000000..82f17e469 --- /dev/null +++ b/Algorithms/0973.k-closest-points-to-origin/README.md @@ -0,0 +1,33 @@ +# [973. K Closest Points to Origin](https://leetcode.com/problems/k-closest-points-to-origin/) + +We have a list of points on the plane. Find the K closest points to the origin (0, 0). + +(Here, the distance between two points on a plane is the Euclidean distance.) + +You may return the answer in any order. The answer is guaranteed to be unique (except for the order that it is in.) + +Example 1: + +```text +Input: points = [[1,3],[-2,2]], K = 1 +Output: [[-2,2]] +Explanation: +The distance between (1, 3) and the origin is sqrt(10). +The distance between (-2, 2) and the origin is sqrt(8). +Since sqrt(8) < sqrt(10), (-2, 2) is closer to the origin. +We only want the closest K = 1 points from the origin, so the answer is just [[-2,2]]. +``` + +Example 2: + +```text +Input: points = [[3,3],[5,-1],[-2,4]], K = 2 +Output: [[3,3],[-2,4]] +(The answer [[-2,4],[3,3]] would also be accepted.) +``` + +Note: + +- `1 <= K <= points.length <= 10000` +- `-10000 < points[i][0] < 10000` +- `-10000 < points[i][1] < 10000` \ No newline at end of file diff --git a/Algorithms/0973.k-closest-points-to-origin/k-closest-points-to-origin.go b/Algorithms/0973.k-closest-points-to-origin/k-closest-points-to-origin.go new file mode 100755 index 000000000..b04ddd356 --- /dev/null +++ b/Algorithms/0973.k-closest-points-to-origin/k-closest-points-to-origin.go @@ -0,0 +1,14 @@ +package problem0973 + +import "sort" + +func kClosest(points [][]int, K int) [][]int { + sort.Slice(points, func(i int, j int) bool { + return dist(points[i]) < dist(points[j]) + }) + return points[:K] +} + +func dist(p []int) int { + return p[0]*p[0] + p[1]*p[1] +} diff --git a/Algorithms/0973.k-closest-points-to-origin/k-closest-points-to-origin_test.go b/Algorithms/0973.k-closest-points-to-origin/k-closest-points-to-origin_test.go new file mode 100755 index 000000000..4a0e22db8 --- /dev/null +++ b/Algorithms/0973.k-closest-points-to-origin/k-closest-points-to-origin_test.go @@ -0,0 +1,45 @@ +package problem0973 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + points [][]int + K int + ans [][]int +}{ + + { + [][]int{{1, 3}, {-2, 2}}, + 1, + [][]int{{-2, 2}}, + }, + + { + [][]int{{3, 3}, {5, -1}, {-2, 4}}, + 2, + [][]int{{3, 3}, {-2, 4}}, + }, + + // 可以有多个 testcase +} + +func Test_kClosest(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, kClosest(tc.points, tc.K), "输入:%v", tc) + } +} + +func Benchmark_kClosest(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + kClosest(tc.points, tc.K) + } + } +} diff --git a/Algorithms/0974.subarray-sums-divisible-by-k/README.md b/Algorithms/0974.subarray-sums-divisible-by-k/README.md new file mode 100755 index 000000000..7225304fd --- /dev/null +++ b/Algorithms/0974.subarray-sums-divisible-by-k/README.md @@ -0,0 +1,18 @@ +# [974. Subarray Sums Divisible by K](https://leetcode.com/problems/subarray-sums-divisible-by-k/) + +Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K. + +Example 1: + +```text +Input: A = [4,5,0,-2,-3,1], K = 5 +Output: 7 +Explanation: There are 7 subarrays with a sum divisible by K = 5: +[4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3] +``` + +Note: + +- `1 <= A.length <= 30000` +- `-10000 <= A[i] <= 10000` +- `2 <= K <= 10000` \ No newline at end of file diff --git a/Algorithms/0974.subarray-sums-divisible-by-k/subarray-sums-divisible-by-k.go b/Algorithms/0974.subarray-sums-divisible-by-k/subarray-sums-divisible-by-k.go new file mode 100755 index 000000000..fbcdff5cc --- /dev/null +++ b/Algorithms/0974.subarray-sums-divisible-by-k/subarray-sums-divisible-by-k.go @@ -0,0 +1,13 @@ +package problem0974 + +func subarraysDivByK(A []int, K int) int { + count := [10000]int{} + count[0] = 1 + prefix, res := 0, 0 + for _, a := range A { + prefix = (prefix + a%K + K) % K + res += count[prefix] // 减去相同的 prefix,剩下的就都是 K 的倍数 + count[prefix]++ + } + return res +} diff --git a/Algorithms/0974.subarray-sums-divisible-by-k/subarray-sums-divisible-by-k_test.go b/Algorithms/0974.subarray-sums-divisible-by-k/subarray-sums-divisible-by-k_test.go new file mode 100755 index 000000000..1685caeb8 --- /dev/null +++ b/Algorithms/0974.subarray-sums-divisible-by-k/subarray-sums-divisible-by-k_test.go @@ -0,0 +1,46 @@ +package problem0974 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans int +}{ + +{ + []int{ +1152,-6255,-7426,2761,-1188,7031,-4556,-7277,-2276,2559,-2932,-3888,5236,4320,4987,680,9794,3898,-5976,2962,-7131,-3812,4966,6059,9028,73,4198,2000,9482,-5529,-1527,2742,1181,5793,-958,8690,-1463,730,7733,9753,-9703,5613,-7979,-5161,5740,9493,-8778,8685,8485,-413,5182,8448,-1342,255,-2163,861,-4669,-9180,9445,3115,4593,-4734,-5028,54,-9250,1567,9690,6825,-3954,1946,-132,-4418,-4917,2676,-4525,-340,1500,-7901,9301,-9731,6337,7218,9999,922,7747,6986,-2848,-2829,1361,-8648,821,2406,-2575,-4304,6795,-4913,2981,-6271,-8994,1117,1645,-8345,8277,6884,7150,8259,1496,-2939,-4133,3382,2550,6378,-1250,-7831,9669,-669,375,6221,-8865,-5175,-2826,-9646,-5517,-5471,7630,-2214,4485,9344,-1336,-8356,3876,-2918,8390,-4886,4799,-1206,4165,7038,1944,1112,-3012,-9428,3015,5626,-9014,-4354,-4731,-8773,5221,6437,82,299,-7260,8828,3861,6423,7181,1848,1643,-2229,7840,2496,8589,6990,9521,5310,-9980,7732,-698,-1127,6226,-6341,-3076,-8436,-5962,7755,6803,6253,-8857,-4929,6469,-1401,-3892,6656,-9838,8580,-7197,-3344,4153,5542,4190,4947,-137,440,7286,-297,-8869,6780,8646,-5934,5174,7113,7458,9458,-6200,-4273,7243,-9841,2232,9776,-4787,2218,918,-9157,7059,6889,-6641,3871,2413,216,-9705,3745,-3324,2470,-23,-3269,480,6667,7034,2355,9074,2377,-7254,5961,-2231,4043,-9049,1501,4501,9411,8251,-9840,-9664,1830,-559,4662,-6849,-5450,9687,-4576,2831,9312,-3419,-4058,-7909,8406,-3919,465,-3985,2509,9726,4762,-8176,-6704,-4652,-9662,-7577,179,-7095,9887,-6866,-8241,4841,7141,-3273,5112,-7880,-4549,-6746,6419,8666,-2189,-6844,-3435,-8537,-1648,2645,-1121,4540,6275,7888,-5244,4085,4188,6673,6938,5775,6915,-5091,7225,9884,-9125,801,-4723,-6353,3572,-2334,-3422,-2989,9767,-8207,8239,-8001,6629,7257,-497,-5390,-201,-3599,-9960,6784,1868,-5129,-4928,4019,1874,-9935,2983,1970,8501,-5648,1396,376,841,-9945,2194,3153,-2501,1206,-7300,6153,4415,-4205,8039,727,9752,1610,-1531,4860,7804,-8830,-5307,4990,-5592,3806,41,-7622,6956,-4484,-5445,-5359,-7523,7561,-3079,2770,-7607,-3522,-4747,9541,8679,917,9909,2879,-8812,-4085,7299,-4354,-4881,-1856,-4369,-6117,-2387,-743,-3873,8417,3865,1312,-4966,1165,3320,8511,-8622,3475,-1370,5194,-118,-3810,-8400,3260,-4937,1537,-1935,-9360,-7289,-3499,9000,-3160,-1118,9463,2312,6935,-1262,6264,-6790,4273,7762,7192,-7776,3172,9238,-1138,-3452,-5572,9657,-5265,2283,645,130,-1240,452,-8255,-1493,-106,2952,9208,-5412,-7867,-3840,912,990,-9385,-469,-7725,9444,-1892,-4961,7966,-1758,-551,-1179,5007,8186,-2869,-7122,3575,5917,3004,-3032,-1151,5521,1665,-8971,-5740,-5213,9751,-9943,3056,175,7263,-4005,311,-7853,-6887,6558,-3063,-5914,-8164,-2429,-6065,9857,-2308,-2836,5097,-7061,4758,-7997,8036,-9560,-2890,2730,1446,4115,-9379,-6317,-8866,1232,8462,4571,-5530,9167,5553,1852,918,7938,-4663,-1023,-2113,7011,7825,4049,5073,6759,6192,-448,-2016,3784,5239,3231,2956,-7572,4246,1405,5936,7601,8508,-8573,-6476,-1782,-9553,-7697,7517,6598,-2470,-8970,-9430,3714,4415,-8957,223,-8265,-514,804,-6797,5059,6309,9426,-2759,-8581,-6619,-4793,1209,5534,-2354,-1606,4805,-3766,8139,3733,3645,-6697,-4619,-3268,2449,-2335,-8669,-8997,-8966,-9994,-7528,896,9952,-9537,-8105,-7889,-9850,-8213,4066,-6346,7602,-8432,6197,-3239,-8509,2362,-7147,3021,-400,-8612,-2178,2879,-496,7910,8435,-6139,3436,6190,4441,-6345,3648,5059,-9195,-3721,5145,3034,2727,-5891,5707,4922,1272,-2195,1482,7886,-3200,-3478,9076,-2963,2185,7974,-4394,-4013,-8032,-1500,-7333,-7896,6353,-1205,-860,-5806,-6000,-9155,8427,-6528,-7552,4016,6590,2786,8654,-6681,-5238,3431,8789,7581,-8661,-1564,-5316,2375,5309,2798,8176,9144,5122,-3471,-3422,-1410,6294,-6310,-8463,5366,-9251,-3988,-7020,-1798,4333,999,-3926,-1423,9018,5372,-2344,-8925,-4622,-5322,5784,-507,-8638,-8961,9367,2534,3982,6107,-4991,7891,9477,5807,2560,-9898,3670,-5249,4081,-215,-1650,-9618,-4633,2657,1213,-8059,766,-9351,6020,4168,8717,9283,6741,-1753,-4665,-6935,-7722,-9356,5000,-2015,4809,1385,464,576,-5208,-5185,-5756,9451,-2176,-5779,3591,-9760,-1172,1884,3635,-5447,4662,5057,5473,-8799,-6636,3989,-9189,-7194,-9346,2063,-8537,9966,4739,1944,-5669,-7228,-8830,-90,2135,-1120,6481,-9647,6883,-1020,6464,-9840,730,-1195,-2179,2991,2331,6110,2136,4595,2256,3811,-7036,3429,-1032,-3289,4680,629,6375,263,7393,2085,-7192,1487,-5963,2923,3624,8276,1144,-4066,-2785,-1440,-1752,3717,-8628,-7500,-4029,1512,1664,-5413,-1321,4855,2791,7748,352,7782,2048,8003,-917,-9363,369,7532,7272,-2155,-9519,2213,2939,5501,458,4471,-5199,369,1448,-7650,-56,1720,-9090,-3706,-3929,-2748,5850,-6186,-7075,-7953,-9362,9414,-2823,-8487,7199,8894,3066,6314,1247,4227,1516,92,4016,-6579,2236,-6855,3794,3570,-9501,1538,-8769,-5532,6590,1107,-6095,710,3289,6791,6280,-8688,282,-8823,129,7317,8785,386,404,-9844,-5861,-4732,-2737,-2531,-2241,5511,-575,-133,-7436,-969,2298,4172,-1369,8636,5422,5129,2437,-5764,-7534,-8954,8767,2949,-6579,2972,6793,-9755,5258,-6259,7908,4217,-2940,6268,-8931,-1971,-5774,-6137,-3971,3644,-7121,8298,-5077,-9079,7585,-600,7632,7063,-263,5499,931,2257,2201,66,-6011,9755,8581,1346,9570,4139,-1004,6634,-7676,1090,9247,-7584,-4128,-9728,-9854,-5272,9420,-9880,-2050,4070,-2456,-6485,-5612,-8686,-5866,777,5188,9597,5723,8964,9453,-7646,1488,5814,9934,-6773,-1097,-2289,-6104,-3311,7587,5385,-3423,9098,2883,6604,1439,8872,-5511,-9426,-5690,-4572,6922,-2624,-5780,-6939,2299,-7063,2179,-5349,351,5292,-7266,4685,-3475,539,-1919,7396,-2248,-5814,2184,5350,-724,4096,8668,-436,3775,9878,7347,8894,4736,-7972,-5437,-1995,-1084,-3960,-1577,-9478,-7737,-268,3476,-6851,-434,5191,4768,-4155,-3287,-132,-6707,8582,-6678,-4955,-2014,7420,-3532,281,-6544,9954,-5658,6236,7188,-2505,6379,8354,3422,-8375,-7566,-5191,3453,-825,173,2023,-1326,-6993,9791,5180,9201,-1208,-6067,-758,2201,9838,-9790,8344,-4523,1442,8028,-4879,976,3144,8022,2921,-8731,-1082,-7625,-9472,9014,-6971,-3672,3774,7962,6281,-9843,5027,-2649,-9228,-2493,-7203,-8625,3037,6427,-2141,-991,851,4312,7294,-9600,-3142,6770,1682,-8798,1158,-2857,9943,2553,-1790,3658,-2540,5531,-6403,-5071,-7511,648,-1050,-2008,-1037,4425,-9944,-588,2036,-6800,3911,2333,-8914,8722,2167,2484,-4883,-3646,-7113,8156,4299,1063,1627,6852,-6935,8250,-7519,-1134,2100,-8264,-544,1456,7603,9070,3250,-7850,-5108,3420,2897,-5126,1028,6736,-6635,-257,4185,-5700,7447,-5167,883,6174,4634,2592,-7094,-2361,8735,2546,7140,-4257,-4586,6532,4220,-9456,-8019,-127,-9002,1907,-4829,-1477,-6768,-1056,-2820,3042,-9124,8693,6431,902,4136,-795,-9664,7920,-9134,-5819,2952,8344,7676,4884,1739,7032,9336,7034,-395,5698,-7746,-7521,5385,2752,2235,4827,7743,1637,315,7865,9484,-7686,7784,2214,5215,8744,2754,4511,5219,-2667,-3080,-3406,3337,-3399,2672,908,-3736,-4643,7754,-7560,-7089,-283,-9871,334,-7192,-874,3635,-7299,-3140,161,2237,-3720,-5598,-2968,-632,-1244,-6142,6584,8026,2805,2329,-9818,-9517,-8795,4408,-6366,1020,666,-4691,7791,-3669,-3069,2138,446,463,-4,-6444,1989,-8451,3301,6455,6665,7260,-6641,8564,-1574,-3330,3658,4357,358,-2859,4250,-7218,5638,-3591,7554,-8596,-3904,-4622,-7011,1477,1754,-6622,-3425,-3170,8678,2075,1813,-7293,-5490,1295,9994,-5950,8956,-4486,-2503,7154,4488,3897,492,6115,7255,236,-3515,2287,-9325,4516,4383,8331,2569,-8459,5354,7820,-4720,-3142,8846,-8680,7065,-4677,3865,3602,8350,839,9858,-532,-813,3447,-9724,-6846,8574,9779,-1625,6148,8105,-36,-3932,-8759,3094,-1386,-5327,-7599,1032,-1709,8211,5522,-677,-9058,-5293,-2129,9868,5805,21,-3602,9682,-5065,-5428,-8197,-3278,-7100,-4709,-7995,2501,7149,-2495,-1554,2103,-5315,-2655,9077,5480,-6158,-7770,4191,8112,5290,-5348,-6762,1242,-345,5092,4490,-3995,8315,-1238,6060,3725,7100,1137,-8310,-3669,-6583,6117,-6266,-5847,-3044,9389,-6045,9300,-9529,-7703,-4986,8220,3823,9799,2811,-2079,-363,1826,7875,-9156,2831,-9121,-2808,-1463,8816,-604,2891,9121,-6442,-7053,7385,8676,6222,5167,8651,-6051,-4715,-750,-417,1895,8319,2195,-6614,5607,-8039,-9542,-8025,8891,-4231,-3709,8291,3759,-5530,-2808,-3528,-8916,-7552,582,-9036,7706,-1448,2621,-5809,-6267,-952,2888,-6590,-850,-1990,-4906,8586,-2602,2137,7061,-9171,3021,-4020,-1574,4495,5594,-6629,-5308,5126,931,-9755,4536,-8357,7932,-4596,-6597,-1406,5672,9468,-2762,9227,-7946,-3276,-3743,3626,1482,-924,2116,-435,4381,1114,-9953,7534,431,3366,6408,9471,-93,3377,7378,-9248,-887,1989,3162,9194,-2082,-1648,8343,1612,-1232,8256,-784,-9795,-9832,2316,1581,-6121,-3746,-5676,-7492,5207,-4972,6512,1121,-5902,3802,9352,268,6516,3647,-5117,4581,-2853,9620,-3097,1719,-4805,-7486,2313,-7739,-1622,-1967,118,7408,9490,7639,-4095,2010,-3589,-1675,6440,2938,-2091,-8556,9059,-3410,7745,7599,-1788,-5435,1033,8056,2196,-5623,5059,9416,-312,-752,-1288,-4757,7422,9730,5975,-8701,3673,1675,6091,-1973,3245,-7764,5951,-338,-8723,718,1599,-2577,5409,5730,7045,-7293,-589,3126,9781,6433,-7191,8644,3392,6492,8783,-3684,2937,-2450,9494,5618,2867,966,757,-9925,2057,-4367,-6850,8847,696,-1728,5517,-1672,-9425,-697,-6951,5459,4168,304,6191,-3784,-5480,-9326,-8700,9311,5329,4301,-7602,-5976,-4164,8739,4919,-6914,5839,9354,6188,-8561,7434,9935,8931,8347,-9597,-2548,3336,-5362,8782,2880,-2485,-8228,-3655,6376,-2760,-5949,4383,7894,6518,-3610,3741,5916,-4856,6601,9401,2876,-2236,-6349,-5873,-8462,592,-9597,-396,7911,-3839,-5396,-2430,-8830,1027,-693,-4156,6309,6427,-1291,-4462,514,7534,-3535,3030,7517,-2019,6814,9950,3108,529,-1370,-154,-165,-4181,-8721,5786,8258,6664,-6163,295,3514,4101,262,-9906,6430,-7681,5060,2046,7253,-2350,5896,5555,883,-7456,-9484,-3072,-2150,-2036,4116,-5128,996,-4637,-5158,-5308,6140,8498,-4349,58,-7928,4536,-16,-198,-5012,1725,645,-8764,6021,-2040,-1112,8189,2724,4234,-4966,8206,6616,-332,5660,-1188,-9432,2043,-7338,-6661,913,4649,5902,973,3421,3228,5856,9391,-9312,597,-4322,7127,-5687,1619,6126,6657,-9249,9919,-4522,7059,-7103,-4730,-3945,-3640,230,-9913,111,223,6777,8505,-7313,2440,-1331,-2640,-7203,9059,2737,-1030,3778,4638,6167,8987,2092,3913,-6739,1747,303,-6286,-7138,1119,-307,8884,4117,-3208,88,-8910,-9895,-9266,3728,-8203,-1141,-9414,4699,2761,-6790,-8991,-5766,5054,4639,-8668,9378,9212,-2625,-8957,9853,490,3779,1182,-4229,-4539,-1647,3429,7622,-4970,9332,-7157,1379,3099,5675,1031,-5420,1498,-5702,-5953,38,-9454,-5901,-45,2570,2469,4809,-7714,5888,3678,6280,-2532,-5094,3680,-3192,-1651,-8565,886,4338,5394,315,15,5304,3606,-6195,7142,6708,-1554,-6146,-3807,-8128,-7921,9673,-8236,4422,3618,644,-9037,7828,-4280,7120,-1967,3754,-8797,1116,-8854,7518,2723,-6511,-3465,3018,9189,-4329,3757,1008,2961,-2115,-8530,6798,-8703,-6099,6556,4460,3201,-6284,-7726,-9000,-6445,-3327,8781,-8562,-1282,9002,-1833,6386,-26,-532,2443,-5926,2326,1183,-6605,4701,-7262,3360,2320,-4221,-2637,-2788,2358,-4870,5841,8329,394,-4871,5862,-3879,-5982,-760,9806,-9298,-5685,1836,6732,-1979,-2539,-1720,-9042,-5952,8285,-513,9037,7119,-1561,-8007,829,-9878,4789,1292,-1292,7625,-954,1061,2359,4464,-1545,-9391,-9482,1575,-6363,-8227,-6613,1305,1257,-4648,-9956,9741,-4118,-7035,5230,-1195,6057,-578,5334,2041,2583,1456,496,5353,-2807,-1166,-9587,-255,9421,-4257,-8304,-5010,-9750,-218,-4517,9112,-5702,-5200,-123,2557,-8125,-7500,-8151,2616,9806,-1498,620,-1096,2121,-1964,-8936,6071,865,6458,-7108,-387,7455,-6679,-7208,3465,8426,7642,5837,-4288,-2687,2744,-2902,-8283,8362,-109,-7688,-800,7282,-8738,4199,-2780,4166,-3396,1974,9577,7381,-3267,-5041,-4927,-5352,-6102,-7217,7639,3469,2975,9357,-6226,8160,289,-3894,3834,8369,-458,-7824,3101,6863,8970,322,3791,377,8072,1622,6939,-1230,-3391,3744,-4040,-9281,-1363,-9733,-982,3447,-8995,6567,-5838,-7614,6162,-3007,3462,937,7502,-7576,1240,-1783,6771,-7732,-9317,1097,1196,-9526,777,-1946,-6843,8968,-2978,4293,-2042,232,-1791,1192,4695,6364,-4207,-2844,-8637,-5297,-8807,-7552,7970,5220,-3913,-1911,4983,-850,-9322,9755,-8617,9130,349,-731,4166,5547,8366,3683,-2386,-8920,-1685,-8047,1611,-5621,6918,1459,-1841,3508,9739,-8313,1077,6570,4014,4145,9420,8085,6324,3725,-6599,152,-8780,361,-5647,-7419,-9714,4583,6354,3715,6348,8921,3669,-5944,5003,-8754,6513,338,-3527,-9789,-669,-6682,6384,-1597,9825,657,-3609,-2889,-5481,275,5666,-6111,-7878,-9807,-1999,-5734,5890,-2387,6711,-5075,5317,5994,9885,8972,-923,-8381,-4974,9994,-5868,4998,5168,-7072,2103,6866,1682,1230,-5055,-3685,-4656,-359,5230,9249,-6854,5192,-3839,375,6409,-6887,-5887,-5114,1957,-583,-6348,6520,-4967,-8106,7380,1297,112,-3203,-9369,-9662,5013,-1952,-8804,9608,9486,9902,-6550,-7626,9697,-181,-1143,3642,8818,9802,469,-7678,-9844,1132,4574,6337,-9518,-669,6887,-5741,6920,-7463,-5221,-577,3737,6045,-9545,-6891,4229,4436,-8725,-5150,-645,-3754,644,-6008,8873,8480,9789,-7793,-5530,1609,4616,2814,-6392,8772,-7221,9347,-5513,-9346,-758,9341,-2306,8756,-7452,-9029,269,7416,1225,-4367,3654,-7176,5032,7575,-7742,6446,3486,1697,-1231,1423,8582,1450,-1973,-7296,5019,7898,-8436,-2199,6933,3260,2423,9491,8713,-5935,9305,-17,-9986,433,-9583,-2397,249,5329,9523,-5353,2729,1432,2852,-6644,-9101,7234,-4188,-2772,-7131,-9023,-1573,3842,-7798,2018,-4264,2943,-7891,2316,1436,6465,-4665,8747,-3284,1262,-6360,-2659,-7078,-2724,359,952,-1159,3953,-5766,-3986,-6909,6487,2373,1794,9137,6732,-5748,-5385,-8256,9151,-7587,-6975,-1938,-9675,-5566,8495,1844,7404,5338,-5654,-4729,-8907,-1774,8409,-9734,-5364,4105,8299,-2147,-8195,9695,-898,-8608,-8793,-5444,-5946,-2088,-6839,9152,3296,-4687,-4969,3176,4493,-2318,-2457,8673,-6012,-4037,-1612,-3510,-5981,4999,-5894,6490,-5592,8381,2066,2646,7542,5555,2257,5344,-8208,-4567,7759,-8475,4503,-2350,7246,1307,8402,-3012,-2342,-2864,5276,6570,-3574,9756,-8135,-7918,-4011,-8505,-4357,7317,-2493,6700,7778,2581,-5816,-8638,2623,-3697,1706,3584,-6342,2794,-9934,2701,-8802,-1633,5917,-8695,-3001,1632,-8519,-6071,8365,1068,8508,4257,-248,-7274,3809,646,-4726,5665,1452,8303,5961,-6232,-7306,-920,-8036,7057,4238,-8433,1461,3276,9783,-2179,3294,1759,6373,8185,9335,7363,5578,-2584,-3494,-1175,-803,-8488,-5810,-7164,-4492,6075,-8035,-6883,4431,-6367,-1418,-7218,4535,7387,-2000,9719,6198,9721,9918,-4792,9413,-2402,-6028,-1143,-4902,2563,3781,-1103,-1157,-2318,-711,9671,121,-1183,4024,-2932,2347,-2896,-1883,7256,181,-3861,9731,7675,7224,7920,6281,-6887,1104,5637,-7218,-3644,-1156,6902,-6410,-9010,-2315,-6041,1635,-3893,5801,-9306,1793,-7271,-8974,9737,3064,-7013,-8550,-3311,-6333,-4697,3365,-9464,-6152,6938,4320,4706,-6571,8240,-7257,6275,9842,-5304,4611,4874,-8964,-294,-7602,3458,-4302,2275,-8361,4685,5052,4911,-3960,7258,-3440,6766,-6235,3638,574,-7645,-8770,-3762,-4410,6907,-7693,3178,6512,-7533,-5007,-4899,1040,-5680,8034,-330,-6237,-5983,-3623,2813,-9102,-9574,2415,-8008,2674,6489,1360,-2055,-6441,-4307,-9004,-2110,-242,-8453,9947,-2146,7515,4094,4435,-1076,4464,-6739,2333,6672,-8184,-9469,-7484,6317,-9477,5394,1238,-7050,1770,8024,7277,-5029,-3479,3474,-6809,-4216,4973,-6301,4137,-3757,3090,-303,-6414,602,-1883,-4834,2107,4851,-7307,4207,8029,8557,-5156,-931,-2948,6207,5647,-2013,8455,0,7631,-9244,4160,83,-9539,-9444,-7231,-2419,1380,-4026,-8018,6837,-3864,-8135,8096,-8262,1606,-3315,4163,6766,-7191,1866,7858,8760,7499,1474,-1932,2632,-8138,7436,-5689,-6790,4045,7497,9912,-7695,-5162,-8751,-3445,5284,7773,94,-5240,6343,-5849,-1469,9269,-1512,6920,7307,-3969,2247,-7385,9077,-1464,-8399,-6174,-3104,3621,6313,-3625,9406,-614,-8696,681,-2787,-7903,1372,7787,5061,8473,-6823,2040,9251,-1637,-7747,-4913,-8068,-2669,1027,6914,-3782,-6502,7646,-6234,9076,-9346,-2596,-4342,-6652,8828,-432,5989,7197,2802,5055,9185,1433,7905,-6839,7111,9880,-5914,3849,-59,640,8571,6075,2072,6306,-3638,-54,-9184,-4186,-3065,-8317,6932,-5427,1740,-8067,-3721,-9473,-9808,-2642,-8798,-8639,9340,7665,-6812,-2968,-4442,6195,2973,-2768,6294,6759,8688,-7912,8550,-1337,-3265,-8116,-1681,811,-2846,-3861,-4468,955,-261,-6499,-4339,-7788,-70,2233,-9120,-3656,-9873,4904,3450,5373,-8454,2654,-9155,349,-8585,5769,-4906,-451,5378,1992,-1457,-66,1571,-8890,-7709,1005,5629,3943,-9230,1705,4347,1203,-8473,-6260,7553,-280,431,-1291,722,4311,-512,-9853,2073,8090,5917,-3333,-7419,-7980,-3980,6177,3703,-4609,-2859,1270,9385,-2496,7768,7175,-1728,-7935,9393,-3234,9485,5594,-8597,5041,-9568,9044,750,4995,8170,3602,-9466,4952,5338,5140,1836,8504,-7719,1330,-6176,-3352,9446,-1366,-7308,5860,-3636,7977,-4407,-5077,-1241,-6829,-5296,637,-2673,8382,-3540,198,-9093,8099,-9359,8094,-7524,-8186,6078,2724,6925,6610,-1990,-6584,-9826,9258,-8378,2509,4854,9639,-7706,6835,5337,5205,9278,7845,9854,8723,1432,3751,9809,-6416,-5903,5988,-2767,-2373,5764,-3868,-202,-8134,-4972,3516,1330,4455,-7289,-8927,-5746,8092,-7775,2157,-2182,4192,-783,-9890,9156,2655,-8925,-3858,5207,-7280,-7171,9426,-7201,3062,4981,681,127,-4502,-1038,-6929,5673,-5890,2075,3929,6281,9714,5567,817,-3553,2825,-805,6684,-7333,-6081,1363,6313,6531,2396,-472,4587,-5125,7855,3273,-526,-227,6809,-2955,3468,-134,4573,-9793,-8844,-5782,8242,-4744,-616,-9418,-1476,-8131,-3537,8892,-567,2324,9154,-473,4582,4473,-9575,7356,-4570,8624,4044,7726,5211,7553,2583,-7718,-9259,3744,1202,-6952,1536,9350,265,5801,5073,-1365,-5786,-7628,-8790,-9038,3786,7248,5899,3337,-5191,1785,6285,4699,882,3512,9540,-1734,-3647,1941,-4124,4060,2970,-9894,2868,-9901,2142,-8514,6461,-4099,570,-7463,-2505,7858,1198,7394,4011,-2887,3462,1978,-9631,-8184,343,3864,-3368,-4151,-9309,4083,-3766,-4130,918,-2332,4821,-8476,-2586,-4791,-5658,-4224,-9841,-6160,5744,6409,5130,1897,-2889,-7052,4486,407,3220,5637,-8435,-3401,-5809,7336,-7595,2943,-7639,-3426,5693,-7027,-563,6918,-4,3718,2621,-6332,131,-9809,-9027,-2441,-5422,-8401,5494,8059,-8283,2520,373,1153,-8177,2373,2947,-9781,7171,2078,-2543,-6073,-1061,-1917,-7976,-6098,-2262,6601,1483,6653,-1889,870,6893,8317,4277,6388,9407,-7424,-4194,-2163,-5427,-5007,7120,8760,-3364,-5161,4271,8433,9019,5141,-1474,-2486,9629,9440,8456,482,5105,1745,-1512,-5409,4446,2257,960,-5222,-4257,-7034,7581,304,1539,-9630,3169,-1017,221,104,-867,3834,7081,2588,-6682,-5308,7695,5605,8573,-3269,1569,-4193,4996,-7299,2893,8734,-6716,2298,6876,553,-2071,-9710,-1690,7804,4369,9940,-630,-6378,-1621,-539,-7908,5169,-3492,-2799,4503,-257,-8288,-2919,-7462,4237,-8118,-6029,-2391,-8609,7645,3028,-3447,-3182,-2343,-3510,6663,-5275,448,-8412,-7034,969,8010,-5364,5076,-9706,8399,-7516,652,-3776,-1124,-6698,1590,-5102,-3184,-9793,-1875,-9261,8477,3014,-9408,5640,-3010,9699,-346,6239,-533,1261,-5278,-1698,-9553,-4772,-5492,9808,1478,6690,-1660,3637,4544,-3354,-982,-7023,3347,9682,-3079,1439,2387,-2727,-5519,-5800,-796,1767,-7125,-1349,-3710,-6747,-8210,-5997,-5626,6771,-6191,-8276,962,2527,-9359,2541,-6984,538,6044,17,4493,7150,-4439,-4251,-7880,-5530,8634,-2792,5329,-7463,7189,7568,-4654,-6917,1486,-6477,8830,-9192,2639,-4051,-9567,2364,-3353,9459,6236,-3113,-9522,-9233,-8390,6749,-5299,-8518,-3244,4866,1987,-3560,8815,-3804,-8583,7771,-6971,-895,7243,-6139,-9535,-7629,-6652,-6607,9258,-9689,8537,7623,-3121,-9014,7129,8851,808,2465,359,-9899,5478,-941,-4594,5568,-3663,-8355,-6253,-8619,4725,2337,-1747,-9357,-2287,-1349,-3505,-1239,5383,-7180,-3088,-1533,6881,-6713,8119,4608,-2212,5114,-3948,-9871,9792,-1221,6560,6698,-1479,9488,-5785,6459,-6337,9984,9695,3781,5624,-459,-5138,3830,-5517,-3510,7690,-2194,-2736,7737,4721,7213,-774,-8442,6119,4998,4659,6937,-2717,300,1116,1323,-8588,-6745,-5223,3496,-278,-8628,-5858,2230,-6156,5371,-3793,9345,7592,3698,-655,4181,-9123,-384,-2814,1660,3519,2656,-8107,-4925,-3725,9492,-7341,-5016,-7852,-7598,3075,-8342,-5691,-7130,3643,814,-772,1210,2044,-6727,-284,6956,-7779,2605,5034,7879,-7660,5942,5104,-3083,7307,2335,5986,-3139,-1009,2580,1760,-5015,2952,1861,-2905,2451,-3436,-2901,5289,-1821,-3976,2262,4694,-7787,-4127,-6245,6606,-4533,-340,-990,7434,-6551,8891,-931,-2454,-5958,-2865,-2298,-6553,5490,-154,-4629,8780,9632,-3296,-3291,-9129,2056,1496,606,-2827,-1072,-7598,9496,5690,-8620,3448,2413,8886,-2218,5728,3435,7221,5955,-3421,2737,8742,-9046,9077,-1247,1894,4219,9673,-8687,8919,5682,9917,-9280,9023,2415,3353,4123,-4985,-4251,-258,-8611,-3851,-5250,6878,7020,5729,38,-3841,994,2470,16,-9464,6298,7853,-478,-2529,-8769,5853,2180,-3287,1083,7778,5874,-2081,-8853,-1669,-718,5505,-5517,-2056,-8144,8195,-4468,-2712,4807,4862,6309,6701,-1115,-9444,3584,9722,7211,2627,-8731,-2277,-9783,-9835,-3562,3700,293,8780,-4789,-5457,-742,-4710,-7909,-1339,5445,416,-6314,-9202,7214,-2340,-9528,1048,-3480,8465,-3688,-2925,-201,1152,1750,-9905,2657,-8630,8860,-5105,-1603,-3972,5258,-9827,807,3282,2328,5456,-9818,8834,-2203,8990,1704,9670,-5258,-8140,-4791,788,-4483,537,-2467,4685,6605,-4772,8753,7560,-5888,368,-9311,8732,2,-3683,-3671,-7010,-5562,-5567,5238,9691,-5244,-4399,-6683,1180,-2645,-7249,-7265,5604,5955,-401,-5827,7433,2660,6890,-4960,5674,156,-7457,4493,-7550,-7748,9179,-3002,-3131,860,154,-59,1363,6753,-5566,8066,-2736,7769,-371,-4926,-3399,7038,-2982,-4486,-4719,-6493,-9795,6703,9067,40,3582,-8960,1853,-4400,2332,-8789,-538,261,3526,7215,2203,-8290,-1172,-1838,6147,8004,5479,-3744,-2025,7806,-241,-3993,-3602,-1625,3665,-2792,8050,-6339,5404,-3260,-6535,6851,8245,-461,-5539,7105,2566,-2253,468,2357,-1572,2177,-6377,842,-9219,9240,-8456,-1711,7752,2600,-8519,4669,5805,-7937,7833,8119,-7654,1469,-9224,-1261,-7789,9830,-4729,3727,105,3237,1239,4318,8818,2283,-919,686,2732,4190,-6996,-1505,6459,8109,-1106,128,-6678,258,464,-3807,-390,3237,4552,-6369,450,-6633,9246,3418,7991,-2649,-1394,9551,8610,-8957,2871,-4203,-6556,-506,1253,-5489,5684,-131,179,-1398,-60,-766,-5666,1319,3354,4644,-5282,-1290,-910,-1034,930,6848,-7046,-8217,-2338,2608,-3437,9438,3793,7406,-9665,-2575,7150,-1107,7508,-4757,1201,-9603,-1999,348,6554,-2602,-7963,-9829,1492,-1243,-283,5581,9221,900,-3456,-2969,99,8766,7726,-7366,317,4912,1399,-5916,9059,3413,6218,-1271,21,4693,-8221,-8835,4162,-1376,-2134,-6587,3820,856,-9323,-928,8426,-4793,-4653,3005,8224,-3944,-3941,2639,-3562,-8675,6692,-5305,8066,-6626,6259,8183,7314,-4866,-2383,-107,-1491,-5215,-8683,5594,-2802,-6668,-3184,5683,-626,8332,-4177,-6416,-6843,-4473,-2922,4201,1867,-9070,8178,-2930,8076,9331,-4612,6290,-1115,541,-1911,-1532,-830,-9309,-2655,-2642,9813,7427,-1109,-2988,-877,-3445,7904,3349,-86,-5420,6378,7334,5859,4692,2639,6367,1690,5414,-6725,690,-9489,3027,6942,46,1558,6256,5501,4802,4951,6756,-6775,1898,-7214,-1981,-8296,-6751,9391,-903,5455,7326,-1876,-1986,-7992,-2480,3671,144,-313,9561,5305,-7700,-3830,6489,-8828,9795,2721,-329,-3441,-9572,-5717,5379,2270,9839,429,-9429,9700,8729,275,-8518,2504,8294,-1713,-711,7670,-9574,-6252,5869,8702,283,7342,-9348,-7575,8638,379,1254,-9222,5363,-837,-157,-4067,-6157,8102,9010,-8648,-8655,-4734,1962,1220,-4142,-4873,-7070,-4094,9116,8731,-1641,7632,-805,7839,-9507,5537,-9364,8576,-7514,-9577,3493,3154,7004,-389,1604,5465,4214,3284,-127,-7431,-5127,8588,9317,-3434,5268,-8974,5111,-5080,6535,-5284,7297,4807,-2434,9545,5280,-643,-8756,-491,-3565,-8419,-2837,5003,-8479,2294,-3525,-9918,-8398,1532,-129,2436,-9451,-4933,6410,6847,2351,6109,1467,-5403,-6808,-3815,-4776,-6289,6041,-4129,-532,-5397,8745,458,8042,190,5691,2236,-7303,6541,7327,75,7145,-8011,2916,-6047,8625,759,-4386,-3341,2987,-2414,-8710,1300,-224,7772,8581,6388,-3247,223,-2110,4708,-2548,-9758,8036,8185,1523,5005,870,-7841,-1220,-8687,-4438,-4189,7468,-6053,-7725,-5992,-8558,-4954,869,-2040,2920,-5636,8031,-8889,2633,372,-6841,8167,1504,4995,-2162,-3148,-8063,9014,868,9347,-6238,-9742,-9347,-8759,-1593,-1304,607,2830,3257,-1411,9043,-8521,-6083,-1636,-695,1485,-9476,1958,-9713,-2942,-644,8578,6158,-1747,7247,-937,228,-83,179,5817,-5071,-7958,-8638,-6660,9666,-6394,-7694,8046,-1187,695,-9213,-6597,-8744,512,5071,91,-9026,-1028,-6875,-9690,-7650,1382,-6710,7907,-1379,-2932,-7385,462,-3951,-2577,4219,800,-9459,-1052,-6287,-1995,2629,2748,-1831,5339,-8764,1562,-9003,7020,5622,5928,-5509,-5971,-7374,4556,4862,-2247,1908,707,-5586,-7996,-3387,-2041,-8876,3024,-4173,-972,-2032,-4571,-5027,-9979,-8087,903,-1874,-3956,-1681,-6277,-3006,-4316,6452,-8439,8980,3223,-7461,8249,-4296,-1622,819,-3868,-7159,1354,2351,-3888,-6043,1521,4731,6236,4178,-8065,3764,575,-801,609,-6610,3209,-5654,-667,-5131,-4285,6159,-5933,4172,7025,9283,-5548,-2087,7504,-3847,-1355,-9750,-906,-9161,9407,-682,-5114,-4874,-7303,-8193,-8621,-5474,-7714,9896,7509,7783,1438,2970,-6413,2817,-3888,5013,3670,7348,130,-1723,-4688,-2371,-8784,-9220,-4388,306,-4908,-8958,-7110,7161,-1675,-9844,-525,9944,-3305,-2221,7772,-7965,-4185,-4673,-1478,-9237,-9711,8978,-5535,-1515,6651,8797,-5195,-3773,-5330,-5783,6135,-3231,569,4876,-2335,-6264,-5245,2607,-4662,-8026,6423,8165,-2090,3446,-1806,6356,-3838,-881,-5870,-5685,6362,-593,5500,3626,-5707,1634,-8637,-3886,3256,158,-8218,9616,2993,3200,-4267,-2857,3220,-7108,3875,-5750,3904,-8935,-6222,1315,5054,-5201,-4186,-1682,2760,1224,-5607,-1806,-8340,8717,5885,4671,-980,6556,9619,4231,3261,2641,-9655,-389,-1245,-8125,-5534,-8497,3330,-5361,-6717,7536,-9193,-9320,6121,9413,-3353,-4560,-2859,-743,-3385,134,9777,-8664,-5423,-8816,4156,7652,1739,4736,-3306,2965,6308,5094,-9908,9553,-9083,-6140,6317,-5354,-4371,-2588,-1251,1734,9048,-6361,8069,1123,-8560,-6689,-2088,-9582,-5056,-8095,-2107,4514,-6875,7448,7322,8842,-2618,-1499,-6580,-6599,5995,-7090,6350,3748,4145,237,-8580,983,-6734,5357,-7130,-8128,-5097,-3287,-7919,6315,-625,684,-5627,-2401,3601,8105,2553,6785,-4038,6735,2045,-4552,-6634,-6183,2226,-970,1888,5525,6304,8295,5626,9270,3040,393,-7534,-4761,-4913,5087,3666,3169,4733,7382,9509,-7313,2040,-2255,5284,8465,258,-5622,2006,5257,-2292,-1167,7404,9174,-7813,-6850,8959,-3166,6838,-3442,3855,-8325,-1549,-2226,-4721,-5080,-2313,-8787,-3003,4946,-8463,-5032,1578,9480,-6313,6206,-838,9371,8626,-34,-1813,9800,-9226,-341,7347,888,-2950,5229,-9944,-6061,4520,9694,9335,-2808,5173,5992,-813,-3018,-6054,9746,7570,7456,-401,8508,9333,-3963,-664,1793,-5194,-711,8960,-4485,-9446,-6856,2104,-738,-8638,6883,-9653,7263,2800,2918,3451,-6904,4429,-574,6875,2425,-1291,-6566,4673,624,-2973,6734,5264,4797,-5827,-8646,-6138,-2469,4985,-3535,-351,3528,-5452,-9188,-5530,-7567,4655,2735,-1592,4651,-8681,-4308,1501,2512,2335,-3818,5663,2757,2177,-2080,-349,-913,-5114,3523,3006,-4163,2899,-3724,62,9765,5606,-707,-4453,-9227,-2144,-9393,-2350,1317,699,1225,-7181,258,9931,8240,-2217,6320,-5240,1286,1998,4187,-7351,-9745,-9173,885,-9507,6468,4913,-6216,6013,-3457,-7360,5626,-7394,1691,8820,-9555,-7564,-6979,5419,8877,-2950,-7087,-3249,-9719,-5615,-9218,-17,-3527,6821,-3239,8843,677,4787,-7213,-4138,2128,6294,5468,5469,-1377,-149,3973,7684,-4728,-7710,-3385,2730,7128,-4702,-5014,-423,5997,-2025,-862,-356,2841,-9726,-6881,-4362,-4305,-3259,3140,3766,9602,-6017,-126,5011,-4331,9687,-3194,5293,2328,3646,-3999,4898,3354,7144,-339,-7543,-5917,-4028,1144,542,-9414,-3419,-9172,-26,9651,9407,3765,-6122,6676,8812,4802,37,-5817,-6725,-6381,-5038,9573,6602,1052,4752,9210,715,2968,-9533,2215,97,-4073,7410,-880,5701,-3980,-4417,1927,3734,7444,1923,4569,1980,1287,8660,-9263,590,-6206,4083,8004,-5830,-2102,2769,7373,1386,8716,-3067,-7780,-5268,5021,2607,5238,8452,-3214,-7654,6194,-7087,4446,-8669,1007,-9862,-8292,2160,9700,-7,-6452,-5688,-6786,-9372,-5850,1658,8606,-2897,5226,-6594,1872,-7202,-7628,8443,-9422,-1666,-9576,5638,-6129,-3471,4951,7879,4230,1863,-5800,1971,4266,3855,3164,3988,3378,6839,8514,3925,-2789,-673,-353,-9,4130,6379,-9074,1054,-5501,1421,-2475,2840,-21,9173,1257,-3133,4670,3486,-7103,7567,2044,-9504,7394,-9718,6350,9227,5277,-8945,-5588,9036,6872,8156,-6304,707,3460,-8403,-1155,-6792,2895,5607,-2218,8667,-438,6918,-756,-9230,-2419,7485,8937,1946,-6754,6350,-1368,-2028,9855,-449,-1583,3018,-53,-257,6983,9253,-1097,7193,-7724,4124,646,8097,-7722,1435,-1738,809,-3040,-4875,2705,-7458,6923,3794,-7649,-8602,-7489,-5354,-8510,-6385,-7892,3425,-2721,-9921,6062,235,-514,6483,8513,2600,-6894,6577,-8314,5928,2851,-4956,-6908,7783,-9276,-3386,-3242,3820,3782,4140,-2546,-3292,7465,-8426,-9503,-3512,1182,7650,9769,3061,-6934,-574,-1768,-3103,-2570,3914,-3842,1532,6692,-361,1232,-8135,-3863,7847,-9947,2558,-5368,1812,-7197,-6626,-8696,9388,-349,3959,3327,-8835,-6065,-7225,8479,-8603,6391,5753,-2033,5878,-5782,7829,1969,-5496,1925,-5101,9382,-6128,9525,-9317,4266,-6278,-8900,7146,2678,7953,960,-4974,3226,7405,6840,-3630,4133,1788,-1500,1701,-4538,8979,1498,-1837,7647,-9441,-4481,7426,-2438,-2225,3689,2141,1862,5294,2810,6432,-4832,-8207,100,3964,9929,6829,743,-3904,-3473,5176,5630,5365,-9214,-8807,9354,-665,-1659,-9092,-9130,-7733,3936,777,-4595,4522,-516,4925,-3478,2091,-1411,-4892,3981,6989,5771,4500,-1833,-2500,8438,-3077,-3021,-6256,3350,-5406,-156,6612,144,8557,-1464,4788,-7798,2266,-7840,8664,-7107,439,-9813,8360,2100,-6790,2533,-1071,-2647,-8715,-6955,-9472,-7776,-8130,-7483,-5959,-172,8188,9156,-4346,2079,-7540,-6540,-9679,-211,-5345,9980,-2996,4259,4192,5881,8314,-1467,-7313,-5261,6437,-1099,6003,-2317,7104,-7815,-8727,-5898,-1643,6055,-5294,8385,2890,3441,-800,-6675,6508,6998,5224,7814,6591,6606,-3143,-5974,-672,-4256,-8597,2690,4006,-4538,-3871,8552,9018,6034,1540,7748,-2343,-4909,-1683,3895,-4934,-5173,-3890,615,8698,-9505,6281,6660,-4936,6528,-2776,-3513,9671,1910,-2700,-1369,-68,-8593,2722,4971,-2943,-6542,7688,2627,-3596,-4034,4877,-4822,9405,1370,8620,6024,-8855,-9696,185,-1624,-2618,-8299,9981,-9217,7544,-1627,2477,-4397,-6342,-8976,9145,-8815,6374,6637,-9676,832,-2832,-9267,5788,-3178,1336,-7392,4586,-4433,1929,-6643,-8921,-7062,-3573,-1377,-1856,-9511,-9457,-3871,-8701,-7937,1473,-7780,-9510,-9575,-3787,-686,-2676,-8259,-8997,-5324,7373,-1060,4275,4439,5724,4504,-7403,-8145,6401,2735,-1437,-8533,155,-1233,111,-8174,4896,-6613,-5354,9578,6860,-7229,-9006,8667,4682,-9259,-1183,-2064,-7935,-5497,3474,-831,-4842,-8919,-5378,5038,-8953,-6441,-1537,1636,1386,9081,7124,3640,8647,-7303,-882,5960,-3037,7726,-9709,-2866,-7313,9221,7834,9086,6721,3841,3712,7226,-8716,1952,1659,-3028,5388,-2817,526,-7219,1502,8432,-5729,3371,902,4301,-5800,-7180,-5324,2784,-6311,-6170,-3585,-3347,-5639,2860,9022,6602,-6723,5499,-4054,4304,-2052,2707,-5900,6433,644,8420,-496,4872,-1677,-7640,4809,5444,2056,1271,9535,-8664,-4883,-4922,-9880,2840,-8167,1586,3931,-3623,-5406,-1300,7498,-4935,-2762,8527,-2923,3646,-142,7060,-8190,6458,7839,3144,2150,-1568,9902,-858,-8605,7637,-3109,-8285,6725,5425,3063,-3646,2421,3832,-8385,-8347,-4366,-1405,-3122,-3688,6317,6754,-9129,-7197,4938,5329,-7496,3247,-1239,7584,-2819,-9090,5223,7951,6494,-5946,-3185,6228,-2843,4694,-9267,-8937,-9469,5089,8476,3912,-5471,-5296,7059,-479,-1050,1503,7992,-9743,-5664,3653,8721,-2158,2777,3685,-5690,-2421,-6745,99,933,-763,-7683,-8942,5862,7664,8167,8146,-4923,-7925,3239,4258,351,-8930,-9099,2063,-9423,8505,-8835,-1602,8352,-4311,2976,6531,-6556,145,-2187,-192,8458,-3379,6883,-2865,1242,4550,-210,3038,-4364,8284,-5111,-8050,-4451,-4077,-2444,-7915,-4748,-4185,6597,4133,8788,-9733,-4998,-5386,-7205,3203,530,-3789,4821,-8866,-4572,8259,-639,921,-1180,-4565,7272,-2705,1771,3491,1394,9814,-7271,-5626,4134,2720,-1167,5928,-9183,4428,-5612,-4807,9896,-7243,1469,-4725,-2326,-1389,-6658,1513,-9366,1423,-2979,3622,5956,887,-5588,1701,8938,5019,4493,3664,8535,7998,8532,-3977,6244,5864,-3922,-7723,8732,8253,-7820,-4229,9488,-9848,110,9428,-7874,-5467,-3660,2577,-46,7417,-6660,1331,4884,908,-7404,1403,-797,-5487,-2327,5990,394,-9696,-2605,-3228,-9551,-2588,2048,8799,7877,-6270,9314,9140,-3544,1236,1589,5159,-6244,9002,-2775,-1598,-5251,-6026,-1983,-3876,-7508,2133,5454,-6833,2932,7531,1863,-4157,-2618,-9158,2300,4278,2781,-5981,7913,-2238,7006,-8541,-1479,-1978,967,-9201,6697,-641,-343,-9017,-9869,9686,5309,8571,4439,-1036,-7165,-8173,-4674,8984,4543,4101,9961,-6778,6920,-3539,4208,-4285,9557,7896,3468,5152,971,-9077,-2735,5892,-815,-3836,-1938,-9331,9321,2624,-7499,5117,3422,-187,-2793,7961,-940,-8642,-4818,-6349,1991,2798,-9023,4970,-9536,7240,-1845,889,-9702,-8431,4322,7261,-2957,-6907,2483,7130,964,-1533,-9278,-8780,4439,-2402,7978,9240,-7166,5283,9017,3241,1673,6903,1144,-8029,4731,-2437,753,-5360,1830,-4052,6715,1450,-1475,-1635,-2212,2889,-9602,9781,6216,-3092,-951,7961,-3204,-6855,7489,-4306,349,3546,-651,-9805,2688,-9745,-7225,8034,-8250,8856,-2438,-9904,7804,8983,-2827,-3544,-7439,-1078,173,-5860,2855,9925,3024,-7041,8515,-6520,-8663,-5607,4550,5973,8149,8184,-5535,272,9287,8506,-7211,5415,-9141,-2109,-7392,-5754,7484,2759,4857,5153,-2330,4120,-5666,-1593,3193,992,-982,6335,-7018,-9668,54,3874,-49,6271,824,-5111,1216,6347,-7191,9538,8289,-1344,-1025,-2935,528,1757,7306,9198,-6318,-7381,-8443,5031,-2220,-2112,1452,8415,-1902,8087,208,-857,4388,5019,8902,81,-4779,-2705,4096,-6871,-2744,-4913,-2990,-5887,-1026,-9002,6523,-9569,3616,-9767,4512,25,-7687,791,5629,3254,-9404,-7866,-8800,-7933,-9808,-763,4309,6585,7556,-5072,-744,-5007,-9116,1799,2875,9439,1827,7812,8179,-299,-5561,472,-9776,-1511,6607,1686,6261,9207,8446,1467,-9494,7171,-8433,8561,1171,3739,7545,-515,2872,-3700,4112,172,5600,2074,320,3115,-1281,2663,7833,-4461,1575,6293,-1576,645,1135,-649,2403,-2928,-6161,-284,7485,-8118,4042,2381,310,7374,7456,-9921,-9923,8476,710,6774,-7320,-5247,2087,6748,5796,470,3798,4491,-2564,3085,3091,-7178,4378,3364,9218,5504,1161,-8683,-5917,9941,9611,2188,-5275,-3339,-5859,-2794,2612,-5908,-434,-6310,9004,4833,-587,-3454,-2594,-8550,848,-3522,229,-2347,8323,-7678,5826,-8173,3040,4538,1168,8538,8613,-7336,7131,4987,5156,1373,-5108,-515,2022,-4374,3177,-9918,8586,9179,-904,-8192,-296,8794,-4677,-9537,8472,-1431,-1776,7629,343,7360,-8831,749,1990,-2103,6154,-1172,-1440,-9542,-1547,-6275,3542,3904,-5906,-7575,981,3127,9717,-366,-1752,-5000,-3794,-303,132,3007,8416,1912,8864,-1041,2046,-8222,-5726,-7988,-1130,5508,-2026,-4608,4223,2522,3,-9130,-2844,7438,-8947,-8519,-9274,459,2400,5776,-2782,-6133,2929,9782,-9884,6336,-5280,8346,6509,-2179,8840,-2507,1996,-794,5861,-1742,-4773,-6746,-4709,5699,-4853,-9919,1850,323,-9078,-1926,8717,8512,-7308,968,-7941,-7030,-5828,-9206,5665,-3625,7898,-3572,-4628,3286,-6721,7349,7842,-6948,1126,-1867,1124,9377,-6833,7648,-4315,1,-3013,7914,4832,-3586,-2188,-9698,4096,-4706,-5001,1502,4803,8872,-2044,7155,-7119,-300,-2258,5139,-9176,549,3976,-7941,7808,-8892,1408,-5754,-8031,-9170,-2482,-3640,3483,-1462,4928,-6584,-3824,-3546,-7952,9736,8498,-7099,-1205,2560,-5911,-2624,4695,5169,-5884,-602,-978,3291,6361,6187,-2220,-9578,-5245,-8173,-2138,-4885,-8481,3620,3272,-4808,-8395,-2508,-5266,6542,9360,7352,-57,-2518,-5799,3427,2174,-1826,8868,3984,2698,-1206,-2146,7973,-4555,-1997,-1933,-3526,-1100,6085,-8223,9586,6553,3468,-3384,9091,5039,-8323,-3427,-2500,-1644,6551,-124,5923,-4029,-7348,6887,3521,254,-625,8602,-8010,3669,-1498,2256,630,5403,2196,9934,6020,9058,8354,-7911,-3469,-5082,-8666,-3897,-3470,-1634,-3142,-8098,5002,-1983,417,-4183,-4444,4713,-5138,-8391,-4270,-9748,-8322,-6032,-4348,8320,-6486,541,6825,-3375,-559,9854,1103,-1068,6156,5411,-5053,-1632,7465,6429,-2467,5717,-2477,5938,3234,6984,-8756,5139,-9761,2133,-1024,8769,1436,5222,-8227,6638,-38,1942,-7022,-1614,2109,1147,-4339,-6674,4819,-4782,6661,-8265,5064,9200,8801,9673,-9980,1143,-7498,3159,3008,7948,2445,7893,2560,-1053,-6502,-9559,-2031,-6392,1133,5202,-719,-3971,-4263,8273,3454,8135,4726,-504,2969,3723,9009,8603,9317,1634,-8140,5754,-5393,-5402,9428,-164,9744,4240,-7598,9595,-8319,-4686,5581,-1894,-4477,6144,-1049,-971,-4333,3318,-3284,8649,6883,-77,7486,-1462,7624,4918,7619,-504,3956,-9353,5492,-9445,671,-9839,-1958,-8947,-2611,-4819,-6770,-2029,3840,-6524,5552,-9902,-3252,7810,-4418,6162,-8970,1766,-4938,-7173,1366,2253,1807,3868,3673,8923,8896,-1560,354,7694,-6190,-1438,-4787,-5600,4992,9864,7686,-4440,1346,4707,-2315,-916,215,-7918,-6963,9741,-6047,-2199,3575,-9481,6413,-7983,8005,3969,-1011,1937,-3327,-280,-4791,-6980,2014,6366,3644,2722,1914,6508,-8698,-9846,-4463,-213,-4237,-3869,-6368,9261,-7271,-5617,2346,8938,-6983,1833,5917,-7194,-7732,5744,9936,6209,9504,169,-1732,-3065,-570,-1270,-8250,-9913,3553,7749,-3754,3152,-423,-8090,-8651,6861,54,7203,855,-3756,-758,-7837,-9227,-5203,-7761,-375,8014,-9005,5854,-8979,6341,3996,9786,-1224,9139,-9141,6240,-2079,-2761,4423,-2283,-6595,-2502,-8722,4803,-1462,-4087,6497,-6551,7631,-4134,-2311,9861,-6461,8603,-5635,6453,2643,9550,-5001,6456,623,-4282,-5636,-9360,8753,4071,-9505,-9344,-1714,9194,600,6919,2689,2398,-9543,2284,2227,4637,3918,-2212,-2042,5497,6473,-2836,4682,3184,-8760,-8951,1900,1973,7493,1576,108,-591,-4046,-8004,-8910,2890,-182,-6580,-1241,1092,8133,-1438,-8545,5001,2654,3627,5784,6201,-9475,226,7016,7008,-6870,-8846,975,3266,2124,2600,4153,9053,-3096,8444,-2954,9525,-8114,9824,2059,9762,3807,3003,2945,-7452,-993,-848,-6838,-7410,773,-5489,-1305,9230,4212,8431,4144,-3703,1790,-7764,-5199,42,-2452,-5152,6411,-7880,4876,-4894,3753,4484,1363,8306,2530,2706,2644,-6554,8789,-8485,4492,2462,-7579,-5298,-8049,-6404,2333,-6473,3450,-4073,-624,9132,4001,9060,-5392,3112,-6155,5544,2531,-6717,9690,2190,-1693,2651,5760,-503,1944,-9468,7416,-1670,-9287,3729,8584,-381,945,207,9510,9862,8157,-3570,508,-2506,9158,-8399,9516,-321,7985,9872,1583,707,6944,3955,-1560,-682,4087,-6441,-3376,-7841,-3818,-7730,-5487,-906,-9282,1040,3764,1022,-8601,-485,-9447,2578,-4127,-6943,-6742,5504,425,-4943,767,5637,9063,7752,-6461,-6564,-2409,5143,247,-4822,2033,-5652,-536,-2216,3394,-1758,-3171,-70,2487,251,3997,-2391,9410,-4072,-4005,8889,6382,-8388,-6457,-4512,8215,-6854,8795,2556,-5668,-2157,-6137,-5347,3166,9047,323,-2151,-9578,6944,-7035,-6370,-482,424,12,-4408,4109,-3911,-1570,-6959,-3458,5,8066,-3804,9720,-1959,-642,-8941,-5587,-6541,-2427,-5983,244,8846,-8844,-2023,-1059,3628,-2567,4215,5818,473,8965,2834,5586,-6703,4210,-2188,-4732,8355,-2440,9328,-6701,-6481,-4586,5084,-4788,-5721,-5364,2770,8958,-1053,5092,1820,-6811,-2953,-5715,-4751,-8183,-5276,-5846,857,-1681,-585,-4607,8478,-5833,-3258,6189,-1824,-3633,3450,1746,-1161,4841,-145,756,-3509,2299,-8355,-5464,-4025,2390,6008,2435,-7312,-139,9273,7112,876,-2397,-8705,-2344,-5070,-5960,-8552,-830,-8934,-457,5055,5379,1035,-8539,-7897,4244,-8761,5229,6746,344,6840,2311,-7137,-3694,5056,7202,-7205,2112,-5466,3476,-7960,8333,-2921,-604,-3003,5678,-2244,6503,-239,-340,-5550,9106,-5194,-6538,-5474,2926,4671,-4271,3976,-7668,2977,-4361,8299,3144,748,2433,7882,8956,-1690,-921,4591,6018,-9084,-1825,-9483,-1995,895,2816,5497,1348,-6937,-3395,-660,646,-1023,-4391,4402,-905,841,925,-7921,225,-519,-3331,9720,-4805,-1597,-4513,1820,-9995,4419,-6853,4512,-5864,-6075,-1449,-9760,8635,-6843,-9887,-214,-7911,-6533,1381,-8261,-6686,-6516,-2065,8899,1689,-4575,6607,-4586,5119,8318,3327,2636,4645,-3924,2454,-3654,6504,-6415,7245,-9420,-7351,-7172,586,-7995,3409,4501,6264,307,2309,-1137,-7799,2112,-2862,-2472,8691,9991,5674,-8279,-1024,-7323,3633,-7892,-1930,-3812,5184,9136,-9585,1248,-3055,-3837,2876,4503,4348,8947,3145,5515,-27,-7172,-4921,-5627,2812,7595,-2391,4119,6212,7147,-277,-6521,6254,-4069,-5840,6073,-6216,5491,42,3311,4186,-1730,-4818,258,-9844,3235,5570,-7473,-2941,-697,1773,2979,5837,-8708,8777,4335,2937,3565,740,-8609,5015,6724,4265,4770,6442,8084,3978,6960,-2497,2967,8986,-9978,1690,6881,-1348,2034,7494,5789,-8415,2692,-5475,-4740,-591,-54,-7253,1295,1313,5765,-7124,-344,-7323,-2161,7212,-9520,-4250,-3926,-8633,-246,-8114,7869,3450,8110,-8801,-3651,-9512,-4598,-7354,-7403,-4325,2938,1181,2523,-7351,-3035,7038,3684,9813,-5924,-9361,5253,-4716,-6460,13,-3742,-4548,-8105,3654,1458,-2230,9691,-4229,6437,-4430,2696,2194,6682,271,7767,-8175,-398,-8635,-7309,1911,-9013,-170,4163,742,-8648,-88,-1521,1082,3550,-2470,-2735,-9171,-1028,1717,-7356,-3992,-8642,-152,5552,-9037,-3683,3859,5475,1293,-9988,3047,-4115,2397,-1237,3948,4156,-7846,-9509,-9681,-919,840,-2739,-5851,294,-1277,4972,5607,7865,-9939,5465,851,142,376,7561,-8673,2299,-9870,3798,9012,-4307,-664,-5323,6578,-799,3023,2057,847,5849,8009,2041,5840,-4424,3777,-532,6609,8041,2543,1333,-2794,-7147,-4263,-7413,-1640,7205,-65,-6771,-99,-856,710,5313,5019,-9755,3325,-8843,4525,-5396,-1899,-7462,-1854,-3948,1057,-3010,5229,-3256,2847,8567,-4100,-6350,-9292,225,9725,545,4469,-3928,-7121,6400,7366,-1762,238,-9003,-2478,7252,7929,4547,2486,7132,-7916,-9872,-6209,7892,2515,700,3992,3060,360,-8490,9878,-6981,-2359,-7724,6891,-5199,-9610,-4063,-7023,-2911,4187,-8731,3051,-8324,-2194,6939,2032,-5768,-9460,-6077,-4470,-3003,-294,-6240,-4409,5317,6408,5501,1584,-2652,-5870,2043,-179,-3352,2515,5402,8669,9543,-107,5887,2537,-4232,713,4032,-7532,8774,-9602,-6743,-529,-9286,2397,-5089,4736,-3142,-4680,995,8281,9073,-6150,9911,-7326,201,-8215,-4780,-1319,2292,8978,5316,-4213,-5816,1094,7564,-9974,228,-1017,4833,2170,-4683,7767,-11,-3943,1753,-674,3827,6585,8783,5095,6165,8579,-2265,2277,-1688,-2757,6357,-5938,8419,8183,194,-3193,4211,-8174,-5558,-3683,-8215,661,3195,-3411,-3838,9163,-7963,-7098,-8830,8064,4404,9522,4095,-4888,1025,-3755,-3175,-2475,4525,-31,5621,-769,-8883,5201,-8008,-5708,-2023,6088,-5362,-8590,4677,-3322,1489,734,8331,9914,-4167,-8502,3203,-5486,-6197,-1706,-4793,-9501,110,5947,1490,-6732,3227,2586,-1641,-8757,2147,628,8327,667,-3567,-2475,-2321,1466,144,9356,-2828,2091,1696,3849,-7633,-5586,-9171,-2190,-4413,8783,6480,-3821,3989,-3854,-5932,685,-1557,94,-1403,6533,3317,-7582,-1415,1762,-563,-646,3923,-439,4276,-9328,4841,2473,-4343,-5470,3085,7972,5415,6686,-2154,5123,7225,-7032,-9495,-2128,-9098,-3017,-449,-6017,-4134,5089,-6836,-1069,-2835,8223,-6674,-2245,6973,-9822,-2540,3174,2907,4796,-7179,-1060,8496,7903,1979,-7778,9002,-8439,2347,-5331,-9908,4973,-753,-9689,103,9772,7267,-8714,7108,-7669,-3777,7193,-5678,9554,-1021,6542,-4854,-5283,-6281,-9510,-7676,-1466,-4009,3160,9124,-3153,9722,-9930,-3969,2315,-102,-1213,-1081,-430,6548,-5937,-5845,5004,8459,615,2407,-6758,-2513,-9730,-378,1657,9774,1222,2925,344,4167,5007,-3438,2738,-4221,-8324,-3022,-9081,-7467,4125,8194,1166,-8711,4672,-5906,1737,-7894,-2695,-4701,8076,-5215,7897,-4336,-6149,-5993,1614,-8395,9113,1064,-7257,-4943,6968,-6691,-5514,-2356,4726,6233,-5652,1097,9241,9749,-8060,1871,-3950,50,6926,-7912,-9811,-9938,-6594,-222,-9457,-3636,4459,-3881,2286,-8571,1751,-4788,8736,3220,-6221,1477,388,9914,-7080,8407,-4933,6960,-1996,6007,-3557,4765,-5945,322,-7552,9909,-5512,-9804,-1693,-7645,-1402,-9383,-6568,7279,-6009,9816,-5775,7172,-9045,-3931,-2238,-8405,2351,1204,-7622,-5258,5132,-6342,4662,-1640,-6927,-5074,1322,-8221,4955,9954,8891,-1389,7866,-7695,-6734,-5553,5715,-3729,-2687,2025,5117,-9657,7304,-9091,-5392,-9806,-4131,1840,-2211,-6486,-4890,-6185,3285,-2461,2440,8765,7142,-7511,9979,6828,7955,-2844,4128,-228,6203,2254,-7601,-8219,8044,-3680,-7625,7361,2190,5838,454,2399,-3393,-3300,-8625,390,-7680,1209,4406,-5640,-4782,5785,-2111,9211,9944,-4444,-6367,1373,-3394,-936,-9268,4340,6799,541,8165,-1055,-794,-539,8612,7306,5026,3001,-5255,1115,-7203,-6249,7975,-3664,-989,9957,1582,6127,4678,165,-8323,-742,-7247,5402,-1500,9482,4649,9566,-9389,-1931,5423,-5521,66,-4787,5973,5827,-4675,-2621,7091,4962,9817,2201,3211,-8,-6277,4477,3808,-4873,9840,1626,4887,5192,-3526,-4061,8472,8884,-5189,4554,2964,-9259,5318,7244,7574,-3105,7955,-6873,-7823,-5542,3661,-6791,-7647,-1824,-7993,26,-8321,539,-701,9280,-5193,2543,-1538,-6394,-7089,589,-7837,2329,859,-3011,4489,1679,-4544,579,2935,-2082,-351,5992,-6884,-4880,9932,9991,-5626,802,-1337,-6215,-9639,-916,3146,-1081,-9648,752,-6025,-1909,-7715,1419,3030,-989,5406,-166,5129,6110,-3855,538,-159,5347,-6333,3842,-8963,-5453,8526,-9444,3295,-6274,-9480,7986,2176,-7689,-627,-6663,-1826,1840,6277,-7520,-7646,-9387,570,-2871,4137,-476,3683,-381,-5722,-4575,3335,-1703,-6045,5883,3754,9684,7619,-1190,-3011,-174,-6778,1670,5358,-9718,1146,-295,-1877,6644,8979,9108,-9585,8854,-3302,-5762,9489,7705,5116,4481,7353,5096,3446,9652,-9417,-8115,1359,-8708,-2342,3654,-5691,2999,-8132,69,6837,4611,-5642,-7719,-824,-6760,-9772,3505,-2901,4960,-172,-3896,4965,-2763,352,4829,710,-3314,5350,-9013,2897,-5989,7612,-2488,-4126,4958,8535,-3405,-9056,-1231,-334,-2355,5542,-9960,2260,8892,4342,5365,-5740,3923,-5531,2830,5975,4034,2313,4412,8396,6592,8727,8258,-560,8734,1301,-9601,9308,-454,5793,-6513,5117,3237,-6082,-9318,-3420,-5613,6458,7268,2197,-5827,7064,2187,-6441,5036,3310,3462,8675,-1276,-922,3601,-1196,5461,-2780,-9277,-2925,2237,-7493,-7151,-7189,7637,5866,-4314,6375,1330,-7749,-7510,-8584,-9920,-7068,-1354,1870,-8891,2574,6281,874,-5141,3689,-564,-3990,-3548,3381,4092,2162,-2959,-9890,4967,-7510,9893,4241,7406,-4983,6898,2682,-9569,7975,2219,1501,-7858,-3625,-1837,-5478,-4420,-8552,2921,2756,1097,-5811,9083,-1502,884,5955,-1475,1498,-4661,4088,681,-5512,1324,6862,-915,9634,3835,297,1846,3273,-6215,-7585,1351,-5514,1258,8566,9027,3606,112,-1237,-3459,-4784,-8315,-887,-6966,-4638,7270,-221,-7474,-60,-3728,955,-9580,1499,-885,8182,-2099,174,7898,-1948,4817,6221,7972,5892,2178,-5371,-652,-7846,-1490,3177,1974,-8271,-1232,-4387,7304,9146,-7359,-968,4388,4824,-9199,-1105,-2523,9319,-8511,-3652,5269,3704,9246,9566,8032,7996,-9460,4568,-482,4008,3838,-9422,8983,-9566,-9527,-4113,5309,384,-6482,2944,9272,4916,-8364,49,8564,4660,-1334,-5088,-5730,-2625,-2418,9782,-7314,809,7638,-9701,-6379,9943,-212,-7282,6741,-7703,5453,4234,-3803,-4681,5452,-4030,-2624,8082,4712,-2745,8520,9151,-6992,7663,8966,-3074,-4266,8348,5482,-7505,1477,9253,1523,-3985,-8451,-5682,9952,-3918,-1992,-4236,242,-2980,6673,-2266,-281,-1586,-1726,6038,-6812,1454,1666,-5523,8741,388,-1646,-732,6922,-7547,-7835,-4484,-3005,7665,-7785,7949,6806,285,5258,3442,780,-105,1996,4168,9412,2889,-6591,5861,657,-7790,-8122,7322,-1506,684,-7808,1268,1200,-8876,2390,-2154,2688,-7868,2133,457,7459,8723,-5277,626,5315,-5149,5162,-3616,1730,7991,-6261,6688,-8514,8951,7899,-2499,-3950,-9461,-5835,7272,-4423,-3886,3858,4207,412,6682,-4564,5386,-3967,-9760,2291,3935,3970,4847,-7333,830,-4806,4854,-1892,1754,-3645,4141,620,-8490,5690,-9201,-5760,-7560,6873,-7577,728,7738,4846,4689,-988,-5521,300,-1076,-437,-1609,-5563,5092,-5897,4866,8311,8380,-7162,6644,-453,1762,-3149,-2581,3278,5373,-4474,525,9702,-6946,-3614,-4165,2282,-9125,-4913,8119,6305,4548,-2263,-6345,4157,4140,-1461,7655,6523,7992,-1089,-9167,2713,3867,2776,2525,-1289,-9942,9442,917,7086,7520,-457,5804,-808,-4424,5802,-3685,5402,6439,5910,9387,-8456,-8768,-7250,-5055,-171,3465,7623,9081,4749,5108,-5316,-5351,-8411,-5755,-3361,4404,9050,4511,4635,-3295,-8399,567,7243,-7724,-2749,3319,-5674,-2281,-1111,-917,6524,4401,612,-8427,381,-2438,7330,-6716,8223,-6668,226,1780,-1477,1506,6953,-2856,1025,-5288,3588,-5717,-3476,4830,-7486,-6267,1418,2577,-8537,-8875,4687,-3229,7170,-2465,4299,7329,-5121,8479,5931,7097,-757,-7694,-6422,745,-1654,-63,9029,-7589,3899,-1093,-2232,-7924,-4589,2903,-1340,2736,4045,-5553,-1712,921,-2682,1520,1951,4722,3286,-9287,-3379,1749,-8724,2551,8301,6130,-4528,3557,-235,-4693,-7738,9197,2591,7299,-3737,783,9221,-3076,-6783,2336,-7170,-8649,9266,4666,3583,-1635,9231,-5442,5694,-9124,8043,-9324,8647,-216,-5572,3028,-320,-9801,750,-647,-4171,7480,-931,8328,7917,181,-4797,1676,7470,7012,5181,-51,-2909,-8281,-980,4092,-947,322,-4646,2699,-9964,-4729,-4688,9503,-4385,855,-8943,-6860,2065,-5977,3074,-7900,4450,-1736,-7216,4781,-7354,-9822,-1527,1013,-8005,412,-3416,3546,2925,-6095,-3810,5411,7232,8828,-9769,4225,-3482,938,-6326,976,8959,8841,306,-622,2593,6128,-2484,-5507,6608,-3000,-8464,-1885,4215,5721,-7615,-6751,-151,825,-5819,4389,4677,-7413,2115,-9229,-7684,1463,-1084,8781,998,-8,-6039,9757,8871,-7907,-2046,-8710,-3064,641,4725,663,4564,3057,2138,9282,-1388,7695,-9922,-9855,-5941,-4465,5377,5393,-4619,-6204,-948,-8551,6711,8967,2114,-5312,-6210,1374,-3633,-7907,-5509,3532,-2488,6090,-66,9401,-5504,-5535,-4421,-7796,2123,1412,2665,9241,-6313,9044,-1174,4138,-2690,-918,1467,-4945,7694,1935,-764,-881,3508,-7176,1218,3485,-3361,5010,-4162,-600,-2614,-2558,-4785,-4423,8625,5468,2436,-3320,6762,-2607,-5762,3823,-6248,-643,7887,-5489,-719,2045,8913,-8959,398,-4059,-9110,-4589,6640,9417,-1006,-7092,6458,-5539,4941,2437,-2889,-4100,-4854,-6930,-5226,7183,-2045,-3585,-7346,6950,7554,-8739,-8600,-9109,-558,-5284,-415,-9482,-9525,-5124,8327,-8728,-7580,-9806,3420,-3383,-5359,-4015,-3920,-1767,5219,-4870,4734,2504,-3051,8791,6403,925,1372,-4719,-5785,-7757,-2597,1694,-769,1070,-7500,-9363,-3896,-4505,477,1269,6938,-5118,-7664,6818,8126,4490,2404,-993,-745,-7465,-4189,-7124,9785,-9740,7178,2503,-9011,2546,7811,1951,-8394,-8137,-573,6738,4712,-2744,-7028,5567,3730,4822,272,-74,-5239,251,-4216,-351,4701,5145,-7146,-1671,-3506,9048,-9025,9067,-6752,9496,6429,-563,-8098,3078,-3944,6885,4808,-9709,2919,7686,-4206,-5629,-8172,-9659,6872,-59,6610,-5349,7410,7988,-8287,4581,-5970,-8994,7690,-4315,9122,9610,7679,-8075,-279,7038,-5809,4160,4616,9851,4287,3203,-1381,5505,-3195,2526,7949,-4904,5273,8306,-3063,-8255,5179,-3494,8194,5546,-6901,6474,-7234,-2964,8191,7948,6750,2998,-4337,9376,9767,-6450,-4236,5167,8628,5941,-6513,-4403,-1299,814,-1751,7464,-8246,-4457,3833,-9373,9183,-4663,2663,-8050,-1190,3852,1190,-6740,4634,8694,6404,-6745,-5675,-3775,8710,-4532,-497,3561,-9794,-1326,-4007,-2946,-7481,7160,1339,-1554,9426,-4674,-5676,-8048,1013,5503,3140,9026,-9277,-6142,1553,-5387,1597,-9504,-4711,-3247,3594,-1651,-6534,-7884,8325,887,3129,5705,-4059,4140,-5680,5224,9190,7524,-3737,3369,8925,-6405,-3543,-2112,4572,-4877,9619,6147,-7442,-1180,-1298,-4194,8260,-8449,9861,8266,-441,2129,-3173,9102,-7862,3085,9189,4,4502,3798,2428,6583,6574,2814,-5331,8189,2968,-211,770,-2877,-3075,-5158,448,7475,-1014,5857,-1227,-5285,6012,-1442,9992,8512,-6169,8378,-9663,-2758,3875,-2214,-3451,1496,427,580,5157,-1074,-5730,-5160,-4237,-7316,1923,-3710,9405,-135,325,-5859,6724,3975,-997,3539,-4296,1577,-1742,8912,8556,-5079,-8987,56,-6303,-1148,-5016,-7649,-689,-1244,-1411,-9449,-7646,-5799,-3284,7582,1588,-4076,-9869,7124,539,3519,6521,-8188,9993,-371,-1312,2906,8713,8956,22,-769,-7464,-9669,9661,-2045,-5754,2807,5177,8067,-1138,-3541,148,-2233,890,2520,2626,-2882,9270,-4186,887,3701,2028,-9724,4660,1217,5249,-8096,-8815,8424,-468,4092,-1661,-7715,-8917,-3381,7822,8518,-5262,2074,-9778,7001,-8498,-1929,1070,3532,7585,8368,-7477,9148,8963,-7675,-2566,-6335,7493,-3457,-4917,-4846,-2128,3487,-7929,7438,-1733,1247,9929,6970,-6784,713,1052,-6451,-5388,8821,10,-2540,3175,2606,-9127,-663,6223,8383,-9987,-5677,9713,8368,-8246,291,9145,4201,4750,8291,6813,1433,-2194,7613,-2445,8105,1003,-8319,-3203,6997,-9150,2909,-5126,2752,732,-3457,7288,-193,-5709,-5660,1190,5973,-1276,-8029,-2726,2028,7222,984,-3064,8714,2753,-294,-7972,-4700,3821,1183,4836,1497,-9797,875,-1346,4768,4768,9091,8509,6013,2275,1693,-8064,-4516,-8288,-2188,6123,-6788,-480,3671,506,3,-7835,7631,-2630,246,5304,-2511,-6110,-1449,-5600,9097,-7294,-9191,-2332,-2531,-5646,668,4652,-526,-1688,-5349,-4005,1499,2703,8563,-48,-242,4878,-2879,6690,-706,-5628,6094,6853,-3290,-4067,4426,1867,5297,-4109,4085,7282,-3527,6402,6170,1912,-5171,5842,4751,-3345,-9247,450,-9689,-6708,-3161,1770,2482,3702,5697,-1619,-8947,6571,3129,6747,-7970,-662,-3954,4181,8477,-9039,-7578,-1315,-4103,3770,-3160,-3214,6035,5920,-6395,-5336,-6415,-2482,6515,-7196,-3181,-7698,6539,-7857,3541,-4692,-2383,-599,-7005,-5185,5139,3294,6094,4572,-1436,360,-3560,4199,-7422,7993,-4701,6839,7063,-2425,-3558,9801,-328,-2162,9100,9784,-1823,1729,2118,5129,4902,-6834,5780,-1179,-9467,-8399,-7999,3009,593,-1288,1106,-4250,-8392,7638,-4892,-8696,9407,-6712,-8215,-9714,4189,3608,8357,2427,7675,-6674,-7200,6292,506,8528,-6307,-4743,2087,9764,8714,-2464,2469,-4552,1879,-5897,7570,-3226,-5921,2063,-3337,-7588,5546,-4102,2918,1058,2644,-553,3092,-3093,2477,6369,-3270,-8218,-3862,-7689,-7189,3267,-9462,7714,556,-1118,4200,4451,6008,6420,-6187,-651,6832,-6364,-649,7627,7425,-2653,-1246,3992,-541,-5881,-4797,-7472,8443,8172,-6088,-5361,-5320,-4420,1545,-3574,-5770,-8125,-8170,-9062,-1120,2443,9677,-2032,394,2445,491,-7322,-5576,8307,-3673,5318,-8883,-4484,9989,526,3664,-5666,1358,757,-7037,5815,-9222,2450,-6278,2563,2528,5115,2744,7904,7032,4110,3373,79,4299,-4600,1906,-8246,-3712,-4239,-8536,-9023,978,3044,6418,-9455,-1943,-1713,8266,9778,7473,9426,8213,2675,5242,-5632,9890,179,-577,-6246,-3812,7364,7441,-8248,-9678,6435,-3145,-2836,3044,621,7904,-2475,8077,2588,3000,6132,1764,8906,-6778,1343,-7684,-5801,8944,7104,531,-6113,-8379,-1711,9852,453,-7679,-998,3151,5017,8762,-73,8866,-7469,-3984,8121,1798,6551,9228,-9482,-7548,-3850,-2909,6954,-2727,2064,-2747,-3599,-9928,3469,-7762,6917,-3456,2781,-5220,-7860,1870,2583,3016,7792,-3368,-9691,2450,-5581,6756,-1677,540,-6501,-1357,6579,3379,-8045,-3672,-4104,8644,-5152,-4036,-152,-6125,2356,-6026,8580,-9169,9440,2062,-2130,-1907,-4696,6685,8025,-4554,-9210,-3219,-6971,-58,-844,-3142,-7723,-3112,-2338,-8537,-4331,2040,-1959,-20,-5335,-6875,4064,-5378,7468,883,6106,-6446,-308,4270,-3831,-8442,4082,-7899,2027,4814,2926,-6461,155,-6679,-7057,-6644,1100,-4418,6070,-7331,968,7242,-9377,-7439,9872,2607,4955,-3817,4298,8589,1659,-6293,-7038,9118,-3453,513,9910,-2230,-8348,-8029,-5259,7165,7522,-9089,-3559,-4738,6766,-4754,5940,4118,-1470,3486,-9001,-3237,5170,581,6958,-2942,6059,-6459,7547,-7643,5061,1838,-1165,2340,-6502,-3851,1133,7466,-2289,7955,-6442,-614,-5571,-9958,-3712,5129,-8794,8828,5281,-2485,-5935,-3109,7215,-3664,4157,8431,-7883,-1865,1774,2172,-2660,5288,917,1638,-1699,2467,5896,-3493,9834,9119,8995,8242,4461,8938,-6944,6388,-4707,-6231,6810,9514,-4024,3528,2359,-3425,-4543,-1883,730,-7366,7219,8981,2232,6032,-3392,-6030,3512,1445,3556,6786,2763,8582,2203,-922,-7480,-6162,-3694,2847,-1812,-3720,-2860,-2855,6292,8420,-8212,-5500,5714,2817,7987,7548,647,-2982,5801,-4402,-4639,-8861,-5758,-1539,2225,-4169,-6293,6421,-8004,5699,5604,-8469,-6594,3332,9293,5307,7934,-6974,-7539,1937,-4260,-3039,-6580,-8500,-4685,-6120,4997,-2912,5989,-3540,-4620,5884,-1487,-6442,-6683,-755,3699,1840,-2421,-9897,7107,-4442,3107,-9462,4913,909,-4058,-1006,-4228,-806,3846,-7387,284,4954,-5715,-2183,-7556,-3108,4697,7040,-2251,6954,-4107,-4260,-4117,-6324,-4720,3733,-9712,4194,-390,926,370,-6598,3194,4070,-2464,-3702,-9113,163,2752,-9263,1166,-9974,6775,-9924,9002,5202,-2228,8056,-3220,5263,1850,2659,-3613,4668,699,8360,-489,-6253,-7531,7544,-2434,-3406,-9690,967,700,-6744,2152,5170,-317,-2889,9674,7870,-1724,7883,8726,1611,-2548,-1550,-949,6888,6898,-7617,-1459,4353,-3425,3612,9275,-8063,8437,7289,-8446,-9172,7585,7127,6732,-2835,2893,-2058,7059,7939,6456,-8460,-4807,7757,7172,3952,-9286,-230,3397,-3705,-5430,8078,-5369,7215,8669,-3320,9025,-6263,-9772,-9659,1053,6467,8452,5808,-7921,-4057,9191,-76,8383,6453,-7162,1617,2442,7259,-7176,4905,2476,-5397,2373,140,-2693,8083,2632,294,-2112,-5913,7785,-2148,6785,9186,110,2563,-2960,9852,-7000,9712,9492,1915,-7710,1052,6326,-3815,7775,-1618,7476,9041,-6606,891,5981,-1912,1083,-8004,-8964,-5696,5638,2777,5881,-1741,3925,5882,7668,-2729,-5586,434,-461,4639,4081,5580,-5772,5517,-276,1916,3570,-1872,597,5111,-4598,9025,4978,8941,6723,9384,396,8676,4317,-8660,9040,-924,6238,-4214,1332,8989,7950,2209,4345,2298,9452,-5026,962,-9446,-5728,-2152,2684,-2426,-4206,5108,3925,468,-8751,-3009,806,-6468,5864,-8391,-7191,-1623,-7745,1957,4680,4628,6905,-1262,3506,6619,-6105,7256,-3733,-5465,621,9477,9572,8653,-491,-1144,-2348,-5789,34,-5203,-7926,-4337,-9960,7971,1965,-63,-1938,1984,1097,7062,2284,8852,621,-8993,3475,-5223,-9936,-4687,-7893,-4778,932,689,-1442,-733,2626,1895,-2277,-6702,-7435,136,-2550,-7506,-7044,-2639,4225,8113,-3987,-7,2406,5591,-3050,8935,4494,9293,-5456,4882,-3365,2353,-3614,-8300,7050,-1681,-1711,-5426,1981,9858,3176,-9421,9543,6131,3717,-5785,-7946,9890,4228,8361,-8034,-3235,-8544,8659,-8458,5336,2585,-6223,8370,451,680,-769,7625,-8359,-9949,-7944,5006,-3040,9529,2596,9661,7502,-6538,7828,3430,-5431,-4645,-8954,7737,-8444,-5791,6463,2015,1278,-6470,9467,-8334,1420,-9189,-1216,-2664,6344,-3533,3865,565,606,-7221,-6667,-9248,-7212,1278,-9450,6173,1565,2186,-5387,1524,-8638,754,-39,6253,-6635,-8637,-9905,-2424,6123,-4182,9233,4894,8566,-3050,-5892,6560,6472,1128,-1199,3322,-2823,-3953,9139,1320,384,18,2786,-4831,-2699,7403,-6244,6281,-9533,6700,-1507,-5283,6168,9944,-4378,7399,763,-4195,3806,4690,5013,-4659,-4220,-44,-8202,-7865,-7847,-7774,-4703,-473,9521,5318,-5301,-2939,9037,-9815,-1652,-7457,5080,-3769,6944,-450,-6204,1688,-6620,-3879,-5161,-5361,-5024,-7771,-1224,5074,4260,-1357,-3240,4830,5902,-771,-3993,2051,-1164,-7012,3862,-8814,8544,-1435,-3625,5910,-6372,-850,1984,7619,-796,-598,-9744,-8452,-3263,53,-1467,7249,3598,9216,5318,5168,-5625,810,2941,-37,4529,5755,-248,1388,1961,7854,-1481,-1865,-6781,-411,1962,-2890,6937,-4922,2528,4961,-6092,-8952,1255,2047,-3356,-3799,3172,9443,-5478,-2213,-3225,5467,-1159,301,8524,5995,-3162,-6442,8951,-7000,869,-7906,604,-1036,-5540,-4136,5906,-6287,8011,-5244,5653,2488,-3684,9211,-7309,-6656,1130,-4980,4418,-7703,-2858,-4362,6636,2205,-6804,7749,-7154,-1958,-1198,3572,-546,-9926,3804,7026,-8175,7741,-8627,7409,1766,2168,-5943,5856,115,3324,-3078,52,-8631,3072,-7118,9159,246,8192,-7855,5299,6171,-197,-1568,-1125,-6762,3387,-5417,8373,-1852,4365,-9964,8329,-607,4339,9019,-6911,-9566,5723,7509,-2154,2963,-9271,-6014,-8485,-6373,-7724,705,-7112,3957,9930,-925,-3987,-8671,-1174,-4336,3038,-2700,-871,-9500,-7696,8623,9234,-3437,-8359,5733,4992,-3759,1311,7161,-685,3667,-853,-5497,8530,-1513,-8500,1766,1316,-8266,8593,864,2460,8667,-1218,-9402,-4978,-2120,541,-9141,4676,-4683,-8325,2953,6336,105,8464,4384,-2498,-3674,-6602,-564,9157,-1688,-5608,-5351,1770,2809,-8017,-2033,-2857,1644,-540,-4993,-5508,-180,4922,-6868,2535,-3245,-6860,-3552,-5100,-6040,-2036,3465,1191,-6064,-9965,5958,3615,-4651,105,9107,-4936,-7755,-6176,7705,-2059,-2007,4701,-2814,8919,-7022,-8227,-4199,807,-4779,-5906,-2638,-2356,8323,-1353,-9994,2720,4403,-1247,-1112,-4741,-7172,-8529,6407,8747,-3279,-5336,-8414,9156,6439,-6728,-9912,3964,-2487,6333,-2510,9232,6119,4474,5763,5147,-9073,-7451,-787,-7403,7036,-4796,-7436,2097,896,7054,-2228,-5440,7785,8180,-2300,-6962,8144,-5199,-6386,7181,-4596,-2421,5932,-9352,-9050,4181,-1639,-7707,-1147,7165,2113,5981,-4368,-1701,9495,-1573,3771,3135,4110,-8663,-8426,1595,3258,-5601,989,-4791,8666,-8028,-8680,-4178,7405,-1073,-1169,-435,652,-7841,-3842,-9172,879,648,-8462,5197,-6904,4918,-6260,9898,2573,8556,-7183,1992,7750,2820,-4761,-5480,2695,-2300,585,6266,6318,-2737,1173,-8468,-3719,812,-5768,1437,-9182,3556,213,5603,-4124,-1616,2324,129,-7847,6295,-877,-982,5506,-9417,-5364,640,5884,-827,3113,1108,-5045,-7440,7873,4655,8684,6528,1625,3839,794,5426,7201,9900,6822,-6533,-632,5235,2452,2787,2521,-6196,5383,-6784,-8090,-3563,-8212,-7570,9139,4326,9857,5491,8894,-6454,3117,-2127,-5943,-3001,8507,9537,-8089,871,-7518,-9708,-2836,-466,-9698,-5558,8995,-5166,-3470,-6761,7822,5408,2847,-2601,3089,5144,-2987,-2434,-1303,7128,-2458,-8050,-762,7894,-722,8179,-7113,7418,8122,9621,5545,2531,-806,-8145,-4445,-4190,-4619,2605,3850,-8365,1528,-5691,8585,5742,7660,6818,-6674,-4947,-2805,-8862,5516,-5374,1914,7276,934,-412,-1008,-1056,-3559,4487,697,-8875,-6087,9923,-9723,1398,-7646,-5825,-7904,-2148,7308,9346,8871,8761,1035,952,4634,9161,-2844,-8455,-7300,-1046,7172,-910,2392,-6988,9897,1531,-3824,9045,7981,8855,137,-6673,-6287,-881,4531,2108,5199,-1158,-4506,-5653,-7941,-4259,1698,7385,-658,5768,-6419,8831,-5415,1660,-8853,7895,-3753,-6341,-6982,5974,-7427,5176,5834,9526,-6563,-581,-4748,-5564,-8771,-8911,5055,6412,-97,5030,7207,3930,-2799,-8205,-2824,6486,-7020,-7188,9866,495,9299,-8500,-9073,-8193,4937,-2725,1367,1119,-2450,6880,7893,8524,-7838,9581,-9715,-7200,-5312,-147,-5232,-5679,-4808,-3028,3649,-4569,1940,4279,-8033,-7665,-8708,4234,-9961,-6509,-140,-2548,9287,1225,7464,1173,-5774,-4557,-9798,7287,-7815,-7875,3004,-8976,6763,-7614,-6893,-2077,-7096,-5853,-6008,2298,-7194,9274,3634,4513,8343,5525,-3341,-7341,-9517,-7286,-3456,4695,-9014,871,9590,3406,-2848,2498,7008,-6826,-3098,2260,-8498,5201,7739,-6055,564,8215,-3753,7548,-844,4212,7207,-1334,-9474,-9941,8050,1694,7825,5344,-6203,3377,-6910,8683,7513,9520,635,7726,8260,1757,9195,-836,-2310,9718,-180,1757,-9291,2876,5649,-9896,6877,-7477,5187,5285,5396,2691,-1822,-9089,1071,-6557,-7990,-4017,5144,99,2725,-2562,4000,8716,7494,-9096,-6399,-6523,-2143,-9542,-5326,1210,-4229,-3022,4089,-7653,-3391,1242,2357,6252,-7011,7114,9473,-8688,-6368,5126,811,-177,-1977,9678,-338,5528,143,-8089,7262,-7027,-1602,-9704,-128,4545,6490,-689,2491,2572,-2658,-6601,-4758,-89,-4426,-3466,3695,4243,3306,4613,3835,-677,3314,8958,8325,-2552,4166,-226,5801,1437,8341,-2291,5896,-8945,-386,-1882,-8377,-291,-2088,4513,2001,424,-3559,-6399,-4027,-5233,3543,-9023,9048,-3119,-4721,9829,6467,-4661,-2862,-1766,-1423,-6844,-7879,7777,4373,6820,-2470,-299,-7419,6795,4433,7712,-4058,-7995,4791,-2556,2165,7628,4150,-9716,-5031,-7707,-268,-3039,8624,-2099,-8288,-9029,4959,-9395,-6083,-3638,-5255,-1389,-5862,6084,-8395,3018,-1099,1308,-7600,-2840,9511,7467,2564,8561,-5554,-1401,-587,-2547,-5631,4732,6678,3231,-8714,5460,8513,-1890,-9683,-2478,8068,-965,-6050,2742,9835,8563,-9068,8137,5103,-3301,-7086,-656,3547,4842,-1203,-9357,-1052,-3678,805,9372,7424,7005,-9512,-7609,2505,8538,-8453,-7059,-8858,-7983,7370,-3592,-3955,-7402,7022,-553,1946,9432,-4549,3059,-9117,-8454,5844,3974,2575,6141,-1025,430,5881,-3311,1022,5579,9899,150,-1803,9463,3816,-490,5906,3027,-7656,-4927,9072,6179,-4627,-9341,6321,-79,-6320,-1369,-6197,8468,311,3121,3758,7964,-6024,-4430,-6256,9747,-1186,-7219,-6393,4915,-1284,9804,-3598,-3521,-7581,6818,8450,9891,-9233,8152,-2952,8878,9368,9871,7764,9529,3733,-8670,-2149,5253,-5061,-6568,-6992,-4315,7593,1151,3877,2066,1414,9920,4647,-8871,-3838,-4932,9971,-522,-8500,-9673,5070,-3918,-299,-9400,-3453,295,3226,-1081,-4307,-9560,8927,1985,955,-6244,-8252,-1551,-2351,2334,6321,8781,-2498,-4580,-9009,-2862,-9772,-4441,-433,3164,6600,9939,-5943,-4268,5843,-2941,5744,-7800,-2741,4319,-4436,-8755,-8964,-9177,4192,-2800,-8879,-8200,-3586,-4345,-3245,9398,411,-1991,-9015,7408,-8299,1364,3354,-4819,-1051,2248,798,7866,-9894,-1504,9183,1671,-9351,9180,-9014,2399,7281,-6897,-587,-3934,-256,3914,-437,564,-7935,-3076,5652,-8680,4182,7590,-5343,-5366,1069,7181,8528,2916,6365,777,6282,3331,-5458,-16,-8750,-4039,-7268,-4833,1083,-427,-2895,2953,45,5989,4244,-2529,-2732,-6142,6146,-8509,9723,-9788,-8187,9200,-5436,-572,5337,-3020,-4607,5022,-854,-2203,9307,9281,8597,8277,108,9379,-9387,-8687,-1986,8758,9688,-2147,-1315,-9827,-4396,-9198,453,2850,6398,-8167,-2005,-5656,-8475,4059,-5875,4198,-9828,3897,1414,7521,5457,943,-7408,-5803,4378,5250,2115,8996,9602,7718,-4056,5445,-2677,-6583,2600,-5750,-3964,-5065,-4653,-5740,556,-7792,-6870,9086,7988,-6647,-6202,-6827,4130,-5181,5064,5987,-656,5030,484,-430,5764,3133,-8407,5220,-5417,4769,8954,8666,7660,5117,-7884,-1743,-9973,-4833,-4652,-5330,-3675,-338,2723,2089,-4544,6774,2703,9312,1657,4072,3061,-278,1429,-6353,-5289,8438,-3549,-6936,-5641,-4623,-6484,-7281,-7060,3315,9154,-1354,7071,-7651,-3126,-8841,1543,8453,5661,-7783,-414,8075,9300,5643,-2573,1966,5855,4694,3528,-9102,4951,4648,1412,-3009,9818,806,-5392,-7878,-2127,3589,-1338,-3532,5852,1176,4162,2899,-8349,3019,25,-2449,592,7201,-999,-4309,-5888,-7755,-4107,-3974,696,-9701,-4378,-852,-805,3725,6199,-9422,-4194,-1119,-4515,-4680,8789,4867,1784,9086,7004,-7557,-2232,1885,2929,-8781,1224,-7994,-7155,-1288,9450,-9010,7911,4994,5175,-8052,97,7630,-6990,-535,-9986,-6211,6983,-199,8215,-3016,-4694,-1961,1408,-9560,-7522,8378,-6808,-625,9289,7013,-3517,6838,-9641,-4235,-8041,3196,-3261,-351,5982,70,-6668,-5458,-863,8966,-5665,-517,6317,-6408,-6074,-2032,9881,-6150,4096,3100,-8657,-3090,-9373,-1694,-9562,-8584,1028,-7435,-1662,300,4964,-3782,-9574,2246,-4769,653,909,4576,6907,-4780,5968,289,-7036,3194,9859,7944,-2344,8118,-2884,-9151,8935,-6597,6340,-416,3573,1547,8667,6489,9368,-3088,952,3132,-8697,5882,-24,3266,7845,-3012,-876,-1232,-1143,6338,4753,-6113,298,-6071,3578,6884,-3773,329,-403,-818,2354,5747,5089,6619,5280,4147,8908,-5532,3761,4980,1285,-7893,-2033,-782,3742,6942,-5546,-9794,3674,-6345,419,-9396,9354,1647,5199,-9076,-6208,-5304,-264,-6967,-9371,4106,960,-452,-204,-7900,-9647,-6187,7656,-7713,7586,385,-5346,-6145,-4462,-5072,1171,9762,-3791,-6974,1837,-1643,3027,-5863,-9460,4052,8047,-5584,-3983,4909,-6768,-1923,7733,7090,-7533,3952,-5102,8845,9710,7808,334,9513,-1579,7503,2269,-1599,373,-7573,4848,-9914,1218,9270,-3939,843,3186,-7945,7482,681,-4830,-60,9086,-7279,1380,3548,9602,-1203,6134,5201,-5872,-6692,-5657,-531,-1470,-7742,-4043,5737,-8380,-7035,-6323,-1398,2260,6357,-2,9193,-172,5469,3304,5867,4086,2705,-2802,-9953,1020,7574,-2834,-1357,-955,9503,6318,-3689,-774,1385,4282,6574,2813,-5642,6428,7261,-9710,1435,-9261,3239,-4837,-7576,9821,1742,-9196,-1010,-2201,-6438,-9753,4342,-8183,9646,1687,1498,7922,4914,280,2257,-1486,6118,-6142,-6000,-4682,2785,-7588,8782,8448,393,2042,3431,6451,498,922,-8611,-8468,3026,-1813,-726,5242,6613,-2219,6623,5178,-8097,-5545,-2905,-7684,1979,-7692,-7532,1942,3704,-5471,-111,3293,-7086,7061,-5006,-3853,3471,-5510,-6599,-8393,-776,9599,1896,1315,4476,7483,8438,-5500,5369,-6061,8964,-955,6794,-8997,-8540,-5475,-5005,-5586,-381,5221,-6253,8205,-4889,-4622,4684,-1444,6266,6824,8806,1451,-9949,4003,1397,-9058,4371,-2663,-2967,-2154,-4378,-7900,-351,4342,3418,377,-1359,-6126,5024,-9704,4272,2639,6507,-3564,3971,9631,-5921,8317,4111,8733,8706,1543,-2608,-367,-4116,-1746,-234,-5491,6325,-1692,-3032,1888,7137,-745,4241,3178,-2658,-9595,-4130,-9433,-9600,-6367,-301,6320,6584,-4931,-5255,-4429,-9497,-2311,-7676,-8521,-2447,1566,7669,7082,-3314,2633,-6968,-5413,8516,-8631,-1904,8838,6332,-6395,-1459,-7428,-8628,-8742,-3369,-3525,5278,-37,6555,-7417,-6561,-230,-6213,-7050,-5355,3329,-2626,8337,-5593,4171,9348,-7477,473,9948,7962,-3269,-8949,-6637,6285,144,2829,-6695,6881,637,-8832,-5885,-2360,8874,-5379,-5642,9244,-6064,9769,2106,-600,-5022,3709,1146,1088,1780,5672,6551,5404,-3445,348,-1323,-109,-8304,-7011,-7634,-6109,-6517,-1577,-8765,6026,5674,4113,3703,-8250,-6003,-8144,9690,3511,-6528,-8036,-3936,-2827,4625,-5105,-5190,-9622,8872,-7161,4801,-4666,-277,2733,-2867,3498,-8423,-5155,-3329,5353,5263,865,895,-6891,7443,-8199,-1598,1640,-571,-6339,-2967,6095,-8576,-7864,500,-6680,8368,-7169,9077,1534,2996,5278,8923,-4715,-2011,4506,1596,-4488,-2125,-5287,8034,-1908,522,-8329,-7410,1330,7433,7944,9156,-2737,5154,-227,9968,6489,-8033,-2895,9683,-5838,-3208,9506,4242,-3488,8779,1546,7865,1313,-1371,3194,-2042,5383,7155,-8891,-577,7042,-3348,3008,1916,8690,-2646,-4422,-1553,8095,5935,2752,-8129,-1492,-6322,-6699,867,-2507,-2115,1675,1444,-9584,-6277,7137,6819,4319,-3802,3344,5791,-9916,-5197,7179,7894,695,7470,1053,3185,-2977,993,-4460,5364,5501,-9626,4786,1714,-4111,5942,-9259,-6009,-9267,-7398,-3395,-3012,-5476,-6547,-2465,-9167,1844,-4196,-8753,-8723,245,2267,7024,-7576,2235,-2893,-2725,-145,-5190,-3657,4607,3494,2687,-485,-9809,9068,7086,-7426,2296,-7634,-1792,-1764,9501,-5082,7170,-9040,5812,-1635,5845,9762,7305,6542,9465,8215,3175,-3264,-9360,8917,2975,7047,3262,-2604,5706,9506,-8163,-8071,4923,9201,-765,5834,9421,7073,4547,-3493,1142,6152,-1322,-8717,7498,8711,9544,-6077,4628,5153,-4675,9653,9888,388,-5546,-1767,-9327,-8039,-2298,6035,-8217,-5281,9145,9907,-6897,7076,5448,7848,1237,-4283,-8198,5956,9856,4122,815,4714,-6558,8726,-6413,2228,6062,8909,7565,-1390,-408,-5191,-4299,-8549,5022,1918,-6310,2831,3973,-2575,65,-8975,7428,-7144,-67,-3533,-6790,821,-6547,-8536,9637,-7604,3095,-8244,2641,7490,3404,8335,2233,-5533,265,-4123,3010,-8234,1822,898,7623,-3599,-2286,-9064,-9198,5170,-6014,4981,6786,-6680,2338,6844,471,-9761,-1224,3055,-9828,7753,9836,7776,2662,4479,-8616,1376,2626,-7134,8005,-357,-5370,-8429,1599,-7664,-9856,-5732,8396,9020,-7028,-6569,-5969,5544,-1810,-9513,-4387,-5074,-4748,-9414,3132,-853,-4325,-2181,4568,1487,4544,-2680,1921,-5971,-8118,-7841,7624,4606,-276,8147,-7799,1524,-6697,3150,9748,-8473,-881,-1824,-7667,4555,3607,7712,-5138,-2547,5800,-5719,-6741,-6711,984,4526,-3764,9808,-7155,8767,-374,-2460,-6021,-9831,5239,-3853,3644,-9676,296,-1896,1991,-8359,1086,-4150,-6375,7285,3794,-4559,-7544,735,-3867,-6475,-3755,-7411,-2315,1883,6514,-2592,7623,-7248,5709,-8117,-2045,525,4545,-3084,8134,-6357,-9723,6580,9064,-9289,-2536,8177,3220,-1514,3312,9933,-4446,-9636,2072,5138,-4181,7319,5306,-4404,3021,-5527,-5903,680,4614,4202,1440,4628,1279,-6587,-673,-8863,8322,-1838,5772,-2286,-422,-8592,-8077,-1798,389,-5114,5411,4703,9013,2915,-4021,6028,-5081,-7212,9645,6671,-1897,8974,7332,-1804,5948,-4028,-2958,6776,4370,3368,7898,-4160,-2214,1657,7930,7757,6386,6946,-2365,-9416,2115,-1572,-1166,7847,-5584,-6038,-9162,9219,-7122,-773,-7301,2604,-3389,9350,-9680,6157,-9478,-5958,-1764,6933,5560,-2837,-3580,3866,9155,-5561,-9819,-9624,2975,-7654,-1859,3319,9993,4452,511,8027,-8275,-5932,-1289,3205,3920,3924,-1721,-2576,8005,7601,7572,6910,178,-6805,-7870,3826,9765,-8303,-4010,-6643,-9962,5292,4302,-4725,8983,-8353,6249,163,8234,5297,2261,8508,6985,176,8688,6752,6623,-4691,2444,6013,-7784,8825,-2673,8615,3584,-8137,4534,2265,5130,9426,-2613,6468,-9549,7446,6527,-2970,-6088,9475,-5885,584,-784,-9338,-2830,-5168,-4790,8808,9400,6435,478,-7801,5179,9831,-1474,9739,1937,-6791,8811,4269,-738,7006,-2235,6647,-2737,7937,-3158,-3593,-4,-3814,-8131,-2513,1831,-6439,6373,9842,5643,5850,-1336,1955,-6578,771,3738,6314,-3922,-5954,945,-3229,9795,-7414,5839,-714,913,-7877,-6217,6848,-9159,-1723,3505,-6532,9770,1644,-9028,3646,-4410,2875,291,-3106,4213,1112,5940,-6782,-3083,-4318,-3280,-5042,-225,-2458,8712,-2262,-5827,783,-6383,-3497,8063,-1493,8449,-6909,4840,4236,-4576,-8580,-1221,-645,8912,-5219,9538,-1090,2994,-1514,-2446,8292,4413,310,-9273,-2212,-6030,-1821,1252,-1287,2703,-1226,-6422,6001,-1667,7337,-5557,-2358,-8444,-6151,-6941,2688,4706,1766,-3459,-8208,9797,1845,-3896,6285,-557,-448,-6671,-8641,-1570,-2559,8957,-347,-6542,-6810,9038,8480,-1530,-3834,-6363,7776,729,854,7874,-3675,4688,-1181,-180,-3618,1929,-7547,1747,-4676,2889,-7270,1523,2801,-692,2135,9698,-7019,-6801,-4444,8981,-7141,5875,-2230,3979,-5167,-5495,8433,4502,5855,7631,2972,-738,3447,-9767,5906,5484,6148,-9458,-7772,2463,2510,6613,9477,129,-904,-9141,5279,2536,1493,1979,9743,9800,2219,-4301,-6779,-1544,-1248,-1480,2062,7320,-2444,-8703,6624,-2931,3354,8259,-7278,8705,6740,5151,-6763,-8960,-3934,-197,-5723,4534,-8412,3935,-7203,7313,1176,6345,-1965,1272,3930,267,-1686,-9353,9130,-1178,-4946,-9657,6981,2694,-7559,-9218,6778,8871,678,3486,-2838,-1530,-5774,-175,5632,-6401,-4145,-5251,7394,7261,5118,8284,3888,-2290,-4091,-3159,-3931,-3291,-7922,-7621,-4857,-3819,8867,-7906,8302,7579,-607,-8861,-66,-4433,4360,-5240,-672,4631,-1836,-597,7881,-6260,-7767,-1473,190,-568,-5320,-6234,7661,-540,9998,3906,9201,4620,-9182,3925,4677,2324,7156,5943,-4403,-1650,-9,-3886,1334,6133,6648,-3522,-3132,-2240,-4426,8973,841,-8267,8228,9509,5683,8541,7946,305,8620,-2714,2526,3366,8750,2710,3273,656,-4494,1978,-5210,-1509,-2886,8181,185,-3479,7631,-6251,7343,7699,5471,1495,-3901,8881,-5301,-9085,7386,-6732,-3495,9104,-7204,1418,3651,-832,7998,5881,5908,-5899,-5894,1480,5786,-5580,8219,-6625,-8242,-4268,3231,-3973,-8726,-5903,-7484,9475,7424,-1794,3453,3992,-4577,-2836,-6465,9390,3297,-7693,3980,7506,-4902,5464,-8119,2422,8817,4695,7468,-3860,-2541,-1056,-3286,-7985,3346,1634,1935,-8496,7612,4846,6406,-8795,-5190,4336,-7153,-5173,-2067,-2901,7328,9025,8701,-8170,-678,6736,7211,-5093,-4889,5649,-3652,-3348,4528,-4102,-3739,1907,-3861,5414,-9464,-9661,6417,9108,9309,9171,4558,-1736,-7236,4067,97,6163,-3197,3539,-3649,-3529,-783,-5033,8608,-251,4182,4850,8344,4621,7814,-1281,-7912,-3956,-8045,1757,-9090,-4259,-1376,8259,4324,-2819,1347,-9346,1000,8375,4840,3440,-4394,7968,2776,-6526,8120,-5069,-202,-9994,6899,-4931,3189,1689,-7647,6359,-9646,-7362,1530,3630,7701,4380,393,9142,2283,3561,752,1219,-5016,1865,-1031,2822,736,3215,-4901,-2339,-620,-4190,7047,1442,4254,-2086,-1315,2960,-9445,5285,2563,1664,-4593,1189,-7875,-6327,-1954,404,-5758,-2863,-4764,9092,5319,7899,-692,1371,9932,-5917,4094,747,-5630,-7752,-5211,4521,-6306,-9020,3907,-3893,-824,6704,9488,9943,-8976,-8816,1498,-5702,6408,8203,-7950,-3716,2688,-394,4487,1782,5371,-3993,9106,-6051,4743,-6365,-5614,4854,7674,-413,-8675,-3991,8205,523,-7736,-935,6458,-6099,181,5904,-9833,-9966,5308,-1580,-7362,-2578,1625,8023,-1872,4592,7169,759,-1770,7567,8348,2293,-8417,-5194,3846,-5330,-2645,-1037,-3806,5249,9062,-5417,-4984,251,9380,7718,1705,-2055,429,-415,640,-9220,-3090,745,-9688,9808,602,-5248,-6626,-312,1954,5270,8456,3739,4759,5888,7287,-9800,9041,6876,9273,-6505,-1581,2887,4334,7758,-6599,-4960,2423,427,-124,897,9393,-520,6595,2154,2000,-7866,8014,-4526,5980,-6377,8940,9246,2611,-1829,3070,3260,8756,6014,203,-6137,-382,-4913,8850,8831,9293,-1862,8314,2061,-9497,7436,-1333,2455,2258,2737,42,-8019,7389,9407,1779,5933,3615,6425,-9600,3916,-5914,1162,-6994,-3933,-2432,-5382,-1375,-4681,6003,2052,-7687,-8761,6844,674,9680,-9164,-5042,3288,-3335,-5725,-3982,2499,-8567,-7191,-3732,849,-4157,9369,-103,-494,893,-623,8715,-4987,2292,4832,3466,-8654,-2558,-2972,-548,7847,2652,-4499,-5103,-7333,6672,3338,-6515,3658,-5182,-2866,234,-2649,-1100,4572,9896,91,-950,3655,-3036,5281,-9542,1574,-8213,4878,459,5009,2819,7785,-9925,-1265,-5584,6307,4501,7862,4008,1076,-7915,5925,6702,246,7713,2000,1435,2183,-5533,-8951,-1086,4477,3642,-8481,-4431,-9459,7452,-4746,-1531,-7182,-5285,-9218,-6090,-1699,-1940,-8454,952,-7174,9574,-417,-2002,-5528,9793,611,-4401,9242,1786,-1461,-5581,-708,707,7274,7367,1825,78,-36,1143,8815,-225,-9117,-9492,5260,-7489,-7117,3552,-5220,-9909,-9812,-610,-1326,1163,-5540,6176,-3517,8004,-4009,-2992,1365,-7800,9294,6373,2729,7885,1737,-7949,-971,-2040,5647,4488,2040,5404,-6641,2722,-4850,-3036,-3419,8668,9083,6477,-8466,-9891,-7936,7013,2377,-2241,185,419,-9071,-6678,-5465,3129,-2830,4348,-7941,-3945,589,-4342,1641,2714,9703,-9812,1106,3802,-1109,-472,-8670,-6669,7031,-3690,8259,-1810,-8703,6407,-2382,3410,-8255,-5521,4198,4357,1169,4001,-7145,4550,-9861,2659,9027,2373,1537,2230,2373,7744,9222,8823,-9011,922,6178,3384,3287,3201,6480,8568,-2664,5936,5121,-5208,9856,4198,-3152,-1564,-3489,-1198,-3399,-8832,-8122,9449,1390,-6794,1976,-977,-7415,4302,4180,-2913,990,-7694,6839,-759,245,-9484,4087,1273,-4402,1679,5185,9586,-276,-8854,-7805,-5240,-829,7097,2267,5414,1652,-7596,-537,9747,-5702,1329,-474,-862,9391,-1100,-6963,-855,802,-9293,-6822,-3865,2813,-3022,984,1596,-4200,4320,9001,2435,-2005,4437,972,1238,7831,-86,-6706,-80,2497,6714,272,-360,8717,135,-8251,6057,8215,-4126,5800,-6898,4005,9150,-8126,-7612,-4132,6883,3046,-2205,6692,-2846,8029,9591,-4452,3579,3571,-206,2506,801,-9265,-2482,5801,2654,1499,6511,-5923,-5667,2796,5000,-8818,-8464,456,-1896,-4762,-2133,-7296,5698,-2200,-2671,1112,-1955,8212,-6543,-2180,1538,9512,-7987,6586,925,-5540,7222,-3293,-1336,8220,-1919,-2244,-4072,7212,-5946,-7120,6657,-2258,4303,-1527,2462,-9328,3172,-811,2639,-6522,7701,6915,-6376,-3140,-7888,-4414,-2604,2037,9737,-3698,-8068,-3025,-6458,-1220,-3402,4276,-5622,-6175,7411,54,4960,3954,2667,-3527,68,5101,-4758,-6002,5772,-4993,9347,4701,437,935,3512,-4045,1577,-2325,715,9614,361,3002,-9706,-391,7105,-6927,7753,6975,3343,9622,2625,8809,-407,8338,1242,4189,-1900,-4549,5246,3221,-6746,-6003,-9315,9812,-3382,4290,-2920,-9174,2340,44,6691,8716,-419,-8409,5791,-5781,-1742,-16,8247,-3608,4407,6079,-8307,-7090,-3577,2597,6169,1683,-3119,-94,2366,-2141,1739,8867,4019,3384,5505,1912,4595,1327,2190,7532,3663,4352,-1356,5675,3846,-5323,-2186,6325,-7276,-9712,3603,4454,2012,6103,-7317,-3813,9335,-1528,5902,-598,3881,-9056,-7367,5632,-1431,9611,7281,-5240,856,-6045,2279,-592,-3736,-81,-1129,7097,7865,3904,-1210,7464,-6849,1933,-783,-6662,-8735,-4316,-1661,-4275,-1334,-1878,-4308,5082,721,-9713,8679,4872,8975,9877,5021,9752,-658,-5620,-1852,-1978,1963,-3229,1997,2791,2101,-7357,-273,-7380,19,262,3462,-3230,6660,-8824,6160,-1595,8034,-7158,-4316,-9778,-7954,9255,-6989,-5034,-4298,-4497,-7404,5265,95,6425,-7015,-5535,-2647,-5439,-2734,9118,-502,-4600,-3344,4867,-7404,-4192,-15,2225,2143,9424,8662,-2809,141,8579,-4790,-9133,5334,5375,-9947,8862,-2246,7128,-8286,-1561,-2268,-3941,-100,-5514,-4200,9444,-8564,-2354,-7794,-2494,6557,-5770,-8378,1314,9899,-3059,-8932,-5796,6869,-1861,4909,-3287,1529,-1351,-7091,4641,219,-8831,-1486,-7578,936,-8754,2553,6543,6004,5798,-6098,469,9593,4457,6158,-6339,-3148,8901,-1489,-2204,-8598,2537,-9831,5295,-8805,1588,4712,-7496,-8817,4008,6688,9670,1394,2942,6346,7197,-3855,-9840,3998,-8470,6390,-2535,-2517,4581,1729,-349,-2916,1483,-5360,8570,2990,-9337,1428,6562,-4819,-6617,-7727,-444,1090,8737,4012,2617,6814,-5026,5036,9700,-2032,-1161,2536,2892,5032,3941,-887,-6146,2623,-4765,752,9385,7209,6854,1277,6143,2764,8205,8407,-67,427,-6047,4599,-4823,-5450,264,-95,964,-2682,-5518,656,2858,7373,5832,58,9308,-8534,2535,435,7873,-225,3992,-9387,-9794,6745,-1527,6276,3489,1185,3310,-9858,-9780,3164,-5616,-9010,-2327,9361,1136,-9918,-7484,2127,1721,-8919,-1529,6299,-3603,-3101,-5135,8710,-3783,-2286,-7725,9678,-7485,-7337,6641,-5396,-3335,-3777,117,8888,-150,9832,-6364,-1195,1570,5348,-7101,6206,2262,-226,1413,-7854,7668,-2546,-3239,-9507,8942,7032,9779,1813,8242,3996,8292,6195,5435,-3017,6136,1416,-1746,-1221,-5240,-1380,-2719,-4545,83,-5857,229,3867,-3486,-8362,-1031,4872,3458,-4448,1479,9952,-2598,1022,-7272,3332,7832,9649,-2450,-3289,3451,-8508,354,4463,7721,-401,-5203,3536,-132,-5793,-3558,4166,-6621,-9839,-8766,-8038,8516,-4713,6257,-3891,-9591,3142,4083,-9057,9393,-6213,-7164,-750,-1305,-7998,3025,3515,-2830,8748,6907,-3776,-665,9177,4303,-4525,-3992,-6061,-7615,7664,9584,6332,7023,-3923,4731,-2704,8448,1714,9547,4158,4325,3956,909,6164,2179,6406,4144,4428,-8471,-7666,-4315,5108,-959,2542,8099,6403,-1782,-3281,-5958,-9715,980,3447,9578,5414,6424,-411,-8507,553,-494,-7086,-6209,-6871,9509,-9713,956,-7462,-7653,8159,89,6803,7613,-8840,-8861,-4055,-7651,5901,3794,3798,8739,-4518,9457,1590,-4387,6692,-9805,1688,-3642,-9637,7523,-7483,3159,7583,7083,7667,8451,5588,-539,-3535,-7609,-5764,8269,-8810,-7843,1715,-2387,5695,5538,5315,4396,-8972,1711,605,4611,6475,4876,8904,-4289,4236,-8564,1729,-4865,8325,-3815,-5833,-9151,-6072,-8738,-2386,7557,2394,-6513,7746,-9951,4462,-7081,2561,-1238,4156,5294,-4187,-2447,9177,-8613,-6516,-5545,-5289,1348,6454,-8224,-5120,4394,4619,-6108,-2397,5865,6385,-8448,-8890,4717,-5157,6436,9457,5569,1726,123,-1833,-7361,6818,-2786,7196,8328,4818,-3390,9310,-3776,-5892,-25,-3418,-4061,3539,727,-4250,6610,-9488,-5190,-1075,-1765,-7171,-9767,-485,3485,-4599,-6587,-9452,-3604,-1458,-3267,-9032,-3059,-2439,-3088,-8026,9264,-7325,9177,-4495,-5895,-3358,9422,3060,7857,2051,9235,9865,940,4265,-6108,7235,6915,-1255,8408,-6635,-1656,3427,-8578,8554,2935,-8049,-7878,-3129,-4560,-1332,-9720,-9304,8336,-2477,-5082,722,2939,-3199,-984,3707,-253,-357,-8599,9789,4953,-6752,8272,-1138,-3059,-3062,-3850,-6615,-3327,-1368,-710,5115,9438,6703,-9554,3027,-4988,-3572,5858,-9746,-9109,600,6117,211,7615,8022,-8622,-4757,9449,-4392,-7697,-9461,-500,1445,9384,249,-3646,-6490,-6389,-768,-132,867,-3849,1151,8198,1296,1471,1376,-2049,-6978,-3107,-6555,6603,9744,-7765,-43,4951,-4062,-6311,6030,6221,453,-6646,-5462,5824,7429,2260,2108,9736,8876,613,-8592,4703,7921,-2363,9809,-7957,984,4764,4380,-6773,5165,5565,4177,-4101,3421,-8055,-143,2742,-3801,191,-9500,-2776,-3480,7227,-8462,-7017,-678,-3226,-8634,4231,-5433,740,-4295,-4634,7932,-9418,7469,4321,-1597,1656,-1603,-3982,-8619,6495,-7214,7563,9171,4575,-8346,-2623,-6597,3365,914,7522,7951,-1603,-43,6292,9381,-1102,-6648,-5223,8219,4089,-4468,-9110,-2804,-1253,7326,7376,-5011,-8538,1066,-2711,-7224,617,-8009,-6197,-7268,9293,-1462,6193,9739,-7415,9788,1861,-5467,4564,-8064,4561,4098,9108,7977,7351,-8467,-2326,-2895,-3785,-3268,8583,-9380,-1465,3432,-3021,-7088,4908,1975,-1990,-4068,965,-5386,2614,-4540,-2199,7165,5735,-9328,4577,-4736,1668,9838,724,873,-5017,9832,7691,6596,8765,-6915,2099,-5565,4128,-6568,4586,341,-7648,-9027,1485,4055,7624,-5784,4190,-6781,7091,-959,-6054,1768,7132,5413,9293,-6392,-4851,8463,-7128,7486,-5364,-1571,-5363,-6557,-9106,8821,-4187,-71,-5184,4786,-3024,8043,-8188,-2844,8883,416,8280,-7213,753,7697,53,7383,-2766,-9028,9875,-3194,3201,-8322,-7544,-6,4976,3204,854,-9205,9101,157,-2048,-2086,8565,4875,-9330,7912,-6468,-6457,-2192,-7119,-1776,1141,-1660,-365,-471,4456,-3887,6104,1309,2626,-9308,9522,-330,-2366,5492,1614,-3159,6922,4335,3848,-8472,9418,-8815,-9233,-6124,-1356,3114,6143,5368,-8883,5956,5534,7837,9757,5210,-4702,-770,-9693,-331,-2373,-8768,-7761,427,-5021,4348,-1923,-7187,4247,-1139,8242,746,1023,3137,5737,-5232,-2397,-4406,-5303,7067,2838,8100,3168,-7054,3801,-3192,-4585,6933,4693,7268,-7453,-5996,-4821,-3442,-2120,5579,2921,-1401,-5077,4473,9728,7461,-9934,-3969,-7768,-2396,-1897,1643,-1623,-7102,6273,-9482,-9485,1510,-6977,3282,-4040,2205,5375,-1963,-4722,2244,-1655,9408,7268,5282,4834,7777,1939,8946,3191,-2988,-6050,8486,-4128,-72,-801,-4059,-6760,-4530,-2800,-7075,-514,-9573,7454,5152,-9238,5572,-6112,5850,5261,-4113,-3198,2092,-3184,-8879,-5764,-8830,8370,522,783,-1583,-4472,-7289,4184,-7372,-831,-9425,-9706,-8680,-1566,-2281,188,3404,-338,5961,3719,-8453,-3047,-7240,-6207,-2223,2168,4528,2238,-6373,-7982,-8553,6636,-965,-3787,8022,-3988,8580,5823,-2222,8979,5792,-8379,-5480,1349,1622,5938,-5712,6213,-7480,-1670,-7304,8306,-5654,-6165,3520,-4313,-7564,-8101,-2655,-6238,3002,-651,-2082,-9449,-3071,8257,5570,8133,1927,8003,-9760,3141,-7453,9008,1472,-5158,3980,6138,-7052,-5879,-4328,1796,4675,-1148,3540,-7311,2113,-7409,7974,-9869,4563,-1443,8284,4411,7958,4795,-7066,-4418,-4473,2217,2825,-4347,-7247,-2263,8306,-7898,9487,-9371,5671,2676,-727,-3924,-9626,4124,7151,4256,224,-8302,-2855,3642,-6179,1728,-7146,8366,5046,5749,4688,191,-7252,6020,6345,-5367,6234,7723,-7721,7201,-6557,-1014,-1804,8865,-7947,6878,-8695,-9305,-247,-4326,2987,-9505,-4741,-9765,7772,4833,-811,-739,6435,-6049,5083,9861,-929,7271,-4985,-3702,-3897,-9012,-6961,-7921,-1063,-6002,-61,-3517,3992,5665,159,7644,-829,9194,-7998,-6805,1482,-7944,-8120,-8789,1429,5261,-6949,1370,-9712,8613,-1049,6504,-711,-7613,9769,-6232,8681,-2599,6613,-4491,9095,-3443,-2182,8893,3799,9293,2668,-9738,8138,2640,4921,-2721,3838,-1260,-4605,-1074,-4551,-9340,-3180,227,-2111,-3935,9128,-818,-7836,1617,2778,-7822,1297,3844,58,-6992,9442,6962,-1100,2799,-8794,2818,2202,1233,-7263,-8765,-4464,-7068,-2350,7318,-7407,-5203,5288,-3565,3144,-4704,-3996,-4655,-8362,8985,6368,-576,5344,-7350,-5811,-6364,7299,8109,8143,7515,4830,-7291,-1861,-8934,8990,-4112,8704,-5629,9303,133,5533,-9517,1538,-1026,2930,-171,-3441,-6591,-8481,6438,5154,-9456,9795,-9303,-6011,2215,4437,-7845,7132,4303,978,7031,-6092,1541,-2494,8380,-9188,7201,1987,-9068,-7078,-2093,3702,-268,2633,-9288,5373,5194,-5582,-2674,2226,1600,6575,-9543,4846,-9513,-5104,-7751,-6247,-7192,6537,-577,-9240,-5226,9182,-7043,8733,2012,-532,-1811,-2296,9442,-6363,722,-2896,-8594,5154,885,-1642,-2926,-1524,-9041,-6452,-804,-5306,-7120,5551,-9594,7551,5683,1995,-2738,5001,9218,-5563,-890,3803,6383,5564,3064,-7642,7282,-767,5416,198,4918,-6101,-5699,6146,8261,3467,8185,331,-8107,5572,-7383,-7157,9610,1570,9085,5033,6624,-315,8318,2400,-4605,-7197,4455,-6859,-5437,5247,-7619,-8228,-748,-9092,-7558,-1424,274,-6547,3561,-9117,8128,3951,-4203,-704,-4605,7979,4545,-6217,5412,-9681,1987,-6184,-2936,-738,-2461,4575,8395,-1573,6397,1669,-612,1540,-3552,6839,-4822,7592,-8805,753,-5437,381,-5889,-488,1477,-1845,-8776,-3403,-3167,5036,7753,1886,6009,-663,8074,-3243,-2299,-816,4947,4461,-1481,9536,3340,-4441,-3816,5037,6294,200,-4172,-7874,-7122,8616,2276,4197,2411,1894,-6109,9383,692,7067,-6602,-5547,4893,-2885,566,-9458,-7080,-5798,1830,-6154,3686,-6986,3626,-9261,-6515,-3433,-814,5371,7959,-635,5543,6918,-6046,4515,-2802,6169,7302,-1456,-1659,-2098,-6630,-9555,1325,2751,1804,-7421,1918,-1790,-1271,-278,4012,-4807,5282,-5749,-4788,-7592,-4917,-9703,921,-5089,4504,8128,-3649,3968,-5058,-6699,-1460,5475,2201,4018,-3801,5049,1739,5133,-2787,8587,1200,-9679,1107,7360,167,9329,-5547,6811,2333,7630,-8451,904,-2591,3594,7933,8275,6400,1485,-4005,-7114,2822,-2876,9807,-1500,-7489,-6432,-8688,-5490,-507,4911,5043,-2986,-8566,8182,-9778,-5142,-4776,2714,6525,-8926,-8061,-9111,4859,-5393,-8917,-1619,2696,8046,463,-6681,1692,6224,-3972,-4246,-786,4361,5074,-3237,-1820,2170,-2882,-2544,-7609,7500,-7013,-2484,-5357,1185,9351,4373,2416,166,5190,-1446,3760,-8499,-7533,-6770,3143,725,-8453,2250,4114,-9108,-9038,-1734,-6338,9033,-1982,2560,-427,-4740,-6981,5499,-7732,-2570,-7375,6274,9225,624,2257,-9033,-302,-8751,5626,7957,7444,-378,-8814,9557,-8991,-2709,-6524,-3537,5328,7933,-5018,6033,-791,-6529,-8504,2518,-3755,1400,-3300,-3300,4911,-2548,-2162,-253,3287,4564,-6924,-3096,-4897,3222,-8049,3901,-4925,8950,1282,9151,-1870,-3431,84,-3134,1313,2383,-4813,-8943,-788,-837,-8846,1950,-8598,4790,5982,-2121,7489,8442,8244,1742,6323,-5305,-8581,-4641,6999,-478,-8816,2092,9849,1273,-8555,-5252,-1104,6124,-6792,5946,-1455,3522,6168,-7725,-5223,7073,-2933,7692,-9466,-6318,3360,-8265,-5387,-3767,-3472,-2745,7686,-2231,8552,-6488,-1024,5999,5346,1872,2045,4046,-7975,-9505,-2414,-1047,-2524,-9818,4536,2464,9658,-8822,-5382,-2923,7888,7164,-4651,8943,-3694,4572,3977,6454,-2946,-1371,-3024,6772,8813,-6599,2644,-9842,-3135,9119,-2703,933,4051,5662,-4530,4004,4268,-9426,-2343,-4666,3809,-2757,968,6712,6332,-3576,3369,3766,-2253,4482,18,9581,-4243,-3176,-586,-3979,-9918,8219,197,8235,-8605,9921,-9495,6015,7136,-2167,-6646,5565,-907,4339,5264,-307,-8471,7519,-8070,2663,-2063,7111,3495,8537,-5846,-6668,-1743,-7705,7143,5179,4375,4822,-2030,-3164,8184,7242,7642,7321,3052,9328,-3482,-7611,3880,-7776,2965,-1267,7367,-779,8492,1352,8657,2141,-1552,-6751,-4143,3009,-1813,-5690,-3451,1983,-8300,-7396,6797,3392,6408,7511,1902,8695,-7398,1596,760,5331,-6439,488,-8342,1856,-6237,-415,-7580,-2607,-6984,9522,-8129,1653,9243,3406,6960,-6124,7262,-1003,1669,-786,8217,3680,8591,-5856,7774,-5588,2891,7486,-7950,-6840,-5019,-2869,8959,1333,-1904,-3800,6977,3636,5258,-1601,184,3355,-5233,7881,-4925,-9575,-361,7210,-5116,2987,-1622,1313,-1183,8511,-3469,-8616,-7348,1176,8902,-9496,5982,-2020,-3127,7211,7215,-4224,808,7204,-9363,-5582,6389,-4923,2606,6442,5893,4108,-7258,4262,8411,-6571,5109,-4900,-8454,7880,-4479,-6271,-9412,4414,-8305,-4511,-8237,7915,5044,-3258,-7383,-6302,6603,2789,-2092,-3199,3999,2895,-5804,-6353,-5523,-4484,-7614,1801,5264,8993,-7025,4823,-6365,8595,6835,1411,-4248,6091,-6050,6165,6391,-6486,-922,1333,-7965,-471,6443,4624,5398,5457,4484,6566,-1628,-792,-2642,-4709,2857,1952,4504,-3073,7176,-2578,-7014,6628,-8987,242,6128,363,-6237,-463,647,-3404,-3290,-3719,5455,8177,5171,2315,3956,-8412,4438,-5913,6259,-554,6426,-3328,-1334,7611,-2898,2690,3960,1847,-849,2605,7991,-8692,2850,2774,-4634,7311,-4179,-8721,9969,1816,2667,-7923,-1043,-6405,9423,1821,-814,1676,-897,1838,-9192,-8004,-7512,79,4099,3525,-1678,-9674,-1685,8075,5666,-9034,-3485,7544,-1733,-3522,1486,-5688,-8871,-9592,5123,-4147,-4421,-805,3869,6508,-4402,6143,9784,-9083,3938,2073,-4248,-3548,4877,9071,2914,2473,7453,8028,-7320,-420,5804,5559,-8762,6934,-5470,-8994,-6356,-8846,-5753,8952,-1749,8869,-1938,2640,-6003,-9348,-7091,-7502,-6079,8113,-6272,-2426,-9764,-2350,-7548,-6943,4603,-9834,9102,5009,-7965,-3399,8566,-5377,-965,-105,2896,-7138,-1090,607,-3495,-7569,-4663,-6487,-5556,6982,-2251,-6097,-6457,9268,-6177,-3108,9529,3428,817,3395,-8432,7343,-5207,5755,7805,6879,6396,9749,-5266,-9287,-2248,-4276,-3313,2351,-3748,-3232,-8736,-9348,5790,-3794,-7295,-3138,6777,9222,-658,883,-2587,9702,-4865,8600,3987,-5848,-4419,-3305,1373,1132,9767,-5948,9987,-2834,6758,7432,3992,-6821,-1331,-274,-2081,-9688,4067,-4838,-9044,-6590,8878,2966,-1220,-6093,4252,7246,6651,7646,-3241,7182,6685,-9164,-3781,7060,-8988,-8376,7383,-9285,7702,4396,-5302,-2503,3604,6045,1847,-3486,3127,1109,2142,6564,5924,9191,4169,-9579,8692,339,4981,9421,-4848,3477,7722,-3297,2906,1390,5133,7480,-3857,-6872,4928,4420,-8232,7975,-6590,6097,-1432,-810,5503,-884,8768,147,8204,1462,3588,1379,-1063,-7771,8632,-609,-7577,7090,-7427,-7572,-4930,-5375,-2546,-7625,-1097,6591,-8911,-4256,-187,-6639,-9535,8867,-9209,-9023,-6923,-1964,-9846,2505,-8435,5327,4301,-8736,919,8249,7171,-7031,-777,3337,5764,-7523,-4100,-5226,-3601,-5002,-8884,-8796,7092,1760,7894,-9962,7583,-81,-4733,4185,2669,-3265,-9498,4100,4856,-9486,7870,7434,-1764,-868,-4824,9052,-7783,3247,5904,-6001,9406,1979,1133,8784,4292,-1320,-2723,4278,6984,-3992,-3449,-8277,-9659,-8298,-2891,-3164,8942,-7014,-6342,-8924,5971,-911,-9860,-8722,-6642,-6843,1504,-5638,-6362,6119,8790,-4360,4172,3685,2115,7690,1119,6798,1912,-5284,9288,-8871,235,-9707,-377,3500,-3450,-7469,7262,-9205,-4952,-5835,8342,9829,-9016,4282,6749,1385,7427,-2711,5324,-8544,-8102,-4996,9,452,-6214,4223,-3394,-6231,5356,405,-4064,-1587,9165,6811,2500,-1372,-1266,4379,1537,2970,-9500,7476,-4610,-2786,6190,9866,-3539,7555,5758,-3671,-463,6731,8153,-3006,-9466,8778,-322,-4474,-9215,-9450,-7005,1341,220,-6639,5468,7493,1980,9129,1455,-5980,-5367,-5079,5393,-8627,4115,2785,-1866,-3205,6055,4128,756,3988,9337,2633,8661,-6372,4573,-3440,8783,5664,-7026,649,-6492,9214,5979,-2742,-8175,-3129,1026,5388,3930,-1924,3435,-1254,-4455,2481,-9517,7545,-1682,6602,8227,-3146,-2530,-6430,663,-7387,-1544,-8204,177,7146,9399,2867,2055,-2149,387,3314,8853,7011,-6603,-7726,9394,3169,-8585,761,521,8453,-3815,-4311,-5029,9428,8693,-5035,-6772,-5373,-7735,2719,1994,-9009,-3478,9426,-2876,-5639,-6893,-2108,9355,-8375,9930,8643,-389,4286,8195,-3583,1050,7453,7652,2604,7012,-1217,193,9861,-2257,4035,-7732,-7239,-9655,-1619,5821,-5363,-3416,-789,-2450,-9862,4989,5666,-740,-7150,1919,1509,-7519,-569,8716,1509,8528,-4690,1461,3576,8004,8743,-2096,-3769,8430,-623,-4385,2023,3234,9103,5868,4473,-6112,-7230,9944,30,465,-5482,-5621,-8758,-9777,8282,-2086,-5099,5571,-2383,840,-7597,-177,-7301,-8647,-2270,7177,8863,6002,-8409,-3403,-2786,467,-7021,5527,4521,-2263,-9716,7768,9741,1335,-3025,6124,4441,-2520,7745,7009,-2414,3407,1599,-2766,302,4360,-4432,-9864,7543,-6626,-4890,3223,5443,-8074,3563,8400,3331,9985,236,8240,9322,2678,-4198,-4288,4493,-4482,-2673,-220,9748,7066,9373,-9448,-2382,3571,-900,7652,4072,2148,9605,2479,7158,2231,2272,8377,3760,883,-1610,-5166,-1979,-1060,-6409,3676,2431,-2432,-4975,-3687,-1612,-4689,-5885,2959,139,-3896,-9814,368,3831,-9245,8260,-292,-3693,-2925,3666,-6610,7306,5769,993,6967,-4591,7939,-5301,-3235,-7095,5778,65,-548,7303,1158,-6601,3034,-1267,-6980,-3558,-1355,-8181,-8528,14,-516,-9956,4321,9717,5622,-3232,-8173,-4287,-3762,-9311,5676,3758,-4201,5213,-5116,-6122,4797,4807,-3837,-8745,3302,2443,3106,-6818,-6717,-37,-2099,114,9144,-9589,1127,-9746,7640,2958,-9549,7587,-2963,2259,5993,374,9074,-337,-2015,-7687,1336,4438,-1574,828,-5757,-4263,-8125,8984,-8257,6598,5520,5859,-8786,6445,4759,-6346,-3550,-6184,-5693,8838,730,-3640,2142,7697,-7348,-9271,8207,8934,-5992,8842,-621,-3705,9085,-8433,-4388,6937,-6951,9685,5483,-2572,-1632,-6071,961,-8390,-4381,-154,5757,-3294,-5623,-804,4726,9820,2566,9961,-8338,-6891,9504,-4732,927,8280,-8666,-6135,4978,9180,1356,-6932,9594,710,-9911,4930,-5292,7250,-2690,2456,-620,534,6556,3868,-2562,4188,1217,7530,-843,9135,-2047,6772,-7912,-9673,9965,3041,3807,-513,7272,8598,-6199,580,-6999,-9025,-3643,9660,-6357,600,-293,-7523,-6037,9315,-2542,-1644,6456,-2724,-3080,857,6722,7482,-6765,2556,-9761,3054,2158,411,-3739,-5507,-5094,-2206,9712,6582,-2755,1587,-8053,1036,-5440,5162,6412,4305,6421,6835,7613,5038,-7920,-7247,2320,5367,1167,7489,-6185,6919,6226,9815,-1568,3185,-8126,-3795,-7011,442,3070,-9159,1227,-3767,5217,8328,8918,-3748,-1951,6812,9744,5009,-1429,5534,1853,2514,4457,2200,7571,-4147,4666,4020,9872,802,9806,1222,2750,9595,3203,-6518,-9991,1304,1317,1826,-3126,-248,-7065,3277,5872,6410,3311,-6041,-3466,2079,2686,-3324,-5867,-2261,-6598,-2299,-2227,-759,5344,-6048,705,8540,-6023,2461,-9358,1704,-5232,-3355,6727,-350,8228,-1063,7960,2956,-4794,3224,-581,-8230,132,2062,7963,2688,-2235,-1211,-1454,1178,623,3178,5675,9343,-1336,4828,-8396,-892,-9673,1285,9411,-7663,9067,-6400,6993,-7732,6082,-1754,3406,2455,6753,-1157,6210,2043,-5103,8334,9100,1165,-4899,-2441,-102,8950,1144,4386,1447,1765,6379,418,288,1894,966,6433,6826,3416,6819,-1383,-5183,4154,7978,-5938,8618,-6115,3271,9024,-5755,-965,6271,-3550,933,7691,-597,5468,-6858,-9835,-6191,1712,8273,7253,-1469,443,1491,-3073,3078,4113,-2836,3659,-4029,-331,5984,-6332,6329,4217,-7642,-2204,-2997,-5657,-4036,-2307,-4588,8246,9038,88,-967,-8051,-7754,-9764,905,-2889,381,-7285,5090,-1977,-6229,-998,-6000,6053,-7828,-8735,9340,6375,-854,1816,1219,-4733,-799,1648,4254,2717,5113,4074,9848,8976,5266,6693,3840,4486,-9292,4062,-6020,5437,8645,-6288,2351,3414,8420,-2500,-4120,2151,8769,1967,-5096,933,-9392,-9269,6672,4645,-1395,-7496,4769,807,4024,-7282,6588,1213,-8674,1523,-3264,2316,7490,-3393,-1245,-9015,1564,6686,9767,-8093,5236,-7532,-6537,5609,6919,-8612,-8210,-4466,3520,-4383,-911,-5952,-2855,-3372,-8999,-6681,-404,-1900,-6418,2640,706,-8912,1953,-4223,8285,4115,5991,4945,3596,9297,-8031,-79,-3577,-4129,7838,6959,-9961,7717,3159,-3895,7332,-7257,970,2659,6246,7652,-9253,-6197,2687,4334,6234,8819,3305,-9902,-837,-606,5488,-1779,-7643,845,-337,4769,-2922,45,2610,3343,7818,8418,-2547,1611,-2495,-5229,-275,-8926,8773,-1110,-4764,-7982,2100,-8531,2569,-5676,-6746,-6567,-1131,-797,3982,-8324,-4474,1976,-68,-3041,113,-3210,-8508,9721,971,5663,8106,-3065,-232,-5409,6347,-2678,6386,-3293,1688,2644,7646,-6183,-6397,9243,2749,652,-3217,9287,4176,-2906,-1835,-9254,-7147,4850,6100,-9163,7841,3659,-9470,-9677,9147,-1782,-84,2953,-4920,-4672,259,3187,4161,287,-1647,5431,-8884,-6902,6190,-5481,8890,-9148,8798,9949,-4402,5618,-7117,2249,-6074,3981,-1552,-6869,5839,-8843,9503,-8715,-4450,-3497,4233,3443,-2302,-9425,-4470,-1111,-1357,2427,-4242,-4174,-177,-9256,6448,7286,6049,-1561,6652,6819,461,-5422,-8277,-7767,-4200,-8059,7634,-547,-1985,-8156,-5588,6203,279,-6597,-6948,2401,7356,3362,-7898,5550,7527,6252,8296,-6524,-6853,-4953,-826,5111,-7147,5069,2758,3510,4334,-2483,6459,6530,-4621,-8489,9286,-9897,-737,2221,-943,-3220,-3454,-9763,-2180,4780,-5022,392,-7526,2457,-4171,-3289,-6512,455,7805,7350,-9173,-5355,-7449,7889,5919,-161,7884,-9173,-1590,-3545,-6039,4503,2181,-6293,8044,-1408,-6958,-4882,7519,-3822,-9403,-682,2915,-5146,6558,9078,-7074,-6027,6089,3326,6587,3635,-2892,517,-2856,9689,-173,-4483,9311,7958,271,3594,-9678,6409,-9082,5557,-5428,4317,279,8188,385,1986,-1135,-1624,-3830,7934,-1722,5400,-8023,5861,-1122,235,539,-4402,2367,-2018,-4759,-5944,4454,-55,1783,5084,-7291,1571,467,-7144,267,5321,-6959,-9024,1780,-1082,-7009,-5332,-5366,-2562,-3881,1124,2692,9443,4260,8283,-1825,-2269,-2052,-9711,-792,-716,-1647,7591,7839,5560,2830,3866,3257,-6852,-5818,3141,5996,-7617,-618,7953,-9803,-6382,-1300,-1104,-7513,-3204,-8875,-3360,-1051,6578,-7683,-2276,-4462,9065,-7428,5743,5570,1449,-4252,9959,-6079,-3286,-9410,-3507,-820,8390,-4123,-2181,3216,-8213,-4049,-3064,-2714,8421,-2727,9638,9352,-3055,-5271,3390,-7440,9141,599,-7132,8191,-4937,-2864,6366,-6862,-5449,8400,-8410,4885,5070,-9113,5623,497,-2078,-4420,-4315,6807,-9184,-2555,4471,-7674,8208,-9302,7878,-2676,-7358,-9854,9472,5102,8120,-7295,4242,-6853,4054,4160,8314,7380,-8382,5394,-6666,-2591,-1547,-4826,2394,370,8606,5061,7055,-8783,8395,2582,-7743,-6839,-5659,8244,6690,-2618,-1108,6824,-3921,-1270,456,4200,-8804,-6128,2466,-7073,-9510,2411,3049,-2613,9668,3493,-8234,-9933,-9222,-6117,2543,3579,2201,-8936,-8908,8906,-2103,2968,4565,-9391,3454,-7646,3860,3192,9402,-6177,6793,-4960,-7224,98,75,-7094,706,-8641,-5423,-3208,288,9965,-4898,-1253,-3205,7314,-181,3941,-3193,-4642,9032,5093,-2148,-2618,-886,1287,-2635,126,-9471,1778,-8030,-10000,-4274,-7766,-1915,-1242,196,4306,-96,7854,-4879,-7040,394,-8284,-1765,3441,3740,-4341,-2978,-4202,-6084,4328,1481,-8273,4038,8956,-827,9512,-6616,7566,-2416,9945,-6443,-5286,-9586,716,-9237,-6602,6430,4430,-36,9499,-4988,9637,-110,921,2704,1180,4337,-8921,-9706,9020,6814,-2482,-2485,-6239,9708,9102,-7028,445,-3866,1031,-2264,-5133,-9721,-6330,3615,8709,-7131,-8994,4723,7552,4775,-7896,-2928,-8531,-2136,-3001,3634,-1189,6782,-6196,9181,-2617,7725,-4823,2559,2553,-3267,-6662,-7924,-1701,1773,-6006,8436,-1892,-6172,6872,152,-4373,3605,-8582,-7263,7325,6551,-7579,8213,7574,6514,-2110,-8016,-8915,5969,6866,-4375,-8798,8080,-122,830,-1895,-2009,-2022,-8150,-5533,-5433,1577,5959,7946,-4106,-7867,9174,831,-443,-3895,2198,2733,-4690,1796,8654,2548,-1754,5204,7038,-5052,-7852,-5857,-1287,-9755,4390,1597,-2371,-986,4558,-8546,3412,-7993,3,1902,4302,8909,-9601,6061,-449,4465,5878,-2752,5439,42,446,-5411,4055,4110,1000,7987,4426,-6320,-3017,4773,-1310,-7524,-966,649,-7843,-5301,7822,2128,-4853,-5966,6092,-3908,7308,-1095,-7295,-246,3475,5003,-6847,4942,2804,43,4210,-9356,1616,-9797,-1405,-6478,7650,-8557,-4799,7333,9337,-3311,-8565,1586,-2870,8056,-3002,-3161,7650,-5248,-7353,-2566,2730,-4276,-4366,-6831,3556,4731,-1181,-6802,1816,-3052,3448,-4693,6123,-326,-1244,-3745,-8502,7233,-328,-8681,-1450,-3980,-9474,-5754,2921,8805,-8841,-1226,2637,1673,-2740,-8292,2167,-4891,-1310,-2957,-7373,-855,-2455,3616,-1965,-8579,9650,9939,3955,6890,-2404,9605,6853,-7599,9322,-700,7297,-662,-7254,402,-6060,-5075,9836,-2849,1139,-9844,-9164,-3447,6127,-4164,-8927,-2370,735,-4446,9650,3573,-3422,-1336,7389,-7398,1904,-5811,6953,-1354,-3001,3598,1682,1406,5494,6321,1062,-2810,-4007,-4853,9229,7967,-1275,-935,8676,535,4601,6301,6000,7001,966,-2268,1369,-2071,7173,9767,-9584,-9745,-8324,2604,-5562,-2965,4617,5120,6706,-4266,7907,-8528,-6862,-8313,1704,1692,260,-3389,7856,-9748,3234,5981,-4499,2923,1294,-5850,-6778,8314,7023,7539,518,-6334,-9889,4835,6952,8461,-3167,6468,-8288,1083,-371,-5707,2878,759,-401,-2846,9908,50,-2993,3454,-3550,-3052,-6546,-9130,-1824,9915,4434,3724,1035,-496,-6142,-1688,-5374,-9826,-9897,6284,9036,312,-4741,2968,-2092,-5354,-1478,5135,8487,9573,-7703,7759,9559,7834,6480,6520,-9304,-374,2771,-9844,9490,-5150,-2594,-3195,-4355,-2082,810,7322,-5824,-6868,2356,6432,-3422,-6916,4495,4789,-281,4186,-1793,8549,-7392,-3909,7442,1384,905,7652,-9786,9251,-31,4513,-5678,-2197,-2956,2397,-8436,-7355,-2275,1269,-6857,7743,-865,8197,9149,-5671,2788,-653,-4360,-7361,9153,-957,9901,5460,9360,9103,3642,-620,-9754,4981,-7997,-5051,2528,-7831,-8237,3910,3671,5253,9668,8137,1920,3663,-5452,-8029,4520,-9779,-3413,-740,-4729,5034,7537,-6103,8030,-7158,-9502,4488,-6398,-1406,425,-5735,-6702,3258,-1510,-3577,7894,-6233,2837,4452,1880,-3965,3154,4153,-3998,-1634,9076,1757,1412,9229,-1692,-6811,4984,497,-4289,-2809,-9117,-8557,4866,2733,-7549,-8314,-274,-5632,-2789,1146,6954,3677,1508,-8418,2751,886,-3679,5564,-6011,-3959,876,-4759,-5072,2792,3108,-7552,1487,-2722,-7972,5367,4736,6141,-17,233,4058,3193,6317,4680,-481,-6085,-5034,1967,-4031,9091,4106,9899,-4219,-2570,8148,-782,8659,-744,-5698,7270,-5037,-8966,-8425,-6003,384,5319,-8777,-5342,-1206,-5736,-4299,9949,-1814,-2332,-5470,-7468,-2201,1757,1552,-4871,4340,-8158,-8727,5293,-7900,-5689,8746,-2786,6483,-8960,3870,6587,4748,2080,-812,-4234,-4952,5026,1415,5065,2196,8348,-2548,2094,-7159,9159,4598,3159,-1743,4878,-3232,9519,5844,4686,-1078,5076,1225,6071,-4571,9044,-9209,-986,-9950,5702,-8593,-4699,-3654,1747,-9199,-4393,-5231,8614,1732,-6084,-7029,4717,9775,1413,9354,9868,-7232,-3150,1685,-1332,-5215,7944,-3883,-3022,-9076,3703,-2505,6031,-6293,-3449,3755,9891,4134,-103,-4733,3413,-7496,-5697,-6975,8390,-1592,-2805,7435,-661,1337,1533,-8346,-2564,-150,-74,-1629,6125,6019,1350,-9660,-4171,1505,5838,-313,-6232,-1591,-6934,-4904,-7257,-4649,3340,-5632,1750,8399,6557,509,-9458,-4807,6398,1493,1526,8739,-2204,9872,6945,-2983,-5542,-9249,7130,-4731,-9894,-2546,4592,-2041,5063,-2375,347,-8221,-5255,-2728,-7378,2890,-2755,7075,-457,401,-4325,7053,9523,6372,-4487,-5394,-5382,-2250,-2323,-535,-8221,-8646,-9114,-7658,6847,-2834,-6409,6818,-2351,7087,8812,-94,-3185,6736,-3213,3255,1381,6704,-8795,8765,-3497,8664,9855,-5275,9056,-628,-2546,5567,8921,-7292,9697,-2563,-411,8482,-3036,-2113,-9125,3143,1512,7029,-1017,-2757,-8478,9535,-3106,-2605,3648,3945,950,-8044,9110,7002,5393,-6411,-1621,-9758,6902,-7100,2061,2990,-9678,9382,7713,-3311,8889,3789,-5998,-9155,6515,4688,-5971,-1051,4127,-1770,5426,8193,-8548,-461,4913,7047,-6925,7563,-6980,7800,-7547,-5844,-8002,5186,-4310,2309,6273,6774,-6142,-1993,-3182,-632,-6574,5382,1129,-2286,-8159,-5159,-6381,-6686,-859,5121,-5668,-1266,-9026,-3900,3238,3754,-6010,-5793,3607,-3595,2099,-3443,-2744,-7664,-9473,-2207,-1135,-6675,-6462,1303,980,-8073,-4040,8311,3966,2879,1956,9324,3574,-4840,8990,873,-8303,6005,7587,-7688,-2280,6029,3285,3740,-8847,2065,-193,-3951,7553,3526,3163,-5309,5410,1965,-7254,-9088,6165,-7486,9657,-8819,-8593,5925,-9859,-681,5057,-1064,-7347,9051,2732,4613,-9251,9610,91,1532,-1435,-8073,331,-6929,-2777,8307,-8887,-7947,-6830,-1149,8742,782,2041,8271,-390,9952,-5992,-279,2943,-2144,-6429,-516,1904,-3473,4026,2287,-5452,234,-7911,9569,-8863,-6970,-5901,8621,710,-2397,-6747,-9674,2608,8932,-4571,-6212,-5251,8850,7562,9260,-5564,2316,4770,5340,7406,-5410,-3635,-8723,7766,8510,-5382,-4311,-6999,-198,-67,5688,-6083,-4031,-2124,-1174,7953,732,-8669,3444,7275,-639,-5082,716,8257,2299,-511,3457,9421,1018,-9189,6774,-327,-2360,-7216,-8392,-731,-4114,-8976,-188,-9721,7904,-1695,-7081,7408,-6738,8449,-1994,-1304,-1050,-8963,-8380,680,-7867,-5942,-9784,1652,4244,7241,6461,3780,-5144,-8747,5772,5630,1925,2761,-6334,1206,-8597,9638,-6111,3696,7805,-7416,-5160,-2132,-377,6554,-5124,-9134,3671,5681,8177,-7001,3751,869,1372,8801,-3761,-6956,-9283,-651,-9853,-5265,5745,-6510,-2286,-5554,-7172,-7422,-8531,2864,3184,751,3419,6328,-6906,-5325,3205,4817,-525,4654,4309,3777,-5757,8359,-1829,2196,-4176,7490,-745,893,-6449,5680,5905,3126,-387,4045,-9817,1160,6589,7266,7985,-333,2876,9914,-1556,-5825,8879,-2596,-8600,8145,6684,-6828,1458,-4278,-7286,-3829,-2895,2522,-793,-4324,9116,-1264,-5588,4494,-8362,7511,-930,-8463,7636,8354,-6746,-8845,8140,-6130,7130,-1495,7141,7708,2531,6114,-2697,4915,-6550,-1258,6202,2740,-8552,2132,632,-9435,9032,523,5199,-1571,7899,-1184,-6647,-3500,4115,2173,5849,3438,-5196,6447,-335,9076,1920,5222,7139,-7671,-755,2475,9760,-5106,564,4788,8527,-6023,2280,6616,-2029,9854,-3950,-7808,-5098,5372,-9085,-4751,5709,5202,5707,1484,6262,-5058,5408,-3951,6893,6273,-9427,4003,-3745,9488,3390,8343,-7226,307,5884,546,-6953,1121,59,6024,-7028,1778,-2337,-1902,2402,3361,9415,-2314,-9736,2722,2913,-8388,-2645,-9324,4633,1261,-2846,-9634,-9374,-4133,-6634,5175,-3562,-4002,-5003,-1129,7733,-5991,4074,5713,-4757,-3991,-9332,9137,-2601,-9475,-827,8289,913,8972,-1006,9190,2705,1935,-975,-9361,-5573,2902,-2018,-7200,-6125,6809,-7495,4807,-6774,4904,-81,-1206,-9068,-3743,7423,7766,-6433,9860,-4635,-3312,-883,-2438,-5597,-3976,-8132,518,9233,-6360,-2518,9556,-8093,-1661,-532,-1577,-7787,-9773,8780,-5848,-7742,-1667,451,-544,-8984,2458,5215,2077,-9837,3275,2430,934,4418,4404,-5187,1813,2356,2814,-1365,5485,-8418,3472,-9099,-7,6824,-3533,-9260,253,5907,8409,7880,3197,-8437,6870,-606,2434,-3558,-1323,5529,479,8957,-1319,-7699,54,3233,-264,-589,-103,-5412,3101,-5653,-7129,-4983,-9634,1552,6472,-1944,-7918,5548,6057,1255,-4139,-1432,406,-4156,-4483,2095,-8898,5425,2719,9128,3098,-5487,-9487,-7216,-419,3552,-8692,-4527,7337,-9021,-2869,2178,-6046,-2751,-5435,6285,3752,3264,4407,4130,-4343,1537,-8035,-3579,-6198,-8150,8237,-2359,5450,-7508,-6130,-5650,-9957,36,-2214,5960,9102,-1134,737,-2421,-7940,8457,-808,3024,9827,-4349,-3386,1742,-8793,-1795,-2502,8919,-5073,4141,6379,-6265,8283,3355,-5683,5218,-3886,-6790,-521,-7786,-5790,5102,4333,3161,-7025,-1422,-7509,2718,6325,2077,2184,-4746,2244,8773,3201,6307,6348,4555,-1863,-4462,-5349,5930,-7568,-5955,-6440,8212,1681,-4703,5734,8632,-3831,8654,9672,701,-5366,550,5980,8001,-766,5433,-6230,-5398,1741,7630,7114,-6277,2312,-1978,-4284,8384,-5741,-6602,9805,-8743,-9184,322,-377,-6837,2268,344,3931,-6155,-9122,8803,-1618,1757,-5345,-4269,-4315,5183,-4927,-2439,590,1488,4848,-3577,-139,5029,3419,9078,-2883,-8855,-1964,5301,4518,-7484,4591,5558,-8739,-2724,-1226,4618,-8050,5598,-6819,7725,3923,-4035,9252,-8801,-9756,-9694,705,5536,-9879,9452,-3499,-5715,7474,9858,6426,-6058,7867,2793,9746,6079,4408,-4374,-4150,6839,5098,-4761,-452,2813,3292,-8159,5223,5529,5561,-4446,3731,-5385,-6055,4976,7580,-1640,-6366,-1063,-7761,-950,3804,8091,4496,-9977,6061,6920,-5657,6378,-2302,-8449,8816,-4491,-6665,8764,-5683,3930,-1143,-2414,-2189,2903,-5553,3039,806,7840,3880,-9480,-7716,6284,-9711,-8644,9035,9026,-4906,-5051,-5549,-7168,-4789,3623,7350,-2531,4423,-8750,5381,5683,-6015,3832,-4624,-3145,-4466,8637,-7497,-3577,2667,-3723,7887,-5410,-6105,7244,4193,-5613,6529,327,9372,8594,3420,-5508,7941,-3367,7104,1673,-3288,-3726,-3723,-746,-8707,2087,-7925,3174,547,6788,93,4280,7134,7588,2400,-3471,-1008,6329,3308,9102,-4552,4559,-4774,8939,5912,8710,1288,5356,4792,-7438,-8655,1921,-6041,-5384,-5140,456,5238,6508,3188,859,3009,9730,4414,-5899,5660,9321,4147,-5766,8378,8270,7883,3961,-4730,5753,2036,8722,-3363,9335,7175,4594,3488,-6210,-2572,-5625,-4681,973,2441,5965,1532,934,-6070,6379,-6740,2623,-8699,-4480,-48,-5425,8293,9723,4899,6144,-2960,8955,270,8534,-2922,-2059,-9009,1672,4842,235,3441,773,-7870,4583,-7942,-7943,8557,7808,3999,-1557,-8249,1791,-1307,-7535,5145,-8809,9517,2224,4836,1876,-7050,-8217,-124,474,1584,-3991,-489,59,3843,8239,-8532,-2311,-6723,-3852,-1845,7096,-8360,3877,-3928,-2187,-3097,-1241,7092,-4214,575,-9602,4589,5589,-8614,-3470,3586,-2154,7122,-2302,-4239,-1160,-3348,-2079,-5794,4036,-7990,-9907,-910,-5855,-7042,8638,-4553,186,-4637,2854,6717,7707,6828,-5364,6685,-4767,3889,-6995,-139,3048,-70,-4456,4564,7758,-3038,-2917,-1751,7493,6493,-3403,-149,-5484,-435,-7895,2504,-2747,6612,-1233,-7181,-4794,-1265,-7977,8573,-9724,-2288,1020,-1122,6545,5435,-7308,-502,6990,-72,-2356,2764,9766,5597,1772,3963,-6414,1523,8204,5269,5474,5447,-5691,8325,1142,9338,6644,7272,-3418,-30,-9984,-316,-4867,-8811,-1213,-1577,-8017,-9155,8507,-5107,7670,-2929,4427,6657,1973,-9162,-9483,5064,3764,4757,9791,9934,-8661,4610,-5585,-9629,7099,8118,-3815,-7825,-2093,546,9192,-4047,6962,-7337,941,6969,7341,9676,4334,-8606,4247,1521,-8921,-3787,-2309,-7871,8504,-113,-8357,-6735,3113,-910,-2076,659,-4634,16,-3243,9593,3367,4050,6476,4762,8436,9577,-6704,5717,7470,9970,-7905,-1413,-7823,-5080,-5686,2567,-2375,-7361,-4137,-1548,-6010,-3753,5628,4400,-1244,6775,-1098,-9021,-3377,-7686,-3346,-9783,-3008,2800,5479,5488,-6088,-4056,4534,4779,-129,2574,9953,2627,-6977,9588,-4474,-2722,-573,9084,-625,-9291,-1452,-5448,-7009,7886,3576,6598,-1634,-6205,1641,2905,-9874,-1135,-2899,-4385,2391,-8306,482,5950,-2260,575,-4106,710,4840,7889,-9370,356,-8038,1276,9603,1636,-8317,9302,-4444,-4337,-5172,-4349,5056,-4328,3113,-185,7377,-3134,-3066,8555,8703,-4625,5229,-559,-7197,-6125,4451,2181,5407,-8549,3912,281,-4688,-7790,-30,-4610,9113,-1076,5414,3289,-6469,-5593,-708,9607,9128,3250,-8228,-9467,8152,-4873,5287,4980,6048,3709,4266,1360,188,-2937,9910,-5305,-149,-3171,-5057,6522,5098,-126,-7775,2305,-3231,-1039,-9160,-3184,-6120,-7826,-9413,4098,8691,3849,-9159,-2045,911,67,5880,-4097,-5363,-1430,4097,-1073,-1613,7299,-5658,-74,-9896,1632,-3752,-3474,6942,-599,5324,-5238,-6725,-8472,-4134,-9064,-4625,4203,-5384,-7316,4227,612,2297,9311,-43,36,4620,-4423,7447,264,-39,6660,5352,3381,-6560,-5833,-3306,-4194,6342,-8351,-5814,-8153,5136,8329,-3194,466,5847,164,4899,-8738,8418,-3088,-1441,-6460,-8810,3181,-8323,9044,1417,5774,-9830,-3954,-9074,-392,686,7794,-7369,2314,8668,8585,5176,736,7767,-2052,1118,-4273,592,2324,-3366,-811,-1826,3157,7227,2141,9270,6126,1317,7106,-5140,5320,9166,-7285,-6732,5761,-6050,-3767,-9960,9739,2321,-4242,3817,-4301,-135,1666,-7031,8348,-2834,7123,2369,-804,1487,2454,-1777,35,-6202,5390,1528,1039,5425,2826,-8941,-9312,-3563,-3096,3371,2295,-5950,2778,-943,-109,1591,-8960,-3556,2761,1509,3303,4687,2305,-2469,6223,-188,-7052,9896,-4326,9349,5024,1,2646,6461,7457,-8839,2317,-6300,-9902,5119,-666,-715,-2642,1889,-5229,75,-1900,7278,117,7558,1350,1712,6932,8891,8091,-6200,-3139,-5010,-480,-2831,3071,-1521,-5928,-1690,-54,-3372,-1242,2993,-2525,4898,2347,8094,9364,7960,-3726,5360,676,2335,4095,5353,-7212,-8094,9344,1362,-5449,-8711,-8458,-4488,-4207,-9216,-7400,3288,9790,2060,6763,911,-6517,-844,-2097,2719,-714,-8809,-2572,-6592,4449,3762,-957,-1742,-571,2890,962,7061,-7281,-9364,7514,-756,-8996,2128,8323,-4702,-1096,-1751,427,6912,7130,7840,4499,2882,-8202,-2139,5041,7066,-1032,-25,9286,2261,-9849,3687,-5682,-2770,-5041,8328,7233,4854,-4375,7724,9233,7978,-6547,1522,-8681,-7077,2702,-4538,-5849,-6839,5754,-7195,-5627,6859,5037,-8008,3959,2956,9522,-4899,-9270,-6296,-2998,-4525,-9268,-7038,8012,4802,-4948,5672,-5535,-6745,-8948,6646,-5046,-3420,9823,-5974,-9318,-4675,-8756,2269,4424,7525,3130,4828,4085,48,7738,-1925,-5469,285,8235,-2502,6152,9589,5879,-307,36,-2322,-6379,-2935,-8076,-3349,-4721,3445,-4917,-8933,3171,8051,3147,-926,-4683,8283,1267,-6155,4817,8075,-1923,-215,-1746,4288,1745,5169,-8249,-9013,-3116,8718,-3527,-6548,6639,4456,9952,-464,3761,-5889,-6646,5824,1865,807,3097,2366,7328,-3535,8444,-9358,209,-451,-1296,-9087,3552,1945,14,-4761,7639,-5804,1546,7470,6125,-9178,-1559,-1124,9865,-2438,-5015,-2027,-828,680,-1276,6373,-759,1994,3531,-2964,-5207,-7213,9423,-5660,7456,-3146,-648,-6867,4772,-248,-3821,4297,7116,7834,-2373,4699,-8906,2142,7492,-5282,9046,-4145,1211,-2651,-4902,9827,-6379,-4478,-1722,2103,1780,-4222,-6250,4994,3510,-7104,9571,-848,-5788,-9501,7060,4376,-2996,-5253,2156,5549,2841,-4672,3419,5190,-1100,1254,9380,-292,-1190,6885,277,-4750,-9287,-1939,-1243,-992,-7453,-8756,-4972,-5529,-9475,799,-3352,-5443,-7016,7615,-9974,5045,6603,4761,-439,9506,4119,-5028,-1041,8435,9956,-7059,2433,2041,9759,-1403,-8845,-4928,-1466,4976,3905,-12,1706,-8003,5533,6115,-6597,8266,5707,5343,9473,702,-3129,9469,-5389,9628,1570,3961,-2975,1523,-4023,-8633,-3258,7588,4025,3184,-8548,9702,8887,-1092,6646,6198,-7367,5841,-6098,-8563,-8138,-9269,-4756,9570,-2610,-9438,5265,2904,9773,-9024,-3385,435,3885,-896,-7139,-5345,1785,9078,4253,7626,9844,4862,-8487,-3902,80,6880,-9195,-3700,7708,-38,3762,-9151,8080,-483,-2874,4194,104,-863,5247,-6243,-9790,-2404,-4209,8443,-5078,-1366,-8266,8575,-4935,-5115,-3990,9390,5716,-8359,9451,8447,-9384,-4270,-3486,-2960,-6612,6302,8789,3031,-2322,-5813,-9518,1501,-2078,7710,-1421,6843,-4296,-1305,7867,-7873,4517,-1413,6107,2311,3344,-8205,-8190,4777,307,-4247,-3156,4989,6176,3283,-8590,9307,4057,-5416,64,6604,-7479,1717,-1074,7248,-1223,-9979,-2348,33,9516,9613,-8641,4268,7498,-695,-1093,-6396,-861,-8184,-1797,-5505,-4740,2914,9200,-6213,9770,-2155,7255,-9053,-9766,1110,-6412,9402,-5339,1339,-418,9967,-5675,-3219,9036,4019,-837,7411,7668,6911,9401,-6490,-5388,-2114,-6341,-6872,-9828,-8488,-1306,294,-9640,-4063,-2688,981,1399,-3054,4335,7601,-6468,-605,558,-535,-6036,8326,-7027,865,6195,-8798,1699,-6989,8825,-9344,-2707,-7463,-5351,-7452,2676,7472,7955,-1434,-998,-8611,-2707,7664,9993,2886,-8431,-3004,270,-3898,9066,-8049,184,8676,7577,9283,-6431,-1786,8045,-6314,-9575,5085,1174,7977,-3807,-3533,-6983,-448,-3760,8143,-2683,-8410,7522,1892,-8347,-7913,1646,5210,-8835,4840,5965,8953,9348,-3578,2156,-929,-6068,-9959,-5135,3226,634,176,-3634,6679,4971,-2761,6819,1722,9318,796,8951,3299,4522,-5665,-8011,-2467,-8758,8766,2157,9585,-9830,-9405,-8015,7175,-5818,4699,-3365,-2776,372,-4389,2776,5388,-7467,6365,3355,-3290,2111,-8991,-2854,-2654,2289,9808,7430,7460,-6513,-4637,9450,-8623,1054,-8248,-442,-1667,9787,-4439,-655,-7960,5785,-4473,8208,8579,-5168,-9755,-9061,-4572,4484,7027,-9869,1632,-328,-3140,5075,8643,2788,6689,3499,1612,5805,4121,3353,-7195,7443,-6832,-5690,6555,-6256,7621,-2564,8729,-7980,-1707,3079,-3052,1098,6755,6922,8118,5883,9717,-5791,-6023,-3643,-7327,4946,-3971,6031,6579,-3532,-52,8124,-6520,-7144,6342,9220,-3439,-8655,-3021,639,2788,5553,8370,2935,7531,6018,-1978,2197,3628,429,-2075,-4738,-7917,233,566,-7941,3906,-1654,-3843,1590,-1106,1855,-5596,-7845,-8737,-728,6239,-4438,-1734,432,-7697,-1743,-6482,1609,-2060,-12,-2879,3651,5324,-9145,7227,9707,-7092,-4279,8517,-7613,4361,84,2282,-642,4520,8465,-5643,-4198,9673,2909,4590,-1856,7184,6391,1248,31,2347,-9145,8346,-6065,-2499,9099,-7771,1591,-1961,-977,5979,-6378,8210,-6807,-9130,-3645,7808,-5044,8197,2046,-2826,-5739,8003,2425,-752,5760,1482,1345,-7534,5904,9000,2957,1295,-5725,-1355,6010,-3916,6005,-569,1962,-3474,9253,2876,8772,8426,6738,4841,-207,5625,-2971,3635,-1491,-7811,-5627,-9384,9665,3292,772,3865,6875,8448,3892,4496,-5079,6845,4136,2032,8738,9435,-6487,-8569,-3719,2296,256,556,8935,4372,7088,-3056,1611,9043,-9994,7183,2748,6538,2900,8255,-6526,8772,-1673,6594,-1604,-8465,-883,-2072,-9052,-8619,3676,-5587,-3049,-8930,-4650,565,-3405,-9819,3428,-4839,-9565,-4635,4722,5825,-1372,-9204,-7664,-5459,-6426,-6758,5091,1237,-7629,8146,8748,-4025,3196,8889,7147,-2247,-4059,6812,-6546,-6960,-3346,7214,-550,2970,-2875,5515,-5656,6412,3331,-5190,1512,7524,3357,-4866,1724,-2538,4515,-1101,-5144,-5733,-2698,-5041,5586,3852,1413,4821,6595,-8726,-8730,6398,-6341,4746,-3410,-6361,1377,-5305,-6099,-4586,-5623,-2505,-1170,2926,-3520,2652,8855,-4391,-4449,-1882,-926,548,-8516,3202,-7867,5079,-1615,5804,-3662,8896,9298,6468,-5162,1466,9656,5200,487,8502,-4739,-958,4957,4948,5492,-3401,-2977,-6112,-4383,-2838,-9135,-2128,5449,-6247,-7633,-6714,5287,-8268,4242,-5122,7692,4907,860,-6396,-6688,-9323,-1152,1624,2146,-7377,5503,4905,2919,-9905,-5204,6536,1759,-8930,-7995,-5280,-4456,-8986,6083,9887,2528,8610,-2137,-6334,-2877,4863,-8452,-1033,3373,-9352,2417,-6293,-5985,-2702,1899,-5995,5091,9163,-4155,1793,-9793,3527,-1752,-4547,-143,4821,441,-783,4913,-934,4522,-695,1770,2366,4633,-7607,-9358,9164,7292,-3043,-166,4712,-1587,-788,7995,2043,-9661,9038,-7100,-3125,-8671,-3530,-5332,8391,971,-2875,2011,-4125,-7355,9252,-4735,6326,-5482,-7942,-8120,9368,3985,-4224,-4526,-4722,-5532,2515,-8994,-4473,3355,9886,307,1211,-9255,-8412,8279,-6836,-2849,-4636,5958,2423,-6130,-7747,-1913,-1710,-3473,6482,9829,-2458,8856,5719,-8235,-9106,-5620,-3535,2283,-6667,-8724,-3204,5880,3520,-6166,-3663,3478,-6198,8297,-3508,-3624,-8406,3878,5025,9601,-9389,-4651,8110,-218,-2153,-3014,-3185,9169,-4777,7852,-7364,6419,-9209,9184,-2697,-403,-9740,2908,-7746,6547,4504,346,-359,-1799,-4284,4245,9659,-1554,7237,6194,-9039,-7433,3831,4930,-6488,-3732,5949,-8436,1582,-6914,4487,-2970,-132,564,-5035,2232,7754,5051,-5888,2587,963,6257,1402,-1844,4659,-9880,-239,-9285,1723,-142,-9121,6388,-753,-4119,9737,9108,-1104,9671,1454,-8582,-6694,6244,8713,-3230,-1446,4889,9016,202,3937,5719,-7742,-2189,1992,-2641,-5883,-9819,9372,-4458,-7984,-4362,-4547,-9776,-6563,-7608,3390,-9633,8488,8533,-7320,9212,-6319,-3197,-7659,9581,7041,-454,4179,8580,7373,-8983,-8690,-4032,4854,-5398,1529,731,700,955,6942,4808,520,6922,-1499,-1412,-4315,3794,-7904,3265,6546,-1784,4651,-2848,5564,-956,-9591,-8790,1454,7915,5149,9093,6259,-7124,4550,8185,-597,5829,-5717,1342,5279,-8065,-6975,-1392,-692,-4704,-8329,-3787,3189,-5872,-4774,6855,-9632,271,7996,-8077,2562,9962,-5992,377,-1236,3515,8923,-6528,-6051,3760,5846,8725,2605,5554,-4932,-1608,7323,6855,3401,-985,5734,-5109,8927,2707,1200,5507,-7491,9467,-625,9276,7146,5334,-1401,2360,-6581,2804,-401,6521,4661,-3402,-9119,-3982,-2951,-7625,9761,6836,5079,-8642,-6241,-1132,4633,-3536,-2655,8489,-7355,-6436,4952,8694,4445,406,-6142,-2096,-6974,-9817,8811,7134,-1857,1574,-5438,3093,4920,7382,-3493,-9509,8130,1793,-2326,-1045,-3318,1842,9171,8686,1890,5139,-2680,-7874,-865,1503,5453,-5662,1568,4468,7221,-5995,1742,-3166,-1531,4676,7436,-4110,8131,9659,-5530,393,-4927,-7746,2979,-2150,-207,2824,-1155,-9541,-6811,-7023,-3119,116,6059,-303,9209,-2426,-3913,-3057,-9940,-9381,9034,8454,-5757,7084,4141,-4679,1346,-1808,-9865,-7264,-3652,-3021,-9862,-1810,-8642,-5822,-833,-9340,253,8842,6002,3908,2362,-1351,-8330,3874,5166,1970,4239,-3377,-2431,-4478,-4614,8008,-639,-6013,-8751,1145,438,-5401,-6763,6074,-1094,7114,1814,-1264,-9905,-6436,4933,-4318,7161,-5503,6190,9578,-3143,-8966,7902,2222,4728,-5630,8023,-7608,-2882,-450,7454,2742,4541,-5671,-2580,-4275,7620,2177,-9459,-8113,8,6651,-1420,7165,-2392,1354,-517,7641,9443,-6103,-7146,8083,2819,-2320,9115,-9768,-4156,-9343,2743,4582,-9934,-4826,2811,-5027,-5710,-776,-9912,4065,9997,-7595,-5191,3791,9058,-8462,-3039,-1453,-7336,-9485,-6242,6371,-1791,-3198,2158,5502,4305,9176,7951,-9719,6655,802,7654,-5852,289,6277,3883,4639,-3169,4645,-6046,8856,2197,4273,-8860,-7974,7270,4446,5882,3888,-6650,-6538,6830,-1251,-6799,1808,-690,-3777,-9843,8447,5890,7334,2568,4055,-3417,2191,-1861,-2341,-4377,889,8163,-9527,9860,5435,-7669,-1890,-4857,-2232,1297,3176,-1561,-2955,1841,9761,3186,4549,-8666,7908,-712,3519,2336,139,-6844,-4268,5975,7045,-4626,9277,-2617,-6496,-7481,9716,-8813,7980,-552,-1905,9598,772,-5037,5445,-1307,-5134,-669,-9493,-1753,2181,9315,5022,-273,-8553,2905,-7943,-3172,5652,6863,-379,1081,-3310,-6328,-372,-9760,-9308,7041,-8733,8480,-502,4252,-8200,7846,-2143,-3683,3116,-2668,2272,6849,1970,-3198,4562,-8065,3218,226,6743,-2177,-7574,-1599,-4186,-6414,-9671,5415,-6398,-4453,-8964,8009,-592,-6603,-5091,-2819,-3710,-903,-5589,-3984,-4937,-5774,6004,-9738,3737,-8708,-4840,-1091,-9713,-5178,2229,6867,-1347,-7613,-216,-5244,3831,1205,3831,1099,9905,8465,6305,5672,5853,3064,-5262,7903,-8458,4067,-8724,-5878,-5689,-7731,78,1299,6572,9927,9199,-3060,-2709,9857,6979,5061,-8201,-2747,7311,-3497,-8390,-3436,-1175,-9853,6161,6944,-7385,5892,3708,-9808,-8887,2839,9136,7176,3159,2206,1020,6899,9684,-8006,-626,-7064,-5294,6959,-3154,-146,1398,-4804,-4607,-661,1763,-4862,3871,841,8445,6955,9384,3310,239,7638,-5387,3719,-6164,9070,4209,6833,-9184,-5977,-211,-6189,544,-4713,-9902,556,-1667,-1070,6208,6581,-9870,-1072,1476,6751,-7489,2085,-2237,8441,-8257,4259,-9430,-9787,6153,-4792,-6471,-6014,4574,73,9504,-7330,-745,-5992,2024,-4122,5318,7548,9798,8747,-6507,-5942,8107,4742,-7957,7216,-1242,-992,-4908,-291,-3157,3244,3260,-6719,8377,685,-9458,-466,-4722,-8010,1470,7049,2350,1856,93,-6623,5326,3145,-4713,-5498,6179,-455,4261,6925,-355,8117,6655,-7020,-5005,6428,-1035,6344,2207,6067,3176,-1491,-8175,-6325,9947,-3375,9979,8589,-1195,-1240,-9559,-4828,-715,5804,-8144,-4005,-5890,983,7790,4526,3782,-6890,7468,-7426,-9641,1994,8913,3046,4761,3418,1198,-535,-6880,236,-3433,-4422,-8975,7851,6355,1308,-763,-1307,589,43,4618,3936,4667,7490,2635,1731,1883,-6,-4454,-5040,297,-7610,380,4635,-7692,-6260,3364,4536,8209,8112,-1124,291,-3426,-6059,3326,7451,-8608,-6559,-1389,-5305,5822,9487,-142,9664,-3131,7612,485,-3490,2623,3279,-5395,-739,-9171,264,4764,2204,3839,-9063,-3135,-8760,-1028,6753,-8427,-2861,1781,-1845,4549,-4085,-1717,-2643,-2964,-828,915,2696,-2991,3738,7158,5880,1529,10000,1016,-1462,-9958,5486,-7186,7545,2150,-9596,-3193,3394,-7889,-829,8034,3461,-2044,-8688,991,-9271,-2786,7244,-792,7249,5198,-2179,5279,8298,7750,-3378,5526,-2629,-1229,-3896,9742,-8593,-1704,-4991,3342,934,943,3878,5547,4993,885,-1148,9747,2356,5460,-4457,9513,2808,8946,-2161,-197,-3646,8814,6744,831,-6252,5334,-9718,4997,9706,-3825,1281,-8803,1312,-4197,-4455,-8294,-7026,-1721,-5839,5823,4389,8278,9162,-9351,-7260,-4709,-649,7809,7163,-4000,2494,7540,-2887,6434,4418,2271,9433,-3747,-9497,-9359,-4956,-1911,-1191,-1178,9164,-8233,-6380,9727,-1668,1469,-8886,-3929,2875,5895,5290,-9361,6678,-4960,2420,-7337,586,-7042,6939,3833,606,7951,5514,-5949,3710,-1411,1750,6418,8618,4870,-9199,1335,-3657,-9452,-3780,4946,-1030,8230,-6414,-2507,-3798,8891,4246,4865,-2261,3512,5587,8698,1794,7427,-9477,-4760,4686,6102,-6254,8289,2523,8328,-8824,5223,-4892,350,9480,495,-1042,9950,6914,-2292,8106,-428,8683,3784,-9116,-1278,-8558,-1581,-4262,1931,-9162,-5639,8592,4104,5383,-8259,-9831,74,8866,-7317,-3730,6441,-3513,-4948,-842,-4539,-8013,4108,9459,5153,9799,-2219,-6834,-4005,299,2103,4593,5382,-7495,-9086,1551,-6386,-2117,-2923,9545,7738,-6680,7032,-1558,-3799,3302,-7095,2276,9978,9828,-8389,3416,2276,-6785,4374,947,-785,-1680,9962,8221,9346,6050,-741,5097,9347,-125,6684,-7540,-9104,9005,5501,-8380,-2912,7272,1318,2094,-8573,-856,6980,9476,9966,-8885,5576,3235,3071,-302,-8222,-5872,-9622,8136,-466,-5909,-6944,-21,-8653,-8824,-3448,-9442,-679,-3473,-2378,4873,-6752,-7224,-8658,-2888,7204,5272,3424,5304,8174,4760,4731,-4513,-1684,3371,1019,-8359,-4227,-6192,-8180,6002,-1191,-3904,-3871,-2380,-7730,-6320,-9397,-4687,-1366,5593,-6467,7691,2848,-3951,1878,-2490,-3363,6712,-7849,-7930,9423,4786,-8021,-41,1581,-1811,9416,-1038,-1868,-650,6076,2926,-5948,-2508,-8929,-1774,9422,2090,4011,9551,2773,-8719,2034,-6280,-9761,-9063,5919,2632,-7859,-2811,2265,-2307,-8729,-4965,9242,-6769,-5972,3431,7993,-2423,2119,6617,1708,-4317,-4870,-2802,3255,1107,1730,9578,-140,5030,-9679,-559,-5911,127,5852,-8102,6486,-5227,1361,-6106,7608,-8027,1216,6011,-3427,-4310,-992,-4670,-3057,-1287,-24,-2969,-540,-9077,307,-395,3204,-8014,7197,6914,-2405,-7865,-5101,-4843,-7781,2266,-6085,4642,609,-6473,-7645,32,3966,1150,4984,1156,8734,2515,-8466,-4094,-2284,4662,-9998,3994,-7763,-198,811,-8184,7461,-1869,-6571,9349,4462,493,-993,-5003,-3914,2441,2838,4490,-8887,5236,-3934,5878,-2187,5329,3713,-1015,-8218,-5755,7901,-711,5186,6573,-5257,-9806,2713,-2129,-9803,7119,223,-3832,6373,-1823,1699,-5415,8023,1313,3668,-9345,5418,-9650,9235,4195,5788,-8164,1469,-6129,1998,1360,6977,8563,-3994,8369,-7759,-4803,-5968,5041,-5587,6410,1001,-6451,2220,-4419,-8055,-5873,-3902,-4817,3740,-8076,7909,-3716,-2996,3161,1210,5263,1039,3457,-7697,-5842,-1406,-1716,3641,-7217,-584,6230,-1457,-7823,-4298,3476,9067,-6319,-6060,-8556,7198,7514,-3972,-7802,1911,-1558,-9987,-5983,4393,-4518,-739,7383,-8894,987,7352,-3005,-4209,9452,-6087,-2757,5077,-4450,8252,-6874,-1838,5951,129,93,-5267,-8602,1729,-9599,1309,5194,3786,-7188,7351,1861,3401,8131,-4318,4274,-8283,9878,-2212,-2453,-9233,-6796,-296,4582,4366,2545,2816,881,6371,8093,-2933,-9635,3650,-8586,-7055,3367,9100,2951,-4908,-8368,-2972,7264,2825,-5101,-6511,4278,8010,-3212,6756,-6370,-6093,8655,-7455,7515,5295,5223,-4857,-3196,8913,5143,1227,8048,5709,-4940,7438,-571,8984,-1346,-1759,-5503,-7280,9204,-112,6897,-7469,3374,-4161,1500,5262,4765,-6156,2436,-7476,7569,3801,-1199,-4828,-2812,2082,9410,-5498,3300,-62,-1197,-1820,-5512,-8870,4968,4031,-6601,-1585,9248,5253,-2920,6832,-8981,4517,9120,3632,2005,-9104,-2319,-286,6982,7550,7796,-4795,2140,-4109,-3501,-1815,4413,8388,1812,-663,-4768,2876,1037,9845,5123,-2674,7355,-4167,5924,4067,4774,5825,-4286,-9879,1961,6489,7937,1664,-5727,-3203,5982,8882,-3984,2137,-4988,1302,5051,7810,-8276,-8656,-4104,1579,-283,-910,7327,-1449,5463,-9028,-8405,-7990,-3278,2003,-1523,-2147,-675,9011,-2373,1562,-4595,-8939,8744,-4337,-4474,3644,-5157,-9553,-9481,6728,1146,-6494,-9412,-1433,8815,-9049,-6209,-3492,2612,-800,4808,7334,-6387,8482,-5775,-196,-9586,-3772,6377,5856,-347,9391,-3633,-4350,1547,3783,-3853,-8622,4406,5662,-5314,8444,227,7112,803,-4454,-4919,-4688,5964,5586,-9362,5036,2146,6445,-6172,-6901,-6576,9454,2345,8053,6176,2151,-5942,6898,-9292,-1949,-3004,-5349,-4176,-2544,1294,-4146,9556,7915,3826,-2878,2567,3923,2583,318,-8930,-474,7694,-8821,7114,2786,8369,-9798,-5097,-3352,-3301,3079,-7679,-1362,2252,-2681,-589,9941,2990,-9654,-6952,-4991,-2755,8606,7330,-6078,-744,8717,2066,6313,3253,-5310,3200,8384,2514,-56,6205,-8932,1780,2576,8126,-4644,-3814,4561,757,-5930,1823,-2836,-6695,-8331,3439,3084,9232,4719,709,-7826,4157,4811,5126,6447,-5581,2429,3488,-8987,9819,6976,-7787,5579,-2532,-7048,-3160,-499,2773,-6081,2630,-6110,2126,-6126,1620,-5344,9633,-3761,1792,-8590,-4367,-2559,9486,-2267,-5873,1846,-4920,-9099,-8760,-8934,7380,-3739,-4592,3243,2042,9521,-7074,1873,-5649,5019,-6850,9954,-6229,7800,6803,2921,4134,8611,6236,-322,-7478,2922,-6868,8253,3127,199,-9758,6052,-9608,-4682,-9114,-1248,-4366,8374,-2243,-7584,-4043,-9439,-8130,-728,-9859,1820,6713,9104,-8082,-9790,-5017,7923,-4434,-1681,7894,6272,5599,-919,-759,7448,3234,7355,3961,-7549,4587,-6770,-9948,8669,-7559,-7272,-6822,3581,-3233,5964,-1449,-2278,8989,1785,8049,-1368,-8021,-223,-5222,2006,-9993,-8458,1135,5703,8182,-8605,-7076,-7439,-3424,-9123,-4189,9904,7029,806,2113,4898,-4864,2930,8792,-3281,-4974,6982,1162,4941,-2163,5342,-2892,-719,-7321,-8720,7104,-5775,9327,-9091,2278,2471,-275,-1543,7966,893,-7258,7658,-3948,-3385,6261,-8375,-2868,-8915,-3504,-2327,4825,1258,-4785,-1222,833,7234,908,6522,8519,-8240,8691,3332,4519,5889,-1062,-9930,-8575,6355,3954,8421,-2768,9427,-5890,2496,6945,-7384,-1900,-6529,-9735,2908,-5291,4848,5520,-8577,7543,-8113,4627,4141,8914,-4332,8435,2017,-7745,9677,4348,7373,-2949,-6976,2425,-3846,8420,-1322,-3505,-72,-5350,-954,-1549,8309,7856,-1245,-5217,6528,-1010,-2670,7072,9542,5876,-4886,-2421,3972,-5043,4320,-2863,8225,6152,-6125,-4239,3121,2021,-5684,5476,-4866,-9497,-7297,-7035,8751,-8570,-3015,8090,3350,-1579,4667,-5627,-3108,-3473,-3724,2261,1369,-6200,5567,-9632,-4071,1556,2749,-8136,-1733,4291,-1898,5403,-1338,414,8156,2691,-2581,3792,7811,-6748,-2324,7189,8752,-5350,1548,3118,-5224,-8642,-5465,-1861,-1008,6975,9637,1831,-6652,-2239,6398,3606,8893,-3031,-321,4914,9938,1751,-4032,7515,2333,5332,-1909,-6080,5710,5843,7510,-6909,2649,8021,-2711,-3220,917,7132,3162,-1549,-9277,8405,9825,-2540,898,4277,-6979,-1331,-1646,3467,-2134,4300,-280,2537,2961,9061,-7579,3516,-733,2186,-3932,-9159,8676,1004,-8159,4743,7431,6099,-339,2854,-1650,9233,8213,233,9069,6615,-1708,4455,8571,-6966,-5133,-4202,-1512,-9032,-6062,-8895,-5160,8653,-3502,-7723,9074,591,5050,4362,-5143,7006,-5354,-6932,-4784,8313,-8000,-4846,3912,7392,9886,2247,-5715,-4194,4294,-8997,-5143,-9785,8641,-5178,-6032,-3111,8424,8082,1755,-836,-5910,-2370,2456,2440,6507,-9269,-9502,6457,4561,-4099,-1036,179,9604,6602,-822,1080,-3319,-155,1675,-2990,-827,-5977,6795,6736,-5799,-6625,7926,8738,-3526,2036,1563,-1155,-6574,-1796,5408,1811,-6446,-1173,-4071,-2020,-5945,9406,7274,8523,-9487,-5673,-6004,7266,8924,7110,-1272,5491,-621,-9239,8772,-7842,1573,2445,5529,-4613,9006,3991,1950,-5437,928,5967,119,3000,-9072,-5656,-2472,-8596,-525,975,2979,-3058,1905,7360,-7935,285,9245,-887,6551,241,5177,2714,-6413,-6430,7595,-3284,-2422,-6889,7270,-4555,116,7230,9366,9506,-7132,-8791,-9922,-3641,8399,3116,-9224,7845,-2051,7563,-2142,23,8916,-1227,9401,-6059,5192,1632,-2949,6129,1521,-8601,3689,5195,1066,3993,-6524,5786,8599,-1303,3670,6454,975,-4036,-2238,-5464,5446,-9425,8748,6807,-1494,7161,8851,5556,2947,-1178,3695,-5933,-3732,-7902,-888,4634,8781,9899,-9792,909,-4758,1773,-1851,-1616,7201,2426,-390,-7575,-9842,5237,833,-2621,-2034,9346,-9674,-103,7913,-7080,5121,-5704,238,-6727,-3537,3388,4418,-2846,-6980,3460,-6159,641,7850,-1036,2884,8494,-2440,-9345,5357,-1715,7865,5234,-8265,-1588,-7994,-6470,-1879,8843,1210,-5338,7616,3953,-589,-5047,2034,7562,3268,-3893,-5361,-719,238,-9908,-8269,-1627,2237,4830,1236,-7786,-1995,7422,-2825,7668,4694,-3074,-8475,-1164,-1052,4086,7669,5745,7568,1627,-4728,9443,-96,-6330,-6564,-1534,871,-1374,2090,-2775,3818,-7011,-6009,-1057,-9856,9147,4825,8494,-878,2603,4645,4234,-8429,3509,-2860,1453,-7340,-8216,5621,5162,-5119,-3466,-6747,2013,6484,9456,-5725,-8849,-1381,9151,-7555,-3070,3924,-9613,-7463,1579,3222,-4804,165,-2351,-7286,1609,-7318,-2403,7872,9250,6880,-9416,1378,-4594,-8709,7327,-6824,-8901,2065,-5341,-9344,346,1952,6901,-5166,-7922,1034,-1448,-4127,-7101,-3346,-6054,9617,-4564,-4506,-3891,1195,1193,3294,-5353,-2582,3387,-9129,-850,-1970,-7963,7927,-1051,-4907,-2438,2864,-8432,-2045,-1716,-7895,-2062,7233,-4244,6298,-9761,2370,6788,-2541,3091,8522,-8436,-701,8534,-2978,-1250,6493,9376,285,2575,3219,3406,7929,3477,-7829,-734,-3813,-2621,4105,-5866,6549,5642,-2590,-2778,-2123,-7955,-4926,8882,2745,-5842,-8557,8413,8587,-3957,3042,-8980,678,5330,-4166,2001,2231,3558,6434,-6167,6298,3077,-7273,-4963,6795,4278,4480,1385,3790,5905,4837,-8345,-1338,-4037,1409,3650,1644,9174,-7062,-8739,2537,-1832,-3693,-7642,-9465,602,-8777,8275,-3856,5549,-2010,9268,5620,-7659,-6631,-367,9013,2769,-4565,-4131,5284,6154,-8129,1441,-124,9089,3272,4100,4053,7982,2760,5604,-6287,-8156,2274,-9161,4483,1211,-5357,7356,689,2366,-5597,3940,-796,-971,-3891,3026,6902,-4051,4708,6198,-602,6112,-4820,-1330,-1953,-2302,3437,7107,-9087,8733,-728,3922,717,8193,-6229,-8426,-7302,-4828,3746,6536,-7319,767,-7559,-9053,7191,-429,-7424,3883,-9603,9400,4616,-5546,-3491,-5984,133,4981,2988,3586,-8246,2090,-5771,-1933,-6371,9656,-1526,-791,8397,5234,-6177,-1518,-7359,237,4649,4269,960,-3686,2604,-676,4961,-5989,6356,7295,-4753,-5738,-8019,3217,2700,5046,-3089,9362,5271,913,-7661,7900,-4877,-9844,9084,4635,-4348,3852,-1666,-3417,5592,-8677,-6740,-3078,6352,-3985,-8828,2293,4938,-5757,3974,-1514,-5369,-660,-1763,5039,-9249,656,6190,-3759,-5628,171,-9004,-6457,732,-8640,-9582,9366,-9244,-7565,3789,-6059,5407,956,-1254,8239,-6324,-3635,7787,-5685,-1144,-3611,-2065,-6857,3014,-921,-6220,-5204,-6833,1298,-1960,-1842,1361,-6738,6429,789,-344,2043,-7784,6886,2361,6919,-4658,-4640,3989,-2195,-4719,-3290,2768,9421,3627,7784,3144,8087,-9248,-7928,-3084,-6979,-4999,7322,-1378,6454,9533,1765,-450,5553,3610,3898,-1220,1483,1477,-3995,4190,-9393,-8257,-9233,-5798,-2395,1329,-4060,8756,-2019,2821,-1632,7631,1036,3508,7793,-1418,-8148,-271,4031,15,9354,6322,-234,-3588,-8337,-1943,5474,-469,4219,-3343,-958,7922,-8247,1723,5006,6246,-2872,2312,3946,6968,7848,-4590,93,473,-6358,8093,-6701,320,5669,7304,5804,6194,2153,-3956,-5345,4522,-6197,-5173,-9098,-2599,-2308,-7338,4502,-2788,-4604,-7186,-8792,5789,8857,-6275,-5520,-5578,7917,-7625,-4444,-8405,82,-9808,8784,640,-2720,5079,3869,9670,6354,-7024,9538,8072,-3849,-1676,-6606,278,-4018,6956,-4041,-9809,-1783,-9974,6224,-6397,7395,-6454,-2526,-5559,-6677,5963,-4226,2315,-3842,-3126,-7735,1980,5964,1638,7636,6357,-279,-4992,-5550,6317,-8036,3319,5263,4101,-7818,-6598,4665,-7598,2219,-9538,6058,-4224,7678,-7015,-8902,1268,3034,-6463,1480,-9287,-3237,-4131,-7974,1125,-8979,-1995,7231,-7853,8329,-1172,-1615,3982,7572,6802,6624,-2403,7838,-9396,35,-753,-5919,-9078,6716,-6290,3159,130,-1790,3689,-7111,-9091,7213,8634,7967,-1505,8223,-8874,-5112,-2323,6954,8189,6324,5812,-1853,-7745,3269,2136,4247,1458,7029,-8766,9160,-5325,-8159,-9696,-9883,7737,-3458,-8491,-6056,-621,6492,-2670,-7775,4158,-2661,-7074,-1497,2040,-7816,6946,2693,-1874,-9613,-9628,9520,1700,6149,-4220,-6513,7926,-2414,2651,4831,-8408,-4158,7385,-6905,-5923,-6987,-891,820,6383,-6876,-2234,5538,7190,-1765,-8518,4669,2079,-4647,-7293,-9699,3337,-6275,-2784,-8765,7537,-1957,-4864,1973,9997,-669,9396,-5685,404,-3604,6880,-9650,-6754,-3005,-7303,-3335,-7012,2003,2000,-8780,5624,-7389,1176,4647,8451,-9587,7755,-985,4762,9888,-2766,4031,7538,-3437,2534,-1385,-5759,304,6956,-3336,7895,9169,-4312,-271,-7152,4497,-9968,8503,-5789,7649,-7878,3727,5580,-9977,-2005,-986,8406,5912,-5701,-2151,-1642,8870,-9982,-1333,-8754,8038,9395,1698,25,-5706,3549,4786,-4509,5897,-2419,6328,-4635,-8828,-2897,-2165,-9478,5948,6144,-9073,-6798,-3674,2286,9531,-6470,4040,4324,6217,3886,8732,2982,81,-6830,848,-1164,-2160,6642,9421,-1364,4459,4597,-8814,-1159,7137,4004,7665,6786,-8703,2405,-4210,-8801,-1936,-8475,-52,5046,7551,5055,8232,-9453,7916,4172,-6490,1603,3892,-555,3756,5648,-5590,4490,1550,4708,3513,8489,-1857,8674,-4433,9169,-3108,3123,2689,8170,6524,-458,-6997,-2248,-1941,-3245,-5448,7043,-1439,-8069,-9215,6826,6595,7965,7526,-3135,-6793,2394,-234,8676,-8,-3395,6132,-1941,2217,349,-5209,7085,-5814,-7810,3604,4967,5532,-5760,-9793,3837,5337,2766,9267,5628,8058,1390,-312,8071,-6046,496,8554,6025,-4147,3322,-225,-2122,-9892,901,-6603,-1572,8105,4054,-1830,962,6858,975,-9411,-9051,-7919,6356,-8365,-2070,-4627,-5930,5433,-9446,-2560,2742,2987,-7283,9984,-76,1172,9506,3708,-3247,-7314,-8427,-9835,-8658,-4010,-8028,1956,7038,8564,3753,-6395,-7243,-1036,745,-8643,-5369,-615,-5771,-1656,-6298,7827,9527,7479,4825,2669,-947,6707,-635,6389,-3915,-5144,6972,6498,3992,3162,-4848,-4921,2808,9425,-2976,1455,-5833,-2386,237,-1521,7446,-2185,5417,7738,1061,4014,-4690,5828,9187,-2500,-9695,7865,-7188,3225,7434,8869,3336,-36,-3370,4032,-3833,9345,2912,-4008,492,-8249,-3722,2017,7467,-9241,-6155,3489,-6354,1234,-8744,183,-3264,-2229,4993,247,6797,-4763,4013,2188,-4837,9432,-1745,20,-3324,-9673,-8218,3362,-265,7806,8563,8257,5960,8230,-9092,-7211,-4109,5221,-2329,-9088,7602,8759,369,-4551,-2745,-8476,685,-4743,-2417,-1938,-7818,8230,6977,-3749,7672,-9545,-6081,-5668,8064,-6004,-4625,-8992,7223,-3879,7671,9003,5227,2498,8522,5034,5849,6901,-2086,-6262,-6077,-8892,-6548,8579,-736,-6054,4204,-9389,-8438,3239,-8943,-1489,-1461,-6750,2163,-2291,-728,-7842,-1127,5838,-5837,-3191,-204,-8510,8353,8810,3801,4031,1918,-3461,7102,1387,-7838,-2508,-7309,1684,8856,3320,-1395,-4165,-4992,9022,8898,4735,-5924,1162,-703,-3105,8821,-6139,-1329,7469,-7398,585,4392,1924,2119,-4485,-2985,6168,4751,-2827,-5991,6019,7029,-910,-7204,-4163,708,1867,-8948,6682,-7459,9286,-5318,2156,8154,-5774,-1437,1356,5839,4205,-5838,3186,-7122,3181,-5117,-8087,60,5145,-2395,8636,1686,2968,5466,1937,-8659,6299,9189,-7444,-476,-4463,-4616,5962,7167,6461,-5050,-9989,9619,5085,-3658,-379,-4966,-4040,9050,-8911,-3937,-8491,8672,3044,-5638,328,-4385,1483,-3080,8295,6233,8414,4865,-4490,-92,2963,-4468,6771,4358,9818,-1892,-7319,6367,5252,2797,3255,3317,-7390,8620,-4726,-5831,-5485,-4185,-5832,9457,5115,9192,2427,8896,2138,-8208,-7191,-8450,-3266,-2525,8408,-3642,3467,-4728,140,-6655,3179,5022,2511,-2406,4835,-404,-5443,9071,-4532,-7501,6158,-9948,306,-6440,-5531,-6029,-8360,3676,-8583,7332,-3506,7078,-8757,-9665,-3469,-7650,255,5074,497,-5675,2315,-9864,2446,-835,-7220,4682,2448,-9013,4301,-2503,4673,1193,6366,-3886,-8680,-8312,-3326,-7939,9871,182,-3857,6993,5867,-9053,-4327,9488,-8811,2937,2396,8303,-3199,-5982,4677,-3285,-2859,-9285,9994,6748,3250,1526,-9128,5309,2559,-2193,8982,-8962,-7677,-4841,-5420,-2729,-5446,-5609,3996,6456,3924,-9262,-5332,1466,9923,5831,1320,622,4439,-9019,8458,-6032,628,-9250,-847,-4214,7428,2133,7270,3852,4339,-9500,-1893,-2618,-6911,4856,-6145,-3751,3505,-1110,9388,-8729,-2135,-148,5664,1407,-9772,1177,-5711,2288,9094,-1509,5105,6490,-5399,7555,-8216,-6656,-2235,-4995,4242,4407,-1300,-9918,4754,6620,-4011,-7448,4268,2229,6535,1462,-3870,3458,-7659,-3793,9334,-7560,-3848,7731,4885,8358,-8712,-5236,-4789,-2178,-8346,-5140,5053,-6368,-9674,-5729,633,-4152,4210,-2141,5328,-282,1023,-4746,-4726,-270,4632,861,-3546,-5003,-8909,1707,-9562,8335,-8342,5700,2002,4801,-8783,-563,-1945,-1951,-8562,-4618,2878,9459,-7487,-6109,2396,-475,-3493,-3154,2559,-3084,3630,-3177,6803,3781,-7452,8070,9124,4686,265,-1175,-9765,-2986,9305,7678,6818,1135,-8917,-2867,556,9117,8191,-471,-5909,9994,-3847,2377,9843,-9089,-1067,-7673,-5654,-450,-7983,-2375,-6953,-3566,4586,-8012,-7485,202,5750,-5870,-8802,-6722,-2651,-4665,7627,-8010,355,8467,-8793,-7427,3128,-947,-3832,-9086,-9989,5080,-277,3140,4016,4281,-290,-6650,-9281,8135,-3883,-546,2546,-9273,-4394,4779,1484,4909,6338,-1254,-8181,-9316,755,6050,-1162,5149,6799,-1415,4109,-5873,2517,-2474,-8760,-1873,-2459,-9898,-7827,9255,-9615,-6467,-4012,4668,-1463,1099,2926,7885,-8933,1478,4119,-5044,8804,-4309,2720,-1280,1358,-4081,4712,5780,-573,6071,935,-9637,7969,-5062,-3462,-7789,-6398,5768,-4259,6730,-5545,2393,7162,-4806,-8507,1930,4499,-3908,9730,9737,3063,5142,-8552,-9895,-7924,3648,3441,-4688,-8639,-3337,9842,-6038,-8295,-438,-4684,-5780,6422,-8602,-5687,-5046,5219,1655,1529,1607,-5866,-2563,4978,4055,-7628,-644,1979,9090,7424,8608,4795,2065,9814,-9358,-3999,5243,-855,-3215,-2573,5174,-4500,6977,6296,-4949,-7740,-7701,-7532,8900,-4890,-9269,-641,-9485,2186,8714,-1454,-2233,-2191,3359,-2247,-7480,7833,-2821,-2569,6021,2053,7030,-4008,5304,6855,7226,965,-8865,-2842,1840,-1565,4694,2161,1814,3450,9457,57,-8664,3952,-4461,-6529,-2488,-2441,5436,-8873,6291,-6438,-7052,-4101,-8336,9295,6695,2499,-1314,-3741,-1450,9106,-2559,9126,4522,9386,-8168,-6114,4122,1830,696,-7942,-2875,2361,2980,7964,6772,-1228,6257,-4592,5994,2779,883,-299,2074,6946,20,-2744,-4376,-4977,-7836,-4604,-8172,9344,-8207,-9410,-2361,8982,-503,-918,-5415,-7198,-6132,1700,-9773,5082,-3387,-7064,1034,-8955,-8143,-577,5702,5474,-9932,9181,1247,-3841,-4512,323,-5932,6415,5558,3165,-2007,-1622,6259,4985,-4602,9232,-8707,5980,7559,9608,-743,-4606,9972,7994,9924,9256,7876,-1116,-2392,-4638,2306,-528,-5247,-5793,-8315,9060,-1953,-3105,-4737,-6943,1558,-8267,-2091,-3157,5273,-2402,5556,-1033,-328,4876,-6345,7020,5326,-6518,3282,-834,5431,3350,4513,-3207,6259,-5065,572,-2169,-9098,9,5353,-2278,6758,847,9999,6618,6362,-1761,5177,-8969,-4304,1101,9428,-1597,1469,-6347,6373,6679,-7064,1200,-1349,-299,-437,1074,-6423,-312,477,-9931,2614,-613,9727,3456,7350,9660,9199,-7009,-4141,9249,1836,6221,8808,6991,1570,-1281,7795,-6934,-1081,4410,8496,-1173,-6939,-2815,9380,-2837,-5087,-2631,8663,5759,1209,8929,2248,6257,8592,854,-4940,-832,-1397,-6502,3601,1610,7089,4074,3501,-7741,-3046,1335,-4573,2848,-2658,-5753,4438,-924,2099,6848,-6765,-3034,1402,7484,-317,-7676,-9565,2550,2647,-9527,-4670,3736,-1745,-6779,5845,-7770,200,6179,-9415,-2731,-3988,-3667,-3756,-8478,1646,4782,8476,5834,8128,-2994,4216,6116,-5885,-5044,712,-7978,-6671,-2218,1541,5985,-3751,-1356,7924,8020,8428,-3828,-813,-6965,-7363,9750,2362,244,-7863,5568,-1187,-1673,-5869,-5955,-7119,4881,4461,-8853,-1366,9557,-3112,-3142,1992,-7350,6135,-5539,866,3343,2515,1792,9168,-5453,6255,-5500,2422,6287,-5466,4240,-4534,5077,-771,1192,-4113,-9830,1523,-9174,8948,1718,-5127,-5418,2887,5684,7370,-1067,9614,84,-7835,7223,3360,7618,6827,1861,5259,2047,1520,-6943,5470,6397,-9321,9930,4357,2152,-5578,-4874,-7086,6049,6928,7734,-4753,-7865,-8377,2481,7866,-5006,6388,605,3973,-6980,7356,1600,-9797,-5865,-7555,-4369,7584,-7540,3845,1321,6806,8269,-2096,-5345,-2156,6842,-7006,-7969,9812,-4848,-1306,-1697,4063,-3153,-7841,-6021,-5064,5462,1887,-5244,-8918,2258,-708,-2020,4335,-1254,-1214,3962,-5025,-376,9057,4008,3956,-3863,9807,-4294,-3422,-3198,6677,-1487,-3071,-6573,-9543,-9367,-8742,6542,8211,-7364,1624,3368,1177,2100,-9211,4748,2584,1454,-8090,8948,763,2376,-8972,9608,9326,6999,7432,4519,732,-9213,9912,5999,1114,-8693,4621,9447,6262,-684,-9746,-7588,-3083,-2425,8294,4674,617,4959,-8195,1088,-5515,-2381,7241,3270,-8316,992,-9367,-9103,-8393,6049,-8313,8318,-8834,-2311,430,-3157,4459,5709,-7364,132,-7668,3577,5843,-267,8008,-3585,7114,4232,-3683,8714,1687,-1228,7201,-8369,7918,3546,8250,-2412,-5756,2072,1927,4209,-9643,-257,-991,6369,3897,9865,4274,-9000,1180,2807,9313,2482,5838,-6333,3450,9355,8520,2894,5218,157,-6780,-7133,669,-6485,-4140,2721,-4161,5491,3746,-1866,-7500,-5291,-8149,-2706,1979,-4851,-1333,-4156,6664,-263,47,-9113,-2197,4683,6472,5560,6206,2207,5514,-27,-3013,7904,-3765,6254,-9244,7308,-1005,-4896,6753,-7805,9782,-7200,794,-6272,-7605,-491,699,-8425,5071,-3222,-6286,-4126,-3220,2790,5601,-2938,-9660,-6723,8807,361,-1874,-3772,-8802,-421,-6630,-6782,-6247,1872,8240,-367,6915,918,-1951,-8913,7352,-6906,3975,-2048,6237,-505,1784,-9578,1063,9428,-4746,5218,-4475,-5990,-956,-4203,-3633,6740,7010,7878,-7451,-2957,-4530,-2113,8643,-6169,-1945,1737,5256,-1365,2279,3039,2374,-1813,-8990,-8284,6849,8203,5633,-2656,-2388,-9724,-6256,4710,-8338,-1893,5311,-5287,-3238,-2730,5868,-5856,19,1935,8396,3350,9966,-7570,8100,-5295,-4578,7070,8756,-6083,438,-4351,-4844,9396,-6255,-3244,784,8949,8943,1216,-9992,-8589,-246,3343,9997,-1053,694,-3737,-2491,-162,-3501,9198,6683,-7797,5637,7575,-8826,-9452,601,-1722,-4952,8367,7094,-1266,-9488,-900,-4277,-8992,7760,6396,207,-9844,-7608,-7304,-9508,2936,-373,-6003,9352,-4426,5003,3711,-2646,5835,-7152,5528,-1772,-746,-1095,-1542,-6134,-494,1356,-2092,-9855,-7843,-3275,8541,728,-2295,-9285,7901,-4904,-7961,-2101,6658,7018,-4243,9536,8893,9940,-6085,-364,5621,-3832,901,-2592,-4593,8454,-1903,-4230,1157,3787,-1167,-8268,533,-2399,3781,6706,5016,9970,5832,3529,5357,-6110,4909,-8553,-6812,9074,-968,-5316,-588,-2286,8286,-8594,9471,8454,4237,-4016,3656,3658,-6221,5760,-8395,588,2166,-876,-3533,-9989,-1473,5514,43,-4092,9162,-245,951,4776,-4331,6633,8061,7422,-9966,-5383,5416,-5061,3387,17,3759,-6091,-1728,5820,-2876,-2165,-3203,-2417,-6843,-9891,3205,-3978,-4223,-8398,5726,6747,6873,7829,-3197,-7049,9408,6748,-8085,337,-78,-8122,6846,-7477,-2395,3602,-6511,-6114,-3627,1237,-8771,-5424,-8364,-7415,6593,4294,2763,-7988,3246,8107,-3766,-1684,-603,-2332,-9971,6423,-2848,2141,-4623,5607,1197,7448,7237,-7458,2822,7183,-4283,2013,-7482,353,-1693,5704,-4998,-4383,7773,-7414,-5888,2417,9786,-8508,6,6624,-8615,6152,-1880,-4980,758,-1063,1418,7237,2507,-7521,3461,2313,1105,-9118,5599,-8042,-8383,-1444,-717,2444,-599,-4030,8702,-2355,-2484,7364,-4101,-5485,-5236,4734,6101,8274,-2600,1152,-1123,5221,8392,-910,199,8107,-8597,-7710,5223,2,-8403,5014,-8178,-850,2467,5140,-9385,9385,5040,-3171,8454,-465,2992,-4296,2212,3629,4402,-64,2350,-9857,3514,-2469,-4390,7732,4276,6231,-5230,-4550,-8870,738,-549,-1010,7605,-7490,6560,-2742,-4422,-6582,-5242,-2492,-6950,395,5910,-5604,-3421,6842,7346,4526,-92,5734,-4253,8992,-581,-6041,2762,-7255,6557,-3505,-3087,5235,-8831,-6888,8458,6398,-9666,-1674,8663,-4193,7367,2452,-392,-5830,-8384,8213,-5279,-8739,1009,-7112,-6794,-5438,-8936,-66,7432,-7931,1615,416,-5623,-4743,6170,-4359,9131,8455,-7970,-1676,-3971,9180,8649,764,9185,3682,-702,-5373,-9285,-4040,901,9044,-1582,4437,4774,-2503,5748,141,2881,-9620,-2044,1085,3733,936,9483,7896,-2117,-7793,-5546,2872,-9508,3713,7500,-1292,-2676,1256,2375,-7199,-8751,-4865,2027,7451,-4977,-4604,2544,39,8862,3629,-6048,6770,-3015,-2734,951,7427,-4118,5671,2685,6369,8163,1494,-8098,-9162,3277,-701,-8547,8340,-1063,-9182,-2383,9790,313,-4727,-7410,-7128,-9622,-1339,4035,382,-322,-1250,3526,7220,3025,-7791,5593,-270,-441,-3714,-7320,-9900,-6360,5686,5820,7557,1331,-7126,-3221,4488,4533,4795,-1357,8255,9759,-3331,-7440,5984,2522,-7073,809,4458,9879,4217,1192,2807,-1312,-939,-7995,6383,9284,7557,-8640,-9315,-539,-5945,9919,4036,7587,1316,-1303,5598,3997,3931,-3111,-4712,1154,-8562,1967,-598,-1060,-4704,9876,-1230,-2411,3400,5425,8881,5402,-5662,443,372,-766,5137,-8596,1957,9940,243,-9445,-7822,-2841,5180,-7258,-9045,-3620,-5749,5691,-9084,-3355,-395,-2053,3634,729,-9995,87,-9860,-7528,-6223,7759,-8978,5811,4689,-9487,-892,6846,-1053,-4411,1279,7523,-9930,-7024,-5860,-4669,1400,7355,-5834,6027,7378,1802,-2197,7981,14,2819,-9143,-4934,-5212,-7623,1593,-7876,-3030,-9765,9041,5427,1939,-7243,-3046,-979,4324,8484,-5233,8850,-962,8811,-3756,9712,2487,7897,-8995,-3765,-9605,-5052,1155,7857,5858,-2171,-132,5491,7147,-96,5874,-2848,-6086,8108,4721,-2629,6864,-8690,-6470,-5805,-6393,-4653,2951,-1040,6239,-1791,-7170,-4278,-361,-4796,6843,-8550,3918,340,-372,8138,-7062,-173,-1954,-5030,-7128,2807,5230,8407,-6911,7288,9400,-6524,1131,3618,-6351,-6278,4315,-9383,-7572,1322,-2659,-6200,4644,1941,9994,-1299,-6972,7107,8048,5442,-5514,6661,-6947,-997,2538,627,5432,2297,-6717,-6626,-2163,7393,8706,-2109,227,6575,9449,4736,-1579,4700,1018,-5753,8408,-1318,7521,4706,-8383,-1684,-5185,-5397,66,9902,-8672,-6110,2209,9662,6632,8062,106,-9331,7365,4273,-6260,2922,6924,-4001,822,-2827,-2936,-3416,4271,-5355,-3035,-8149,-6883,-7714,682,-3857,-7015,9781,9505,5560,-3158,721,-6991,3831,3048,9223,8961,1519,-2661,5477,-5159,-280,-5090,-7108,-2613,-771,-4557,9867,5515,341,4983,3889,1663,854,8580,5447,1925,-8754,7915,-487,7802,7029,182,6669,7421,3379,-4435,284,-363,1206,6858,-2498,-3711,-5249,-2007,7737,-6943,-6499,-603,4771,-5527,-7981,2853,-3467,2133,1685,8323,6415,3966,410,1441,-5317,693,-6280,2924,4710,-5007,-2840,-6373,-6831,-3750,8555,-7376,-457,8038,2575,66,6110,358,-4959,-3183,-5896,5596,3075,1984,-7583,-7396,-2604,9095,-3163,2660,-1574,-2291,-5218,-6362,3831,4576,-2870,6144,-7860,723,-1585,2732,-1673,-4378,-3162,996,-8698,3867,7043,-6670,482,8536,-4749,9271,5103,-5726,-2939,-6791,1814,5941,-8339,6385,-1509,7473,8285,-6875,-9690,8481,4661,6376,-1379,5327,-9126,-478,-3453,7393,5008,-9699,-4501,-133,-7383,7580,-5092,-8236,3770,-5872,7085,-5450,395,6260,-5455,-4893,6154,-6929,-9271,-4173,-8807,-9445,-4893,5558,5556,-6447,-3535,5782,804,5903,846,1057,-6653,6926,7639,-2554,4702,-306,3751,-5198,-780,1142,7032,-5187,-5624,-2514,5320,2046,5347,5954,8271,1020,3007,-2034,-1661,-3793,-3227,-7398,-4066,-392,5056,5832,615,-1930,2302,-4604,-6785,6727,2768,-4775,7838,1369,-5405,9307,7973,-2611,-2774,-8765,5512,9902,2667,-7569,-7883,9964,9397,-4392,-9070,-7689,-1417,-8952,-1962,5890,-2297,3020,7118,7706,-2366,-9333,5347,-3747,7875,-4954,-1444,-6804,8112,-4899,6772,-1447,-8089,6164,3888,3178,-364,8237,-8138,9037,8071,5423,9062,5506,2508,9793,7151,8032,-121,2499,-6086,-6945,9536,7855,8546,5325,-5506,1424,-7027,1973,7812,-1743,-9957,-9380,8093,5935,-803,-1349,-538,9520,6804,7899,-788,-8780,-8588,2753,-9469,-4678,-4541,2109,4528,-9328,2442,261,-8566,-1658,8048,7327,1927,-2240,-194,-4743,3851,8258,-6910,7767,-7105,-9208,-7792,8441,7919,6142,-5360,9505,-519,3563,1388,-5618,8840,-9872,-652,2166,-3807,-4900,-7868,-7583,-2014,-4873,-4588,3977,2084,2328,2415,-1558,-5642,4102,6164,7027,-7493,-5715,-3599,5386,7551,-7232,6672,8235,-9265,-561,8057,1067,9112,7203,-1203,8512,-3904,4886,-5560,-7796,7720,3310,6311,-1266,-8620,2004,-2951,4811,-8140,-6889,-5504,7850,7210,5386,5939,-9987,-2182,-5599,-8002,6011,5973,-2711,-783,-1561,1697,9974,6234,-3537,4938,-604,9761,-2089,-3495,7023,8759,-4974,3903,5923,-3728,9277,3534,-7765,7490,-4242,-1630,-9457,499,1190,2354,-4095,-3157,-8278,-2615,7766,7001,-4885,9858,1689,-4016,-8896,6407,6737,1840,7557,7442,-4415,-9252,1234,-4942,8912,-9952,-7590,1282,-338,-1434,821,-6576,3418,996,4210,-9275,-2814,8760,-7114,-6715,-1092,-4330,-7691,-2510,-8667,-9847,7883,8487,-9268,418,5042,3054,-7748,-3475,6470,-7041,4381,-7632,4253,6363,-1113,-4808,4300,-908,-9746,3787,551,-1454,5925,6344,-4596,7028,-3195,6555,-2712,581,-2126,4183,-1319,4050,-2292,8915,-7277,8212,1661,9238,915,-9145,-6966,-9499,8466,7152,-6758,-5087,7980,1118,-9038,542,-8153,-7304,-1095,-5933,-2376,3758,55,-3487,5664,5890,-3652,6380,4547,-896,-2023,-9008,4816,-7674,-6637,4194,-929,-3569,-2512,-9766,-1049,-5454,6301,3025,-2819,-9168,-8253,-7615,8756,6049,-7736,-5671,4682,-1826,3030,-9137,478,-2300,-5854,4236,-8748,-8425,-3241,6002,1702,3673,-4690,793,6311,9412,-2411,-7712,4952,973,6133,-2433,1343,6412,-2947,-3030,9780,-8190,8276,-3604,-9970,-5096,301,9711,-745,-1513,-9310,6595,-4274,-643,8720,-3063,3355,-5394,9819,1159,8905,7133,9296,-1413,-4688,4216,-7625,-8424,4978,9671,3851,1706,1077,2263,-9998,4332,9980,4500,-5839,8886,1544,5016,-6366,-5511,-9273,-9877,7607,-974,6891,3847,7843,6896,8834,7334,-8037,-7032,-1491,-6661,-5523,5373,958,4257,4559,-3999,6937,-8457,-7965,-2818,-3515,411,4340,5928,-6883,1230,-3173,-2600,1504,-2229,1913,-1625,9773,-4138,-3435,2186,-8620,-323,-8819,-3105,-7789,-951,-8628,-9046,4831,-2496,3617,-4238,5678,7696,-6414,-3035,7344,-1783,-2767,-8349,7913,8168,-3475,3367,-4894,7494,-6746,-8235,-851,5265,-3922,-3554,8418,2252,7170,-5023,4942,-562,-7550,3006,6617,-7469,-945,-2703,8498,5132,8708,9879,3854,6924,-3595,-3748,-4737,-2564,6287,-665,-4590,-4719,-4106,2425,1285,-9789,-3068,-9578,-9573,9546,-2096,-3787,-8436,-3034,7224,-3059,8571,-9854,-5053,-2706,534,5218,-9078,-4806,5178,4270,3433,9941,-5909,-1303,-8865,-6215,1581,6834,6180,6408,-1912,-9867,2237,7153,9210,-8753,709,-2373,-7412,-1838,-338,1058,5748,1017,-684,-6483,-9326,-5574,3529,-8320,-2954,694,-7130,-2169,7051,-1877,9090,-5807,-1156,9245,5569,3200,2540,-8384,7303,-1732,-6305,-6297,4396,-7155,-3347,-3129,666,-447,-227,8399,-6629,9673,2793,1318,-165,1766,5647,-9151,-2252,9425,6398,-7675,-8616,2174,6200,2989,9529,3126,-6830,-2989,4685,-4579,-3135,-6246,-6163,-5220,9475,7266,-3332,787,-9021,-1568,4084,-2704,-4582,9083,9586,9721,7917,-5032,-1428,-2146,747,-5890,-923,-7993,-3663,-6155,-4212,-7122,-2798,-7565,-7544,-2064,2738,-5550,-9807,1010,-3265,-4417,4298,3577,5124,8629,-5314,-1858,-640,-5470,4802,-4199,5201,-5418,-2572,6085,-7721,4488,9391,-5952,5023,-8191,-5553,7102,8800,3399,2175,1736,-2524,-4794,4974,-8270,1716,4740,-5804,-9202,2470,-6375,4796,-2023,-2495,1711,986,5961,-8570,5930,-4470,1199,-3946,9069,401,9509,-2439,-9991,9946,-2310,1780,7480,1435,2216,-3457,-1443,-7430,-1115,189,5438,-2137,-6955,-3229,-8868,4380,-6405,-5209,7446,-3622,1728,1308,-4571,-4866,8785,-601,-5569,4925,9570,907,-3798,6532,-6306,-2421,-4019,356,7583,-4327,-9186,-7448,5021,-1988,-362,8504,2193,-1344,-7393,721,-9713,-3736,4288,-7718,-8270,1378,4682,-8480,4564,7446,-4331,-9222,-5360,8922,-4319,9828,-4504,4957,-3745,8456,-593,-4602,-7905,-5003,-2098,6474,8642,2616,-4907,1219,-1919,-4639,-606,9775,-915,-7801,-9617,-2132,2267,-7078,7569,-1276,-6062,4997,5420,-3913,8757,9270,3235,-1991,8402,5246,1800,3892,2388,8461,2698,7071,8310,-1921,5777,5499,-4570,-1466,3797,-1297,-7860,5051,2933,-5314,-4185,-8627,-6399,-3216,-9349,4777,-7351,5962,-821,-8851,6933,-3708,-3581,-9894,8820,5199,9497,-5346,-2741,-3777,-9663,5676,-7484,-1894,2246,1722,3494,9846,-1665,8285,1628,5826,8285,8616,8961,-3041,9854,9720,6814,7980,-611,-4383,-3154,6807,-8110,7864,4770,-1644,3896,-4483,-2579,-1102,-6854,-2684,-9026,-3917,-9938,-5026,4818,-3498,4598,-5895,5680,-3663,1117,-6395,8395,7539,-8796,-8876,-1702,-7652,-149,-7784,8811,-2859,4543,-7867,-4211,-6097,6923,-3452,9201,2008,-6304,6825,8563,-9064,3010,2672,7465,7739,-3865,-7478,-8335,-7921,-2414,2073,7213,-8896,-8188,-6560,357,-6268,-8447,5266,2687,6037,8270,9778,-5891,-1442,6136,2954,-611,-1726,4743,3477,-5883,4558,6144,7547,-3500,-9498,5118,-7118,8816,-2603,6923,5116,-7896,-9753,3470,6012,1425,1933,8083,5641,-4039,3873,6213,4830,-3732,-1539,8324,-442,-9842,2502,-7317,9788,-3426,-4105,8231,2953,-1785,5948,-6860,-8802,-9648,-5192,-1708,-4269,6028,2808,-5834,8541,9817,-4852,-2432,-1953,6960,-569,-1750,-4332,2450,-4499,7108,305,-8357,9188,-682,-2501,-2288,5,-8271,-39,-416,-7657,-8360,-1321,-9101,4518,3454,2493,6842,-7836,-8379,1406,-1769,-1619,4313,6510,4867,834,-9648,1923,7734,9155,-1983,-57,8186,8329,-3958,-6260,-5124,-7400,4371,-5834,5198,-5438,-3704,2268,1072,7267,-7970,5922,-7364,-4850,2304,4499,-4090,-9041,-3039,-5797,6168,1965,-8252,7080,-6362,-1691,-7661,-4385,8608,-1374,-1808,-4652,5126,2925,2277,-7098,-8656,3887,1488,6181,-4629,8341,-9474,6095,-8039,8737,1193,-9148,1097,3988,-2408,8951,2458,-5620,4737,-157,-1812,7229,-7795,-348,9495,-2292,4399,6746,-4674,2425,-577,-7647,-4167,-4529,6539,-6432,3486,-1518,-3108,-5115,-3937,-8524,-4417,6833,6549,-5787,1322,-8690,3909,-2012,-1568,7260,-2303,7482,-581,6724,523,2205,-7693,952,-3841,-5540,4020,-7543,2689,-2038,-3826,-5300,2766,-4948,-1258,7366,392,6737,-5067,-559,235,-1774,-703,-7338,-1068,7350,2360,-5030,8816,-6985,-2737,-179,-3161,6988,7571,-3012,-7316,4990,-8196,-6834,-6367,-8035,-2074,-4060,-8122,-1052,4065,215,683,8806,994,7798,-849,-574,-4610,-3938,6801,-5741,-8441,-9884,7988,9995,-602,2756,4856,-550,2877,7493,-7753,-2962,8676,6444,-4740,2154,4900,-1352,-1836,7045,-5039,2120,5291,-4748,8591,3800,4115,2285,-8528,-9491,8066,4392,5024,5767,1849,3900,-3868,-7415,1858,924,-7089,9625,-8105,-3123,1541,443,5571,6681,-8190,-8312,-8868,-8406,5475,-757,4013,2784,-6078,-3352,6780,-7368,5849,-6847,5494,7041,-1459,-7184,-9745,9255,-8741,5937,7668,-8081,-7291,-5755,4009,-2355,-6698,-8502,6331,7793,4826,-5734,-2398,1595,-7684,-8841,5175,6251,-7311,2806,5955,6278,-5942,1869,-9850,9956,-7209,3052,-8413,-9127,-3061,-9359,-3661,5308,-527,8891,9522,-2186,-4173,-7356,8312,41,6238,7956,5611,-3398,7966,4177,-9287,1313,-7175,-264,-2127,1061,6148,-5392,1689,3077,-3042,-887,2499,-7615,-5741,3112,-426,-1963,9033,2156,2120,-1688,1693,8924,2180,8811,691,1677,7447,7951,254,9099,-5635,8544,-7571,-4253,2513,-7840,590,7933,-4770,718,-5749,9433,-3474,7199,-4169,6058,6709,-7498,9196,-8079,7981,-4147,3468,1086,-2673,-5426,-2031,2122,-3880,5793,7389,276,-2656,-2541,3268,9269,-5205,8821,-5701,9507,3866,7329,-104,8007,6711,-1872,-4369,3300,-9923,-3131,-5642,-2141,-6059,4766,2714,1202,-2023,-3026,-8949,5140,-7896,850,-7002,-2350,-2884,7642,-6193,-1158,174,-254,-9037,-1226,4106,-6130,4043,6468,-8439,-7509,-8754,8486,-5277,-7166,-9216,6127,-6436,-3466,9067,-4074,1203,2476,-4864,2114,1825,9775,6066,-8916,-9582,6428,7183,-6224,8459,2177,4332,-5804,2180,7142,3280,-2167,-5055,2001,6645,4049,2261,-3965,5131,5822,-5412,5242,2922,728,8158,-7227,3623,-991,-1892,2858,7718,-8267,-2591,-3045,3620,-8522,5185,9434,5575,669,8476,4127,-5659,7871,6180,-9991,-4966,-7519,-3226,5010,-7393,6247,-9012,-595,9769,-2125,-8692,9130,8312,3491,-8632,-7233,3458,9745,-3675,8862,-5519,3866,7245,8976,-3963,6444,-5686,528,821,1743,-6276,-5283,-3295,661,-9961,8396,-4028,3159,5816,-8610,739,-8397,-3582,6075,-9741,7435,9651,-4384,8618,160,-383,1011,6815,898,-992,-1918,1016,-6188,2603,9329,-5056,5706,8042,-384,8899,6731,9799,4932,-344,-6787,9347,1306,-1437,-8574,-2335,-3647,4793,-6514,2317,-5645,-2039,-591,-2280,-8906,-6197,841,-5765,-5558,9629,3736,-930,-1292,3683,-8740,4958,7588,-8194,3737,-7414,4288,-3146,5334,3162,1771,-3600,-4792,6861,-4923,4103,-272,-2894,-585,6122,7892,3193,9749,-4848,173,2660,5360,9728,-959,519,-4138,2972,-3827,3897,-8408,-1813,-411,3591,-1245,8549,-5440,-992,3286,-7600,8724,-1967,-6704,831,-2387,5744,-5819,120,-8091,-7904,4923,-92,-1814,-9711,2808,659,-5131,47,9812,-8977,-5550,2744,-4682,4211,8380,4847,8710,8347,-5657,-622,5080,-6529,-3276,6003,-5245,3338,5382,2548,7749,-3484,-8337,1214,-7684,3822,-7351,-1027,-7789,-7129,-7160,-3304,5628,962,9582,-5400,-4097,3928,1230,-7893,-5848,-4607,1856,-7303,-4736,3810,5266,8964,9802,-6581,6597,3980,-403,4954,8971,9184,3363,-3657,-7686,3727,-4083,2055,-7683,927,3186,6118,-6750,-934,-5494,7569,-4222,-6342,243,-978,9712,380,7631,-9120,2956,3241,9489,-2888,6548,-7586,-9758,-2429,9206,-2464,-2440,-5080,6001,-5170,-4050,3970,-8986,8891,733,-9390,-5904,1695,-5279,8635,-9624,903,8981,-7873,3790,-6570,-7040,7672,-7086,-8441,-7848,-8781,-753,-1590,5935,-7316,9118,6535,-9946,7283,7982,2277,-8700,8699,3431,-7401,244,-3883,3358,-6123,654,-1862,8919,-2846,4436,7091,328,-4913,5882,-7294,-3838,9503,6849,-5605,-7807,7589,6070,-7199,-465,8541,-9041,4825,-442,701,-4665,-5452,8239,-3648,5646,-4577,9041,2859,3739,-6685,2905,5687,6210,1851,5670,4584,-8557,-7215,-8163,-8736,2932,9432,4766,6099,3467,-3730,-7198,-8486,1668,7252,4638,4605,3921,6823,3594,5380,6951,-1013,-5279,-6050,2122,7547,4521,3878,9055,-3932,-9594,592,6337,-1781,4718,1264,-6799,-7673,-9544,-8896,9796,4772,-9127,-3326,-8558,3465,-7875,3373,9360,8178,-5628,-2354,-7240,-1251,-6206,7086,-1942,7947,8496,139,7016,-9847,9709,3382,-1829,7069,-4023,9756,1536,-3911,2186,1088,-3880,-6901,-4557,-1332,-2771,6823,-6362,-8859,9416,-1714,-9049,-3718,8403,4824,9018,-2435,250,-9365,4068,8610,3103,-9945,-4204,-6545,-8124,-2914,8357,-2634,-9039,-6212,6736,-7749,-3227,2670,2844,-1437,-307,7818,6326,-1856,5754,8499,-7227,9016,1907,258,9607,290,-4193,1670,-6031,3944,7544,-3381,-5289,2132,-7403,-9017,4315,-1345,-2169,-9786,6711,-5758,-2301,9512,-2077,3939,967,4235,3586,-1492,4162,-371,-2281,-4674,-2464,-3872,-9221,-1723,-8367,-9150,-8749,-4291,-7268,1813,-14,6934,-383,6609,-4836,4851,8822,-1813,-5911,-6666,9802,8431,-7711,-4809,-7428,-6570,438,-2977,8735,-1060,-1367,6631,-1582,-7751,-5150,-949,2928,-453,-2882,-6099,-7107,1472,-2976,-2676,7274,-8080,-4615,-6512,4256,5693,6077,9214,2975,-3626,-4762,470,3271,-6615,-4004,-4368,-6903,1606,1787,5664,-9340,9065,-3511,7320,5892,6160,4003,-290,-7094,5566,-1347,2974,7299,3725,-7659,-6556,-7231,2933,-5222,936,4469,-1158,2249,-2290,-6673,-2832,6463,3894,658,8042,9621,-7718,-4156,8358,-8694,564,1662,-3814,3458,-427,4224,9437,9245,9791,-6312,2037,8178,5516,9545,-7755,3392,2349,-3382,2138,4827,7191,2195,-8884,9895,-8529,7424,-8377,-6622,-695,-248,8143,-384,-8118,5535,-4935,-907,3642,-4615,-722,-9221,4804,7228,3936,-9910,9445,-8596,-3858,8599,-4403,-6302,-8280,428,8843,-2139,-9281,227,-5384,-9273,7426,7489,9529,-9082,6083,-8632,-7787,5201,-8845,-7899,158,3738,2667,-1448,6382,1569,6949,5279,5901,-5885,4626,-4656,8428,9780,-9447,2561,-8671,-6731,-3431,4391,-5100,-8841,-7316,-157,6504,-7426,8558,-4924,5822,6018,-7804,529,-1300,-9563,6981,3751,-2005,4624,9393,5249,-3079,7248,-2675,4625,1858,3882,-8901,753,-1493,6053,4766,7791,-1019,1489,-7675,1310,-3600,-6842,4129,-8330,9241,-8692,-9110,6862,-1091,8423,5907,5705,-2164,3426,-715,-2292,-2956,1998,1678,-5851,-1084,4757,-4606,3089,-7339,-6432,341,-6838,6142,9043,-3924,-5222,5125,9923,2658,1416,41,8963,5416,5867,-6999,8977,-9232,2277,6837,-9175,-2058,9453,-140,-6223,5908,-6933,2091,-8075,8240,9210,-5619,6342,8167,-6204,7267,-8241,-5159,-4496,-2306,-9190,-7323,7580,-4806,-1389,1859,-8372,8755,290,3907,-1805,-5277,-465,-9280,85,-2941,8942,-1116,-6143,1540,-6163,8039,9672,7916,-9406,1547,-7150,-4073,-3918,1877,-2407,-1321,6163,630,-311,-6082,669,8724,6521,-4878,-8473,2679,-7739,-4612,-7486,2067,-6856,2021,1951,-3308,-2960,-3755,8214,9888,1400,5983,-4309,-1244,-5168,-2891,-9204,5144,-3202,8211,-9168,2796,-3746,7966,-447,2702,-3804,3762,-1697,7496,8798,450,1436,-8948,-1341,-9967,3372,4099,6797,-4243,6725,-5004,-3856,-3060,-3615,3031,9539,3328,-7797,6755,-3961,4159,1006,3357,4339,-5203,795,2491,7227,6911,8996,6844,-6346,5838,5991,4043,-1812,-5085,-7983,-8937,6241,7842,-9779,-6040,-3938,-6478,-3262,-4148,8565,151,4783,1353,-3097,-4153,-2170,4749,-4919,-3547,9063,-4966,8985,6394,-8291,-9011,7459,9756,3555,-7153,-9625,-9708,956,4385,-859,-4078,-9968,1017,-3483,148,-3719,-8734,2615,-5663,8592,3384,5276,7911,7155,1769,-5851,-7637,-7735,2298,-9374,-5417,-7504,-3098,9194,5362,-9820,-6527,4644,-9813,2211,-4266,-7826,-5704,4034,6545,407,-5767,4105,1748,-8869,9117,6632,3357,-7602,8239,898,-434,4168,-2105,-3881,8414,-8161,8825,9073,3912,-5447,8617,-4990,-9873,4654,-8771,-3585,7063,7681,2072,1743,1699,8199,-4413,2785,1042,7138,-4045,8250,5761,9946,5854,-6428,1599,-9611,872,-7606,-7381,2919,-1537,7131,1010,-1386,-2129,7506,9520,8311,8721,-656,4170,2275,8424,-2195,9971,-9780,7987,-8502,-915,4892,-7514,8070,-5298,-9769,-6103,3237,9455,5569,4080,8484,-5369,337,132,-3742,7641,1191,7397,-1393,6488,439,-5165,9061,-4137,8625,3589,-3079,726,-7892,4212,-4468,-5918,7104,4823,-5931,-8066,-2911,-7400,-5257,-1990,-1488,3558,-8128,-3537,1632,-3699,-6779,2329,6695,6706,1374,-7458,2565,-2448,-1713,-8962,1950,6058,-1069,8758,2445,-4794,-6809,7216,1958,-5808,-2262,-3334,6124,-3127,-2724,-5851,6129,2894,7691,-2178,-5907,3716,7776,-7971,-5438,-3314,7670,-6847,-1329,8930,-876,1551,9468,9488,3298,-5989,1775,4588,-1838,-9117,6182,4605,3147,-4323,5522,93,-2925,-5707,3675,-9462,5561,-742,-1212,503,-5376,-8536,7881,2463,8184,5408,2917,9321,7764,9375,-8907,851,-1859,9660,9615,-8835,-2173,820,7885,-4899,8836,-4467,4380,-1222,8625,7069,998,-782,4132,611,4267,-9100,2412,1104,205,-4926,-6190,-3087,-5306,2173,-862,9674,-7379,-8726,-1396,2652,7291,-1204,-1207,-8242,-3736,-3790,337,2980,-6043,602,7472,-705,-4588,-7528,3064,7721,-9739,-5635,-8172,-7460,5739,-1204,9977,8404,4964,2050,-1659,9628,3269,1520,8410,-2031,-1595,5110,-8832,9254,-5505,-6877,-1923,9513,8416,-9078,9112,-2187,-6047,-43,-4294,791,5621,-4397,-8619,-7148,-1446,-9789,-3565,2117,3625,7402,-1736,6479,6197,-6365,8019,6069,-4013,-1829,7715,2395,-3574,9263,-3716,7797,9024,-8523,8866,-5542,4338,3080,-8342,-8582,9566,318,-4524,5047,-4294,-5948,-9997,7127,7353,-3634,-8702,5125,-5825,-1157,-8712,-9158,-1742,-2916,7332,-6678,-4460,2681,-5054,-1009,-5578,2784,-3781,6397,4334,-1531,-7263,-2179,-8053,-5227,-2665,6245,6422,-2196,9351,9135,-4933,8464,-5801,5329,-6819,5355,-4043,6903,-8861,3666,-9010,6263,-7267,-6187,-4591,6567,-8180,-1818,6346,4841,629,-8611,8896,2271,9131,4351,2419,1784,217,-6603,-5208,2556,-2832,8227,5535,-8387,5524,8989,7484,-7671,-1511,-5575,9495,-8786,-928,636,2972,7151,-277,5408,5006,-5429,-4697,-573,-9078,-8494,4496,3993,-9036,8190,-2968,-1508,-1542,3202,184,1039,2497,-9878,-529,1602,4721,-8038,-7885,-2556,7859,4331,9343,585,8716,727,6156,-5759,1357,-9331,7182,-8335,5074,-4814,-2639,-6960,-2450,6014,-2280,1710,8791,298,-2430,-2263,2672,-4295,-7937,-5729,5297,3691,-6867,2637,-8929,-8894,-4850,-5988,-519,3248,5411,130,-1416,-2985,-2414,-5559,5757,193,6208,9180,-8283,-8669,6484,1372,-2313,7633,-1264,-5634,8790,6613,6709,-8819,-2759,4164,-6534,-9179,8814,9675,274,5203,-6324,9831,9732,2901,-5311,-8060,-4476,-3487,6562,611,-3956,-1316,-1059,-23,2841,8287,-2380,-4096,-9115,-2842,6276,-6297,-9973,-5000,47,-4829,-5879,5005,-4060,3989,-7147,8815,6434,-3506,-3317,6691,-3056,2200,4480,6935,-824,903,-3416,5036,-9564,6590,-953,-3676,-8283,-4363,3029,-8822,-2386,-9188,-364,-7552,-1926,-2220,4914,-210,1522,7597,-2364,-4791,-6821,-7035,-6615,3726,-8363,3435,-8092,9510,-3943,6736,7410,6940,776,-4461,7411,-4986,-116,766,3335,-2910,-794,-785,381,3058,1225,-8866,-8908,-4943,-8022,9842,-1556,-973,513,5407,-4503,832,-3461,-3557,-2135,-6668,5440,-6107,7513,-2769,5610,6684,-2282,9215,-392,-3749,3311,8523,2007,8330,3648,1464,-5111,8828,-2355,1203,1302,-710,1967,-1945,-4172,8739,-3605,5906,-6163,493,-7497,3462,4904,-8639,5673,-3174,1921,4544,-1811,8182,1117,1775,-3586,1823,9314,-7649,4713,-3248,5470,4123,-1994,-7128,-9198,-3883,-5984,7525,2911,-8746,7578,1373,1914,9931,5683,9377,-3298,-6284,-7142,2709,2106,8268,7115,-5909,836,-2808,-501,717,1344,-6632,6358,-5767,-877,-3820,1862,-8802,8229,1658,-7215,657,7128,-7666,-4970,-9790,-2890,334,-2015,8811,-4803,8419,4456,6982,-9330,-6256,-515,-2697,2053,-9375,-1896,9457,-836,966,737,3084,8105,7926,783,-8105,2763,-6266,6877,1545,3434,-5200,3202,9460,-5927,-7499,418,-6521,9606,-2200,-4095,455,2610,9190,-4036,-569,-3118,7152,-8702,-4933,6787,3393,6902,7347,1754,8714,-6546,6274,-5838,-9840,-1045,-6435,-357,321,-7923,-9746,-8072,-1758,9420,5521,7621,-7056,-1581,6495,-6563,-6837,-5588,4735,-1687,-662,1235,2663,7166,8950,9856,-671,1556,-4962,8745,9359,-3265,944,3443,-5936,-9686,3841,-6657,1256,-4013,3027,9776,-1351,9523,-9610,5636,4300,-2024,2943,1852,1429,-9971,4251,-5141,2617,2029,8266,-8443,-3955,-6419,-5544,-7119,-7255,-7793,5605,5153,-7463,-3291,-6717,6705,-6152,3620,-2681,1842,8232,-886,1747,-9671,-1724,-6184,-7475,-1462,6628,2757,-537,1240,-9894,-4765,-3053,-6173,-5690,9483,5568,7055,-393,9157,-3198,6134,7316,-9191,9773,1997,-2160,-8167,3078,6034,-1781,3884,-1800,6582,-9307,7037,7748,9733,-4242,7571,-1194,3986,-8635,6130,3509,9255,-7477,7773,-4066,418,-7302,-9003,-9924,-3693,-4086,-946,6148,-3114,-298,7113,-5503,2494,2000,-5676,-6001,8364,8041,-1843,3483,7995,3933,-5065,8667,-4077,-4759,3657,3624,-139,-7812,3130,4677,938,8309,9186,-9401,-209,7989,-9750,-844,9408,6806,-1854,3018,7855,-2115,-9753,3055,-9353,-7772,425,7878,3125,-8941,1828,-5255,7514,5660,-5160,-7262,-1168,8191,-9453,-2098,7888,-4613,-1687,5658,2658,-9377,88,-7474,9212,284,2176,-9399,8973,-5778,-6014,5013,-77,-551,2990,1064,8288,-7075,-821,5762,-4993,8278,-8016,2676,9971,-9754,6623,6479,8336,-8557,-9090,-528,-1276,-6532,-3973,977,305,8260,7298,8411,2846,446,-6943,-1566,-9504,-4224,5586,-8454,3292,-7489,-7468,-1931,-6135,-4278,-2577,4387,-2404,-4817,3736,2350,-8905,-3051,1646,5957,-1114,7146,8393,1283,-6286,7984,-5285,-7178,-7107,-7644,5407,-3238,-7693,-8183,-1114,-8183,5936,9638,4898,3218,5157,4173,-6338,-7573,1958,-9861,4750,-8269,-8031,-2602,-7480,7195,5416,9873,1094,8137,3924,2009,2711,5964,-8841,8459,-1172,-4800,-8642,-1363,3770,3986,5882,-5167,-8589,-6552,-1651,9392,-86,6179,4454,-8632,-4156,7655,-2182,-9207,-7522,-5916,-2912,-8561,-1568,-1508,-2962,1047,-3640,-7675,-5633,3510,-4562,775,-164,2906,4979,-4493,-9175,8756,7122,-2281,6692,3874,-4649,-9926,-1084,4677,5162,-1020,9561,8113,1596,-5628,8544,-9889,-3689,-7175,7378,-4342,-1184,7595,-2741,-8654,163,-7447,-5167,-4142,-6271,-487,-7941,-6942,2445,-551,3561,-3502,-7627,3111,6758,2546,5773,6226,6476,-3915,-9002,-5347,-1948,8821,-7688,6951,7060,5289,5519,9445,-7079,-9553,-4607,766,-2079,-3031,-8697,2487,-1547,-3266,4992,7790,-7599,-2580,-4791,-552,-2059,6619,7332,7155,1032,3738,-4843,6516,7763,-4344,-9049,5950,8206,2563,378,-1114}, +586, +767481, + }, + + { + []int{4, 5, 0, -2, -3, 1}, + 5, + 7, + }, + + // 可以有多个 testcase +} + +func Test_subarraysDivByK(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, subarraysDivByK(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_subarraysDivByK(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + subarraysDivByK(tc.A, tc.K) + } + } +} diff --git a/Algorithms/0975.odd-even-jump/README.md b/Algorithms/0975.odd-even-jump/README.md new file mode 100755 index 000000000..ce1a2ba91 --- /dev/null +++ b/Algorithms/0975.odd-even-jump/README.md @@ -0,0 +1,64 @@ +# [975. Odd Even Jump](https://leetcode.com/problems/odd-even-jump/) + +You are given an integer array A. From some starting index, you can make a series of jumps. The (1st, 3rd, 5th, ...) jumps in the series are called odd numbered jumps, and the (2nd, 4th, 6th, ...) jumps in the series are called even numbered jumps. + +You may from index i jump forward to index j (with i < j) in the following way: + +- During odd numbered jumps (ie. jumps 1, 3, 5, ...), you jump to the index j such that A[i] <= A[j] and A[j] is the smallest possible value. If there are multiple such indexes j, you can only jump to the smallest such index j. +- During even numbered jumps (ie. jumps 2, 4, 6, ...), you jump to the index j such that A[i] >= A[j] and A[j] is the largest possible value. If there are multiple such indexes j, you can only jump to the smallest such index j. +- (It may be the case that for some index i, there are no legal jumps.) + +A starting index is good if, starting from that index, you can reach the end of the array (index A.length - 1) by jumping some number of times (possibly 0 or more than once.) + +Return the number of good starting indexes. + +Example 1: + +```text +Input: [10,13,12,14,15] +Output: 2 +Explanation: +From starting index i = 0, we can jump to i = 2 (since A[2] is the smallest among A[1], A[2], A[3], A[4] that is greater or equal to A[0]), then we can't jump any more. +From starting index i = 1 and i = 2, we can jump to i = 3, then we can't jump any more. +From starting index i = 3, we can jump to i = 4, so we've reached the end. +From starting index i = 4, we've reached the end already. +In total, there are 2 different starting indexes (i = 3, i = 4) where we can reach the end with some number of jumps. +``` + +Example 2: + +```text +Input: [2,3,1,1,4] +Output: 3 +Explanation: +From starting index i = 0, we make jumps to i = 1, i = 2, i = 3: + +During our 1st jump (odd numbered), we first jump to i = 1 because A[1] is the smallest value in (A[1], A[2], A[3], A[4]) that is greater than or equal to A[0]. + +During our 2nd jump (even numbered), we jump from i = 1 to i = 2 because A[2] is the largest value in (A[2], A[3], A[4]) that is less than or equal to A[1]. A[3] is also the largest value, but 2 is a smaller index, so we can only jump to i = 2 and not i = 3. + +During our 3rd jump (odd numbered), we jump from i = 2 to i = 3 because A[3] is the smallest value in (A[3], A[4]) that is greater than or equal to A[2]. + +We can't jump from i = 3 to i = 4, so the starting index i = 0 is not good. + +In a similar manner, we can deduce that: +From starting index i = 1, we jump to i = 4, so we reach the end. +From starting index i = 2, we jump to i = 3, and then we can't jump anymore. +From starting index i = 3, we jump to i = 4, so we reach the end. +From starting index i = 4, we are already at the end. +In total, there are 3 different starting indexes (i = 1, i = 3, i = 4) where we can reach the end with some number of jumps. +``` + +Example 3: + +```text +Input: [5,1,3,4,2] +Output: 3 +Explanation: +We can reach the end from starting indexes 1, 2, and 4. +``` + +Note: + +- `1 <= A.length <= 20000` +- `0 <= A[i] < 100000` \ No newline at end of file diff --git a/Algorithms/0975.odd-even-jump/odd-even-jump.go b/Algorithms/0975.odd-even-jump/odd-even-jump.go new file mode 100755 index 000000000..5b853a076 --- /dev/null +++ b/Algorithms/0975.odd-even-jump/odd-even-jump.go @@ -0,0 +1,81 @@ +package problem0975 + +import "sort" + +// ref: https://leetcode.com/problems/odd-even-jump/discuss/217981/JavaC%2B%2BPython-DP-idea-Using-TreeMap-or-Stack +func oddEvenJumps(A []int) int { + size := len(A) + + indexs := make([]int, size) + for i := range indexs { + indexs[i] = i + } + + sort.Slice(indexs, func(i int, j int) bool { + if A[indexs[i]] == A[indexs[j]] { + return indexs[i] < indexs[j] + } + return A[indexs[i]] < A[indexs[j]] + }) + + nextHigher := nextIndex(indexs) + + ascToDes(A, indexs) + + nextLower := nextIndex(indexs) + + higher, lower := make([]int, size), make([]int, size) + higher[size-1], lower[size-1] = 1, 1 + for i := size - 2; i >= 0; i-- { + higher[i], lower[i] = lower[nextHigher[i]], higher[nextLower[i]] + } + return sum(higher) +} + +func nextIndex(indexs []int) []int { + size := len(indexs) + res := make([]int, size) + stack := make([]int, 0, size) + for _, j := range indexs { + for len(stack) > 0 && stack[len(stack)-1] < j { + pop := stack[len(stack)-1] + res[pop] = j + stack = stack[:len(stack)-1] + } + stack = append(stack, j) + } + return res +} + +func ascToDes(A, indexs []int) { + i, size := 0, len(A) + for i+1 < size { + if A[indexs[i]] != A[indexs[i+1]] { + i++ + continue + } + a, j := A[indexs[i]], i+1 + for j+1 < size && A[indexs[j+1]] == a { + j++ + } + reverse(indexs, i, j) + i = j + 1 + } + reverse(indexs, 0, size-1) +} + +func reverse(A []int, i, j int) { + for i < j { + A[i], A[j] = A[j], A[i] + i++ + j-- + } +} + +func sum(A []int) int { + res := 0 + for _, a := range A { + res += a + } + return res +} diff --git a/Algorithms/0975.odd-even-jump/odd-even-jump_test.go b/Algorithms/0975.odd-even-jump/odd-even-jump_test.go new file mode 100755 index 000000000..3184bfb45 --- /dev/null +++ b/Algorithms/0975.odd-even-jump/odd-even-jump_test.go @@ -0,0 +1,62 @@ +package problem0975 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{2, 3, 1, 1, 4, 2, 3, 1, 1, 4}, + 5, + }, + + { + []int{1, 2, 3, 2, 1, 4, 4, 5}, + 6, + }, + + { + []int{58614, 72008, 68132, 35335, 91636, 89945, 33065, 74739, 909, 81635, 56486, 95230, 36319, 62571, 32300, 78278, 60070, 98747, 101, 14075, 4360, 12584, 92938, 94860, 48041, 94668, 81838, 77861, 74728, 18765, 54887, 42387, 94978, 17383, 16985, 65886, 15740, 11005, 50392, 79666, 60504, 75475, 26575, 28496, 42870, 99084, 71791, 94625, 53787, 55455, 99009, 18998, 78259, 79151, 84474, 75005, 15533, 66112, 92370, 56328, 36094, 94952, 56159, 41163, 61413, 80412, 22830, 1569, 52909, 94135, 68025, 63090, 62781, 49698, 73091, 24919, 89175, 27447, 94494, 92649, 7792, 44817, 74403, 44965, 50889, 80682, 70499, 95800, 16448, 92355, 92798, 63474, 94039, 25268, 88178, 77347, 60968, 9062, 3013, 1096, 25055, 76235, 38662, 77544, 62564, 38926, 88014, 3841, 46531, 82985, 12681, 71048, 32811, 2430, 47372, 52169, 4158, 56591, 34743, 449, 19077, 11081, 54062, 4312, 92813, 84506, 94529, 31480, 90526, 98431, 76473, 27508, 67088, 59566, 40420, 30609, 5984, 12538, 13395, 48089, 64189, 76406, 4671, 82375, 4347, 55494, 74414, 63122, 94967, 34469, 58588, 8279, 55979, 81329, 20160, 26096, 70040, 25388, 25924, 93551, 99854, 15519, 90016, 55272, 3860, 58550, 64154, 3379, 75769, 81780, 7164, 64839, 45654, 23872, 45867, 15938, 33366, 65520, 47648, 55592, 54344, 82059, 34338, 81296, 7998, 42773, 35232, 45158, 83350, 51239, 98724, 86146, 11884, 31689, 2272, 73375, 1920, 88593, 19334, 41383, 6203, 31125, 38951, 5223, 76755, 71134, 35788, 83519, 7742, 5400, 35498, 90184, 75646, 67231, 56273, 80376, 41222, 3068, 80240, 19049, 38765, 35760, 12336, 35078, 17708, 61601, 65343, 1364, 45647, 55405, 87166, 49603, 8045, 5172, 86210, 79072, 85844, 26224, 64799, 9571, 82657, 33361, 95514, 47138, 3306, 90905, 62553, 28708, 3680, 37668, 15686, 54828, 14688, 17461, 92086, 64012, 24258, 87889, 62471, 94559, 48291, 88790, 67844, 4416, 24029, 28157, 17001, 23818, 22604, 87834, 46289, 87651, 13799, 56491, 1346, 93030, 563, 38990, 80158, 99988, 1950, 82408, 51008, 3818, 77711, 11190, 61147, 77832, 67359, 37987, 2644, 43626, 91369, 33292, 24795, 13783, 51025, 53334, 7304, 40775, 65868, 96605, 43154, 43603, 47113, 22503, 39483, 64526, 39705, 58137, 83558, 99796, 88503, 37179, 2172, 61160, 47455, 23701, 4030, 32157, 79807, 96411, 10666, 87763, 4871, 71347, 2679, 42104, 87023, 39310, 92456, 71319, 60418, 16137, 34049, 41109, 59020, 99603, 28370, 50356, 93344, 34542, 62860, 76613, 63026, 75343, 19569, 95733, 17689, 58368, 29604, 63442, 29111, 43121, 68222, 26906, 72787, 34687, 13215, 61312, 16575, 43057, 39839, 7616, 71076, 68082, 77779, 54491, 55391, 16923, 20746, 22824, 52530, 81898, 35697, 88187, 73587, 71644, 33517, 11847, 96279, 85461, 40886, 86321, 89921, 34247, 50156, 33178, 69515, 91216, 98454, 74377, 30524, 88049, 99261, 34652, 94871, 51154, 96463, 99585, 81294, 68343, 15401, 491, 59547, 70445, 93553, 51711, 69684, 64735, 20492, 64430, 98172, 11118, 68854, 61430, 37585, 79334, 1048, 89241, 81736, 48070, 10813, 45262, 58425, 25388, 48653, 77572, 92273, 56164, 82724, 7793, 85636, 92081, 16800, 82748, 84956, 87865, 51713, 60825, 20808, 70813, 40501, 2116, 13426, 38821, 88517, 56494, 91625, 92948, 8679, 58821, 33452, 50679, 45552, 47994, 10180, 83316, 49027, 64498, 47267, 18101, 54100, 15953, 85217, 83160, 14363, 6884, 6849, 39324, 95304, 55614, 26552, 22964, 11087, 14107, 81186, 13863, 86406, 82299, 13680, 55872, 705, 86203, 55827, 75534, 49034, 69042, 93123, 55954, 87470, 34304, 9753, 514, 22665, 83858, 31149, 22461, 49563, 94690, 50897, 34087, 7750, 57366, 22625, 36749, 38116, 75818, 23162, 93589, 74238, 48111, 88047, 35916, 38433, 12936, 77855, 40119, 50025, 47096, 65618, 37393, 91586, 43192, 35921, 40087, 76629, 99305, 86651, 47972, 29135, 44598, 34401, 24353, 18694, 95587, 49930, 10997, 38390, 38871, 51353, 98004, 97663, 56589, 61809, 67562, 50222, 48667, 31452, 68392, 9189, 31714, 89097, 22737, 96758, 98416, 57538, 4043, 9347, 20030, 32681, 11310, 79721, 36415, 23373, 4369, 38267, 450, 11649, 60464, 93494, 19936, 74106, 19770, 149, 89653, 84610, 6677, 17713, 23430, 92832, 38192, 80738, 43581, 38124, 76534, 61576, 26931, 58281, 70385, 82707, 67717, 64074, 59590, 9205, 94518, 71484, 27287, 69235, 62081, 65885, 37890, 57317, 66002, 20165, 50801, 12034, 10553, 91106, 12454, 89326, 46979, 45490, 33981, 41621, 37723, 56498, 33559, 82197, 23356, 24847, 48055, 93508, 2391, 72341, 600, 40486, 76420, 44607, 42948, 25321, 47509, 22825, 28352, 65329, 59944, 92954, 96886, 52238, 8755, 29990, 51780, 67316, 94619, 15510, 3668, 87003, 80516, 76574, 46860, 67778, 41146, 19205, 39089, 78704, 80185, 96113, 88766, 68208, 52091, 72392, 18320, 92308, 71257, 59448, 43404, 63354, 61767, 89885, 57073, 21337, 44137, 24296, 90495, 84352, 55581, 19639, 4354, 13416, 44321, 67420, 22399, 68452, 86194, 75724, 42552, 64572, 98836, 88541, 33814, 68544, 16321, 55736, 35653, 43814, 43889, 66323, 84599, 46857, 14658, 75415, 75164, 95384, 39405, 46387, 54059, 89212, 70421, 2127, 20732, 85389, 58547, 87390, 41139, 21046, 414, 99605, 13638, 64296, 48970, 38014, 53720, 7828, 97003, 49273, 1528, 41934, 75720, 31208, 74502, 76736, 23912, 96797, 2788, 86360, 51264, 15337, 25839, 59351, 27845, 83842, 21952, 38406, 50681, 33977, 82414, 26388, 8897, 15478, 62694, 56356, 6329, 99304, 47944, 31943, 72916, 2429, 43424, 66441, 96213, 76163, 88515, 11890, 42977, 3179, 27199, 38429, 34382, 37374, 80308, 18954, 82449, 54192, 33874, 55223, 16142, 49545, 2195, 86297, 33158, 34404, 99515, 61345, 41765, 79065, 6766, 57050, 52070, 86122, 58620, 48527, 52022, 78189, 34732, 55778, 70739, 99555, 69368, 96187, 39903, 60878, 74529, 34841, 26917, 97283, 34853, 99990, 85227, 21606, 82821, 98362, 27682, 66445, 76958, 8328, 81933, 30836, 70638, 95013, 3510, 61171, 29240, 11465, 71185, 97904, 51271, 34634, 44908, 41461, 53190, 40917, 8037, 97942, 99670, 17413, 24103, 43695, 69873, 3134, 83549, 63843, 26929, 87086, 66120, 31692, 54784, 97923, 4843, 70846, 84941, 69231, 14001, 59714, 78595, 41859, 58242, 25346, 31274, 80857, 48949, 44881, 12288, 37447, 52072, 23101, 80793, 38370, 23848, 30829, 82446, 90414, 96029, 1519, 75389, 52548, 12456, 24653, 28169, 40421, 47072, 93678, 5835, 70916, 85410, 35729, 24921, 22130, 30083, 14529, 55167, 25039, 2725, 23263, 82063, 41737, 88353, 94361, 24334, 55997, 88106, 58142, 16800, 24795, 98762, 29938, 86770, 79501, 74198, 72194, 78998, 84740, 6236, 16780, 50552, 21248, 53321, 49318, 12677, 8596, 1165, 82503, 8174, 96156, 98383, 74569, 45038, 27578, 41245, 34529, 39629, 72619, 89252, 15771, 24267, 20989, 4534, 85420, 51127, 6703, 44625, 45061, 77795, 76139, 13448, 62687, 50968, 1349, 14773, 66684, 36702, 96368, 50175, 68828, 13361, 47944, 73412, 83348, 19960, 39690, 47352, 44037, 47544, 29590, 80872, 91307, 34900, 63786, 38070, 57875, 69553, 50151, 67458, 75714, 84329, 18880, 21638, 51437, 50965, 80772, 51738, 90005, 77760, 50631, 82632, 47585, 34171, 43342, 45620, 65053, 5215, 72950, 96823, 45881, 6877, 20125, 10321, 25635, 79390, 104, 87357}, + 965, + }, + + { + []int{10, 13, 12, 14, 15}, + 2, + }, + + { + []int{2, 3, 1, 1, 4}, + 3, + }, + + { + []int{5, 1, 3, 4, 2}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_oddEvenJumps(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, oddEvenJumps(tc.A), "输入:%v", tc) + } +} + +func Benchmark_oddEvenJumps(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + oddEvenJumps(tc.A) + } + } +} diff --git a/Algorithms/0976.largest-perimeter-triangle/README.md b/Algorithms/0976.largest-perimeter-triangle/README.md new file mode 100755 index 000000000..aea823662 --- /dev/null +++ b/Algorithms/0976.largest-perimeter-triangle/README.md @@ -0,0 +1,38 @@ +# [976. Largest Perimeter Triangle](https://leetcode.com/problems/largest-perimeter-triangle/) + +Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths. + +If it is impossible to form any triangle of non-zero area, return 0. + +Example 1: + +```text +Input: [2,1,2] +Output: 5 +``` + +Example 2: + +```text +Input: [1,2,1] +Output: 0 +``` + +Example 3: + +```text +Input: [3,2,3,4] +Output: 10 +``` + +Example 4: + +```text +Input: [3,6,2,3] +Output: 8 +``` + +Note: + +- 3 <= A.length <= 10000 +- 1 <= A[i] <= 10^6 diff --git a/Algorithms/0976.largest-perimeter-triangle/largest-perimeter-triangle.go b/Algorithms/0976.largest-perimeter-triangle/largest-perimeter-triangle.go new file mode 100755 index 000000000..7dac04a60 --- /dev/null +++ b/Algorithms/0976.largest-perimeter-triangle/largest-perimeter-triangle.go @@ -0,0 +1,50 @@ +package problem0976 + +import "container/heap" + +func largestPerimeter(A []int) int { + size := len(A) + h := intHeap(A) + + heap.Init(&h) + + a := heap.Pop(&h).(int) + b := heap.Pop(&h).(int) + for i := size - 3; i >= 0; i-- { + c := heap.Pop(&h).(int) + if a < b+c { + return a + b + c + } + a, b = b, c + } + return 0 +} + +// intHeap 实现了 heap 的接口 +type intHeap []int + +func (h intHeap) Len() int { + return len(h) +} + +func (h intHeap) Less(i, j int) bool { + return h[i] > h[j] // NOTICE: Max is at the top +} + +func (h intHeap) Swap(i, j int) { + h[i], h[j] = h[j], h[i] +} + +func (h *intHeap) Push(x interface{}) { + // Push 使用 *h,是因为 + // Push 增加了 h 的长度 + *h = append(*h, x.(int)) +} + +func (h *intHeap) Pop() interface{} { + // Pop 使用 *h ,是因为 + // Pop 减短了 h 的长度 + res := (*h)[len(*h)-1] + *h = (*h)[:len(*h)-1] + return res +} diff --git a/Algorithms/0976.largest-perimeter-triangle/largest-perimeter-triangle_test.go b/Algorithms/0976.largest-perimeter-triangle/largest-perimeter-triangle_test.go new file mode 100755 index 000000000..6383a7ead --- /dev/null +++ b/Algorithms/0976.largest-perimeter-triangle/largest-perimeter-triangle_test.go @@ -0,0 +1,74 @@ +package problem0976 + +import ( + "container/heap" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{757, 341, 254, 499, 96, 622, 685, 514, 482, 655, 680, 593, 407, 660, 330, 469, 841, 335, 53, 764, 341, 918, 290, 667, 47, 725, 319, 135, 118, 636, 145, 540, 363, 708, 658, 735, 999, 306, 531, 427, 393, 872, 30, 838, 873, 710, 438, 364, 95, 567, 737, 510, 961, 881, 37, 567, 464, 991, 587, 363, 25, 532, 565, 116, 876, 479, 805, 908, 71, 581, 262, 881, 657, 734, 60, 111, 718, 739, 950, 349, 588, 963, 947, 213, 356, 429, 446, 420, 706, 221, 709, 948, 855, 811, 763, 978, 704, 384, 601, 920, 170, 864, 785, 308, 983, 524, 711, 233, 537, 657, 682, 728, 37, 131, 521, 783, 130, 669, 574, 503, 453, 712, 216, 976, 764, 803, 921, 747, 261, 329, 500, 361, 485, 757, 173, 47, 211, 730, 171, 254, 115, 936, 111, 837, 35, 64, 244, 481, 385, 300, 450, 682, 339, 423, 927, 835, 332, 827, 624, 212, 180, 802, 873, 535, 528, 947, 882, 549, 574, 81, 415, 645, 307, 826, 924, 405, 800, 791, 620, 337, 517, 488, 981, 920, 131, 367, 39, 45, 686, 256, 781, 298, 303, 146, 478, 297, 33, 767, 247, 195, 664, 763, 65, 127, 790, 424, 678, 238, 810, 944, 285, 700, 595, 432, 968, 497, 288, 15, 995, 855, 541, 712, 635, 938, 855, 784, 638, 50, 584, 857, 620, 495, 337, 903, 1000, 407, 687, 520, 406, 447, 586, 209, 53, 869, 383, 80, 311, 928, 545, 916, 16, 219, 517, 226, 31, 201, 830, 753, 324, 989, 701, 976, 713, 228, 227, 391, 268, 301, 674, 690, 994, 224, 851, 638, 117, 341, 146, 235, 676, 172, 429, 744, 806, 899, 549, 633, 148, 181, 948, 381, 861, 93, 143, 974, 366, 901, 517, 161, 166, 492, 355, 441, 388, 407, 17, 34, 472, 592, 32, 184, 388, 156, 400, 764, 435, 968, 798, 130, 277, 687, 955, 476, 135, 644, 313, 303, 28, 635, 667, 817, 651, 341, 98, 637, 870, 141, 695, 425, 997, 467, 961, 622, 624, 987, 913, 256, 781, 338, 304, 144, 253, 137, 860, 377, 162, 476, 632, 181, 616, 671, 486, 900, 447, 697, 389, 787, 858, 495, 574, 329, 583, 423, 784, 382, 715, 939, 515, 476, 710, 558, 872, 52, 133, 524, 240, 792, 506, 958, 738, 138, 378, 836, 469, 238, 659, 54, 346, 458, 971, 536, 44, 34, 494, 224, 573, 443, 90, 804, 415, 90, 48, 690, 713, 302, 243, 276, 636, 611, 226, 933, 788, 147, 94, 691, 453, 414, 518, 322, 939, 961, 551, 338, 79, 1000, 186, 671, 404, 675, 653, 965, 218, 268, 410, 656, 793, 615, 884, 911, 55, 360, 297, 526, 913, 120, 301, 551, 604, 454, 545, 531, 3, 642, 85, 67, 394, 235, 731, 862, 599, 804, 574, 951, 981, 855, 226, 19, 336, 259, 441, 342, 305, 250, 727, 78, 985, 672, 110, 78, 719, 57, 375, 449, 750, 593, 497, 376, 930, 67, 822, 750, 10, 170, 371, 465, 5, 542, 965, 388, 508, 888, 873, 337, 590, 863, 425, 812, 347, 41, 306, 813, 413, 343, 613, 12, 978, 81, 227, 78, 560, 164, 921, 847, 279, 113, 663, 290, 474, 395, 390, 241, 206, 804, 568, 831, 391, 83, 501, 222, 823, 171, 1000, 290, 513, 343, 706, 444, 303, 606, 217, 25, 290, 619, 702, 935, 699, 27, 774, 916, 531, 682, 896, 834, 14, 729, 454, 372, 542, 189, 960, 958, 508, 710, 199, 981, 207, 158, 215, 904, 322, 302, 436, 922, 449, 627, 370, 409, 33, 138, 85, 470, 73, 177, 724, 723, 441, 278, 910, 2164, 14, 217, 310, 65, 606, 488, 477, 120, 894, 495, 149, 891, 481, 716, 297, 912, 89, 981, 414, 715, 398, 844, 890, 746, 970, 767, 821, 760, 291, 876, 423, 869, 845, 580, 959, 265, 882, 217, 966, 537, 526, 557, 911, 662, 991, 579, 358, 636, 405, 537, 913, 441, 267, 892, 376, 657, 627, 99, 664, 359, 549, 941, 520, 65, 759, 550, 198, 207, 284, 887, 853, 581, 23, 364, 394, 754, 936, 532, 480, 16203, 965, 531, 429, 72, 963, 640, 365, 797, 349, 219, 235, 571, 282, 732, 976, 625, 277, 298, 726, 619, 668, 917, 598, 895, 489, 128, 365, 701, 537, 68, 27, 32, 546, 169, 323, 548, 38, 819, 498, 276, 498, 520, 959, 95, 202, 615, 387, 451, 429, 255, 572, 19, 61, 496, 584, 142, 977, 1531, 45, 874, 442, 288, 66, 938, 929, 532, 786, 66, 734, 607, 405, 502, 597, 241, 669, 758, 445, 955, 708, 894, 875, 798, 993, 818, 336, 215, 631, 574, 661, 422, 489, 60, 23, 90, 51, 41, 526, 489, 231, 860, 635, 345, 865, 519, 350, 426, 755, 457, 999, 841, 942, 336, 943, 414, 526, 262, 393, 749, 967, 55, 115, 619, 446, 44, 184, 804, 910, 737, 599, 891, 851, 752, 327, 1000, 977, 543, 942, 985, 757, 106, 411, 343, 370, 623, 34, 625, 60, 754, 601, 434, 94, 187, 716, 451, 310, 379, 700, 362, 543, 528, 389, 454, 950, 83, 508, 729, 503, 688, 1000, 787, 3891, 903, 105, 482, 750, 843, 969, 841, 478, 136, 971, 260, 439, 753, 232, 233, 398, 134, 885, 342, 209, 253, 426, 656, 154, 299, 567, 74, 136, 630, 979, 884, 725, 472, 943, 78, 289, 962, 173, 535, 318, 157, 939, 39, 976, 443, 15, 107, 259, 269, 146, 690, 79, 506, 523, 546, 170, 776, 736, 721, 569, 962, 553, 507, 6, 311, 527, 300, 997, 553, 174, 877, 244, 540, 818, 673, 980, 518, 913, 257, 82, 962, 264, 130, 79, 425, 871, 808, 823, 627, 928, 461, 709, 218, 740, 822, 665, 729, 994, 614, 298, 36, 82, 601, 409, 488, 384, 869, 818, 74, 255, 11, 512, 75, 572, 78, 320, 868, 803, 49, 277, 439, 177, 378, 647, 290, 280, 923, 776, 622, 203, 523, 824, 179, 68, 867, 328, 646, 145, 114, 496, 234, 599, 335, 645, 221, 557, 561, 797, 188, 688, 697, 351, 91, 965, 285, 485, 207, 774, 33, 87, 167, 926, 249, 906, 989, 523, 985, 14, 188, 64, 507, 205, 450, 725, 282, 891, 677, 84, 955, 754, 810, 91, 492, 910, 383, 863, 941, 812, 859, 514, 757, 54, 126, 45, 413, 938, 647, 809, 620, 307, 225, 628, 41, 113, 757, 552, 578, 877, 607, 955, 192, 937, 901, 146, 815, 67, 144, 806, 240, 199, 705, 650, 60, 976, 917, 694, 548, 962, 985, 255, 785, 939, 530, 997, 400, 4, 832, 353, 202, 734, 605, 408, 927, 387, 947, 34, 712, 516, 896, 508, 513, 81, 862, 960, 931, 111667, 838, 569, 866, 270, 290, 396, 24, 496, 426, 826, 358, 859, 475, 88, 510, 902, 748, 648, 58, 351, 710, 885, 173, 247, 937, 874, 597, 487, 53, 365, 498, 352, 869, 659, 458, 50, 774, 251, 672, 930, 864, 367, 675, 548, 922, 860, 769, 472, 73, 933, 29, 259, 412, 161, 380, 82, 153, 832, 948, 257, 521, 671, 883, 173, 388, 639, 313, 485, 54, 951, 818, 994, 81, 51, 905, 959, 231, 543, 730, 954, 672, 73, 562, 157, 263, 10003, 596, 834, 690, 210, 231, 185, 180, 581, 883, 459, 238, 208, 98, 988, 418, 806, 321, 985, 183, 749, 427, 538, 491, 51, 74, 306, 722, 28, 399, 268, 611, 441, 10, 321, 849, 733, 228, 735, 411, 883, 345, 751, 753, 896, 91, 627, 737, 969, 529, 274, 56, 168, 716, 789, 132, 176, 616, 69, 319, 525, 284, 530, 68, 23, 214, 617, 628, 68, 718, 526, 408, 851, 636, 743, 142, 237, 930, 110, 199, 158, 598, 323, 847, 621, 392, 982, 112, 515, 309, 504, 129, 915, 328, 328, 677, 722, 427, 14, 608, 737, 865, 469, 961, 465, 413, 803, 875, 161, 561, 497, 114, 786, 293, 436, 999, 247, 410, 845, 575, 444, 454, 692, 746, 965, 423, 711, 579, 614, 405, 643, 132, 466, 347, 152, 474, 215, 645, 369, 369, 576, 603, 305, 807, 799, 720, 958, 845, 904, 292, 91, 764, 82, 99, 408, 816, 260, 982, 595, 437, 301, 261, 438, 871, 429, 864, 538, 765, 702, 380, 792, 713, 692, 103, 668, 554, 106, 448, 41, 514, 668, 847, 68, 812, 414, 666, 825, 548, 882, 531, 65, 260, 317, 85, 180772, 266, 585, 210, 13, 437, 436, 792, 653, 494, 156, 845, 29, 493, 994, 225, 184, 397, 48, 733, 851, 496, 42571, 34, 103, 686, 638, 666, 604, 99, 615, 481, 752, 508, 129, 445, 486, 528, 412, 803, 128, 63, 317, 796, 750, 394, 654, 739, 528, 869, 831, 341, 713, 638, 229, 329, 548, 641, 907, 288, 326, 202, 875, 867, 506, 494, 637, 840, 486, 150, 996, 991, 293, 170, 842, 790, 471, 707, 298, 269, 768, 961, 219, 679, 968, 955, 908, 458, 59, 640, 704, 785, 524, 427, 679, 857, 836, 917, 154, 24, 485, 565, 30, 776, 688, 54, 161, 158, 433, 211, 220, 947, 414, 819, 611, 873, 315, 334, 690, 888, 63, 487, 135, 608, 589, 121, 761, 394, 369, 177, 197, 101, 192, 363, 62, 330, 198, 485, 930, 693, 161, 214, 91, 395, 313, 1000, 949, 592, 65, 28, 886, 393, 359, 188, 698, 532, 824, 753, 506, 190, 409, 363, 13, 932, 630, 734, 84, 789, 523, 512, 593, 814, 324, 705, 814, 104, 579, 162, 648, 673, 974, 507, 882, 700, 714, 892, 41, 103, 129, 912, 491, 891, 5, 413, 233, 442, 997, 469, 141, 695, 680, 357, 449, 874, 421, 2, 351, 570, 319, 69, 814, 266, 540, 165, 443, 618, 980, 854, 18, 941, 565, 943, 110, 977, 255, 889, 810, 239, 216, 430, 566, 760, 236, 581, 808, 483, 926, 68, 368, 990, 987, 604, 926, 487, 197, 935, 502, 405, 639, 727, 385, 906, 762, 460, 148, 727, 270, 175, 546, 735, 160, 459, 828, 735, 915, 326, 102, 772, 405, 208, 35, 496, 691, 187, 851, 543, 63, 13, 393, 857, 14, 399, 668, 942, 554, 910, 411, 952, 620, 760, 103, 669, 416, 985, 408, 787, 830, 666, 570, 950, 944, 723, 791, 422, 448, 565, 549, 819, 221, 282, 872, 47, 850, 667, 159, 102, 223, 831, 330, 24, 470, 701, 312, 787, 111, 281, 432, 967, 551, 831, 604, 875, 467, 533, 773, 196, 365, 363, 688, 885, 951, 391, 370, 648, 824, 600, 177, 477, 811, 290, 882, 297, 128, 862, 714, 99, 578, 905, 214, 920, 810, 426, 915, 786, 233, 743, 115, 436, 559, 137, 651, 172, 691, 845, 257, 733, 179, 991, 730, 345, 691, 534, 220, 128, 143, 265, 156, 711, 833, 193, 301, 129, 407, 819, 480, 42, 992, 474, 746, 46, 230, 38, 208, 579, 886, 854, 62, 782, 469, 201, 709, 334, 214, 400, 294, 211, 933, 848, 503, 468, 179, 702, 452, 645, 569, 82, 965, 833, 33, 962, 941, 527, 467, 536, 243, 576, 775, 353, 954, 940, 984, 667, 104, 160, 467, 607, 703, 451, 68, 333, 780, 29, 912, 373, 993, 695, 845, 682, 176, 29, 869, 42, 846, 898, 144, 60, 327, 283, 568, 746, 498, 176, 251, 933, 37, 832, 189, 475, 983, 156, 836, 522, 579, 637, 249, 294, 609, 115, 634, 492, 764, 381, 831, 698, 682, 410, 854, 509, 754, 116, 857, 312, 774, 959, 918, 943, 8, 573, 733, 241, 831, 319, 783, 193, 510, 943, 455, 977, 899, 109, 741, 37, 90, 47, 258, 219, 150, 750, 91, 473, 440, 768, 21, 864, 125, 404, 888, 120, 552, 551, 576, 704, 357, 896, 516, 156, 952, 577, 900, 168, 931, 731, 893, 628, 524, 66, 884, 292525, 547, 735, 899, 975, 498, 406, 151, 564, 827, 363, 862, 607, 130, 573, 793, 332, 818, 762, 418, 988, 288, 480, 141, 319, 678, 278, 516, 105, 849, 319, 961, 908, 751, 118, 825, 132, 757, 631, 294, 156, 586, 704, 42, 837, 464, 807, 52, 454, 818, 58, 491, 654, 113, 218, 959, 488, 868, 799, 131, 154, 192, 390, 199, 424, 46, 782, 540, 108, 558, 403, 327, 312, 726, 184, 805, 194, 423, 383, 260, 242, 9, 723, 142, 608, 579, 879, 560, 378, 419, 452, 992, 626, 496, 739, 148, 265, 791, 966, 937, 623, 754, 166, 30, 338, 35, 48, 322, 868, 552, 820, 354, 70, 471, 350, 746, 469, 53, 705, 870, 22, 72, 227, 856, 311, 33, 282, 697, 400, 25, 472, 967, 207, 863, 753, 583, 569, 954, 608, 768, 579, 462, 473, 154, 581, 234, 83, 467, 386, 64, 731, 446, 91, 610, 856, 880, 770, 446, 3, 199, 413, 384, 476, 427, 574, 641, 455, 46, 221, 565, 985, 457, 971, 805, 248, 899, 195, 50, 885, 872, 27, 112, 545, 696, 537, 388, 698, 612, 647, 923, 399, 177, 920, 621, 627, 768, 442, 684, 288, 414, 537, 573, 231, 476, 356, 222, 923, 759, 633, 858, 247, 452, 273, 632, 133, 449, 504, 859, 826, 799, 728, 252, 665, 801, 453, 423, 247, 401, 607, 918, 967, 460, 328, 318, 141, 34, 572, 899, 392, 712, 584, 919, 294, 924, 229, 73, 675, 1, 193, 257, 908, 388, 448, 45, 726, 510, 652, 608, 552, 258, 723, 145, 608, 603, 644, 925, 1, 367, 62, 712, 740, 234, 37, 370, 875, 500, 969, 107, 657, 358, 201, 595, 937, 155, 972, 584, 462, 61, 798, 917, 500, 993, 346, 60, 29, 854, 504, 121, 949, 218, 301, 196, 819, 747, 66, 285, 215, 89, 233, 177, 123, 717, 100, 568, 376, 842, 563, 996, 878, 5, 886, 198, 717, 659, 532, 695, 150, 439, 789, 433, 871, 80, 680, 139, 557, 8, 561, 148, 678, 90, 480, 321, 93, 130, 666, 25, 6102, 428, 945, 947, 682, 128, 499, 172, 423, 511, 72, 370, 548, 599, 66, 879, 678, 559, 784, 4, 22, 745, 660, 812, 599, 218, 683, 638, 411, 227, 405, 387, 323, 568, 785, 637, 626, 211, 193, 142, 517, 525, 812, 159, 725, 214, 165, 505, 173, 489, 249, 789, 394, 944, 934, 451, 697, 660, 100, 259, 486, 626, 872, 183, 102, 24, 152, 27, 63, 676, 928, 17, 699, 859, 227, 500, 988, 106, 723, 284, 792, 685, 829, 847, 912, 547, 306, 195, 584, 256, 413, 40, 656, 903, 53, 182, 751, 403, 225, 715, 218, 195, 726, 79, 222, 497, 519, 769, 64, 651, 413, 570, 682, 232, 144, 619, 688, 51, 739, 694, 402, 719, 393, 639, 661, 926, 462, 654, 274, 163, 165, 107, 631, 589, 758, 944, 647, 402, 201, 826, 193, 907, 966, 961, 155, 829, 645, 865, 543, 68931, 643, 693, 484, 894, 823, 423, 764, 644, 70, 419, 465, 383, 755, 701, 517, 610, 323, 883, 808, 183, 562, 712, 401, 918, 848, 602, 648, 740, 115, 542, 947, 362, 712, 115, 565, 803, 821, 499, 356, 674, 436, 396, 831, 933, 444, 766078, 380, 782, 78, 809, 781, 514, 811, 976, 530, 213, 705, 951, 648, 882, 229, 573, 645, 313, 495, 676, 473, 375, 861, 66, 312, 213, 877, 366, 524, 763, 260, 441, 768, 694, 854, 328, 127, 531, 993, 293, 172, 312, 554, 414, 688, 326, 62, 319, 3, 18, 920, 633, 422, 153, 626, 563, 6, 483, 880, 414, 999, 278, 245, 727, 613, 462, 948, 396, 204, 452, 24, 265, 162, 241, 335, 960, 413, 947, 235, 509, 26, 90, 339, 805, 471, 630, 592, 802, 897, 100, 605, 664, 755, 196, 956, 408, 262, 918, 380, 803, 332, 386, 786, 51, 562, 743, 42, 802, 467, 133, 908, 492, 610, 861, 308, 846, 838, 980, 577, 560, 473489, 734, 827, 166, 738, 998, 329, 364, 783, 557, 686, 81, 41, 933, 652, 378, 648, 268, 294, 378, 331, 257, 822, 807, 460, 153, 207, 785, 868, 704, 295, 296, 841, 104, 391, 382, 452, 322, 430, 235, 239, 2, 297, 282, 825, 386, 236, 918, 323, 920, 51, 993, 330, 829, 28, 560, 683, 784, 916, 113, 634, 143, 864, 758, 598, 77, 965, 511, 767, 121, 202, 908, 887, 436, 483, 992, 82, 431, 775, 352, 551, 616, 738, 195, 821, 859, 17, 931, 616, 509, 557, 978, 261, 663, 783, 188, 567, 872, 983, 434, 924, 957, 474, 327, 642, 422, 416, 71, 651, 807, 982, 679, 433, 57, 408, 233, 423, 969, 963, 595, 484, 999, 787, 656, 609, 173, 568, 432, 874, 314, 624, 691, 991, 385, 397, 730, 127, 809, 152, 291, 93, 753, 620, 341, 503, 349, 265, 698, 600, 832, 577, 320, 830, 778, 900, 692, 525, 517, 230, 790, 958, 293, 534, 923, 147, 57, 529, 81, 471, 837, 934, 957, 34, 189, 117, 592, 400, 907, 482, 76, 810, 804, 411, 255, 132, 974, 833, 334, 484, 393, 101, 657, 744, 829, 345, 844, 313, 640, 725, 944, 111, 526, 737, 777, 574, 276, 765, 954, 210, 630, 678, 95, 54, 510, 329, 849, 532, 910, 404, 516, 825, 591, 204, 578, 384, 395, 966, 923, 618, 674, 308, 896, 920, 853, 492, 268, 934, 847, 615, 787, 193, 800, 67, 127, 180, 582, 403, 934, 762, 591, 699, 657, 772, 823, 127, 81, 666, 117, 328, 460, 902, 549, 489, 704, 774, 704, 185, 111, 517, 640, 872, 643, 868, 896, 483, 735, 561, 619, 174, 408, 645, 962, 863, 304, 68, 995, 336, 856, 210, 439, 373, 935, 340, 861, 755, 182, 543, 743, 342, 364, 975, 964, 82, 81, 880, 865, 381, 488, 653, 522, 539, 542, 160, 562, 933, 759, 96, 43, 989, 337, 627, 409, 594, 446, 187, 158, 956, 658, 628, 390, 308, 472, 178, 640, 283, 226, 364, 187, 16, 516, 590, 434, 260, 541, 733, 621, 294, 69, 664, 609, 565, 842, 348, 368, 961, 532, 544, 957, 974, 158, 455, 90, 328, 759, 735, 949, 881, 290, 523, 4, 804, 103, 668, 26317, 971, 772, 450, 362, 801, 317, 358, 946, 191, 674, 212, 72, 235}, + 4695, + }, + + { + []int{2, 1, 2}, + 5, + }, + + { + []int{1, 2, 1}, + 0, + }, + + { + []int{3, 2, 3, 4}, + 10, + }, + + { + []int{3, 6, 2, 3}, + 8, + }, + + // 可以有多个 testcase +} + +func Test_largestPerimeter(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, largestPerimeter(tc.A), "输入:%v", tc) + } +} + +func Benchmark_largestPerimeter(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + largestPerimeter(tc.A) + } + } +} + +func Test_intHeap(t *testing.T) { + ast := assert.New(t) + + ih := new(intHeap) + heap.Init(ih) + + heap.Push(ih, 1) + heap.Pop(ih) + + begin, end := 10, 0 + for i := begin; i > end; i-- { + heap.Push(ih, i) + ast.Equal(begin, (*ih)[0], "插入 %d 后的最小值却是 %d,ih=%v", i, (*ih)[0], (*ih)) + } +} diff --git a/Algorithms/0977.squares-of-a-sorted-array/README.md b/Algorithms/0977.squares-of-a-sorted-array/README.md new file mode 100755 index 000000000..87de3ccc1 --- /dev/null +++ b/Algorithms/0977.squares-of-a-sorted-array/README.md @@ -0,0 +1,23 @@ +# [977. Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array/) + +Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. + +Example 1: + +```text +Input: [-4,-1,0,3,10] +Output: [0,1,9,16,100] +``` + +Example 2: + +```text +Input: [-7,-3,2,3,11] +Output: [4,9,9,49,121] +``` + +Note: + +- 1 <= A.length <= 10000 +- -10000 <= A[i] <= 10000 +- A is sorted in non-decreasing order. diff --git a/Algorithms/0977.squares-of-a-sorted-array/squares-of-a-sorted-array.go b/Algorithms/0977.squares-of-a-sorted-array/squares-of-a-sorted-array.go new file mode 100755 index 000000000..12cfbf849 --- /dev/null +++ b/Algorithms/0977.squares-of-a-sorted-array/squares-of-a-sorted-array.go @@ -0,0 +1,16 @@ +package problem0977 + +func sortedSquares(A []int) []int { + size := len(A) + res := make([]int, size) + for l, r, i := 0, size-1, size-1; l <= r; i-- { + if A[l]+A[r] < 0 { + res[i] = A[l] * A[l] + l++ + } else { + res[i] = A[r] * A[r] + r-- + } + } + return res +} diff --git a/Algorithms/0977.squares-of-a-sorted-array/squares-of-a-sorted-array_test.go b/Algorithms/0977.squares-of-a-sorted-array/squares-of-a-sorted-array_test.go new file mode 100755 index 000000000..26cb45044 --- /dev/null +++ b/Algorithms/0977.squares-of-a-sorted-array/squares-of-a-sorted-array_test.go @@ -0,0 +1,42 @@ +package problem0977 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans []int +}{ + + { + []int{-4, -1, 0, 3, 10}, + []int{0, 1, 9, 16, 100}, + }, + + { + []int{-7, -3, 2, 3, 11}, + []int{4, 9, 9, 49, 121}, + }, + + // 可以有多个 testcase +} + +func Test_sortedSquares(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, sortedSquares(tc.A), "输入:%v", tc) + } +} + +func Benchmark_sortedSquares(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + sortedSquares(tc.A) + } + } +} diff --git a/Algorithms/0978.longest-turbulent-subarray/README.md b/Algorithms/0978.longest-turbulent-subarray/README.md new file mode 100755 index 000000000..365c4f042 --- /dev/null +++ b/Algorithms/0978.longest-turbulent-subarray/README.md @@ -0,0 +1,37 @@ +# [978. Longest Turbulent Subarray](https://leetcode.com/problems/longest-turbulent-subarray/) + +A subarray A[i], A[i+1], ..., A[j] of A is said to be turbulent if and only if: + +- For i <= k < j, A[k] > A[k+1] when k is odd, and A[k] < A[k+1] when k is even; +- OR, for i <= k < j, A[k] > A[k+1] when k is even, and A[k] < A[k+1] when k is odd. + +That is, the subarray is turbulent if the comparison sign flips between each adjacent pair of elements in the subarray. + +Return the length of a maximum size turbulent subarray of A. + +Example 1: + +```text +Input: [9,4,2,10,7,8,8,1,9] +Output: 5 +Explanation: (A[1] > A[2] < A[3] > A[4] < A[5]) +``` + +Example 2: + +```text +Input: [4,8,12,16] +Output: 2 +``` + +Example 3: + +```text +Input: [100] +Output: 1 +``` + +Note: + +- `1 <= A.length <= 40000` +- `0 <= A[i] <= 10^9` \ No newline at end of file diff --git a/Algorithms/0978.longest-turbulent-subarray/longest-turbulent-subarray.go b/Algorithms/0978.longest-turbulent-subarray/longest-turbulent-subarray.go new file mode 100755 index 000000000..2df153e8e --- /dev/null +++ b/Algorithms/0978.longest-turbulent-subarray/longest-turbulent-subarray.go @@ -0,0 +1,29 @@ +package problem0978 + +func maxTurbulenceSize(A []int) int { + size := len(A) + greater, less := 1, 1 + + res := 1 + for i := 1; i < size; i++ { + switch { + case A[i] > A[i-1]: + greater, less = less+1, 1 + res = max(res, greater) + case A[i] < A[i-1]: + greater, less = 1, greater+1 + res = max(res, less) + default: + greater, less = 1, 1 + } + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/0978.longest-turbulent-subarray/longest-turbulent-subarray_test.go b/Algorithms/0978.longest-turbulent-subarray/longest-turbulent-subarray_test.go new file mode 100755 index 000000000..01bf18622 --- /dev/null +++ b/Algorithms/0978.longest-turbulent-subarray/longest-turbulent-subarray_test.go @@ -0,0 +1,52 @@ +package problem0978 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{20139, 81378, 2481, 28634, 85929, 85544, 11925, 81989, 7988, 37255, 40179, 47403, 94119, 6931, 3304, 75116, 50953, 93923, 81930, 41072, 46267, 68680, 30665, 87113, 62556, 7249, 18549, 1108, 35840, 62910, 44416, 22825, 76705, 48168, 41182, 33930, 59080, 34150, 33752, 27250, 74819, 72764, 55778, 56126, 4923, 67219, 41218, 51928, 10800, 94338, 91010, 95816, 45597, 66196, 71747, 52922, 80013, 10182, 92174, 85162, 14454, 18610, 39339, 306, 8871, 10989, 88613, 53278, 72922, 36100, 87781, 69307, 13328, 98190, 42436, 13520, 64108, 64795, 4818, 91292, 13155, 3426, 96600, 85766, 41274, 79233, 82614, 62669, 97029, 81057, 48849, 97685, 49839, 10409, 29065, 20971, 30892, 61282, 98880, 67105, 28467, 80970, 66076, 18107, 3276, 79580, 14735, 36963, 91245, 85521, 45441, 95433, 20430, 13999, 46839, 78945, 32718, 33941, 48678, 15896, 22562, 95700, 26561, 25933, 34842, 98885, 67743, 11996, 66772, 5194, 38699, 45603, 45191, 98644, 92604, 33101, 20905, 75126, 85263, 24435, 61183, 54394, 80186, 29349, 29650, 57012, 90807, 88477, 27804, 79343, 40709, 42410, 62688, 69311, 39682, 40963, 6186, 90101, 34797, 5410, 716, 77274, 98522, 9160, 38232, 58672, 56217, 34966, 30595, 79824, 809, 6595, 26654, 42070, 35002, 7579, 62773, 70071, 8772, 41796, 8819, 14086, 56487, 41363, 69728, 31593, 80875, 56537, 17372, 58755, 19375, 12407, 79353, 535, 60473, 77764, 98245, 97424, 79759, 7828, 13750, 25941, 32374, 54229, 53714, 91022, 45100, 19214, 92129, 63116, 81637, 95268, 41570, 17715, 64053, 79299, 12488, 57232, 80971, 28074, 16441, 32193, 8294, 30185, 51114, 92038, 93200, 93357, 11902, 4217, 29573, 16439, 15088, 13456, 91914, 69965, 73598, 97441, 65685, 47628, 82870, 98093, 12624, 74031, 86151, 88050, 27629, 18618, 90372, 16509, 73908, 45923, 24820, 92050, 86334, 51169, 96130, 68862, 90565, 99035, 31139, 43080, 19527, 22126, 52570, 67275, 41297, 6841, 64025, 84302, 67465, 43908, 72003, 33119, 37463, 32594, 53008, 61277, 12135, 58373, 14786, 38086, 2409, 94779, 77012, 36251, 53924, 64455, 89145, 39912, 44422, 61621, 95925, 11694, 22307, 67557, 28283, 90177, 57970, 92925, 39727, 85606, 74021, 35409, 13675, 55752, 59754, 26485, 65186, 63562, 95981, 43829, 60831, 75901, 30843, 76193, 12673, 62257, 75911, 51253, 73307, 85258, 10560, 82780, 60264, 36420, 77372, 86750, 79009, 40498, 97559, 49100, 59836, 45574, 70547, 80846, 25848, 68446, 7010, 51820, 59259, 11797, 57183, 48446, 75342, 15858, 89528, 24695, 41419, 93599, 91731, 24959, 31037, 39878, 40782, 54487, 47934, 60543, 98867, 20184, 51586, 80185, 38564, 68384, 32141, 79869, 49773, 29870, 86621, 77913, 52300, 22461, 32280, 64883, 58425, 93513, 34571, 47020, 62967, 62712, 69321, 57617, 79972, 25874, 76169, 4861, 40785, 97328, 48078, 26060, 89027, 84068, 54302, 6611, 95452, 73801, 64327, 82294, 17874, 29691, 56774, 13041, 51381, 60067, 28985, 68765, 62969, 84317, 11595, 96079, 26155, 52199, 60927, 34067, 52257, 99249, 23139, 21073, 67338, 28650, 17358, 29576, 21963, 36531, 67171, 16919, 91135, 49328, 56508, 58782, 67571, 33131, 770, 82401, 70343, 69458, 1919, 28242, 55176, 30551, 31062, 6550, 27307, 97978, 69092, 46089, 75003, 65981, 26942, 17891, 88438, 4246, 18844, 90363, 2977, 66344, 43914, 4381, 67111, 3164, 98882, 91404, 32457, 97178, 65449, 32245, 81454, 52740, 39882, 22707, 64533, 339, 17746, 13391, 83531, 34339, 18509, 35441, 13839, 8171, 17351, 23950, 99939, 38085, 2109, 35990, 95542, 36995, 60809, 49967, 82694, 49709, 94552, 82415, 46432, 99104, 52606, 12130, 69340, 57495, 65080, 24299, 74950, 78718, 5435, 79494, 31201, 71679, 86026, 67747, 72258, 37981, 9688, 85010, 1502, 94475, 93644, 11139, 69555, 51447, 34953, 26662, 25419, 65371, 12880, 19043, 3964, 8336, 35820, 46590, 21988, 23248, 5364, 82818, 73406, 695, 55645, 56518, 59658, 34621, 63758, 85722, 20188, 4198, 49056, 73439, 12949, 289, 31196, 25091, 69448, 58028, 80680, 56125, 15674, 67118, 61294, 3862, 73116, 31820, 59603, 16544, 9089, 81244, 88506, 72150, 59579, 14687, 93785, 75583, 20946, 71087, 11674, 98081, 39599, 93460, 70077, 38979, 32410, 61753, 48637, 6954, 69955, 82836, 63285, 29290, 95643, 92897, 82369, 24412, 36913, 13115, 21376, 20964, 57305, 79406, 57722, 93586, 4504, 90900, 27551, 75142, 63237, 14041, 77415, 65666, 67419, 37078, 76698, 15348, 43514, 32368, 99733, 44548, 60610, 6389, 36541, 62252, 98414, 69623, 95400, 54341, 50210, 40190, 89464, 22708, 7095, 84440, 922, 97577, 82271, 15107, 50741, 46367, 73469, 68993, 6175, 43446, 70868, 28613, 22836, 33476, 30297, 87449, 85760, 9882, 7406, 63073, 28830, 4738, 91077, 55475, 77649, 4174, 42388, 52023, 79618, 50322, 17230, 20529, 17767, 66081, 53297, 18552, 86257, 33838, 18280, 49613, 67985, 81479, 448, 52160, 79004, 63067, 9618, 75765, 44260, 66192, 36524, 17567, 10397, 81169, 68445, 62018, 99910, 73379, 77054, 49780, 51559, 14687, 57187, 63379, 13994, 71408, 16989, 11855, 67869, 64592, 27893, 64456, 65298, 39117, 39198, 93968, 48419, 52532, 80370, 95860, 71813, 60456, 85372, 303, 3612, 18575, 47183, 44976, 62503, 9746, 63893, 83975, 23025, 89258, 92656, 46055, 16351, 88855, 98410, 15191, 34798, 38190, 90573, 58033, 54836, 28727, 9271, 63777, 84166, 95664, 58837, 91986, 93282, 30759, 62791, 96579, 28709, 47520, 11115, 86163, 76649, 50336, 46519, 79361, 17889, 64283, 64258, 15953, 43339, 4516, 16714, 24556, 59334, 49766, 28566, 86857, 63180, 74243, 24025, 5610, 46536, 24659, 44253, 62337, 6102, 28004, 90987, 66166, 98254, 96571, 35091, 78858, 75288, 72752, 72174, 41054, 93939, 67181, 51546, 42975, 50003, 43166, 71553, 88350, 41698, 91823, 19743, 66010, 92326, 48883, 94325, 32340, 71674, 66734, 99908, 68658, 85600, 2364, 8935, 51434, 73008, 51013, 91720, 68502, 38855, 30741, 3599, 98269, 55479, 61111, 21924, 86615, 38257, 60324, 12332, 5496, 59115, 98235, 75811, 80167, 59842, 55219, 61783, 78213, 68607, 45196, 99910, 12115, 74026, 65133, 85669, 58830, 7874, 52273, 905, 17113, 92318, 48665, 23757, 88982, 59104, 58854, 24440, 45818, 24233, 92150, 5163, 74797, 54739, 78398, 10427, 8588, 99036, 84902, 21853, 62113, 66871, 3056, 66940, 47871, 29681, 7525, 90227, 69785, 84291, 78045, 62721, 6455, 87153, 22132, 61421, 32966, 27617, 367, 76783, 4064, 40051, 38900, 23586, 9940, 33628, 94744, 1018, 74325, 20074, 38922, 85815, 21241, 78584, 90979, 43693, 31594, 16227, 87154, 37796, 52087, 90036, 88169, 33623, 6744, 58251, 7075, 71285, 81930, 98005, 99071, 28785, 57210, 4003, 47285, 72816, 21207, 83522, 11522, 97080, 95298, 73063, 17077, 53433, 39906, 75360, 80261, 32911, 34362, 91937, 76128, 5575, 76188, 79358, 20550, 49751, 80698, 65202, 71366, 57213, 24463, 35084, 78217, 68818, 74858, 89972, 72356, 47569, 46271, 67991, 94929, 55258, 66948, 65980, 76357, 88020, 6724, 91021, 85711, 39035, 23591, 1905, 99605, 86916, 50648, 58231, 12914, 74923, 41625, 25127, 75880, 73858, 25555, 21205, 96715, 35761, 20753, 86494, 19774, 23901, 86096, 74887, 43040, 45424, 29167, 97408, 14963, 51128, 73815, 90506, 11081, 32912, 78214, 56075, 42651, 77394, 76566}, + 15, + }, + + { + []int{9, 4, 2, 10, 7, 8, 8, 1, 9}, + 5, + }, + + { + []int{4, 8, 12, 16}, + 2, + }, + + { + []int{100}, + 1, + }, + + // 可以有多个 testcase +} + +func Test_maxTurbulenceSize(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxTurbulenceSize(tc.A), "输入:%v", tc) + } +} + +func Benchmark_maxTurbulenceSize(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxTurbulenceSize(tc.A) + } + } +} diff --git a/Algorithms/0979.distribute-coins-in-binary-tree/1.png b/Algorithms/0979.distribute-coins-in-binary-tree/1.png new file mode 100644 index 000000000..b351a843e Binary files /dev/null and b/Algorithms/0979.distribute-coins-in-binary-tree/1.png differ diff --git a/Algorithms/0979.distribute-coins-in-binary-tree/2.png b/Algorithms/0979.distribute-coins-in-binary-tree/2.png new file mode 100644 index 000000000..840174598 Binary files /dev/null and b/Algorithms/0979.distribute-coins-in-binary-tree/2.png differ diff --git a/Algorithms/0979.distribute-coins-in-binary-tree/3.png b/Algorithms/0979.distribute-coins-in-binary-tree/3.png new file mode 100644 index 000000000..add2ff713 Binary files /dev/null and b/Algorithms/0979.distribute-coins-in-binary-tree/3.png differ diff --git a/Algorithms/0979.distribute-coins-in-binary-tree/4.png b/Algorithms/0979.distribute-coins-in-binary-tree/4.png new file mode 100644 index 000000000..c5c30f59e Binary files /dev/null and b/Algorithms/0979.distribute-coins-in-binary-tree/4.png differ diff --git a/Algorithms/0979.distribute-coins-in-binary-tree/README.md b/Algorithms/0979.distribute-coins-in-binary-tree/README.md new file mode 100755 index 000000000..d215b654b --- /dev/null +++ b/Algorithms/0979.distribute-coins-in-binary-tree/README.md @@ -0,0 +1,50 @@ +# [979. Distribute Coins in Binary Tree](https://leetcode.com/problems/distribute-coins-in-binary-tree/) + +Given the root of a binary tree with N nodes, each node in the tree has node.val coins, and there are N coins total. + +In one move, we may choose two adjacent nodes and move one coin from one node to another. (The move may be from parent to child, or from child to parent.) + +Return the number of moves required to make every node have exactly one coin. + +Example 1: + +![1](1.png) + +```text +Input: [3,0,0] +Output: 2 +Explanation: From the root of the tree, we move one coin to its left child, and one coin to its right child. +``` + +Example 2: + +![2](2.png) + +```text +Input: [0,3,0] +Output: 3 +Explanation: From the left child of the root, we move two coins to the root [taking two moves]. Then, we move one coin from the root of the tree to the right child. +``` + +Example 3: + +![3](3.png) + +```text +Input: [1,0,2] +Output: 2 +``` + +Example 4: + +![4](4.png) + +```text +Input: [1,0,0,null,3] +Output: 4 +``` + +Note: + +- `1<= N <= 100` +- `0 <= node.val <= N` \ No newline at end of file diff --git a/Algorithms/0979.distribute-coins-in-binary-tree/distribute-coins-in-binary-tree.go b/Algorithms/0979.distribute-coins-in-binary-tree/distribute-coins-in-binary-tree.go new file mode 100755 index 000000000..8524e891e --- /dev/null +++ b/Algorithms/0979.distribute-coins-in-binary-tree/distribute-coins-in-binary-tree.go @@ -0,0 +1,28 @@ +package problem0979 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +func distributeCoins(root *TreeNode) int { + res := 0 + dfs(root, &res) + return res +} + +func dfs(node *TreeNode, res *int) int { + if node == nil { + return 0 + } + l, r := dfs(node.Left, res), dfs(node.Right, res) + *res += abs(l) + abs(r) + return l + r + node.Val - 1 +} + +func abs(a int) int { + if a < 0 { + return -a + } + return a +} diff --git a/Algorithms/0979.distribute-coins-in-binary-tree/distribute-coins-in-binary-tree_test.go b/Algorithms/0979.distribute-coins-in-binary-tree/distribute-coins-in-binary-tree_test.go new file mode 100755 index 000000000..8752bf634 --- /dev/null +++ b/Algorithms/0979.distribute-coins-in-binary-tree/distribute-coins-in-binary-tree_test.go @@ -0,0 +1,55 @@ +package problem0979 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans int +}{ + + { + []int{3, 0, 0}, + 2, + }, + + { + []int{0, 3, 0}, + 3, + }, + + { + []int{1, 0, 2}, + 2, + }, + + { + []int{1, 0, 0, kit.NULL, 3}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_distributeCoins(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, distributeCoins(root), "输入:%v", tc) + } +} + +func Benchmark_distributeCoins(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + distributeCoins(root) + } + } +} diff --git a/Algorithms/0980.unique-paths-iii/README.md b/Algorithms/0980.unique-paths-iii/README.md new file mode 100755 index 000000000..a64ad0c07 --- /dev/null +++ b/Algorithms/0980.unique-paths-iii/README.md @@ -0,0 +1,46 @@ +# [980. Unique Paths III](https://leetcode.com/problems/unique-paths-iii/) + +On a 2-dimensional `grid`, there are 4 types of squares: + +- `1` represents the starting square. There is exactly one starting square. +- `2` represents the ending square. There is exactly one ending square. +- `0` represents empty squares we can walk over. +- `-1` represents obstacles that we cannot walk over. + +Return the number of 4-directional walks from the starting square to the ending square, that **walk over every non-obstacle square exactly once**. + +Example 1: + +```text +Input: [[1,0,0,0],[0,0,0,0],[0,0,2,-1]] +Output: 2 +Explanation: We have the following two paths: +1. (0,0),(0,1),(0,2),(0,3),(1,3),(1,2),(1,1),(1,0),(2,0),(2,1),(2,2) +2. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2) +``` + +Example 2: + +```text +Input: [[1,0,0,0],[0,0,0,0],[0,0,0,2]] +Output: 4 +Explanation: We have the following four paths: +1. (0,0),(0,1),(0,2),(0,3),(1,3),(1,2),(1,1),(1,0),(2,0),(2,1),(2,2),(2,3) +2. (0,0),(0,1),(1,1),(1,0),(2,0),(2,1),(2,2),(1,2),(0,2),(0,3),(1,3),(2,3) +3. (0,0),(1,0),(2,0),(2,1),(2,2),(1,2),(1,1),(0,1),(0,2),(0,3),(1,3),(2,3) +4. (0,0),(1,0),(2,0),(2,1),(1,1),(0,1),(0,2),(0,3),(1,3),(1,2),(2,2),(2,3) +``` + +Example 3: + +```text +Input: [[0,1],[2,0]] +Output: 0 +Explanation: +There is no path that walks over every empty square exactly once. +Note that the starting and ending square can be anywhere in the grid. +``` + +Note: + +1. `1 <= grid.length * grid[0].length <= 20` \ No newline at end of file diff --git a/Algorithms/0980.unique-paths-iii/unique-paths-iii.go b/Algorithms/0980.unique-paths-iii/unique-paths-iii.go new file mode 100755 index 000000000..ba03e707e --- /dev/null +++ b/Algorithms/0980.unique-paths-iii/unique-paths-iii.go @@ -0,0 +1,58 @@ +package problem0980 + +var dx = []int{0, 0, 1, -1} +var dy = []int{1, -1, 0, 0} + +func uniquePathsIII(grid [][]int) int { + m, n := len(grid), len(grid[0]) + + queue := make([][2]int, 0, m*n*10) + paths := make([]int, 0, m*n*10) + allWalked := 0 + + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + switch grid[i][j] { + case 0: + allWalked |= 1 << uint(i*n+j) + case 1: + allWalked |= 1 << uint(i*n+j) + queue = append(queue, [2]int{i, j}) + paths = append(paths, 1< 0 { + size := len(queue) + for s := 0; s < size; s++ { + x, y := queue[s][0], queue[s][1] + path := paths[s] + for k := 0; k < 4; k++ { + i, j := x+dx[k], y+dy[k] + if i < 0 || m <= i || + j < 0 || n <= j || + path&(1< b { + return a + } + return b +} + +func min(a, b, c int) int { + if a <= b && a <= c { + return a + } + if b <= a && b <= c { + return b + } + return c +} diff --git a/Algorithms/0983.minimum-cost-for-tickets/minimum-cost-for-tickets_test.go b/Algorithms/0983.minimum-cost-for-tickets/minimum-cost-for-tickets_test.go new file mode 100755 index 000000000..e21f4f514 --- /dev/null +++ b/Algorithms/0983.minimum-cost-for-tickets/minimum-cost-for-tickets_test.go @@ -0,0 +1,90 @@ +package problem0983 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + days []int + costs []int + ans int +}{ + + { + []int{1, 4, 6, 7, 8, 20}, + []int{7, 2, 15}, + 6, + }, + + { + []int{1, 4, 6, 7, 8, 20}, + []int{2, 7, 15}, + 11, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 30, 31}, + []int{2, 7, 15}, + 17, + }, + + // 可以有多个 testcase +} + +func Test_mincostTickets(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, mincostTickets(tc.days, tc.costs), "输入:%v", tc) + } +} + +func Benchmark_mincostTickets(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + mincostTickets(tc.days, tc.costs) + } + } +} + +func Test_min(t *testing.T) { + type args struct { + a int + b int + c int + } + tests := []struct { + name string + args args + want int + }{ + + { + "a 最小", + args{a: 0, b: 1, c: 2}, + 0, + }, + + { + "b 最小", + args{a: 1, b: 0, c: 2}, + 0, + }, + + { + "c 最小", + args{a: 2, b: 1, c: 0}, + 0, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := min(tt.args.a, tt.args.b, tt.args.c); got != tt.want { + t.Errorf("min() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/Algorithms/0984.string-without-aaa-or-bbb/README.md b/Algorithms/0984.string-without-aaa-or-bbb/README.md new file mode 100755 index 000000000..55efc24c0 --- /dev/null +++ b/Algorithms/0984.string-without-aaa-or-bbb/README.md @@ -0,0 +1,27 @@ +# [984. String Without AAA or BBB](https://leetcode.com/problems/string-without-aaa-or-bbb/) + +Given two integers A and B, return any string S such that: + +S has length A + B and contains exactly A 'a' letters, and exactly B 'b' letters; +The substring 'aaa' does not occur in S; +The substring 'bbb' does not occur in S. + +Example 1: + +```text +Input: A = 1, B = 2 +Output: "abb" +Explanation: "abb", "bab" and "bba" are all correct answers. +``` + +Example 2: + +```text +Input: A = 4, B = 1 +Output: "aabaa" + +Note: + +- 0 <= A <= 100 +- 0 <= B <= 100 +- It is guaranteed such an S exists for the given A and B. diff --git a/Algorithms/0984.string-without-aaa-or-bbb/string-without-aaa-or-bbb.go b/Algorithms/0984.string-without-aaa-or-bbb/string-without-aaa-or-bbb.go new file mode 100755 index 000000000..01314f328 --- /dev/null +++ b/Algorithms/0984.string-without-aaa-or-bbb/string-without-aaa-or-bbb.go @@ -0,0 +1,29 @@ +package problem0984 + +import "strings" + +func strWithout3a3b(A int, B int) string { + var sb strings.Builder + sb.Grow(A + B) + + a, b := byte('a'), byte('b') + if A < B { + A, B = B, A + a, b = b, a + } + + for A > 0 { + sb.WriteByte(a) + A-- + if A > B { + sb.WriteByte(a) + A-- + } + if B > 0 { + sb.WriteByte(b) + B-- + } + } + + return sb.String() +} diff --git a/Algorithms/0984.string-without-aaa-or-bbb/string-without-aaa-or-bbb_test.go b/Algorithms/0984.string-without-aaa-or-bbb/string-without-aaa-or-bbb_test.go new file mode 100755 index 000000000..953439c9e --- /dev/null +++ b/Algorithms/0984.string-without-aaa-or-bbb/string-without-aaa-or-bbb_test.go @@ -0,0 +1,78 @@ +package problem0984 + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A int + B int + ans string +}{ + + { + 1, + 2, + "abb", + }, + + { + 1, + 3, + "bbab", + }, + + { + 4, + 1, + "aabaa", + }, + + { + 2, + 5, + "bbabbab", + }, + + { + 2, + 6, + "bbabbabb", + }, + + // 可以有多个 testcase +} + +func isCorrect(A, B int, s string) bool { + if A+B != len(s) || + len(strings.Replace(s, "a", "", -1)) != B || + len(strings.Replace(s, "b", "", -1)) != A { + return false + } + if strings.Contains(s, "aaa") || + strings.Contains(s, "bbb") { + return false + } + return true +} + +func Test_strWithout3a3b(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + str := strWithout3a3b(tc.A, tc.B) + ast.True(isCorrect(tc.A, tc.B, str), "A = %d, B = %d, %s", tc.A, tc.B, str) + } +} + +func Benchmark_strWithout3a3b(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + strWithout3a3b(tc.A, tc.B) + } + } +} diff --git a/Algorithms/0985.sum-of-even-numbers-after-queries/README.md b/Algorithms/0985.sum-of-even-numbers-after-queries/README.md new file mode 100755 index 000000000..b093d2deb --- /dev/null +++ b/Algorithms/0985.sum-of-even-numbers-after-queries/README.md @@ -0,0 +1,30 @@ +# [985. Sum of Even Numbers After Queries](https://leetcode.com/problems/sum-of-even-numbers-after-queries/) + +We have an array `A` of integers, and an array queries of queries. + +For the `i-th` query `val = queries[i][0]`, `index = queries[i][1]`, we add val to `A[index]`. Then, the answer to the `i-th` query is the sum of the even values of A. + +(Here, the given `index = queries[i][1]` is a 0-based index, and each query permanently modifies the array `A`.) + +Return the answer to all queries. Your `answer` array should have `answer[i]` as the answer to the i-th query. + +Example 1: + +```text +Input: A = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],[2,3]] +Output: [8,6,2,4] +Explanation: +At the beginning, the array is [1,2,3,4]. +After adding 1 to A[0], the array is [2,2,3,4], and the sum of even values is 2 + 2 + 4 = 8. +After adding -3 to A[1], the array is [2,-1,3,4], and the sum of even values is 2 + 4 = 6. +After adding -4 to A[0], the array is [-2,-1,3,4], and the sum of even values is -2 + 4 = 2. +After adding 2 to A[3], the array is [-2,-1,3,6], and the sum of even values is -2 + 6 = 4. +``` + +Note: + +- 1 <= A.length <= 10000 +- -10000 <= A[i] <= 10000 +- 1 <= queries.length <= 10000 +- -10000 <= queries[i][0] <= 10000 +- 0 <= queries[i][1] < A.length \ No newline at end of file diff --git a/Algorithms/0985.sum-of-even-numbers-after-queries/sum-of-even-numbers-after-queries.go b/Algorithms/0985.sum-of-even-numbers-after-queries/sum-of-even-numbers-after-queries.go new file mode 100755 index 000000000..5f1017442 --- /dev/null +++ b/Algorithms/0985.sum-of-even-numbers-after-queries/sum-of-even-numbers-after-queries.go @@ -0,0 +1,27 @@ +package problem0985 + +func sumEvenAfterQueries(A []int, queries [][]int) []int { + res := make([]int, 0, len(A)) + + sumEven := 0 + for _, v := range A { + if v%2 == 0 { + sumEven += v + } + } + + for _, q := range queries { + v, i := q[0], q[1] + old, new := A[i], A[i]+v + if old%2 == 0 { + sumEven -= old + } + if new%2 == 0 { + sumEven += new + } + res = append(res, sumEven) + A[i] = new + } + + return res +} diff --git a/Algorithms/0985.sum-of-even-numbers-after-queries/sum-of-even-numbers-after-queries_test.go b/Algorithms/0985.sum-of-even-numbers-after-queries/sum-of-even-numbers-after-queries_test.go new file mode 100755 index 000000000..e808210dd --- /dev/null +++ b/Algorithms/0985.sum-of-even-numbers-after-queries/sum-of-even-numbers-after-queries_test.go @@ -0,0 +1,39 @@ +package problem0985 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + queries [][]int + ans []int +}{ + + { + []int{1, 2, 3, 4}, + [][]int{{1, 0}, {-3, 1}, {-4, 0}, {2, 3}}, + []int{8, 6, 2, 4}, + }, + + // 可以有多个 testcase +} + +func Test_sumEvenAfterQueries(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, sumEvenAfterQueries(tc.A, tc.queries), "输入:%v", tc) + } +} + +func Benchmark_sumEvenAfterQueries(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + sumEvenAfterQueries(tc.A, tc.queries) + } + } +} diff --git a/Algorithms/0986.interval-list-intersections/1.png b/Algorithms/0986.interval-list-intersections/1.png new file mode 100644 index 000000000..72102be2e Binary files /dev/null and b/Algorithms/0986.interval-list-intersections/1.png differ diff --git a/Algorithms/0986.interval-list-intersections/README.md b/Algorithms/0986.interval-list-intersections/README.md new file mode 100755 index 000000000..84a29a1cc --- /dev/null +++ b/Algorithms/0986.interval-list-intersections/README.md @@ -0,0 +1,23 @@ +# [986. Interval List Intersections](https://leetcode.com/problems/interval-list-intersections/) + +Given two lists of closed intervals, each list of intervals is pairwise disjoint and in sorted order. + +Return the intersection of these two interval lists. + +(Formally, a closed interval [a, b] (with a <= b) denotes the set of real numbers x with a <= x <= b. The intersection of two closed intervals is a set of real numbers that is either empty, or can be represented as a closed interval. For example, the intersection of [1, 3] and [2, 4] is [2, 3].) + +Example 1: + +![1](1.png) + +```text +Input: A = [[0,2],[5,10],[13,23],[24,25]], B = [[1,5],[8,12],[15,24],[25,26]] +Output: [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]] +Reminder: The inputs and the desired output are lists of Interval objects, and not arrays or lists. +``` + +Note: + +1. `0 <= A.length < 1000` +1. `0 <= B.length < 1000` +1. `0 <= A[i].start, A[i].end, B[i].start, B[i].end < 10^9` \ No newline at end of file diff --git a/Algorithms/0986.interval-list-intersections/interval-list-intersections.go b/Algorithms/0986.interval-list-intersections/interval-list-intersections.go new file mode 100755 index 000000000..b6e4364c3 --- /dev/null +++ b/Algorithms/0986.interval-list-intersections/interval-list-intersections.go @@ -0,0 +1,39 @@ +package problem0986 + +func intervalIntersection(A [][]int, B [][]int) [][]int { + sizeA, sizeB := len(A), len(B) + res := make([][]int, 0, sizeA+sizeB) + for i, j := 0, 0; i < sizeA && j < sizeB; { + switch { + case A[i][1] < B[j][0]: + i++ + case B[j][1] < A[i][0]: + j++ + default: + res = append(res, []int{ + max(A[i][0], B[j][0]), + min(A[i][1], B[j][1]), + }) + if A[i][1] < B[j][1] { + i++ + } else { + j++ + } + } + } + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0986.interval-list-intersections/interval-list-intersections_test.go b/Algorithms/0986.interval-list-intersections/interval-list-intersections_test.go new file mode 100755 index 000000000..4e47a3f02 --- /dev/null +++ b/Algorithms/0986.interval-list-intersections/interval-list-intersections_test.go @@ -0,0 +1,51 @@ +package problem0986 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A [][]int + B [][]int + ans [][]int +}{ + + { + [][]int{{0, 2}, {5, 10}, {13, 23}, {24, 25}}, + [][]int{{1, 2}, {8, 12}, {15, 24}, {25, 26}}, + [][]int{{1, 2}, {8, 10}, {15, 23}, {24, 24}, {25, 25}}, + }, + + { + [][]int{{0, 2}, {5, 10}, {13, 23}, {24, 25}}, + [][]int{{1, 5}, {8, 12}, {15, 24}, {25, 26}}, + [][]int{{1, 2}, {5, 5}, {8, 10}, {15, 23}, {24, 24}, {25, 25}}, + }, + + { + [][]int{{0, 2}, {5, 10}, {13, 23}, {24, 25}}, + [][]int{{1, 1}, {8, 12}, {15, 24}, {25, 26}}, + [][]int{{1, 1}, {8, 10}, {15, 23}, {24, 24}, {25, 25}}, + }, + + // 可以有多个 testcase +} + +func Test_intervalIntersection(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, intervalIntersection(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_intervalIntersection(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + intervalIntersection(tc.A, tc.B) + } + } +} diff --git a/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/1.png b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/1.png new file mode 100644 index 000000000..f276f30b6 Binary files /dev/null and b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/1.png differ diff --git a/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/2.png b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/2.png new file mode 100644 index 000000000..bc09c349f Binary files /dev/null and b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/2.png differ diff --git a/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/README.md b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/README.md new file mode 100755 index 000000000..d3812867f --- /dev/null +++ b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/README.md @@ -0,0 +1,43 @@ +# [987. Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/) + +Given a binary tree, return the vertical order traversal of its nodes values. + +For each node at position (X, Y), its left and right children respectively will be at positions (X-1, Y-1) and (X+1, Y-1). + +Running a vertical line from X = -infinity to X = +infinity, whenever the vertical line touches some nodes, we report the values of the nodes in order from top to bottom (decreasing Y coordinates). + +If two nodes have the same position, then the value of the node that is reported first is the value that is smaller. + +Return an list of non-empty reports in order of X coordinate. Every report will have a list of values of nodes. + +Example 1: + +![1](1.png) + +```text +Input: [3,9,20,null,null,15,7] +Output: [[9],[3,15],[20],[7]] +Explanation: +Without loss of generality, we can assume the root node is at position (0, 0): +Then, the node with value 9 occurs at position (-1, -1); +The nodes with values 3 and 15 occur at positions (0, 0) and (0, -2); +The node with value 20 occurs at position (1, -1); +The node with value 7 occurs at position (2, -2). +``` + +Example 2: + +![2](2.png) + +```text +Input: [1,2,3,4,5,6,7] +Output: [[4],[2],[1,5,6],[3],[7]] +Explanation: +The node with value 5 and the node with value 6 have the same position according to the given scheme. +However, in the report "[1,5,6]", the node value of 5 comes first since 5 is smaller than 6. +``` + +Note: + +- `The tree will have between 1 and 1000 nodes.` +- `Each node's value will be between 0 and 1000.` diff --git a/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/vertical-order-traversal-of-a-binary-tree.go b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/vertical-order-traversal-of-a-binary-tree.go new file mode 100755 index 000000000..13e8c900b --- /dev/null +++ b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/vertical-order-traversal-of-a-binary-tree.go @@ -0,0 +1,59 @@ +package problem0987 + +import ( + "sort" + + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +func verticalTraversal(root *TreeNode) [][]int { + ds := make([]data, 0, 1024) + dfs(root, 0, 0, &ds) + + sort.Slice(ds, func(i int, j int) bool { + if ds[i].x == ds[j].x { + if ds[i].y == ds[j].y { + return ds[i].value < ds[j].value + } + return ds[i].y > ds[j].y + } + return ds[i].x < ds[j].x + }) + + res := make([][]int, 0, len(ds)) + + x := ds[0].x + values := make([]int, 0, 10) + for _, d := range ds { + if x == d.x { + values = append(values, d.value) + continue + } + res = append(res, values) + values = append(make([]int, 0, 10), d.value) + x = d.x + } + res = append(res, values) + + return res +} + +type data struct { + value, x, y int +} + +func dfs(node *TreeNode, x, y int, dataSlice *[]data) { + if node == nil { + return + } + dfs(node.Left, x-1, y-1, dataSlice) + *dataSlice = append(*dataSlice, data{ + value: node.Val, + x: x, + y: y, + }) + dfs(node.Right, x+1, y-1, dataSlice) +} diff --git a/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/vertical-order-traversal-of-a-binary-tree_test.go b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/vertical-order-traversal-of-a-binary-tree_test.go new file mode 100755 index 000000000..d14d8d057 --- /dev/null +++ b/Algorithms/0987.vertical-order-traversal-of-a-binary-tree/vertical-order-traversal-of-a-binary-tree_test.go @@ -0,0 +1,50 @@ +package problem0987 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans [][]int +}{ + + { + []int{0, 2, 1, 3, kit.NULL, kit.NULL, kit.NULL, 4, 5, kit.NULL, 7, 6, kit.NULL, 10, 8, 11, 9}, + [][]int{{4, 10, 11}, {3, 6, 7}, {2, 5, 8, 9}, {0}, {1}}, + }, + + { + []int{3, 9, 20, kit.NULL, kit.NULL, 15, 7}, + [][]int{{9}, {3, 15}, {20}, {7}}, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7}, + [][]int{{4}, {2}, {1, 5, 6}, {3}, {7}}, + }, + + // 可以有多个 testcase +} + +func Test_verticalTraversal(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, verticalTraversal(root), "输入:%v", tc) + } +} + +func Benchmark_verticalTraversal(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + verticalTraversal(root) + } + } +} diff --git a/Algorithms/0988.smallest-string-starting-from-leaf/1.png b/Algorithms/0988.smallest-string-starting-from-leaf/1.png new file mode 100644 index 000000000..e858b9aa8 Binary files /dev/null and b/Algorithms/0988.smallest-string-starting-from-leaf/1.png differ diff --git a/Algorithms/0988.smallest-string-starting-from-leaf/2.png b/Algorithms/0988.smallest-string-starting-from-leaf/2.png new file mode 100644 index 000000000..b38b85868 Binary files /dev/null and b/Algorithms/0988.smallest-string-starting-from-leaf/2.png differ diff --git a/Algorithms/0988.smallest-string-starting-from-leaf/3.png b/Algorithms/0988.smallest-string-starting-from-leaf/3.png new file mode 100644 index 000000000..9d621d7a3 Binary files /dev/null and b/Algorithms/0988.smallest-string-starting-from-leaf/3.png differ diff --git a/Algorithms/0988.smallest-string-starting-from-leaf/README.md b/Algorithms/0988.smallest-string-starting-from-leaf/README.md new file mode 100755 index 000000000..772c2e7a7 --- /dev/null +++ b/Algorithms/0988.smallest-string-starting-from-leaf/README.md @@ -0,0 +1,39 @@ +# [988. Smallest String Starting From Leaf](https://leetcode.com/problems/smallest-string-starting-from-leaf/) + +Given the root of a binary tree, each node has a value from 0 to 25 representing the letters 'a' to 'z': a value of 0 represents 'a', a value of 1 represents 'b', and so on. + +Find the lexicographically smallest string that starts at a leaf of this tree and ends at the root. + +(As a reminder, any shorter prefix of a string is lexicographically smaller: for example, "ab" is lexicographically smaller than "aba". A leaf of a node is a node that has no children.) + +Example 1: + +![1](1.png) + +```text +Input: [0,1,2,3,4,3,4] +Output: "dba" +``` + +Example 2: + +![2](2.png) + +```text +Input: [25,1,3,1,3,0,2] +Output: "adz" +``` + +Example 3: + +![3](3.png) + +```text +Input: [2,2,1,null,1,0,null,0] +Output: "abc" +``` + +Note: + +- The number of nodes in the given tree will be between 1 and 8500. +- Each node in the tree will have a value between 0 and 25. \ No newline at end of file diff --git a/Algorithms/0988.smallest-string-starting-from-leaf/smallest-string-starting-from-leaf.go b/Algorithms/0988.smallest-string-starting-from-leaf/smallest-string-starting-from-leaf.go new file mode 100755 index 000000000..c017b0aee --- /dev/null +++ b/Algorithms/0988.smallest-string-starting-from-leaf/smallest-string-starting-from-leaf.go @@ -0,0 +1,38 @@ +package problem0988 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +func smallestFromLeaf(root *TreeNode) string { + res := string('z' + 1) + dfs(root, "", &res) + return res +} + +func dfs(node *TreeNode, s string, res *string) { + s = string('a'+node.Val) + s + + if node.Left == nil && node.Right == nil { + *res = min(*res, s) + return + } + + if node.Left != nil { + dfs(node.Left, s, res) + } + + if node.Right != nil { + dfs(node.Right, s, res) + } +} + +func min(a, b string) string { + if a < b { + return a + } + return b +} diff --git a/Algorithms/0988.smallest-string-starting-from-leaf/smallest-string-starting-from-leaf_test.go b/Algorithms/0988.smallest-string-starting-from-leaf/smallest-string-starting-from-leaf_test.go new file mode 100755 index 000000000..9cc9f9684 --- /dev/null +++ b/Algorithms/0988.smallest-string-starting-from-leaf/smallest-string-starting-from-leaf_test.go @@ -0,0 +1,66 @@ +package problem0988 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans string +}{ + + { + + []int{25, 1, kit.NULL, 0, 0, 1, kit.NULL, kit.NULL, kit.NULL, 0}, + "ababz", + }, + + { + []int{4, 0, 1, 1}, + "bae", + }, + + { + []int{25, 1, 3, 1, 3, 0, 2}, + "adz", + }, + + { + []int{0, 1, 2, 3, 4, 3, 4}, + "dba", + }, + + { + []int{25, 1, 3, 1, 3, 0, 2}, + "adz", + }, + + { + []int{2, 2, 1, kit.NULL, 1, 0, kit.NULL, 0}, + "abc", + }, + + // 可以有多个 testcase +} + +func Test_smallestFromLeaf(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, smallestFromLeaf(root), "输入:%v", tc) + } +} + +func Benchmark_smallestFromLeaf(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + smallestFromLeaf(root) + } + } +} diff --git a/Algorithms/0989.add-to-array-form-of-integer/README.md b/Algorithms/0989.add-to-array-form-of-integer/README.md new file mode 100755 index 000000000..f490c8f03 --- /dev/null +++ b/Algorithms/0989.add-to-array-form-of-integer/README.md @@ -0,0 +1,44 @@ +# [989. Add to Array-Form of Integer](https://leetcode.com/problems/add-to-array-form-of-integer/) + +For a non-negative integer X, the array-form of X is an array of its digits in left to right order. For example, if X = 1231, then the array form is [1,2,3,1]. + +Given the array-form A of a non-negative integer X, return the array-form of the integer X+K. + +Example 1: + +```text +Input: A = [1,2,0,0], K = 34 +Output: [1,2,3,4] +Explanation: 1200 + 34 = 1234 +``` + +Example 2: + +```text +Input: A = [2,7,4], K = 181 +Output: [4,5,5] +Explanation: 274 + 181 = 455 +``` + +Example 3: + +```text +Input: A = [2,1,5], K = 806 +Output: [1,0,2,1] +Explanation: 215 + 806 = 1021 +``` + +Example 4: + +```text +Input: A = [9,9,9,9,9,9,9,9,9,9], K = 1 +Output: [1,0,0,0,0,0,0,0,0,0,0] +Explanation: 9999999999 + 1 = 10000000000 +``` + +Note: + +- 1 <= A.length <= 10000 +- 0 <= A[i] <= 9 +- 0 <= K <= 10000 +- If A.length > 1, then A[0] != 0 \ No newline at end of file diff --git a/Algorithms/0989.add-to-array-form-of-integer/add-to-array-form-of-integer.go b/Algorithms/0989.add-to-array-form-of-integer/add-to-array-form-of-integer.go new file mode 100755 index 000000000..61c5372c0 --- /dev/null +++ b/Algorithms/0989.add-to-array-form-of-integer/add-to-array-form-of-integer.go @@ -0,0 +1,36 @@ +package problem0989 + +func addToArrayForm(A []int, K int) []int { + size := len(A) + A[size-1] += K + for i := size - 1; i > 0 && A[i] > 9; i-- { + A[i-1] += A[i] / 10 + A[i] %= 10 + } + + if A[0] < 10 { + return A + } + + A0 := num2ints(A[0]) + return append(A0, A[1:]...) +} + +func num2ints(n int) []int { + res := make([]int, 0, 8) + for n > 0 { + res = append(res, n%10) + n /= 10 + } + reverse(res) + return res +} + +func reverse(A []int) { + i, j := 0, len(A)-1 + for i < j { + A[i], A[j] = A[j], A[i] + i++ + j-- + } +} diff --git a/Algorithms/0989.add-to-array-form-of-integer/add-to-array-form-of-integer_test.go b/Algorithms/0989.add-to-array-form-of-integer/add-to-array-form-of-integer_test.go new file mode 100755 index 000000000..a4ad8fc61 --- /dev/null +++ b/Algorithms/0989.add-to-array-form-of-integer/add-to-array-form-of-integer_test.go @@ -0,0 +1,63 @@ +package problem0989 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans []int +}{ + + { + []int{1, 2, 6, 3, 0, 7, 1, 7, 1, 9, 7, 5, 6, 6, 4, 4, 0, 0, 6, 3}, + 516, + []int{1, 2, 6, 3, 0, 7, 1, 7, 1, 9, 7, 5, 6, 6, 4, 4, 0, 5, 7, 9}, + }, + + { + []int{1, 2, 0, 0}, + 34, + []int{1, 2, 3, 4}, + }, + + { + []int{2, 7, 4}, + 181, + []int{4, 5, 5}, + }, + + { + []int{2, 1, 5}, + 806, + []int{1, 0, 2, 1}, + }, + + { + []int{9, 9, 9, 9, 9, 9, 9, 9, 9, 9}, + 1, + []int{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + }, + + // 可以有多个 testcase +} + +func Test_addToArrayForm(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, addToArrayForm(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_addToArrayForm(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + addToArrayForm(tc.A, tc.K) + } + } +} diff --git a/Algorithms/0990.satisfiability-of-equality-equations/README.md b/Algorithms/0990.satisfiability-of-equality-equations/README.md new file mode 100755 index 000000000..d99679dea --- /dev/null +++ b/Algorithms/0990.satisfiability-of-equality-equations/README.md @@ -0,0 +1,50 @@ +# [990. Satisfiability of Equality Equations](https://leetcode.com/problems/satisfiability-of-equality-equations/) + +Given an array equations of strings that represent relationships between variables, each string equations[i] has length 4 and takes one of two different forms: "a==b" or "a!=b". Here, a and b are lowercase letters (not necessarily different) that represent one-letter variable names. + +Return true if and only if it is possible to assign integers to variable names so as to satisfy all the given equations. + +Example 1: + +```text +Input: ["a==b","b!=a"] +Output: false +Explanation: If we assign say, a = 1 and b = 1, then the first equation is satisfied, but not the second. There is no way to assign the variables to satisfy both equations. +``` + +Example 2: + +```text +Input: ["b==a","a==b"] +Output: true +Explanation: We could assign a = 1 and b = 1 to satisfy both equations. +``` + +Example 3: + +```text +Input: ["a==b","b==c","a==c"] +Output: true +``` + +Example 4: + +```text +Input: ["a==b","b!=c","c==a"] +Output: false +``` + +Example 5: + +```text +Input: ["c==c","b==d","x!=z"] +Output: true +``` + +Note: + +- `1 <= equations.length <= 500` +- `equations[i].length == 4` +- `equations[i][0] and equations[i][3] are lowercase letters` +- `equations[i][1] is either '=' or '!'` +- `equations[i][2] is '='` diff --git a/Algorithms/0990.satisfiability-of-equality-equations/satisfiability-of-equality-equations.go b/Algorithms/0990.satisfiability-of-equality-equations/satisfiability-of-equality-equations.go new file mode 100755 index 000000000..f0b226c24 --- /dev/null +++ b/Algorithms/0990.satisfiability-of-equality-equations/satisfiability-of-equality-equations.go @@ -0,0 +1,44 @@ +package problem0990 + +func equationsPossible(equations []string) bool { + u := newUnion(26) + + for _, e := range equations { + if e[1] == '=' { + u.unite(e[0]-'a', e[3]-'a') + } + } + + for _, e := range equations { + if e[1] == '!' && u.find(e[0]-'a') == u.find(e[3]-'a') { + return false + } + } + + return true +} + +type union struct { + parent []byte +} + +func newUnion(size int) *union { + parent := make([]byte, size) + for i := range parent { + parent[i] = byte(i) + } + return &union{ + parent: parent, + } +} + +func (u *union) find(i byte) byte { + if u.parent[i] != i { + u.parent[i] = u.find(u.parent[i]) + } + return u.parent[i] +} + +func (u *union) unite(x, y byte) { + u.parent[u.find(x)] = u.find(y) +} diff --git a/Algorithms/0990.satisfiability-of-equality-equations/satisfiability-of-equality-equations_test.go b/Algorithms/0990.satisfiability-of-equality-equations/satisfiability-of-equality-equations_test.go new file mode 100755 index 000000000..8a2bf76ab --- /dev/null +++ b/Algorithms/0990.satisfiability-of-equality-equations/satisfiability-of-equality-equations_test.go @@ -0,0 +1,67 @@ +package problem0990 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + equations []string + ans bool +}{ + + { + []string{"a==b", "b!=a"}, + false, + }, + + { + []string{"b==a", "a==b"}, + true, + }, + + { + []string{"a==b", "b==c", "a==c"}, + true, + }, + + { + []string{"b!=b"}, + false, + }, + + { + []string{"a==b", "b!=c", "c==a"}, + false, + }, + + { + []string{"c==c", "b==d", "x!=z"}, + true, + }, + + { + []string{"a==b", "c!=d"}, + true, + }, + + // 可以有多个 testcase +} + +func Test_equationsPossible(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, equationsPossible(tc.equations), "输入:%v", tc) + } +} + +func Benchmark_equationsPossible(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + equationsPossible(tc.equations) + } + } +} diff --git a/Algorithms/0991.broken-calculator/README.md b/Algorithms/0991.broken-calculator/README.md new file mode 100755 index 000000000..45be942de --- /dev/null +++ b/Algorithms/0991.broken-calculator/README.md @@ -0,0 +1,47 @@ +# [991. Broken Calculator](https://leetcode.com/problems/broken-calculator/) + +On a broken calculator that has a number showing on its display, we can perform two operations: + +- Double: Multiply the number on the display by 2, or; +- Decrement: Subtract 1 from the number on the display. + +Initially, the calculator is displaying the number X. + +Return the minimum number of operations needed to display the number Y. + +Example 1: + +```text +Input: X = 2, Y = 3 +Output: 2 +Explanation: Use double operation and then decrement operation {2 -> 4 -> 3}. +``` + +Example 2: + +```text +Input: X = 5, Y = 8 +Output: 2 +Explanation: Use decrement and then double {5 -> 4 -> 8}. +``` + +Example 3: + +```text +Input: X = 3, Y = 10 +Output: 3 +Explanation: Use double, decrement and double {3 -> 6 -> 5 -> 10}. +``` + +Example 4: + +```text +Input: X = 1024, Y = 1 +Output: 1023 +Explanation: Use decrement operations 1023 times. +``` + +Note: + +- `1 <= X <= 10^9` +- `1 <= Y <= 10^9` diff --git a/Algorithms/0991.broken-calculator/broken-calculator.go b/Algorithms/0991.broken-calculator/broken-calculator.go new file mode 100755 index 000000000..da645c50a --- /dev/null +++ b/Algorithms/0991.broken-calculator/broken-calculator.go @@ -0,0 +1,11 @@ +package problem0991 + +// ref: https://leetcode.com/problems/broken-calculator/discuss/234484/JavaC%2B%2BPython-Change-Y-to-X-in-1-Line +func brokenCalc(X int, Y int) int { + res := 0 + for X < Y { + res += Y%2 + 1 + Y = (Y + 1) / 2 + } + return res + X - Y +} diff --git a/Algorithms/0991.broken-calculator/broken-calculator_test.go b/Algorithms/0991.broken-calculator/broken-calculator_test.go new file mode 100755 index 000000000..7163dc6ce --- /dev/null +++ b/Algorithms/0991.broken-calculator/broken-calculator_test.go @@ -0,0 +1,69 @@ +package problem0991 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + X int + Y int + ans int +}{ + + { + 68, + 71, + 34, + }, + + { + 1, + 1000000000, + 39, + }, + + { + 2, + 3, + 2, + }, + + { + 5, + 8, + 2, + }, + + { + 3, + 10, + 3, + }, + + { + 1024, + 1, + 1023, + }, + + // 可以有多个 testcase +} + +func Test_brokenCalc(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, brokenCalc(tc.X, tc.Y), "输入:%v", tc) + } +} + +func Benchmark_brokenCalc(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + brokenCalc(tc.X, tc.Y) + } + } +} diff --git a/Algorithms/0992.subarrays-with-k-different-integers/README.md b/Algorithms/0992.subarrays-with-k-different-integers/README.md new file mode 100755 index 000000000..e3e2f463d --- /dev/null +++ b/Algorithms/0992.subarrays-with-k-different-integers/README.md @@ -0,0 +1,29 @@ +# [992. Subarrays with K Different Integers](https://leetcode.com/problems/subarrays-with-k-different-integers/) + +Given an array A of positive integers, call a (contiguous, not necessarily distinct) subarray of A good if the number of different integers in that subarray is exactly K. + +(For example, [1,2,3,1,2] has 3 different integers: 1, 2, and 3.) + +Return the number of good subarrays of A. + +Example 1: + +```text +Input: A = [1,2,1,2,3], K = 2 +Output: 7 +Explanation: Subarrays formed with exactly 2 different integers: [1,2], [2,1], [1,2], [2,3], [1,2,1], [2,1,2], [1,2,1,2]. +``` + +Example 2: + +```text +Input: A = [1,2,1,3,4], K = 3 +Output: 3 +Explanation: Subarrays formed with exactly 3 different integers: [1,2,1,3], [2,1,3], [1,3,4]. +``` + +Note: + +- `1 <= A.length <= 20000` +- `1 <= A[i] <= A.length` +- `1 <= K <= A.length` diff --git a/Algorithms/0992.subarrays-with-k-different-integers/subarrays-with-k-different-integers.go b/Algorithms/0992.subarrays-with-k-different-integers/subarrays-with-k-different-integers.go new file mode 100755 index 000000000..16f7c2a7d --- /dev/null +++ b/Algorithms/0992.subarrays-with-k-different-integers/subarrays-with-k-different-integers.go @@ -0,0 +1,28 @@ +package problem0992 + +// ref: https://leetcode.com/problems/subarrays-with-k-different-integers/discuss/234482/JavaC%2B%2BPython-Sliding-Window-with-Video +func subarraysWithKDistinct(A []int, K int) int { + return atMostK(A, K) - atMostK(A, K-1) +} + +func atMostK(A []int, K int) int { + count := [20001]int{} + res := 0 + for l, r := 0, 0; r < len(A); r++ { + if count[A[r]] == 0 { + K-- + } + count[A[r]]++ + for K < 0 { + count[A[l]]-- + if count[A[l]] == 0 { + K++ + } + l++ + } + // the number of distinct elements in A[i:r+1] (l<=i<=r) + // is NOT more than K + res += r + 1 - l + } + return res +} diff --git a/Algorithms/0992.subarrays-with-k-different-integers/subarrays-with-k-different-integers_test.go b/Algorithms/0992.subarrays-with-k-different-integers/subarrays-with-k-different-integers_test.go new file mode 100755 index 000000000..01aa9ba93 --- /dev/null +++ b/Algorithms/0992.subarrays-with-k-different-integers/subarrays-with-k-different-integers_test.go @@ -0,0 +1,63 @@ +package problem0992 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans int +}{ + + { + []int{ 2690,798,5800,94,2066,8611,5951,4576,5884,6357,3937,2533,3518,3237,1959,6006,1851,6262,7148,8002,8939,5855,6370,8250,1766,6669,8733,4627,6333,558,7446,3415,9345,7094,6585,5556,7562,9374,2503,9499,4497,176,6037,3330,7846,8605,9947,5395,7195,23,8055,2315,6214,5431,4695,2124,5555,7224,7906,5323,8848,810,880,1746,192,1504,685,2895,297,6978,8874,8452,8293,828,2780,3541,9221,9357,7195,4381,6121,4425,7220,4025,8009,6168,9752,8955,5567,6484,5451,7736,1211,6687,870,3979,8830,1627,2581,6288,3327,9216,377,281,6729,7113,3735,941,8891,423,8087,4804,4566,6653,8454,2876,7651,2386,7668,7095,8443,1874,6295,8955,5692,8989,5190,1744,3323,6615,1407,6789,605,7558,4338,3372,7452,279,2580,170,9608,3066,2173,2120,9651,9745,650,2644,7476,197,4315,6977,565,5393,6310,6034,5909,9653,6163,3363,4455,7316,8525,5696,4353,1526,5111,5596,878,7223,4501,7340,6205,9398,8015,8185,1631,2023,2690,482,5693,7458,3438,1079,5151,5617,2441,6463,7302,6630,7930,867,9635,6419,2751,449,8621,9503,8839,8522,5408,3048,7049,4196,8425,412,5932,5912,299,4686,1036,8821,9036,2632,7452,635,872,4243,9166,3729,1501,4080,3964,9840,8942,7858,3651,6422,3457,4258,819,2276,49,794,9216,1568,8844,6218,5140,4420,1333,1015,3211,9917,3635,6823,1861,1757,337,9798,3703,3529,9452,7155,650,8683,3144,3651,779,3057,1915,3806,7386,6460,81,173,5883,7139,7814,8610,5495,3357,5327,1632,9772,5946,2865,4447,857,5851,7320,9642,8883,1702,3410,3376,4435,3651,8994,6086,4326,6785,7149,6355,1435,8049,1392,7618,1673,9210,2120,564,9574,8388,7992,651,2465,9693,167,4817,8825,4215,4895,3071,9091,2663,4175,182,6968,8584,1514,7561,8468,3430,9862,9057,4793,2628,5662,8472,362,6294,4833,3854,5952,4232,2368,9368,4632,4693,4132,3003,2371,5120,8949,2997,9973,8223,8580,5813,711,6778,8002,9902,8454,5281,9015,584,7441,1444,2604,623,3646,3528,8129,5810,7845,5481,1512,5749,1748,9122,5448,2431,2969,3734,5707,173,5131,8923,704,1261,6018,8762,521,6964,8874,5441,3246,6313,2661,1872,73,3095,742,2319,8056,6703,2550,935,6735,3444,5394,6404,9075,9197,395,5658,47,5094,2501,5757,4691,2591,9400,1383,4032,8876,7714,2534,2045,3107,7012,7387,1525,449,2800,6172,2679,8069,2,1106,7381,932,484,7148,6533,1347,5335,2299,2003,528,5297,228,7117,3066,3082,4033,5557,7412,3742,8224,9011,7574,4990,258,241,348,4702,6861,717,5029,393,3275,3322,6837,9049,6697,7599,1091,1247,4873,6918,9036,2273,2896,2990,3918,6054,4296,8618,1790,7788,3359,4976,5347,4211,9815,6699,2600,7792,4260,6506,350,3611,6401,2911,4935,6705,1051,7664,6060,8386,3108,4297,1225,1012,9441,4935,1708,2894,733,8399,3449,9934,4052,2293,1992,6500,6457,1429,1429,8100,6240,7614,5488,3688,4724,2834,75,4348,194,712,8607,2096,3901,2890,3207,5002,2120,6151,8578,9457,9519,8002,5269,3427,3982,4353,3431,2992,2392,9967,5508,6172,8001,8666,5515,8433,4645,3861,5568,9291,6751,8376,4826,538,2786,4651,1430,531,9412,6031,242,5424,6366,4645,7251,9099,9597,1172,3680,4887,7076,8759,6500,8855,8808,1325,7680,4085,2866,9512,7958,6749,9121,8782,9471,9279,8613,4027,1654,2992,5781,189,651,8713,2970,2455,3490,5431,2882,9790,4657,9161,318,2655,3093,7990,9236,1687,6253,6500,7645,5817,2829,4146,5752,9868,2061,703,8998,5642,2248,2656,5180,2243,6494,5390,5732,8200,2114,2357,9212,2352,9660,4263,1157,9766,8407,9431,389,9528,2788,9391,7158,2618,9270,6730,2789,3169,5797,9738,9523,1129,8107,8867,1415,9184,9385,6846,6747,88,9907,8967,4363,1433,4080,7360,1721,8476,6507,6668,4603,9281,613,8420,8091,3242,8720,9926,9782,9886,5349,4033,3054,2375,4943,3450,6456,4564,4222,8841,4751,6280,1894,5501,7023,8873,1885,3764,9274,2802,9728,452,2167,1233,9358,2725,990,5497,9339,1365,8461,9218,6783,1090,5078,3700,981,9171,1535,5168,9820,1840,1184,9559,9817,2581,3864,9824,3299,8979,1897,1750,5030,2751,1944,3928,2097,9122,8910,8824,8056,6263,9081,701,2178,2831,4699,3440,5644,5904,4570,8434,8404,6210,6463,3077,3278,2337,5479,8655,7459,6686,3989,5290,8797,8750,1006,6246,7341,9337,2555,3190,2021,8588,1403,1263,4350,9288,7102,620,500,6064,1627,3676,228,3583,8827,2930,1941,3664,2203,7413,1900,9124,1198,9998,1766,6272,3977,8236,194,7404,9414,2675,6676,4213,4753,8712,2484,5803,6478,2023,2477,5428,1153,4158,9374,3735,2020,7743,3340,1506,3636,5842,8654,4869,9093,496,8224,4469,4762,2473,5489,1962,2189,783,3349,385,45,2777,8947,3146,9371,9345,9079,5387,6300,4854,8961,6683,6634,1611,5845,4488,4259,8422,1370,9682,5736,3682,6283,2237,127,3869,761,3843,1810,715,9542,4480,8398,5825,6747,8692,261,9962,2323,5460,1964,3398,6878,3418,4910,6294,3295,8192,3159,1634,4878,7049,5577,9155,8903,8313,9083,7577,2970,1847,2948,6421,9593,1522,4437,8016,7628,3897,9949,2819,2672,6850,7970,61,1332,8628,1439,177,6522,2300,7680,8740,6956,332,4215,2435,2325,5304,2891,3195,7220,1031,596,9567,4349,3144,2832,6615,1223,698,3249,1547,1310,3106,7373,4459,5442,5529,4397,1082,6455,7724,2958,7678,9844,2970,2115,2739,7988,8106,4224,2885,7319,2354,1073,8073,8898,7057,7617,6612,8219,662,9875,8802,9518,2934,3117,705,2843,9610,9704,4883,565,318,898,4832,5348,4324,5115,9665,9940,7567,7515,8742,7556,1048,4747,2897,4360,4733,7959,2937,8488,4429,9091,1224,2111,8253,6819,2446,3020,8678,5153,1083,4420,8340,4778,7976,9918,1176,2657,6975,1557,1303,1163,4767,7786,1050,2514,6233,688,6476,7571,8453,4446,7695,3903,7870,7152,1239,5325,6466,6583,3821,1654,563,5892,9597,1544,9448,9809,552,5941,1629,6808,3363,3633,9982,9177,9239,2374,3072,8377,3503,7427,4617,9278,9628,9561,4035,4452,3668,7549,3181,9595,191,9338,2169,4086,9529,9724,4159,4493,851,2965,8473,2572,3602,9899,3701,9378,8591,424,8407,1475,1061,2265,5604,4951,5285,2560,6247,5496,117,8274,4783,6056,4669,8186,5791,8345,1929,4756,2702,9858,1642,6771,2165,7281,8133,7627,4003,2788,3986,7511,8860,7198,2318,6100,678,6825,697,2436,746,8478,8313,8013,8089,686,2518,3800,2405,8445,748,1026,4563,8017,4460,7422,5296,6535,5626,6656,8601,6207,10000,4499,6561,5771,1690,245,1215,2596,4825,1926,7725,8181,3616,7565,3706,2174,5930,658,4777,8690,9122,5781,7776,2217,3064,9510,5546,8303,4995,4698,7973,2259,9642,9501,309,9961,7450,8906,1919,6137,9859,7621,4895,3773,8635,1986,6914,7607,5209,4043,6237,1816,8267,9613,6804,9002,1073,5019,611,5240,1247,2714,9545,7697,7055,9572,8056,5000,1069,5669,6711,9734,6601,7473,2592,6455,4392,7516,7714,3657,4948,9856,6032,848,775,9483,7263,8069,9572,6702,4476,2098,6174,9039,5892,3239,7151,56,8907,5609,9747,3989,3910,8846,6458,1930,6592,1649,953,1835,7321,2692,681,6178,7762,7945,3079,2397,2114,5833,1315,4398,4052,5549,2273,1609,9399,9767,7963,4697,8797,2874,4892,9579,4364,8702,3382,9633,7904,3069,3261,4576,4759,9161,411,3730,7779,916,5178,3765,5228,9541,8797,9019,3467,4650,9031,648,4160,7185,3585,5207,6222,7581,921,1381,6442,8599,5934,1028,5631,8091,6005,1834,9372,375,1319,9919,8020,8623,4368,9235,5357,6460,9202,3509,5922,7336,4336,3933,2209,1987,9187,2115,4718,9969,569,4949,3262,4650,6721,7653,349,3625,2512,4425,4921,1998,2031,2330,5140,5532,9786,1381,2069,3723,8082,5981,3320,3127,9100,2535,1306,3247,7777,476,8125,8135,252,650,7354,6166,2895,4740,6506,8329,8190,1022,8780,2702,5761,5681,1379,5162,2823,925,853,7044,5054,9778,4109,359,5612,8438,9849,7540,7849,4594,7196,7070,6642,7669,7149,7004,2296,159,855,9770,1391,103,2999,7000,3855,9446,4865,8617,5911,5514,5756,3062,1189,2756,9233,1257,2623,4138,5440,802,5373,7014,4522,8998,1436,3892,360,7130,6044,7912,6675,7772,4195,438,442,5659,5081,6904,127,2154,7482,8044,6170,6241,4231,8387,5700,8700,7445,1684,9309,3882,9612,214,9704,8015,6233,8761,1338,5122,7436,1710,4990,8400,4571,1114,1075,87,2205,5784,9820,8364,7296,1716,5759,7494,260,7376,6647,7968,1486,2738,3731,1739,6646,8388,9908,6873,2921,2147,6419,4147,6919,3697,9800,2516,4534,9364,3572,9964,4749,7268,7736,6223,7562,3297,1468,4387,6397,3162,7017,341,5387,1607,431,5973,2571,1200,1312,8293,8476,3075,2035,4766,654,6066,2594,2954,5332,5923,2060,8123,1416,78,3844,4387,3319,5123,8464,2538,6721,4961,970,3292,6538,9568,6323,9080,5340,6728,5675,7762,6099,7864,2538,1809,7279,4288,3611,8930,677,6998,7947,9299,7679,9669,1566,6297,4983,5610,1931,9274,5328,6454,8331,5236,2637,6334,1038,7188,9224,6110,2661,5856,3869,945,3257,9550,9420,3547,5203,6666,9290,5360,7666,4964,272,4826,5160,9472,6635,7526,9357,3732,8250,487,7051,9981,3348,2706,3392,1690,8895,865,5263,2735,8234,9009,6911,4580,916,1491,5050,5508,2002,2238,2415,7967,7021,5979,4241,584,2546,728,3207,599,8736,5958,2554,1127,4861,7627,1017,937,8562,449,1656,2432,7466,7845,9820,931,5943,2969,1345,5631,4077,1058,8548,3346,9925,5242,5834,337,1628,7407,183,4451,2497,3538,5416,9971,7834,3882,8250,2098,688,4639,3776,1986,94,8847,9345,6380,246,5291,4199,843,492,475,5473,6975,9353,2102,1233,1851,6985,5563,9231,1688,8461,572,2261,4848,5946,3341,162,6835,1160,2777,2647,3925,3957,7405,3820,9406,6543,8843,876,3257,9277,5353,20,5109,8839,5536,9496,8311,8825,2973,8703,3990,693,3506,930,9086,2686,8518,1297,4174,781,1105,3374,7898,239,1378,8831,425,5429,9577,7808,6023,114,5804,655,3877,7041,3830,47,4404,685,164,4293,1246,9223,5830,2670,4077,1732,9380,9399,7458,4268,1654,2819,1327,4764,4283,6281,4621,7845,2387,8900,1719,5979,7157,5681,1069,7334,9882,4868,3763,8628,3408,8835,4575,3125,6792,6441,9726,14,7127,8661,3375,9527,2345,5208,1110,6157,1130,6811,4203,1344,9755,535,9209,3414,7299,9274,4623,4150,2427,9705,5042,1470,5441,9512,89,6526,1142,5460,2448,3323,7568,1082,8310,4973,2985,1373,4350,3409,3150,6500,9810,7367,8848,1065,4923,8325,1446,9483,1914,1714,2218,4013,2291,5164,1223,6213,3229,5971,8882,6061,5971,4955,8878,8710,1605,2638,4758,6848,4024,2888,887,1508,7026,1193,3058,5882,751,7383,5519,3795,863,8137,8325,6832,4485,9453,5379,8136,8537,1746,2779,3766,8983,1247,9089,4393,1998,4491,6688,9283,7491,6930,4661,6219,5691,518,2290,7899,3076,8476,1756,6130,3884,1787,1006,9378,2152,2321,148,7235,1887,5581,1553,8543,7757,5862,2985,1924,817,7362,1415,4053,4270,6048,4873,4153,6894,4943,8335,2843,2490,9764,4879,5832,3955,3976,9284,7444,7389,7384,6554,5413,2639,9091,1108,8678,3204,1184,7079,9830,6044,8245,4844,2134,3788,7729,9714,2511,3962,131,7529,9946,3730,2896,216,8533,7923,529,2263,1381,2867,6258,6774,5326,1847,2469,3461,7293,3692,3469,7946,2671,4097,3220,6702,6871,9850,2885,3776,620,5343,5362,1888,9576,298,1711,9093,8586,6045,7637,2728,1125,7434,4112,8311,3199,5881,2050,4275,3315,6885,1086,9538,7183,575,797,397,2983,74,1756,2451,336,797,3020,5189,9414,4756,2161,3272,934,3856,9988,4870,6516,210,81,6301,3479,3860,2329,7358,8760,624,8785,383,1911,5894,7506,410,2886,8683,5975,2364,1180,405,4450,6870,4739,2320,7,3376,4697,5435,9662,929,3619,8268,3845,8600,8614,2696,5757,3654,413,8876,1128,6242,7990,3015,2962,8148,5204,3165,1829,442,8510,4917,6690,4294,8287,8780,911,8909,4580,9009,1220,8185,6033,2822,13,8793,8764,6773,6955,4716,9760,249,1699,6153,8172,129,637,7659,2242,7392,630,8189,5496,6704,5006,9794,7930,9866,3915,8543,7750,911,2149,383,3198,3475,5976,3790,3530,4252,8021,8095,4611,9959,4448,5159,9177,9972,9331,63,7231,7685,3802,5685,5257,7731,1990,9499,1861,5977,7930,9111,8559,4135,8561,7906,3371,1488,4902,297,6495,5484,3882,6191,8550,983,7009,9865,8622,9472,133,688,219,8155,7250,1763,8594,1935,3272,8834,6190,937,8781,4724,9567,872,1656,2386,6070,5326,5543,7066,8891,1397,5898,7613,327,3912,3461,8832,7290,4645,9954,6815,1622,4146,9613,6822,9842,4901,7638,8966,2120,299,9187,998,4951,4082,923,3279,9441,8318,5403,607,5950,9016,8245,8423,8504,4410,9085,8845,589,9124,7754,4187,5072,3163,3995,6334,6680,1028,2799,7655,7376,2749,1099,5982,1733,8485,2953,6202,731,4255,5907,7530,4457,3827,5628,4911,2152,3005,7495,9039,7527,5180,6926,6068,8730,6500,8044,4555,2711,9469,8963,8598,1816,641,6040,794,1387,3154,930,9170,7109,1874,3342,8026,3067,1048,4878,1924,8119,690,1957,9799,3177,8142,1452,875,7795,4847,6033,1854,2972,718,1555,994,8958,6183,9943,6316,585,7848,150,3559,9310,4197,8540,6623,9780,7239,8395,9767,5430,5976,5846,739,2978,2616,3638,7390,9004,2795,3721,5254,9305,1801,8926,8027,1909,7325,4090,2388,5821,6871,1078,25,4565,3610,9518,6314,2484,1918,1363,710,1699,3119,7914,8997,3650,2924,3564,9375,7251,9929,2660,5971,6349,2237,5252,8097,9002,7653,976,9168,8585,6287,9521,4105,6381,2336,7171,7737,3244,1807,2567,9475,5840,8279,8802,7132,7034,3849,4732,4334,9354,2440,2178,6645,8440,9451,3061,2565,3871,318,1513,2498,6924,3137,1655,2358,9827,2327,1483,4862,5130,7241,3270,5197,6685,7025,5277,696,5800,6527,1432,3609,6544,3047,4404,4477,8666,1009,9714,8422,5746,296,6117,7737,7174,3516,1976,3696,7481,5136,1638,1817,7104,8924,4864,5925,8888,8668,1659,9834,6670,5919,4703,8114,8165,4169,3753,7866,2452,9969,9433,4052,8501,2036,6293,2229,1272,3872,3653,6951,7614,234,6324,3752,798,4392,8789,2106,3235,5976,4156,6113,7547,3095,3025,8360,1674,9963,7025,1900,2613,4746,8668,7519,8584,7872,2952,966,3537,5533,1820,4444,610,6309,5686,781,9778,5246,9078,3339,4093,9861,8289,6221,7440,2906,9039,6459,4638,3583,2284,8707,8973,4668,6411,3335,777,8158,2254,1421,7537,4292,752,2158,8837,209,6555,4999,1262,3149,8850,3691,9926,4980,4105,2782,6619,1349,2567,5819,1425,1476,3483,6816,5229,9240,4228,2189,4954,5294,5480,5497,6696,6356,9790,3677,8680,1119,3252,6,5729,5493,6569,4967,2846,8932,9348,1909,3502,1145,8779,6745,4739,3130,77,9794,3508,9149,9769,6000,7322,8526,5892,9130,5430,4781,6407,7849,4666,4445,9791,4235,9900,8775,5292,6449,8774,7925,818,6241,7448,9303,9114,4420,7237,1505,4834,6361,6433,1435,9273,6769,3738,2912,5828,6641,1852,175,1788,3187,5339,6749,446,260,1565,4594,3081,8776,6125,8359,723,7970,1402,9374,9237,2684,5413,3562,5674,453,1479,4882,6292,8478,1544,7683,1735,1340,7065,5611,2604,4666,5851,2255,9632,2243,7766,6469,5538,6700,99,1051,6616,3032,2018,7886,5435,8594,2533,6260,2198,4919,9987,6051,3739,9913,6214,7047,2430,605,1741,2128,184,4398,7003,5953,7109,8696,7526,915,7910,6301,5865,3840,4160,5956,3074,7880,1020,2869,805,2575,293,6222,119,4477,9805,7713,403,8221,120,4819,3849,5838,8702,1215,7754,3973,6574,6337,6589,3097,8902,6716,2270,8598,3500,8324,9177,7691,6184,3573,8835,7180,8871,8362,2690,1888,2810,8038,7968,9971,5509,7503,3276,1654,7936,7342,8408,5802,5273,9296,1836,2857,7328,7416,5762,3341,5994,683,4760,4567,5663,2850,4161,3977,2236,9675,5524,3132,1506,9161,507,2379,2805,7840,838,2054,2061,7369,8998,3233,3336,2596,9330,3794,7062,4353,3477,8358,9180,3126,4653,6492,1106,8924,7646,792,4053,8962,6957,5746,4166,3865,6870,8661,5144,1542,8503,8848,6390,691,6834,8744,9659,9421,6111,8692,5095,2679,1303,2192,6001,7270,682,6011,8400,2756,9066,3864,5873,8734,6446,6065,9924,9814,1776,4463,8335,4673,9296,4323,4745,1065,1886,1265,4416,76,5587,7200,4548,5003,8233,4859,8633,5676,142,5746,2809,9161,886,4090,624,3951,4902,5497,6430,8912,9450,2747,3097,1057,959,1440,72,4125,4521,4891,6921,6064,6447,7236,2524,4316,8426,5911,6821,7015,9658,7715,8254,1115,5265,764,3090,757,3893,1306,324,8935,2450,3928,4006,2263,4166,1285,5906,2269,3236,1478,5621,4793,5266,8834,1406,1770,8058,8421,5684,8792,9917,5678,6845,8907,1563,2080,1720,4481,6844,8053,884,156,5498,8694,6134,3714,7189,2900,4760,4699,6942,3747,4676,1159,2508,9017,1805,3718,5146,468,1990,8253,7030,4497,6888,4232,8132,4502,8225,7058,474,5368,6672,8494,6945,4822,9194,9330,7978,8252,8600,999,7622,9297,7671,9754,5485,8506,8518,3214,3785,676,9019,9912,1800,3246,6927,2673,1373,3036,6621,9320,2142,6214,6807,2910,7128,9238,1393,8823,6871,7678,7684,3407,6191,672,6156,6371,8870,5604,6635,6596,8471,8581,9684,3688,8304,5316,8560,4745,9764,5940,8828,4019,8251,1468,7129,4842,9101,4664,9611,8178,1419,8136,299,4933,2118,4304,9781,561,7334,7575,9067,6519,580,2776,8624,8173,6624,771,1229,4109,4748,5357,959,3156,8126,2044,615,1300,9474,6460,6569,9042,7974,5100,3693,1416,2477,6866,434,708,1661,4979,1350,4952,3856,9324,2127,4104,5399,5436,6021,591,754,6663,5333,1114,7657,6116,4128,5643,38,1888,2809,935,1033,2762,4571,4729,6195,9140,9073,8013,91,296,5484,4277,796,9841,8833,6888,5973,638,3400,7246,903,2962,6542,405,7675,5494,2020,1791,698,8534,7997,8370,9074,5168,4532,3654,2792,5016,740,9339,8305,6919,3566,9392,4023,6327,9575,9069,1642,9497,1383,7626,876,2751,1674,7990,9012,9250,1875,8177,4524,9309,3109,33,7763,6240,2664,2993,9404,8942,5786,4638,8253,4335,4539,4281,321,3775,5711,5751,2695,813,4416,6692,4128,9597,5610,411,4084,726,3981,8528,3214,7813,6255,582,1388,2856,8903,1129,8896,4020,6035,8518,4833,8528,9123,4462,9227,1416,9995,9431,3547,4874,2709,3978,1396,8268,6733,5990,8204,8516,9699,3436,9359,7887,5885,8513,6411,9131,466,9055,1283,7260,8640,3267,2093,3451,8502,6049,4964,5810,3483,6972,9062,241,3061,8750,7574,6636,659,7206,1243,8395,6964,3509,7232,4041,5310,6432,7426,4166,9192,7473,9621,8405,6495,358,2655,6494,3797,2337,2539,5261,9837,1270,9336,1937,3409,8368,9816,5518,6156,1452,4673,4124,1697,1563,7439,8757,3842,2357,7952,4907,5753,4817,1894,3215,9890,6382,4281,8411,6303,8446,7059,3786,6371,5045,4866,4762,7352,398,4345,2401,3689,4438,2255,5765,4440,8255,4526,4755,7449,3167,7109,2201,5845,5886,4535,1563,9401,2460,1530,1682,2836,1512,9737,6680,8956,954,6259,2797,3930,4714,7177,5013,8809,6150,484,7608,7243,1920,6700,1553,3876,2990,7122,7776,8397,9001,5351,5784,7602,2398,2899,6177,8884,9584,2815,5639,3673,1395,2715,7225,167,1475,2377,2267,8204,9051,5295,9252,3353,8047,4698,2945,7426,514,6406,8480,7888,3088,726,7078,6511,9334,5682,8554,7120,645,788,7623,840,5587,5322,3870,8479,2073,4440,4113,9394,5462,7347,5466,8754,8650,4710,5090,3619,684,1873,218,4110,5029,2277,6629,5839,2467,1017,4732,9815,3223,6344,3977,5115,775,9793,3404,2291,8668,1222,9993,3996,1349,2397,8856,5031,611,6370,564,4568,1403,3571,765,2023,327,4402,3430,7666,5669,4471,8951,1881,1558,2716,9628,5665,3184,6175,8948,1314,3181,8691,5507,5993,9210,4639,9248,5975,6025,6669,4760,2751,2863,6780,8649,4380,3767,8303,1688,569,9421,9692,1179,7543,5587,510,7408,9850,3471,9364,9972,4940,9867,6223,6077,8729,3940,3240,6673,7010,4556,1688,2556,3242,393,4973,6014,444,1379,8779,2635,7346,9897,4041,2057,3023,6733,3920,4885,7799,5843,7664,7566,6130,5862,4795,5849,4316,1860,2760,2987,4152,1021,145,1026,1448,6839,5749,7853,2215,2093,1959,495,9199,955,8125,4688,195,8772,1122,3628,7895,7517,9844,3250,1186,2335,1526,2342,8819,3016,7327,4815,2841,9147,5498,3050,7162,9659,2260,8997,2653,452,5826,7909,6784,5059,3672,8032,6770,5432,8530,2580,9674,2747,2159,2414,6702,2533,7697,5860,6989,802,3566,8988,3990,5974,9138,3602,4798,7573,1627,4614,3055,6856,1532,7083,6739,3439,6762,8634,6749,5258,3026,3869,4112,6703,5201,5796,1030,6520,7514,6355,5610,5281,9284,290,2190,8942,7001,60,3750,4595,8329,6880,955,602,3989,6227,3226,6945,2820,5692,1922,9417,8705,871,2266,7112,9770,2147,4120,1592,8515,9924,7659,6934,7953,8065,9425,7107,5984,7895,8274,6231,6750,1476,2820,1545,7965,4301,7092,7640,9893,9496,3859,2421,1199,6643,6966,1174,811,7627,2982,9093,267,1830,702,6655,6950,6442,3328,3702,4086,5347,6144,864,3818,4337,4999,7957,6181,871,5025,6052,7901,7086,1424,5023,317,6224,1399,9466,9027,5021,9567,1664,8882,905,3141,9982,594,8316,1498,4454,699,6496,4034,6974,1342,4695,950,398,7660,1219,9218,3110,1596,1980,6759,7029,8201,3134,3034,451,9778,3608,9539,5544,249,8861,9167,1090,612,5911,4031,2772,5887,1951,7447,945,3736,9878,1711,9093,7218,3824,6037,2876,9315,3284,4874,4297,821,525,3216,5553,5272,76,354,7997,7983,8659,8461,8284,8863,3067,863,2046,6531,9279,4255,6762,5818,4223,7524,4649,231,7438,9660,9016,8865,9797,9863,8266,8097,3134,890,3460,3798,2089,7805,2272,4996,7290,6493,7258,7856,9129,8827,4438,1350,1472,266,1208,6548,7857,4853,4282,860,2670,4887,2442,5654,6239,2929,6921,8571,1760,4551,9869,7019,3343,5667,3455,8920,1762,2369,6526,9353,1136,4481,4843,2936,275,3497,8891,2020,3132,8208,696,4304,3199,9492,3536,6082,6594,9717,2644,4181,1091,2664,5083,1127,8671,9716,5404,7532,2764,5032,4663,1305,7936,7715,3277,8665,9319,731,8580,5372,6961,487,1764,6451,2705,6549,956,7366,5951,5621,2973,1358,4247,9067,2350,571,1464,7729,8151,3582,1270,3075,9446,5440,6105,7073,9725,202,1164,5408,5745,3083,718,3785,7037,2006,308,6313,7277,9760,7285,8288,1892,3574,813,5746,5926,8613,5899,6697,8142,9744,9282,304,7609,2526,444,3017,3322,2602,4690,4233,4772,1681,1413,2215,3987,4743,8281,3760,6803,5810,820,1910,5799,9934,644,1548,9892,5159,1414,2844,9635,5650,975,1313,3634,4196,9847,4013,2708,2409,4905,8356,7772,7919,8821,3887,662,1528,3471,4043,5199,6396,9917,9815,2984,356,1276,569,614,7936,1643,570,3109,3746,4174,373,9713,7201,4636,2412,3227,7623,7170,9683,6474,2036,1343,6227,7799,9928,1574,7384,3568,3020,7791,7732,4646,1802,3157,9578,7759,6881,4777,771,9028,8962,5486,2045,7444,853,9243,7638,63,1397,172,4405,957,6768,4785,8834,8181,9048,2558,4489,8166,2196,1593,7660,7537,5295,9424,8110,4172,1304,9456,792,4289,2177,9967,1639,5293,529,3378,6060,8209,6274,2791,4091,9989,4739,8317,7773,7056,2086,5799,1086,7105,7507,3118,9183,8057,436,4444,9861,8270,8839,593,4696,2810,9711,7377,7509,5226,7476,3187,173,800,6878,3492,6996,6322,4173,6562,4450,6824,3860,4626,7445,8929,7306,9819,845,3727,5336,8393,9727,4262,6445,7226,9523,8273,4413,1124,102,4830,2381,9501,1129,1453,9737,7394,4496,2900,5519,4785,6067,6862,9906,6942,4640,8023,7255,3170,1927,4498,6347,1127,845,2467,2379,7613,8730,3830,6442,2425,5131,7382,6879,8657,3520,3606,8628,9233,8015,7276,4552,1208,7935,5025,7726,8076,7774,690,4172,4754,3212,4994,3325,9799,590,5398,5007,8762,9707,5287,9286,3087,4978,8516,9207,4861,8371,2397,4734,5249,4961,4249,9848,2409,6694,3617,826,3754,9983,8610,9592,7915,5868,8447,1310,1192,3362,6653,2779,2399,5288,1734,9393,6,7213,4454,1175,8387,6112,7841,7319,4034,4119,475,9488,2708,265,6382,693,3578,1172,3224,6907,7454,9975,6170,8575,5194,2745,9530,8798,7822,9169,8786,4428,2094,9851,9423,7822,2594,8281,3266,1519,1877,1248,9058,8607,2343,8839,9385,6591,1355,8972,3987,9462,2937,2398,9522,8095,5453,4483,9740,873,2534,4772,6555,3222,232,9389,3132,6892,7739,5694,3841,6263,3817,5868,2079,6405,7076,5040,9841,24,2429,887,4291,4120,7678,8896,6759,7278,5906,9393,4355,8298,4871,6675,4193,63,1683,9377,6239,2593,3868,2525,6957,9150,654,7771,5521,146,329,916,3286,2721,7857,6037,3336,5633,3452,5965,1562,1693,248,4226,7872,3475,4994,4157,1845,9975,3519,153,6279,3934,9415,72,2038,3476,5781,5758,5912,3574,5449,4116,4072,6569,9510,3174,7634,4065,6708,3046,2761,4555,9919,3191,4562,8755,7174,2130,7158,5502,2365,2468,7780,5986,9467,6590,8700,8073,3725,5140,2757,8002,465,5231,7496,8128,4060,8011,8354,5177,1733,3465,6198,3256,7671,9678,7193,9611,7331,5986,8644,4373,2331,1491,5430,8685,2360,7199,6768,7630,8806,77,8630,5669,7043,4837,8052,6246,7859,9299,1015,1832,1519,904,880,260,4817,7033,8501,9258,2425,4494,5648,2411,4315,1572,8174,2496,9519,8380,1792,18,3072,9130,9645,9680,5454,3478,9055,4172,7084,8510,1121,3630,3570,9602,9256,8751,4204,8871,1991,2287,8601,3333,6217,193,476,7609,3803,4570,4831,6468,6478,3189,4491,7497,6954,9585,7506,7283,9894,3729,933,4509,9089,8939,3534,1160,4540,1578,344,2216,4718,989,4417,791,1743,8325,8991,1249,9197,826,5080,4103,3178,5271,7112,7260,4731,1402,3343,2219,2875,8997,5345,5455,646,6608,5140,3320,382,9252,4357,4509,7994,1473,2451,6485,6802,2553,4307,1901,5396,5571,1690,6901,4834,5977,5126,227,8770,2570,1462,974,540,3113,1933,5428,3328,5916,99,2660,2973,461,1604,8949,251,3581,3007,6590,1282,6396,4503,4891,3169,1330,7174,2543,792,2858,7301,6588,1822,961,4518,4588,2188,1611,2186,8988,7759,8479,5963,4508,4586,2022,1572,7552,658,8703,2243,1682,8528,5102,5134,2029,6531,8953,8027,2371,235,618,5958,4089,767,7088,3711,8054,6792,237,8905,1623,9348,6505,3917,30,6676,1486,2037,6814,2029,2714,9361,2977,8635,3504,7205,1826,1770,5351,2857,1763,4955,5945,3240,8089,3125,6117,8049,1595,9297,6206,4777,5478,4637,3851,3063,7580,3770,8101,2135,5824,5343,7515,3176,9707,9491,3681,270,4603,214,140,6704,9103,8825,1896,3003,1868,8065,6514,557,7563,2152,8639,9579,8920,892,4579,2347,5508,9343,7259,7563,3781,6629,9572,8120,8257,5129,7729,7096,5222,8936,8472,2209,6885,6676,502,9695,2034,3506,3367,1522,3942,6124,430,8269,2189,1457,4227,825,6297,704,7184,2863,5981,336,7892,6466,562,9963,3760,467,9989,5503,6508,1307,2247,4684,2883,6276,1740,6552,9890,5456,7133,2158,2541,4737,9350,7562,3723,7119,8216,7247,7365,502,6552,7505,7211,4373,4654,1659,7247,223,1239,1979,807,1038,1252,5249,6799,7499,2505,1188,6645,9671,2399,5500,3228,3494,610,5913,2457,2847,4659,811,7625,9037,4391,6631,5897,2161,6790,6377,460,5005,3469,1356,7529,5994,6236,548,4539,8419,8041,5252,9071,3336,380,760,3753,2252,1777,8397,1327,7416,3433,8324,396,4406,2680,4083,5983,2582,4616,3203,6585,6236,8149,7315,8499,1776,2048,3043,3894,1260,2220,650,5408,6930,5028,5393,4310,9908,2739,7990,6140,314,490,474,5791,7231,4653,8787,7596,5476,8694,4331,3286,5340,1537,8687,4932,9790,927,3936,1408,215,403,262,3625,9477,3448,1736,6146,6365,6024,5013,1553,7029,5366,4270,9504,3899,6438,8825,7728,2892,4528,5888,6353,5646,7376,2128,4667,2135,2953,7563,8409,675,3693,1318,1705,2802,8758,3003,4045,1511,5633,808,8172,7642,1470,4367,9569,8263,4321,6180,8923,5277,6308,1330,4668,7360,83,7446,9867,2392,5214,434,1890,32,730,4956,3008,311,9441,5900,2423,258,7421,2321,8735,8632,3601,8669,6610,8453,1216,4324,4446,3831,756,5282,9878,7252,8024,4818,5249,6146,3534,23,9818,8750,1339,5047,2862,3750,406,1978,9937,9679,9196,2720,6489,9759,3727,4024,3249,8659,9266,4682,7464,4603,3791,4558,5087,6249,4481,3155,3455,9398,5482,4425,7729,7309,7310,8391,8851,1102,8886,6534,3322,8588,3359,6979,1850,816,1000,5569,8352,6276,7976,8053,6681,2136,1061,6024,3224,2848,8445,7497,9540,3747,8257,7416,6823,4766,3029,4812,5712,1264,6498,6510,8690,1772,837,9900,6787,8841,9213,5991,6878,2933,4464,9669,9361,8350,7366,5232,3648,7128,7245,7892,8704,1898,5140,9269,493,8080,4528,9703,3252,9162,3737,2164,2889,3548,1358,1466,4931,5756,957,1962,27,9016,860,4458,8129,445,3075,7172,1271,9360,8495,3989,1283,4937,2913,4847,2353,9651,333,2455,2671,9150,4412,4359,7552,9773,1914,5597,8474,1993,2824,7003,5704,9499,5691,277,1752,4054,8491,5270,9837,8555,9973,6427,4302,5490,3226,3958,662,360,8446,5148,8754,3435,2201,5096,2694,6336,2377,1558,5880,1086,6127,3096,1683,5137,7693,5541,4166,6199,3966,2613,7475,5990,8782,8262,9376,5988,1182,9914,3449,7854,5602,5767,2572,674,5314,677,6635,7844,7948,8692,1582,2573,832,2819,8590,807,7699,6042,9803,1074,5565,6401,5031,5059,3051,2886,7865,7984,685,1164,9916,6277,5689,9798,2429,5553,5414,1888,752,5914,6994,1543,5371,8933,253,9675,7721,5551,6812,5220,104,391,8759,6954,5084,7025,4682,8524,3818,8596,9720,4650,9117,8541,4483,11,8101,282,1798,8872,2435,8896,5867,5759,1631,8294,8021,2321,2066,8295,7288,8868,3772,4340,1852,609,9391,4976,8013,9719,4338,9218,8990,3606,1711,2470,1505,9733,6165,5884,2816,1630,8566,472,9784,5036,9594,8592,8121,2115,7579,2130,3495,2504,1607,8635,9884,4741,7697,6016,3171,2423,5440,5545,7151,4208,8975,4225,5890,1221,6219,9944,3094,4160,5288,817,5560,319,2909,4964,8423,4723,1971,1581,538,483,5481,955,8935,3830,2019,5954,3581,172,3431,9177,8843,3846,5183,5597,1718,6154,8425,8124,3559,6256,8986,9579,7803,9383,4166,9489,7665,3952,5498,8202,8959,4498,3763,8580,494,8885,3876,4133,873,9367,2164,1635,3346,1370,7741,7498,2046,2324,4799,6426,5444,653,9098,7383,9569,1924,3592,5543,8246,6651,9825,4375,2617,4518,1044,7479,2464,1137,8261,1289,4777,4695,185,7670,2565,4059,3292,9481,5928,2035,9803,5618,6475,5863,794,2932,7274,8663,1728,6551,4231,7299,1990,2887,5861,9952,540,6771,4813,1530,8900,5135,2796,7740,4261,8786,3811,1193,5641,9385,8054,6023,9663,322,4302,9487,2986,7282,7351,9871,6991,4704,3522,5816,1867,6487,836,7647,76,8280,8742,8672,9587,981,8163,5574,6456,3383,269,3781,4053,5626,8535,8673,7226,124,5548,9316,1992,7233,7591,1308,2886,1009,3097,8298,7792,4153,2007,6100,7122,2150,8361,9619,8977,1709,3356,3206,9906,6566,4657,9966,3569,3388,7900,7552,6348,1439,6485,390,1686,8978,218,4302,9940,701,4636,4473,4099,3947,1901,7725,5280,1869,6408,1940,8878,3606,5689,5227,532,9934,3969,6036,796,1039,5844,724,3974,5707,2026,8725,7891,8467,6945,8517,8538,2129,5897,4870,1974,3680,3415,7452,37,6302,3699,3346,5995,1665,4697,9813,6285,4591,4412,263,7671,6804,4686,5933,7159,9040,9690,8450,319,2966,3051,3442,2806,895,7634,5648,264,3701,5491,4112,1810,5736,8152,6941,7191,5356,1005,2597,1741,1257,4034,3192,8544,8074,2909,5436,1167,1967,9493,6540,9786,395,8200,9460,7034,9622,3686,4599,1961,9660,883,7753,3797,9244,1737,7398,4546,1017,9075,9385,9733,6989,9380,4101,5065,4497,9086,1728,5486,5223,1355,4867,597,8256,7064,3083,3957,4166,3221,9835,6569,7923,966,8664,3072,120,245,6283,9180,7032,9517,9011,7620,9418,5472,4592,113,346,7523,8793,4948,4696,1533,3959,2143,5879,5883,6984,4472,6048,7135,2349,25,7469,3036,4892,3346,5214,716,8974,2886,1671,6634,7090,3993,2608,1033,8921,3961,1572,8059,3032,1506,9058,6186,5225,5704,2607,2882,7594,4241,1154,2917,2732,6728,5623,8134,2949,5340,5421,6270,5327,4046,2952,2411,6615,3255,7023,7068,3598,7599,559,3270,9323,679,8550,6658,5592,5696,9433,7740,3601,7266,5598,4886,4488,2630,1523,9523,1619,9740,629,1308,3260,1206,3834,5086,9888,8603,7608,6202,1425,5717,795,5492,1060,9219,1859,2165,8324,4648,2787,4249,1437,4570,867,8738,6225,6676,5983,19,7335,7636,6631,2485,2487,158,9981,9285,3663,4263,5449,788,4145,2938,2104,8678,595,4183,9321,964,1373,6399,9631,7258,62,3657,7570,4409,4488,2865,1758,9190,4384,9363,945,1417,2767,8660,3825,1007,3171,2698,9589,7449,9246,655,1479,2939,9510,7954,936,2414,964,5493,5356,1902,2197,3216,4442,7452,6700,2845,2413,3613,1854,2554,613,4505,2676,3978,1703,1613,5277,3700,89,5513,3081,8322,6471,5651,2607,9572,161,3891,3656,155,5034,4133,9585,7774,2299,1290,2701,7496,7646,8567,801,4999,9299,8820,3623,127,7582,9101,2859,565,6791,6373,6529,9829,8664,655,1917,3581,8771,3619,5817,7423,298,7839,6035,2595,9989,5139,5068,3922,5615,7956,7738,4236,4873,906,8950,5203,7574,801,4943,5326,8157,1836,5478,4455,3355,5517,80,9821,174,7487,1703,2563,2411,45,3033,4639,8024,3095,39,3052,9811,2180,6871,4792,9305,2875,3699,9351,6159,2424,712,158,77,3566,200,5593,2415,111,3592,8949,7042,5062,2707,198,6397,4045,6373,2243,8645,7799,2768,4789,2647,4727,7995,9612,2386,4391,8382,3946,6298,2723,6887,2789,7207,5403,7928,9753,4164,9636,1958,1636,8064,1080,1068,825,1184,6561,2486,4926,9387,8098,3718,8541,2429,5774,403,8854,868,4751,5397,9212,7894,9216,9770,8660,1305,8420,4468,8617,7258,5149,6121,6587,9847,3269,802,3499,2181,1225,28,9504,7674,2648,2762,3557,2675,4552,4768,6648,9968,5778,8314,8861,3235,9281,2307,730,7109,7111,4670,232,8737,4889,8897,2360,3191,686,3093,2811,2042,1315,56,3065,3091,6026,3498,2092,9564,5974,1731,1458,5685,6800,7276,7950,5122,8246,497,470,5594,294,5062,6567,7162,6520,1599,5613,5857,4817,4342,444,8305,8337,3080,4010,5972,1174,248,3874,8741,6422,4779,5586,2035,4090,5339,797,5361,9181,6341,8843,8297,2929,3578,180,4660,9306,9521,937,819,577,2132,3963,3146,9554,8894,7809,9615,3966,4996,7847,3119,4810,793,90,3178,6046,471,5948,6866,7016,8653,5590,9824,4118,5356,6545,4575,5215,793,4588,6927,4907,8095,3834,8099,4310,4538,1073,7572,1521,4604,891,9211,7473,1931,4344,5579,2030,8705,9163,8709,8533,251,2169,1857,5735,395,5149,3452,1048,599,1015,1012,7553,167,4872,3214,9902,4714,5351,6193,3328,9170,8687,5112,9419,5555,5071,6148,3978,5368,8168,3688,8039,3182,3827,3963,8467,3991,5641,6202,3764,2377,8008,2675,9345,4157,9797,4010,936,7504,5060,5256,6121,245,2482,5047,6473,2384,7196,9607,8784,1452,9781,5213,9723,5815,4884,3455,3226,9601,7923,7177,4995,9265,5713,9562,877,9583,353,9879,7558,7595,9865,2856,8846,8053,7860,1846,2250,6242,913,2372,7986,6638,1057,483,147,6804,8860,5499,5629,5176,4861,5161,1029,1070,9298,9115,5845,4832,6189,2598,8520,2299,3205,3393,3006,178,3190,6567,5374,9434,7069,8905,1967,8301,6108,3514,7709,4679,172,993,7067,9180,950,9898,1995,6704,5321,8645,7095,9549,4040,3046,2060,2977,5833,5923,5274,477,5894,9017,6805,1607,3216,9720,6311,1657,7703,7570,732,7135,8115,8896,1012,4701,3743,4733,1092,8791,280,2281,8693,6200,4770,9239,3092,7467,6835,1679,1552,6469,5030,4877,9264,8041,6506,6992,3258,5154,8593,9884,6189,8141,6737,8920,648,1484,1766,97,2208,5908,7182,3413,6062,9039,5579,137,3599,8603,485,9892,1538,1306,3702,5345,2878,7760,1948,8433,8793,3272,4986,4295,3666,7823,6167,6362,7544,9831,4141,518,2224,9414,5371,4283,5043,1268,1204,8765,9085,97,8814,9730,2848,4188,84,2967,7791,9597,4981,12,243,4140,3986,4003,3209,2743,7859,5925,9602,7857,3011,7805,8546,3741,3264,3610,1010,9191,8188,7698,1743,8075,3535,506,2552,5660,9506,9182,6483,5103,1429,8800,7768,8077,7674,8608,7749,9524,2311,1897,4008,8551,7689,2020,9976,1930,7276,995,4605,5414,9411,9528,611,9227,9222,7722,6636,9305,5247,247,1867,214,8636,6445,6345,7179,5505,1791,8419,3015,8979,5030,5514,5466,3917,2973,5954,4779,9647,9477,8643,3331,5850,7583,907,3328,709,6484,6875,3715,587,6992,2101,1890,2523,867,1925,6743,183,3679,2069,110,3269,461,8358,9739,8897,4792,5870,6306,9033,1759,389,6589,6303,4967,2759,9434,4171,7864,7781,3194,4247,4315,8755,9428,17,3986,4427,3727,1628,6320,1785,9083,687,3453,4782,6649,5876,7331,9726,5806,1930,5668,6913,3525,7220,4385,869,6986,7688,1428,2202,7487,7233,5495,8581,6170,5214,4155,8558,9589,9680,5971,3378,5902,4848,1046,3201,7284,1542,9472,8993,2576,4147,5313,2569,9801,312,8348,4663,8287,2285,2218,4971,5249,8219,3621,9849,3335,6210,4237,9579,9881,2180,9702,1661,4837,1832,552,463,8701,5144,9646,7079,1815,7683,5944,3612,6555,1084,1753,9388,2393,6729,5513,1383,608,8421,1651,3121,3800,6190,2888,532,2985,6391,3323,3068,4578,5031,3300,9401,2003,5145,9469,9712,227,6746,712,2490,682,9103,550,916,9384,9724,2529,670,3597,8813,819,1964,6958,7489,2701,3912,5447,794,6017,3773,2291,1982,6313,6686,134,697,558,3309,7940,9561,8705,7540,1687,4832,1957,1360,8940,3302,7122,5744,550,9525,5204,4875,1610,1547,3435,2311,4818,1035,5081,4403,7643,8076,8423,9390,6566,6344,1743,9085,6746,9167,6771,9097,3248,4578,3989,5710,6166,6280,7917,8638,7997,7404,3719,124,8603,1932,2402,6114,4122,444,1042,6987,2855,8593,7550,6681,996,4647,2,7824,3430,5452,879,8713,4071,2498,9670,4960,9141,7457,4961,5447,1905,1266,3530,5169,2978,3029,4930,7735,9648,5644,7468,3143,601,990,9311,3071,2158,6613,8007,4615,2807,336,9476,4004,6411,5618,2713,3062,9817,3073,2158,3867,2851,1176,1855,6025,7613,3941,620,984,8418,9963,871,7029,879,8225,2344,9233,8183,3602,6492,4080,8301,8908,8850,2507,8605,7969,2205,1742,7859,9512,7797,6586,2642,5644,1605,7300,8286,7772,7662,8356,802,1146,4243,7368,5996,3004,7403,9374,9340,510,7539,8029,3672,8078,3305,4973,811,7391,9154,9850,6738,1511,277,2533,4813,4224,269,4051,4948,8314,7530,9244,3471,3496,4865,4541,9805,7119,5432,3207,8462,2474,2939,7501,7321,7784,8842,2826,8183,8540,5576,1305,4118,2092,3997,2363,3079,9092,3205,6485,1455,9120,3568,1887,8666,2117,7360,3750,4788,3176,9165,8650,526,3669,3108,9009,7743,8474,2980,6514,720,9625,32,8875,6959,9226,8656,3420,8925,1894,6911,8522,3520,8765,2510,9501,754,8641,8736,1378,160,1865,7900,2777,7851,6239,655,5431,314,1570,4871,8566,7431,6949,4073,5825,1005,414,2891,9097,8097,3128,6570,8066,1350,5281,2310,2822,2327,5421,2337,2929,3713,1857,644,3667,1109,2808,2042,3793,1611,162,4243,3365,3034,7824,547,3673,4609,1177,2320,7744,690,3625,9655,1614,9969,9837,9143,3066,2841,3335,3732,5283,4887,2400,1366,6680,6365,3729,295,5583,992,4905,889,3119,3131,571,8894,7845,1674,9452,1214,4963,5280,3321,3284,5804,5585,5167,6785,2794,7352,8625,6504,8217,2211,5590,4496,5273,5458,4393,6598,655,7003,199,1944,7844,1097,4516,5962,7109,5256,614,6405,2993,9083,7960,323,9519,8519,9065,3829,4181,1301,347,3485,5506,6292,8500,4980,6821,6484,5232,7109,723,2140,1645,3456,565,8196,8733,6632,7799,9788,1128,1606,9131,1060,1703,4627,2932,6546,2858,2034,8891,5007,7155,6660,4078,1258,5097,1697,6892,1827,598,6518,8218,5409,8777,4353,9009,6221,8437,4023,4013,405,2720,7071,1279,4586,133,6693,6844,8306,4707,9016,4797,2822,1995,1707,4509,3765,4933,8920,7134,8704,6940,4008,8340,5932,7582,8220,6408,9827,4349,9928,1638,787,9312,4898,4399,2509,7090,1399,3976,7367,4770,8983,5497,4603,5138,6628,4576,1798,4329,9655,6123,9290,2561,8875,689,2732,9785,1920,2042,3158,1443,7097,2498,7414,9511,3246,1146,9485,9247,6267,1575,8834,8441,5743,225,9389,8152,3790,342,5756,3491,3952,7988,8897,3685,9136,2482,5457,987,6637,8744,6854,3657,5020,4162,8415,1462,8180,7425,7787,9243,3360,2810,6977,1031,6881,2213,6924,9982,4138,4127,8967,6709,6898,9400,9813,3896,4661,3878,7851,2309,1972,7537,9460,1086,6336,9284,9804,5787,1603,7410,8070,1926,5431,8095,2183,7965,1452,6771,6840,6115,1639,2667,3703,319,2381,7880,5782,6091,5292,189,315,214,8259,5365,7615,3267,6997,2490,3023,3496,2635,1359,8766,2288,5582,5176,3393,9673,2992,7709,625,1879,9972,7323,397,9871,5634,6674,885,6413,1893,1480,4816,782,2764,6692,7543,6583,8828,2100,3544,5484,1948,1624,6260,7465,2551,9732,7120,7261,7006,2898,5608,1834,7044,5278,4136,3863,7328,1368,1393,2238,1134,3605,5722,9758,3278,3583,6636,7738,1796,2208,517,3735,2422,1883,9862,9858,2321,4707,8629,6920,2037,9954,1468,2989,3908,5348,5704,9862,1991,3641,4731,1582,3945,3830,746,2421,6282,68,5023,300,4461,288,712,9274,4890,3370,3014,3258,6861,2470,2639,8107,37,9982,8317,607,8134,9949,1805,6284,7047,5221,6785,7102,2501,9642,6318,7331,6686,1910,1423,397,2807,1235,9984,4660,3319,5252,3203,5905,9577,4892,3615,8420,2654,8452,2492,2720,2121,8234,9528,3993,8577,5357,8101,9757,1442,3634,8440,6568,6604,4802,4620,8862,2387,4489,9437,6725,9405,3609,6590,3304,8311,6517,7619,5221,5057,5638,5911,7888,5037,858,2456,6398,1524,8367,7350,7595,9825,205,8808,5876,3267,553,3190,8222,7071,1123,3600,4141,4989,6089,6389,8782,8038,6465,9981,5869,8476,1347,4080,9103,7298,2093,7101,7194,7680,5086,9204,3016,3856,5931,2092,3896,564,3484,5550,4909,9790,5360,7175,1453,4149,1221,2554,8787,7015,6801,588,1277,2769,9884,3111,6750,537,8035,9879,5933,1637,6567,7472,7157,7313,8892,1718,355,9997,6650,5283,363,9037,784,8564,740,5143,5292,1452,8807,8744,8292,3505,1491,7952,6320,1690,9884,4305,3661,4439,3128,8564,4651,7897,6673,5556,1136,2213,3990,5952,8036,869,4409,5101,9075,1559,4786,3794,254,6284,1978,8747,1546,2890,9473,455,5743,5211,3162,8554,8794,4764,9129,4284,8443,7855,9148,4663,7688,3833,9359,9948,3224,3764,3030,6895,761,5534,7879,3591,6203,5593,4781,3871,275,1177,8327,4744,5657,2537,1718,6085,4698,3526,5122,7581,1830,8418,5622,4572,7027,5122,8320,2194,6376,9153,7218,1634,5907,8571,372,9829,8804,6354,2895,8053,6959,5613,6531,722,5294,580,994,5760,6733,9989,5715,2759,3404,178,1056,434,2465,7745,9608,4833,2819,3819,9486,4583,6144,3661,6183,4908,5768,3898,3040,8059,895,966,8743,2165,5535,1165,6541,157,9652,7754,3914,6507,3518,2560,1801,1641,9202,3957,3239,6664,2266,6018,9656,4860,3552,2980,6483,7820,7319,7198,6193,8355,7314,4373,4865,146,8395,9186,4199,7499,2222,5828,8777,7943,7787,9835,7617,5538,215,2478,8654,6874,5803,7894,5762,2979,6788,8753,2661,581,561,9424,3153,1372,7129,4857,6484,5048,5010,5861,2657,1947,8283,6307,8175,798,1363,7812,4600,5979,7279,9389,667,1972,5512,5528,3435,6027,1131,8803,8462,7800,1383,1951,4559,5975,9346,1106,2189,1271,1941,501,6282,1676,9915,8359,8668,9101,2790,9769,4463,8070,7498,9072,8256,2840,6128,7783,9972,3124,5493,8714,3295,8308,6456,8619,6430,5890,9807,9824,9790,6207,5698,2067,8818,3965,7919,1905,1168,6165,1173,4572,1557,6227,7097,5737,2973,933,7716,3603,811,8095,1570,422,6311,6009,9380,1844,9675,7023,8815,3044,5862,7856,2651,5582,2889,1585,2070,9920,8988,8183,9822,6732,4778,3040,5962,6839,7264,2539,7362,4540,2466,2155,4178,5639,4263,6984,8988,4635,4344,8125,8034,1005,9925,2779,3472,406,2320,1733,5840,6788,2639,722,6899,3897,9294,943,8943,4955,2843,2090,4924,9843,2841,8408,2086,5342,2397,1759,3102,2191,5460,1821,5609,2763,8011,399,9455,4939,9509,4395,5389,1325,8745,8183,2612,6196,5378,9903,3192,8420,9581,6355,1537,3382,4094,7046,8957,1242,6555,4240,7468,3440,5679,2237,6947,9838,2137,9021,298,2941,1882,8626,6366,8316,9099,644,3711,4716,3845,1312,8419,178,7894,4837,4337,7704,6147,5846,7367,3835,7136,4987,1205,4862,6746,3807,3120,8758,4094,2739,4512,2909,4335,2618,7986,2976,5475,7979,7542,8353,5511,1587,1330,9557,3095,6192,8029,3334,8647,8806,6565,3138,4493,350,5770,4410,2499,3810,5104,8036,8362,8611,129,1066,1426,5987,553,7801,611,7035,5768,8723,8856,9350,7060,9693,7039,9380,9252,3042,4826,8360,3174,7758,1056,1627,4841,8211,6588,8567,9828,7799,1389,5676,318,3524,565,5710,963,1959,3915,9205,9701,9906,5641,8683,3913,9531,110,1778,662,2682,5292,7708,8490,7983,3035,7521,6164,377,7189,5900,2555,208,904,5150,7237,7708,6167,9178,9361,123,6585,8071,2366,8287,3080,1938,9057,5086,2660,7001,4003,6209,3566,9584,9793,2229,3693,2256,970,6957,5452,8275,2485,3485,4986,602,4376,1217,72,2615,2402,4900,3439,419,4834,5209,1816,7641,5933,8534,5585,9993,9404,2532,5087,966,3099,5856,2534,7720,3868,9565,2323,6443,882,6992,803,9438,4246,9667,8185,9334,9158,9490,7436,1400,7921,401,8870,9186,6188,6707,4534,3954,7696,6948,2127,4749,3881,673,5671,5162,7720,2939,9753,2213,7411,5608,4259,8269,912,1154,2601,9045,5549,9526,1040,5734,4027,4549,2948,4828,5422,2422,4466,4021,991,7394,5038,8278,9482,7191,4415,7653,3888,4294,3534,5007,7782,9046,843,8788,2501,7678,2632,5894,2872,126,5803,1038,3761,2807,6528,2791,9107,734,1077,6433,1033,2829,4125,3775,5566,2,7598,9305,2436,4063,4707,5259,2061,1704,58,5108,405,6568,9158,6504,9990,1580,7710,2223,7569,2166,7453,3780,8124,4795,1808,9830,1711,7398,8523,7594,6998,6067,6180,1847,4338,6004,4230,3704,8872,1936,816,9294,4032,5087,3300,1452,4119,799,3592,2185,5405,2306,9320,6817,2584,1918,9746,836,7360,1451,2728,2198,7585,2153,3346,7549,1756,7591,4057,4215,3621,9517,8093,657,7638,5971,4464,8496,4555,6648,3705,5308,4901,2380,8147,8448,4327,21,8347,44,8572,9278,2725,3203,7791,1332,8071,4253,9361,5736,7660,8390,4678,5391,9314,3517,7576,6565,9517,3078,9331,9989,5906,4057,6263,7475,7948,2417,6634,1346,8811,2653,1379,6430,4592,1954,5360,3044,8019,1479,2785,4661,8893,903,5978,2183,4622,9955,5429,4147,72,4014,8078,2472,2081,1311,229,183,7094,1394,1375,8821,9971,5447,8278,6156,3259,6818,7812,9098,5606,2953,1500,1584,286,9449,9762,6580,1825,2626,4621,7727,5090,3526,5916,3648,1592,6350,9502,5368,3934,1717,7576,1340,1969,5771,5716,8134,7829,7315,7484,8164,4465,4789,8563,5992,2510,8765,7228,1526,5115,4474,1745,6793,3148,2096,9613,2542,6007,2822,6258,3846,5381,2313,6325,1417,3527,7623,9773,1358,6735,629,1095,3172,1666,8922,6789,3629,7613,1777,7402,7325,7789,9067,7839,6959,6277,1755,66,8480,8540,1384,7426,4514,6124,6990,7140,9835,7685,9885,9121,883,6503,3497,7701,4522,1532,9320,9106,5183,2732,807,3547,6202,5078,8182,2745,1507,3534,8183,954,2200,1321,723,1437,5515,802,9205,2775,7314,8889,5724,2945,5782,1855,7981,4151,9444,8092,4528,6842,2351,2585,4894,6287,5228,7222,1289,3215,7748,4373,8420,1285,9973,973,5415,5891,4162,5432,1180,5533,5422,5813,4405,1531,6645,3191,8147,2684,2164,3667,6128,2830,3756,5430,9175,9271,7571,2493,1302,3951,4594,8348,7459,1427,4376,5240,6724,2196,2469,1004,6869,9590,8320,1368,8998,6962,2786,9981,7403,5924,105,5586,6474,9229,3942,594,5632,1554,6559,9660,477,8763,6830,50,5491,9765,5263,826,8235,737,4454,3360,4768,1394,9559,5858,6385,2275,2380,6707,8067,7919,7203,8632,6141,151,3917,7502,6891,2784,1344,7026,5292,3426,5174,5367,4836,5962,5980,1044,4426,1672,3780,2131,2171,7346,2243,9732,8533,751,5412,4040,9197,2317,9251,5334,1594,7260,5906,4345,2295,4449,2375,5375,2005,1636,6828,4044,9158,2962,5502,4917,8132,971,543,5670,6968,3877,2149,4284,3507,951,4008,8604,5544,5631,6999,906,2432,2205,7092,7443,8517,2006,2659,308,1879,241,1023,6016,7626,8141,9302,29,8358,9530,1448,7767,8326,9755,4011,9980,9801,5658,6282,8287,4756,9940,5217,4966,2639,3065,8451,8220,8419,5117,6821,8639,8002,6730,6944,8915,4175,3500,210,8877,5522,8995,318,7384,7733,7205,1063,9668,9977,89,1449,2498,4002,2572,3713,6953,3031,2416,751,5748,1331,4873,11,2834,1815,7118,4046,933,5941,9182,2052,9331,9078,9736,4785,8536,966,7121,2889,1170,1827,9154,1717,7508,6401,2120,629,4788,6632,6291,2233,3804,5604,2695,9463,1116,2437,1069,3705,5430,9485,2643,2059,2561,1316,7560,9601,8616,5159,8465,2175,7704,6117,887,1519,4501,289,2247,2063,8757,9971,6592,7504,883,9783,232,1144,8718,9868,920,6785,2391,2117,1291,7144,7079,604,2947,6783,6982,3802,340,2379,5301,4049,5623,7718,7285,2626,1961,6094,5902,7431,2585,7460,3561,906,7389,879,646,1132,6606,6678,4583,4831,1047,9081,83,1340,810,7065,8228,623,9819,1836,9881,757,8851,6746,7013,3301,3934,8690,1134,9252,3789,6086,6175,6815,5093,3882,7990,2757,7727,5865,3527,3947,2982,5712,7815,6182,2380,9729,7857,9668,2469,5010,5029,2676,4921,9739,9300,3081,3366,652,6837,1083,8269,164,2068,2101,3153,4059,7629,3064,1243,2425,5733,5879,2616,6876,6018,2681,9481,8311,7774,9131,7537,2205,4280,5435,3867,5562,3730,974,4226,4106,1604,2586,9527,7088,8488,2093,3071,9025,396,6996,1570,9062,6979,8709,4317,5406,1428,1526,4721,6313,4201,9571,3538,1294,3810,9148,184,9910,112,724,3153,6286,2618,1779,5133,8169,8171,6709,2881,9724,9617,8073,7141,9969,9840,6612,134,4340,6237,11,5988,7833,4868,3516,9749,4660,7635,2854,4465,4639,4524,8124,787,9752,1351,9669,7742,2592,925,7103,2310,5261,958,2216,8147,6153,9644,2596,754,8128,8702,9114,883,8070,2238,9415,9276,8287,3339,3785,5604,7333,5640,6372,3833,8646,7755,4929,5803,1444,7039,7658,798,1363,8082,6400,3132,3405,5176,2837,8449,4369,6310,6914,2493,5664,3624,6162,7638,2560,3035,5125,883,4889,2211,4110,7138,2378,2263,9926,8307,5140,1904,4743,298,1774,6062,6849,6545,2880,659,3416,9859,6440,2821,5732,7427,4328,3536,3359,9699,7621,7778,4267,829,1530,2942,3562,302,2083,2602,100,8261,1843,5312,4,6729,4478,9120,7355,3808,6943,701,2700,4281,1636,6092,5198,6499,7165,1688,5470,2243,4656,1713,3066,9874,2456,2839,8902,6541,3281,5188,8283,4676,750,1120,5651,2859,52,1978,2415,7819,3180,1814,6369,7058,5636,9641,6914,287,8079,3807,7853,1367,8224,1574,4274,7395,5171,1008,2036,7504,4709,5397,9403,7981,7223,159,5795,9280,6079,4396,3451,8562,4678,3775,1111,494,7067,8526,2031,9734,2254,9030,1918,9710,6774,5603,1587,6399,7132,3673,6435,2197,2398,6574,6645,7490,5453,2381,4517,4921,1503,2996,3505,483,829,7302,3215,573,406,3803,1925,5816,9531,4011,8112,9880,321,8135,7774,5302,8194,544,5155,8750,1548,381,6632,6354,3120,106,2407,8357,6100,4804,817,9744,8626,1949,4616,6176,5751,3998,5589,8758,6548,5664,5747,8502,2929,8850,1554,472,3493,9415,1349,7611,2687,7653,9012,4365,4256,8630,5899,3684,7358,7914,9929,2072,4899,8324,2530,6118,972,6153,1710,847,2779,8996,3751,4566,6806,4037,4831,1190,4997,8941,1096,5658,3495,9043,506,9043,6286,9922,784,3894,1886,361,91,6683,6322,6329,3246,9551,6968,6539,1808,595,4896,7608,3277,5178,2272,8094,9237,8191,2291,8306,588,7197,7189,1912,2664,5669,4297,7773,8375,7771,7779,590,9654,4361,6575,3646,9946,203,3800,7428,9547,7650,6657,1722,4996,1665,6128,1327,1429,6403,7870,7894,1201,9187,9400,9429,1392,7522,7601,7239,4062,516,958,8571,4538,7107,8040,5122,8600,6315,6814,9796,8128,1868,3344,3644,1500,8780,2645,2344,5342,8562,2134,2410,5128,4348,6512,9273,5314,5402,8134,657,5463,416,7581,911,280,2504,3503,133,6247,494,5705,5820,2238,6162,7100,5021,1302,1834,4527,7943,1760,6253,283,4333,6720,1465,9214,2533,8188,5661,1145,8921,3073,1024,4546,5146,959,1816,2371,4856,7768,4164,8921,27,8213,4947,8085,7646,5617,395,6846,1646,9163,483,9246,2623,1049,8808,7937,4631,7504,5196,3657,945,6701,2642,8028,3580,9695,3076,6756,6986,5994,1021,8222,7265,4021,7055,3788,5389,5805,9967,499,156,1856,7796,3694,8288,3795,4523,7417,8769,8829,2102,8054,4729,7289,5368,7276,6422,6696,2347,5874,6475,5037,9642,9497,6495,6799,8583,7536,1548,906,3878,653,5329,9806,4704,9547,577,5182,1202,3830,8130,1379,7371,8593,2303,7063,8753,6752,3671,6042,5789,7070,7067,3713,8218,9817,1667,866,2890,7633,1386,3928,5953,5548,7454,901,8712,1781,9377,1803,9163,7928,9643,5138,9115,3304,309,470,5469,9194,4255,966,7914,6759,9675,9190,1581,4814,5023,1006,8,3471,6711,9592,2191,561,7298,5190,6219,3165,9056,2793,2856,6160,2074,9323,9879,4205,4074,7095,7229,3337,8670,4475,9234,7741,1130,9421,7475,1336,6707,1923,3057,7323,5396,5273,3120,8954,2685,287,1705,626,9951,1321,3944,8749,9073,4973,6062,5631,1918,1448,8272,5981,9269,922,1606,1025,5352,4421,6205,2328,7309,1826,7318,4707,5440,3003,9332,8841,2111,1378,6770,5956,6748,3513,1147,8976,9183,1208,6384,6143,5090,7595,7286,4775,4435,2113,3941,3330,7957,3614,4170,7805,7295,73,8597,5977,9323,9263,1036,8350,8552,3710,4967,3747,3577,4091,5826,3495,3028,301,6910,5419,5652,1551,7039,342,9784,9602,4767,4800,4801,7880,9898,8167,5272,1242,4272,5133,2725,308,7607,8311,9881,6052,4791,4976,6629,622,8235,8580,7729,7914,8774,3413,8934,7733,4492,634,6292,7500,5973,5899,7613,1412,7261,374,5736,3509,1863,3901,1359,2826,9765,3030,2097,402,4994,1497,6593,2066,6840,4278,4261,7857,7194,4332,8376,4699,620,2851,3464,2127,2213,2355,2712,1409,1716,8379,7007,1960,7960,635,2488,5681,9863,5082,736,5658,6168,8769,2860,3896,7881,877,2240,1426,1833,993,328,3251,7215,2178,4307,9084,385,4681,8355,8639,4782,6229,1470,1253,5125,4982,7616,5785,4411,467,2951,507,2730,9461,3333,767,3388,6490,3538,3995,8308,5635,9656,2940,9077,8502,6101,6625,7737,3324,540,8015,7531,6292,2484,1963,8589,8750,7191,1107,8755,1313,9141,7686,3910,8391,4063,3879,1907,2507,1068,4686,5497,7441,3511,7799,6015,2399,7902,4128,2651,428,6501,2335,2827,1336,6337,8283,5104,2004,4846,5150,6015,421,906,8313,3102,2981,9159,2896,4685,594,7885,5738,4314,8158,2421,3314,4299,6477,7039,9881,8489,5850,9101,353,9967,4578,8678,8003,9855,8039,7300,2170,8989,2414,7318,3894,4450,4465,207,7291,7818,2239,9925,623,998,1031,7651,4399,2779,5792,2087,426,9698,1284,2676,8980,5638,7921,8401,1317,2521,2919,169,7000,2831,8764,9994,333,2544,3275,4502,6983,9595,1776,8724,366,5966,942,5567,7021,2383,4921,1206,2053,5606,1900,3723,5849,1728,2597,7972,1008,5086,2436,2381,471,9300,2912,8212,4732,5834,7489,3308,5780,9310,5735,1355,373,9601,3842,1595,4621,8917,7479,5708,8729,7541,7826 }, +360, +10013, + }, + + { + []int{2, 1, 2, 1, 2}, + 1, + 5, + }, + + { + []int{2, 1, 2, 1, 2}, + 2, + 10, + }, + + { + []int{1, 2, 1, 2, 3}, + 2, + 7, + }, + + { + []int{1, 2, 1, 3, 4}, + 3, + 3, + }, + + // 可以有多个 testcase +} + +func Test_subarraysWithKDistinct(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, subarraysWithKDistinct(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_subarraysWithKDistinct(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + subarraysWithKDistinct(tc.A, tc.K) + } + } +} diff --git a/Algorithms/0993.cousins-in-binary-tree/1.png b/Algorithms/0993.cousins-in-binary-tree/1.png new file mode 100644 index 000000000..5d4c50ae4 Binary files /dev/null and b/Algorithms/0993.cousins-in-binary-tree/1.png differ diff --git a/Algorithms/0993.cousins-in-binary-tree/2.png b/Algorithms/0993.cousins-in-binary-tree/2.png new file mode 100644 index 000000000..56574fb43 Binary files /dev/null and b/Algorithms/0993.cousins-in-binary-tree/2.png differ diff --git a/Algorithms/0993.cousins-in-binary-tree/3.png b/Algorithms/0993.cousins-in-binary-tree/3.png new file mode 100644 index 000000000..e7a7aaf62 Binary files /dev/null and b/Algorithms/0993.cousins-in-binary-tree/3.png differ diff --git a/Algorithms/0993.cousins-in-binary-tree/README.md b/Algorithms/0993.cousins-in-binary-tree/README.md new file mode 100755 index 000000000..b3e3e6d85 --- /dev/null +++ b/Algorithms/0993.cousins-in-binary-tree/README.md @@ -0,0 +1,41 @@ +# [993. Cousins in Binary Tree](https://leetcode.com/problems/cousins-in-binary-tree/) + +In a binary tree, the root node is at depth 0, and children of each depth k node are at depth k+1. + +Two nodes of a binary tree are cousins if they have the same depth, but have different parents. + +We are given the root of a binary tree with unique values, and the values x and y of two different nodes in the tree. + +Return true if and only if the nodes corresponding to the values x and y are cousins. + +Example 1: + +![1](1.png) + +```text +Input: root = [1,2,3,4], x = 4, y = 3 +Output: false +``` + +Example 2: + +![2](2.png) + +```text +Input: root = [1,2,3,null,4,null,5], x = 5, y = 4 +Output: true +``` + +Example 3: + +![3](3.png) + +```text +Input: root = [1,2,3,null,4], x = 2, y = 3 +Output: false +``` + +Note: + +- The number of nodes in the tree will be between 2 and 100. +- Each node has a unique integer value from 1 to 100. \ No newline at end of file diff --git a/Algorithms/0993.cousins-in-binary-tree/cousins-in-binary-tree.go b/Algorithms/0993.cousins-in-binary-tree/cousins-in-binary-tree.go new file mode 100755 index 000000000..2695bbc3f --- /dev/null +++ b/Algorithms/0993.cousins-in-binary-tree/cousins-in-binary-tree.go @@ -0,0 +1,37 @@ +package problem0993 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is Pre-defined.... +type TreeNode = kit.TreeNode + +func isCousins(root *TreeNode, x int, y int) bool { + root = &TreeNode{Left: root} + px, dx := dfs(root, x) + py, dy := dfs(root, y) + return dx == dy && px != py +} + +// dfs do NOT check the first root +func dfs(root *TreeNode, x int) (*TreeNode, int) { + if root == nil { + return nil, 0 + } + + if (root.Left != nil && root.Left.Val == x) || + (root.Right != nil && root.Right.Val == x) { + return root, 1 + } + + if parent, depth := dfs(root.Left, x); depth > 0 { + return parent, depth + 1 + } + + if parent, depth := dfs(root.Right, x); depth > 0 { + return parent, depth + 1 + } + + return nil, 0 +} diff --git a/Algorithms/0993.cousins-in-binary-tree/cousins-in-binary-tree_test.go b/Algorithms/0993.cousins-in-binary-tree/cousins-in-binary-tree_test.go new file mode 100755 index 000000000..4b6a0ade2 --- /dev/null +++ b/Algorithms/0993.cousins-in-binary-tree/cousins-in-binary-tree_test.go @@ -0,0 +1,58 @@ +package problem0993 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + x int + y int + ans bool +}{ + + { + []int{1, 2, 3, 4}, + 4, + 3, + false, + }, + + { + []int{1, 2, 3, kit.NULL, 4, kit.NULL, 5}, + 5, + 4, + true, + }, + + { + []int{1, 2, 3, kit.NULL, 4}, + 2, + 3, + false, + }, + + // 可以有多个 testcase +} + +func Test_isCousins(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, isCousins(root, tc.x, tc.y), "输入:%v", tc) + } +} + +func Benchmark_isCousins(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + isCousins(root, tc.x, tc.y) + } + } +} diff --git a/Algorithms/0994.rotting-oranges/1.png b/Algorithms/0994.rotting-oranges/1.png new file mode 100644 index 000000000..ce69a318d Binary files /dev/null and b/Algorithms/0994.rotting-oranges/1.png differ diff --git a/Algorithms/0994.rotting-oranges/README.md b/Algorithms/0994.rotting-oranges/README.md new file mode 100755 index 000000000..40eb0e0a6 --- /dev/null +++ b/Algorithms/0994.rotting-oranges/README.md @@ -0,0 +1,42 @@ +# [994. Rotting Oranges](https://leetcode.com/problems/rotting-oranges/) + +In a given grid, each cell can have one of three values: + +- the value 0 representing an empty cell; +- the value 1 representing a fresh orange; +- the value 2 representing a rotten orange. + +Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. + +Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1 instead. + +![1](1.png) + +Example 1: + +```text +Input: [[2,1,1],[1,1,0],[0,1,1]] +Output: 4 +``` + +Example 2: + +```text +Input: [[2,1,1],[0,1,1],[1,0,1]] +Output: -1 +Explanation: The orange in the bottom left corner (row 2, column 0) is never rotten, because rotting only happens 4-directionally. +``` + +Example 3: + +```text +Input: [[0,2]] +Output: 0 +Explanation: Since there are already no fresh oranges at minute 0, the answer is just 0. +``` + +Note: + +- 1 <= grid.length <= 10 +- 1 <= grid[0].length <= 10 +- grid[i][j] is only 0, 1, or 2. diff --git a/Algorithms/0994.rotting-oranges/rotting-oranges.go b/Algorithms/0994.rotting-oranges/rotting-oranges.go new file mode 100755 index 000000000..0e43ba374 --- /dev/null +++ b/Algorithms/0994.rotting-oranges/rotting-oranges.go @@ -0,0 +1,51 @@ +package problem0994 + +var dx = [4]int{0, 0, -1, 1} +var dy = [4]int{-1, 1, 0, 0} + +func orangesRotting(grid [][]int) int { + m, n := len(grid), len(grid[0]) + + fresh := 0 + rottens := make([][2]int, 0, m*n) + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + switch grid[i][j] { + case 1: + fresh++ + case 2: + rottens = append(rottens, [2]int{i, j}) + } + } + } + + if fresh == 0 { // special case + return 0 + } + + count := -1 + for len(rottens) > 0 { + count++ + size := len(rottens) + for r := 0; r < size; r++ { + x, y := rottens[r][0], rottens[r][1] + for k := 0; k < 4; k++ { + i, j := x+dx[k], y+dy[k] + if i < 0 || m <= i || + j < 0 || n <= j || + grid[i][j] != 1 { + continue + } + grid[i][j] = 2 + fresh-- + rottens = append(rottens, [2]int{i, j}) + } + } + rottens = rottens[size:] + } + + if fresh > 0 { + return -1 + } + return count +} diff --git a/Algorithms/0994.rotting-oranges/rotting-oranges_test.go b/Algorithms/0994.rotting-oranges/rotting-oranges_test.go new file mode 100755 index 000000000..fc538e78b --- /dev/null +++ b/Algorithms/0994.rotting-oranges/rotting-oranges_test.go @@ -0,0 +1,52 @@ +package problem0994 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + ans int +}{ + + { + [][]int{{2, 1, 1}, {1, 1, 0}, {0, 1, 1}}, + 4, + }, + + { + [][]int{{2, 1, 1}, {0, 1, 1}, {1, 0, 1}}, + -1, + }, + + { + [][]int{{0, 2}}, + 0, + }, + + { + [][]int{{0}}, + 0, + }, + + // 可以有多个 testcase +} + +func Test_orangesRotting(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, orangesRotting(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_orangesRotting(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + orangesRotting(tc.grid) + } + } +} diff --git a/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/README.md b/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/README.md new file mode 100755 index 000000000..5cbd4eeaa --- /dev/null +++ b/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/README.md @@ -0,0 +1,37 @@ +# [995. Minimum Number of K Consecutive Bit Flips](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/) + +In an array A containing only 0s and 1s, a K-bit flip consists of choosing a (contiguous) subarray of length K and simultaneously changing every 0 in the subarray to 1, and every 1 in the subarray to 0. + +Return the minimum number of K-bit flips required so that there is no 0 in the array. If it is not possible, return -1. + +Example 1: + +```text +Input: A = [0,1,0], K = 1 +Output: 2 +Explanation: Flip A[0], then flip A[2]. +``` + +Example 2: + +```text +Input: A = [1,1,0], K = 2 +Output: -1 +Explanation: No matter how we flip subarrays of size 2, we can't make the array become [1,1,1]. +``` + +Example 3: + +```text +Input: A = [0,0,0,1,0,1,1,0], K = 3 +Output: 3 +Explanation: +Flip A[0],A[1],A[2]: A becomes [1,1,1,1,0,1,1,0] +Flip A[4],A[5],A[6]: A becomes [1,1,1,1,1,0,0,0] +Flip A[5],A[6],A[7]: A becomes [1,1,1,1,1,1,1,1] +``` + +Note: + +- `1 <= A.length <= 30000` +- `1 <= K <= A.length` diff --git a/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/minimum-number-of-k-consecutive-bit-flips.go b/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/minimum-number-of-k-consecutive-bit-flips.go new file mode 100755 index 000000000..a2d9fa1bb --- /dev/null +++ b/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/minimum-number-of-k-consecutive-bit-flips.go @@ -0,0 +1,24 @@ +package problem0995 + +func minKBitFlips(A []int, K int) int { + size := len(A) + + swap := make([]int, size+1) + flag := 1 + + res := 0 + for i := 0; i < size; i++ { + flag ^= swap[i] + if A[i] == flag { + continue + } + if i+K > size { + return -1 + } + res++ + flag ^= 1 // swap flag + swap[i+K] = 1 // swap flag back when i+K + } + + return res +} diff --git a/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/minimum-number-of-k-consecutive-bit-flips_test.go b/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/minimum-number-of-k-consecutive-bit-flips_test.go new file mode 100755 index 000000000..760303883 --- /dev/null +++ b/Algorithms/0995.minimum-number-of-k-consecutive-bit-flips/minimum-number-of-k-consecutive-bit-flips_test.go @@ -0,0 +1,57 @@ +package problem0995 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans int +}{ + + { + []int{0, 1, 0}, + 1, + 2, + }, + + { +[]int{ 0,0,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,0,1,0,1,0,1,1,1,1,0,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,1,0,1,0,1,1,0,1,1,1,1,0,1,1,1,1,0,0,0,1,0,0,1,1,1,1,1,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,0,0,0,0,0,0,0,1,1,1,0,1,0,1,1,1,0,1,0,0,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,1,1,0,0,0,0,0,1,0,1,1,1,1,1,1,1,0,1,1,0,0,1,0,1,0,0,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1,1,0,1,1,1,1,1,0,1,0,1,0,1,0,0,1,1,1,1,0,1,1,0,0,1,1,0,0,0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,0,0,0,1,0,1,0,1,1,0,0,0,1,0,0,1,0,0,0,1,1,0,1,1,0,1,1,1,0,1,1,1,1,0,0,1,0,0,1,1,0,1,0,1,0,1,1,0,1,1,1,0,1,0,1,0,1,0,0,1,0,0,0,1,1,1,0,0,0,0,1,1,0,0,1,0,1,1,0,1,1,1,0,0,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,1,1,0,0,1,1,0,1,0,0,1,1,0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,1,1,0,1,1,0,0,0,0,1,1,0,1,1,1,0,1,1,1,1,1,0,1,1,1,1,0,0,0,0,0,1,1,1,0,1,0,1,1,0,0,0,1,1,0,1,1,1,0,1,1,1,1,0,1,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,0,0,1,1,0,1,0,0,0,1,0,1,1,0,1,0,1,0,1,1,0,1,1,0,0,1,1,1,1,1,0,1,1,1,1,1,0,0,1,0,0,0,1,1,1,0,1,0,0,1,0,0,1,1,0,0,1,1,0,1,1,0,1,1,1,1,0,0,0,1,1,1,1,0,1,1,0,1,1,0,1,0,1,1,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,0,0,0,0,1,0,1,0,0,1,0,1,1,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,1,1,0,1,1,0,0,0,1,0,1,0,1,0,0,0,1,1,0,0,0,1,0,0,0,0,1,0,1,1,1,1,0,1,1,0,1,1,1,0,1,1,0,1,0,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,0,1,0,0,0,1,0,0,1,1,0,0,1,0,1,1,0,0,0,1,1,1,1,1,0,0,1,1,1,1,0,1,1,0,1,1,0,1,0,1,0,0,1,0,1,1,0,1,1,1,0,0,0,0,0,0,1,1,0,1,0,0,0,0,1,1,1,0,1,1,0,0,1,1,0,0,0,0,1,1,1,0,0,1,1,0,1,1,0,1,0,1,0,0,1,0,1,1,1,0,1,1,1,0,1,1,0,0,1,0,0,1,0,1,0,0,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,0,0,1,0,1,0,0,0,0,0,1,1,1,0,0,1,0,1,0,1,1,0,0,1,1,1,1,1,0,1,0,1,1,1,1,0,1,0,1,1,0,1,0,1,1,0,1,1,0,0,1,1,0,0,1,1,0,1,1,1,1,1,0,1,1,0,1,1,1,0,0,0,0,1,0,0,0,1,1,1,0,1,1,0,1,0,1,1,0,1,1,1,0,1,0,0,0,1,1,0,1,0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,0,1,0,1,0,0,0,0,0,1,1,0,1,0,0,0,1,1,0,1,0,1,0,0,0,0,0,0,0,1,1,1,0,1,1,0,1,0,0,0,0,1,1,1,1,1,1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,1,0,1,0,0,0,0,1,1,1,0,1,1,0,1,1,1,0,1,0,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,1,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,0,1,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,0,1,0,1,1,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,0,1,0,1,0,0,1,1,1,0,0,1,1,0,0,0,1,1,1,0,1,0,0,1,0,0,1,1,1,0,1,1,1,0,0,1,1,0,1,1,0,1,0,1,0,0,0,1,1,1,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,1,0,0,1,1,0,0,0,0,1,0,0,1,0,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,0,1,1,0,1,1,1,1,0,0,1,0,0,0,0,1,0,1,0,1,1,0,0,0,1,0,1,0,0,0,1,0,0,1,1,1,0,1,0,1,1,1,1,0,0,1,0,0,0,0,1,0,1,0,0,1,1,1,0,0,1,1,0,1,1,1,0,0,1,0,1,1,0,0,0,1,1,1,0,0,1,1,0,0,0,1,1,0,1,1,1,1,1,0,1,0,1,1,1,0,0,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,1,0,0,0,1,0,1,0,1,0,0,1,0,1,0,1,1,0,0,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,1,0,0,0,0,0,0,0,1,1,1,1,0,1,1,0,0,1,1,1,1,1,1,0,1,1,1,0,0,0,1,0,1,0,0,1,0,0,0,0,1,0,0,1,1,1,1,0,1,1,0,1,0,1,0,1,1,0,1,1,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,1,1,1,0,0,0,1,0,1,1,0,1,1,0,0,1,1,1,1,0,0,1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,0,1,1,1,1,0,1,0,1,1,1,0,1,0,0,1,1,0,0,0,1,1,1,1,1,1,0,0,1,0,0,0,0,0,1,1,0,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,0,0,1,1,1,0,1,1,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,1,1,0,0,0,0,1,1,0,1,0,0,0,1,1,1,0,0,0,0,0,0,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,1,1,1,0,1,1,0,0,0,0,1,0,0,1,0,1,1,0,0,1,1,1,0,0,0,1,0,1,1,1,1,1,1,0,0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,1,1,1,0,0,1,1,0,1,0,0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,0,0,1,0,0,0,1,1,0,0,1,0,0,0,1,1,0,1,0,1,1,0,1,1,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,0,1,1,0,0,1,1,0,1,0,1,0,1,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,0,1,0,0,1,1,0,1,1,1,0,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,0,1,1,0,1,0,0,1,0,1,1,1,0,1,0,1,1,1,1,0,1,1,1,0,1,0,0,1,1,1,0,1,0,0,1,0,0,1,1,1,0,0,0,1,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,0,1,1,0,1,0,0,1,1,0,1,1,0,0,1,1,1,1,0,0,1,0,1,1,1,0,0,1,0,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0,1,0,1,0,0,0,0,1,0,1,1,0,0,0,1,1,1,1,0,1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,0,1,1,0,0,1,1,1,0,0,1,1,0,0,1,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1,1,1,0,1,0,0,0,0,1,1,0,1,0,1,1,0,0,1,0,1,1,1,0,0,1,1,0,1,1,1,0,1,1,0,1,0,0,1,0,1,0,0,0,1,1,0,0,0,0,0,1,1,0,0,0,1,1,1,1,0,0,0,1,0,0,0,1,0,1,0,1,1,1,0,0,0,1,1,1,0,0,1,0,1,0,0,0,1,1,0,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,0,1,1,1,1,1,0,1,1,1,1,1,1,0,1,0,1,1,0,1,0,0,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,1,0,0,1,0,0,1,0,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,0,0,1,1,1,1,0,1,0,1,1,0,0,1,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,1,0,1,1,0,0,0,0,0,0,1,0,0,1,1,0,0,0,1,1,1,0,0,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,1,1,1,0,0,1,1,1,1,0,0,0,1,1,0,1,1,0,1,0,1,0,1,1,0,0,0,0,0,1,1,0,0,0,0,1,1,1,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,1,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,1,1,1,0,1,1,1,1,0,1,0,0,1,0,0,1,1,0,1,1,0,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1,1,0,1,0,0,0,0,0,1,0,0,1,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,0,0,1,0,0,1,1,0,1,1,0,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,1,0,1,1,0,0,1,0,0,1,1,1,0,0,0,1,1,1,0,1,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,1,1,1,1,0,0,1,1,1,0,0,1,1,0,0,1,1,0,1,1,1,0,1,0,0,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,1,0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1,0,0,1,0,1,1,1,1,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,0,1,1,1,1,0,0,0,0,1,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,0,1,0,1,1,0,1,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,0,1,0,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,1,0,1,1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,1,0,1,1,1,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,0,1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,0,0,1,1,0,1,1,1,0,0,0,0,0,1,1,1,1,1,0,1,1,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,0,1,0,1,1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,1,0,0,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,1,1,0,1,0,0,0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,1,0,1,0,1,1,0,1,0,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,0,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,1,0,0,0,1,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,1,1,0,0,0,1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,0,0,1,1,0,0,1,1,1,1,0,0,1,0,1,1,0,1,1,0,1,1,0,1,1,1,1,0,1,0,0,0,1,0,0,1,0,0,1,1,0,0,0,1,0,0,1,1,0,0,1,1,1,0,1,1,0,0,1,1,0,1,0,1,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,1,1,0,1,0,1,0,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,0,1,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,1,0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,1,1,0,1,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1,1,0,0,1,0,0,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1,1,1,1,0,1,1,0,0,0,1,0,1,0,0,1,1,1,0,0,1,1,0,1,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,1,1,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,1,0,0,0,0,1,1,0,1,1,0,0,0,1,0,1,0,0,1,0,0,0,0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,1,1,0,1,0,0,0,1,1,0,1,1,1,0,1,1,1,0,1,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,0,0,0,0,1,0,0,0,1,1,0,1,0,0,1,1,1,0,1,1,0,1,1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,1,1,1,0,0,1,0,1,0,0,0,0,1,0,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,0,1,0,1,1,1,1,0,1,0,0,0,0,0,1,0,1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,1,1,1,0,1,0,0,1,1,1,0,1,0,1,1,1,0,1,0,1,0,1,1,0,0,0,1,0,0,0,1,0,1,1,1,1,0,1,0,1,0,0,0,0,0,0,1,1,0,1,1,0,1,0,1,1,1,0,1,1,0,0,0,0,1,0,0,0,1,0,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,1,0,1,1,1,0,0,1,1,0,0,1,0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,0,0,1,1,0,1,0,0,1,1,1,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,0,0,1,1,0,1,0,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,1,1,1,0,1,0,1,1,0,1,0,1,1,1,1,1,1,1,1,1,0,1,1,0,1,0,1,0,1,1,0,0,1,1,1,0,1,0,1,1,1,0,0,1,0,1,0,1,0,1,1,1,1,0,1,1,0,0,0,1,0,1,0,0,0,1,1,0,0,1,1,1,0,1,0,1,1,1,1,0,0,1,1,0,0,0,1,0,0,0,1,1,1,0,0,0,0,1,1,0,1,0,1,1,1,0,0,0,1,0,0,1,1,1,1,0,1,1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,0,1,0,0,1,0,0,1,0,0,0,0,1,1,1,0,0,1,1,0,0,0,1,0,1,0,1,0,0,1,1,1,1,0,0,0,1,0,1,1,0,1,1,1,1,0,1,1,1,1,1,0,0,0,1,1,0,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,1,1,1,0,0,0,1,0,0,1,1,1,0,0,0,0,1,1,0,1,0,0,0,1,1,0,1,0,0,1,0,0,1,0,1,0,1,0,1,1,1,0,1,1,1,0,1,1,1,0,0,1,0,1,0,0,1,0,1,1,0,0,1,0,1,0,1,1,0,0,0,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,0,0,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,0,1,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,1,0,0,1,1,0,1,0,1,1,0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,0,0,0,0,1,0,0,1,1,1,1,0,1,1,0,0,1,1,0,1,0,0,1,1,1,0,0,1,0,1,0,1,0,1,1,1,1,0,1,1,1,1,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,1,1,1,0,1,0,0,1,1,0,1,1,1,0,0,1,0,0,0,0,1,0,0,1,1,1,1,0,1,0,1,0,0,1,1,1,0,1,0,1,1,1,0,0,1,0,1,0,1,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,1,0,1,1,1,1,0,0,0,0,1,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,1,0,0,1,0,1,0,1,1,1,0,1,0,1,1,1,1,1,1,0,1,1,1,0,1,0,0,1,1,1,0,0,0,1,1,0,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,0,0,1,1,1,1,1,1,1,1,0,1,1,1,0,0,1,0,1,1,1,1,1,0,1,0,1,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,1,0,1,1,1,0,0,1,1,1,0,1,1,0,0,1,0,0,1,1,0,1,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,1,0,0,0,1,0,1,0,1,1,0,0,1,1,0,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,1,0,1,1,0,1,0,0,1,0,1,0,1,0,0,0,0,1,1,0,1,0,0,1,0,1,1,1,0,1,0,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,0,0,0,1,1,0,1,0,1,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,0,1,0,1,1,0,0,1,0,0,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1,0,1,1,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,1,0,1,1,0,0,1,1,0,1,1,1,0,1,1,0,0,1,1,1,0,0,1,1,0,0,0,1,0,1,1,1,1,1,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0,1,1,1,1,0,1,1,1,0,0,0,0,1,0,0,1,1,1,1,1,1,1,0,1,0,1,1,1,1,0,0,1,1,0,1,1,0,0,1,1,0,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0,0,1,1,1,1,1,0,0,0,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,1,0,1,0,0,0,0,1,1,0,0,0,1,1,1,0,0,1,0,1,1,1,0,0,1,1,1,1,1,1,0,1,0,0,0,0,0,1,1,1,1,0,0,1,1,0,1,0,0,1,1,0,1,0,0,0,1,0,1,0,1,0,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,1,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,0,1,0,1,1,1,0,1,1,0,1,1,0,1,0,1,1,0,1,0,1,0,1,0,1,1,0,1,1,1,1,1,1,0,0,1,1,1,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,0,1,0,0,0,0,0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,0,1,1,1,0,1,1,0,0,1,0,0,0,0,1,0,0,1,0,1,1,0,1,1,1,1,0,1,1,1,0,1,1,0,0,0,1,1,1,0,1,0,1,0,1,1,0,1,0,0,1,1,0,1,1,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,1,0,1,0,1,0,0,1,1,0,1,0,0,0,0,0,1,0,0,1,1,1,0,1,1,1,1,1,1,0,1,1,0,0,1,0,0,0,1,1,0,0,0,0,0,1,1,0,1,0,1,0,1,1,1,0,1,1,1,1,0,0,1,1,1,0,0,0,0,0,1,0,0,1,0,1,1,1,0,0,1,0,1,1,0,0,0,1,0,1,0,0,0,0,1,0,1,0,0,1,1,0,1,1,1,1,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,0,1,0,1,1,1,0,0,0,1,1,0,0,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,0,0,0,1,0,1,1,0,1,0,1,0,0,0,1,0,0,1,0,0,0,1,1,0,1,1,0,1,0,0,1,0,0,1,1,1,1,0,1,1,0,1,1,1,1,1,1,0,1,0,0,1,1,0,0,0,0,0,0,1,1,0,1,1,0,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,0,0,0,1,1,0,1,0,0,1,1,1,0,1,0,1,0,1,1,1,1,1,1,0,0,0,0,1,0,0,0,0,1,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,0,0,0,1,0,1,1,0,0,0,1,1,1,1,0,0,1,0,1,0,1,1,1,1,0,1,1,0,1,0,1,1,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,0,0,0,0,1,0,1,0,1,1,1,1,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,1,1,0,0,1,0,1,1,1,1,1,1,1,0,0,0,1,0,0,0,1,1,0,0,1,1,1,1,0,0,1,0,1,1,0,0,0,0,1,1,1,1,1,0,1,1,1,1,1,1,0,0,1,1,0,1,0,1,0,0,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,1,1,0,0,0,1,1,1,0,1,0,0,0,1,1,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,1,0,0,1,0,1,1,1,0,0,0,1,1,0,1,0,0,1,1,1,1,1,1,0,1,1,1,1,1,0,1,0,0,0,1,0,1,1,1,0,0,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,1,1,1,0,0,1,0,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,1,1,0,1,0,0,1,1,0,1,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,1,1,1,0,0,1,1,0,0,1,1,0,0,0,0,0,1,1,1,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1,0,0,0,0,1,0,1,0,0,1,0,1,0,1,1,0,0,1,1,0,0,0,0,0,1,0,0,0,1,1,0,1,1,0,0,1,0,0,1,1,1,1,0,0,1,1,1,0,0,0,0,1,0,1,1,0,1,1,1,1,0,1,0,1,1,1,1,0,0,0,0,0,1,0,1,0,1,0,0,0,1,1,0,1,1,0,1,0,1,0,1,1,1,1,1,1,1,0,0,0,1,1,0,1,0,0,1,0,0,0,1,1,1,1,0,1,1,0,1,1,1,1,1,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,1,0,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,0,0,1,0,0,1,1,0,1,1,0,0,0,1,0,0,1,1,0,0,1,0,1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,1,0,1,1,0,0,1,0,0,1,1,1,0,0,0,1,1,1,0,1,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1,1,0,0,0,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,1,1,1,1,0,0,1,1,1,0,0,1,1,0,0,1,1,0,1,1,1,0,1,0,0,0,0,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,1,0,1,0,0,1,0,1,0,0,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,1,1,1,0,1,0,0,1,0,0,0,1,0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,0,1,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1,0,0,1,0,1,1,1,1,0,0,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,0,1,1,1,1,0,0,0,0,1,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,0,1,0,1,1,0,1,0,1,1,1,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,1,1,0,1,0,1,1,1,0,0,0,1,1,0,0,0,1,0,0,0,0,0,1,1,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,1,0,1,1,0,1,1,0,1,1,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,1,1,1,0,0,0,1,1,0,0,0,0,1,1,0,0,0,0,1,1,0,1,1,0,0,1,0,1,1,1,0,1,1,0,0,1,0,1,1,0,0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,0,1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,0,0,1,1,0,1,1,1,0,0,0,0,0,1,1,1,1,1,0,1,1,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,1,0,1,0,1,1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,0,0,0,1,1,0,0,1,0,1,0,0,1,1,1,1,1,1,0,1,0,1,1,1,1,1,0,1,1,0,1,1,1,1,0,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,1,1,0,1,0,0,0,1,1,1,1,1,0,1,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,0,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,1,1,0,1,0,1,0,1,1,0,1,0,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,0,1,1,0,0,1,1,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,1,0,0,0,1,1,0,0,0,1,0,1,1,0,1,1,0,0,0,0,1,0,0,0,1,0,1,0,1,1,0,0,0,1,1,0,0,1,1,1,1,0,1,1,1,1,0,1,0,0,1,1,0,0,1,1,1,1,0,0,1,0,1,1,0,1,1,0,1,1,0,1,1,1,1,0,1,0,0,0,1,0,0,1,0,0,1,1,0,0,0,1,0,0,1,1,0,0,1,1,1,0,1,1,0,0,1,1,0,1,0,1,1,1,1,0,1,1,1,0,1,1,1,1,0,0,0,1,1,0,1,0,1,0,1,1,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,0,1,1,1,1,1,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,0,1,1,0,1,0,1,0,0,0,0,1,1,0,0,1,0,1,1,1,0,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,0,1,0,0,0,0,0,0,1,1,0,1,1,0,1,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,1,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,1,1,0,0,0,1,0,1,0,1,1,1,1,0,1,0,1,1,0,1,0,1,0,1,0,1,1,0,0,1,0,0,0,1,1,0,0,1,0,0,0,0,1,0,0,1,1,0,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1,1,1,1,1,0,0,0,0,1,1,0,1,0,0,0,1,1,1,1,0,0,1,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,1,0,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,1,1,1,0,1,1,1,1,1,1,0,1,0,0,1,0,1,0,1,0,1,0,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,0,0,0,1,1,1,0,1,0,1,0,0,0,1,1,1,0,0,0,1,0,1,1,1,0,1,0,1,0,0,1,1,1,1,1,1,0,0,1,0,0,1,1,0,1,0,1,1,0,1,0,0,1,0,0,0,0,0,1,1,1,0,0,0,0,1,0,0,1,1,0,1,1,1,1,0,0,0,1,1,1,1,1,1,0,1,1,0,0,1,0,1,0,1,1,1,1,1,1,0,0,1,0,0,1,1,0,1,0,1,1,0,0,0,0,0,1,1,0,0,1,1,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,0,1,1,0,1,1,0,0,1,1,0,0,1,0,1,1,1,1,1,1,0,1,0,0,0,1,0,1,1,0,1,1,0,1,1,1,1,1,1,1,0,0,1,0,1,0,0,0,0,0,1,1,1,0,0,1,0,1,1,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,0,1,0,0,0,1,0,0,1,1,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,1,1,1,1,1,0,0,1,1,0,0,1,1,0,1,0,1,1,1,0,0,0,0,0,0,1,0,1,0,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0,0,1,0,1,0,0,0,0,0,1,1,0,1,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,1,1,0,1,0,1,1,1,1,1,0,0,1,0,1,1,0,0,1,1,1,1,1,0,1,1,0,1,0,1,0,1,0,1,1,1,0,1,1,0,0,0,1,1,1,1,1,0,0,0,1,0,1,0,0,1,0,0,0,1,1,0,1,1,0,1,0,1,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,0,0,0,1,1,0,1,1,0,1,0,1,1,1,1,1,1,0,1,0,1,0,1,0,0,0,1,1,0,0,1,1,1,1,1,0,1,0,0,0,1,0,0,1,0,1,0,1,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,1,0,1,0,1,0,0,1,0,0,0,1,0,1,0,1,0,1,1,1,0,0,1,1,1,0,0,1,0,1,0,1,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,1,1,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,1,0,0,0,0,0,0,0,1,0,0,1,1,0,1,0,1,1,0,0,0,0,1,0,0,0,1,1,0,0,0,1,1,1,0,1,0,1,0,1,0,0,1,0,1,1,1,1,0,0,1,1,0,0,0,1,0,0,0,1,1,0,0,0,1,0,0,1,1,1,0,1,0,0,1,0,0,1,0,0,1,0,0,0,0,0,1,1,1,1,1,0,0,1,1,0,0,1,1,1,0,1,0,1,0,0,0,0,0,1,1,1,0,1,0,1,0,1,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,1,1,1,0,0,1,1,1,1,0,1,1,0,0,0,0,1,0,1,1,0,0,1,0,1,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,1,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,1,0,0,1,0,1,1,0,0,1,0,1,1,1,1,0,0,0,1,0,0,1,0,1,0,0,1,1,1,0,1,1,0,1,0,0,1,1,1,0,0,1,0,1,0,0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,0,0,0,1,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,0,1,1,1,0,1,0,0,0,1,0,1,1,1,0,0,1,0,1,1,1,1,0,0,0,1,1,1,0,1,1,1,1,0,0,0,1,0,0,1,1,1,1,0,1,0,0,0,1,1,0,0,1,1,1,0,1,0,1,1,1,1,0,1,1,1,1,0,1,1,0,0,0,1,1,0,0,0,1,0,1,0,1,0,1,0,0,0,0,1,1,0,1,0,0,0,1,1,1,1,1,0,1,1,0,1,0,0,1,0,0,1,1,0,1,0,1,1,1,0,0,1,1,1,1,1,1,1,0,0,1,1,0,1,0,0,0,0,0,1,1,1,1,0,1,0,0,0,1,1,0,1,1,1,0,1,0,1,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,0,1,0,1,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,0,0,1,0,0,1,0,0,1,1,0,0,0,1,0,1,0,0,0,1,1,0,1,1,0,0,0,0,0,0,1,1,0,0,0,1,1,0,1,0,0,1,0,0,1,0,1,0,1,1,0,1,1,1,0,1,0,0,1,1,1,1,0,1,0,0,0,1,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,0,0,1,0,1,1,0,1,0,1,0,0,1,0,1,0,1,0,1,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,0,1,1,0,1,0,0,0,0,1,0,0,1,0,1,1,1,1,1,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,1,0,1,0,0,0,0,0,0,1,1,0,1,0,1,0,1,1,1,0,1,0,0,1,1,1,1,0,1,1,1,1,1,0,1,1,0,1,0,0,0,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,0,1,0,0,1,0,0,1,1,1,1,0,0,1,1,1,0,0,0,1,0,0,1,1,0,0,1,1,1,0,0,0,0,1,0,1,0,0,0,1,1,1,1,0,1,0,0,1,0,0,0,1,1,1,1,1,0,1,1,1,1,0,1,0,1,1,0,1,1,1,0,1,0,0,0,1,1,0,0,0,0,1,1,1,1,1,0,0,1,1,0,0,1,1,0,0,0,1,1,1,0,1,0,1,0,0,1,1,0,1,1,1,0,0,0,0,0,1,1,0,0,1,1,1,0,0,1,0,1,0,1,1,1,1,1,1,1,0,0,0,0,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,1,0,0,0,0,1,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,0,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,1,1,1,1,0,0,1,1,0,0,1,1,1,0,1,0,0,0,0,1,0,1,1,1,0,0,0,0,1,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,1,1,0,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,0,0,1,1,1,0,0,0,1,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,0,1,1,0,0,0,1,0,1,0,1,1,1,1,0,0,0,1,0,1,0,1,0,1,1,0,1,0,0,0,0,0,0,1,0,1,1,0,1,1,0,1,1,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,1,1,0,0,1,1,1,1,1,1,1,1,0,1,0,0,0,1,0,0,1,0,1,0,0,0,1,1,0,1,0,0,0,0,1,0,1,0,0,1,1,1,1,1,0,0,1,0,0,1,0,1,0,1,0,1,0,1,1,0,0,0,0,0,0,1,0,1,0,0,0,1,0,0,1,1,1,1,1,1,1,0,0,1,0,1,0,1,1,1,0,0,1,1,1,1,1,0,0,0,1,0,0,0,1,0,1,0,1,1,0,1,1,1,1,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0,1,0,1,1,0,1,0,1,1,1,0,0,1,0,0,1,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,1,0,0,1,1,1,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,1,0,0,0,1,1,1,1,0,0,1,0,0,0,1,1,0,0,1,0,1,1,0,1,0,1,0,1,1,1,1,0,1,1,0,0,0,1,1,0,1,1,1,1,1,1,1,0,1,1,0,0,1,0,1,0,1,1,0,1,0,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,1,1,0,0,1,1,1,0,1,1,1,0,1,0,0,1,0,0,0,1,0,1,0,0,0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,1,0,1,0,0,0,1,1,0,0,1,1,1,0,0,1,1,0,1,1,0,0,0,1,1,0,0,1,1,1,1,1,0,1,0,1,0,0,1,0,1,1,1,0,0,0,0,1,1,1,0,1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,1,1,1,0,1,1,1,1,1,0,1,0,1,0,0,0,1,1,0,0,1,1,1,1,1,0,1,0,1,0,0,0,0,1,1,1,1,1,1,1,1,1,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,1,1,0,1,1,0,1,0,0,1,1,0,0,1,1,0,1,0,1,0,0,1,1,1,1,0,0,1,0,1,1,0,1,1,0,0,1,0,1,0,1,1,1,1,0,1,1,0,0,0,0,1,0,1,1,0,0,0,0,1,0,0,1,0,1,1,1,1,1,0,0,1,0,0,1,0,1,1,1,0,0,1,1,0,1,0,1,0,0,1,1,0,1,1,0,1,1,0,1,1,0,1,1,1,0,0,1,0,1,0,0,1,1,0,1,1,1,1,0,0,1,1,0,1,0,0,1,1,0,1,1,1,0,0,1,0,1,0,1,0,0,1,1,0,0,1,1,0,1,1,1,1,1,0,0,0,0,1,0,0,1,1,0,0,0,1,1,1,1,0,0,0,1,1,1,0,0,1,0,1,1,0,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,0,1,0,1,1,1,0,1,1,1,0,1,0,0,1,1,1,0,1,1,0,0,1,0,0,0,1,0,0,1,0,0,1,1 }, +3693, +3152, + }, + + { + []int{0, 0, 0, 1, 0, 1, 1, 0}, + 3, + 3, + }, + + { + []int{1, 1, 0}, + 2, + -1, + }, + + // 可以有多个 testcase +} + +func Test_minKBitFlips(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minKBitFlips(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_minKBitFlips(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minKBitFlips(tc.A, tc.K) + } + } +} diff --git a/Algorithms/0996.number-of-squareful-arrays/README.md b/Algorithms/0996.number-of-squareful-arrays/README.md new file mode 100755 index 000000000..31eb6db9a --- /dev/null +++ b/Algorithms/0996.number-of-squareful-arrays/README.md @@ -0,0 +1,26 @@ +# [996. Number of Squareful Arrays](https://leetcode.com/problems/number-of-squareful-arrays/) + +Given an array A of non-negative integers, the array is squareful if for every pair of adjacent elements, their sum is a perfect square. + +Return the number of permutations of A that are squareful. Two permutations A1 and A2 differ if and only if there is some index i such that A1[i] != A2[i]. + +Example 1: + +```text +Input: [1,17,8] +Output: 2 +Explanation: +[1,8,17] and [17,8,1] are the valid permutations. +``` + +Example 2: + +```text +Input: [2,2,2] +Output: 1 +``` + +Note: + +- 1 <= A.length <= 12 +- 0 <= A[i] <= 1e9 diff --git a/Algorithms/0996.number-of-squareful-arrays/number-of-squareful-arrays.go b/Algorithms/0996.number-of-squareful-arrays/number-of-squareful-arrays.go new file mode 100755 index 000000000..8044c95c8 --- /dev/null +++ b/Algorithms/0996.number-of-squareful-arrays/number-of-squareful-arrays.go @@ -0,0 +1,49 @@ +package problem0996 + +import "math" + +// ref: https://leetcode.com/problems/number-of-squareful-arrays/discuss/238562/C%2B%2BPython-Backtracking +func numSquarefulPerms(A []int) int { + size := len(A) + + count := make(map[int]int, size) + for _, a := range A { + count[a]++ + } + + cands := make(map[int][]int, size) + for x := range count { + for y := range count { + if isSquare(x + y) { + cands[x] = append(cands[x], y) + } + } + } + + res := 0 + var dfs func(int, int) + dfs = func(x, remain int) { + if remain == 0 { + res++ + return + } + count[x]-- + for _, y := range cands[x] { + if count[y] > 0 { + dfs(y, remain-1) + } + } + count[x]++ + } + + for x := range count { + dfs(x, size-1) + } + + return res +} + +func isSquare(x int) bool { + root := int(math.Sqrt(float64(x))) + return root*root == x +} diff --git a/Algorithms/0996.number-of-squareful-arrays/number-of-squareful-arrays_test.go b/Algorithms/0996.number-of-squareful-arrays/number-of-squareful-arrays_test.go new file mode 100755 index 000000000..264dd55f7 --- /dev/null +++ b/Algorithms/0996.number-of-squareful-arrays/number-of-squareful-arrays_test.go @@ -0,0 +1,51 @@ +package problem0996 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{7, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, + 12, + }, + + { + []int{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2}, + 1, + }, + + { + []int{1, 17, 8}, + 2, + }, + + { + []int{2, 2, 2}, + 1, + }, + + // 可以有多个 testcase +} + +func Test_numSquarefulPerms(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + ast.Equal(tc.ans, numSquarefulPerms(tc.A), "输入:%v", tc) + } +} + +func Benchmark_numSquarefulPerms(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numSquarefulPerms(tc.A) + } + } +} diff --git a/Algorithms/0997.find-the-town-judge/README.md b/Algorithms/0997.find-the-town-judge/README.md new file mode 100755 index 000000000..12354b474 --- /dev/null +++ b/Algorithms/0997.find-the-town-judge/README.md @@ -0,0 +1,56 @@ +# [997. Find the Town Judge](https://leetcode.com/problems/find-the-town-judge/) + +In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. + +If the town judge exists, then: + +1. The town judge trusts nobody. +1. Everybody (except for the town judge) trusts the town judge. +1. There is exactly one person that satisfies properties 1 and 2. + +You are given trust, an array of pairs trust[i] = [a, b] representing that the person labelled a trusts the person labelled b. + +If the town judge exists and can be identified, return the label of the town judge. Otherwise, return -1. + +Example 1: + +```text +Input: N = 2, trust = [[1,2]] +Output: 2 +``` + +Example 2: + +```text +Input: N = 3, trust = [[1,3],[2,3]] +Output: 3 +``` + +Example 3: + +```text +Input: N = 3, trust = [[1,3],[2,3],[3,1]] +Output: -1 +``` + +Example 4: + +```text +Input: N = 3, trust = [[1,2],[2,3]] +Output: -1 +``` + +Example 5: + +```text +Input: N = 4, trust = [[1,3],[1,4],[2,3],[2,4],[4,3]] +Output: 3 +``` + +Note: + +- 1 <= N <= 1000 +- trust.length <= 10000 +- trust[i] are all different +- trust[i][0] != trust[i][1] +- 1 <= trust[i][0], trust[i][1] <= N diff --git a/Algorithms/0997.find-the-town-judge/find-the-town-judge.go b/Algorithms/0997.find-the-town-judge/find-the-town-judge.go new file mode 100755 index 000000000..2e1f685bb --- /dev/null +++ b/Algorithms/0997.find-the-town-judge/find-the-town-judge.go @@ -0,0 +1,18 @@ +package problem0997 + +func findJudge(N int, trust [][]int) int { + count := [1001]int{} + trustSomebody := [1001]bool{} + for _, t := range trust { + count[t[1]]++ + trustSomebody[t[0]] = true + } + + for i := 1; i <= N; i++ { + if count[i] == N-1 && !trustSomebody[i] { + return i + } + } + + return -1 +} diff --git a/Algorithms/0997.find-the-town-judge/find-the-town-judge_test.go b/Algorithms/0997.find-the-town-judge/find-the-town-judge_test.go new file mode 100755 index 000000000..9e0066d8e --- /dev/null +++ b/Algorithms/0997.find-the-town-judge/find-the-town-judge_test.go @@ -0,0 +1,69 @@ +package problem0997 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + trust [][]int + ans int +}{ + + { + 1, + [][]int{}, + 1, + }, + + { + 2, + [][]int{{1, 2}}, + 2, + }, + + { + 3, + [][]int{{1, 3}, {2, 3}}, + 3, + }, + + { + 3, + [][]int{{1, 3}, {2, 3}, {3, 1}}, + -1, + }, + + { + 3, + [][]int{{1, 2}, {2, 3}}, + -1, + }, + + { + 4, + [][]int{{1, 3}, {1, 4}, {2, 3}, {2, 4}, {4, 3}}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_findJudge(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, findJudge(tc.N, tc.trust), "输入:%v", tc) + } +} + +func Benchmark_findJudge(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + findJudge(tc.N, tc.trust) + } + } +} diff --git a/Algorithms/0998.maximum-binary-tree-ii/1.1.png b/Algorithms/0998.maximum-binary-tree-ii/1.1.png new file mode 100644 index 000000000..feea0fe1e Binary files /dev/null and b/Algorithms/0998.maximum-binary-tree-ii/1.1.png differ diff --git a/Algorithms/0998.maximum-binary-tree-ii/1.2.png b/Algorithms/0998.maximum-binary-tree-ii/1.2.png new file mode 100644 index 000000000..c5d267cc0 Binary files /dev/null and b/Algorithms/0998.maximum-binary-tree-ii/1.2.png differ diff --git a/Algorithms/0998.maximum-binary-tree-ii/2.1.png b/Algorithms/0998.maximum-binary-tree-ii/2.1.png new file mode 100644 index 000000000..7d3e53c67 Binary files /dev/null and b/Algorithms/0998.maximum-binary-tree-ii/2.1.png differ diff --git a/Algorithms/0998.maximum-binary-tree-ii/2.2.png b/Algorithms/0998.maximum-binary-tree-ii/2.2.png new file mode 100644 index 000000000..f5f00c506 Binary files /dev/null and b/Algorithms/0998.maximum-binary-tree-ii/2.2.png differ diff --git a/Algorithms/0998.maximum-binary-tree-ii/3.1.png b/Algorithms/0998.maximum-binary-tree-ii/3.1.png new file mode 100644 index 000000000..9415518db Binary files /dev/null and b/Algorithms/0998.maximum-binary-tree-ii/3.1.png differ diff --git a/Algorithms/0998.maximum-binary-tree-ii/3.2.png b/Algorithms/0998.maximum-binary-tree-ii/3.2.png new file mode 100644 index 000000000..d91de6405 Binary files /dev/null and b/Algorithms/0998.maximum-binary-tree-ii/3.2.png differ diff --git a/Algorithms/0998.maximum-binary-tree-ii/README.md b/Algorithms/0998.maximum-binary-tree-ii/README.md new file mode 100755 index 000000000..1dd76eb54 --- /dev/null +++ b/Algorithms/0998.maximum-binary-tree-ii/README.md @@ -0,0 +1,54 @@ +# [998. Maximum Binary Tree II](https://leetcode.com/problems/maximum-binary-tree-ii/) + +We are given the root node of a maximum tree: a tree where every node has a value greater than any other value in its subtree. + +Just as in the [previous problem](https://leetcode.com/problems/maximum-binary-tree/), the given tree was constructed from an list A (root = Construct(A)) recursively with the following Construct(A) routine: + +- If A is empty, return null. +- Otherwise, let A[i] be the largest element of A. Create a root node with value A[i]. +- The left child of root will be Construct([A[0], A[1], ..., A[i-1]]) +- The right child of root will be Construct([A[i+1], A[i+2], ..., A[A.length - 1]]) +- Return root. + +Note that we were not given A directly, only a root node root = Construct(A). + +Suppose B is a copy of A with the value val appended to it. It is guaranteed that B has unique values. + +Return Construct(B). + +Example 1: + +![1.1](1.1.png) +![1.2](1.2.png) + +```text +Input: root = [4,1,3,null,null,2], val = 5 +Output: [5,4,null,1,3,null,null,2] +Explanation: A = [1,4,2,3], B = [1,4,2,3,5] +``` + +Example 2: + +![2.1](2.1.png) +![2.2](2.2.png) + +```text +Input: root = [5,2,4,null,1], val = 3 +Output: [5,2,4,null,1,null,3] +Explanation: A = [2,1,5,4], B = [2,1,5,4,3] +``` + +Example 3: + +![3.1](3.1.png) +![3.2](3.2.png) + +```text +Input: root = [5,2,3,null,1], val = 4 +Output: [5,2,4,null,1,3] +Explanation: A = [2,1,5,3], B = [2,1,5,3,4] +``` + +Note: + +- `1 <= B.length <= 100` diff --git a/Algorithms/0998.maximum-binary-tree-ii/maximum-binary-tree-ii.go b/Algorithms/0998.maximum-binary-tree-ii/maximum-binary-tree-ii.go new file mode 100755 index 000000000..a8a08b7ee --- /dev/null +++ b/Algorithms/0998.maximum-binary-tree-ii/maximum-binary-tree-ii.go @@ -0,0 +1,23 @@ +package problem0998 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +func insertIntoMaxTree(root *TreeNode, val int) *TreeNode { + if root == nil { + return &TreeNode{Val: val} + } + + if val > root.Val { + return &TreeNode{ + Val: val, + Left: root, + } + } + + root.Right = insertIntoMaxTree(root.Right, val) + + return root +} diff --git a/Algorithms/0998.maximum-binary-tree-ii/maximum-binary-tree-ii_test.go b/Algorithms/0998.maximum-binary-tree-ii/maximum-binary-tree-ii_test.go new file mode 100755 index 000000000..7f8b9bc67 --- /dev/null +++ b/Algorithms/0998.maximum-binary-tree-ii/maximum-binary-tree-ii_test.go @@ -0,0 +1,55 @@ +package problem0998 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + val int + ans []int +}{ + + { + []int{4, 1, 3, kit.NULL, kit.NULL, 2}, + 5, + []int{5, 4, kit.NULL, 1, 3, kit.NULL, kit.NULL, 2}, + }, + + { + []int{5, 2, 4, kit.NULL, 1}, + 3, + []int{5, 2, 4, kit.NULL, 1, kit.NULL, 3}, + }, + + { + []int{5, 2, 3, kit.NULL, 1}, + 4, + []int{5, 2, 4, kit.NULL, 1, 3}, + }, + + // 可以有多个 testcase +} + +func Test_insertIntoMaxTree(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ans := kit.Ints2TreeNode(tc.ans) + ast.Equal(ans, insertIntoMaxTree(root, tc.val), "输入:%v", tc) + } +} + +func Benchmark_insertIntoMaxTree(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + insertIntoMaxTree(root, tc.val) + } + } +} diff --git a/Algorithms/0999.available-captures-for-rook/1.png b/Algorithms/0999.available-captures-for-rook/1.png new file mode 100644 index 000000000..24c6e6d39 Binary files /dev/null and b/Algorithms/0999.available-captures-for-rook/1.png differ diff --git a/Algorithms/0999.available-captures-for-rook/2.png b/Algorithms/0999.available-captures-for-rook/2.png new file mode 100644 index 000000000..404336b54 Binary files /dev/null and b/Algorithms/0999.available-captures-for-rook/2.png differ diff --git a/Algorithms/0999.available-captures-for-rook/3.png b/Algorithms/0999.available-captures-for-rook/3.png new file mode 100644 index 000000000..fee9ce4ca Binary files /dev/null and b/Algorithms/0999.available-captures-for-rook/3.png differ diff --git a/Algorithms/0999.available-captures-for-rook/README.md b/Algorithms/0999.available-captures-for-rook/README.md new file mode 100755 index 000000000..5ae04840f --- /dev/null +++ b/Algorithms/0999.available-captures-for-rook/README.md @@ -0,0 +1,70 @@ +# [999. Available Captures for Rook](https://leetcode.com/problems/available-captures-for-rook/) + +On an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns. These are given as characters 'R', '.', 'B', and 'p' respectively. Uppercase characters represent white pieces, and lowercase characters represent black pieces. + +The rook moves as in the rules of Chess: it chooses one of four cardinal directions (north, east, west, and south), then moves in that direction until it chooses to stop, reaches the edge of the board, or captures an opposite colored pawn by moving to the same square it occupies. Also, rooks cannot move into the same square as other friendly bishops. + +Return the number of pawns the rook can capture in one move. + +Example 1: + +![1](1.png) + +```text +Input: [ +[".",".",".",".",".",".",".","."], +[".",".",".","p",".",".",".","."], +[".",".",".","R",".",".",".","p"], +[".",".",".",".",".",".",".","."], +[".",".",".",".",".",".",".","."], +[".",".",".","p",".",".",".","."], +[".",".",".",".",".",".",".","."], +[".",".",".",".",".",".",".","."]] +Output: 3 +Explanation: +In this example the rook is able to capture all the pawns. +``` + +Example 2: + +![2](2.png) + +```text +Input: [ +[".",".",".",".",".",".",".","."], +[".","p","p","p","p","p",".","."], +[".","p","p","B","p","p",".","."], +[".","p","B","R","B","p",".","."], +[".","p","p","B","p","p",".","."], +[".","p","p","p","p","p",".","."], +[".",".",".",".",".",".",".","."], +[".",".",".",".",".",".",".","."]] +Output: 0 +Explanation: +Bishops are blocking the rook to capture any pawn. +``` + +Example 3: + +![3](3.png) + +```text +Input: [ +[".",".",".",".",".",".",".","."], +[".",".",".","p",".",".",".","."], +[".",".",".","p",".",".",".","."], +["p","p",".","R",".","p","B","."], +[".",".",".",".",".",".",".","."], +[".",".",".","B",".",".",".","."], +[".",".",".","p",".",".",".","."], +[".",".",".",".",".",".",".","."]] +Output: 3 +Explanation: +The rook can capture the pawns at positions b5, d6 and f5. +``` + +Note: + +- board.length == board[i].length == 8 +- board[i][j] is either 'R', '.', 'B', or 'p' +- There is exactly one cell with board[i][j] == 'R' \ No newline at end of file diff --git a/Algorithms/0999.available-captures-for-rook/available-captures-for-rook.go b/Algorithms/0999.available-captures-for-rook/available-captures-for-rook.go new file mode 100755 index 000000000..1decb2945 --- /dev/null +++ b/Algorithms/0999.available-captures-for-rook/available-captures-for-rook.go @@ -0,0 +1,35 @@ +package problem0999 + +var dx = [4]int{0, 0, -1, 1} +var dy = [4]int{-1, 1, 0, 0} + +func numRookCaptures(board [][]byte) int { + res := 0 + i, j := findRook(board) + // explore 4 direction + for k := 0; k < 4; k++ { + x, y := i+dx[k], j+dy[k] + for 0 <= x && x < 8 && + 0 <= y && y < 8 && + board[x][y] != 'B' { + if board[x][y] == 'p' { + res++ + break + } + x += dx[k] + y += dy[k] + } + } + return res +} + +func findRook(board [][]byte) (i, j int) { + for i = 0; i < 8; i++ { + for j = 0; j < 8; j++ { + if board[i][j] == 'R' { + return + } + } + } + panic("No Rook") +} diff --git a/Algorithms/0999.available-captures-for-rook/available-captures-for-rook_test.go b/Algorithms/0999.available-captures-for-rook/available-captures-for-rook_test.go new file mode 100755 index 000000000..cab30a3f7 --- /dev/null +++ b/Algorithms/0999.available-captures-for-rook/available-captures-for-rook_test.go @@ -0,0 +1,88 @@ +package problem0999 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + board [][]byte + ans int +}{ + + { + [][]byte{ + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', 'p', '.', '.', '.', '.'}, + {'.', '.', '.', 'R', '.', '.', '.', 'p'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', 'p', '.', '.', '.', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + }, + 3, + }, + + { + [][]byte{ + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', 'p', 'p', 'p', 'p', 'p', '.', '.'}, + {'.', 'p', 'p', 'B', 'p', 'p', '.', '.'}, + {'.', 'p', 'B', 'R', 'B', 'p', '.', '.'}, + {'.', 'p', 'p', 'B', 'p', 'p', '.', '.'}, + {'.', 'p', 'p', 'p', 'p', 'p', '.', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + }, + 0, + }, + + { + [][]byte{ + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', 'p', '.', '.', '.', '.'}, + {'.', '.', '.', 'p', '.', '.', '.', '.'}, + {'p', 'p', '.', 'R', '.', 'p', 'B', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', 'B', '.', '.', '.', '.'}, + {'.', '.', '.', 'p', '.', '.', '.', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + }, + 3, + }, + + // 可以有多个 testcase +} + +func Test_numRookCaptures(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + ast.Equal(tc.ans, numRookCaptures(tc.board), "输入:%v", tc) + } +} + +func Test_numRookCaptures_NoRook(t *testing.T) { + ast := assert.New(t) + board := [][]byte{ + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', 'p', '.', '.', '.', '.'}, + {'.', '.', '.', 'p', '.', '.', '.', '.'}, + {'p', 'p', '.', '.', '.', 'p', 'B', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + {'.', '.', '.', 'B', '.', '.', '.', '.'}, + {'.', '.', '.', 'p', '.', '.', '.', '.'}, + {'.', '.', '.', '.', '.', '.', '.', '.'}, + } + ast.PanicsWithValue("No Rook", func() { numRookCaptures(board) }, "没有检测出不含 Rook 的 board") +} + +func Benchmark_numRookCaptures(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numRookCaptures(tc.board) + } + } +} diff --git a/Algorithms/1000.minimum-cost-to-merge-stones/README.md b/Algorithms/1000.minimum-cost-to-merge-stones/README.md new file mode 100755 index 000000000..ebb03ac1e --- /dev/null +++ b/Algorithms/1000.minimum-cost-to-merge-stones/README.md @@ -0,0 +1,46 @@ +# [1000. Minimum Cost to Merge Stones](https://leetcode.com/problems/minimum-cost-to-merge-stones/) + +There are N piles of stones arranged in a row. The i-th pile has stones[i] stones. + +A move consists of merging exactly K consecutive piles into one pile, and the cost of this move is equal to the total number of stones in these K piles. + +Find the minimum cost to merge all piles of stones into one pile. If it is impossible, return -1. + +Example 1: + +```text +Input: stones = [3,2,4,1], K = 2 +Output: 20 +Explanation: +We start with [3, 2, 4, 1]. +We merge [3, 2] for a cost of 5, and we are left with [5, 4, 1]. +We merge [4, 1] for a cost of 5, and we are left with [5, 5]. +We merge [5, 5] for a cost of 10, and we are left with [10]. +The total cost was 20, and this is the minimum possible. +``` + +Example 2: + +```text +Input: stones = [3,2,4,1], K = 3 +Output: -1 +Explanation: After any merge operation, there are 2 piles left, and we can't merge anymore. So the task is impossible. +``` + +Example 3: + +```text +Input: stones = [3,5,1,2,6], K = 3 +Output: 25 +Explanation: +We start with [3, 5, 1, 2, 6]. +We merge [5, 1, 2] for a cost of 8, and we are left with [3, 8, 6]. +We merge [3, 8, 6] for a cost of 17, and we are left with [17]. +The total cost was 25, and this is the minimum possible. +``` + +Note: + +- `1 <= stones.length <= 30` +- `2 <= K <= 30` +- `1 <= stones[i] <= 100` diff --git a/Algorithms/1000.minimum-cost-to-merge-stones/minimum-cost-to-merge-stones.go b/Algorithms/1000.minimum-cost-to-merge-stones/minimum-cost-to-merge-stones.go new file mode 100755 index 000000000..d0756739a --- /dev/null +++ b/Algorithms/1000.minimum-cost-to-merge-stones/minimum-cost-to-merge-stones.go @@ -0,0 +1,49 @@ +package problem1000 + +// ref: https://leetcode.com/problems/minimum-cost-to-merge-stones/discuss/247567/JavaC%2B%2BPython-DP +func mergeStones(stones []int, K int) int { + size := len(stones) + if (size-1)%(K-1) != 0 { + return -1 + } + + sum := [31]int{} + for i := 0; i < size; i++ { + sum[i+1] = sum[i] + stones[i] + } + + dp := [31][31]int{} + // dp[l][r] 的含义是, + // stones[l:r+1] 完成**所有**合并后,所花费的最小费用。 + // 我着重强调了 **所有** 二字 + // dp[l][r] 在完成所有合并后,有两种可能 + // 1. 合并成一块石头 + // 2. 没有合并成一块石头 + + for width := K; width <= size; width++ { + for l := 0; l+width <= size; l++ { + r := l + width - 1 + dp[l][r] = 1 << 32 + for m := l; m < r; m += K - 1 { + dp[l][r] = min(dp[l][r], dp[l][m]+dp[m+1][r]) + // 把 dp[l][r] 分解成两个部分 + // dp[l][m] 代表了,能合并成一块石头的左边, + // dp[m+1][r] 代表了,剩下的右边。 + } + if (r-l)%(K-1) == 0 { + // 如果 dp[l][r] 的左边和右边还能够进行合并 + // 还要加上最后一次合并的费用 + dp[l][r] += sum[r+1] - sum[l] + } + } + } + + return dp[0][size-1] +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1000.minimum-cost-to-merge-stones/minimum-cost-to-merge-stones_test.go b/Algorithms/1000.minimum-cost-to-merge-stones/minimum-cost-to-merge-stones_test.go new file mode 100755 index 000000000..1c9ac0798 --- /dev/null +++ b/Algorithms/1000.minimum-cost-to-merge-stones/minimum-cost-to-merge-stones_test.go @@ -0,0 +1,51 @@ +package problem1000 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + stones []int + K int + ans int +}{ + + { + []int{3, 5, 1, 2, 6}, + 3, + 25, + }, + + { + []int{3, 2, 4, 1}, + 2, + 20, + }, + + { + []int{3, 2, 4, 1}, + 3, + -1, + }, + + // 可以有多个 testcase +} + +func Test_mergeStones(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, mergeStones(tc.stones, tc.K), "输入:%v", tc) + } +} + +func Benchmark_mergeStones(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + mergeStones(tc.stones, tc.K) + } + } +} diff --git a/Algorithms/1001.grid-illumination/README.md b/Algorithms/1001.grid-illumination/README.md new file mode 100755 index 000000000..171e2693a --- /dev/null +++ b/Algorithms/1001.grid-illumination/README.md @@ -0,0 +1,40 @@ +# [1001. Grid Illumination](https://leetcode.com/problems/grid-illumination/) + +On a N x N grid of cells, each cell (x, y) with 0 <= x < N and 0 <= y < N has a lamp. + +Initially, some number of lamps are on. lamps[i] tells us the location of the i-th lamp that is on. Each lamp that is on illuminates every square on its x-axis, y-axis, and both diagonals (similar to a Queen in chess). + +For the i-th query queries[i] = (x, y), the answer to the query is 1 if the cell (x, y) is illuminated, else 0. + +After each query (x, y) [in the order given by queries], we turn off any lamps that are at cell (x, y) or are adjacent 8-directionally (ie., share a corner or edge with cell (x, y).) + +Return an array of answers. Each value answer[i] should be equal to the answer of the i-th query queries[i]. + +Example 1: + +```text +Input: N = 5, lamps = [[0,0],[4,4]], queries = [[1,1],[1,0]] +Output: [1,0] +Explanation: +Before performing the first query we have both lamps [0,0] and [4,4] on. +The grid representing which cells are lit looks like this, where [0,0] is the top left corner, and [4,4] is the bottom right corner: +1 1 1 1 1 +1 1 0 0 1 +1 0 1 0 1 +1 0 0 1 1 +1 1 1 1 1 +Then the query at [1, 1] returns 1 because the cell is lit. After this query, the lamp at [0, 0] turns off, and the grid now looks like this: +1 0 0 0 1 +0 1 0 0 1 +0 0 1 0 1 +0 0 0 1 1 +1 1 1 1 1 +Before performing the second query we have only the lamp [4,4] on. Now the query at [1,0] returns 0, because the cell is no longer lit. +``` + +Note: + +- `1 <= N <= 10^9` +- `0 <= lamps.length <= 20000` +- `0 <= queries.length <= 20000` +- `lamps[i].length == queries[i].length == 2` diff --git a/Algorithms/1001.grid-illumination/grid-illumination.go b/Algorithms/1001.grid-illumination/grid-illumination.go new file mode 100755 index 000000000..1cb44cef5 --- /dev/null +++ b/Algorithms/1001.grid-illumination/grid-illumination.go @@ -0,0 +1,90 @@ +package problem1001 + +func gridIllumination(N int, lamps [][]int, queries [][]int) []int { + l := newLights(N) + for _, lamp := range lamps { + x, y := lamp[0], lamp[1] + l.turnOn(x, y) + } + + res := make([]int, 0, len(queries)) + for _, cell := range queries { + x, y := cell[0], cell[1] + res = append(res, l.checkIlluminated(x, y)) + } + + return res +} + +type lights struct { + h, v, ad, dd map[int]int + isOn map[int]bool + n int +} + +func newLights(N int) *lights { + return &lights{ + h: make(map[int]int, 1024), + v: make(map[int]int, 1024), + ad: make(map[int]int, 1024), + dd: make(map[int]int, 1024), + isOn: make(map[int]bool, 1024), + n: N, + } +} + +func (l *lights) turnOn(x, y int) { + l.h[x]++ + l.v[y]++ + l.ad[x+y]++ + l.dd[x-y]++ + l.isOn[x<<32+y] = true +} + +func (l *lights) turnOff(x, y int) { + if x < 0 || l.n <= x || + y < 0 || l.n <= y || + !l.isOn[x<<32+y] { + return + } + l.isOn[x<<32+y] = false + l.h[x]-- + l.v[y]-- + l.ad[x+y]-- + l.dd[x-y]-- +} + +func (l *lights) checkIlluminated(x, y int) int { + res := 0 + + if l.h[x] > 0 { // maybe [x,y-1] or [x,y] or [x,y+1] is On + res = 1 + l.turnOff(x, y-1) + l.turnOff(x, y+1) + // leave [x,y] in the end + } + + if l.v[y] > 0 { + res = 1 + l.turnOff(x-1, y) + l.turnOff(x+1, y) + } + + if l.ad[x+y] > 0 { + res = 1 + l.turnOff(x-1, y+1) + l.turnOff(x+1, y-1) + } + + if l.dd[x-y] > 0 { + res = 1 + l.turnOff(x-1, y-1) + l.turnOff(x+1, y+1) + } + + if res == 1 { + l.turnOff(x, y) + } + + return res +} diff --git a/Algorithms/1001.grid-illumination/grid-illumination_test.go b/Algorithms/1001.grid-illumination/grid-illumination_test.go new file mode 100755 index 000000000..766826b89 --- /dev/null +++ b/Algorithms/1001.grid-illumination/grid-illumination_test.go @@ -0,0 +1,48 @@ +package problem1001 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + lamps [][]int + queries [][]int + ans []int +}{ + + { + 5, + [][]int{{0, 0}, {4, 4}}, + [][]int{{1, 1}, {1, 0}}, + []int{1, 0}, + }, + + { + 10000, + [][]int{{6781, 8653}, {2624, 6531}, {7485, 1378}, {3819, 4964}, {7741, 343}, {9960, 5}, {83, 1173}, {9533, 9441}, {1763, 8712}, {2082, 6100}, {4538, 9471}, {9093, 9315}, {3415, 1120}, {8646, 7698}, {7660, 4705}, {6683, 9643}, {3665, 9248}, {685, 6302}, {8082, 4077}, {9369, 91}, {9404, 5771}, {7233, 9561}, {3236, 8674}, {6280, 3683}, {4672, 272}, {9098, 7894}, {9051, 7955}, {6721, 5461}, {1525, 4768}, {2305, 3189}, {1425, 1664}, {7277, 5281}, {5270, 94}, {9135, 1047}, {1423, 2026}, {9364, 2504}, {1387, 9993}, {4382, 9260}, {1981, 9858}, {7104, 6716}, {4844, 7154}, {1974, 1734}, {5252, 1305}, {122, 6845}, {6148, 6059}, {7072, 4871}, {5503, 9185}, {2443, 8877}, {6763, 4757}, {1733, 270}, {7044, 953}, {2843, 7884}, {3418, 7137}, {3455, 1437}, {8334, 1716}, {1941, 3179}, {5258, 2367}, {3446, 3109}, {1750, 4210}, {6160, 7724}, {995, 3633}, {2915, 5399}, {6484, 6788}, {2869, 1759}, {7072, 4567}, {7647, 5011}, {6274, 9931}, {2319, 6246}, {1785, 7459}, {2916, 7772}, {9800, 1224}, {1349, 3521}, {6343, 5734}, {7690, 3297}, {4464, 4156}, {4481, 4577}, {5123, 8000}, {9307, 5493}, {434, 3497}, {156, 2584}, {3350, 9427}, {9518, 8519}, {6584, 9086}, {8670, 3110}, {5609, 704}, {8206, 9545}, {234, 2094}, {2546, 5708}, {1748, 775}, {6867, 3292}, {418, 8985}, {2143, 8460}, {9026, 4618}, {6422, 8113}, {776, 7424}, {4863, 246}, {9547, 9529}, {7281, 3801}, {1158, 756}, {3594, 6972}, {2104, 8230}, {6284, 9381}, {8005, 663}, {4891, 7678}, {5986, 6802}, {7632, 5781}, {252, 1032}, {6553, 1117}, {6802, 2078}, {7254, 6108}, {8183, 6906}, {4270, 779}, {7025, 5290}, {8568, 3721}, {5037, 5117}, {3762, 936}, {5608, 7927}, {1806, 239}, {311, 7986}, {2336, 2070}, {5936, 3448}, {2625, 3869}, {3151, 3786}, {8015, 4709}, {9602, 3628}, {9979, 8901}, {1230, 4326}, {7385, 1126}, {4807, 8996}, {8851, 3992}, {8683, 4647}, {2647, 8763}, {8057, 7091}, {6324, 6119}, {2194, 6463}, {6001, 116}, {7471, 3912}, {695, 5827}, {1466, 2573}, {8290, 8915}, {6643, 964}, {6323, 2508}, {6348, 8692}, {65, 1256}, {3502, 9145}, {7699, 8757}, {7314, 1844}, {3271, 2660}, {1193, 632}, {5871, 6397}, {4997, 1054}, {2783, 2249}, {6893, 6290}, {7360, 102}, {1517, 627}, {3728, 1143}, {8739, 6919}, {9280, 5474}, {4628, 2357}, {228, 7040}, {501, 5529}, {2103, 816}, {1410, 3635}, {2532, 4676}, {9930, 1336}, {4702, 1074}, {1792, 4768}, {8121, 1924}, {332, 294}, {2014, 3097}, {6920, 8347}, {9979, 1698}, {1124, 1460}, {6289, 1525}, {2915, 7575}, {5605, 2174}, {8012, 6466}, {1183, 921}, {7881, 5492}, {3485, 3321}, {315, 5026}, {6193, 292}, {5492, 1956}, {2111, 7093}, {9995, 9861}, {9793, 7785}, {12, 9430}, {4259, 7394}, {3270, 8235}, {9558, 1799}, {3531, 460}, {6737, 322}, {2659, 7894}, {4699, 9552}, {1449, 3896}, {8499, 5173}, {396, 6550}, {1769, 198}, {6528, 4682}, {6130, 460}, {5227, 462}, {1143, 1800}, {3752, 8579}, {6214, 7897}, {9623, 4844}, {6368, 8903}, {5291, 6804}, {4505, 9788}, {458, 260}, {3388, 4934}, {6833, 4846}, {2436, 87}, {1086, 1797}, {3092, 7125}, {2628, 9746}, {5904, 2234}, {4650, 5985}, {5250, 9780}, {9164, 5137}, {6726, 4422}, {5561, 520}, {4030, 3670}, {6003, 3517}, {9966, 8589}, {6498, 636}, {97, 554}, {7217, 2598}, {9522, 6511}, {5071, 9806}, {7012, 3394}, {2384, 4573}, {3595, 3294}, {5002, 9070}, {2241, 5584}, {7704, 7891}, {6674, 7178}, {5770, 1054}, {4864, 4851}, {1795, 3449}, {6943, 116}, {8634, 639}, {9930, 8509}, {154, 7040}, {5772, 1086}, {7602, 9185}, {3224, 6686}, {3749, 9433}, {6626, 1384}, {490, 9302}, {5188, 5225}, {6477, 6470}, {7722, 6323}, {7165, 8446}, {9894, 5902}, {3324, 3383}, {4493, 8417}, {3042, 3611}, {8999, 6029}, {9498, 1661}, {8915, 1603}, {7364, 8270}, {2657, 2536}, {5777, 3673}, {3078, 8}, {9146, 5080}, {5627, 7425}, {2298, 4460}, {5071, 8675}, {1503, 9017}, {9393, 9495}, {445, 1479}, {7958, 837}, {2699, 3826}, {3961, 5356}, {3779, 7915}, {1413, 846}, {6134, 5782}, {5597, 1889}, {9750, 6650}, {2470, 8911}, {1835, 6724}, {4823, 9159}, {6015, 68}, {3007, 4122}, {5426, 5949}, {1791, 2750}, {6726, 2505}, {3916, 6447}, {3971, 9812}, {863, 1833}, {245, 2972}, {1684, 7871}, {7673, 8904}, {318, 5543}, {6260, 7149}, {2162, 3020}, {2588, 1706}, {3255, 2907}, {988, 2270}, {9372, 3622}, {4213, 2732}, {9602, 4788}, {4200, 2110}, {1310, 4719}, {5964, 7535}, {8105, 2500}, {5198, 8880}, {2048, 6247}, {9740, 7652}, {8931, 3532}, {7897, 8163}, {7546, 1375}, {6605, 2779}, {8731, 1869}, {5570, 458}, {3478, 2169}, {4984, 4294}, {778, 7288}, {3073, 1717}, {7404, 3605}, {3526, 3141}, {5623, 7086}, {2016, 6469}, {8791, 788}, {6063, 42}, {1501, 6271}, {2327, 4747}, {2158, 6952}, {8366, 6934}, {6196, 8766}, {2048, 537}, {9419, 8882}, {2699, 1465}, {6069, 90}, {6531, 2846}, {1559, 1665}, {2879, 5109}, {8458, 2757}, {9002, 7949}, {2091, 888}, {3379, 731}, {9819, 9121}, {4253, 758}, {9807, 5656}, {1312, 3355}, {5105, 7725}, {8134, 8266}, {541, 5857}, {3423, 2439}, {3573, 2907}, {7965, 9658}, {1518, 4452}, {8489, 559}, {1425, 27}, {4476, 4551}, {1130, 2435}, {7415, 8389}, {5212, 2528}, {6667, 8146}, {7084, 5134}, {7378, 6186}, {8498, 3450}, {20, 5565}, {5515, 758}, {5667, 2847}, {3977, 6921}, {6928, 6328}, {9137, 1581}, {4963, 4132}, {5452, 7456}, {3767, 6595}, {1527, 803}, {1483, 3482}, {915, 46}, {1794, 5649}, {8517, 3034}, {4308, 9060}, {3527, 1669}, {6091, 2994}, {9653, 2482}, {2087, 4577}, {7489, 3750}, {7354, 5719}, {4320, 332}, {7101, 3522}, {5531, 8162}, {5449, 9074}, {2831, 7322}, {5615, 8154}, {1821, 6090}, {6865, 3666}, {3194, 9916}, {1878, 7672}, {3456, 1615}, {7354, 8810}, {9820, 8548}, {9291, 2685}, {1166, 9665}, {5229, 5466}, {9324, 898}, {7015, 6267}, {3647, 9987}, {4612, 3779}, {5444, 5015}, {7812, 2419}, {5580, 6212}, {2024, 4262}, {7708, 4629}, {7529, 6246}, {9742, 3719}, {1345, 3956}, {2574, 572}, {7296, 5764}, {7535, 7323}, {4569, 4718}, {6804, 8445}, {9074, 5503}, {5030, 2626}, {5800, 4022}, {7268, 2570}, {8520, 87}, {8239, 1933}, {4823, 5979}, {2282, 3636}, {6428, 334}, {5712, 1325}, {9392, 8608}, {3197, 2394}, {69, 6421}, {2116, 1683}, {1628, 1621}, {8392, 2191}, {4557, 2476}, {6947, 7855}, {8483, 5211}, {7858, 8404}, {8429, 3125}, {2278, 3780}, {4415, 1443}, {8132, 4409}, {1631, 8065}, {3446, 1025}, {5720, 6030}, {4041, 3455}, {6554, 8496}, {1053, 2889}, {2056, 3502}, {104, 9720}, {4216, 4404}, {1923, 1595}, {3607, 450}, {107, 1444}, {8131, 9533}, {3953, 5001}, {7999, 1197}, {6747, 9860}, {4498, 9086}, {769, 6084}, {184, 2831}, {9984, 6442}, {735, 8677}, {9626, 4269}, {3132, 9705}, {3541, 2726}, {9620, 694}, {4040, 9332}, {339, 4012}, {8689, 9722}, {4392, 7520}, {849, 3020}, {215, 9738}, {701, 6102}, {4230, 229}, {2927, 8437}, {5152, 578}, {2100, 1291}, {9621, 4853}, {2124, 2991}, {3960, 5623}, {5837, 59}, {2559, 1426}, {9248, 9085}, {9031, 3224}, {1794, 9062}, {2446, 7485}, {4981, 5662}, {7495, 9944}, {4780, 5726}, {6185, 7062}, {1138, 1380}, {8560, 2631}, {5092, 4931}, {6891, 3631}, {4882, 8416}, {5612, 8966}, {658, 694}, {219, 3353}, {9021, 787}, {3172, 2423}, {6257, 3369}, {2980, 9236}, {5677, 9566}, {783, 8937}, {2776, 9980}, {1917, 850}, {4058, 833}, {617, 2159}, {1552, 8832}, {273, 3203}, {3517, 1183}, {5305, 2792}, {5092, 7799}, {2760, 7785}, {8591, 8919}, {5384, 6103}, {4507, 6209}, {874, 133}, {41, 396}, {624, 2028}, {991, 9392}, {2658, 2472}, {8837, 5917}, {3802, 1064}, {9337, 3044}, {5383, 7682}, {219, 7436}, {7022, 3740}, {3841, 4319}, {9924, 2068}, {9300, 5354}, {6357, 6890}, {3138, 6720}, {8337, 4385}, {634, 2952}, {6281, 9985}, {8483, 3579}, {8774, 3368}, {5765, 3143}, {7331, 4164}, {7662, 4750}, {3054, 7082}, {1470, 9351}, {6843, 387}, {5099, 7932}, {5169, 4010}, {6638, 5691}, {6299, 7519}, {9381, 38}, {183, 183}, {2223, 4947}, {7803, 6025}, {6851, 876}, {5067, 3842}, {9241, 1103}, {9412, 3986}, {5055, 2351}, {9301, 2109}, {405, 6305}, {3216, 3036}, {5329, 9696}, {6926, 8025}, {4428, 9866}, {952, 1974}, {2724, 9889}, {959, 7191}, {3992, 3275}, {2244, 6675}, {815, 6035}, {16, 6919}, {4401, 3365}, {8926, 6899}, {5276, 4517}, {3404, 3003}, {5648, 1545}, {8846, 5655}, {9028, 379}, {5371, 707}, {1167, 3576}, {5710, 7696}, {8879, 451}, {6646, 337}, {1350, 5554}, {5382, 6383}, {8887, 4528}, {1846, 4966}, {46, 2026}, {2464, 9477}, {5333, 9602}, {1332, 4930}, {1616, 463}, {9284, 7764}, {162, 8539}, {4296, 7591}, {629, 8804}, {604, 2043}, {919, 8459}, {637, 6310}, {3895, 8504}, {2048, 77}, {6028, 4756}, {1051, 5487}, {590, 2845}, {7178, 906}, {5243, 1110}, {1979, 5140}, {2548, 5732}, {2178, 9011}, {1869, 6098}, {918, 8517}, {2608, 702}, {3938, 4026}, {4683, 7977}, {4965, 7828}, {3773, 2779}, {6850, 9742}, {621, 3646}, {3169, 2434}, {1763, 7086}, {3020, 9153}, {3821, 287}, {7427, 7888}, {7052, 5063}, {649, 2613}, {420, 8495}, {388, 5406}, {5199, 4438}, {1425, 2058}, {4699, 2030}, {6477, 2221}, {8567, 477}, {8493, 7969}, {4762, 3262}, {3399, 432}, {2780, 1053}, {3351, 3835}, {5547, 7071}, {9243, 5430}, {728, 1159}, {855, 9305}, {3735, 8594}}, + [][]int{{930, 7824}, {1683, 1180}, {1207, 76}, {2087, 3113}, {6101, 8065}, {2438, 6525}, {7984, 5702}, {6964, 9156}, {5661, 1016}, {7498, 8283}, {4154, 166}, {6950, 8261}, {8276, 3574}, {5640, 9831}, {8302, 6271}, {8007, 8268}, {8289, 9069}, {9658, 6081}, {5238, 5905}, {288, 5178}, {8622, 3550}, {2584, 4508}, {9643, 5997}, {4825, 3137}, {5924, 6938}, {2188, 1015}, {501, 3236}, {1517, 1681}, {4924, 1777}, {6525, 388}, {6109, 6984}, {9523, 3291}, {9727, 4373}, {4454, 3268}, {8701, 824}, {7493, 1089}, {1863, 9558}, {3023, 8776}, {9662, 1127}, {5499, 7891}, {3899, 9958}, {3682, 4497}, {9368, 6229}, {6288, 483}, {4293, 934}, {3446, 608}, {1941, 5986}, {2283, 2561}, {1902, 7062}, {1446, 5637}, {3885, 3937}, {1206, 7103}, {576, 7416}, {42, 771}, {2442, 7651}, {6121, 6461}, {5906, 7773}, {1100, 2985}, {3188, 8679}, {3855, 7500}, {5438, 1253}, {7380, 3930}, {9605, 9087}, {5855, 9837}, {3054, 5330}, {4011, 1541}, {8853, 5869}, {5763, 1491}, {8281, 7828}, {7386, 6460}, {9085, 753}, {6532, 8956}, {6345, 9982}, {2586, 3280}, {7320, 7052}, {7402, 1803}, {5768, 2799}, {4965, 8690}, {348, 1583}, {6720, 720}, {2701, 216}, {9667, 4659}, {853, 5627}, {4797, 4749}, {6610, 3195}, {5437, 7987}, {9754, 5441}, {2059, 5058}, {1057, 7945}, {6445, 6773}, {2740, 7938}, {9250, 2144}, {9697, 8578}, {4043, 4312}, {4941, 7168}, {3597, 7017}, {6589, 712}, {8112, 2751}, {3165, 6811}, {3539, 3021}, {3580, 4684}, {1733, 3097}, {862, 3668}, {5070, 941}, {2905, 398}, {8052, 2088}, {8440, 8300}, {38, 5643}, {4059, 1376}, {4933, 8701}, {4773, 6772}, {4678, 1912}, {9037, 2739}, {1, 4649}, {7613, 3725}, {3125, 9187}, {1510, 1527}, {1026, 1149}, {7242, 9912}, {4205, 6448}, {3041, 3902}, {8239, 698}, {2005, 1687}, {5830, 7357}, {7493, 1896}, {4435, 4240}, {6694, 1578}, {6411, 5741}, {2413, 2967}, {1398, 1378}, {8278, 9394}, {2947, 1632}, {9937, 604}, {1682, 8703}, {7519, 2032}, {1800, 5176}, {3177, 7864}, {2031, 6153}, {5066, 9653}, {5219, 933}, {4848, 6475}, {6230, 785}, {6895, 7218}, {4444, 424}, {3453, 4758}, {192, 5480}, {4711, 8264}, {318, 6739}, {267, 6316}, {9591, 2495}, {668, 2169}, {64, 6726}, {2866, 2636}, {194, 6215}, {2471, 1013}, {8924, 5139}, {2314, 2055}, {9117, 9985}, {3248, 9948}, {9898, 9626}}, + []int{0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0}, + }, + + // 可以有多个 testcase +} + +func Test_gridIllumination(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, gridIllumination(tc.N, tc.lamps, tc.queries), "输入:%v", tc) + } +} + +func Benchmark_gridIllumination(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + gridIllumination(tc.N, tc.lamps, tc.queries) + } + } +} diff --git a/Algorithms/1002.find-common-characters/README.md b/Algorithms/1002.find-common-characters/README.md new file mode 100755 index 000000000..7869886c5 --- /dev/null +++ b/Algorithms/1002.find-common-characters/README.md @@ -0,0 +1,25 @@ +# [1002. Find Common Characters](https://leetcode.com/problems/find-common-characters/) + +Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates). For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the final answer. + +You may return the answer in any order. + +Example 1: + +```text +Input: ["bella","label","roller"] +Output: ["e","l","l"] +``` + +Example 2: + +```text +Input: ["cool","lock","cook"] +Output: ["c","o"] +``` + +Note: + +- 1 <= A.length <= 100 +- 1 <= A[i].length <= 100 +- A[i][j] is a lowercase letter \ No newline at end of file diff --git a/Algorithms/1002.find-common-characters/find-common-characters.go b/Algorithms/1002.find-common-characters/find-common-characters.go new file mode 100755 index 000000000..b228ccf27 --- /dev/null +++ b/Algorithms/1002.find-common-characters/find-common-characters.go @@ -0,0 +1,26 @@ +package problem1002 + +import "strings" + +func commonChars(A []string) []string { + res := make([]string, 0, 128) + for i := 'a'; i <= 'z'; i++ { + sub := string(i) + count := strings.Count(A[0], sub) + for j := 1; j < len(A) && count > 0; j++ { + count = min(count, strings.Count(A[j], sub)) + } + for count > 0 { + res = append(res, sub) + count-- + } + } + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1002.find-common-characters/find-common-characters_test.go b/Algorithms/1002.find-common-characters/find-common-characters_test.go new file mode 100755 index 000000000..56f8e38de --- /dev/null +++ b/Algorithms/1002.find-common-characters/find-common-characters_test.go @@ -0,0 +1,50 @@ +package problem1002 + +import ( + "sort" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []string + ans []string +}{ + + { + []string{"cxizlxaeicvxwiaqebzdzjfqmtjtrbnrehrisntpsmsntpsndsvjthgnubvekkxqwzknqqrcutenoeseqakkldnktsqpbhkklazy", "zohpatikncppgxcjpzazcwjaqbhuaokxabfvfrrbyvgjimfujzvsebjbvegwgapdixvzblrkqpzrdbtxlpultojuhwzqetvplpdf", "vutkluptjbjaahtaweadgtcvasaujlwgqrufojtakworsxlzlkkatwrnqxmtfbcmfjbbnpyitirnnvtmtlqxfzalycigeeeqtaqu", "intoasbpbflhukiroofoqzpeksolynoytjfbcmeoeamxxbnlfgdwjwpenhufllcrnjrxttbevqdxqmxyvvguuliqfvbdalpkbawy", "zizxutlyzcwwklwndwmgnquzfwaodungcpkhudujtfgcfpgsaatsflcxafskssjxhjhwexxgiwefozusudcxuwkroogopgcsjzgl", "lyesyttpoqgrplyxzpqqajqqafygvyuzkxwggpmpuvrlkgdzowyhhxjopcxtanieccgwzursvnvguwikgyszbybqthewgouzerpz", "msfudeekbpluzevvypmamrqhrdmjqclqsteprmpszzoigjuzrcofmtrasaokotykharcpddjufoufzoifrqlfpsfdemnptjxlaxv", "qcarngpdtsuakowbmkgnwmfjmjwmxkxeqpxyhcjnsrskuequgqlwppwwcgisepfnbxirpgynyymdqbzrbvmwupsvzdmylccylxkm", "opwvbicxbdcovfrlhxmqhytujlknkxazqooghibtajaojhssbbajzcqlyacbespfluawhygjwkfowcueylpogablbmmuhdkewhpv", "fuutvjfdwhhndlxuqxulutzepevejifzvkudvqqvkxhpkfixtrgugzyminanprvguibaocheuxqxhvxibyqjsomjdvnvxezmsorp", "myhbmytkraqvtvgygpmscwcqqtkzbhyyggprhovjpjyqijdrgunyxymksocskvurczbsmdelbusuqdpofskzamhklmhrrgdjqtge", "ynwjqmhdsstcahzioqwnlftajrnbhdembeitsczfqoztjhfaxkpojhawgtsokgzzjfyonkcsisvxqodducsnhgkclvgnyrbbfkuy", "qgigwnrfatzcrnrhvnczfnlcjratbkbcvnegnodqqbyuzghsbmieamvwqqlrkidicnmkjrlohjtrgkbitnpxzwsxqzbdidzaveyx", "bmfvderczfvirbashmriyzfrkwceebvwhpyjnlahoyzcuitkcezpnavgloycjxjaqrasckgfkwakplyyjkbzcdbhbrehwpjihngy", "ykcazotwzfalckzeyjxujrkvukxsjuxgilopctogqmrnvzhpsnseadhifhhjloawubvmiqvyzmynrvisnyjupjwgfzdhctrgmiov", "pukyolrguitgcnzddpwwpqxemttsujduonbjovqngzpbaifivisqojqztcyblerocqottjayafypdzzyvymlkrdihcvjqpawouiy", "ejuejeqynodrspsndrmpjkcixvjxogoprzjgyxnsctcovaubwbkqaajtfjvcmrnrkcmvspvnwesitvvnimezjcgyrjimcwnetmll", "xujtbtnnacezhqbzrpelbgbsnmwvuamfbvxxjjkcynsojrhlebzeptnloqgyxlfdnqcdwxfxazaxcmxkcrneiqheycgvsbgltvid", "qldmyynkbixpfjsdvlgfngzrhdijjxeehzebaquekjfpxofxvugnftclfcczvoqigfkievyvormswqpwvqbnobvhqjadiavgdqzw", "bncxmbpwuywvnaeecphfwvbpuvvknxkzsfeykeaejdrcitwtioyenzxjfsiagbsunnokmjclaffcoozgayuhjiypcmeijghndzjn", "rerjcjeqjvdyzzyybnbwzheozqrvjbjegzfvgwuepexsaimjtfcghoaxdsdlltahlkzneuevgnackjoohginvpqcbjxbexbqfgyc", "vgsskznernyntiwofhoqkntgeclhhgoyihgeeodumqnwxwrhqmgnhlubftwjwoijfymfwugxqsxwsytjctuqcxcxuhlzcllhyfri", "lgzsgpurzxthlzehntsvkycdavippybpnkbxjpkzdlkyxffllbydeziobquhotpbshtsoeuyoutytdyduoadxeancbnysuxzorad", "zjfekgidfvzzbhzoksizpcylqigaacvgqcgmzntxzrtmbucnmmrgbkbexuunvyqqnbrgnottufxpylvkbmqdocstubrfgwuqkdcn", "trlgbgboeszlfgadqoxwpjtkwpcrnticpxgdgyxmibjdhzrvkqzajqjhozzkiqffnwcqyuexdselwfumyyvvamiizwvztgimzgbp", "mlimwoskddyxunxgssfjgfcdrzbswtiyqdyamnikfhfdvfbhnltkgatdttxprfgafnufaqpzbdgmbnogesvuysqseuckbqcmpzdl", "nvlxantvgwrtmzzvutdjvsfftnjthfferdhejcfmhvvhunxzsijvyfigonnfrdzflvbsxnftjfxfczxoayrkouwycwvmhsfhfmyt", "oijzdasbaiylwkvqqmbklzbmajydkpwaglivwqqhvljvjxglkslutxjrivdgpazioaiaoobikvxlfjmizipgkhvughuoxowykuqr", "epyfwunrkauzbbsvuaoflozsaavyjkcuusjndiyqeatigykkbvoihfpuljqdjckemlslgdfkvmydateenrvzhavtsjrqobvvyaqo", "xxkfwqdzwffllyqczpnkulqzuokoogssiqyzaxehyomsgvaxzqnzflzwzzavnmibtzddwrlnuzljtojecrbbjucgyijjyinwozrj", "ywpjlyfbwsiognlmkszyzpxcglnlacldfjcuziemxtdeepbwewwlxfqquomlsfieomdmsiqavuqrftydpomufvewlbqvlojdmgfg", "xkceantgnjkiybxcvplnpxwimnprwbtwasjquwmqkrakctprjmnfdpsqjlwxuzwykuchddgsdlccgyqpolckeecgfvejderxtngo", "lvutlzkxcevzpqszqgdayhnyllkgrvbimougbdmgbqdzwtrddgxkwqczegfnkigphwghsosruryztixvqgrxoziiubxwoehtqoun", "pzorupuimoaxlyfrwweufewwucosqnrirupklqjekyktreaxgaxaqgncmwwkgwprybafuwtsagjyrawbpqeqztzdrmcpzhxcomjh", "eyzcwioqzvcmtxvtxxulcnxwewewbpgjyzpgcouplsctjipuwiutxhdtczetfxnnkifkvwhiamxjjppaubbwxvqrmpymzvgoevlg", "uasbblgcquaqcormaeupxgykzrjypwccgwbypsvxlnswbnwlixvjlzkirnlzzibkicrtlupwtoebxcemwvjkidvmlivouxiynnal", "nasxfhzdreqnspwuourravhdbjchfulzvgquccvevbodabeievzgvzegubfipdeoaffrgnyjdzshvtiotmjieezilwwkqhqlivts", "dimmqymdjhbsfkegyxfmejnczmfnmrajcxfuqymxexhmynyrxkjgpbdwmwdsckzcjymoasudsksobvebaefjngzvzqkplpoehfjh", "sejxqwviqhlkbartmgwsvuwruemjqpaepilbyaerwjziyecmmmeothvosfvxcyiecjxkdxfqfnmmzahndoduzhutzuhfpuszcuhv", "irhbaqsjmsjbwvnxhtqgocwhqqktfiquoveymoqlrussuizzmwipoudtlnrajonjmcmoqmvyqwbeznrqwrxkphozzplmnnwbygio", "nrvzlftzhwwfeckjtoknipjpokzwnbacdauzfnvebpapoqpyseaeyzicfsaljevtkwgivtxfjrrmocsmvimctfvrboawndjjgumy", "droxndceqfcpkqgmkrdeewtdxxmsgimnzsrzojkqwhavlzvpvmrtlttxhrtehcapcncxvfgxkpatabowpigzldstfbsiqwezvbww", "uapczwtmobvrzurhsxkodzgouxoeffgerxtxkvyaghvtzqzshqgmrrtwxkfxsisdhonyvmescqxqiltaumknxycdkzdijwkaaotg", "ijmsesoptcjvpducnyahcxsojqkrzjbcqwzzxfgacynhxknvkaosrnolagfiutvrwaqsxmrbofmduxrxxnxmxlaccxqzlbvrxjra", "veksvbkqchdgnkneqdlslicomlnnceijpsmgtaehnzsvghfabvdiwzjgdecjxsdcestuemlobekumtaxssdgzftxvjjrnhhdyfzj", "xtotdktrxgnvmqzxchalgdywlysribmxxjhgznotfjgtrxhilkrlsdofswlyflfzgxerykdgqdmxkyxjlopolafuznutdbzygzlx", "eiehlrjgmquyephjgqlmpvnxzbownzdazsyspurryzqribvlzyjigcszsuhxgtyycfwlakzaixmqorrzejooqkmrdggmkghbkesj", "ktataiirpttwjzyypfjsquylawvjnjtqpveynzftkxohlcwtprhvpohmrhhnhnjyjsgkgouiigliduyioqkaaavnyxpkabqehelc", "gacnwampmavvepmrnztqvmggpxcnbcioicwtqgalidjuqmzvobyrrnskhhccftqqxgakgwcsonkbasmpsyvixreqjyrjknwlxbdw", "mbvxwmfrudiujaxqnkvjwwexnphttfowstanntyfzgpztcqzzhxqhkvvqipbtqsbmjgjthyqnsbxnipvhpztlncvuevhkpbpwkxo", "udajfrqvjszwaqgzbblnuooxmvbtejsnhlllqajbjrgzzxooefazffzujkymnugfzxyaolprcksntajgvcbcycqzhqvvozvdoelh", "okqaorpeduegmjdalsmoybbdgnleozmvfvtnvzipghruarrzqqejzuzdflkjoewpzarevfrxhjoougnlccnztocotinvmebuwmtf", "dxrojfhlemlupcyjguhymianoxilfxgcxbfdqixvmgqeabpagmfgemhbeppewoowsljutsptrcvvtzaeyqffwbsoipwebjhssigj", "wssourljhoocgyrujbjgawbapexglevdtqkgdokwphlzyteycpzswblmxvxpwlkcjuiwgkppgbioyqngqjnasbofhbyrfxszhqdr", "hhvpfphtxnyiemyhynlwyyyjgtfsrljoglclidyxvvtrssqafossxmobcnvztpafkpuaruwzlsciirrdapmllqifqhyhaimsjrbz", "vjkpztaauscdovjvkyborqlaxcyjzsmgfourpyyyhtapxfxhbyyudjpdwtuwnlkfinmwghqwtvazsdkbzlzaamshyaubektppojw", "fjyxxtkawexosprbayitlqzyjisrdzueijomhbhlizxlnfkpapjpdyzpqemepwescbnfgghulgraenudwysqhsucjlqgujdcjjyr", "nsnwrrgffjtpjqufcuhndbukfpmelifvuasyyroamcjzrtvkzomxbkwlsrvmnzedhrwwgvvntxmmvzagugdzogrlxymtkdjzuhdq", "wcwvstsjugpaxdrlrqdctufwijfjstnwfdfgcixsvxynwrzxyojqwrmmgqqgrwumcfxgzifgdlrqdwoltdtfoyyalzlnyziblpek", "qgjnrxxigdlryhbknxmaqexsjabtrofromjudzyubsyxjcifjjyqchgomlgcpxwvxxdrrpcfbuuijxdwukwumdvunbnlkmobxcsc", "mueqpapmemzbrklixyhmubxhdxhzzhbakytecctcqahmruljqsleaedvqyybrkxmshliywgxlfuhxpbjmcwpoqrhbkrdlxuphncf", "djbzfihlhqeswuegjyxxthddepzqflfnhkyckjenevfcbxagwvxqplmajqctayqlbdnlgbptmaosepfbdcxkptkaxnntnxzqozxv", "jtvuxxetpjvdncairjsvzphhblrxvpvficztkgphkspptvzdhrqphhydgcnysuwzkxalsucwmfsqxbkgkxaxkajesiyywgecsxai", "cdpbumrfxufyzpxdhfkuogbgtuwoqwmxffomzkvfuicdahjvirwqkrnseiltuetvtbxkwmprbziietgrvbzwmgxxmsjrbvmyulks", "cyyktczgcgjxekttrkmigjqrawlnlpudzavedpsketuoerledqftnkrkralkpxtzvgetimtztwpqrwvwfsriwlemljgqqagokrus", "vlkzbmcrdvbrutlbtvntvdplgsdnxhjskvnptsjdepnuiivpefjnjhprqjssgsoemeiwuqrggchgkjabcqxrqaqohkruhbjnfcvt", "uaqbfmjjrnqfvvfsuybubxkkjgxacwnjbrwmnpcbbnlriyaqcfeekdosmaohfmplrltoxflmhnsmuatdvxwyzrwlszlvwxzgvvxg", "hkvdhjzwhykxsnqdlrhgfojcpwlughuqbpsznsgffzuergznmpdksgycrqmnruihbbavuosjvnwxxpmnautiudmgalztxoczqoka", "kpkbaedgiyzaroyxsfakegglmwgfxoreoaycxvjtjnzkdidjglzhlnzsgfoemkcdpkcuigafemvuvfjcdtqpfpkyjuneilabthcx", "ebycypouydpptxjsggahkbvnchwlegdfdclkremybnomyfjnnzjvwrgpxdymtwxhuvgajquqgfqcpdbrmfwwjpvxgrxcabewwqjn", "xnhqueqqpvsayorjsgudtghmdfgycbuakukmdequrezaqtuojmicaxcpfkfxsoctgrbziicpenckxitdsxevmgzctgsdhkbxjsfb", "podtoqisfeuuydukdjrhzjiafupdibkcbgrkzfafilrlwwvchfwksqyrwizakxxmquwjboqqkprdxwblzzgsrqviyeaxvckuqmxx", "jegfkvmxouyukzdpwnxdaovvfavxdmgfaotqbijxdwkyxzqjpggtwhiguefekcgqrzlyofodjoittschlurcdamlgjwwsvlhicfx", "omhmmohcfdmzkaahbmwwnmuclhvfnjsfozxcndelgyibfljbxldpjuprpsmjzfrcrdmeaqlnahcphjvionmidxuzwjziggsrymuq", "urtoodmqotufmyrgkvvlplcpqrmgjqtwnsxubzxzcdyrfurhlzhvycgoivncoteplodztiugoncputkbelracwgwqsmzumtnqazx", "zmjlpylrliiwbihsjsanaazofhsjagkunaanexpnrkxvwnmfneaficratlgvgmojwzonpczjbybynmiqsklagfyksrxveetmokxt", "saeqogjrdooixctqlgalayioezshxoxmzwuzgsbnkktlogfvvsajuwoepqvlpjwqcbgnsmmlbusgirlzzbngiiagzvwgxlureiyh", "bteycsnlukwjaxqgwxlqrcyxueykznnxjzpkpeafuoorjrymrqevfaqfczpabmolgamoegiprphpnuyswvmreruyacmqipwulphn", "jaboldifpcohlpigojohzlrokaqkjpawhylpzktmwsqqylfddjcobbhiudsuermrbfklqowvqshwgrhqqutovxdqujaxrapmgcvn", "guugpqwaktbjuowrwqprgmhlgmiqxifbjvjyfvhtmpydasmgitzzzcgnctyckzsohlwmfyopsdemdblrkhkjhubmqpcnqatijgdv", "ugvhvmurdhblohmvjxbdxemzqrwxekbbogjsfebjucoxxqmlzusvihpxuettmhjraroyklrxsjtwacwrfgxfvetcxribrshtbrzr", "luxgfrjcsqmurdlzkactiqvmximtiskkwzydehsthhyplbnhrcccczayczwolxszolqgouaftebwpapxukeqcyjokvvzlwpfnjlu", "izskskqbrrmvomzrcjezunmzchljddiqqznhqlgeycpzpdzkgwlqplewpqyfskitalevfsuyytdkvgfqzqgoxsbsleitmwpofwax", "wvkmmniagtilhzxyjdiygqbzanjqrhfxmmkzhdtkfebexdusgjszwamcvxyveansmqpnfmydczzpmxtlxkbpljcjxrtrrftiepsg", "oruykgciordgafzgnecforlmsffpvqwhciawolaxwqyxuhgrkzkkyacxxrcwtquaewnwssroctfbkuigrlutetjjejkbgnphtiwt", "uwympkgqzyevazokvbykabpmgfandumwsmqfiovjwougsglifctzeifnvgiikuereayvvilzrcwphkhhfxcxhnmuukwqrilpicxg", "iibipamzyznjhicfdibpdnbxynsazmtgszimvmnlkzeidzzjynoojcuuyfljdwsnjupoujuhwbprllxciruyijvxxhpzscgormur", "wcvtavkujkgsjvxqnmvoiocyxqcmvargirtngaeubransrjzynzqywtudugdwyeupnraptwjjffyonrqeuxeqgyreqhelkhvxebt", "cnqzxqrnztogafefllnooldvzdsuvqfgwwpouvgqcmmlxbksqgjddsouzupaxhafjogryatvnsrmgtlwgchdogdoupsbsbglhdzd", "ufnneunxpecjduyiwdzjrwirtgffhrwjiehhjblrcevtpvjxzpkrkprbxgcnvvqbayyrjvudrtgdhpugljpdbziqczwtrnuxlaht", "ljtbzjgnemfjdkrtzmtbypymrpwckgksaxvhivsylevfoznwnwbrjfknrrxgqfxvewhqxoiexlzgdcpanxfzupztzemkbezpjbpo", "cxirqwcyzjdjqqgotntbxyobemvskwwpfchskzuewaolcambienmubdanhkuxcgenkypzrdlxfsohmwnoynbehgcxztrnxrmfhst", "tihyhgzhskgzfhxatpronphslvsyhpcttwqqgdydcbzsmeoujlbhcnclaohphekvwuhqfquxpcktxqlxpfhfehksocgvfvxcwery", "btpuhxgofircivkkjqzdjxreazftdtnyylobbbxgswskewxyycnsivjdrwijzkzhpyucdfikwqshookugwrcedzafxheuhpichut", "tvqttikfjrbskmwjqtbyavmovyzeeagtjxxhklquyfruwurbsifvvywusfqiblokjpqbeqmawilxgmvhmmimyfrqfhomcbjsxvgd", "rgzrgbihpdckrqarsylkklmnevpgqhitnzyaigntuijzkxtncqhksmunyjrzmlwmldlhfthajvklatvlcgfoewzlrufmuipnzihm", "rewrgpzcfycoclwwzctcubmibztupbgbdsqpvgidgpyzsrplrzsftreapamshhchojthagpgyefgmnlmcactiapvnhnqhytmznvr", "smlywmmixzagjnyjyftddnajcwtxzsgzciqyzoojkutsagnmmwxfdbhqhyzvdufhfbpeqjvdakshjblgjdahpotznhuessuiklae", "vqwxiktrzpllggpfhyzxpvsadeteueapiixzmorruxheofxuzexbktrzyuehqwflufvwqisffnotrirxbcpaconyfdaykglfxavp", "airidyzwwudqytasdzwiexpiyzgnhgclzlyojxrzptucbkfksarxkcvqlhxurlzkjbarurxolakwihgspsiggyyvgiuhphkzezaw"}, + []string{"g", "z"}, + }, + + { + []string{"bella", "label", "roller"}, + []string{"e", "l", "l"}, + }, + + { + []string{"cool", "lock", "cook"}, + []string{"c", "o"}, + }, + + // 可以有多个 testcase +} + +func Test_commonChars(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ans := commonChars(tc.A) + sort.Strings(ans) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_commonChars(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + commonChars(tc.A) + } + } +} diff --git a/Algorithms/1003.check-if-word-is-valid-after-substitutions/README.md b/Algorithms/1003.check-if-word-is-valid-after-substitutions/README.md new file mode 100755 index 000000000..d1f4002a1 --- /dev/null +++ b/Algorithms/1003.check-if-word-is-valid-after-substitutions/README.md @@ -0,0 +1,48 @@ +# [1003. Check If Word Is Valid After Substitutions](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions/) + +We are given that the string "abc" is valid. + +From any valid string V, we may split V into two pieces X and Y such that X + Y (X concatenated with Y) is equal to V. (X or Y may be empty.) Then, X + "abc" + Y is also valid. + +If for example S = "abc", then examples of valid strings are: "abc", "aabcbc", "abcabc", "abcabcababcc". Examples of invalid strings are: "abccba", "ab", "cababc", "bac". + +Return true if and only if the given string S is valid. + +Example 1: + +```text +Input: "aabcbc" +Output: true +Explanation: +We start with the valid string "abc". +Then we can insert another "abc" between "a" and "bc", resulting in "a" + "abc" + "bc" which is "aabcbc". +``` + +Example 2: + +```text +Input: "abcabcababcc" +Output: true +Explanation: +"abcabcabc" is valid after consecutive insertings of "abc". +Then we can insert "abc" before the last letter, resulting in "abcabcab" + "abc" + "c" which is "abcabcababcc". +``` + +Example 3: + +```text +Input: "abccba" +Output: false +``` + +Example 4: + +```text +Input: "cababc" +Output: false +``` + +Note: + +- 1 <= S.length <= 20000 +- S[i] is 'a', 'b', or 'c' diff --git a/Algorithms/1003.check-if-word-is-valid-after-substitutions/check-if-word-is-valid-after-substitutions.go b/Algorithms/1003.check-if-word-is-valid-after-substitutions/check-if-word-is-valid-after-substitutions.go new file mode 100755 index 000000000..8f27a8410 --- /dev/null +++ b/Algorithms/1003.check-if-word-is-valid-after-substitutions/check-if-word-is-valid-after-substitutions.go @@ -0,0 +1,27 @@ +package problem1003 + +func isValid(S string) bool { + bs := []byte(S) + stack := make([]byte, len(S)) + top := -1 + + for _, b := range bs { + top++ + stack[top] = b + switch top { + case 0: + if b != 'a' { + return false + } + case 1: + default: + if b == 'c' && + stack[top-1] == 'b' && + stack[top-2] == 'a' { + top -= 3 + } + } + } + + return top == -1 +} diff --git a/Algorithms/1003.check-if-word-is-valid-after-substitutions/check-if-word-is-valid-after-substitutions_test.go b/Algorithms/1003.check-if-word-is-valid-after-substitutions/check-if-word-is-valid-after-substitutions_test.go new file mode 100755 index 000000000..a15b3bf71 --- /dev/null +++ b/Algorithms/1003.check-if-word-is-valid-after-substitutions/check-if-word-is-valid-after-substitutions_test.go @@ -0,0 +1,57 @@ +package problem1003 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans bool +}{ + + { + "abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc", + true, + }, + + { + "aabcbc", + true, + }, + + { + "abcabcababcc", + true, + }, + + { + "abccba", + false, + }, + + { + "cababc", + false, + }, + + // 可以有多个 testcase +} + +func Test_isValid(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, isValid(tc.S), "输入:%v", tc) + } +} + +func Benchmark_isValid(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isValid(tc.S) + } + } +} diff --git a/Algorithms/1004.max-consecutive-ones-iii/README.md b/Algorithms/1004.max-consecutive-ones-iii/README.md new file mode 100755 index 000000000..25a72f9c3 --- /dev/null +++ b/Algorithms/1004.max-consecutive-ones-iii/README.md @@ -0,0 +1,31 @@ +# [1004. Max Consecutive Ones III](https://leetcode.com/problems/max-consecutive-ones-iii/) + +Given an array A of 0s and 1s, we may change up to K values from 0 to 1. + +Return the length of the longest (contiguous) subarray that contains only 1s. + +Example 1: + +```text +Input: A = [1,1,1,0,0,0,1,1,1,1,0], K = 2 +Output: 6 +Explanation: +[1,1,1,0,0,1,1,1,1,1,1] +Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. +``` + +Example 2: + +```text +Input: A = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], K = 3 +Output: 10 +Explanation: +[0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1] +Bolded numbers were flipped from 0 to 1. The longest subarray is underlined. +``` + +Note: + +- 1 <= A.length <= 20000 +- 0 <= K <= A.length +- A[i] is 0 or 1 diff --git a/Algorithms/1004.max-consecutive-ones-iii/max-consecutive-ones-iii.go b/Algorithms/1004.max-consecutive-ones-iii/max-consecutive-ones-iii.go new file mode 100755 index 000000000..932cebcdd --- /dev/null +++ b/Algorithms/1004.max-consecutive-ones-iii/max-consecutive-ones-iii.go @@ -0,0 +1,16 @@ +package problem1004 + +// ref: https://leetcode.com/problems/max-consecutive-ones-iii/discuss/247564/JavaC%2B%2BPython-Sliding-Window +func longestOnes(A []int, K int) int { + left, right := 0, 0 + for right = range A { + K -= 1 ^ A[right] // 每次遇到 0 就会消耗一次 K + if K < 0 { // K 不够用的时候,就从左边回血 + K += 1 ^ A[left] + left++ + } + } + // A[left:right+1] 并不是真的 max-length-sliding-windows + // 把 right-left+1 当作是 A[:right+1] 中出现过的最长子数组的长度,更合适 + return right - left + 1 +} diff --git a/Algorithms/1004.max-consecutive-ones-iii/max-consecutive-ones-iii_test.go b/Algorithms/1004.max-consecutive-ones-iii/max-consecutive-ones-iii_test.go new file mode 100755 index 000000000..9421f306f --- /dev/null +++ b/Algorithms/1004.max-consecutive-ones-iii/max-consecutive-ones-iii_test.go @@ -0,0 +1,63 @@ +package problem1004 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans int +}{ + + { + []int{1, 1, 0, 0, 1, 1, 0, 0}, + 2, + 6, + }, + + { + []int{0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1}, + 3, + 10, + }, + + { + []int{1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1}, + 8, + 25, + }, + + { + []int{1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0}, + 100, + 11, + }, + + { + []int{1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0}, + 2, + 6, + }, + + // 可以有多个 testcase +} + +func Test_longestOnes(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, longestOnes(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_longestOnes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + longestOnes(tc.A, tc.K) + } + } +} diff --git a/Algorithms/1005.maximize-sum-of-array-after-k-negations/README.md b/Algorithms/1005.maximize-sum-of-array-after-k-negations/README.md new file mode 100755 index 000000000..0404d95a0 --- /dev/null +++ b/Algorithms/1005.maximize-sum-of-array-after-k-negations/README.md @@ -0,0 +1,35 @@ +# [1005. Maximize Sum Of Array After K Negations](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/) + +Given an array A of integers, we must modify the array in the following way: we choose an i and replace A[i] with -A[i], and we repeat this process K times in total. (We may choose the same index i multiple times.) + +Return the largest possible sum of the array after modifying it in this way. + +Example 1: + +```text +Input: A = [4,2,3], K = 1 +Output: 5 +Explanation: Choose indices (1,) and A becomes [4,-2,3]. +``` + +Example 2: + +```text +Input: A = [3,-1,0,2], K = 3 +Output: 6 +Explanation: Choose indices (1, 2, 2) and A becomes [3,1,0,2]. +``` + +Example 3: + +```text +Input: A = [2,-3,-1,5,-4], K = 2 +Output: 13 +Explanation: Choose indices (1, 4) and A becomes [2,3,-1,5,4]. +``` + +Note: + +- 1 <= A.length <= 10000 +- 1 <= K <= 10000 +- -100 <= A[i] <= 100 \ No newline at end of file diff --git a/Algorithms/1005.maximize-sum-of-array-after-k-negations/maximize-sum-of-array-after-k-negations.go b/Algorithms/1005.maximize-sum-of-array-after-k-negations/maximize-sum-of-array-after-k-negations.go new file mode 100755 index 000000000..2b1a872e4 --- /dev/null +++ b/Algorithms/1005.maximize-sum-of-array-after-k-negations/maximize-sum-of-array-after-k-negations.go @@ -0,0 +1,57 @@ +package problem1005 + +import "sort" + +func largestSumAfterKNegations(A []int, K int) int { + size := len(A) + + i, j := 0, size-1 + minAbs := abs(A[0]) + for i <= j { + minAbs = min(minAbs, abs(A[i])) + if A[i] >= 0 { // move non-negative to right side + A[i], A[j] = A[j], A[i] + j-- + continue + } + i++ + } + + negatives := A[:j+1] + negSize := j + 1 + + sum := 0 + if K >= negSize { // all negative could convert to positive + if (K-negSize)&1 == 1 { // someone need keep as negative + sum -= minAbs * 2 // choose minAbs keep as negative + } + } else { + sort.Ints(negatives) + // min K negative could convert to positive + // sort make min K negative in negatives[:K] + } + + index := min(K, negSize) + for i := 0; i < index; i++ { + sum -= A[i] + } + for i := index; i < size; i++ { + sum += A[i] + } + + return sum +} + +func abs(a int) int { + if a < 0 { + return -a + } + return a +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1005.maximize-sum-of-array-after-k-negations/maximize-sum-of-array-after-k-negations_test.go b/Algorithms/1005.maximize-sum-of-array-after-k-negations/maximize-sum-of-array-after-k-negations_test.go new file mode 100755 index 000000000..7b6d6f0b5 --- /dev/null +++ b/Algorithms/1005.maximize-sum-of-array-after-k-negations/maximize-sum-of-array-after-k-negations_test.go @@ -0,0 +1,57 @@ +package problem1005 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans int +}{ + + { + []int{-75, 44, -14, -80, 11, 81, 67, 73, 75, -77, -35, -77, 9, 22, 11, 93, -34, 5, 78, 80, 1, 0, 94, 56, 21, -79, 13, -54, 82, 19, -99, -19, 6, -18, 39, -19, 83, 96, -66, -75, -3, 54, 97, -4, 77, -66, 69, 14, 17, -59, 13, -32, -6, -52, 74, 73, 61, -26, -62, 89, 71, 22, -35, -61, -75, -10, 17, -54, -49, -78, 79, -79, 63, 27, 85, -66, -24, 2, -15, -42, -58, 60, -8, 6, 43, -33, -11, -52, -62, -79, 93, -78, -36, -80, -23, -72, 43, -96, -25, 60, 49, -48, 44, 54, 11, 13, 82, 73, 17, -22, -9, -16, -83, 23, 6, 83, 37, -93, -43, 5, 9, -25, -87, -69, -51, -10, 36, 77, 62, -92, 100, 13, 64, 84, 100, 30, 88, 50, -56, -55, 50, 57, 77, -40, 15, -25, 8, -87, 50, 13, 45, -49, -66, -65, -6, -90, -82, 68, -86, -25, 2, 72, 87, 69, 57, -43, -32, 54, -69, -42, 21, 0, -4, 82, 44, 84, -34, -44, 88, 92, 30, 66, 80, -68, 10, -15, -8, -87, -37, -49, 52, -59, 53, 21, -76, 32, -74, 87, 89, 58, 50, -47, 14, 64, 36, -84, 57, 58, -49, -15, -96, -64, 33, -100, -89, 76, -20, -79, -35, 6, 37, -90, 28, -14, 32, 16, -88, -32, -59, 40, -7, -51, 99, -31, -99, -100, -5, -19, 59, 83, -72, 59, -59, 50, 67, 56, 76, 67, -47, -16, -99, -87, -27, 80, -9, 45, 41, -42, 64, -28, 65, 56, 65, 27, -22, 37, -70, -35, -74, -69, 12, -37, 3, -76, 70, -100, 19, -3, -69, -15, -29, 98, -16, 19, -59, 38, -3, -39, -61, -26, -6, -73, -80, 41, -79, 42, 34, 98, -68, 97, 10, -16, 92, -21, 100, -75, 1, -74, 61, 41, 58, -96, -4, -93, -34, -32, 94, 60, 57, -56, -17, 5, 83, 22, -40, 51, 0, -61, 62, 25, -32, -56, -98, -55, -96, -92, 100, -50, 66, 7, 46, 23, -53, -41, -85, -71, 58, -47, -20, 9, -24, 36, 19, 22, -78, 56, -38, 53, -10, -72, 11, -92, 90, -45, -80, 100, -98, -85, 45, -18, -37, -15, -56, 28, -2, -11, 55, 18, 65, 18, -19, -43, 39, 31, -76, 89, -1, -97, 25, -96, -26, 34, 70, -80, -9, -97, -41, 43, 96, 82, 95, -67, -22, 60, 95, -41, -90, -34, 25, -35, 76, -26, -46, -20, 63, -41, -46, -6, -91, 8, -43, 93, -54, 80, -93, 41, -19, 63, 66, 47, 50, -3, -16, 46, -28, -100, -27, -76, -93, 19, 56, 64, 36, 53, -99, -5, -75, -91, -37, 78, -49, -92, -43, 8, -22, -90, -65, -55, 21, -13, 98, 38, 93, 65, -54, -77, -29, -50, 15, -4, 22, 17, -65, 17, 55, 74, 45, 78, -12, 20, -81, -72, 3, 19, -13, -93, 50, 21, -67, 17, 42, 99, 34, -53, -85, -40, -54, 92, -35, 10, 73, 9, 0, 56, -40, 0, -44, -2, -50, -33, 42, 64, -65, 92, 78, 42, 40, 41, 84, 27, 78, -59, -24, 42, 47, -24, 66, -1, -15, 32, -23, -90, -89, -38, 17, -82, -76, 43, 89, 37, 48, -13, 54, 64, -21, -27, 74, -4, 30, 19, -74, 42, 18, 64, 39, 29, 45, 15, -43, 13, 9, -39, -46, -92, 91, -23, -55, 63, 40, -12, -5, 80, -39, -80, 16, -78, 91, 75, -46, 25, 19, 71, 17, -32, -61, -65, -24, -94, 67, 45, 73, 89, 50, 2, 19, -33, -30, 14, -47, 67, -67, 59, -90, -58, -57, -37, 14, 22, 10, -82, -14, 82, 88, -41, 26, 61, 87, 66, 36, 93, -15, -96, -24, -3, 68, -58, -63, -58, -75, 82, -98, -50, 7, -29, 87, -5, 80, -23, -79, -64, -97, -61, -3, 50, -93, -82, -63, -13, -16, 40, -25, 28, -89, 55, -17, -22, 66, 26, 83, 31, 71, -66, -60, -69, -60, -54, 28, 87, 39, 87, 89, 32, -37, 10, 30, -69, -9, 29, 32, 89, 100, 62, 73, 26, -61, -70, 90, -34, 54, -49, -88, 60, -99, 78, 37, 98, 6, 75, 95, -91, 89, 22, -31, -49, 65, 11, 9, -94, 17, -25, -25, -79, 13, -8, -86, -92, 0, 21, -34, 36, 58, 94, 75, 82, 10, 83, -57, 48, 69, 34, -46, 24, -1, -19, -48, -82, -95, -54, 86, 90, -91, 52, -63, 50, 87, 100, 48, -33, 76, -77, -23, -86, 84, 38, -86, -84, 24, -32, 52, -10, -71, 9, -30, -82, 65, 79, 38, 95, 2, 86, 95, -56, 74, 87, 48, -28, -92, -9, 70, -75, 49, -84, 37, -25, -32, 93, 88, -63, -80, 96, -14, 13, -8, -40, 60, 14, -28, 98, -1, -34, 51, 23, 74, -85, 53, 62, -67, 80, 30, -22, 41, 93, -58, -62, -35, -79, 22, -76, -100, -38, -45, 15, -50, 43, -30, 44, -27, 55, -70, -80, 67, 2, 48, 45, 49, -61, -4, -89, -90, 84, -47, -8, 62, 61, 21, 31, 94, 40, 20, 98, -73, 46, -64, -61, -69, -44, -84, 24, 83, -93, -6, -48, -75, -20, 92, -28, -55, 24, -18, -9, 31, -84, -100, 89, 50, -36, -5, 67, -67, 20, -90, -33, -29, 53, 77, -19, 68, -51, -30, -41, 22, 91, 7, -74, 38, -39, 71, 6, 73, 50, 44, 85, 9, 74, -29, -27, -39, -6, 29, 83, -18, -42, 91, 69, 58, 3, -60, 93, -39, -21, -77, 7, 12, -81, -99, 94, 12, -6, -82, 99, -31, -15, 0, -57, -100, 1, 54, -19, 47, 4, 39, -63, 38, -85, 20, 62, 47, -24, -74, -73, 17, -89, -4, 49, 71, -83, 88, 36, 11, 100, -71, 35, -46, -74, 11, 47, -96, 82, 45, 69, -25, 86, -27, -33, 25, -86, 91, 10, 62, 7, -56, 38, 86, 62, -28, -31, 15, -17, -100, -61, 96, 61, 80, 78, -87, -13, -59, -79, 62, 35}, + 848, + 50592, + }, + + { + []int{4, 2, 3}, + 1, + 5, + }, + + { + []int{3, -1, 0, 2}, + 3, + 6, + }, + + { + []int{2, -3, -1, 5, -4}, + 2, + 13, + }, + + // 可以有多个 testcase +} + +func Test_largestSumAfterKNegations(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, largestSumAfterKNegations(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_largestSumAfterKNegations(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + largestSumAfterKNegations(tc.A, tc.K) + } + } +} diff --git a/Algorithms/1006.clumsy-factorial/README.md b/Algorithms/1006.clumsy-factorial/README.md new file mode 100755 index 000000000..f89e884b0 --- /dev/null +++ b/Algorithms/1006.clumsy-factorial/README.md @@ -0,0 +1,32 @@ +# [1006. Clumsy Factorial](https://leetcode.com/problems/clumsy-factorial/) + +Normally, the factorial of a positive integer n is the product of all positive integers less than or equal to n. For example, factorial(10) = 10 * 9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1. + +We instead make a clumsy factorial: using the integers in decreasing order, we swap out the multiply operations for a fixed rotation of operations: multiply (*), divide (/), add (+) and subtract (-) in this order. + +For example, clumsy(10) = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1. However, these operations are still applied using the usual order of operations of arithmetic: we do all multiplication and division steps before any addition or subtraction steps, and multiplication and division steps are processed left to right. + +Additionally, the division that we use is floor division such that 10 * 9 / 8 equals 11. This guarantees the result is an integer. + +Implement the clumsy function as defined above: given an integer N, it returns the clumsy factorial of N. + +Example 1: + +```text +Input: 4 +Output: 7 +Explanation: 7 = 4 * 3 / 2 + 1 +``` + +Example 2: + +```text +Input: 10 +Output: 12 +Explanation: 12 = 10 * 9 / 8 + 7 - 6 * 5 / 4 + 3 - 2 * 1 +``` + +Note: + +- 1 <= N <= 10000 +- -2^31 <= answer <= 2^31 - 1 (The answer is guaranteed to fit within a 32-bit integer.) diff --git a/Algorithms/1006.clumsy-factorial/clumsy-factorial.go b/Algorithms/1006.clumsy-factorial/clumsy-factorial.go new file mode 100755 index 000000000..399031255 --- /dev/null +++ b/Algorithms/1006.clumsy-factorial/clumsy-factorial.go @@ -0,0 +1,22 @@ +package problem1006 + +var answers = []int{0, 1, 2, 6, 7} + +func clumsy(N int) int { + if N <= 4 { + return answers[N] + } + a := N*(N-1)/(N-2) + (N - 3) + b := (N - 4) * max(1, (N-5)) / max(1, (N-6)) + return a - 2*b + clumsy(N-4) +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +// go to look O(1) solution +// https://leetcode.com/problems/clumsy-factorial/discuss/252279/You-never-think-of-this-amazing-O(1)-solution diff --git a/Algorithms/1006.clumsy-factorial/clumsy-factorial_test.go b/Algorithms/1006.clumsy-factorial/clumsy-factorial_test.go new file mode 100755 index 000000000..88663297c --- /dev/null +++ b/Algorithms/1006.clumsy-factorial/clumsy-factorial_test.go @@ -0,0 +1,42 @@ +package problem1006 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans int +}{ + + { + 4, + 7, + }, + + { + 10, + 12, + }, + + // 可以有多个 testcase +} + +func Test_clumsy(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, clumsy(tc.N), "输入:%v", tc) + } +} + +func Benchmark_clumsy(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + clumsy(tc.N) + } + } +} diff --git a/Algorithms/1007.minimum-domino-rotations-for-equal-row/README.md b/Algorithms/1007.minimum-domino-rotations-for-equal-row/README.md new file mode 100755 index 000000000..145d1f437 --- /dev/null +++ b/Algorithms/1007.minimum-domino-rotations-for-equal-row/README.md @@ -0,0 +1,36 @@ +# [1007. Minimum Domino Rotations For Equal Row](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/) + +In a row of dominoes, A[i] and B[i] represent the top and bottom halves of the i-th domino. (A domino is a tile with two numbers from 1 to 6 - one on each half of the tile.) + +We may rotate the i-th domino, so that A[i] and B[i] swap values. + +Return the minimum number of rotations so that all the values in A are the same, or all the values in B are the same. + +If it cannot be done, return -1. + +Example 1: + +![domino](domino.png) + + +```text +Input: A = [2,1,2,4,2,2], B = [5,2,6,2,3,2] +Output: 2 +Explanation: +The first figure represents the dominoes as given by A and B: before we do any rotations. +If we rotate the second and fourth dominoes, we can make every value in the top row equal to 2, as indicated by the second figure. +``` + +Example 2: + +```text +Input: A = [3,5,1,2,3], B = [3,6,3,3,4] +Output: -1 +Explanation: +In this case, it is not possible to rotate the dominoes to make one row of values equal. +``` + +Note: + +- `1 <= A[i], B[i] <= 6` +- `2 <= A.length == B.length <= 20000` diff --git a/Algorithms/1007.minimum-domino-rotations-for-equal-row/domino.png b/Algorithms/1007.minimum-domino-rotations-for-equal-row/domino.png new file mode 100644 index 000000000..61f048ebb Binary files /dev/null and b/Algorithms/1007.minimum-domino-rotations-for-equal-row/domino.png differ diff --git a/Algorithms/1007.minimum-domino-rotations-for-equal-row/minimum-domino-rotations-for-equal-row.go b/Algorithms/1007.minimum-domino-rotations-for-equal-row/minimum-domino-rotations-for-equal-row.go new file mode 100755 index 000000000..08028e9f9 --- /dev/null +++ b/Algorithms/1007.minimum-domino-rotations-for-equal-row/minimum-domino-rotations-for-equal-row.go @@ -0,0 +1,32 @@ +package problem1007 + +func minDominoRotations(A []int, B []int) int { + if res, ok := check(A, B, A[0]); ok { + return res + } + if res, ok := check(A, B, B[0]); ok { + return res + } + return -1 +} + +func check(A, B []int, flag int) (int, bool) { + a, b := 0, 0 + i, n := 0, len(A) + for ; i < n && (A[i] == flag || B[i] == flag); i++ { + if A[i] != flag { // A needs a swap to be all flag + a++ + } + if B[i] != flag { // B needs a swap to be all flag + b++ + } + } + return min(a, b), i == n +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1007.minimum-domino-rotations-for-equal-row/minimum-domino-rotations-for-equal-row_test.go b/Algorithms/1007.minimum-domino-rotations-for-equal-row/minimum-domino-rotations-for-equal-row_test.go new file mode 100755 index 000000000..00e63e9f9 --- /dev/null +++ b/Algorithms/1007.minimum-domino-rotations-for-equal-row/minimum-domino-rotations-for-equal-row_test.go @@ -0,0 +1,57 @@ +package problem1007 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + B []int + ans int +}{ + + { + []int{2, 1, 1, 3, 2, 1, 2, 2, 1}, + []int{3, 2, 3, 1, 3, 2, 3, 3, 2}, + -1, + }, + + { + []int{5, 2, 6, 2, 3, 2}, + []int{2, 1, 2, 4, 2, 2}, + 2, + }, + + { + []int{2, 1, 2, 4, 2, 2}, + []int{5, 2, 6, 2, 3, 2}, + 2, + }, + + { + []int{3, 5, 1, 2, 3}, + []int{3, 6, 3, 3, 4}, + -1, + }, + + // 可以有多个 testcase +} + +func Test_minDominoRotations(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minDominoRotations(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_minDominoRotations(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minDominoRotations(tc.A, tc.B) + } + } +} diff --git a/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/1266.png b/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/1266.png new file mode 100644 index 000000000..3423c8333 Binary files /dev/null and b/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/1266.png differ diff --git a/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/README.md b/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/README.md new file mode 100755 index 000000000..63f8ee576 --- /dev/null +++ b/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/README.md @@ -0,0 +1,19 @@ +# [1008. Construct Binary Search Tree from Preorder Traversal](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/) + +Return the root node of a binary search tree that matches the given preorder traversal. + +(Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value < node.val, and any descendant of node.right has a value > node.val. Also recall that a preorder traversal displays the value of the node first, then traverses node.left, then traverses node.right.) + +Example 1: + +![1266](1266.png) + +```text +Input: [8,5,1,7,10,12] +Output: [8,5,10,1,7,null,12] +``` + +Note: + +- 1 <= preorder.length <= 100 +- The values of preorder are distinct. diff --git a/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/construct-binary-search-tree-from-preorder-traversal.go b/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/construct-binary-search-tree-from-preorder-traversal.go new file mode 100755 index 000000000..e114ef672 --- /dev/null +++ b/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/construct-binary-search-tree-from-preorder-traversal.go @@ -0,0 +1,27 @@ +package problem1008 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +// ref: https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/discuss/252232/JavaC%2B%2BPython-O(N)-Solution +func bstFromPreorder(A []int) *TreeNode { + i, n := 0, len(A) + + var helper func(int) *TreeNode + helper = func(bound int) *TreeNode { + if i == n || A[i] > bound { + return nil + } + root := &TreeNode{ + Val: A[i], + } + i++ + root.Left = helper(root.Val) + root.Right = helper(bound) + return root + } + + return helper(1 << 32) +} diff --git a/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/construct-binary-search-tree-from-preorder-traversal_test.go b/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/construct-binary-search-tree-from-preorder-traversal_test.go new file mode 100755 index 000000000..a3fcc53a1 --- /dev/null +++ b/Algorithms/1008.construct-binary-search-tree-from-preorder-traversal/construct-binary-search-tree-from-preorder-traversal_test.go @@ -0,0 +1,39 @@ +package problem1008 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + preorder []int + ans []int +}{ + + { + []int{8, 5, 1, 7, 10, 12}, + []int{8, 5, 10, 1, 7, kit.NULL, 12}, + }, + + // 可以有多个 testcase +} + +func Test_bstFromPreorder(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ans := kit.Tree2ints(bstFromPreorder(tc.preorder)) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_bstFromPreorder(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + bstFromPreorder(tc.preorder) + } + } +} diff --git a/Algorithms/1009.complement-of-base-10-integer/README.md b/Algorithms/1009.complement-of-base-10-integer/README.md new file mode 100755 index 000000000..56b0ed2f2 --- /dev/null +++ b/Algorithms/1009.complement-of-base-10-integer/README.md @@ -0,0 +1,35 @@ +# [1009. Complement of Base 10 Integer](https://leetcode.com/problems/complement-of-base-10-integer/) + +Every non-negative integer N has a binary representation. For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on. Note that except for N = 0, there are no leading zeroes in any binary representation. + +The complement of a binary representation is the number in binary you get when changing every 1 to a 0 and 0 to a 1. For example, the complement of "101" in binary is "010" in binary. + +For a given number N in base-10, return the complement of it's binary representation as a base-10 integer. + +Example 1: + +```text +Input: 5 +Output: 2 +Explanation: 5 is "101" in binary, with complement "010" in binary, which is 2 in base-10. +``` + +Example 2: + +```text +Input: 7 +Output: 0 +Explanation: 7 is "111" in binary, with complement "000" in binary, which is 0 in base-10. +``` + +Example 3: + +```text +Input: 10 +Output: 5 +Explanation: 10 is "1010" in binary, with complement "0101" in binary, which is 5 in base-10. +``` + +Note: + +- 0 <= N < 10^9 diff --git a/Algorithms/1009.complement-of-base-10-integer/complement-of-base-10-integer.go b/Algorithms/1009.complement-of-base-10-integer/complement-of-base-10-integer.go new file mode 100755 index 000000000..b425470b7 --- /dev/null +++ b/Algorithms/1009.complement-of-base-10-integer/complement-of-base-10-integer.go @@ -0,0 +1,14 @@ +package problem1009 + +func bitwiseComplement(N int) int { + x := N + x |= 1 // when x is 0 + x |= x >> 1 + x |= x >> 2 + x |= x >> 4 + x |= x >> 8 + x |= x >> 16 + // if N is 000101011101 + // then x 000111111111 + return x ^ N +} diff --git a/Algorithms/1009.complement-of-base-10-integer/complement-of-base-10-integer_test.go b/Algorithms/1009.complement-of-base-10-integer/complement-of-base-10-integer_test.go new file mode 100755 index 000000000..b1f9b946a --- /dev/null +++ b/Algorithms/1009.complement-of-base-10-integer/complement-of-base-10-integer_test.go @@ -0,0 +1,67 @@ +package problem1009 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans int +}{ + + { + 2, + 1, + }, + + { + 1, + 0, + }, + + { + 0, + 1, + }, + + { + 5, + 2, + }, + + { + 7, + 0, + }, + + { + 10, + 5, + }, + + { + 87654321, + 46563406, + }, + + // 可以有多个 testcase +} + +func Test_bitwiseComplement(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, bitwiseComplement(tc.N), "输入:%v", tc) + } +} + +func Benchmark_bitwiseComplement(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + bitwiseComplement(tc.N) + } + } +} diff --git a/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/README.md b/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/README.md new file mode 100755 index 000000000..df95c13df --- /dev/null +++ b/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/README.md @@ -0,0 +1,29 @@ +# [1010. Pairs of Songs With Total Durations Divisible by 60](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/) + +In a list of songs, the i-th song has a duration of time[i] seconds. + +Return the number of pairs of songs for which their total duration in seconds is divisible by 60. Formally, we want the number of indices i < j with (time[i] + time[j]) % 60 == 0. + +Example 1: + +```text +Input: [30,20,150,100,40] +Output: 3 +Explanation: Three pairs have a total duration divisible by 60: +(time[0] = 30, time[2] = 150): total duration 180 +(time[1] = 20, time[3] = 100): total duration 120 +(time[1] = 20, time[4] = 40): total duration 60 +``` + +Example 2: + +```text +Input: [60,60,60] +Output: 3 +Explanation: All three pairs have a total duration of 120, which is divisible by 60. +``` + +Note: + +- 1 <= time.length <= 60000 +- 1 <= time[i] <= 500 diff --git a/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/pairs-of-songs-with-total-durations-divisible-by-60.go b/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/pairs-of-songs-with-total-durations-divisible-by-60.go new file mode 100755 index 000000000..0876d21a0 --- /dev/null +++ b/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/pairs-of-songs-with-total-durations-divisible-by-60.go @@ -0,0 +1,16 @@ +package problem1010 + +func numPairsDivisibleBy60(time []int) int { + rec := [60]int{} + for _, t := range time { + rec[t%60]++ + } + + res := rec[0] * (rec[0] - 1) / 2 + res += rec[30] * (rec[30] - 1) / 2 + for i := 1; i < 30; i++ { + res += rec[i] * rec[60-i] + } + + return res +} diff --git a/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/pairs-of-songs-with-total-durations-divisible-by-60_test.go b/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/pairs-of-songs-with-total-durations-divisible-by-60_test.go new file mode 100755 index 000000000..50fd8e13a --- /dev/null +++ b/Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60/pairs-of-songs-with-total-durations-divisible-by-60_test.go @@ -0,0 +1,52 @@ +package problem1010 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + time []int + ans int +}{ + + { + []int{95, 51, 462, 476, 245, 271, 481, 257, 130, 314, 244, 215, 397, 60, 21, 60, 168, 213, 107, 394, 209, 223, 410, 220, 444, 337, 264, 417, 356, 409, 467, 23, 273, 236, 281, 478, 227, 69, 207, 255, 18, 133, 362, 161, 329, 66, 233, 487, 23, 315, 296, 60, 424, 370, 331, 305, 333, 218, 145, 379, 212, 413, 486, 111, 45, 239, 57, 395, 140, 405, 266, 212, 356, 28, 346, 358, 309, 263, 101, 46, 167, 352, 359, 381, 205, 308, 213, 390, 211, 142, 287, 476, 189, 164, 9, 5, 58, 206, 39, 248, 409, 189, 139, 128, 107, 342, 466, 143, 267, 372, 119, 172, 416, 5, 31, 77, 167, 133, 192, 182, 323, 238, 219, 140, 327, 275, 361, 435, 452, 489, 185, 468, 252, 144, 233, 7, 243, 83, 72, 35, 446, 188, 259, 185, 499, 141, 457, 33, 267, 238, 224, 121, 164, 436, 375, 259, 247, 136, 207, 391, 255, 182, 237, 451, 184, 407, 156, 386, 249, 351, 336, 110, 262, 119, 375, 302, 95, 236, 279, 172, 199, 346, 14, 291, 338, 102, 101, 182, 28, 321, 446, 384, 191, 71, 259, 410, 113, 160, 372, 260, 452, 246, 132, 416, 20, 113, 257, 113, 300, 222, 295, 10, 461, 449, 233, 73, 273, 91, 464, 452, 362, 477, 2, 435, 373, 139, 165, 20, 455, 361, 62, 253, 412, 281, 362, 94, 246, 475, 224, 176, 22, 388, 100, 255, 180, 340, 93, 245, 442, 420, 353, 25, 329, 232, 216, 2, 120, 450, 57, 133, 47, 309, 460, 354, 93, 259, 485, 339, 490, 56, 488, 311, 250, 217, 247, 420, 376, 329, 491, 165, 488, 251, 430, 470, 122, 111, 359, 343, 200, 480, 162, 353, 344, 349, 301, 145, 388, 456, 17, 455, 487, 324, 493, 248, 151, 53, 414, 396, 194, 170, 290, 349, 287, 242, 53, 77, 219, 280, 267, 384, 118, 314, 12, 189, 118, 379, 254, 160, 179, 29, 87, 274, 346, 228, 488, 481, 481, 56, 67, 3, 256, 463, 150, 399, 340, 464, 9, 28, 479, 250, 256, 21, 209, 87, 59, 7, 433, 189, 433, 22, 76, 45, 217, 301, 34, 98, 248, 265, 496, 319, 157, 69, 216, 46, 299, 233, 153, 310, 151, 299, 283, 206, 335, 220, 65, 195, 76, 213, 10, 150, 104, 488, 139, 360, 426, 14, 115, 136, 409, 36, 165, 488, 440, 111, 462, 369, 341, 234, 372, 226, 369, 136, 424, 125, 418, 215, 178, 291, 54, 183, 140, 82, 326, 92, 50, 82, 311, 12, 1, 9, 99, 106, 195, 153, 77, 108, 60, 211, 69, 194, 253, 246, 353, 273, 483, 452, 488, 229, 412, 333, 441, 39, 255, 190, 480, 280, 419, 19, 337, 252, 312, 154, 247, 380, 94, 70, 55, 320, 448, 328, 230, 18, 322, 309, 79, 477, 239, 314, 426, 19, 408, 151, 62, 495, 183, 401, 431, 396, 93, 336, 205, 423, 113, 369, 376, 217, 158, 389, 250, 271, 465, 5, 108, 221, 309, 148, 57, 500, 209, 259, 149, 479, 321, 368, 347, 358, 109, 23, 152, 114, 476, 428, 314, 78, 95, 16, 58, 317, 84, 108, 338, 386, 495, 128, 172, 459, 29, 385, 181, 102, 3, 8, 198, 359, 115, 149, 82, 88, 340, 416, 450, 472, 353, 495, 432, 404, 370, 74, 426, 121, 423, 406, 260, 84, 23, 459, 384, 156, 310, 66, 493, 108, 43, 248, 408, 134, 323, 416, 202, 110, 20, 425, 38, 257, 19, 334, 300, 362, 319, 12, 82, 200, 95, 316, 447, 221, 372, 285, 490, 245, 84, 386, 188, 109, 244, 411, 232, 473, 56, 351, 44, 278, 294, 145, 198, 65, 242, 340, 237, 242, 308, 385, 204, 2, 344, 220, 63, 250, 174, 79, 186, 289, 288, 82, 159, 285, 495, 129, 8, 478, 202, 74, 263, 474, 184, 212, 160, 476, 374, 345, 103, 106, 307, 436, 291, 435, 363, 332, 292, 425, 429, 184, 290, 332, 189, 20, 316, 317, 458, 287, 202, 79, 301, 431, 387, 178, 88, 94, 335, 295, 52, 53, 170, 305, 155, 268, 380, 395, 211, 379, 347, 284, 417, 32, 264, 318, 47, 318, 265, 191, 131, 331, 301, 399, 309, 476, 484, 348, 277, 136, 204, 1, 447, 124, 226, 100, 109, 106, 177, 43, 328, 33, 418, 410, 127, 3, 171, 75, 198, 307, 289, 73, 89, 95, 353, 483, 7, 412, 90, 254, 24, 253, 265, 162, 439, 283, 352, 169, 184, 272, 200, 234, 38, 495, 83, 212, 314, 341, 175, 368, 143, 380, 329, 391, 4, 255, 399, 13, 182, 3, 198, 251, 159, 417, 4, 410, 492, 149, 243, 22, 148, 229, 300, 112, 458, 228, 350, 36, 479, 83, 361, 276, 9, 11, 51, 111, 45, 345, 342, 47, 50, 465, 467, 219, 368, 92, 268, 390, 487, 450, 107, 282, 189, 409, 310, 70, 227, 212, 449, 380, 48, 148, 275, 452, 48, 274, 102, 415, 191, 391, 38, 324, 460, 31, 429, 171, 202, 383, 162, 245, 42, 179, 341, 281, 283, 4, 225, 259, 461, 307, 294, 167, 67, 408, 271, 154, 393, 396, 366, 354, 230, 60, 323, 9, 122, 28, 389, 26, 266, 417, 352, 459, 423, 495, 148, 28, 223, 231, 144, 179, 380, 2, 480, 26, 151, 304, 469, 88, 94, 382, 131, 284, 458, 452, 241, 72, 438, 296, 225, 172, 150, 130, 40, 273, 402, 122, 96, 374, 492, 377, 238, 262, 261, 179, 24, 251, 252, 190, 63, 169, 481, 114, 226, 93, 440, 320, 49, 7, 248, 124, 283, 425, 448, 206, 133, 257, 257, 204, 209, 235, 474, 426, 284, 272, 123, 133, 140, 100, 263, 484, 59, 397, 25, 362, 334, 86, 195, 43, 266, 117, 174, 62, 430, 281, 307, 122, 184, 133, 170, 121, 419, 103, 490, 458, 48, 314, 46, 201, 2, 128, 254, 166, 416, 181, 399, 201, 191, 262, 251, 81, 225, 311, 174, 216, 155, 285, 324, 325, 111, 272, 152, 246, 35, 167, 422, 398, 401, 55, 314, 84, 337, 300, 440, 494, 18, 124, 86, 472, 57, 433, 128, 246, 392, 227, 499, 409, 421, 180, 362, 147, 152, 415, 39, 170, 136, 2, 132, 477, 463, 195, 56, 491, 217, 398, 302, 54, 365, 254, 338, 465, 141, 252, 359, 319, 53, 187, 17, 426, 183, 50, 240, 196, 70, 488, 240, 121, 223, 484, 204, 151, 134, 367, 131, 281, 243, 96, 357, 77, 322, 79, 67, 250, 142, 405, 215, 82, 23, 58, 297, 346, 400, 352, 453, 133, 173, 145, 234, 152, 318, 469, 36, 292, 471, 314, 91, 7, 446, 1, 298, 287, 76, 196, 109, 434, 136, 262, 288, 461, 114, 385, 317, 284, 333, 441, 406, 464, 14, 442, 481, 78, 467, 138, 446, 265, 441, 175, 232, 419, 478, 78, 216, 61, 455, 243, 345, 106, 427, 435, 274, 136, 431, 66, 71, 135, 436, 209, 457, 7, 392, 437, 65, 59, 157, 141, 269, 257, 384, 197, 235, 63, 203, 426, 71, 29, 304, 402, 318, 384, 312, 490, 78, 121, 305, 139, 19, 340, 368, 24, 409, 218, 31, 356, 475, 59, 476, 465, 245, 316, 340, 69, 195, 34, 346, 292, 464, 261, 38, 373, 484, 82, 2, 413, 159, 106, 320, 39, 387, 281, 421, 251, 114, 99, 495, 330, 202, 362, 233, 71, 370, 319, 74, 289, 68, 420, 10, 467, 370, 328, 53, 110, 299, 203, 273, 223, 205, 214, 300, 419, 213, 41, 59, 200, 20, 172, 381, 263, 98, 309, 154, 368, 333, 484, 313, 240, 78, 106, 355, 244, 265, 475, 473, 411, 244, 268, 185, 468, 308, 9, 365, 129, 240, 464, 323, 249, 212, 496, 364, 119, 119, 195, 153, 17, 377, 181, 81, 326, 334, 395, 145, 13, 461, 57, 26, 163, 314, 71, 27, 248, 289, 148, 336, 339, 188, 202, 96, 310, 297, 200, 312, 235, 181, 61, 410, 169, 326, 445, 111, 464, 415, 199, 177}, + 14804, + }, + + { + []int{336, 24, 100, 342, 274, 11, 43, 22, 416, 138, 384, 386, 70, 265, 59, 253, 344, 435, 400, 296, 192, 143, 311, 424, 315, 63, 420, 254, 493, 431, 32, 394, 178, 51, 378, 335, 265, 92, 335, 325, 25, 355, 258, 298, 390, 399, 393, 114, 149, 62, 299, 471, 286, 204, 163, 214, 15, 272, 315, 212, 272, 437, 339, 193, 125, 394, 62, 188, 154, 150, 109, 294, 228, 200, 459, 42, 469, 132, 37, 460, 143, 1, 144, 127, 398, 82, 370, 464, 14, 85, 321, 358, 205, 14, 264, 289, 183, 93, 56, 126, 413, 140, 441, 446, 445, 378, 258, 119, 385, 226, 8, 93, 476, 265, 115, 86, 360, 92, 396, 407, 458, 58, 65, 397, 381, 32, 228, 37, 319, 220, 73, 328, 162, 458, 231, 219, 481, 387, 423, 256, 252, 36, 309, 395, 471, 4, 225, 146, 188, 182, 347, 82, 21, 292, 91, 144, 387, 263, 206, 452, 197, 192, 324, 257, 370, 28, 440, 180, 294}, + 245, + }, + + { + []int{30, 20, 150, 100, 40}, + 3, + }, + + { + []int{60, 60, 60}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_numPairsDivisibleBy60(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numPairsDivisibleBy60(tc.time), "输入:%v", tc) + } +} + +func Benchmark_numPairsDivisibleBy60(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numPairsDivisibleBy60(tc.time) + } + } +} diff --git a/Algorithms/1011.capacity-to-ship-packages-within-d-days/README.md b/Algorithms/1011.capacity-to-ship-packages-within-d-days/README.md new file mode 100755 index 000000000..858f6d2b9 --- /dev/null +++ b/Algorithms/1011.capacity-to-ship-packages-within-d-days/README.md @@ -0,0 +1,52 @@ +# [1011. Capacity To Ship Packages Within D Days](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/) + +A conveyor belt has packages that must be shipped from one port to another within D days. + +The i-th package on the conveyor belt has a weight of weights[i]. Each day, we load the ship with packages on the conveyor belt (in the order given by weights). We may not load more weight than the maximum weight capacity of the ship. + +Return the least weight capacity of the ship that will result in all the packages on the conveyor belt being shipped within D days. + +Example 1: + +```text +Input: weights = [1,2,3,4,5,6,7,8,9,10], D = 5 +Output: 15 +Explanation: +A ship capacity of 15 is the minimum to ship all the packages in 5 days like this: +1st day: 1, 2, 3, 4, 5 +2nd day: 6, 7 +3rd day: 8 +4th day: 9 +5th day: 10 + +Note that the cargo must be shipped in the order given, so using a ship of capacity 14 and splitting the packages into parts like (2, 3, 4, 5), (1, 6, 7), (8), (9), (10) is not allowed. +``` + +Example 2: + +```text +Input: weights = [3,2,2,4,1,4], D = 3 +Output: 6 +Explanation: +A ship capacity of 6 is the minimum to ship all the packages in 3 days like this: +1st day: 3, 2 +2nd day: 2, 4 +3rd day: 1, 4 +``` + +Example 3: + +```text +Input: weights = [1,2,3,1,1], D = 4 +Output: 3 +Explanation: +1st day: 1 +2nd day: 2 +3rd day: 3 +4th day: 1, 1 +``` + +Note: + +- `1 <= D <= weights.length <= 50000` +- `1 <= weights[i] <= 500` diff --git a/Algorithms/1011.capacity-to-ship-packages-within-d-days/capacity-to-ship-packages-within-d-days.go b/Algorithms/1011.capacity-to-ship-packages-within-d-days/capacity-to-ship-packages-within-d-days.go new file mode 100755 index 000000000..50fc17390 --- /dev/null +++ b/Algorithms/1011.capacity-to-ship-packages-within-d-days/capacity-to-ship-packages-within-d-days.go @@ -0,0 +1,35 @@ +package problem1011 + +func shipWithinDays(weights []int, D int) int { + lo, hi := 0, 0 + for _, w := range weights { + lo = max(lo, w) + hi += w + } + + for lo < hi { + mid := (lo + hi) >> 1 + days, cur := 1, 0 + for _, w := range weights { + if cur+w > mid { + days++ + cur = 0 + } + cur += w + } + if days > D { + lo = mid + 1 + } else { + hi = mid + } + } + + return lo +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1011.capacity-to-ship-packages-within-d-days/capacity-to-ship-packages-within-d-days_test.go b/Algorithms/1011.capacity-to-ship-packages-within-d-days/capacity-to-ship-packages-within-d-days_test.go new file mode 100755 index 000000000..823a23356 --- /dev/null +++ b/Algorithms/1011.capacity-to-ship-packages-within-d-days/capacity-to-ship-packages-within-d-days_test.go @@ -0,0 +1,75 @@ +package problem1011 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + weights []int + D int + ans int +}{ + + { + []int{59, 468, 1, 380, 122, 368, 175, 383, 398, 422, 175, 403, 11, 415, 62, 379, 418, 406, 485, 410, 440, 364, 329, 8, 235, 461, 308, 69, 347, 37, 450, 187, 382, 44, 209, 463, 393, 478, 162, 376, 88, 335, 70, 3, 233, 375, 54, 412, 270, 299, 155, 243, 195, 423, 402, 464, 6, 63, 473, 149, 62, 162, 320, 490, 27, 30, 226, 488, 451, 18, 85, 179, 303, 425, 333, 210, 128, 422, 334, 475, 387, 379, 81, 196, 310, 48, 16, 171, 472, 35, 103, 434, 61, 498, 195, 168, 167, 394, 254, 99, 190, 316, 393, 40, 397, 170, 437, 442, 291, 323, 415, 336, 143, 400, 352, 42, 201, 28, 233, 43, 142, 81, 24, 378, 384, 156, 250, 376, 172, 493, 179, 500, 89, 104, 69, 320, 108, 238, 89, 245, 478, 242, 344, 47, 112, 188, 383, 10, 488, 9, 471, 430, 129, 1, 154, 344, 235, 456, 29, 115, 9, 394, 192, 12, 349, 415, 101, 398, 383, 175, 465, 267, 206, 71, 113, 448, 205, 202, 254, 221, 336, 425, 470, 455, 344, 172, 425, 417, 291, 190, 24, 240, 14, 397, 61, 246, 128, 232, 189, 210, 186, 163, 33, 386, 258, 50, 326, 412, 134, 19, 141, 158, 459, 403, 124, 99, 344, 269, 383, 151, 419, 495, 44, 295, 331, 59, 71, 386, 408, 79, 214, 217, 425, 189, 134, 232, 294, 232, 444, 198, 488, 21, 457, 118, 471, 256, 95, 428, 447, 112, 238, 408, 391, 270, 335, 244, 13, 402, 69, 121, 357, 221, 463, 113, 329, 193, 483, 384, 182, 380, 178, 263, 458, 422, 265, 439, 252, 222, 138, 88, 47, 465, 117, 91, 291, 107, 391, 239, 19, 108, 443, 497, 357, 432, 12, 252, 457, 96, 264, 210, 118, 395, 116, 445, 60, 361, 193, 363, 448, 435, 245, 190, 263, 169, 376, 381, 168, 403, 196, 477, 281, 16, 33, 84, 138, 10, 213, 434, 373, 464, 413, 351, 167, 411, 54, 134, 90, 102, 46, 41, 25, 270, 252, 383, 380, 499, 3, 128, 17, 392, 144, 433, 447, 383, 219, 262, 363, 82, 463, 461, 214, 207, 255, 398, 104, 306, 469, 385, 36, 202, 490, 350, 370, 207, 156, 153, 396, 155, 219, 298, 430, 480, 1, 415, 278, 55, 418, 353, 60, 169, 164, 43, 91, 489, 1, 7, 309, 159, 208, 246, 283, 140, 247, 204, 387, 15, 412, 182, 409, 61, 431, 394, 147, 150, 62, 423, 165, 298, 333, 467, 293, 226, 291, 187, 188, 368, 483, 234, 459, 386, 103, 374, 302, 320, 492, 277, 25, 21, 36, 149, 178, 78, 359, 457, 101, 139, 491, 266, 64, 352, 353, 471, 55, 265, 105, 101, 281, 286, 5, 27, 165, 360, 114, 344, 262, 266, 290, 464, 451, 209, 265, 371, 59, 453, 224, 465, 463, 261, 1, 295, 475, 71, 308, 1, 53, 58, 355, 470, 222, 242, 364, 275, 223, 484, 294, 8, 125, 75, 155, 469, 141, 319, 377, 258, 161, 374, 89, 52, 165, 206, 366, 6}, + 256, + 682, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + 10, + 10, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + 1, + 55, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, + 5, + 15, + }, + + { + []int{1, 2, 3, 1, 1}, + 4, + 3, + }, + + { + []int{1, 1, 1}, + 3, + 1, + }, + + { + []int{3, 2, 2, 4, 1, 4}, + 3, + 6, + }, + + // 可以有多个 testcase +} + +func Test_shipWithinDays(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, shipWithinDays(tc.weights, tc.D), "输入:%v", tc) + } +} + +func Benchmark_shipWithinDays(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shipWithinDays(tc.weights, tc.D) + } + } +} diff --git a/Algorithms/1012.numbers-with-repeated-digits/README.md b/Algorithms/1012.numbers-with-repeated-digits/README.md new file mode 100755 index 000000000..5ff1827d3 --- /dev/null +++ b/Algorithms/1012.numbers-with-repeated-digits/README.md @@ -0,0 +1,30 @@ +# [1012. Numbers With Repeated Digits](https://leetcode.com/problems/numbers-with-repeated-digits/) + +Given a positive integer N, return the number of positive integers less than or equal to N that have at least 1 repeated digit. + +Example 1: + +```text +Input: 20 +Output: 1 +Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11. +``` + +Example 2: + +```text +Input: 100 +Output: 10 +Explanation: The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100. +``` + +Example 3: + +```text +Input: 1000 +Output: 262 +``` + +Note: + +- `1 <= N <= 10^9` diff --git a/Algorithms/1012.numbers-with-repeated-digits/numbers-with-repeated-digits.go b/Algorithms/1012.numbers-with-repeated-digits/numbers-with-repeated-digits.go new file mode 100755 index 000000000..beb73bcde --- /dev/null +++ b/Algorithms/1012.numbers-with-repeated-digits/numbers-with-repeated-digits.go @@ -0,0 +1,73 @@ +package problem1012 + +// ref: https://leetcode.com/problems/numbers-with-repeated-digits/discuss/256725/JavaPython-Count-the-Number-Without-Repeated-Digit +func numDupDigitsAtMostN(N int) int { + digits := convert(N + 1) // +1 为为了把判别条件从 <= 简化成 < + bits := len(digits) + + noRepeat := 0 + // 统计宽度短于 N 的不含重复数字的数的个数 + for b := 1; b < bits; b++ { + noRepeat += 9 * count(9, b-1) + } + + // 统计和 N 具有相同高位的且不含重复数字的数的个数 + hasSeen := make(map[int]bool, 10) + for b := 0; b < bits; b++ { + d := 0 + if b == 0 { + d = 1 // 最高位上的数字不能为 0 + } + for ; d < digits[b]; d++ { + // 如果 hasSeen[d]=true + // 说明在更高位上已经出现过 d 了 + // 无论低位上再出现什么,都不是 noRepeat 了 + if !hasSeen[d] { + noRepeat += count(9-b, bits-b-1) + } + } + if hasSeen[digits[b]] { + // digits[:b+1] 中出现了重复的数字 + // 不可能再有 noRepeat 了 + break + } + hasSeen[digits[b]] = true + } + return N - noRepeat +} + +func convert(N int) []int { + res := make([]int, 0, 10) + for N > 0 { + res = append(res, N%10) + N /= 10 + } + swap(res) + return res +} + +func swap(A []int) { + i, j := 0, len(A)-1 + for i < j { + A[i], A[j] = A[j], A[i] + i++ + j-- + } +} + +// 统计了 m 个数字组成宽度为 n 的数值时, +// 不含重复数字的数值的个数。 +// 注意, +// 真正使用 count 的时候,是为了统计 n+1 位宽度的数值 +// 在 n+1 位的最高位上不放置 0 +// 就可以保证剩下的 n 位的宽度确实是 n +// 所以,count 在使用时,还需要乘上 n+1 位上可供选择的数字的个数 +// 例如, 9*count(9, i-1) 的实际含义才是,所有宽度为 i 且不包含重复数字的数值个数 +// 例如, count(8,i) 的实际含义是,以 X 开头所有宽度为 i+1 且不包含重复数字的数的个数 +// X 可以是任意一个数字 +func count(m, n int) int { + if n == 0 { + return 1 + } + return count(m, n-1) * (m - n + 1) +} diff --git a/Algorithms/1012.numbers-with-repeated-digits/numbers-with-repeated-digits_test.go b/Algorithms/1012.numbers-with-repeated-digits/numbers-with-repeated-digits_test.go new file mode 100755 index 000000000..e46cf8d20 --- /dev/null +++ b/Algorithms/1012.numbers-with-repeated-digits/numbers-with-repeated-digits_test.go @@ -0,0 +1,57 @@ +package problem1012 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans int +}{ + + { + 1000000000, + 994388230, + }, + + { + 888, + 230, + }, + + { + 20, + 1, + }, + + { + 100, + 10, + }, + + { + 1000, + 262, + }, + + // 可以有多个 testcase +} + +func Test_numDupDigitsAtMostN(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numDupDigitsAtMostN(tc.N), "输入:%v", tc) + } +} + +func Benchmark_numDupDigitsAtMostN(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numDupDigitsAtMostN(tc.N) + } + } +} diff --git a/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/README.md b/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/README.md new file mode 100755 index 000000000..5d2e96662 --- /dev/null +++ b/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/README.md @@ -0,0 +1,33 @@ +# [1013. Partition Array Into Three Parts With Equal Sum](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/) + +Given an array A of integers, return true if and only if we can partition the array into three non-empty parts with equal sums. + +Formally, we can partition the array if we can find indexes i+1 < j with (A[0] + A[1] + ... + A[i] == A[i+1] + A[i+2] + ... + A[j-1] == A[j] + A[j-1] + ... + A[A.length - 1]) + +Example 1: + +```text +Input: [0,2,1,-6,6,-7,9,1,2,0,1] +Output: true +Explanation: 0 + 2 + 1 = -6 + 6 - 7 + 9 + 1 = 2 + 0 + 1 +``` + +Example 2: + +```text +Input: [0,2,1,-6,6,7,9,-1,2,0,1] +Output: false +``` + +Example 3: + +```text +Input: [3,3,6,5,-2,2,5,1,-9,4] +Output: true +Explanation: 3 + 3 = 6 = 5 - 2 + 2 + 5 + 1 - 9 + 4 +``` + +Note: + +- `3 <= A.length <= 50000` +- `-10000 <= A[i] <= 10000` diff --git a/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/partition-array-into-three-parts-with-equal-sum.go b/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/partition-array-into-three-parts-with-equal-sum.go new file mode 100755 index 000000000..1118b96d4 --- /dev/null +++ b/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/partition-array-into-three-parts-with-equal-sum.go @@ -0,0 +1,28 @@ +package problem1013 + +func canThreePartsEqualSum(A []int) bool { + n := len(A) + sums := make([]int, n) + s := 0 + for i := 0; i < n; i++ { + s += A[i] + sums[i] = s + } + if s%3 != 0 { + return false + } + + s /= 3 + i := 0 + for i < n && sums[i] != s { + i++ + } + + s *= 2 + j := n - 1 + for 0 <= j && sums[j] != s { + j-- + } + + return i < j +} diff --git a/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/partition-array-into-three-parts-with-equal-sum_test.go b/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/partition-array-into-three-parts-with-equal-sum_test.go new file mode 100755 index 000000000..3529ca006 --- /dev/null +++ b/Algorithms/1013.partition-array-into-three-parts-with-equal-sum/partition-array-into-three-parts-with-equal-sum_test.go @@ -0,0 +1,57 @@ +package problem1013 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans bool +}{ + + { + []int{6, 1, 1, 13, -1, 0, -10, 20}, + false, + }, + + { + []int{3, 3, 6, 5, -2, 2, 5, 1, -9, 4}, + true, + }, + + { + []int{0, 2, 1, -6, 6, -7, 9, 1, 2, 0, 1, 2}, + false, + }, + + { + []int{0, 2, 1, -6, 6, -7, 9, 1, 2, 0, 1}, + true, + }, + + { + []int{0, 2, 1, -6, 6, 7, 9, -1, 2, 0, 1}, + false, + }, + + // 可以有多个 testcase +} + +func Test_canThreePartsEqualSum(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, canThreePartsEqualSum(tc.A), "输入:%v", tc) + } +} + +func Benchmark_canThreePartsEqualSum(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + canThreePartsEqualSum(tc.A) + } + } +} diff --git a/Algorithms/1014.best-sightseeing-pair/README.md b/Algorithms/1014.best-sightseeing-pair/README.md new file mode 100755 index 000000000..ed8e17eae --- /dev/null +++ b/Algorithms/1014.best-sightseeing-pair/README.md @@ -0,0 +1,20 @@ +# [1014. Best Sightseeing Pair](https://leetcode.com/problems/best-sightseeing-pair/) + +Given an array A of positive integers, A[i] represents the value of the i-th sightseeing spot, and two sightseeing spots i and j have distance j - i between them. + +The score of a pair (i < j) of sightseeing spots is (A[i] + A[j] + i - j) : the sum of the values of the sightseeing spots, minus the distance between them. + +Return the maximum score of a pair of sightseeing spots. + +Example 1: + +```text +Input: [8,1,5,2,6] +Output: 11 +Explanation: i = 0, j = 2, A[i] + A[j] + i - j = 8 + 5 + 0 - 2 = 11 +``` + +Note: + +- `2 <= A.length <= 50000` +- `1 <= A[i] <= 1000` diff --git a/Algorithms/1014.best-sightseeing-pair/best-sightseeing-pair.go b/Algorithms/1014.best-sightseeing-pair/best-sightseeing-pair.go new file mode 100755 index 000000000..bad3da607 --- /dev/null +++ b/Algorithms/1014.best-sightseeing-pair/best-sightseeing-pair.go @@ -0,0 +1,18 @@ +package problem1014 + +func maxScoreSightseeingPair(A []int) int { + a := A[0] // a is A[i]+i + res := 0 + for j := 1; j < len(A); j++ { + res = max(res, a+A[j]-j) + a = max(a, A[j]+j) + } + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1014.best-sightseeing-pair/best-sightseeing-pair_test.go b/Algorithms/1014.best-sightseeing-pair/best-sightseeing-pair_test.go new file mode 100755 index 000000000..192a62a49 --- /dev/null +++ b/Algorithms/1014.best-sightseeing-pair/best-sightseeing-pair_test.go @@ -0,0 +1,42 @@ +package problem1014 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{1, 2}, + 2, + }, + + { + []int{8, 1, 5, 2, 6}, + 11, + }, + + // 可以有多个 testcase +} + +func Test_maxScoreSightseeingPair(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxScoreSightseeingPair(tc.A), "输入:%v", tc) + } +} + +func Benchmark_maxScoreSightseeingPair(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxScoreSightseeingPair(tc.A) + } + } +} diff --git a/Algorithms/1015.smallest-integer-divisible-by-k/README.md b/Algorithms/1015.smallest-integer-divisible-by-k/README.md new file mode 100755 index 000000000..00fc5ecbc --- /dev/null +++ b/Algorithms/1015.smallest-integer-divisible-by-k/README.md @@ -0,0 +1,33 @@ +# [1015. Smallest Integer Divisible by K](https://leetcode.com/problems/smallest-integer-divisible-by-k/) + +Given a positive integer K, you need find the smallest positive integer N such that N is divisible by K, and N only contains the digit 1. + +Return the length of N. If there is no such N, return -1. + +Example 1: + +```text +Input: 1 +Output: 1 +Explanation: The smallest answer is N = 1, which has length 1. +``` + +Example 2: + +```text +Input: 2 +Output: -1 +Explanation: There is no such positive integer N divisible by 2. +``` + +Example 3: + +```text +Input: 3 +Output: 3 +Explanation: The smallest answer is N = 111, which has length 3. +``` + +Note: + +- `1 <= K <= 10^5` diff --git a/Algorithms/1015.smallest-integer-divisible-by-k/smallest-integer-divisible-by-k.go b/Algorithms/1015.smallest-integer-divisible-by-k/smallest-integer-divisible-by-k.go new file mode 100755 index 000000000..a58cb66be --- /dev/null +++ b/Algorithms/1015.smallest-integer-divisible-by-k/smallest-integer-divisible-by-k.go @@ -0,0 +1,16 @@ +package problem1015 + +// ref: https://leetcode.com/problems/smallest-integer-divisible-by-k/discuss/260852/JavaC%2B%2BPython-O(1)-Space-with-Proves-of-Pigeon-Holes +func smallestRepunitDivByK(K int) int { + if K%2 == 0 || K%5 == 0 { + return -1 + } + + r, length := 1%K, 1 + for r != 0 && length <= K { + r = (r*10 + 1) % K + length++ + } + + return length +} diff --git a/Algorithms/1015.smallest-integer-divisible-by-k/smallest-integer-divisible-by-k_test.go b/Algorithms/1015.smallest-integer-divisible-by-k/smallest-integer-divisible-by-k_test.go new file mode 100755 index 000000000..66fd784a3 --- /dev/null +++ b/Algorithms/1015.smallest-integer-divisible-by-k/smallest-integer-divisible-by-k_test.go @@ -0,0 +1,57 @@ +package problem1015 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + K int + ans int +}{ + + { + 23, + 22, + }, + + { + 5, + -1, + }, + + { + 1, + 1, + }, + + { + 2, + -1, + }, + + { + 3, + 3, + }, + + // 可以有多个 testcase +} + +func Test_smallestRepunitDivByK(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, smallestRepunitDivByK(tc.K), "输入:%v", tc) + } +} + +func Benchmark_smallestRepunitDivByK(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + smallestRepunitDivByK(tc.K) + } + } +} diff --git a/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/README.md b/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/README.md new file mode 100755 index 000000000..b2390e571 --- /dev/null +++ b/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/README.md @@ -0,0 +1,22 @@ +# [1016. Binary String With Substrings Representing 1 To N](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/) + +Given a binary string S (a string consisting only of '0' and '1's) and a positive integer N, return true if and only if for every integer X from 1 to N, the binary representation of X is a substring of S. + +Example 1: + +```text +Input: S = "0110", N = 3 +Output: true +``` + +Example 2: + +```text +Input: S = "0110", N = 4 +Output: false +``` + +Note: + +- `1 <= S.length <= 1000` +- `1 <= N <= 10^9` diff --git a/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/binary-string-with-substrings-representing-1-to-n.go b/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/binary-string-with-substrings-representing-1-to-n.go new file mode 100755 index 000000000..be4db217c --- /dev/null +++ b/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/binary-string-with-substrings-representing-1-to-n.go @@ -0,0 +1,33 @@ +package problem1016 + +import "strings" + +func queryString(S string, N int) bool { + end := N >> 1 + for N >= end { + if !strings.Contains(S, binaryString(N)) { + return false + } + N-- + } + return true +} + +func binaryString(n int) string { + B := make([]byte, 0, 30) + for n > 0 { + B = append(B, byte(n&1)+'0') + n >>= 1 + } + swap(B) + return string(B) +} + +func swap(B []byte) { + i, j := 0, len(B)-1 + for i < j { + B[i], B[j] = B[j], B[i] + i++ + j-- + } +} diff --git a/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/binary-string-with-substrings-representing-1-to-n_test.go b/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/binary-string-with-substrings-representing-1-to-n_test.go new file mode 100755 index 000000000..bb5964ade --- /dev/null +++ b/Algorithms/1016.binary-string-with-substrings-representing-1-to-n/binary-string-with-substrings-representing-1-to-n_test.go @@ -0,0 +1,57 @@ +package problem1016 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + N int + ans bool +}{ + + { + "001111111000111011100110001001011100001101011001000100000001111100100001101100010010100111111100010101000000001010101011111001010111100000001110000001111000100001101010011010111101101000101101001110011000110110000110010111011100100101111000010011111001000001001000011011000111110010001010110101110011010000101001110000010111100001111011110000100000011000111111011101001011110111001110000011100100101001100001100111010010111111111000011110001110100010001000000101110000010100100111100010001111111110100001111000101001111110000011000001000001110011011011100010101010111110101110101110010111000110111110", + 30, + true, + }, + + { + "0110", + 3, + true, + }, + + { + "01010", + 4, + false, + }, + + { + "0110", + 4, + false, + }, + + // 可以有多个 testcase +} + +func Test_queryString(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, queryString(tc.S, tc.N), "输入:%v", tc) + } +} + +func Benchmark_queryString(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + queryString(tc.S, tc.N) + } + } +} diff --git a/Algorithms/1017.convert-to-base-2/README.md b/Algorithms/1017.convert-to-base-2/README.md new file mode 100755 index 000000000..9d7a8222c --- /dev/null +++ b/Algorithms/1017.convert-to-base-2/README.md @@ -0,0 +1,33 @@ +# [1017. Convert to Base -2](https://leetcode.com/problems/convert-to-base-2/) + +Given a number N, return a string consisting of "0"s and "1"s that represents its value in base -2 (negative two). + +The returned string must have no leading zeroes, unless the string is "0". + +Example 1: + +```text +Input: 2 +Output: "110" +Explanation: (-2) ^ 2 + (-2) ^ 1 = 2 +``` + +Example 2: + +```text +Input: 3 +Output: "111" +Explanation: (-2) ^ 2 + (-2) ^ 1 + (-2) ^ 0 = 3 +``` + +Example 3: + +```text +Input: 4 +Output: "100" +Explanation: (-2) ^ 2 = 4 +``` + +Note: + +- `0 <= N <= 10^9` diff --git a/Algorithms/1017.convert-to-base-2/convert-to-base-2.go b/Algorithms/1017.convert-to-base-2/convert-to-base-2.go new file mode 100755 index 000000000..a23fb11d0 --- /dev/null +++ b/Algorithms/1017.convert-to-base-2/convert-to-base-2.go @@ -0,0 +1,39 @@ +package problem1017 + +func baseNeg2(N int) string { + if N == 0 { + return "0" + } + + B := make([]byte, 0, 30) + for N > 0 { + switch N & 3 { + case 0, 1: + B = append(B, byte(N&1)+'0', '0') + default: // 2,3 + B = append(B, byte(N&1)+'0', '1') + N += 4 + // 2^(2n)-2^(2n-1) == 2^(2n-1) + // 所以,把 N 转换成二进制后,每在奇数位上看见 1 就在其左边的偶数位上加 1 + // 就可以转换成以 -2 为基的二进制了 + } + N >>= 2 + } + + swap(B) + + if B[0] == '0' { // no lead 0 except for N is 0 + B = B[1:] + } + + return string(B) +} + +func swap(B []byte) { + i, j := 0, len(B)-1 + for i < j { + B[i], B[j] = B[j], B[i] + i++ + j-- + } +} diff --git a/Algorithms/1017.convert-to-base-2/convert-to-base-2_test.go b/Algorithms/1017.convert-to-base-2/convert-to-base-2_test.go new file mode 100755 index 000000000..712dc1373 --- /dev/null +++ b/Algorithms/1017.convert-to-base-2/convert-to-base-2_test.go @@ -0,0 +1,57 @@ +package problem1017 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans string +}{ + + { + 0, + "0", + }, + + { + 6, + "11010", + }, + + { + 2, + "110", + }, + + { + 3, + "111", + }, + + { + 4, + "100", + }, + + // 可以有多个 testcase +} + +func Test_baseNeg2(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, baseNeg2(tc.N), "输入:%v", tc) + } +} + +func Benchmark_baseNeg2(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + baseNeg2(tc.N) + } + } +} diff --git a/Algorithms/1018.binary-prefix-divisible-by-5/README.md b/Algorithms/1018.binary-prefix-divisible-by-5/README.md new file mode 100755 index 000000000..4277120eb --- /dev/null +++ b/Algorithms/1018.binary-prefix-divisible-by-5/README.md @@ -0,0 +1,40 @@ +# [1018. Binary Prefix Divisible By 5](https://leetcode.com/problems/binary-prefix-divisible-by-5/) + +Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.) + +Return a list of booleans answer, where answer[i] is true if and only if N_i is divisible by 5. + +Example 1: + +```text +Input: [0,1,1] +Output: [true,false,false] +Explanation: +The input numbers in binary are 0, 01, 011; which are 0, 1, and 3 in base-10. Only the first number is divisible by 5, so answer[0] is true. +``` + +Example 2: + +```text +Input: [1,1,1] +Output: [false,false,false] +``` + +Example 3: + +```text +Input: [0,1,1,1,1,1] +Output: [true,false,false,false,true,false] +``` + +Example 4: + +```text +Input: [1,1,1,0,1] +Output: [false,false,false,false,false] +``` + +Note: + +- `1 <= A.length <= 30000` +- `A[i] is 0 or 1` diff --git a/Algorithms/1018.binary-prefix-divisible-by-5/binary-prefix-divisible-by-5.go b/Algorithms/1018.binary-prefix-divisible-by-5/binary-prefix-divisible-by-5.go new file mode 100755 index 000000000..aefb4e8b4 --- /dev/null +++ b/Algorithms/1018.binary-prefix-divisible-by-5/binary-prefix-divisible-by-5.go @@ -0,0 +1,11 @@ +package problem1018 + +func prefixesDivBy5(A []int) []bool { + res := make([]bool, len(A)) + r := 0 + for i, a := range A { + r = (r*2 + a) % 5 + res[i] = r == 0 + } + return res +} diff --git a/Algorithms/1018.binary-prefix-divisible-by-5/binary-prefix-divisible-by-5_test.go b/Algorithms/1018.binary-prefix-divisible-by-5/binary-prefix-divisible-by-5_test.go new file mode 100755 index 000000000..a2d8bd956 --- /dev/null +++ b/Algorithms/1018.binary-prefix-divisible-by-5/binary-prefix-divisible-by-5_test.go @@ -0,0 +1,57 @@ +package problem1018 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans []bool +}{ + + { + []int{1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0}, + []bool{false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, false, false, true, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, true, false, false, false, false, false, false, false, false, true, true, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, false, false, true, true, true, true, false, false, true, true, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, false, false, false, false, false, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, true, false, false, true, false, false, false, true, true, true, true, true, true, false, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, false, false, true, true, false, false, true, false, false, false, true, false, false, false, false, false, false, false, false, true, true, false, false, false, false, true, false, false, false, false, true, false, false, false, false, false, false, true, false, false, true, true, false, false, false, true, true, false, false, false, false, false, false, false, true, false, false, false, true, true, true, true, true, true, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, true, true, true, false, false, false, true, true, true, true, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, true, true, true, true, false, false, true, false, false, false, false, false, false, true, false, false, false, true, true, true, true, true, true, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, false, false, true, true, true, true, false, false, true, false, false, false, false, false, false, false, false, true, true, true, true, true, true, false, false, false, false, false, false, true, true, false, false, true, true, true, false, false, true, false, false, false, true, false, false, true, true, true, false, false, false, false, true, true, false, false, true, true, false, false, false, false, false, false, true, false, false, false, false, false, false, false}, + }, + + { + []int{0, 1, 1}, + []bool{true, false, false}, + }, + + { + []int{1, 1, 1}, + []bool{false, false, false}, + }, + + { + []int{0, 1, 1, 1, 1, 1}, + []bool{true, false, false, false, true, false}, + }, + + { + []int{1, 1, 1, 0, 1}, + []bool{false, false, false, false, false}, + }, + + // 可以有多个 testcase +} + +func Test_prefixesDivBy5(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, prefixesDivBy5(tc.A), "输入:%v", tc) + } +} + +func Benchmark_prefixesDivBy5(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + prefixesDivBy5(tc.A) + } + } +} diff --git a/Algorithms/1019.next-greater-node-in-linked-list/README.md b/Algorithms/1019.next-greater-node-in-linked-list/README.md new file mode 100755 index 000000000..b4f82657c --- /dev/null +++ b/Algorithms/1019.next-greater-node-in-linked-list/README.md @@ -0,0 +1,35 @@ +# [1019. Next Greater Node In Linked List](https://leetcode.com/problems/next-greater-node-in-linked-list/) + +We are given a linked list with head as the first node. Let's number the nodes in the list: node_1, node_2, node_3, ... etc. + +Each node may have a next larger value: for node_i, next_larger(node_i) is the node_j.val such that j > i, node_j.val > node_i.val, and j is the smallest possible choice. If such a j does not exist, the next larger value is 0. + +Return an array of integers answer, where answer[i] = next_larger(node_{i+1}). + +Note that in the example inputs (not outputs) below, arrays such as [2,1,5] represent the serialization of a linked list with a head node value of 2, second node value of 1, and third node value of 5. + +Example 1: + +```text +Input: [2,1,5] +Output: [5,5,0] +``` + +Example 2: + +```text +Input: [2,7,4,3,5] +Output: [7,0,5,5,0] +``` + +Example 3: + +```text +Input: [1,7,5,1,9,2,5,1] +Output: [7,9,9,9,0,5,0,0] +``` + +Note: + +- 1 <= node.val <= 10^9 for each node in the linked list. +- The given list has length in the range [0, 10000]. diff --git a/Algorithms/1019.next-greater-node-in-linked-list/next-greater-node-in-linked-list.go b/Algorithms/1019.next-greater-node-in-linked-list/next-greater-node-in-linked-list.go new file mode 100755 index 000000000..cdb166f8f --- /dev/null +++ b/Algorithms/1019.next-greater-node-in-linked-list/next-greater-node-in-linked-list.go @@ -0,0 +1,30 @@ +package problem1019 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// ListNode is pre-defined... +type ListNode = kit.ListNode + +func nextLargerNodes(head *ListNode) []int { + A := convert(head) + res := make([]int, len(A)) + stack, peek := make([]int, len(A)), -1 + for i := 0; i < len(A); i++ { + for peek >= 0 && A[stack[peek]] < A[i] { + res[stack[peek]] = A[i] + peek-- + } + peek++ + stack[peek] = i + } + return res +} + +func convert(head *ListNode) []int { + res := make([]int, 0, 1024) + for head != nil { + res = append(res, head.Val) + head = head.Next + } + return res +} diff --git a/Algorithms/1019.next-greater-node-in-linked-list/next-greater-node-in-linked-list_test.go b/Algorithms/1019.next-greater-node-in-linked-list/next-greater-node-in-linked-list_test.go new file mode 100755 index 000000000..aeab2d73e --- /dev/null +++ b/Algorithms/1019.next-greater-node-in-linked-list/next-greater-node-in-linked-list_test.go @@ -0,0 +1,56 @@ +package problem1019 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + head []int + ans []int +}{ + + { + []int{225, 172, 286, 36, 70, 170, 19, 187, 206, 132, 239, 79, 58, 236, 117, 139, 278, 222, 257, 168, 152, 121, 205, 103, 130, 209, 220, 90, 263, 171, 116, 297, 165, 20, 246, 225, 205, 9, 103, 220, 14, 166, 269, 135, 214, 11, 297, 268, 214, 227, 256, 157, 106, 153, 261, 156, 165, 242, 297, 235, 297, 219, 215, 127, 258, 230, 47, 231, 7, 183, 150, 140, 288, 47, 269, 252, 41, 115, 13, 119, 273, 199, 149, 142, 175, 172, 107, 255, 53, 23, 270, 226, 146, 159, 170, 105, 5, 106, 238, 50, 210, 175, 258, 269, 272, 283, 1, 154, 269, 9, 81, 176, 252, 82, 272, 143, 66, 161, 238, 88, 251, 179, 8, 125, 37, 271, 22, 269, 268, 29, 50, 159, 151, 203, 127, 297, 275, 29, 299, 135, 219, 118, 94, 106, 89, 279, 178, 49, 159, 270, 263, 7, 85, 122, 249, 181, 276, 68, 56, 209, 128, 151, 218, 30, 70, 53, 11, 145, 153, 88, 51, 128, 101, 152, 102, 40, 115, 161, 177, 58, 276, 179, 242, 208, 269, 241, 4, 38, 217, 237, 4, 200, 189, 40, 8, 183, 196, 49, 57, 63, 157, 59, 203, 35, 269, 28, 231, 88, 272, 234, 128, 198, 122, 201, 289, 236, 1, 148, 21, 253, 111, 178, 279, 69, 122, 49, 2, 137, 221, 187, 290, 288, 296, 158, 250, 295, 44, 245, 66, 72, 129, 23, 34, 125, 288, 59, 26, 25, 135, 181, 171, 49, 80, 161, 193, 249, 284, 89, 125, 130, 81, 43, 15, 156, 228, 124, 62, 24, 83, 11, 117, 78, 146, 54, 95, 153, 189, 264, 282, 139, 82, 122, 49, 137, 88, 278, 56, 117, 105, 300, 14, 87, 243, 27, 113, 65, 30, 161, 91, 175}, + []int{286, 286, 297, 70, 170, 187, 187, 206, 239, 239, 278, 236, 236, 278, 139, 278, 297, 257, 263, 205, 205, 205, 209, 130, 209, 220, 263, 263, 297, 297, 297, 299, 246, 246, 269, 269, 220, 103, 220, 269, 166, 269, 297, 214, 297, 297, 299, 297, 227, 256, 261, 261, 153, 261, 297, 165, 242, 297, 299, 297, 299, 258, 258, 258, 288, 231, 231, 288, 183, 288, 288, 288, 297, 269, 273, 273, 115, 119, 119, 273, 283, 255, 175, 175, 255, 255, 255, 270, 270, 270, 272, 238, 159, 170, 238, 106, 106, 238, 258, 210, 258, 258, 269, 272, 283, 297, 154, 269, 272, 81, 176, 252, 272, 272, 297, 161, 161, 238, 251, 251, 271, 271, 125, 271, 271, 297, 269, 297, 297, 50, 159, 203, 203, 297, 297, 299, 299, 299, 300, 219, 279, 279, 106, 279, 279, 289, 270, 159, 270, 276, 276, 85, 122, 249, 276, 276, 289, 209, 209, 218, 151, 218, 276, 70, 145, 145, 145, 153, 161, 128, 128, 152, 152, 161, 115, 115, 161, 177, 276, 276, 289, 242, 269, 269, 272, 269, 38, 217, 237, 269, 200, 203, 196, 183, 183, 196, 203, 57, 63, 157, 203, 203, 269, 269, 272, 231, 272, 272, 289, 289, 198, 201, 201, 289, 290, 253, 148, 253, 253, 279, 178, 279, 290, 122, 137, 137, 137, 221, 290, 290, 296, 296, 300, 250, 295, 300, 245, 288, 72, 129, 288, 34, 125, 288, 300, 135, 135, 135, 181, 193, 193, 80, 161, 193, 249, 284, 300, 125, 130, 156, 156, 156, 156, 228, 264, 146, 83, 83, 117, 117, 146, 146, 153, 95, 153, 189, 264, 282, 300, 278, 122, 137, 137, 278, 278, 300, 117, 300, 300, 0, 87, 243, 0, 113, 161, 161, 161, 175, 175, 0}, + }, + + { + []int{2, 1, 5}, + []int{5, 5, 0}, + }, + + { + []int{2, 7, 4, 3, 5}, + []int{7, 0, 5, 5, 0}, + }, + + { + []int{1, 7, 5, 1, 9, 2, 5, 1}, + []int{7, 9, 9, 9, 0, 5, 0, 0}, + }, + + // 可以有多个 testcase +} + +func Test_nextLargerNodes(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + head := kit.Ints2List(tc.head) + ast.Equal(tc.ans, nextLargerNodes(head), "输入:%v", tc) + } +} + +func Benchmark_nextLargerNodes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + head := kit.Ints2List(tc.head) + nextLargerNodes(head) + } + } +} diff --git a/Algorithms/1020.number-of-enclaves/README.md b/Algorithms/1020.number-of-enclaves/README.md new file mode 100755 index 000000000..be6c21183 --- /dev/null +++ b/Algorithms/1020.number-of-enclaves/README.md @@ -0,0 +1,32 @@ +# [1020. Number of Enclaves](https://leetcode.com/problems/number-of-enclaves/) + +Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land) + +A move consists of walking from one land square 4-directionally to another land square, or off the boundary of the grid. + +Return the number of land squares in the grid for which we cannot walk off the boundary of the grid in any number of moves. + +Example 1: + +```text +Input: [[0,0,0,0],[1,0,1,0],[0,1,1,0],[0,0,0,0]] +Output: 3 +Explanation: +There are three 1s that are enclosed by 0s, and one 1 that isn't enclosed because its on the boundary. +``` + +Example 2: + +```text +Input: [[0,1,1,0],[0,0,1,0],[0,0,1,0],[0,0,0,0]] +Output: 0 +Explanation: +All 1s are either on the boundary or can reach the boundary. +``` + +Note: + +- 1 <= A.length <= 500 +- 1 <= A[i].length <= 500 +- 0 <= A[i][j] <= 1 +- All rows have the same size. diff --git a/Algorithms/1020.number-of-enclaves/number-of-enclaves.go b/Algorithms/1020.number-of-enclaves/number-of-enclaves.go new file mode 100755 index 000000000..360588a7c --- /dev/null +++ b/Algorithms/1020.number-of-enclaves/number-of-enclaves.go @@ -0,0 +1,44 @@ +package problem1020 + +var dx = [4]int{-1, 1, 0, 0} +var dy = [4]int{0, 0, -1, 1} + +func numEnclaves(A [][]int) int { + m, n := len(A), len(A[0]) + + var dfs func(int, int) + dfs = func(x, y int) { + if x < 0 || m <= x || + y < 0 || n <= y || + A[x][y] == 0 { + return + } + A[x][y] = 0 + for i := 0; i < 4; i++ { + dfs(x+dx[i], y+dy[i]) + } + } + + line := func(i, di, j, dj int) { + for i < m && j < n { + dfs(i, j) + i += di + j += dj + } + } + + // search from the boundary + line(0, 0, 0, 1) // top + line(m-1, 0, 0, 1) // down + line(0, 1, 0, 0) // left + line(0, 1, n-1, 0) // right + + res := 0 + for i := 0; i < m; i++ { + for j := 0; j < n; j++ { + res += A[i][j] + } + } + + return res +} diff --git a/Algorithms/1020.number-of-enclaves/number-of-enclaves_test.go b/Algorithms/1020.number-of-enclaves/number-of-enclaves_test.go new file mode 100755 index 000000000..572f80e79 --- /dev/null +++ b/Algorithms/1020.number-of-enclaves/number-of-enclaves_test.go @@ -0,0 +1,42 @@ +package problem1020 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A [][]int + ans int +}{ + + { + [][]int{{0, 0, 0, 0}, {1, 0, 1, 0}, {0, 1, 1, 0}, {0, 0, 0, 0}}, + 3, + }, + + { + [][]int{{0, 1, 1, 0}, {0, 0, 1, 0}, {0, 0, 1, 0}, {0, 0, 0, 0}}, + 0, + }, + + // 可以有多个 testcase +} + +func Test_numEnclaves(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numEnclaves(tc.A), "输入:%v", tc) + } +} + +func Benchmark_numEnclaves(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numEnclaves(tc.A) + } + } +} diff --git a/Algorithms/1021.remove-outermost-parentheses/README.md b/Algorithms/1021.remove-outermost-parentheses/README.md new file mode 100755 index 000000000..835ba4e8e --- /dev/null +++ b/Algorithms/1021.remove-outermost-parentheses/README.md @@ -0,0 +1,45 @@ +# [1021. Remove Outermost Parentheses](https://leetcode.com/problems/remove-outermost-parentheses/) + +A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings. + +A valid parentheses string S is primitive if it is nonempty, and there does not exist a way to split it into S = A+B, with A and B nonempty valid parentheses strings. + +Given a valid parentheses string S, consider its primitive decomposition: S = P_1 + P_2 + ... + P_k, where P_i are primitive valid parentheses strings. + +Return S after removing the outermost parentheses of every primitive string in the primitive decomposition of S. + +Example 1: + +```text +Input: "(()())(())" +Output: "()()()" +Explanation: +The input string is "(()())(())", with primitive decomposition "(()())" + "(())". +After removing outer parentheses of each part, this is "()()" + "()" = "()()()". +``` + +Example 2: + +```text +Input: "(()())(())(()(()))" +Output: "()()()()(())" +Explanation: +The input string is "(()())(())(()(()))", with primitive decomposition "(()())" + "(())" + "(()(()))". +After removing outer parentheses of each part, this is "()()" + "()" + "()(())" = "()()()()(())". +``` + +Example 3: + +```text +Input: "()()" +Output: "" +Explanation: +The input string is "()()", with primitive decomposition "()" + "()". +After removing outer parentheses of each part, this is "" + "" = "". +``` + +Note: + +- S.length <= 10000 +- S[i] is "(" or ")" +- S is a valid parentheses string \ No newline at end of file diff --git a/Algorithms/1021.remove-outermost-parentheses/remove-outermost-parentheses.go b/Algorithms/1021.remove-outermost-parentheses/remove-outermost-parentheses.go new file mode 100755 index 000000000..62138882d --- /dev/null +++ b/Algorithms/1021.remove-outermost-parentheses/remove-outermost-parentheses.go @@ -0,0 +1,20 @@ +package problem1021 + +import "strings" + +func removeOuterParentheses(S string) string { + var sb strings.Builder + i, count, size := 0, 0, len(S) + for j := 0; j < size; j++ { + if S[j] == '(' { + count++ + continue + } + count-- + if count == 0 { // S[i] and S[j] are outer parentheses + sb.WriteString(S[i+1 : j]) + i = j + 1 + } + } + return sb.String() +} diff --git a/Algorithms/1021.remove-outermost-parentheses/remove-outermost-parentheses_test.go b/Algorithms/1021.remove-outermost-parentheses/remove-outermost-parentheses_test.go new file mode 100755 index 000000000..ecda02191 --- /dev/null +++ b/Algorithms/1021.remove-outermost-parentheses/remove-outermost-parentheses_test.go @@ -0,0 +1,52 @@ +package problem1021 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans string +}{ + + { + "((())())(())()((()))()()()()()((()())())()()(((()())))()(()())()(())()()()((()()(())))(((()())))()()()()()()()(())()(())(()())()((()))()()(())()(())()()()(())()()()()()()()()()()()()()(())()(((())))(())()(()(()))()()()((()()))()((()))()()()()()()()()()()()(())()()()(())()(())(())()()(())()()()()()()()()()()()()()()()()()()(()())()()(())(()())()()()()()()()((()))()()()(())(())()()()()(())((())())(())(())(()()())((()))()()()(())()()()()(())(())()((()))()((()))()((((())(())))())()(())()()()()((())())((())((()()()()())))()()()()(()())()()(()(()))()()()()()()(()(()(())((()))(())))(())(((()))(((()()()))))()(()()()())()((()()(())))()()()()(())()()()(())()()(((())))(())()(())()()()()()()()()()()()()()(())((((((()()))(())())())))()()(())()()()()()()()()((()))()()(())()()()(()())()()()()(())(())()()()()()()()()()()()((()((((()))()))))((()))(())()(()())(())(((()())())())(())(((())))()()()()()()()()()((((()((()))))())())()()()((()()(()()))((()()))()(()()))()(())(((())))()()()()((()()))(())(())()()", + "(())()()(())(()())()((()()))()()()(()()(()))((()()))()()()()(())()()()()((()))()()(())(()())(())()()()()()()()()()()(())()()()(())()()()()()()(())()()()(())(())(((())(())))()()(())()(())((()()()()()))()()()(())()(()(())((()))(()))()((()))(((()()())))()()()()(()()(()))()()((()))()()()(((((()()))(())())()))()(())()()()()()(()((((()))())))(())()()()()((()())())()()((()))(((()((()))))())()(()()(()()))((()()))()(()())()((()))(()())()()", + }, + + { + "(()())(())", + "()()()", + }, + + { + "(()())(())(()(()))", + "()()()()(())", + }, + + { + "()()", + "", + }, + + // 可以有多个 testcase +} + +func Test_removeOuterParentheses(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, removeOuterParentheses(tc.S), "输入:%v", tc) + } +} + +func Benchmark_removeOuterParentheses(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + removeOuterParentheses(tc.S) + } + } +} diff --git a/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/1.png b/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/1.png new file mode 100644 index 000000000..eb175e7c6 Binary files /dev/null and b/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/1.png differ diff --git a/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/README.md b/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/README.md new file mode 100755 index 000000000..d05d018f3 --- /dev/null +++ b/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/README.md @@ -0,0 +1,23 @@ +# [1022. Sum of Root To Leaf Binary Numbers](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/) + +Given a binary tree, each node has value 0 or 1. Each root-to-leaf path represents a binary number starting with the most significant bit. For example, if the path is 0 -> 1 -> 1 -> 0 -> 1, then this could represent 01101 in binary, which is 13. + +For all leaves in the tree, consider the numbers represented by the path from the root to that leaf. + +Return the sum of these numbers. + +Example 1: + +![1](1.png) + +```text +Input: [1,0,1,0,1,0,1] +Output: 22 +Explanation: (100) + (101) + (110) + (111) = 4 + 5 + 6 + 7 = 22 +``` + +Note: + +1. The number of nodes in the tree is between 1 and 1000. +1. node.val is 0 or 1. +1. The answer will not exceed 2^31 - 1. diff --git a/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/sum-of-root-to-leaf-binary-numbers.go b/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/sum-of-root-to-leaf-binary-numbers.go new file mode 100755 index 000000000..f6cf066aa --- /dev/null +++ b/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/sum-of-root-to-leaf-binary-numbers.go @@ -0,0 +1,26 @@ +package problem1022 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func sumRootToLeaf(root *TreeNode) int { + return dfs(root, 0) +} + +func dfs(node *TreeNode, b int) int { + if node == nil { + return 0 + } + b = b*2 + node.Val + if node.Left == node.Right { // both nil + return b + } + return dfs(node.Left, b) + dfs(node.Right, b) +} diff --git a/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/sum-of-root-to-leaf-binary-numbers_test.go b/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/sum-of-root-to-leaf-binary-numbers_test.go new file mode 100755 index 000000000..f0ff2d1ee --- /dev/null +++ b/Algorithms/1022.sum-of-root-to-leaf-binary-numbers/sum-of-root-to-leaf-binary-numbers_test.go @@ -0,0 +1,51 @@ +package problem1022 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans int +}{ + + { + []int{1, kit.NULL, 0}, + 2, + }, + + { + []int{1, 1}, + 3, + }, + + { + []int{1, 0, 1, 0, 1, 0, 1}, + 22, + }, + + // 可以有多个 testcase +} + +func Test_sumRootToLeaf(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, sumRootToLeaf(root), "输入:%v", tc) + } +} + +func Benchmark_sumRootToLeaf(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + sumRootToLeaf(root) + } + } +} diff --git a/Algorithms/1023.camelcase-matching/README.md b/Algorithms/1023.camelcase-matching/README.md new file mode 100755 index 000000000..7bc5fe089 --- /dev/null +++ b/Algorithms/1023.camelcase-matching/README.md @@ -0,0 +1,42 @@ +# [1023. Camelcase Matching](https://leetcode.com/problems/camelcase-matching/) + +A query word matches a given pattern if we can insert lowercase letters to the pattern word so that it equals the query. (We may insert each character at any position, and may insert 0 characters.) + +Given a list of queries, and a pattern, return an answer list of booleans, where answer[i] is true if and only if queries[i] matches the pattern. + +Example 1: + +```text +Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FB" +Output: [true,false,true,true,false] +Explanation: +"FooBar" can be generated like this "F" + "oo" + "B" + "ar". +"FootBall" can be generated like this "F" + "oot" + "B" + "all". +"FrameBuffer" can be generated like this "F" + "rame" + "B" + "uffer". +``` + +Example 2: + +```text +Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBa" +Output: [true,false,true,false,false] +Explanation: +"FooBar" can be generated like this "Fo" + "o" + "Ba" + "r". +"FootBall" can be generated like this "Fo" + "ot" + "Ba" + "ll". +``` + +Example 3: + +```text +Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBaT" +Output: [false,true,false,false,false] +Explanation: +"FooBarTest" can be generated like this "Fo" + "o" + "Ba" + "r" + "T" + "est". +``` + +Note: + +- 1 <= queries.length <= 100 +- 1 <= queries[i].length <= 100 +- 1 <= pattern.length <= 100 +- All strings consists only of lower and upper case English letters. diff --git a/Algorithms/1023.camelcase-matching/camelcase-matching.go b/Algorithms/1023.camelcase-matching/camelcase-matching.go new file mode 100755 index 000000000..93557de1b --- /dev/null +++ b/Algorithms/1023.camelcase-matching/camelcase-matching.go @@ -0,0 +1,25 @@ +package problem1023 + +func camelMatch(queries []string, pattern string) []bool { + pr, pn := []rune(pattern), len(pattern) + + check := func(q string) bool { + pi := 0 + for _, r := range q { + if pi < pn && pr[pi] == r { + pi++ + continue + } + if 'A' <= r && r <= 'Z' { + return false + } + } + return pi == pn + } + + res := make([]bool, len(queries)) + for i, q := range queries { + res[i] = check(q) + } + return res +} diff --git a/Algorithms/1023.camelcase-matching/camelcase-matching_test.go b/Algorithms/1023.camelcase-matching/camelcase-matching_test.go new file mode 100755 index 000000000..718afe7f3 --- /dev/null +++ b/Algorithms/1023.camelcase-matching/camelcase-matching_test.go @@ -0,0 +1,63 @@ +package problem1023 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + queries []string + pattern string + ans []bool +}{ + + { + []string{"IXfGawluvnCa", "IsXfGaxwulCa", "IXfGawlqtCva", "IXjfGawlmeCa", "IXfGnaynwlCa", "IXfGcamwelCa"}, + "IXfGawlCa", + []bool{true, true, true, true, true, true}, + }, + + { + []string{"CompetitiveProgramming", "CounterPick", "ControlPanel"}, + "CooP", + []bool{false, false, true}, + }, + + { + []string{"FooBar", "FooBarTest", "FootBall", "FrameBuffer", "ForceFeedBack"}, + "FoBaT", + []bool{false, true, false, false, false}, + }, + + { + []string{"FooBar", "FooBarTest", "FootBall", "FrameBuffer", "ForceFeedBack"}, + "FB", + []bool{true, false, true, true, false}, + }, + + { + []string{"FooBar", "FooBarTest", "FootBall", "FrameBuffer", "ForceFeedBack"}, + "FoBa", + []bool{true, false, true, false, false}, + }, + + // 可以有多个 testcase +} + +func Test_camelMatch(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, camelMatch(tc.queries, tc.pattern), "输入:%v", tc) + } +} + +func Benchmark_camelMatch(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + camelMatch(tc.queries, tc.pattern) + } + } +} diff --git a/Algorithms/1024.video-stitching/README.md b/Algorithms/1024.video-stitching/README.md new file mode 100755 index 000000000..b94b86865 --- /dev/null +++ b/Algorithms/1024.video-stitching/README.md @@ -0,0 +1,52 @@ +# [1024. Video Stitching](https://leetcode.com/problems/video-stitching/) + +You are given a series of video clips from a sporting event that lasted T seconds. These video clips can be overlapping with each other and have varied lengths. + +Each video clip clips[i] is an interval: it starts at time clips[i][0] and ends at time clips[i][1]. We can cut these clips into segments freely: for example, a clip [0, 7] can be cut into segments [0, 1] + [1, 3] + [3, 7]. + +Return the minimum number of clips needed so that we can cut the clips into segments that cover the entire sporting event ([0, T]). If the task is impossible, return -1. + +Example 1: + +```text +Input: clips = [[0,2],[4,6],[8,10],[1,9],[1,5],[5,9]], T = 10 +Output: 3 +Explanation: +We take the clips [0,2], [8,10], [1,9]; a total of 3 clips. +Then, we can reconstruct the sporting event as follows: +We cut [1,9] into segments [1,2] + [2,8] + [8,9]. +Now we have segments [0,2] + [2,8] + [8,10] which cover the sporting event [0, 10]. +``` + +Example 2: + +```text +Input: clips = [[0,1],[1,2]], T = 5 +Output: -1 +Explanation: +We can't cover [0,5] with only [0,1] and [0,2]. +``` + +Example 3: + +```text +Input: clips = [[0,1],[6,8],[0,2],[5,6],[0,4],[0,3],[6,7],[1,3],[4,7],[1,4],[2,5],[2,6],[3,4],[4,5],[5,7],[6,9]], T = 9 +Output: 3 +Explanation: +We can take clips [0,4], [4,7], and [6,9]. +``` + +Example 4: + +```text +Input: clips = [[0,4],[2,8]], T = 5 +Output: 2 +Explanation: +Notice you can have extra video after the event ends. +``` + +Note: + +- `1 <= clips.length <= 100` +- `0 <= clips[i][0], clips[i][1] <= 100` +- `0 <= T <= 100` diff --git a/Algorithms/1024.video-stitching/video-stitching.go b/Algorithms/1024.video-stitching/video-stitching.go new file mode 100755 index 000000000..2c1da3f0f --- /dev/null +++ b/Algorithms/1024.video-stitching/video-stitching.go @@ -0,0 +1,31 @@ +package problem1024 + +import "sort" + +func videoStitching(clips [][]int, T int) int { + sort.Slice(clips, func(i int, j int) bool { + return clips[i][0] < clips[j][0] + }) + + res := 0 + + for i, start, end := 0, 0, 0; start < T; start = end { + for i < len(clips) && clips[i][0] <= start { + end = max(end, clips[i][1]) + i++ + } + if start == end { + return -1 + } + res++ + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1024.video-stitching/video-stitching_test.go b/Algorithms/1024.video-stitching/video-stitching_test.go new file mode 100755 index 000000000..f3f130089 --- /dev/null +++ b/Algorithms/1024.video-stitching/video-stitching_test.go @@ -0,0 +1,69 @@ +package problem1024 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + clips [][]int + T int + ans int +}{ + + { + [][]int{{5, 7}, {1, 8}, {0, 0}, {2, 3}, {4, 5}, {0, 6}, {5, 10}, {7, 10}}, + 5, + 1, + }, + + { + [][]int{{0, 2}, {4, 6}, {8, 10}, {1, 9}, {1, 5}, {5, 9}}, + 10, + 3, + }, + + { + [][]int{{1, 1}, {1, 2}}, + 5, + -1, + }, + + { + [][]int{{0, 1}, {1, 2}}, + 5, + -1, + }, + + { + [][]int{{0, 1}, {6, 8}, {0, 2}, {5, 6}, {0, 4}, {0, 3}, {6, 7}, {1, 3}, {4, 7}, {1, 4}, {2, 5}, {2, 6}, {3, 4}, {4, 5}, {5, 7}, {6, 9}}, + 9, + 3, + }, + + { + [][]int{{0, 4}, {2, 8}}, + 5, + 2, + }, + + // 可以有多个 testcase +} + +func Test_videoStitching(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, videoStitching(tc.clips, tc.T), "输入:%v", tc) + } +} + +func Benchmark_videoStitching(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + videoStitching(tc.clips, tc.T) + } + } +} diff --git a/Algorithms/1025.divisor-game/README.md b/Algorithms/1025.divisor-game/README.md new file mode 100755 index 000000000..d314bfab9 --- /dev/null +++ b/Algorithms/1025.divisor-game/README.md @@ -0,0 +1,32 @@ +# [1025. Divisor Game](https://leetcode.com/problems/divisor-game/) + +Alice and Bob take turns playing a game, with Alice starting first. + +Initially, there is a number N on the chalkboard. On each player's turn, that player makes a move consisting of: + +- Choosing any x with 0 < x < N and N % x == 0. +- Replacing the number N on the chalkboard with N - x. + +Also, if a player cannot make a move, they lose the game. + +Return True if and only if Alice wins the game, assuming both players play optimally. + +Example 1: + +```text +Input: 2 +Output: true +Explanation: Alice chooses 1, and Bob has no more moves. +``` + +Example 2: + +```text +Input: 3 +Output: false +Explanation: Alice chooses 1, Bob chooses 1, and Alice has no more moves. +``` + +Note: + +1. `1 <= N <= 1000` diff --git a/Algorithms/1025.divisor-game/divisor-game.go b/Algorithms/1025.divisor-game/divisor-game.go new file mode 100755 index 000000000..cec01691b --- /dev/null +++ b/Algorithms/1025.divisor-game/divisor-game.go @@ -0,0 +1,7 @@ +package problem1025 + +func divisorGame(N int) bool { + return N%2 == 0 +} + +// proof: https://leetcode.com/problems/divisor-game/discuss/274606/JavaC%2B%2BPython-return-N-2-0 diff --git a/Algorithms/1025.divisor-game/divisor-game_test.go b/Algorithms/1025.divisor-game/divisor-game_test.go new file mode 100755 index 000000000..3c65a3b01 --- /dev/null +++ b/Algorithms/1025.divisor-game/divisor-game_test.go @@ -0,0 +1,47 @@ +package problem1025 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + ans bool +}{ + + { + 1000, + true, + }, + + { + 2, + true, + }, + + { + 3, + false, + }, + + // 可以有多个 testcase +} + +func Test_divisorGame(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, divisorGame(tc.N), "输入:%v", tc) + } +} + +func Benchmark_divisorGame(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + divisorGame(tc.N) + } + } +} diff --git a/Algorithms/1026.maximum-difference-between-node-and-ancestor/1.jpg b/Algorithms/1026.maximum-difference-between-node-and-ancestor/1.jpg new file mode 100644 index 000000000..d69738990 Binary files /dev/null and b/Algorithms/1026.maximum-difference-between-node-and-ancestor/1.jpg differ diff --git a/Algorithms/1026.maximum-difference-between-node-and-ancestor/README.md b/Algorithms/1026.maximum-difference-between-node-and-ancestor/README.md new file mode 100755 index 000000000..ab5c21e3a --- /dev/null +++ b/Algorithms/1026.maximum-difference-between-node-and-ancestor/README.md @@ -0,0 +1,26 @@ +# [1026. Maximum Difference Between Node and Ancestor](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor/) + +Given the root of a binary tree, find the maximum value V for which there exists different nodes A and B where V = |A.val - B.val| and A is an ancestor of B. + +(A node A is an ancestor of B if either: any child of A is equal to B, or any child of A is an ancestor of B.) + +Example 1: + +![1](1.jpg) + +```text +Input: [8,3,10,1,6,null,14,null,null,4,7,13] +Output: 7 +Explanation: +We have various ancestor-node differences, some of which are given below : +|8 - 3| = 5 +|3 - 7| = 4 +|8 - 1| = 7 +|10 - 13| = 3 +Among all possible differences, the maximum value of 7 is obtained by |8 - 1| = 7. +``` + +Note: + +- The number of nodes in the tree is between 2 and 5000. +- Each node will have value between 0 and 100000. diff --git a/Algorithms/1026.maximum-difference-between-node-and-ancestor/maximum-difference-between-node-and-ancestor.go b/Algorithms/1026.maximum-difference-between-node-and-ancestor/maximum-difference-between-node-and-ancestor.go new file mode 100755 index 000000000..86c5e982e --- /dev/null +++ b/Algorithms/1026.maximum-difference-between-node-and-ancestor/maximum-difference-between-node-and-ancestor.go @@ -0,0 +1,38 @@ +package problem1026 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +func maxAncestorDiff(root *TreeNode) int { + return dfs(root, root.Val, root.Val) +} + +func dfs(node *TreeNode, Max, Min int) int { + if node == nil { + return Max - Min + // Max 和 Min 都是 node 的父节点的值 + // 所以 + // Max 和 Min 所在的两个节点,肯定是父子关系 + } + + Max = max(Max, node.Val) + Min = min(Min, node.Val) + + return max(dfs(node.Left, Max, Min), dfs(node.Right, Max, Min)) +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1026.maximum-difference-between-node-and-ancestor/maximum-difference-between-node-and-ancestor_test.go b/Algorithms/1026.maximum-difference-between-node-and-ancestor/maximum-difference-between-node-and-ancestor_test.go new file mode 100755 index 000000000..2823fbdb5 --- /dev/null +++ b/Algorithms/1026.maximum-difference-between-node-and-ancestor/maximum-difference-between-node-and-ancestor_test.go @@ -0,0 +1,46 @@ +package problem1026 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans int +}{ + + { + []int{7, 5, 12, 11, 0, 2, kit.NULL, 4, 17, 6, 19, kit.NULL, 16, 18, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 9, 14, 10, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, kit.NULL, 3, 1, kit.NULL, kit.NULL, 8, kit.NULL, 13, kit.NULL, kit.NULL, 15}, + 19, + }, + + { + []int{8, 3, 10, 1, 6, kit.NULL, 14, kit.NULL, kit.NULL, 4, 7, 13}, + 7, + }, + + // 可以有多个 testcase +} + +func Test_maxAncestorDiff(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, maxAncestorDiff(root), "输入:%v", tc) + } +} + +func Benchmark_maxAncestorDiff(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + maxAncestorDiff(root) + } + } +} diff --git a/Algorithms/1027.longest-arithmetic-sequence/README.md b/Algorithms/1027.longest-arithmetic-sequence/README.md new file mode 100755 index 000000000..b4bcf91c0 --- /dev/null +++ b/Algorithms/1027.longest-arithmetic-sequence/README.md @@ -0,0 +1,37 @@ +# [1027. Longest Arithmetic Sequence](https://leetcode.com/problems/longest-arithmetic-sequence/) + +Given an array A of integers, return the length of the longest arithmetic subsequence in A. + +Recall that a subsequence of A is a list A[i_1], A[i_2], ..., A[i_k] with 0 <= i_1 < i_2 < ... < i_k <= A.length - 1, and that a sequence B is arithmetic if B[i+1] - B[i] are all the same value (for 0 <= i < B.length - 1). + +Example 1: + +```text +Input: [3,6,9,12] +Output: 4 +Explanation: +The whole array is an arithmetic sequence with steps of length = 3. +``` + +Example 2: + +```text +Input: [9,4,7,2,10] +Output: 3 +Explanation: +The longest arithmetic subsequence is [4,7,10]. +``` + +Example 3: + +```text +Input: [20,1,15,3,10,5,8] +Output: 4 +Explanation: +The longest arithmetic subsequence is [20,15,10,5]. +``` + +Note: + +- `2 <= A.length <= 2000` +- `0 <= A[i] <= 10000` diff --git a/Algorithms/1027.longest-arithmetic-sequence/longest-arithmetic-sequence.go b/Algorithms/1027.longest-arithmetic-sequence/longest-arithmetic-sequence.go new file mode 100755 index 000000000..36fde551a --- /dev/null +++ b/Algorithms/1027.longest-arithmetic-sequence/longest-arithmetic-sequence.go @@ -0,0 +1,41 @@ +package problem1027 + +func longestArithSeqLength(A []int) int { + n := len(A) + + indexes := [10001][]int{} + for i := 0; i < n; i++ { + indexes[A[i]] = append(indexes[A[i]], i) + } + + var dfs func(int, int) int + dfs = func(j, diff int) int { + next := A[j] + diff + if next < 0 || 10000 < next { + return 0 + } + for _, k := range indexes[next] { + if j < k { + return 1 + dfs(k, diff) + } + } + return 0 + } + + res := 0 + for i := 0; i < n; i++ { + for j := i + 1; j < n; j++ { + diff := A[j] - A[i] + res = max(res, 2+dfs(j, diff)) + } + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1027.longest-arithmetic-sequence/longest-arithmetic-sequence_test.go b/Algorithms/1027.longest-arithmetic-sequence/longest-arithmetic-sequence_test.go new file mode 100755 index 000000000..84aab525c --- /dev/null +++ b/Algorithms/1027.longest-arithmetic-sequence/longest-arithmetic-sequence_test.go @@ -0,0 +1,57 @@ +package problem1027 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{9335, 8938, 9465, 1282, 4326, 2363, 290, 9711, 446, 7258, 9783, 8421, 172, 7241, 1736, 211, 1622, 2138, 9260, 8686, 3616, 669, 1588, 4763, 1746, 4735, 4091, 1926, 3895, 7134, 442, 8185, 3356, 4135, 1970, 7322, 8713, 2544, 33, 1356, 1623, 9852, 604, 3639, 6767, 7278, 2518, 1877, 9942, 3709, 8241, 4124, 7358, 5395, 951, 7447, 5246, 9616, 378, 3366, 2585, 1630, 6172, 1952, 9457, 883, 5240, 9981, 6892, 4926, 1613, 1967, 4740, 580, 9591, 5072, 1960, 7203, 8089, 5429, 9700, 6983, 5114, 1577, 5430, 2085, 6190, 247, 8673, 8377, 3410, 9676, 6819, 6336, 3154, 884, 2397, 6302, 195, 9775, 1420, 4734, 579, 4397, 1156, 2942, 2286, 6881, 3877, 3301, 4470, 9053, 8339, 9824, 3765, 1330, 8218, 9249, 3191, 9642, 4955, 7710, 1460, 3939, 9523, 1759, 2400, 4705, 9305, 863, 7087, 9811, 3057, 1593, 6093, 9352, 5002, 2291, 6204, 8748, 1234, 6182, 1372, 656, 5449, 3911, 7713, 262, 5351, 4804, 6798, 8818, 6761, 8460, 4579, 6234, 2883, 1788, 2943, 2134, 9228, 6400, 7862, 2162, 6852, 8452, 2240, 7287, 5999, 6503, 5025, 4626, 3841, 1432, 6316, 3907, 4362, 5458, 9396, 5906, 3731, 6521, 2011, 7222, 9284, 4235, 1742, 6307, 2758, 6674, 8471, 3079, 1297, 4923, 7536, 7676, 7444, 5698, 778, 9413, 1718, 7636, 6778, 7540, 4789, 9659, 1841, 6253, 9744, 2440, 6824, 6714, 8910, 464, 7434, 6297, 3148, 6094, 1637, 1532, 6173, 8335, 8269, 4637, 3126, 3087, 5875, 3261, 5625, 2553, 5928, 4689, 6016, 2549, 6866, 8724, 3872, 3788, 5797, 6302, 5807, 8668, 9725, 0, 7099, 2296, 5347, 7736, 7199, 2212, 6260, 3451, 7838, 2193, 144, 717, 527, 1841, 2334, 5123, 7909, 6161, 9780, 1853, 7309, 3244, 4193, 7064, 9702, 5082, 8875, 9587, 4791, 1850, 2212, 3745, 815, 8784, 5082, 5720, 34, 5039, 122, 6716, 8268, 4032, 4291, 7524, 5003, 8305, 6305, 6485, 5301, 2902, 9268, 6839, 6671, 8415, 2188, 6638, 1166, 9065, 6302, 5179, 2060, 1271, 3063, 7792, 6191, 2946, 9501, 7711, 6370, 1849, 4187, 5986, 4528, 561, 1792, 5375, 1957, 1159, 2938, 5663, 1647, 1746, 7978, 2093, 5636, 3819, 3404, 66, 8947, 4731, 8849, 3592, 1171, 3599, 8284, 6878, 5091, 2636, 9420, 4199, 7283, 3319, 2864, 1443, 9260, 3762, 1663, 7334, 3768, 2822, 8158, 624, 8319, 1434, 176, 4833, 5179, 2819, 469, 5570, 9179, 450, 6576, 724, 300, 4442, 2131, 7040, 8015, 2947, 4287, 1552, 9898, 2658, 7204, 6528, 4443, 4879, 1482, 6136, 6030, 5757, 8553, 3709, 7029, 2256, 7462, 6560, 2624, 6029, 6704, 2528, 1563, 6578, 3067, 6656, 3250, 299, 1699, 8638, 719, 4870, 4575, 114, 3874, 2361, 8271, 9473, 7385, 4829, 7048, 7588, 6534, 356, 5322, 7909, 6750, 4294, 435, 1170, 8000, 1334, 9829, 8486, 1591, 2630, 8521, 8851, 3836, 5852, 2416, 7585, 5709, 9479, 2328, 4010, 9319, 9201, 8279, 5065, 5798, 7814, 9942, 7593, 6276, 3383, 3401, 9741, 2465, 8317, 2508, 8379, 5353, 7878, 9394, 854, 1389, 3950, 5976, 6409, 9113, 1784, 7145, 3618, 2740, 5598, 6655, 7364, 7105, 971, 9575, 554, 5993, 7747, 8911, 729, 2180, 1032, 6178, 5201, 9941, 6054, 9675, 2761, 7377, 8788, 2361, 6556, 193, 9291, 2990, 7289, 6625, 3105, 9472, 8322, 9927, 3272, 6479, 852, 2109, 8630, 9605, 5942, 1363, 7093, 1817, 2890, 459, 1357, 3489, 3947, 5048, 4333, 9187, 4543, 7521, 1157, 427, 6625, 8979, 6877, 2492, 8667, 6413, 7865, 5041, 7902, 6910, 8628, 5527, 8692, 6988, 7623, 3094, 9098, 5858, 6869, 7916, 6812, 1826, 7689, 6270, 4319, 7932, 4319, 8920, 3392, 7610, 8372, 1202, 2951, 8875, 6576, 3329, 2789, 5323, 3596, 879, 2936, 5917, 502, 3864, 6787, 5770, 760, 8288, 6200, 4667, 2266, 9264, 6943, 4955, 2881, 3054, 6686, 4164, 1387, 5469, 8386, 8018, 4854, 4021, 649, 594, 1495, 3359, 5588, 7587, 8314, 7961, 8489, 4375, 5030, 4501, 4691, 1184, 6610, 4176, 2724, 7044, 3308, 967, 7114, 7663, 5328, 2761, 5822, 5044, 5677, 6736, 491, 5498, 6258, 1837, 5695, 3686, 1729, 8985, 8312, 4364, 2134, 6307, 1245, 3977, 3244, 6808, 4161, 5205, 6269, 9963, 4819, 359, 1616, 8619, 2837, 8717, 4402, 8795, 6468, 3837, 2783, 5151, 3394, 7725, 8915, 5216, 9901, 2026, 3209, 1238, 787, 8689, 3074, 7479, 9702, 213, 7609, 9523, 7997, 5422, 4225, 5283, 2974, 7570, 560, 6220, 9354, 9470, 5317, 7128, 8363, 1809, 3877, 1985, 8109, 8651, 2283, 8733, 2847, 4344, 971, 5062, 2599, 7647, 7399, 4068, 765, 6991, 8782, 3804, 8242, 1005, 3963, 964, 1104, 1987, 9710, 7305, 4806, 6434, 6664, 3934, 368, 75, 6902, 649, 9542, 1205, 6645, 8854, 388, 3267, 4254, 2701, 1271, 777, 1409, 3892, 3449, 4967, 3247, 102, 8015, 4541, 572, 6227, 1628, 9690, 9077, 2885, 511, 1747, 9630, 3113, 9509, 5298, 1415, 7406, 4127, 7448, 1591, 6762, 5740, 8915, 7857, 2506, 7275, 4357, 9182, 3441, 2577, 3512, 8575, 6055, 933, 8002, 9756, 1120, 2823, 1704, 2248, 4510, 7587, 2551, 4669, 2678, 2039, 119, 6264, 6923, 2811, 3366, 299, 3286, 8344, 3958, 2417, 1486, 7878, 4721, 6709, 2429, 6569, 9472, 562, 9857, 6239, 9034, 1325, 3799, 7265, 9010, 2120, 3271, 8492, 5894, 2864, 7101, 7272, 8913, 1500, 3034, 2286, 1422, 3191, 3431, 6730, 6711, 6077, 3729, 4688, 294, 2537, 1226, 7815, 5722, 3539, 9832, 1474, 6862, 41, 5952, 8796, 1112, 9615, 1564, 8047, 1661, 1799, 6289, 9957, 1687, 5977, 6354, 4931, 7786, 7007, 6939, 2205, 7634, 8410, 8995, 8490, 7449, 1853, 8889, 7059, 3241, 6379, 4429, 2883, 1669, 8472, 80, 7154, 7242, 1043, 634, 4543, 4721, 6874, 9637, 4436, 6365, 4097, 4224, 3450, 1756, 9381, 6779, 7299, 5061, 1960, 1494, 5468, 1388, 2050, 7493, 4899, 6337, 9755, 7353, 6392, 406, 9303, 3225, 8223, 1070, 6037, 7731, 5504, 8332, 1951, 9817, 1523, 8293, 6804, 4876, 3378, 230, 5630, 3568, 390, 2444, 7064, 6070, 4078, 5412, 667, 6305, 6241, 4813, 2925, 9379, 7045, 1926, 3908, 6001, 7540, 7922, 4115, 7490, 7532, 9836, 8081, 9833, 876, 7775, 3583, 9965, 5731, 2965, 7337, 6321, 1873, 9284, 2141, 7205, 608, 6089, 4794, 865, 3646, 3697, 217, 9916, 6219, 1879, 1866, 8372, 3565, 6830, 7266, 8994, 7673, 8769, 7168, 1656, 1709, 8363, 8353, 432, 3728, 7955, 8708, 8493, 9791, 9360, 3235, 8777, 2445, 6500, 423, 5001, 9507, 8578, 3401, 8483, 4807, 9553, 6951, 4932, 177, 4316, 8246, 1306, 1997, 8289, 5058, 8477, 6562, 8965, 1672, 367, 4104, 9027, 2036, 7915, 8927, 1613, 8218, 9212, 4476, 6216, 8334, 8206, 159, 4619, 8149, 1887, 8897, 8957, 3311, 6651, 7047, 4392, 9013, 6400, 9606, 9276, 9650, 8884, 238, 6240, 5102, 8573, 4789, 5390, 2435, 3831, 4761, 6195, 8585, 4594, 1106, 8779, 5601, 4913, 6938, 5604, 5237, 7402, 521, 3788, 3114, 3607, 2058, 5162, 1392, 5173, 8517, 2238, 3325, 4105, 5754, 132, 3315, 4123, 9264, 7091, 6601, 3077, 8703, 5344, 540, 5157, 988, 8775, 9797, 8987, 1145, 3004, 4243, 7801, 8749, 2521, 5296, 3238, 8231, 8969, 6931, 3930, 2768, 4488, 9531, 6863, 1093, 996, 8003, 7865, 4575, 8957, 1220, 8206, 8827, 735, 271, 7154, 3256, 9686, 5231, 2072, 1513, 7659, 6573, 6252, 8696, 7767, 4975, 3935, 8802, 6865, 8019, 756, 3511, 5069, 1633, 6358, 3408, 6058, 5311, 9416, 1884, 4805, 4687, 8007, 7006, 4864, 4597, 8916, 6260, 6541, 4027, 4109, 7085, 137, 7864, 1445, 9863, 8977, 4841, 3795, 4863, 5568, 1651, 9910, 475, 8854, 5089, 4608, 1026, 5176, 9140, 4223, 2753, 8595, 3680, 6371, 6554, 6538, 1521, 409, 5094, 461, 3423, 7467, 2467, 6811, 0, 2383, 4000, 2053, 2388, 1432, 1867, 3273, 8270, 8941, 7860, 4576, 2204, 8411, 3261, 4791, 1775, 1883, 8679, 7449, 2077, 4661, 8084, 2746, 1270, 9025, 2799, 8533, 8550, 9921, 3308, 8391, 5081, 9152, 8516, 7617, 9963, 7519, 6948, 1479, 1255, 568, 467, 4078, 5299, 3068, 6351, 4016, 1964, 5864, 1364, 9829, 341, 1842, 9670, 8545, 3360, 7274, 7709, 621, 2582, 204, 4209, 388, 3714, 6505, 5364, 7443, 6810, 4705, 8564, 2526, 5873, 6341, 638, 1253, 9897, 4662, 705, 9064, 2777, 7336, 3293, 5361, 7977, 1678, 2752, 622, 5023, 8245, 8405, 4004, 4893, 1321, 266, 8197, 4310, 5842, 6098, 7291, 1235, 2994, 3250, 3099, 4250, 3626, 8600, 7843, 5295, 6534, 3754, 1574, 7728, 3317, 3866, 8320, 858, 4511, 5473, 1932, 4825, 1482, 5793, 3197, 5998, 4853, 6688, 1418, 915, 8431, 2484, 9719, 4047, 1366, 3005, 3039, 8658, 8910, 277, 3625, 6308, 7605, 1069, 9874, 1965, 5225, 2586, 6612, 5225, 8850, 3534, 5816, 9795, 6761, 4778, 9459, 3503, 7819, 9954, 1173, 9088, 3394, 4200, 2140, 8098, 4190, 1992, 3255, 3619, 8741, 9104, 9648, 4044, 8378, 9678, 6096, 2344, 5221, 576, 3000, 3442, 4900, 5071, 4852, 5084, 5574, 1818, 2684, 5303, 7724, 2634, 5721, 220, 614, 1648, 5398, 1656, 7087, 2227, 2457, 9958, 8142, 7100, 7883, 1378, 7145, 6665, 3928, 3832, 8773, 7982, 8914, 4045, 5336, 101, 3228, 3302, 6154, 1791, 6224, 5093, 3809, 5771, 7648, 7245, 8613, 7517, 7759, 4495, 6336, 5484, 6164, 1649, 6345, 5031, 8999, 6873, 6350, 7587, 7429, 4825, 59, 4240, 6535, 3060, 7443, 4503, 101, 7606, 3842, 7540, 3840, 5110, 9082, 7345, 6665, 2302, 1767, 890, 6207, 7428, 2732, 3363, 7461, 2126, 7966, 3516, 5373, 4139, 1936, 9883, 2824, 7055, 5902, 5914, 5650, 2805, 3831, 3066, 3981, 7632, 3369, 9460, 7338, 7738, 4200, 8469, 3168, 564, 9693, 607, 8203, 2616, 6000, 7411, 2, 7963, 5548, 4096, 6147, 8774, 8751, 5210, 1072, 6855, 3326, 3412, 3634, 693, 4761, 4620, 7916, 5603, 7879, 7432, 9510, 4464, 218, 55, 3651, 2608, 774, 4602, 8253, 9700, 3969, 9204, 5571, 9285, 279, 1464, 3074, 3888, 3826, 6361, 2340, 3078, 733, 648, 3063, 140, 3140, 385, 7784, 3130, 5624, 7794, 5603, 6424, 2696, 8650, 5205, 7854, 4725, 1432, 58, 6588, 9711, 6126, 3240, 8943, 8111, 8540, 2383, 1288, 9721, 4374, 6030, 1259, 3959, 2624, 4743, 3057, 7947, 3944, 6133, 9450, 2065, 5984, 1644, 3835, 8685, 3960, 6058, 3560, 6018, 2646, 6503, 1149, 3125, 5394, 3871, 5151, 6515, 4585, 4993, 9209, 6241, 646, 9882, 3791, 8685, 8945, 218, 6788, 850, 2063, 6520, 9993, 3871, 4526, 4435, 7580, 9443, 9566, 9261, 3415, 3439, 3547, 8909, 6824, 6425, 8030, 8024, 1093, 6317, 2061, 2812, 2679, 165, 5780, 4055, 8428, 1147, 7137, 3815, 5615, 8156, 9892, 918, 3797, 8989, 9587, 9595, 6670, 6248, 5019, 7592, 3339, 1401, 9082, 5222, 6014, 8363, 7730, 1728, 2817, 2286, 4059, 7079, 1689, 1155, 7756, 9725, 7931, 2811, 2617, 9134, 3107, 4816, 5475, 2385, 5906, 3490, 3673, 1047, 2990, 6573, 1927, 699, 8191, 277, 6642, 6993, 2367, 1392, 2225, 6073, 8764, 9280, 8614, 6943, 114, 9207, 3488, 9714, 468, 1148, 6755, 8475, 9588, 4702, 5582, 9684, 2259, 5670, 1336, 4655, 7884, 1590, 1693, 1269, 8, 2607, 4976, 3339, 40, 6378, 7741, 2634, 8116, 5576, 4310, 1210, 7096, 5215, 5161, 6627, 7846, 2051, 4777, 4896, 7852, 8420, 9855, 9996, 6392, 7242, 7527, 4323, 4302, 1031, 3224, 6563, 1525, 8087, 8888, 7038, 8260, 4954, 6035, 5593, 1748, 669, 9850, 7814, 5490, 7700, 1823, 3944, 3317, 1911, 5130, 919, 972, 7614, 9702, 4075, 5588, 7405, 8184, 5635, 9887, 5545, 9982, 7653, 5616, 704, 3658, 8010, 4112, 5102, 7156, 2484, 3883, 8192, 2627, 8212, 5330, 9133, 8795, 7229, 3336, 2672, 8103, 7828, 4667, 4058, 5071, 8432, 2911, 2387, 133, 2315, 9072, 4157, 1522, 478, 367, 3737, 2457, 6367, 963, 6960, 4327, 6644, 1791, 3235, 964, 1618, 188, 8774, 7417, 3335, 3982, 3039, 5784, 3203, 9390, 1293, 6789, 7896, 4098, 7569, 2177, 9023, 8043, 6947, 4793, 7673, 1496, 8611, 1100, 1124, 8638, 8505, 3610, 604, 997, 5823, 1032, 3305, 1483, 3672, 5899, 6595, 2805, 2219, 6736, 600, 7543, 6785, 720, 5259, 7497, 4223, 5616, 8781, 215, 4377, 7522, 7030, 6732, 2552, 356, 321, 1356, 3003, 6120, 4674, 8412, 7652, 8021, 2235, 6585, 5635, 3839, 6603, 4314, 2422, 3716, 5722, 7249, 3640, 6202, 5952, 4043, 627, 1570, 6935, 5433, 404, 9560, 5588, 191, 8684, 6310, 3452, 4989, 311, 8225, 5445, 5354, 2950, 1920, 6058, 5742, 4191, 1123, 954, 9617, 3105, 7560, 5707, 3398, 5256, 9387, 5876, 7883, 532, 406, 7296, 4400, 3387, 7010, 1443, 4776, 4579, 6408, 3836, 5789, 3994, 2464, 2765, 1522, 8923, 2956, 6008, 1025, 5761, 107, 7419, 2941, 9850, 3535, 4922, 8571, 8422, 353, 4489, 4002, 1353, 298, 9288, 7327, 2509, 5833, 9622, 5689, 1061, 576, 237, 3732, 4319, 9425, 4670, 6338, 2881, 434, 6243, 2841, 8474, 5755, 5637, 1996, 6142, 24, 6337, 9643, 6153, 6263, 7355, 2569, 9920, 1354, 5638, 9102, 6311, 6832, 5277, 1283, 3283, 8388, 484, 9977, 4496, 1678, 6108, 708, 8446, 7397, 3150, 5383, 9514, 5467, 3458, 4032, 7428, 2744, 3910, 6860, 0, 1372, 8289, 1785, 5901, 6919}, + 6, + }, + + { + []int{44, 46, 22, 68, 45, 66, 43, 9, 37, 30, 50, 67, 32, 47, 44, 11, 15, 4, 11, 6, 20, 64, 54, 54, 61, 63, 23, 43, 3, 12, 51, 61, 16, 57, 14, 12, 55, 17, 18, 25, 19, 28, 45, 56, 29, 39, 52, 8, 1, 21, 17, 21, 23, 70, 51, 61, 21, 52, 25, 28}, + 6, + }, + + { + []int{3, 6, 9, 12}, + 4, + }, + + { + []int{9, 4, 7, 2, 10}, + 3, + }, + + { + []int{20, 1, 15, 3, 10, 5, 8}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_longestArithSeqLength(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, longestArithSeqLength(tc.A), "输入:%v", tc) + } +} + +func Benchmark_longestArithSeqLength(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + longestArithSeqLength(tc.A) + } + } +} diff --git a/Algorithms/1028.recover-a-tree-from-preorder-traversal/1.png b/Algorithms/1028.recover-a-tree-from-preorder-traversal/1.png new file mode 100644 index 000000000..48d777d2c Binary files /dev/null and b/Algorithms/1028.recover-a-tree-from-preorder-traversal/1.png differ diff --git a/Algorithms/1028.recover-a-tree-from-preorder-traversal/2.png b/Algorithms/1028.recover-a-tree-from-preorder-traversal/2.png new file mode 100644 index 000000000..ff925bad2 Binary files /dev/null and b/Algorithms/1028.recover-a-tree-from-preorder-traversal/2.png differ diff --git a/Algorithms/1028.recover-a-tree-from-preorder-traversal/3.png b/Algorithms/1028.recover-a-tree-from-preorder-traversal/3.png new file mode 100644 index 000000000..a133057e6 Binary files /dev/null and b/Algorithms/1028.recover-a-tree-from-preorder-traversal/3.png differ diff --git a/Algorithms/1028.recover-a-tree-from-preorder-traversal/README.md b/Algorithms/1028.recover-a-tree-from-preorder-traversal/README.md new file mode 100755 index 000000000..47845fbce --- /dev/null +++ b/Algorithms/1028.recover-a-tree-from-preorder-traversal/README.md @@ -0,0 +1,41 @@ +# [1028. Recover a Tree From Preorder Traversal](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal/) + +We run a preorder depth first search on the root of a binary tree. + +At each node in this traversal, we output D dashes (where D is the depth of this node), then we output the value of this node. (If the depth of a node is D, the depth of its immediate child is D+1. The depth of the root node is 0.) + +If a node has only one child, that child is guaranteed to be the left child. + +Given the output S of this traversal, recover the tree and return its root. + +Example 1: + +![1](1.png) + +```text +Input: "1-2--3--4-5--6--7" +Output: [1,2,5,3,4,6,7] +``` + +Example 2: + +![2](2.png) + +```text +Input: "1-2--3---4-5--6---7" +Output: [1,2,5,3,null,6,null,4,null,7] +``` + +Example 3: + +![3](3.png) + +```text +Input: "1-401--349---90--88" +Output: [1,401,null,349,88,90] +``` + +Note: + +- The number of nodes in the original tree is between 1 and 1000. +- Each node will have a value between 1 and 10^9. diff --git a/Algorithms/1028.recover-a-tree-from-preorder-traversal/recover-a-tree-from-preorder-traversal.go b/Algorithms/1028.recover-a-tree-from-preorder-traversal/recover-a-tree-from-preorder-traversal.go new file mode 100755 index 000000000..af54f65be --- /dev/null +++ b/Algorithms/1028.recover-a-tree-from-preorder-traversal/recover-a-tree-from-preorder-traversal.go @@ -0,0 +1,46 @@ +package problem1028 + +import ( + "strconv" + + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined... +type TreeNode = kit.TreeNode + +func recoverFromPreorder(S string) *TreeNode { + next := func() (int, *TreeNode) { + level := 0 + for S[level] == '-' { + level++ + } + end := level + for end < len(S) && S[end] != '-' { + end++ + } + val, _ := strconv.Atoi(S[level:end]) + S = S[end:] + return level, &TreeNode{Val: val} + } + + stack, top := make([]*TreeNode, 1000), -1 + + for len(S) > 0 { + level, node := next() + for top >= level { // top is the level of stack[top] + top-- + } + if top >= 0 { + if stack[top].Left == nil { + stack[top].Left = node + } else { + stack[top].Right = node + } + } + top++ + stack[top] = node + } + + return stack[0] +} diff --git a/Algorithms/1028.recover-a-tree-from-preorder-traversal/recover-a-tree-from-preorder-traversal_test.go b/Algorithms/1028.recover-a-tree-from-preorder-traversal/recover-a-tree-from-preorder-traversal_test.go new file mode 100755 index 000000000..3062333d4 --- /dev/null +++ b/Algorithms/1028.recover-a-tree-from-preorder-traversal/recover-a-tree-from-preorder-traversal_test.go @@ -0,0 +1,54 @@ +package problem1028 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans []int +}{ + + { + "3", + []int{3}, + }, + + { + "1-2--3--4-5--6--7", + []int{1, 2, 5, 3, 4, 6, 7}, + }, + + { + "1-2--3---4-5--6---7", + []int{1, 2, 5, 3, kit.NULL, 6, kit.NULL, 4, kit.NULL, 7}, + }, + + { + "1-401--349---90--88", + []int{1, 401, kit.NULL, 349, 88, 90}, + }, + + // 可以有多个 testcase +} + +func Test_recoverFromPreorder(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ans := recoverFromPreorder(tc.S) + ast.Equal(tc.ans, kit.Tree2ints(ans), "输入:%v", tc) + } +} + +func Benchmark_recoverFromPreorder(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + recoverFromPreorder(tc.S) + } + } +} diff --git a/Algorithms/1029.two-city-scheduling/README.md b/Algorithms/1029.two-city-scheduling/README.md new file mode 100755 index 000000000..15916599f --- /dev/null +++ b/Algorithms/1029.two-city-scheduling/README.md @@ -0,0 +1,25 @@ +# [1029. Two City Scheduling](https://leetcode.com/problems/two-city-scheduling/) + +There are 2N people a company is planning to interview. The cost of flying the i-th person to city A is costs[i][0], and the cost of flying the i-th person to city B is costs[i][1]. + +Return the minimum cost to fly every person to a city such that exactly N people arrive in each city. + +Example 1: + +```text +Input: [[10,20],[30,200],[400,50],[30,20]] +Output: 110 +Explanation: +The first person goes to city A for a cost of 10. +The second person goes to city A for a cost of 30. +The third person goes to city B for a cost of 50. +The fourth person goes to city B for a cost of 20. + +The total minimum cost is 10 + 30 + 50 + 20 = 110 to have half the people interviewing in each city. +``` + +Note: + +- `1 <= costs.length <= 100` +- It is guaranteed that costs.length is even. +- `1 <= costs[i][0], costs[i][1] <= 1000` diff --git a/Algorithms/1029.two-city-scheduling/two-city-scheduling.go b/Algorithms/1029.two-city-scheduling/two-city-scheduling.go new file mode 100755 index 000000000..2c2b5bbb7 --- /dev/null +++ b/Algorithms/1029.two-city-scheduling/two-city-scheduling.go @@ -0,0 +1,21 @@ +package problem1029 + +import "sort" + +func twoCitySchedCost(costs [][]int) int { + sort.Slice(costs, func(i int, j int) bool { + return costs[i][1]-costs[i][0] > costs[j][1]-costs[j][0] + // person i is either to A or to B + // c = costs[i][1]-costs[i][0] means + // if person i go to B, the cost have to be paid more. + // so, c is larger, person i is more should go to A. + // after sorting + // persion[:N] go to A, the others go to B. + }) + N := len(costs) / 2 + sum := 0 + for i := 0; i < N; i++ { + sum += costs[i][0] + costs[i+N][1] + } + return sum +} diff --git a/Algorithms/1029.two-city-scheduling/two-city-scheduling_test.go b/Algorithms/1029.two-city-scheduling/two-city-scheduling_test.go new file mode 100755 index 000000000..fcd664b82 --- /dev/null +++ b/Algorithms/1029.two-city-scheduling/two-city-scheduling_test.go @@ -0,0 +1,42 @@ +package problem1029 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + costs [][]int + ans int +}{ + + { + [][]int{{259, 770}, {448, 54}, {926, 667}, {184, 139}, {840, 118}, {577, 469}}, + 1859, + }, + + { + [][]int{{10, 20}, {30, 200}, {400, 50}, {30, 20}}, + 110, + }, + + // 可以有多个 testcase +} + +func Test_twoCitySchedCost(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, twoCitySchedCost(tc.costs), "输入:%v", tc) + } +} + +func Benchmark_twoCitySchedCost(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + twoCitySchedCost(tc.costs) + } + } +} diff --git a/Algorithms/1030.matrix-cells-in-distance-order/README.md b/Algorithms/1030.matrix-cells-in-distance-order/README.md new file mode 100755 index 000000000..95da5fd6f --- /dev/null +++ b/Algorithms/1030.matrix-cells-in-distance-order/README.md @@ -0,0 +1,40 @@ +# [1030. Matrix Cells in Distance Order](https://leetcode.com/problems/matrix-cells-in-distance-order/) + +We are given a matrix with R rows and C columns has cells with integer coordinates (r, c), where 0 <= r < R and 0 <= c < C. + +Additionally, we are given a cell in that matrix with coordinates (r0, c0). + +Return the coordinates of all cells in the matrix, sorted by their distance from (r0, c0) from smallest distance to largest distance. Here, the distance between two cells (r1, c1) and (r2, c2) is the Manhattan distance, |r1 - r2| + |c1 - c2|. (You may return the answer in any order that satisfies this condition.) + +Example 1: + +```text +Input: R = 1, C = 2, r0 = 0, c0 = 0 +Output: [[0,0],[0,1]] +Explanation: The distances from (r0, c0) to other cells are: [0,1] +``` + +Example 2: + +```text +Input: R = 2, C = 2, r0 = 0, c0 = 1 +Output: [[0,1],[0,0],[1,1],[1,0]] +Explanation: The distances from (r0, c0) to other cells are: [0,1,1,2] +The answer [[0,1],[1,1],[0,0],[1,0]] would also be accepted as correct. +``` + +Example 3: + +```text +Input: R = 2, C = 3, r0 = 1, c0 = 2 +Output: [[1,2],[0,2],[1,1],[0,1],[1,0],[0,0]] +Explanation: The distances from (r0, c0) to other cells are: [0,1,1,2,2,3] +There are other answers that would also be accepted as correct, such as [[1,2],[1,1],[0,2],[1,0],[0,1],[0,0]]. +``` + +Note: + +1. `1 <= R <= 100` +1. `1 <= C <= 100` +1. `0 <= r0 < R` +1. `0 <= c0 < C` diff --git a/Algorithms/1030.matrix-cells-in-distance-order/matrix-cells-in-distance-order.go b/Algorithms/1030.matrix-cells-in-distance-order/matrix-cells-in-distance-order.go new file mode 100755 index 000000000..02046c07f --- /dev/null +++ b/Algorithms/1030.matrix-cells-in-distance-order/matrix-cells-in-distance-order.go @@ -0,0 +1,26 @@ +package problem1030 + +var res = [10000][]int{} + +func allCellsDistOrder(R int, C int, r0 int, c0 int) [][]int { + dist := [200][][]int{} + for r := 0; r < R; r++ { + for c := 0; c < C; c++ { + d := abs(r-r0) + abs(c-c0) + dist[d] = append(dist[d], []int{r, c}) + } + } + begin, end := 0, 0 + for d := 0; len(dist[d]) > 0; d++ { + begin, end = end, end+len(dist[d]) + copy(res[begin:end], dist[d]) + } + return res[:end] +} + +func abs(n int) int { + if n < 0 { + return -n + } + return n +} diff --git a/Algorithms/1030.matrix-cells-in-distance-order/matrix-cells-in-distance-order_test.go b/Algorithms/1030.matrix-cells-in-distance-order/matrix-cells-in-distance-order_test.go new file mode 100755 index 000000000..9ed161edc --- /dev/null +++ b/Algorithms/1030.matrix-cells-in-distance-order/matrix-cells-in-distance-order_test.go @@ -0,0 +1,105 @@ +package problem1030 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + R int + C int + r0 int + c0 int + exp [][]int +}{ + + { + 10, + 10, + 5, + 9, + [][]int{{5, 9}, {4, 9}, {5, 8}, {6, 9}, {3, 9}, {4, 8}, {5, 7}, {6, 8}, {7, 9}, {2, 9}, {3, 8}, {4, 7}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {1, 9}, {2, 8}, {3, 7}, {4, 6}, {5, 5}, {6, 6}, {7, 7}, {8, 8}, {9, 9}, {0, 9}, {1, 8}, {2, 7}, {3, 6}, {4, 5}, {5, 4}, {6, 5}, {7, 6}, {8, 7}, {9, 8}, {0, 8}, {1, 7}, {2, 6}, {3, 5}, {4, 4}, {5, 3}, {6, 4}, {7, 5}, {8, 6}, {9, 7}, {0, 7}, {1, 6}, {2, 5}, {3, 4}, {4, 3}, {5, 2}, {6, 3}, {7, 4}, {8, 5}, {9, 6}, {0, 6}, {1, 5}, {2, 4}, {3, 3}, {4, 2}, {5, 1}, {6, 2}, {7, 3}, {8, 4}, {9, 5}, {0, 5}, {1, 4}, {2, 3}, {3, 2}, {4, 1}, {5, 0}, {6, 1}, {7, 2}, {8, 3}, {9, 4}, {0, 4}, {1, 3}, {2, 2}, {3, 1}, {4, 0}, {6, 0}, {7, 1}, {8, 2}, {9, 3}, {0, 3}, {1, 2}, {2, 1}, {3, 0}, {7, 0}, {8, 1}, {9, 2}, {0, 2}, {1, 1}, {2, 0}, {8, 0}, {9, 1}, {0, 1}, {1, 0}, {9, 0}, {0, 0}}, + }, + + { + 2, + 2, + 0, + 1, + [][]int{{0, 1}, {0, 0}, {1, 1}, {1, 0}}, + }, + + { + 2, + 3, + 1, + 2, + [][]int{{1, 2}, {0, 2}, {1, 1}, {0, 1}, {1, 0}, {0, 0}}, + }, + + { + 1, + 2, + 0, + 0, + [][]int{{0, 0}, {0, 1}}, + }, + { + 2, + 2, + 0, + 1, + [][]int{{0, 1}, {0, 0}, {1, 1}, {1, 0}}, + }, + { + 2, + 3, + 1, + 2, + [][]int{{1, 2}, {0, 2}, {1, 1}, {0, 1}, {1, 0}, {0, 0}}, + }, + + // 可以有多个 testcase +} + +func Test_allCellsDistOrder(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ans := allCellsDistOrder(tc.R, tc.C, tc.r0, tc.c0) + ast.Equal(tc.exp, ans, "输入:%v", tc) + } +} + +func Benchmark_allCellsDistOrder(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + allCellsDistOrder(tc.R, tc.C, tc.r0, tc.c0) + } + } +} + +var limit = 10000 + +func Benchmark_abs_normal(b *testing.B) { + for i := 1; i < b.N; i++ { + for j := -limit; j <= limit; j++ { + abs(j) + } + } +} + +func absBit(n int) int { + x := n >> 63 + return (n ^ x) - x +} + +func Benchmark_absBit(b *testing.B) { + for i := 1; i < b.N; i++ { + for j := -limit; j <= limit; j++ { + absBit(j) + } + } +} diff --git a/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/README.md b/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/README.md new file mode 100755 index 000000000..086c5a422 --- /dev/null +++ b/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/README.md @@ -0,0 +1,39 @@ +# [1031. Maximum Sum of Two Non-Overlapping Subarrays](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays/) + +Given an array A of non-negative integers, return the maximum sum of elements in two non-overlapping (contiguous) subarrays, which have lengths L and M. (For clarification, the L-length subarray could occur before or after the M-length subarray.) + +Formally, return the largest V for which V = (A[i] + A[i+1] + ... + A[i+L-1]) + (A[j] + A[j+1] + ... + A[j+M-1]) and either: + +- 0 <= i < i + L - 1 < j < j + M - 1 < A.length, or +- 0 <= j < j + M - 1 < i < i + L - 1 < A.length. + +Example 1: + +```text +Input: A = [0,6,5,2,2,5,1,9,4], L = 1, M = 2 +Output: 20 +Explanation: One choice of subarrays is [9] with length 1, and [6,5] with length 2. +``` + +Example 2: + +```text +Input: A = [3,8,1,3,2,1,8,9,0], L = 3, M = 2 +Output: 29 +Explanation: One choice of subarrays is [3,8,1] with length 3, and [8,9] with length 2. +``` + +Example 3: + +```text +Input: A = [2,1,5,6,0,9,5,0,3,8], L = 4, M = 3 +Output: 31 +Explanation: One choice of subarrays is [5,6,0,9] with length 4, and [3,8] with length 3. +``` + +Note: + +1. `L >= 1` +1. `M >= 1` +1. `L + M <= A.length <= 1000` +1. `0 <= A[i] <= 1000` diff --git a/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/maximum-sum-of-two-non-overlapping-subarrays.go b/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/maximum-sum-of-two-non-overlapping-subarrays.go new file mode 100755 index 000000000..df14736c5 --- /dev/null +++ b/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/maximum-sum-of-two-non-overlapping-subarrays.go @@ -0,0 +1,27 @@ +package problem1031 + +// ref: https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays/discuss/278251/JavaC%2B%2BPython-O(N)Time-O(1)-Space + +func maxSumTwoNoOverlap(A []int, L int, M int) int { + for i := 1; i < len(A); i++ { + A[i] += A[i-1] + } + // assume original A is A' + // now, A[i] = sum(A'[:i+1]) + res, lMax, mMax := A[L+M-1], A[L-1], A[M-1] + for i := L + M; i < len(A); i++ { + // lMax is max sum of contiguous L elements before the last M elements. + lMax = max(lMax, A[i-M]-A[i-L-M]) + // mMax is max sum of contiguous M elements before the last L elements. + mMax = max(mMax, A[i-L]-A[i-L-M]) + res = max(res, max(lMax+A[i]-A[i-M], mMax+A[i]-A[i-L])) + } + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/maximum-sum-of-two-non-overlapping-subarrays_test.go b/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/maximum-sum-of-two-non-overlapping-subarrays_test.go new file mode 100755 index 000000000..fdf2567c5 --- /dev/null +++ b/Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays/maximum-sum-of-two-non-overlapping-subarrays_test.go @@ -0,0 +1,69 @@ +package problem1031 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + L int + M int + ans int +}{ + + { + []int{360, 629, 175, 292, 546, 681, 708, 458, 411, 596, 978, 592, 7, 830, 968, 589, 234, 743, 997, 542, 431, 496, 545, 97, 781, 978, 31, 531, 651, 855, 692, 852, 137, 706, 458, 47, 963, 993, 205, 223, 180, 661, 418, 458, 780, 365, 510, 344, 945, 988, 744, 498, 71, 927, 971, 240, 829, 546, 629, 944, 248, 116, 390, 667, 343, 390, 295, 701, 143, 197, 811, 608, 190, 858, 954, 905, 335, 373, 797, 598, 817, 965, 1000, 861, 612, 306, 783, 772, 755, 439, 256, 82, 993, 207, 695, 613, 930, 236, 0, 439, 348, 400, 825, 12, 306, 846, 792, 334, 339, 814, 631, 51, 633, 666, 852, 686, 939, 139, 264, 508, 675, 784, 60, 89, 730, 958, 879, 356, 550, 135, 755, 517, 390, 945, 536, 406, 383, 110, 389, 649, 802, 682, 257, 770, 420, 165, 101, 126, 475, 42, 714, 305, 547, 750, 640, 61, 914, 358, 617, 266, 69, 543, 771, 509, 162, 738, 806, 668, 734, 845, 718, 795, 956, 203, 368, 523, 440, 674, 586, 552, 928, 954, 414, 623, 960, 673, 279, 76, 814, 80, 881, 834, 377, 434, 84, 737, 166, 173, 429, 434, 925, 252, 1, 172, 209, 340, 242, 173, 460, 520, 632, 618, 260, 401, 300, 879, 74, 228, 5, 694, 976, 28, 448, 131, 431, 702, 217, 766, 841, 513, 647, 541, 48, 321, 986, 200, 998, 657, 338, 365, 276, 562, 897, 161, 586, 381, 775, 140, 355, 558, 237, 683, 953, 350, 122, 295, 606, 935, 736, 641, 239, 415, 999, 834, 935, 637, 940, 972, 670, 778, 257, 446, 118, 799, 28, 921, 987, 99, 415, 844, 827, 294, 454, 993, 58, 916, 312, 571, 217, 487, 619, 191, 616, 450, 68, 688, 270, 812, 468, 239, 762, 636, 267, 745, 560, 212, 228, 425, 364, 670, 231, 512, 639, 732, 450, 472, 78, 562, 145, 963, 331, 325, 323, 804, 476, 149, 247, 88, 237, 370, 82, 392, 399, 432, 135, 890, 731, 871, 601, 37, 124, 691, 249, 240, 518, 69, 430, 761, 963, 803, 397, 575, 535, 199, 311, 39, 312, 317, 123, 103, 249, 77, 131, 730, 712, 405, 134, 662, 489, 657, 846, 824, 788, 257, 332, 891, 31, 618, 584, 482, 141, 300, 915, 493, 760, 954, 308, 584, 704, 857, 464, 69, 601, 683, 918, 456, 24, 81, 39, 23, 829, 567, 402, 84, 619, 247, 437, 529, 190, 178, 195, 57, 818, 884, 498, 204, 509, 354, 86, 105, 663, 627, 913, 172, 330, 828, 763, 508, 306, 861, 962, 874, 806, 891, 304, 927, 700, 77, 811, 136, 459, 485, 29, 778, 344, 971, 377, 588, 601, 429, 282, 710, 794, 918, 312, 250, 950, 143, 947, 907, 392, 330, 270, 326, 439, 380, 155, 706, 962, 683, 877, 711, 459, 47, 317, 691, 132, 989, 816, 748, 765, 989, 970, 178, 546, 831, 572, 651, 664, 221, 424, 992, 90, 889, 418, 11, 278, 776, 570, 57, 970, 391, 623, 177, 797, 123, 693, 449, 662, 679, 296, 987, 475, 918, 486, 624, 218, 512, 185, 526, 831, 433, 927, 447, 381, 928, 754, 459, 607, 649, 273, 509, 163, 591, 734, 573, 664, 501, 607, 191, 675, 939, 185, 465, 644, 307, 695, 479, 674, 751, 922, 803, 860, 932, 768, 272, 294, 223, 977, 536, 150, 602, 612, 863, 768, 154, 477, 156, 331, 404, 345, 401, 4, 307, 606, 60, 75, 2, 295, 297, 848, 612, 661, 640, 635, 841, 800, 174, 366, 54, 539, 786, 879, 469, 322, 32, 588, 904, 411, 577, 97, 621, 32, 4, 784, 346, 791, 659, 62, 228, 422, 532, 961, 889, 859, 441, 978, 515, 311, 665, 728, 892, 299, 22, 573, 473, 963, 150, 831, 858, 156, 139, 472, 53, 579, 105, 337, 576, 83, 409, 762, 556, 906, 836, 782, 825, 380, 416, 2, 904, 676, 265, 637, 757, 970, 911, 62, 816, 784, 511, 372, 572, 889, 25, 94, 722, 514, 137, 147, 863, 674, 236, 494, 351, 706, 962, 192, 930, 833, 580, 992, 239, 14, 786, 749, 746, 166, 321, 951, 820, 387, 157, 852, 376, 258, 682, 882, 742, 995, 291, 304, 920, 131, 800, 78, 264, 164, 428, 301, 952, 510, 408, 336, 258, 442, 933, 866, 366, 991, 314, 323, 190, 326, 315, 195, 848, 583, 357, 462, 336, 417, 838, 208, 969, 559, 48, 938, 248, 702, 5, 928, 936, 378, 792, 325, 215, 240, 166, 643, 395, 3, 158, 89, 742, 448, 90, 348, 694, 797, 374, 886, 852, 19, 393, 202, 906, 693, 308, 227, 558, 379, 385, 691, 953, 881, 973, 762, 663, 539, 63, 983, 633, 310, 798, 389, 140, 411, 100, 40, 826, 328, 997, 856, 433, 586, 204, 724, 340, 773, 656, 694, 498, 257, 658, 468, 8, 486, 380, 118, 123, 901, 108, 539, 763, 461, 294, 327, 24, 46, 495, 744, 417, 823, 844, 511, 40, 245, 854, 1, 210, 386, 64, 688, 516, 461, 672, 371, 946, 155, 524, 56, 825, 23, 579, 580, 198, 312, 179, 445, 47, 644, 759, 89, 676, 314, 567, 298, 907, 555, 646, 544, 403, 643, 194, 485, 428, 139, 296, 808, 445, 343, 236, 51, 132, 945, 9, 928, 929, 90, 313, 458, 231, 429, 662, 707, 833, 407, 589, 708, 555, 762, 806, 638, 553, 489, 577, 497, 507, 905, 51, 204, 297, 575, 876, 849, 145, 363, 68, 431, 532, 881, 15, 355, 956, 575, 657, 809, 544, 343, 80, 641, 93, 619, 210, 834, 764, 26, 685, 312, 434, 974, 999, 384, 704, 590, 547, 234, 782, 448, 22, 866, 614, 683, 852, 564, 846, 430, 440, 899, 383, 244, 644, 809, 304, 651, 847, 314, 378, 495, 488, 418, 324, 838, 571, 800, 461, 2, 904, 83, 226, 836, 146, 667, 154, 603, 706, 336, 40, 802, 19, 449, 726, 539, 73, 511, 695, 527, 79, 69, 395, 876, 415, 943, 756, 398, 348, 900, 228, 953, 119}, + 204, + 648, + 434985, + }, + + { + []int{4, 5, 14, 16, 16, 20, 7, 13, 8, 15}, + 3, + 5, + 109, + }, + + { + []int{0, 6, 5, 2, 2, 5, 1, 9, 4}, + 1, + 2, + 20, + }, + + { + []int{3, 8, 1, 3, 2, 1, 8, 9, 0}, + 3, + 2, + 29, + }, + + { + []int{2, 1, 5, 6, 0, 9, 5, 0, 3, 8}, + 4, + 3, + 31, + }, + + // 可以有多个 testcase +} + +func Test_maxSumTwoNoOverlap(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxSumTwoNoOverlap(tc.A, tc.L, tc.M), "输入:%v", tc) + } +} + +func Benchmark_maxSumTwoNoOverlap(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxSumTwoNoOverlap(tc.A, tc.L, tc.M) + } + } +} diff --git a/Algorithms/1032.stream-of-characters/README.md b/Algorithms/1032.stream-of-characters/README.md new file mode 100755 index 000000000..56ce79281 --- /dev/null +++ b/Algorithms/1032.stream-of-characters/README.md @@ -0,0 +1,32 @@ +# [1032. Stream of Characters](https://leetcode.com/problems/stream-of-characters/) + +Implement the StreamChecker class as follows: + +- StreamChecker(words): Constructor, init the data structure with the given words. +- query(letter): returns true if and only if for some k >= 1, the last k characters queried (in order from oldest to newest, including this letter just queried) spell one of the words in the given list. + +Example: + +```text +StreamChecker streamChecker = new StreamChecker(["cd","f","kl"]); // init the dictionary. +streamChecker.query('a'); // return false +streamChecker.query('b'); // return false +streamChecker.query('c'); // return false +streamChecker.query('d'); // return true, because 'cd' is in the wordlist +streamChecker.query('e'); // return false +streamChecker.query('f'); // return true, because 'f' is in the wordlist +streamChecker.query('g'); // return false +streamChecker.query('h'); // return false +streamChecker.query('i'); // return false +streamChecker.query('j'); // return false +streamChecker.query('k'); // return false +streamChecker.query('l'); // return true, because 'kl' is in the wordlist +``` + +Note: + +- 1 <= words.length <= 2000 +- 1 <= words[i].length <= 2000 +- Words will only consist of lowercase English letters. +- Queries will only consist of lowercase English letters. +- The number of queries is at most 40000. diff --git a/Algorithms/1032.stream-of-characters/stream-of-characters.go b/Algorithms/1032.stream-of-characters/stream-of-characters.go new file mode 100755 index 000000000..3206e00cb --- /dev/null +++ b/Algorithms/1032.stream-of-characters/stream-of-characters.go @@ -0,0 +1,63 @@ +package problem1032 + +// StreamChecker check letters +type StreamChecker struct { + trie *trie + stream []int8 +} + +// Constructor returns StreamChecker +func Constructor(words []string) StreamChecker { + m := 0 + t := &trie{} + for _, w := range words { + m = max(m, len(w)) + t.insert(w) + } + return StreamChecker{ + trie: t, + stream: make([]int8, 0, 1024), + } +} + +// Query returns true if letter in words +func (sc *StreamChecker) Query(letter byte) bool { + sc.stream = append(sc.stream, int8(letter-'a')) + n, t := len(sc.stream), sc.trie + for i := n - 1; i >= 0; i-- { + index := sc.stream[i] + if t.next[index] == nil { + return false + } + t = t.next[index] + if t.isWord { + return true + } + } + return false +} + +type trie struct { + next [26]*trie + isWord bool +} + +func (t *trie) insert(word string) { + n := len(word) + // reversely insert + for i := n - 1; i >= 0; i-- { + index := int(word[i] - 'a') + if t.next[index] == nil { + t.next[index] = &trie{} + } + t = t.next[index] + } + t.isWord = true +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1032.stream-of-characters/stream-of-characters_test.go b/Algorithms/1032.stream-of-characters/stream-of-characters_test.go new file mode 100755 index 000000000..83715a198 --- /dev/null +++ b/Algorithms/1032.stream-of-characters/stream-of-characters_test.go @@ -0,0 +1,107 @@ +package problem1032 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + words []string + ans StreamChecker +}{ + + // 可以有多个 testcase +} + +func Test_Case(t *testing.T) { + ast := assert.New(t) + // + words := []string{"cd", "f", "kl"} + streamChecker := Constructor(words) + // + ast.False(streamChecker.Query('a')) // return false + ast.False(streamChecker.Query('b')) // return false + ast.False(streamChecker.Query('c')) // return false + ast.True(streamChecker.Query('d')) // return true, because 'cd' is in the wordlist + ast.False(streamChecker.Query('e')) // return false + ast.True(streamChecker.Query('f')) // return true, because 'f' is in the wordlist + ast.False(streamChecker.Query('g')) // return false + ast.False(streamChecker.Query('h')) // return false + ast.False(streamChecker.Query('i')) // return false + ast.False(streamChecker.Query('j')) // return false + ast.False(streamChecker.Query('k')) // return false + ast.True(streamChecker.Query('l')) // return true, because 'kl' is in the wordlist +} + +func Test_Case_2(t *testing.T) { + ast := assert.New(t) + // + words := []string{"cd"} + streamChecker := Constructor(words) + // + ast.False(streamChecker.Query('c')) // return false + ast.True(streamChecker.Query('d')) // return true, because 'cd' is in the wordlist + ast.False(streamChecker.Query('c')) // return false +} + +func Test_Case_3(t *testing.T) { + ast := assert.New(t) + // + words := []string{"cd"} + streamChecker := Constructor(words) + // + ast.False(streamChecker.Query('c')) // return false + ast.True(streamChecker.Query('d')) // return true, because 'cd' is in the wordlist + ast.False(streamChecker.Query('d')) // return false +} + +func Test_Case_4(t *testing.T) { + ast := assert.New(t) + // + words := []string{"cd"} + streamChecker := Constructor(words) + // + ast.False(streamChecker.Query('c')) // return false + ast.True(streamChecker.Query('d')) // return true, because 'cd' is in the wordlist + ast.False(streamChecker.Query('c')) // return false + ast.True(streamChecker.Query('d')) // return true, because 'cd' is in the wordlist +} + +func Test_Case_5(t *testing.T) { + ast := assert.New(t) + // + words := []string{"cd", "cdd"} + streamChecker := Constructor(words) + // + ast.False(streamChecker.Query('c')) // return false + ast.True(streamChecker.Query('d')) // return true, because 'cd' is in the wordlist + ast.True(streamChecker.Query('d')) // return true, because 'cd' is in the wordlist +} + +func Test_Case_6(t *testing.T) { + ast := assert.New(t) + // + words := []string{"abaa", "abaab", "aabbb", "bab", "ab"} + streamChecker := Constructor(words) + + querys := []byte{'a', 'a', 'b', 'b', 'b', 'a', 'a', 'b', 'b', 'a', 'a', 'a', 'a', 'b', 'a', 'b', 'b', 'b', 'a', 'b', 'b', 'b', 'a', 'a', 'a', 'a', 'a', 'b', 'a', 'b', 'b', 'b', 'a', 'a', 'b', 'b', 'b', 'a', 'b', 'a'} + expects := []bool{false, false, true, false, true, false, false, true, false, false, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, false, false, true, false, true, false, false, false, false, true, false, true, false, true, false} + + ast.Equal(len(querys), len(expects)) + for i, q := range querys { + ast.Equal(expects[i], streamChecker.Query(q), "%d:%s", i, string(querys[:i+1])) + } +} + +func Test_Case_7(t *testing.T) { + ast := assert.New(t) + // + words := []string{"cd"} + streamChecker := Constructor(words) + // + ast.False(streamChecker.Query('c')) // return false + ast.False(streamChecker.Query('a')) // return false + ast.False(streamChecker.Query('d')) // return false +} diff --git a/Algorithms/1033.moving-stones-until-consecutive/README.md b/Algorithms/1033.moving-stones-until-consecutive/README.md new file mode 100755 index 000000000..c2a543b56 --- /dev/null +++ b/Algorithms/1033.moving-stones-until-consecutive/README.md @@ -0,0 +1,40 @@ +# [1033. Moving Stones Until Consecutive](https://leetcode.com/problems/moving-stones-until-consecutive/) + +Three stones are on a number line at positions a, b, and c. + +Each turn, you pick up a stone at an endpoint (ie., either the lowest or highest position stone), and move it to an unoccupied position between those endpoints. Formally, let's say the stones are currently at positions x, y, z with x < y < z. You pick up the stone at either position x or position z, and move that stone to an integer position k, with x < k < z and k != y. + +The game ends when you cannot make any more moves, ie. the stones are in consecutive positions. + +When the game ends, what is the minimum and maximum number of moves that you could have made? Return the answer as an length 2 array: `answer = [minimum_moves, maximum_moves]` + +Example 1: + +```text +Input: a = 1, b = 2, c = 5 +Output: [1,2] +Explanation: Move the stone from 5 to 3, or move the stone from 5 to 4 to 3. +``` + +Example 2: + +```text +Input: a = 4, b = 3, c = 2 +Output: [0,0] +Explanation: We cannot make any moves. +``` + +Example 3: + +```text +Input: a = 3, b = 5, c = 1 +Output: [1,2] +Explanation: Move the stone from 1 to 4; or move the stone from 1 to 2 to 4. +``` + +Note: + +1. `1 <= a <= 100` +1. `1 <= b <= 100` +1. `1 <= c <= 100` +1. `a != b, b != c, c != a` diff --git a/Algorithms/1033.moving-stones-until-consecutive/moving-stones-until-consecutive.go b/Algorithms/1033.moving-stones-until-consecutive/moving-stones-until-consecutive.go new file mode 100755 index 000000000..a703f9756 --- /dev/null +++ b/Algorithms/1033.moving-stones-until-consecutive/moving-stones-until-consecutive.go @@ -0,0 +1,35 @@ +package problem1033 + +var zerozero = []int{0, 0} + +func numMovesStones(a, b, c int) []int { + a, b, c = sort(a, b, c) + if c-a == 2 { + return zerozero + } + minM, maxM := 2, c-a-2 + if min(b-a, c-b) <= 2 { + minM = 1 + } + return []int{minM, maxM} +} + +func sort(a, b, c int) (int, int, int) { + if a > b { + a, b = b, a + } + if a > c { + a, c = c, a + } + if b > c { + b, c = c, b + } + return a, b, c +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1033.moving-stones-until-consecutive/moving-stones-until-consecutive_test.go b/Algorithms/1033.moving-stones-until-consecutive/moving-stones-until-consecutive_test.go new file mode 100755 index 000000000..5cddac2a7 --- /dev/null +++ b/Algorithms/1033.moving-stones-until-consecutive/moving-stones-until-consecutive_test.go @@ -0,0 +1,55 @@ +package problem1033 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + a int + b int + c int + ans []int +}{ + + { + 1, + 2, + 5, + []int{1, 2}, + }, + + { + 4, + 3, + 2, + []int{0, 0}, + }, + + { + 3, + 5, + 1, + []int{1, 2}, + }, + + // 可以有多个 testcase +} + +func Test_numMovesStones(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numMovesStones(tc.a, tc.b, tc.c), "输入:%v", tc) + } +} + +func Benchmark_numMovesStones(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numMovesStones(tc.a, tc.b, tc.c) + } + } +} diff --git a/Algorithms/1034.coloring-a-border/README.md b/Algorithms/1034.coloring-a-border/README.md new file mode 100755 index 000000000..aeaab48c2 --- /dev/null +++ b/Algorithms/1034.coloring-a-border/README.md @@ -0,0 +1,39 @@ +# [1034. Coloring A Border](https://leetcode.com/problems/coloring-a-border/) + +Given a 2-dimensional grid of integers, each value in the grid represents the color of the grid square at that location. + +Two squares belong to the same connected component if and only if they have the same color and are next to each other in any of the 4 directions. + +The border of a connected component is all the squares in the connected component that are either 4-directionally adjacent to a square not in the component, or on the boundary of the grid (the first or last row or column). + +Given a square at location (r0, c0) in the grid and a color, color the border of the connected component of that square with the given color, and return the final grid. + +Example 1: + +```text +Input: grid = [[1,1],[1,2]], r0 = 0, c0 = 0, color = 3 +Output: [[3, 3], [3, 2]] +``` + +Example 2: + +```text +Input: grid = [[1,2,2],[2,3,2]], r0 = 0, c0 = 1, color = 3 +Output: [[1, 3, 3], [2, 3, 3]] +``` + +Example 3: + +```text +Input: grid = [[1,1,1],[1,1,1],[1,1,1]], r0 = 1, c0 = 1, color = 2 +Output: [[2, 2, 2], [2, 1, 2], [2, 2, 2]] +``` + +Note: + +1. `1 <= grid.length <= 50` +1. `1 <= grid[0].length <= 50` +1. `1 <= grid[i][j] <= 1000` +1. `0 <= r0 < grid.length` +1. `0 <= c0 < grid[0].length` +1. `1 <= color <= 1000` diff --git a/Algorithms/1034.coloring-a-border/coloring-a-border.go b/Algorithms/1034.coloring-a-border/coloring-a-border.go new file mode 100755 index 000000000..a66158b22 --- /dev/null +++ b/Algorithms/1034.coloring-a-border/coloring-a-border.go @@ -0,0 +1,52 @@ +package problem1034 + +var dx = []int{0, 0, 1, -1} +var dy = []int{1, -1, 0, 0} + +func colorBorder(grid [][]int, x0 int, y0 int, color int) [][]int { + m, n := len(grid), len(grid[0]) + c := grid[x0][y0] + + isBorder := func(x, y int) bool { + return x == 0 || x == m-1 || + y == 0 || y == n-1 || + grid[x][y-1] != c || + grid[x][y+1] != c || + grid[x-1][y] != c || + grid[x+1][y] != c + } + + connected := make([][2]int, 1, 1024) + hasSeen := [51][51]bool{} + + connected[0] = [2]int{x0, y0} + hasSeen[x0][y0] = true + + borders := make([][2]int, 0, 1024) + for len(connected) > 0 { + size := len(connected) + for i := 0; i < size; i++ { + p := connected[i] + if isBorder(p[0], p[1]) { + borders = append(borders, p) + } + for k := 0; k < 4; k++ { + x, y := p[0]+dx[k], p[1]+dy[k] + if 0 <= x && x < m && + 0 <= y && y < n && + grid[x][y] == c && + !hasSeen[x][y] { + connected = append(connected, [2]int{x, y}) + hasSeen[x][y] = true + } + } + } + connected = connected[size:] + } + + for _, b := range borders { + grid[b[0]][b[1]] = color + } + + return grid +} diff --git a/Algorithms/1034.coloring-a-border/coloring-a-border_test.go b/Algorithms/1034.coloring-a-border/coloring-a-border_test.go new file mode 100755 index 000000000..818ad996f --- /dev/null +++ b/Algorithms/1034.coloring-a-border/coloring-a-border_test.go @@ -0,0 +1,95 @@ +package problem1034 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + r0 int + c0 int + color int + ans [][]int +}{ + + { + [][]int{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 3, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}, + 0, + 0, + 3, + [][]int{ + {3, 3, 3, 3, 3}, + {3, 1, 3, 1, 3}, + {3, 3, 3, 3, 3}, + {3, 1, 3, 1, 3}, + {3, 3, 3, 3, 3}, + }, + }, + + { + [][]int{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 3, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}, + 0, + 0, + 2, + [][]int{ + {2, 2, 2, 2, 2}, + {2, 1, 2, 1, 2}, + {2, 2, 3, 2, 2}, + {2, 1, 2, 1, 2}, + {2, 2, 2, 2, 2}, + }, + }, + + { + [][]int{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}, + 2, + 2, + 2, + [][]int{{2, 2, 2, 2, 2}, {2, 1, 1, 1, 2}, {2, 1, 1, 1, 2}, {2, 1, 1, 1, 2}, {2, 2, 2, 2, 2}}, + }, + + { + [][]int{{1, 1}, {1, 2}}, + 0, + 0, + 3, + [][]int{{3, 3}, {3, 2}}, + }, + + { + [][]int{{1, 2, 2}, {2, 3, 2}}, + 0, + 1, + 3, + [][]int{{1, 3, 3}, {2, 3, 3}}, + }, + + { + [][]int{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, + 1, + 1, + 2, + [][]int{{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}, + }, + + // 可以有多个 testcase +} + +func Test_colorBorder(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, colorBorder(tc.grid, tc.r0, tc.c0, tc.color), "输入:%v", tc) + } +} + +func Benchmark_colorBorder(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + colorBorder(tc.grid, tc.r0, tc.c0, tc.color) + } + } +} diff --git a/Algorithms/1035.uncrossed-lines/1.png b/Algorithms/1035.uncrossed-lines/1.png new file mode 100644 index 000000000..c9f2f076e Binary files /dev/null and b/Algorithms/1035.uncrossed-lines/1.png differ diff --git a/Algorithms/1035.uncrossed-lines/README.md b/Algorithms/1035.uncrossed-lines/README.md new file mode 100755 index 000000000..b2fc5f696 --- /dev/null +++ b/Algorithms/1035.uncrossed-lines/README.md @@ -0,0 +1,43 @@ +# [1035. Uncrossed Lines](https://leetcode.com/problems/uncrossed-lines/) + +We write the integers of A and B (in the order they are given) on two separate horizontal lines. + +Now, we may draw connecting lines: a straight line connecting two numbers A[i] and B[j] such that: + +- `A[i] == B[j];` +- The line we draw does not intersect any other connecting (non-horizontal) line. + +Note that a connecting lines cannot intersect even at the endpoints: each number can only belong to one connecting line. + +Return the maximum number of connecting lines we can draw in this way. + +Example 1: + +![1](1.png) + +```text +Input: A = [1,4,2], B = [1,2,4] +Output: 2 +Explanation: We can draw 2 uncrossed lines as in the diagram. +We cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will intersect the line from A[2]=2 to B[1]=2. +``` + +Example 2: + +```text +Input: A = [2,5,1,2,5], B = [10,5,2,1,5,2] +Output: 3 +``` + +Example 3: + +```text +Input: A = [1,3,7,1,7,5], B = [1,9,2,5,1] +Output: 2 +``` + +Note: + +1. `1 <= A.length <= 500` +1. `1 <= B.length <= 500` +1. `1 <= A[i], B[i] <= 2000` diff --git a/Algorithms/1035.uncrossed-lines/uncrossed-lines.go b/Algorithms/1035.uncrossed-lines/uncrossed-lines.go new file mode 100755 index 000000000..30aeec927 --- /dev/null +++ b/Algorithms/1035.uncrossed-lines/uncrossed-lines.go @@ -0,0 +1,26 @@ +package problem1035 + +// ref: https://leetcode.com/problems/uncrossed-lines/discuss/282842/JavaC%2B%2BPython-DP-The-Longest-Common-Subsequence +func maxUncrossedLines(A []int, B []int) int { + m, n := len(A), len(B) + dp := make([][]int, m+1) + dp[0] = make([]int, n+1) + for i := 1; i <= m; i++ { + dp[i] = make([]int, n+1) + for j := 1; j <= n; j++ { + if A[i-1] == B[j-1] { + dp[i][j] = 1 + dp[i-1][j-1] + } else { + dp[i][j] = max(dp[i][j-1], dp[i-1][j]) + } + } + } + return dp[m][n] +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1035.uncrossed-lines/uncrossed-lines_test.go b/Algorithms/1035.uncrossed-lines/uncrossed-lines_test.go new file mode 100755 index 000000000..644fe8d7b --- /dev/null +++ b/Algorithms/1035.uncrossed-lines/uncrossed-lines_test.go @@ -0,0 +1,51 @@ +package problem1035 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + B []int + ans int +}{ + + { + []int{1, 4, 2}, + []int{1, 2, 4}, + 2, + }, + + { + []int{2, 5, 1, 2, 5}, + []int{10, 5, 2, 1, 5, 2}, + 3, + }, + + { + []int{1, 3, 7, 1, 7, 5}, + []int{1, 9, 2, 5, 1}, + 2, + }, + + // 可以有多个 testcase +} + +func Test_maxUncrossedLines(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxUncrossedLines(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_maxUncrossedLines(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxUncrossedLines(tc.A, tc.B) + } + } +} diff --git a/Algorithms/1036.escape-a-large-maze/README.md b/Algorithms/1036.escape-a-large-maze/README.md new file mode 100755 index 000000000..befd8397b --- /dev/null +++ b/Algorithms/1036.escape-a-large-maze/README.md @@ -0,0 +1,34 @@ +# [1036. Escape a Large Maze](https://leetcode.com/problems/escape-a-large-maze/) + +In a 1 million by 1 million grid, the coordinates of each grid square are (x, y) with 0 <= x, y < 10^6. + +We start at the source square and want to reach the target square. Each move, we can walk to a 4-directionally adjacent square in the grid that isn't in the given list of blocked squares. + +Return true if and only if it is possible to reach the target square through a sequence of moves. + +Example 1: + +```text +Input: blocked = [[0,1],[1,0]], source = [0,0], target = [0,2] +Output: false +Explanation: +The target square is inaccessible starting from the source square, because we can't walk outside the grid. +``` + +Example 2: + +```text +Input: blocked = [], source = [0,0], target = [999999,999999] +Output: true +Explanation: +Because there are no blocked cells, it's possible to reach the target square. +``` + +Note: + +1. `0 <= blocked.length <= 200` +1. `blocked[i].length == 2` +1. `0 <= blocked[i][j] < 10^6` +1. `source.length == target.length == 2` +1. `0 <= source[i][j], target[i][j] < 10^6` +1. `source != target` diff --git a/Algorithms/1036.escape-a-large-maze/escape-a-large-maze.go b/Algorithms/1036.escape-a-large-maze/escape-a-large-maze.go new file mode 100755 index 000000000..575827977 --- /dev/null +++ b/Algorithms/1036.escape-a-large-maze/escape-a-large-maze.go @@ -0,0 +1,56 @@ +package problem1036 + +var dx = []int{0, 0, 1, -1} +var dy = []int{1, -1, 0, 0} + +// M is length and width of the large maze +const M = 1e6 + +// MAX is the largest number of points that can be enclosed by blocked +// because of len(blocked)<=200 +const MAX = 19900 + +func isEscapePossible(blocked [][]int, source []int, target []int) bool { + isBlocked := make(map[int]bool, len(blocked)) + for _, b := range blocked { + x, y := b[0], b[1] + isBlocked[x<<32+y] = true + } + // BFS + isOpen := func(source, target []int) bool { + tx, ty := target[0], target[1] + // + points := make([][]int, 0, MAX) + hasSeen := make(map[int]bool, MAX) + // + sx, sy := source[0], source[1] + points, hasSeen[sx<<32+sy] = append(points, source), true + // + for len(points) > 0 { + size := len(points) + for i := 0; i < size; i++ { + px, py := points[i][0], points[i][1] + for k := 0; k < 4; k++ { + x, y := px+dx[k], py+dy[k] + if x == tx && y == ty { + return true + } + p := x<<32 + y + if 0 <= x && x < M && + 0 <= y && y < M && + !isBlocked[p] && + !hasSeen[p] { + points, hasSeen[p] = append(points, []int{x, y}), true + } + } + } + if len(hasSeen) > MAX { + return true + } + points = points[size:] + } + return false + } + + return isOpen(source, target) && isOpen(target, source) +} diff --git a/Algorithms/1036.escape-a-large-maze/escape-a-large-maze_test.go b/Algorithms/1036.escape-a-large-maze/escape-a-large-maze_test.go new file mode 100755 index 000000000..1660c31ff --- /dev/null +++ b/Algorithms/1036.escape-a-large-maze/escape-a-large-maze_test.go @@ -0,0 +1,62 @@ +package problem1036 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + blocked [][]int + source []int + target []int + ans bool +}{ + + { + [][]int{{0, 199}, {1, 198}, {2, 197}, {3, 196}, {4, 195}, {5, 194}, {6, 193}, {7, 192}, {8, 191}, {9, 190}, {10, 189}, {11, 188}, {12, 187}, {13, 186}, {14, 185}, {15, 184}, {16, 183}, {17, 182}, {18, 181}, {19, 180}, {20, 179}, {21, 178}, {22, 177}, {23, 176}, {24, 175}, {25, 174}, {26, 173}, {27, 172}, {28, 171}, {29, 170}, {30, 169}, {31, 168}, {32, 167}, {33, 166}, {34, 165}, {35, 164}, {36, 163}, {37, 162}, {38, 161}, {39, 160}, {40, 159}, {41, 158}, {42, 157}, {43, 156}, {44, 155}, {45, 154}, {46, 153}, {47, 152}, {48, 151}, {49, 150}, {50, 149}, {51, 148}, {52, 147}, {53, 146}, {54, 145}, {55, 144}, {56, 143}, {57, 142}, {58, 141}, {59, 140}, {60, 139}, {61, 138}, {62, 137}, {63, 136}, {64, 135}, {65, 134}, {66, 133}, {67, 132}, {68, 131}, {69, 130}, {70, 129}, {71, 128}, {72, 127}, {73, 126}, {74, 125}, {75, 124}, {76, 123}, {77, 122}, {78, 121}, {79, 120}, {80, 119}, {81, 118}, {82, 117}, {83, 116}, {84, 115}, {85, 114}, {86, 113}, {87, 112}, {88, 111}, {89, 110}, {90, 109}, {91, 108}, {92, 107}, {93, 106}, {94, 105}, {95, 104}, {96, 103}, {97, 102}, {98, 101}, {99, 100}, {100, 99}, {101, 98}, {102, 97}, {103, 96}, {104, 95}, {105, 94}, {106, 93}, {107, 92}, {108, 91}, {109, 90}, {110, 89}, {111, 88}, {112, 87}, {113, 86}, {114, 85}, {115, 84}, {116, 83}, {117, 82}, {118, 81}, {119, 80}, {120, 79}, {121, 78}, {122, 77}, {123, 76}, {124, 75}, {125, 74}, {126, 73}, {127, 72}, {128, 71}, {129, 70}, {130, 69}, {131, 68}, {132, 67}, {133, 66}, {134, 65}, {135, 64}, {136, 63}, {137, 62}, {138, 61}, {139, 60}, {140, 59}, {141, 58}, {142, 57}, {143, 56}, {144, 55}, {145, 54}, {146, 53}, {147, 52}, {148, 51}, {149, 50}, {150, 49}, {151, 48}, {152, 47}, {153, 46}, {154, 45}, {155, 44}, {156, 43}, {157, 42}, {158, 41}, {159, 40}, {160, 39}, {161, 38}, {162, 37}, {163, 36}, {164, 35}, {165, 34}, {166, 33}, {167, 32}, {168, 31}, {169, 30}, {170, 29}, {171, 28}, {172, 27}, {173, 26}, {174, 25}, {175, 24}, {176, 23}, {177, 22}, {178, 21}, {179, 20}, {180, 19}, {181, 18}, {182, 17}, {183, 16}, {184, 15}, {185, 14}, {186, 13}, {187, 12}, {188, 11}, {189, 10}, {190, 9}, {191, 8}, {192, 7}, {193, 6}, {194, 5}, {195, 4}, {196, 3}, {197, 2}, {198, 1}, {199, 0}}, + []int{0, 0}, + []int{50, 50}, + true, + }, + + { + [][]int{{0, 199}, {1, 198}, {2, 197}, {3, 196}, {4, 195}, {5, 194}, {6, 193}, {7, 192}, {8, 191}, {9, 190}, {10, 189}, {11, 188}, {12, 187}, {13, 186}, {14, 185}, {15, 184}, {16, 183}, {17, 182}, {18, 181}, {19, 180}, {20, 179}, {21, 178}, {22, 177}, {23, 176}, {24, 175}, {25, 174}, {26, 173}, {27, 172}, {28, 171}, {29, 170}, {30, 169}, {31, 168}, {32, 167}, {33, 166}, {34, 165}, {35, 164}, {36, 163}, {37, 162}, {38, 161}, {39, 160}, {40, 159}, {41, 158}, {42, 157}, {43, 156}, {44, 155}, {45, 154}, {46, 153}, {47, 152}, {48, 151}, {49, 150}, {50, 149}, {51, 148}, {52, 147}, {53, 146}, {54, 145}, {55, 144}, {56, 143}, {57, 142}, {58, 141}, {59, 140}, {60, 139}, {61, 138}, {62, 137}, {63, 136}, {64, 135}, {65, 134}, {66, 133}, {67, 132}, {68, 131}, {69, 130}, {70, 129}, {71, 128}, {72, 127}, {73, 126}, {74, 125}, {75, 124}, {76, 123}, {77, 122}, {78, 121}, {79, 120}, {80, 119}, {81, 118}, {82, 117}, {83, 116}, {84, 115}, {85, 114}, {86, 113}, {87, 112}, {88, 111}, {89, 110}, {90, 109}, {91, 108}, {92, 107}, {93, 106}, {94, 105}, {95, 104}, {96, 103}, {97, 102}, {98, 101}, {99, 100}, {100, 99}, {101, 98}, {102, 97}, {103, 96}, {104, 95}, {105, 94}, {106, 93}, {107, 92}, {108, 91}, {109, 90}, {110, 89}, {111, 88}, {112, 87}, {113, 86}, {114, 85}, {115, 84}, {116, 83}, {117, 82}, {118, 81}, {119, 80}, {120, 79}, {121, 78}, {122, 77}, {123, 76}, {124, 75}, {125, 74}, {126, 73}, {127, 72}, {128, 71}, {129, 70}, {130, 69}, {131, 68}, {132, 67}, {133, 66}, {134, 65}, {135, 64}, {136, 63}, {137, 62}, {138, 61}, {139, 60}, {140, 59}, {141, 58}, {142, 57}, {143, 56}, {144, 55}, {145, 54}, {146, 53}, {147, 52}, {148, 51}, {149, 50}, {150, 49}, {151, 48}, {152, 47}, {153, 46}, {154, 45}, {155, 44}, {156, 43}, {157, 42}, {158, 41}, {159, 40}, {160, 39}, {161, 38}, {162, 37}, {163, 36}, {164, 35}, {165, 34}, {166, 33}, {167, 32}, {168, 31}, {169, 30}, {170, 29}, {171, 28}, {172, 27}, {173, 26}, {174, 25}, {175, 24}, {176, 23}, {177, 22}, {178, 21}, {179, 20}, {180, 19}, {181, 18}, {182, 17}, {183, 16}, {184, 15}, {185, 14}, {186, 13}, {187, 12}, {188, 11}, {189, 10}, {190, 9}, {191, 8}, {192, 7}, {193, 6}, {194, 5}, {195, 4}, {196, 3}, {197, 2}, {198, 1}, {199, 0}}, + []int{0, 0}, + []int{200, 200}, + false, + }, + + { + [][]int{{0, 1}, {1, 0}}, + []int{0, 0}, + []int{0, 2}, + false, + }, + + { + [][]int{}, + []int{0, 0}, + []int{999999, 999999}, + true, + }, + + // 可以有多个 testcase +} + +func Test_isEscapePossible(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, isEscapePossible(tc.blocked, tc.source, tc.target), "输入:%v", tc) + } +} + +func Benchmark_isEscapePossible(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isEscapePossible(tc.blocked, tc.source, tc.target) + } + } +} diff --git a/Algorithms/1037.valid-boomerang/README.md b/Algorithms/1037.valid-boomerang/README.md new file mode 100755 index 000000000..001404bf1 --- /dev/null +++ b/Algorithms/1037.valid-boomerang/README.md @@ -0,0 +1,25 @@ +# [1037. Valid Boomerang](https://leetcode.com/problems/valid-boomerang/) + +A boomerang is a set of 3 points that are all distinct and not in a straight line. + +Given a list of three points in the plane, return whether these points are a boomerang. + +Example 1: + +```text +Input: [[1,1],[2,3],[3,2]] +Output: true +``` + +Example 2: + +```text +Input: [[1,1],[2,2],[3,3]] +Output: false +``` + +Note: + +1. `points.length == 3` +1. `points[i].length == 2` +1. `0 <= points[i][j] <= 100` diff --git a/Algorithms/1037.valid-boomerang/valid-boomerang.go b/Algorithms/1037.valid-boomerang/valid-boomerang.go new file mode 100755 index 000000000..3e7b20ec9 --- /dev/null +++ b/Algorithms/1037.valid-boomerang/valid-boomerang.go @@ -0,0 +1,8 @@ +package problem1037 + +func isBoomerang(p [][]int) bool { + x0, y0 := p[0][0], p[0][1] + x1, y1 := p[1][0], p[1][1] + x2, y2 := p[2][0], p[2][1] + return (x0-x2)*(y1-y2) != (y0-y2)*(x1-x2) +} diff --git a/Algorithms/1037.valid-boomerang/valid-boomerang_test.go b/Algorithms/1037.valid-boomerang/valid-boomerang_test.go new file mode 100755 index 000000000..15d316f90 --- /dev/null +++ b/Algorithms/1037.valid-boomerang/valid-boomerang_test.go @@ -0,0 +1,42 @@ +package problem1037 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + points [][]int + ans bool +}{ + + { + [][]int{{1, 1}, {2, 3}, {3, 2}}, + true, + }, + + { + [][]int{{1, 1}, {2, 2}, {3, 3}}, + false, + }, + + // 可以有多个 testcase +} + +func Test_isBoomerang(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, isBoomerang(tc.points), "输入:%v", tc) + } +} + +func Benchmark_isBoomerang(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isBoomerang(tc.points) + } + } +} diff --git a/Algorithms/1038.binary-search-tree-to-greater-sum-tree/README.md b/Algorithms/1038.binary-search-tree-to-greater-sum-tree/README.md new file mode 100755 index 000000000..a2147be40 --- /dev/null +++ b/Algorithms/1038.binary-search-tree-to-greater-sum-tree/README.md @@ -0,0 +1,24 @@ +# [1038. Binary Search Tree to Greater Sum Tree](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/) + +Given the root of a binary search tree with distinct values, modify it so that every node has a new value equal to the sum of the values of the original tree that are greater than or equal to node.val. + +As a reminder, a binary search tree is a tree that satisfies these constraints: + +- The left subtree of a node contains only nodes with keys less than the node's key. +- The right subtree of a node contains only nodes with keys greater than the node's key. +- Both the left and right subtrees must also be binary search trees. + +Example 1: + +![tree](tree.png) + +```text +Input: [4,1,6,0,2,5,7,null,null,null,3,null,null,null,8] +Output: [30,36,21,36,35,26,15,null,null,null,33,null,null,null,8] +``` + +Note: + +1. The number of nodes in the tree is between 1 and 100. +1. Each node will have value between 0 and 100. +1. The given tree is a binary search tree. diff --git a/Algorithms/1038.binary-search-tree-to-greater-sum-tree/binary-search-tree-to-greater-sum-tree.go b/Algorithms/1038.binary-search-tree-to-greater-sum-tree/binary-search-tree-to-greater-sum-tree.go new file mode 100755 index 000000000..38a3e57b7 --- /dev/null +++ b/Algorithms/1038.binary-search-tree-to-greater-sum-tree/binary-search-tree-to-greater-sum-tree.go @@ -0,0 +1,24 @@ +package problem1038 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func bstToGst(root *TreeNode) *TreeNode { + dfs(root, 0) + return root +} + +func dfs(node *TreeNode, sum int) int { + if node == nil { + return sum + } + node.Val += dfs(node.Right, sum) + return dfs(node.Left, node.Val) +} diff --git a/Algorithms/1038.binary-search-tree-to-greater-sum-tree/binary-search-tree-to-greater-sum-tree_test.go b/Algorithms/1038.binary-search-tree-to-greater-sum-tree/binary-search-tree-to-greater-sum-tree_test.go new file mode 100755 index 000000000..96267c8f9 --- /dev/null +++ b/Algorithms/1038.binary-search-tree-to-greater-sum-tree/binary-search-tree-to-greater-sum-tree_test.go @@ -0,0 +1,41 @@ +package problem1038 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans []int +}{ + + { + []int{4, 1, 6, 0, 2, 5, 7, kit.NULL, kit.NULL, kit.NULL, 3, kit.NULL, kit.NULL, kit.NULL, 8}, + []int{30, 36, 21, 36, 35, 26, 15, kit.NULL, kit.NULL, kit.NULL, 33, kit.NULL, kit.NULL, kit.NULL, 8}, + }, + + // 可以有多个 testcase +} + +func Test_bstToGst(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ans := kit.Ints2TreeNode(tc.ans) + root := kit.Ints2TreeNode(tc.root) + ast.Equal(ans, bstToGst(root), "输入:%v", tc) + } +} + +func Benchmark_bstToGst(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + bstToGst(root) + } + } +} diff --git a/Algorithms/1038.binary-search-tree-to-greater-sum-tree/tree.png b/Algorithms/1038.binary-search-tree-to-greater-sum-tree/tree.png new file mode 100644 index 000000000..fb2cfb543 Binary files /dev/null and b/Algorithms/1038.binary-search-tree-to-greater-sum-tree/tree.png differ diff --git a/Algorithms/1039.minimum-score-triangulation-of-polygon/2.png b/Algorithms/1039.minimum-score-triangulation-of-polygon/2.png new file mode 100644 index 000000000..e02318f5b Binary files /dev/null and b/Algorithms/1039.minimum-score-triangulation-of-polygon/2.png differ diff --git a/Algorithms/1039.minimum-score-triangulation-of-polygon/README.md b/Algorithms/1039.minimum-score-triangulation-of-polygon/README.md new file mode 100755 index 000000000..e0fa9b1ef --- /dev/null +++ b/Algorithms/1039.minimum-score-triangulation-of-polygon/README.md @@ -0,0 +1,38 @@ +# [1039. Minimum Score Triangulation of Polygon](https://leetcode.com/problems/minimum-score-triangulation-of-polygon/) + +Given N, consider a convex N-sided polygon with vertices labelled A[0], A[i], ..., A[N-1] in clockwise order. + +Suppose you triangulate the polygon into N-2 triangles. For each triangle, the value of that triangle is the product of the labels of the vertices, and the total score of the triangulation is the sum of these values over all N-2 triangles in the triangulation. + +Return the smallest possible total score that you can achieve with some triangulation of the polygon. + +Example 1: + +```text +Input: [1,2,3] +Output: 6 +Explanation: The polygon is already triangulated, and the score of the only triangle is 6. +``` + +Example 2: + +![2](2.png) + +```text +Input: [3,7,4,5] +Output: 144 +Explanation: There are two triangulations, with possible scores: 3*7*5 + 4*5*7 = 245, or 3*4*5 + 3*4*7 = 144. The minimum score is 144. +``` + +Example 3: + +```text +Input: [1,3,1,4,1,5] +Output: 13 +Explanation: The minimum score triangulation has score 1*1*3 + 1*1*4 + 1*1*5 + 1*1*1 = 13. +``` + +Note: + +1. `3 <= A.length <= 50` +1. `1 <= A[i] <= 100` diff --git a/Algorithms/1039.minimum-score-triangulation-of-polygon/minimum-score-triangulation-of-polygon.go b/Algorithms/1039.minimum-score-triangulation-of-polygon/minimum-score-triangulation-of-polygon.go new file mode 100755 index 000000000..218d93dec --- /dev/null +++ b/Algorithms/1039.minimum-score-triangulation-of-polygon/minimum-score-triangulation-of-polygon.go @@ -0,0 +1,23 @@ +package problem1039 + +func minScoreTriangulation(A []int) int { + n := len(A) + dp := [50][50]int{} + for d := 2; d < n; d++ { + for i := 0; i+d < n; i++ { + k := i + d + dp[i][k] = 1 << 30 + for j := i + 1; j < k; j++ { + dp[i][k] = min(dp[i][k], dp[i][j]+dp[j][k]+A[i]*A[j]*A[k]) + } + } + } + return dp[0][n-1] +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1039.minimum-score-triangulation-of-polygon/minimum-score-triangulation-of-polygon_test.go b/Algorithms/1039.minimum-score-triangulation-of-polygon/minimum-score-triangulation-of-polygon_test.go new file mode 100755 index 000000000..346d824ec --- /dev/null +++ b/Algorithms/1039.minimum-score-triangulation-of-polygon/minimum-score-triangulation-of-polygon_test.go @@ -0,0 +1,62 @@ +package problem1039 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans int +}{ + + { + []int{1, 2, 3, 4, 1, 6, 7, 8, 1, 10, 12}, + 255, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8, 9}, + 238, + }, + + { + []int{2, 2, 2, 2, 1}, + 12, + }, + + { + []int{1, 3, 1, 4, 1, 5}, + 13, + }, + + { + []int{1, 2, 3}, + 6, + }, + + { + []int{3, 7, 4, 5}, + 144, + }, + + // 可以有多个 testcase +} + +func Test_minScoreTriangulation(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minScoreTriangulation(tc.A), "输入:%v", tc) + } +} + +func Benchmark_minScoreTriangulation(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minScoreTriangulation(tc.A) + } + } +} diff --git a/Algorithms/1040.moving-stones-until-consecutive-ii/README.md b/Algorithms/1040.moving-stones-until-consecutive-ii/README.md new file mode 100755 index 000000000..6464812d7 --- /dev/null +++ b/Algorithms/1040.moving-stones-until-consecutive-ii/README.md @@ -0,0 +1,44 @@ +# [1040. Moving Stones Until Consecutive II](https://leetcode.com/problems/moving-stones-until-consecutive-ii/) + +On an infinite number line, the position of the i-th stone is given by stones[i]. Call a stone an endpoint stone if it has the smallest or largest position. + +Each turn, you pick up an endpoint stone and move it to an unoccupied position so that it is no longer an endpoint stone. + +In particular, if the stones are at say, stones = [1,2,5], you cannot move the endpoint stone at position 5, since moving it to any position (such as 0, or 3) will still keep that stone as an endpoint stone. + +The game ends when you cannot make any more moves, ie. the stones are in consecutive positions. + +When the game ends, what is the minimum and maximum number of moves that you could have made? Return the answer as an length 2 array: answer = [minimum_moves, maximum_moves] + +Example 1: + +```text +Input: [7,4,9] +Output: [1,2] +Explanation: +We can move 4 -> 8 for one move to finish the game. +Or, we can move 9 -> 5, 4 -> 6 for two moves to finish the game. +``` + +Example 2: + +```text +Input: [6,5,4,3,10] +Output: [2,3] +We can move 3 -> 8 then 10 -> 7 to finish the game. +Or, we can move 3 -> 7, 4 -> 8, 5 -> 9 to finish the game. +Notice we cannot move 10 -> 2 to finish the game, because that would be an illegal move. +``` + +Example 3: + +```text +Input: [100,101,104,102,103] +Output: [0,0] +``` + +Note: + +1. `3 <= stones.length <= 10^4` +1. `1 <= stones[i] <= 10^9` +1. `stones[i] have distinct values.` diff --git a/Algorithms/1040.moving-stones-until-consecutive-ii/moving-stones-until-consecutive-ii.go b/Algorithms/1040.moving-stones-until-consecutive-ii/moving-stones-until-consecutive-ii.go new file mode 100755 index 000000000..542543e1c --- /dev/null +++ b/Algorithms/1040.moving-stones-until-consecutive-ii/moving-stones-until-consecutive-ii.go @@ -0,0 +1,42 @@ +package problem1040 + +import "sort" + +func numMovesStonesII(stones []int) []int { + sort.Ints(stones) + return []int{low(stones), high(stones)} +} + +func high(s []int) int { + n := len(s) + return max(s[n-1]-s[1], s[n-2]-s[0]) - n + 2 +} + +func low(s []int) int { + n := len(s) + // corner case + if (s[n-2]-s[0] == n-2 && s[n-1]-s[n-2] > 2) || + (s[n-1]-s[1] == n-2 && s[1]-s[0] > 2) { + return 2 + } + // sliding window is s[i:j] + width, i, j := 0, 0, 1 + for ; j < n; j++ { + if s[j]-s[i] < n { + continue + } + width = max(width, j-i) + i = j + } + width = max(width, j-i) + // finally, all stone move into maxWidth windows + // so need move n-width stones + return n - width +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1040.moving-stones-until-consecutive-ii/moving-stones-until-consecutive-ii_test.go b/Algorithms/1040.moving-stones-until-consecutive-ii/moving-stones-until-consecutive-ii_test.go new file mode 100755 index 000000000..96044a14b --- /dev/null +++ b/Algorithms/1040.moving-stones-until-consecutive-ii/moving-stones-until-consecutive-ii_test.go @@ -0,0 +1,97 @@ +package problem1040 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + stones []int + ans []int +}{ + + { + []int{6, 5, 4, 3, 10}, + []int{2, 3}, + }, + + { + []int{1, 2, 3, 4, 5, 111, 112, 113, 114, 115}, + []int{5, 105}, + }, + + { + []int{1, 2, 3, 4, 5, 11, 12, 13, 14, 15}, + []int{5, 5}, + }, + + { + []int{1, 3, 900, 904, 1000}, + []int{3, 994}, + }, + + { + []int{1, 50, 900, 905, 170000}, + []int{4, 169947}, + }, + + { + []int{1, 50, 900, 904, 170000}, + []int{3, 169947}, + }, + + { + []int{1, 50, 900, 13000, 170000}, + []int{4, 169947}, + }, + + { + []int{4, 8, 9}, + []int{2, 3}, + }, + + { + []int{1, 5, 9}, + []int{2, 3}, + }, + + { + []int{1, 5, 9, 13}, + []int{3, 6}, + }, + + { + []int{1, 50, 900, 13000}, + []int{3, 12948}, + }, + + { + []int{7, 4, 9}, + []int{1, 2}, + }, + + { + []int{100, 101, 104, 102, 103}, + []int{0, 0}, + }, + + // 可以有多个 testcase +} + +func Test_numMovesStonesII(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numMovesStonesII(tc.stones), "输入:%v", tc) + } +} + +func Benchmark_numMovesStonesII(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numMovesStonesII(tc.stones) + } + } +} diff --git a/Algorithms/1041.robot-bounded-in-circle/README.md b/Algorithms/1041.robot-bounded-in-circle/README.md new file mode 100755 index 000000000..a252229c2 --- /dev/null +++ b/Algorithms/1041.robot-bounded-in-circle/README.md @@ -0,0 +1,44 @@ +# [1041. Robot Bounded In Circle](https://leetcode.com/problems/robot-bounded-in-circle/) + +On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can receive one of three instructions: + +- "G": go straight 1 unit; +- "L": turn 90 degrees to the left; +- "R": turn 90 degrees to the right. + +The robot performs the instructions given in order, and repeats them forever. + +Return true if and only if there exists a circle in the plane such that the robot never leaves the circle. + +Example 1: + +```text +Input: "GGLLGG" +Output: true +Explanation: +The robot moves from (0,0) to (0,2), turns 180 degrees, and then returns to (0,0). +When repeating these instructions, the robot remains in the circle of radius 2 centered at the origin. +``` + +Example 2: + +```text +Input: "GG" +Output: false +Explanation: +The robot moves north indefinitely. +``` + +Example 3: + +```text +Input: "GL" +Output: true +Explanation: +The robot moves from (0, 0) -> (0, 1) -> (-1, 1) -> (-1, 0) -> (0, 0) -> ... +``` + +Note: + +1. `1 <= instructions.length <= 100` +1. `instructions[i] is in {'G', 'L', 'R'}` diff --git a/Algorithms/1041.robot-bounded-in-circle/robot-bounded-in-circle.go b/Algorithms/1041.robot-bounded-in-circle/robot-bounded-in-circle.go new file mode 100755 index 000000000..f48b6cc00 --- /dev/null +++ b/Algorithms/1041.robot-bounded-in-circle/robot-bounded-in-circle.go @@ -0,0 +1,61 @@ +package problem1041 + +func isRobotBounded(instructions string) bool { + print(north, east, south, west) + r := newRobot() + for _, i := range instructions { + r.receive(i) + } + return (r.x == 0 && r.y == 0) || // 每轮都会回到原点,就永远会回到原点 + (r.d != north) // 第一轮后,没有回到原点,但是方向改变,至多 4 轮后,还是会回到原点 +} + +type direction int + +const ( + north direction = iota + east + south + west +) + +type robot struct { + d direction + x, y int +} + +func newRobot() *robot { + return &robot{ + d: north, + } +} + +func (r *robot) receive(instruction rune) { + if instruction == 'G' { + r.move() + } else { + r.turn(instruction) + } +} + +func (r *robot) move() { + switch r.d { + case north: + r.y++ + case east: + r.x++ + case south: + r.y-- + case west: + r.x-- + } +} + +func (r *robot) turn(instruction rune) { + if instruction == 'R' { + r.d++ + } else { + r.d += 3 + } + r.d %= 4 +} diff --git a/Algorithms/1041.robot-bounded-in-circle/robot-bounded-in-circle_test.go b/Algorithms/1041.robot-bounded-in-circle/robot-bounded-in-circle_test.go new file mode 100755 index 000000000..71ccc6a85 --- /dev/null +++ b/Algorithms/1041.robot-bounded-in-circle/robot-bounded-in-circle_test.go @@ -0,0 +1,62 @@ +package problem1041 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + instructions string + ans bool +}{ + + { + "GLRLLGLL", + true, + }, + + { + "GLGLGGLGL", + false, + }, + + { + "LL", + true, + }, + + { + "GGLLGG", + true, + }, + + { + "GG", + false, + }, + + { + "GL", + true, + }, + + // 可以有多个 testcase +} + +func Test_isRobotBounded(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, isRobotBounded(tc.instructions), "输入:%v", tc) + } +} + +func Benchmark_isRobotBounded(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + isRobotBounded(tc.instructions) + } + } +} diff --git a/Algorithms/1042.flower-planting-with-no-adjacent/README.md b/Algorithms/1042.flower-planting-with-no-adjacent/README.md new file mode 100755 index 000000000..22aa64e14 --- /dev/null +++ b/Algorithms/1042.flower-planting-with-no-adjacent/README.md @@ -0,0 +1,39 @@ +# [1042. Flower Planting With No Adjacent](https://leetcode.com/problems/flower-planting-with-no-adjacent/) + +You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 types of flowers. + +paths[i] = [x, y] describes the existence of a bidirectional path from garden x to garden y. + +Also, there is no garden that has more than 3 paths coming into or leaving it. + +Your task is to choose a flower type for each garden such that, for any two gardens connected by a path, they have different types of flowers. + +Return any such a choice as an array answer, where answer[i] is the type of flower planted in the (i+1)-th garden. The flower types are denoted 1, 2, 3, or 4. It is guaranteed an answer exists. + +Example 1: + +```text +Input: N = 3, paths = [[1,2],[2,3],[3,1]] +Output: [1,2,3] +``` + +Example 2: + +```text +Input: N = 4, paths = [[1,2],[3,4]] +Output: [1,2,1,2] +``` + +Example 3: + +```text +Input: N = 4, paths = [[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]] +Output: [1,2,3,4] +``` + +Note: + +1. `1 <= N <= 10000` +1. `0 <= paths.size <= 20000` +1. `No garden has 4 or more paths coming into or leaving it.` +1. `It is guaranteed an answer exists.` diff --git a/Algorithms/1042.flower-planting-with-no-adjacent/flower-planting-with-no-adjacent.go b/Algorithms/1042.flower-planting-with-no-adjacent/flower-planting-with-no-adjacent.go new file mode 100755 index 000000000..f39b5df43 --- /dev/null +++ b/Algorithms/1042.flower-planting-with-no-adjacent/flower-planting-with-no-adjacent.go @@ -0,0 +1,24 @@ +package problem1042 + +func gardenNoAdj(N int, paths [][]int) []int { + connects := make([][]int, N) + for _, p := range paths { + i, j := p[0]-1, p[1]-1 // i,j = x-1, y-1 + connects[i] = append(connects[i], j) + connects[j] = append(connects[j], i) + } + res := make([]int, N) + for i := 0; i < N; i++ { + isUsed := [5]bool{} + for _, j := range connects[i] { + isUsed[res[j]] = true + } + for color := 1; color <= 4; color++ { + if !isUsed[color] { + res[i] = color + break + } + } + } + return res +} diff --git a/Algorithms/1042.flower-planting-with-no-adjacent/flower-planting-with-no-adjacent_test.go b/Algorithms/1042.flower-planting-with-no-adjacent/flower-planting-with-no-adjacent_test.go new file mode 100755 index 000000000..d3e49e841 --- /dev/null +++ b/Algorithms/1042.flower-planting-with-no-adjacent/flower-planting-with-no-adjacent_test.go @@ -0,0 +1,57 @@ +package problem1042 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + N int + paths [][]int + ans []int +}{ + + { + 5, + [][]int{{4, 1}, {4, 2}, {4, 3}, {2, 5}, {1, 2}, {1, 5}}, + []int{1, 2, 1, 3, 3}, + }, + + { + 3, + [][]int{{1, 2}, {2, 3}, {3, 1}}, + []int{1, 2, 3}, + }, + + { + 4, + [][]int{{1, 2}, {3, 4}}, + []int{1, 2, 1, 2}, + }, + + { + 4, + [][]int{{1, 2}, {2, 3}, {3, 4}, {4, 1}, {1, 3}, {2, 4}}, + []int{1, 2, 3, 4}, + }, + + // 可以有多个 testcase +} + +func Test_gardenNoAdj(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, gardenNoAdj(tc.N, tc.paths), "输入:%v", tc) + } +} + +func Benchmark_gardenNoAdj(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + gardenNoAdj(tc.N, tc.paths) + } + } +} diff --git a/Algorithms/1043.partition-array-for-maximum-sum/README.md b/Algorithms/1043.partition-array-for-maximum-sum/README.md new file mode 100755 index 000000000..e1c3a8e9b --- /dev/null +++ b/Algorithms/1043.partition-array-for-maximum-sum/README.md @@ -0,0 +1,18 @@ +# [1043. Partition Array for Maximum Sum](https://leetcode.com/problems/partition-array-for-maximum-sum/) + +Given an integer array A, you partition the array into (contiguous) subarrays of length at most K. After partitioning, each subarray has their values changed to become the maximum value of that subarray. + +Return the largest sum of the given array after partitioning. + +Example 1: + +```text +Input: A = [1,15,7,9,2,5,10], K = 3 +Output: 84 +Explanation: A becomes [15,15,15,9,10,10,10] +``` + +Note: + +1. `1 <= K <= A.length <= 500` +1. `0 <= A[i] <= 10^6` diff --git a/Algorithms/1043.partition-array-for-maximum-sum/partition-array-for-maximum-sum.go b/Algorithms/1043.partition-array-for-maximum-sum/partition-array-for-maximum-sum.go new file mode 100755 index 000000000..f38f2be4f --- /dev/null +++ b/Algorithms/1043.partition-array-for-maximum-sum/partition-array-for-maximum-sum.go @@ -0,0 +1,24 @@ +package problem1043 + +// ref: https://leetcode.com/problems/partition-array-for-maximum-sum/discuss/290863/JavaC%2B%2BPython-DP +func maxSumAfterPartitioning(A []int, K int) int { + n := len(A) + dp := make([]int, n+1) + // A's length grows up from 1 to n + for l := 1; l <= n; l++ { + m := 0 // max value of last k items in A[:l] + for k := 1; k <= K && 0 <= l-k; k++ { + m = max(m, A[l-k]) + sum := dp[l-k] + m*k + dp[l] = max(dp[l], sum) + } + } + return dp[n] +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1043.partition-array-for-maximum-sum/partition-array-for-maximum-sum_test.go b/Algorithms/1043.partition-array-for-maximum-sum/partition-array-for-maximum-sum_test.go new file mode 100755 index 000000000..fa09166f5 --- /dev/null +++ b/Algorithms/1043.partition-array-for-maximum-sum/partition-array-for-maximum-sum_test.go @@ -0,0 +1,57 @@ +package problem1043 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + K int + ans int +}{ + + { + []int{322257, 540837, 18171, 364098, 161511, 717990, 678976, 295957, 525576, 912910, 302841, 807371, 774141, 973354, 343843, 742131, 839995, 111282, 772395, 5921, 122534, 750377, 683899, 734664, 184593, 789400, 626212, 809214, 934136, 163420, 452442, 713789, 269552, 932607, 172046, 89529, 277733, 222352, 957023, 867042, 160651, 259497, 476642, 978097, 212742, 714383, 932052, 399211, 894147, 766649, 409010, 763214, 459126, 833028, 777826, 294076, 17566, 538156, 124552, 641, 606726, 429007, 507307, 360562, 133147, 833321, 496061, 966033, 801581, 695725, 323273, 888523, 260890, 835191, 305749, 410437, 505257, 235238, 535199, 66423, 63758, 654191, 288667, 760215, 837132, 41380, 256744, 474781, 302571, 486974, 93945, 417524, 733278, 338240, 165821, 938705, 722138, 676130, 887649, 130572, 585556, 126289, 508926, 355353, 812298, 138788, 751157, 20720, 832600, 562373, 529647, 819221, 57234, 345991, 129691, 240013, 224203, 436010, 969914, 320771, 512865, 735790, 299628, 724880, 359109, 295235, 352639, 514634, 527186, 352191, 958072, 281078, 286045, 983549, 222715, 419519, 234599, 439778, 344828, 901962, 266790, 572029, 551645, 775030, 433586, 852788, 654154, 709948, 707145, 940333, 434841, 548197, 535555, 302255, 99577, 468017, 258874, 244736, 779744, 582486, 66596, 582593, 206343, 571625, 543211, 948901, 259730, 720218, 391355, 4441, 512392, 256717, 264162, 689384, 108804, 743139, 456167, 622153, 34594, 642958, 682978, 492462, 960588, 544889, 59853, 618158, 826481, 46500, 848227, 441833, 60210, 971753, 993798, 106622, 265063, 323422, 150184, 927954, 7368, 233027, 803151, 715037, 741914, 576419, 862192, 47536, 876455, 190304, 672899, 263957, 308829, 925787, 99541, 311184, 654650, 247786, 236849, 372981, 976532, 975655, 893372, 744998, 33851, 914471, 790591, 958015, 559603, 597950, 283947, 386643, 168667, 867857, 105367, 528454, 73767, 928997, 534173, 723272, 416051, 878341, 753212, 446378, 375998, 65721, 866187, 33706, 449084, 397460, 850849, 111453, 747319, 501296, 115045, 712431, 34914, 744459, 665120, 548829, 680009, 889090, 804508, 1131, 216652, 592160, 619079, 250083, 451008, 387734, 221043, 34718, 503942, 807191, 890799, 403017, 558917, 187498, 753156, 161889, 326616, 748336, 753942, 648694, 225315, 388228, 418217, 916129, 435637, 152945, 353274, 51543, 819598, 320869, 329985, 708486, 555732, 291431, 566179, 195921, 708680, 723429, 62059, 617193, 713490, 839672, 427061, 787674, 658480, 758624, 426935, 87777, 146592, 143149, 691270, 228944, 21659, 912288, 405247, 274058, 156786, 742941, 346777, 474383, 355448, 568771, 666124, 677562, 765587, 858179, 528256, 961677, 611111, 818806, 897460, 208616, 659738, 64081, 207641, 889609, 892033, 133501, 266857, 621606, 794935, 396372, 567053, 52331, 582094, 104977, 569902, 496245, 390154, 550784, 55238, 641297, 23741, 860725, 861067, 283503, 924066, 404874, 392211, 897657, 46748, 490894, 304656, 751827, 221437, 730461, 421321, 695259, 158087, 259472, 14837, 744332, 850752, 149834, 924528, 43174, 374614, 567583, 410071, 636843, 783718, 844101, 951446, 703700, 201046, 511629, 145996, 54378, 241686, 285229, 2299, 992962, 948612, 215175, 710462, 977662, 184503, 939465, 439086, 18999, 536186, 659815, 203013, 965787, 255983, 456806, 840014, 261442, 770277, 955892, 940019, 884343, 686299, 676304, 716247, 11141, 236451, 124411, 478090, 680125, 175743, 178750, 461502, 633006, 694179, 47960, 21926, 320034, 524028, 732852, 603541, 799317, 334915, 276857, 253882, 262465, 828135, 394678, 384312, 922363, 222351, 746409, 20062, 157582, 131931, 252307, 626638, 78825, 767279, 505875, 153744, 975663, 64725, 826981, 427925, 926691, 748580, 289254, 3199, 561583, 109612, 470102, 130143, 583840, 224354, 775172, 609376, 235902, 351312, 271143, 575355, 324896, 787099, 855052, 748572, 999311, 926808, 139753, 866799, 537768, 788685, 199740, 950081, 835325, 162448, 518463, 781043, 752546, 985988, 237700, 801304, 846762, 254587, 448003, 91525, 308020, 237083, 12293}, + 30, + 483667362, + }, + + { + []int{322257, 540837, 18171, 364098, 161511, 717990, 678976, 295957, 525576, 912910, 302841, 807371, 774141, 973354, 343843, 742131, 839995, 111282, 772395, 5921, 122534, 750377, 683899, 734664, 184593, 789400, 626212, 809214, 934136, 163420, 452442, 713789, 269552, 932607, 172046, 89529, 277733, 222352, 957023, 867042, 160651, 259497, 476642, 978097, 212742, 714383, 932052, 399211, 894147, 766649, 409010, 763214, 459126, 833028, 777826, 294076, 17566, 538156, 124552, 641, 606726, 429007, 507307, 360562, 133147, 833321, 496061, 966033, 801581, 695725, 323273, 888523, 260890, 835191, 305749, 410437, 505257, 235238, 535199, 66423, 63758, 654191, 288667, 760215, 837132, 41380, 256744, 474781, 302571, 486974, 93945, 417524, 733278, 338240, 165821, 938705, 722138, 676130, 887649, 130572, 585556, 126289, 508926, 355353, 812298, 138788, 751157, 20720, 832600, 562373, 529647, 819221, 57234, 345991, 129691, 240013, 224203, 436010, 969914, 320771, 512865, 735790, 299628, 724880, 359109, 295235, 352639, 514634, 527186, 352191, 958072, 281078, 286045, 983549, 222715, 419519, 234599, 439778, 344828, 901962, 266790, 572029, 551645, 775030, 433586, 852788, 654154, 709948, 707145, 940333, 434841, 548197, 535555, 302255, 99577, 468017, 258874, 244736, 779744, 582486, 66596, 582593, 206343, 571625, 543211, 948901, 259730, 720218, 391355, 4441, 512392, 256717, 264162, 689384, 108804, 743139, 456167, 622153, 34594, 642958, 682978, 492462, 960588, 544889, 59853, 618158, 826481, 46500, 848227, 441833, 60210, 971753, 993798, 106622, 265063, 323422, 150184, 927954, 7368, 233027, 803151, 715037, 741914, 576419, 862192, 47536, 876455, 190304, 672899, 263957, 308829, 925787, 99541, 311184, 654650, 247786, 236849, 372981, 976532, 975655, 893372, 744998, 33851, 914471, 790591, 958015, 559603, 597950, 283947, 386643, 168667, 867857, 105367, 528454, 73767, 928997, 534173, 723272, 416051, 878341, 753212, 446378, 375998, 65721, 866187, 33706, 449084, 397460, 850849, 111453, 747319, 501296, 115045, 712431, 34914, 744459, 665120, 548829, 680009, 889090, 804508, 1131, 216652, 592160, 619079, 250083, 451008, 387734, 221043, 34718, 503942, 807191, 890799, 403017, 558917, 187498, 753156, 161889, 326616, 748336, 753942, 648694, 225315, 388228, 418217, 916129, 435637, 152945, 353274, 51543, 819598, 320869, 329985, 708486, 555732, 291431, 566179, 195921, 708680, 723429, 62059, 617193, 713490, 839672, 427061, 787674, 658480, 758624, 426935, 87777, 146592, 143149, 691270, 228944, 21659, 912288, 405247, 274058, 156786, 742941, 346777, 474383, 355448, 568771, 666124, 677562, 765587, 858179, 528256, 961677, 611111, 818806, 897460, 208616, 659738, 64081, 207641, 889609, 892033, 133501, 266857, 621606, 794935, 396372, 567053, 52331, 582094, 104977, 569902, 496245, 390154, 550784, 55238, 641297, 23741, 860725, 861067, 283503, 924066, 404874, 392211, 897657, 46748, 490894, 304656, 751827, 221437, 730461, 421321, 695259, 158087, 259472, 14837, 744332, 850752, 149834, 924528, 43174, 374614, 567583, 410071, 636843, 783718, 844101, 951446, 703700, 201046, 511629, 145996, 54378, 241686, 285229, 2299, 992962, 948612, 215175, 710462, 977662, 184503, 939465, 439086, 18999, 536186, 659815, 203013, 965787, 255983, 456806, 840014, 261442, 770277, 955892, 940019, 884343, 686299, 676304, 716247, 11141, 236451, 124411, 478090, 680125, 175743, 178750, 461502, 633006, 694179, 47960, 21926, 320034, 524028, 732852, 603541, 799317, 334915, 276857, 253882, 262465, 828135, 394678, 384312, 922363, 222351, 746409, 20062, 157582, 131931, 252307, 626638, 78825, 767279, 505875, 153744, 975663, 64725, 826981, 427925, 926691, 748580, 289254, 3199, 561583, 109612, 470102, 130143, 583840, 224354, 775172, 609376, 235902, 351312, 271143, 575355, 324896, 787099, 855052, 748572, 999311, 926808, 139753, 866799, 537768, 788685, 199740, 950081, 835325, 162448, 518463, 781043, 752546, 985988, 237700, 801304, 846762, 254587, 448003, 91525, 308020, 237083, 12293}, + 1, + 247363899, + }, + + { + []int{10, 9, 3, 2}, + 2, + 30, + }, + + { + []int{1, 15, 7, 9, 2, 5, 10}, + 3, + 84, + }, + + // 可以有多个 testcase +} + +func Test_maxSumAfterPartitioning(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxSumAfterPartitioning(tc.A, tc.K), "输入:%v", tc) + } +} + +func Benchmark_maxSumAfterPartitioning(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxSumAfterPartitioning(tc.A, tc.K) + } + } +} diff --git a/Algorithms/1044.longest-duplicate-substring/README.md b/Algorithms/1044.longest-duplicate-substring/README.md new file mode 100755 index 000000000..68a307f75 --- /dev/null +++ b/Algorithms/1044.longest-duplicate-substring/README.md @@ -0,0 +1,24 @@ +# [1044. Longest Duplicate Substring](https://leetcode.com/problems/longest-duplicate-substring/) + +Given a string S, consider all duplicated substrings: (contiguous) substrings of S that occur 2 or more times. (The occurrences may overlap.) + +Return any duplicated substring that has the longest possible length. (If S does not have a duplicated substring, the answer is "".) + +Example 1: + +```text +Input: "banana" +Output: "ana" +``` + +Example 2: + +```text +Input: "abcd" +Output: "" +``` + +Note: + +1. `2 <= S.length <= 10^5` +1. `S consists of lowercase English letters.` diff --git a/Algorithms/1044.longest-duplicate-substring/longest-duplicate-substring.go b/Algorithms/1044.longest-duplicate-substring/longest-duplicate-substring.go new file mode 100755 index 000000000..c35d6f111 --- /dev/null +++ b/Algorithms/1044.longest-duplicate-substring/longest-duplicate-substring.go @@ -0,0 +1,30 @@ +package problem1044 + +func longestDupSubstring(S string) string { + res := "" + + isExist := func(L int) bool { + seen := make(map[string]bool, len(S)-L+2) + for i := 0; i+L <= len(S); i++ { + sub := S[i : i+L] + if seen[sub] { + res = sub + return true + } + seen[sub] = true + } + return false + } + + lo, hi := 0, len(S) + for lo < hi { + mi := (lo + hi + 1) / 2 + if isExist(mi) { + lo = mi + } else { + hi = mi - 1 + } + } + + return res +} diff --git a/Algorithms/1044.longest-duplicate-substring/longest-duplicate-substring_test.go b/Algorithms/1044.longest-duplicate-substring/longest-duplicate-substring_test.go new file mode 100755 index 000000000..c0ab83d4e --- /dev/null +++ b/Algorithms/1044.longest-duplicate-substring/longest-duplicate-substring_test.go @@ -0,0 +1,73 @@ +package problem1044 + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans string +}{ + + { + "baaaaaababbbbbaaababaaabbabbabbbaabaaaaabbbaaababaabbbabbbabaaabbaabbabbbbbbbaabbabbabababbabbabaababbaabababbabbaabbabaaabbaaaaaaabbaabaabbababbabbbbaaaaabaabaaaabbabaaaabbbbbabaaabbababbbbaabbaabbaaaabbbbaabbababbaaabbbbabbabaaaaabbabaaaabaabaabbbabababaaababaabaabbabbbbaabbabbabaaaababbbaabbbbaaabbabbbbabbbaaaabbbaabbaabaaabaaaaaabbbbbabbbbbbabaabbbaababaaabbaabbabbbbbbbbbaaabaababaaabbbabaaaabbbabaaaabbbbaaaaaabbaaaaabbaaaababaaaaaaababbaaabbbbaababbaabbaababaaabaabbababbbabaaaabbbbaabbabaabbbaaaaabbabbbbbbabaaaaaaaabbaaabbbbbaabbaaababbaaaababbaaabbbbbbabbbbaabbaabababbbbaaaaaaaabaababaabbbababaabbaaaaabbaaabaaababbabbbabbbaaabaaaabbaabbaaabababbbaaaaaababaaabaabaababaaabbbbbbbbbbbaaabaaaabbaabababbaabbbbabbaabbaabaaaabbabbbbbaaaaaabbaabbabaabbbbbaabaabaabbababbbaaaabaaabbabbaaaaababbaabbabaaabbbabbaaababaaabbaaabbabbaababaaabbbabbabbbbaaaabbbaababbbababababaaababaaaababaababbaababbaaabaaaaababaababbaaabbbabaababababbabaabaaabaababaabbbaabaaaabaaabbbaabbbbbaaaaaabaabbabaaaababababaabaabbabbabbbbbbbbabaaaababbbbbbbbaabaabbaaaabbaaaaabbbbaaabbaababbababbaaaaabaaaabaababaabbbbbbaaaababababaaabbabbbabaaaabbbaabaabbaabbaaaabaababaaaabbaabaaabbabaaabaaaabbabaabbbaabbaaaabbabaabbabaabaabbbbaabaabbbaaaabbbbbbbbaaaabbbbbbbbbabababaabbaabbaaaabaabbbbaaaabbababaaabbaaaaaaabbbbbaabaaaaaaabbabbbbaaabaababbaabbbbabaabbbaabbbabbbbbaaabbbabbaabbaabaababaaabbaabababbbaabbaabbbbbababbaaaabbababbaaaabbabbbaabbbbbaabaaaabaabaabbaabababbbabbabbabbbbaaaababbbbbbbbbababbaababbabaaabbabbaabbbbbbbbaaaabaaabaaababaaaabaaabbaaababbbabaaabaaabbababbbabbbbaaabbaaabaabbbaaaabbbaaabbaabbbbabababbaabbbaabaaaabbbabaabbbababbbbabbabbbbabaaaabaababbabaaabbbbbbaaabbbbaababbabbbbaabbaaabbaababbbbbabaaaaabbbbbbaabaaaaaaabbabbaabbbaabaaaaaabbbabbbbaabbbabababaabaaaaaaabaababaabbaaabbabababbababbbbbabaababbaaabbababbbaabaababbbaabbbabbbabaabaabbbbabbaaababaabbabaaabaaaaaabaabaabaabbbaaaaabbabbbbbaaaaabaabbabbbbbabaaabbaaaabbabbaabbbaabbabbbbaabbbabaabbaabbabaabaaaaaaabbaabbbababbaabbbbaaaabaaabbbaaaababababbbbabbbbbabaabaabbbbabaaaabbabbaabbabaaababaabbbbbbaabbbbbababaaabbbbbbaaaabaaaababbbaabaabbbabbabbbbbaabbbabaabbbbbbbababaabbbabbbbbbbabbabaabbbaabbbbababbabbbabababbabbabbaaaabbabbbbabbbaaabbbabaabbbabaaabbbbbabbaaaaaababbaaaababaaabbbaabbabbbababbbabbbbabbababababbbbabbbabbabbabbaaaabaabbabbabbaaaabaabaabaabbaaabbabbbbbbaabaabaabbabaaaaaabbababaababbbbaabbaababababbbaaabbabbbababbbbbbabaaabbbbbabbbbbbbbabaaaaaabababaaaabbaabbbbaaabbbaaaabaabbbaaaabaabbbaabbbbaababbbabbbababaaababababbbabbbbbbbbbaaaabababbbaaabaaaaabaaababbbabbabbbaaabbbaababbaaababbbbbbbaaabbbabaaaababbabbabaaababbababbbaabbbbbabaabbbbbabbbbbbabbbabbbaababbbababaaabbbbbaaabbaaaaaabbbbaabaabaabbabaaaaaaaabbbbaaaabaaabaaaabaabaaabaaaabbbaaaaaababbbababbbaaababaababbbaaaabaabbbbaababbbbbabbaabaaaababaababaaababbbabaabaaaabbbbabbbbaaabaaabaaabababaaabaaabaabaaaabbbbaabbaabaaabaaabaabbbbbbaaaaababbbbbabaaaabaaabbaabaababbbabbaababaaaabbbabbaabaaabaabbbaabbaaaababbbababaabbbbbababaaabbbaaabbaaabaabbabbbbbabbabaabaababababbabababbbabaaaabbbbabbaabaaaaaaaabbaaaaaaabaababbbbaababababbabbaababaabbabbbaaaabbaaabababbabbaabbbbabbbbbaaaaaaababaaaabbabbbbbbaabbbbbabbaababbbababbaaabbbbbabbbaaabababbaaabbaabaabbabaabbbbbaababbabbabbaabbbbbaaaabbbaaaabbaaaabaabaabbbabaabbabbbbaaabbbabbabbabaabbabbaabbabaaabaaabaabbabbaabbbabbbbaabbbbabaabaaaaabaaabbbbabbbaabbabbaabaabbabbbabbbbbbbbbabaabbbaabaaaaaaabaaaaababbabaabaaabbbbbabbbabbbbbaabbbabbaaaabababbbaaaaababbaabbbbaabbaabababbbabaabbbbbabaabbabaaabbabaabbabaaaaabaaaaaaabbbaabbbaaaababbaababbbbaabaababaaaabbbbabbbaaaaaababaaaabbaaaabbaababbabaaabbabababbbbaabbbbbbbbbbbbabbbbabababaaaaaaaababaaababbbbabaaaabababbbaabbaabbbbbaabaaabbbabaaaaaabaabbbbabbaaabbbaabbbababbabaabbbbbabaabbaababaababbbabaaaabaababaaabbabbbbbababbbbaaababbaaaabbababbbbaaabaabbbbbaaabaaabbbababbaabbabaaabbbbaaabbbaabbbaaabbbbbbabbaabbbbababaaabaabaabbbbabbabaaabaabaaabbbbbbabbaabbababbbaaaaabbaabaabbababbbbaabbabbaabbabbabbbabbabaaaabbbbabbbbaaabababbaabaaaaaabbbabbaaaababbbbbbaaaabbbbaaabbaabaaaabbaaabbabbbabbbaaabbaaaabaababaababbabaabbaabbabaabaabbbbbaabbaabbaabaaabbabbbabbabbbbbbaababbabbbbabababbbabbabbbbbaabaababbababbbaabbaaaabaabbbabbabbbaaabbaabbabbbababbabbbbabbbaababaaabbaabbabbbabbaabbababaabababaaaaaabbbaaabbaaaaaaaaabbbbaaabbbbbaabbbaaabaaaabbabaabbaabaababbbbaaaabababbbaabababbabaaabbabaabaabbbaaababbbaaabababaabbbaaaabbaabbbabbababbaabaababbabbaabbbbbabbbabaabbbabbabbaaababbaaababbbababaabaaaaabbaabaaaabbbbaabbabaabbbbabaabaaaabbbaabababaabaabbbaaabbabaabbabaabbbbbabababbababbaaabbabbabaaabaaabbbbaaabbaabaabaabbaabbbabaaaaaaaaabbbabbbaabaabbbbbabaabbbaaabaaaabbaababbbabaabaabbbbbababbababbbaaababaaabbaaabbbbaabaaaababbbbaabaaaabbbbbaaaabaaaaabaaaaababaaabaabbaaabaaaabbbabbbaabbaaababbabaaabaabbabaaaabababbbbabaabbbbabbabbabaaaaaababbababbbbbaabaabbabbaaabbbaababbbaabbaaababbbbabbaaabbabbbbabaaabbaababaaabbaabbaaaaabbabbaaaaabaabbbbbabbbabaaaaaabababbbabaabababbbbbbbbbaaaabbbbbaabbbbaababbbabababaabababbbbbabbbbaaabbabaabbaabaaaabbabaaaabababbbababbbbababababbabbabaabbbaabbaaaabaabaaaaaaabbbbbbabbbaabababaabbaababbbaabbababbababbaababbabbaabaaabbabbbbaaaabbaabaaabbabaaabbbbbababaabaabbababaaaabbaababaabbababbbbbbbaaabbbaababbaaabaaabbbbbbabbabbaabbababbbbbabbaaaaabbaaabbaabbaaabaaabbbaaabbbaabbabbbbbbabababbbbbabaabaabbbbbbabbabaababababbbaababaaaabbbaabbbababbaabaababbbbbabababbbabbbbbbbaaababbbbbbbaabababbabbbbaabaababbbabbababbabbbbbbbaaaabbaabaabbbabaabaaaabbbbababaaaaabbbababbbaababbbabbbaaabbaaaaabaaaabbabaabbabbaaaabbaabbaaaabbbaababaababababaabbbaababaaaabaabaaabaaaaabaabababbabaaabbbabbaabaaaaaabaababaaaabbbbaaababbbaaaaaaabbaaaaabaaaaaabbbbbababbababbaabbbabaaabbaaaaabbabbababbababaababbbbbbaabbabbbaabbabbbbaababbbbbababaaaaaaabbbbabbaababbabaaabbbabbbabbbaabbaabbaabbbbaabbbbbabaaaaababbaabbbabbabaaaaabaaabaababbaabababaaabaabbaabaababbbbaaaabbabbbabbaabbaabbbabbababbababaaaaaabbbaababaaaababbaaaaaaaaabbbabaaaabaaabbabbaabbbbaaaabbabbbbaabbabaabbaaaaabbbbaaabaabbaababababaabaabbaaabaabbbbbbabbabaaabbaabbaaabbbaabbaaabbbbbbbaaabbbabbbabbaabbbbbbbabbababbbbaababababbbbbaaaababbbbaabbbbabbbaaaabaabbabbabaabbbbbbbbbaaaaaabaaaabaaababaaaababbaaaabbaaaabaaabbbaaaabbbaabababbbbaaaaaababaababbabbaabbababababaaabaaabbaabaaabbbbbbbaaaaaabbaabaaabaabaabbaabbaaaabaaababababbaaaabbbbabbaabbbbaabaabaaaaaababababbaabaabbababbabbabbabbbabaabbabbaabaabbaaaabbbbbababbaabbbaaabbbbbbbbababbababbabbaaabbbaaabaababbbabbabbbabbababbabababbabbaabababbabbaaabababbababaaabaaabbbbbabbbaababbbaabaabababbabbbabaaabbaaaaabababbbaaaaabaaabbbabbaabbaaabbabaabbaaabbabbbabbbaabababbbbbaaaababbbabaababbabbbbbbbabbababbaaaababababaaaaabaabbabbbabbaabaaabbbbababbbbaabbbbbbbaabbaaaababbabbabbabaabaabbbbabbbbabbbbabbabbbaabaaaabbaaaaaabbbbaabaabbabbbaabbbbbbaabbbbbbbbbbbbaaabbbabbaabaababbabbaaaabbababbbabbbbbbbaabaabbabbaaaaabbaabbabbbbabababaaababbaaabaabbabbbbabaabbbabbaabbbaabaabaaaaaaaaababbbabababbbaaaaabbababbaaaababbbbbbaabbabbbabaaabaaabbabbabaaababbbbbaaaabaaabbbbaaabaabbbabbbaabaaaaaabbbbababbabaabbbaaabbaaaaaaaababaaabaaababbbababbbbbbabaaababaababbaababbbaabbbaaaabbabaaabbbabaabaabaabaabaaabbbaabbaabbbbabbbbbaaaaababbbbbbaaababaabbabaababaabbabbaaaaaabaabababbbbbaaabbaaaabbabbbabbaaababaabbaabbbbaabbbaababababbabbaabbbaabbaabbabbbbabababbbbbabaaaaaabbabbabbbabbbbabaaabbababaaaaaabbabaaabbbaabbbbaabaaababababbbbbabaaabaabbabbabaabbabaaaabababaaabbabaaabbabbaabbbabbbbaaabbaabbbbbaaaaaaaabaabbaaabaaabbabbbbbaaabbabaabababbbaabaaaaabbbbabbbaabbaabaabbbababbabaabbaaabaaaaaabbabbbabbbbaaabaabaabaaabbabbaabbabaaabbabaabbbbaababbbabbaaabaabaabaabaababaabbaabbbbabbababbbaabbbaaababababbabaabababaaabbbbbbbbabababbbaabbbaabbbbbaabaaabbaabbabababbaaaababbbaaaaabaabbbbabbaabbaabbabababbabaaaabbabbbbababaaaaaabababbaabaaabbababbbbababaaabbbbaaaaabaaabaaabbbaaabaaaabaabbbabbbabbaabbabbbbbbbabaabbbbaabbbaaaabaabaaabbaaabaababbbbaaaaabaaaaabbbabbaabababaabbbbaabaababbbababbbabbabbbaabbbabababbbabaaabbbbaabbabbaabbbabbaabbbaabbbbbbbabaabaaabaaaaaabbaaabbbbbabaabbbbbaabbaaabaaaaaaabaaabaaababaaaaabaaaaabbbbbbbbaababbbbaababaaabababababaabaaababbbaababbbabbbbbaabbabbbbbaaaababbbbabbbaababbabbbabaaabbaaaaabbababbaabbbaaabbabbaabaabaabbbaababbabbabbbbaaaabbaaaaabbaaabaabbbaaabaabbbbaaababbabbaaabbababaaaaabaabaabbbaaaaabbaabbbabaabbababbbaaabbbabbbbbbbbaaababbbaabaabbbbbbabbbaabbbbbaabbbaaabbbbababaabbbabbbbaabaabbaaababaabaababababaaabaaaabababbaaaabababbbaabbbbaaaababbabaaababababbaaabbbabaabaaabbbbabaaaaababbaaababbbababbaabaaaabbbbbababaababbbaaaababbabbbbbbabbaaabaabbabbbabbbbbbbabaabaaabbbaaababbbaaabaababaaaaaabbbbaaabaaabaabbbbaaaabbabbbbaaabbabaaaabbbbabaaabbaaababbabbbaaaabbbbbababbbaababbbaabbabababaabbabbbbbabbbbaaaaabbaaaabbababbabbabaaaaababababbbbaaababbaabbaabbbabbbbbabbbbaaabababababbbabbaabaabaaaaabaabbabbbbbbbabaaabaabbbaabaaaabbaaabaaabaaabaabababababaabaababbbbabbabbaaaaaabbbababbbbababbbaabaababbabaaaaabbabaabaabbbbbaabaaabaababaaaaaabbaabbbaababaaababbaaabbbbaaababbbbaababbabbbaaabaababbabaaabbaababbbabbabababaabaaabbbbbbabbaaaababbbbabbabbaabababbaabbaaaababbbbbbbbababaaaaaabbabaabaabababababaaabbbaabbaabaabababbaaaabbaaaabbbbabbbbaababbaababbaaaababbbbabbaabbbabbaabbabaabaababbaabababaabbababbbaabababaaababababbaabbabbaaaaaaaaabababababaababaabaaabbabaabbabbababbabbbaabbbababaababbaabababbaaabaaaaaababaabbaabbabbaaabbbaabaaaabbaaababbaaabaabaaaaabbbaaabaabaaabbaabbbababaabbbbbbbbbbaababbbbabbaabaabbabbbbbaaaaaabababaabbaababaaaaabababbaaaabbbababbabaabbbbababaaaaaaaaaabbbabbaabbaaababaaabbaababababbabaaabbbabaababaaaabbbababaabbbababbababababbbbbaabababbbbaabbbbabaabaabaabbbabaababaababbaabbabbabaabbaababbbbbaabaababaaabbbbbbbbaababbaaababbabbabaabbbaaaaabbabbaabaababbaaaabaababbbbaaaaaaaaabbbbabbbaabaaaaaaabbbbbaabbbbbabbbaabbbbbbaabaabaaabbaaabaabbabababbbaabbabbbbbabbaabaaaabbbababbbababbabaababaaaaabababaababaaaaababbaababbbabaabaabbabbabbabbbabaababaaaabbbbaaabbabaababababbbabaaaabbbabaabbbaabbbbaaaabbaaaabaababaabbbbaabbabbabbaaaababaabbabaabbbaaaabbbbbaaabbababaaaabaabbaaabbaabbbababababaabbbabbbbbabbaabbaababbbaabaababaaaaaaaaaaaabababaaabaabbbaaaaaabaabbabababbbaabaaaabbababbbbbbababaaabaaaaabaaabbbbbaabbababaabbbbaaaabaaaabababababbabaabaababbbbbbbbbbabbababbabbbbaabbbbbbbababaababaaabbbabababababbbababbbbbbbbbbbbbababbbabaaaaaaabbbbbabbbbbabbbbabababbbbaabaaababbaaaabbabbaabbbbabbbaaaaabbaabbabaaaaababababbaaabababbbabbbabbaabbabbbbabaabbbbbbabaabbababaabbbbabaaababaaababaabaababbbbbbaaabbbabaabaabaabaabaaabbbbbabbaababaababababaababaaaaaabbbaaaababbbabbbabbabababbabaabbabbabbbaaabbbbababaaaabbaabbabbaabbbaaababaaaaabbbaabbababaaaaababbbaaaabbbaaaabbabbabbababababbabbbbababaaabaabbaaabbbaaaaaaaaaabbbaaabaabbbbbbaaaaaabababbbbbbaabababbbaababbababbbbaaaaabaaabbbbababbaaaabbabbabaabbbaababababbbbababababbbaabaabbbaaaababbabaabbbbbaaabbabbbbaababbababbabbaababbabbababbbaabbbaababaabbaabaababbabbbabaaaabbabababbbabbabbbbbbabbbbbbbababbabbbababbbababaaaabbababaaabaaababbaabbabaaaabaaaabaabbaabaabbabbaabbbbbbaaabaaaababbaaabaaabbaaabaababbbaabbabababbaabbbaababbaaababbabaaaaabaaaabbaababbaabbbaaaaaabbaabbabaabababaaababbabababbaabbaabaabbaaabbbbbaaaaababababbaabaaaaababbaabaaabaabbaabbbbababbbbbbaaaabbaaabaaaaabaaaaaabbbbbaaabbaaaabaabbbbabbbaaaaaabbabbabbababaababaabbabbababbbbbababbabbaaababbbabbbbaaaababaabbaaabababbabbaabbababbbbaababaabbbaaaabbababaaababaaabababbbabbaaabbababbabbbaaaabbabaaabbabbbbabbbaabbbbaaabbaababaaabaabbaababbabbbaaaaabbbaabbbaaabbabbaabaabbabababaaababababbbbabaabbbbbbbabbaababbbabaabbbabaaaabababbaaabbabbbaaabbbbaabbbabaabbbbaaabbbbabbaabbaabaaabababbaabbbaababaabbaababaaaaabbaaabbaabaaabbaaabbababbbbbbaabbaabababbbbababbbbbbabaababaaabbbbaabaaaabbaababbabababaaaaabaabbbabaabbbbbaaaaabaaabbabbababbaabbabbabaabbbbbbaababbbabaabababaabaaaaaaaaababbbbabbbaaaabaaabbbabaaabbaabbbaaabaabababbbbaaaaabaaabbabbabababbaabbbaaabaabbaaababaabbaaababbabaabaaababbbbbbaaaababbabbbabbbaabbbbabbaaabbbabbaaabbabaabbbaabbaaabbaaaaabbbbababbbbbbbbaababaaababaaaababbababaaababbabaaaabaababbbabbaaabbaabababaabaaabbaaaababaaabaaaaabbbababbabaababbbababbbbaaaaabbaabaabaababaababbbabbbaabbabaabbbbababaabababbbbbaabbbababbaabbbbaaabbbabbbaaaabaabaaababbbbaaabaaaabababbbabbaaaaaabaaaabbbbabbbbbababaaaaaaababaaabbbbabbaabaabbabbaabbaaabbaaababbaabababaabaababaababbbabaabaabababbbaaaabaaabbaababababbababbbababbaaabbbbabababaabaabbbbbbabababaabbabaaababbbbaaaaabbbbbbabbaaaabbbaaaaaaabaaaabbbabbbbbbbbaabbaabaaaaababbbababbababbbabaaabaaaabaabbaaaabaabaabaabbbababbbababbbbaaaabbbbbaababaababaabbbbababbabbbbaaabbaaaaaabbabbaabaaaabbabbbbabbabbaaababbaaaaabbbbbbbabbaaabbaaaabaabbbaaaaaabaabbaaabbbbaabaaabbabbbbbbaabbbbbbababbbbbbbaaaaababaabbbabbbabaaaabbbbbababbaaabbbaaaabbbababababaabbbbbaaaabababbabbababababbbaabbabbaabaaaaaaaaaaaaaabaaaaababaaaabaaababababbbbbaaababbbababbabbabbbaaabbbbaaabaaabbbbaabaabbbbbabbabbabaaaaababbbaaabaabababaabaaabbabbaaaaabaabbabbabaabababbbbaaaaabaababbbababaabaabaabbaabbbbbabbbaabbaabbbaabaabaabaaaabbbaabaaababbbabababbaababbabaaaaaabbaababbbbbaababbbbbababbbbabaabbbbbaabababbabbbaaaabbbbaaabbabbbabbababaababaaabbabbbababaabaaaaaaaaaaababbbaabbbabbaaaaabaabababbbababaaaabaaabbaababaabbbaaaababbbaaaabbbaaabbaaababaabbabbabababababaaaabbaabaaaaaaaabaaabaabbaaababbaaaabbbaaababbabbaabbaaabaaaaaaabbbaaaaabbaaabaabaababaaababbabaababaaabbababaaabaaabbbaabbbbaabababbbabbaabbbaaabaaabbbabaabaabaaababbbbaabaaaababbbaabbbaaababaabbaabaaabaabbababbabaabbbaababbabaabbbbaaabbbbbbbbabbaabbaabbabaabaaaabaabbabbbbabaababbbbbaabbabbbbabbbabbbababbbaaaaaababbabaaabbbaabaaaaababbbbbbbbbaaabbaaaaabaaaaabbbababababaaaaabaaaaabaaababbaaaabaabbbbbabbbbaaabbbababbbbbbbbabaabbaaabbbbaaaaaaaabbbaabababbbaabbabababbabbaabbabbbbbababababababbbababaaabbbabbabbabbaaaaababbaabbbbbaaababaabbbabbbbaaaababaaabbbbbababbaabaabababbaabaaabbbaabaaabbbaaaabbabaabbbabaaababaaabaabababaaababaaaaabababbaaababaaaabbbaaabaaabbaaaaaaabbbbabaabbaaababbbbbaabaababbabaaaabbbaabaabbaaabaaaaaaabbbabbaabaaabaaaaaababbabbabbaaaababbbbbbbbaaabaaaaaaabbabaaaabaaaabbbabababbaabbbbababbbbababaaaababbaabaabbbabbaabbbababaaaaaabaabbabbababbabbabaabaabbbaababbaabbabaaaaaaabbbbaabbbabbabbaaabaabbbbaabbbaabaabbabaaabababbbabbbabaaaaabbaabbabbbabbababbbabaaaabbbbbbabbaaaaaababbaaaabaaababbaaaaabbbbaaabbaabaaaabbbaabaaaabbabaaaabbbababaaababbbbbabaabbabbbabaaaaabababaababbbbbabbbabaababbaababbbbbbaaaaabababaababbabbabaabbbbaaaaaaababbbaaaabbaabbbaabbbbabaabaabbbabbbbabbaaaaabbaabaabbbbbabaaabaaabaabbaabbababaaabbbbbabbbbabbaaaaaaaabbaabbaaababbabababbaaababbabbbbaaabbbbbbabbabaaaaaaaababaababaabbabbabaabaaaabbabbbbabbbababaaabaabbbaaabbaaaaaaaababbabbaaabbbbbaaaabbabbaaaababbbabbbbbabbaaababbbbbabbbaabbbaaabbbbabaaabbbaabaabbabbbabaabaababbabbbbaabbbaabbbbbaaabbbbbaabbbaabbbbbaabaaabababaaababbbbaaaaaaaabbbbaabbbababaaaabbbaaabaabaabbababbbabaaabaaabbbaaabaaaaaaaaabbaabaabbbbaabbbbaababaabbababbabababbbbbbbbbabbbbabababbbbabaaaabbaabaababbbaabbbaaabaaaaababbbaaabbabbaabbbbaababbbaababbabababbbabbbbabaabaaabbbaabbaababaababbbbababaaaabaaabaaaaabbaabbbbbabbbaabbabbaabbbaabbbbabbaaaababaabbbbbaabaaabaabbabababaaabaabbbbaabbabaabbbbaabababbbbababbabbababbbbbbababbbbbbaabbaababbbbbaaaaaaaababbaaabbaababbaabababbbbbbababbaaabaaabbaaababababbbbaaaaaaaaaabbbaaaabaaabbaaabbbaabaabbabbaaaabbbababaaaaabbaabbaaaabbaaababbbabaaabbbabaaabbbaaaaaaaaaabbabaaaaabbabbbabbabbbbabaaaabbabbbbbbabbbbaabbabaabaabaaabbbbaaaaabbaabaaaabaaaaabbbbbbbaabaabbaaabbaabaaaaaabbabbabbbbabbaaabbbabbbbbabbbbabbbabbaaaabbbaaaabbbabbaaabbbabaababaaaaabbbbaaabaabbbabaaabababbababbbaababaabababbbaaaaababaabaabbbaabbbbbaabbbbaaabbaabbabbbabbbbbaaabbbabbaaaababbbbbbaaaaabaabababbbbbbaaabbbaabaaabbaaababbbabaabaaaabbbabbababaabbbbabaababbbbababbbabaaaabbbbbaaaabaaabbaaaabababbabbababaabaaabaaaaabbbbbabaaaaabbabbabaabbbbbabbaaabbaaabbaababbbbaabbabaabaabbbaaaaabbabaaababbbbbbabbbbbababaababababbbabaaaaaaabbbbaabbaaabbaabababaabaaaabbbbabbbabbbbbbbbaaabaabbabababababaaabababaabaaabbbbaaabbaaabaaaaabbbbaabaabaaabaaaababbabaaaaababbbabbbbbababbbbbabababbaabaaaaabaaababaaababaabaabbaabaaabbabbaabbbbbaabbbabaaabbaaaabbaabaaabbaabaaabababbbbbabaaabababaaababbbabaaaaaaaabaabababbabbbbbbbbbaabaaababbbababababaaabbbbbbaababaaabbbabaaabbbbbbbbbaabaabaaaaaaabbbaabbbbabbaaabaaaaaaaaaababbaabababaaaabbaabbbbabababaabbbabbbaabaabbbaabbabbbabaaaababbbaaaaabbababbbabaabbbabaabaaabbabbbaabbaabaaabaabaaabbabbabbaaaabbbaababbabbabbbaaaabbabbbbaabbabbbaabbbaabaabababaaaababaaababbaaaabbbbbaabaaabbbbaaababbbaababbaaaabaaabbbbaabbababbabbabbbabbbbabaabbababababbababbbababbbabbaabbabbaabbbbbbbbaabbaababbaabbababbaabaabbbbbbbaaaababbbbababbbbabbabbaabbabbaaaaaaabaaaababaababaaaaaabababbaaabaababbababbbababbabbbbaaaabbbaababbaabbaaaaababbaaaababbbaababaababbbaaabbbbabbababbbaabbabaabbabbababababbbaababaaaabbabaabbababbbababbaabaaabaabbbbaaaabbbbabbbaaaabbabbaabbaaabaabababbbabaababbaabaabbbbbaaaaabbababbabbbaabbabbaabbaababaaabbbaaaaaaaabbbabaaaabaaabbababbbbabbaaaaaabaababaaaaaabbbbaaababaaaabbaaaaabaabbbababbabbbbbababbbababbbbaabbbabbbaabbbaaabbaaaabaabaaabaabbabaabbaabbbababbaabaababaabbababbbababbabbaaaaaaaababbbbbbbbaabbbbaaaabbabbbbbbaaabbaaaabbaaaabbbabbbbabbabbabbbbbaababbaaabaaaaaaaabaaaabbaabbababbbabaaabaaabbbababbaabbbbbaabbaaaabaabaabbbaaabbabbaabbbabaabbbabbabaaabaaabbaaabaabbbaabaaabaaaaabbaabbaabbbabbbaabbbbabbabaaaaaababbaaaaabaabbabaabbbbaaaabbaababaabaabbbbbbbbbaabbaabbaaababaaabaaaaabbbbbaaabbabaaaabbbbbbaabbabaababbbaaabaababaaabbababbbbaaabaaabbbabbababaaabbbbabaaaabaabbbaababbbaaabbaaabaabbaabbaababbbababbbbaaaabbbabbbbabaababaaabaabaabbabbbaabbaaaaababbabbabbbbbbababbaaabaaaaababbaaababbabbbbaabbbbabbbbbabaabbbabbbbabaabbabbbbbabbaaabaaaabaaaaaaaabbaaaabbbaaabaaaababbaababaaababbaababbabaabbbbaaaabbabaabababaaabbbaaababbaaaabbbaabaabbaababbaaaabbabbabbabaaaaaaaabbabbaababaaaaabbbbaabbbabbbbbbabbbbaaaaaaabaaaabbbbbbaaaaabbabbaabaaaaabbbabaaaabbababbbaaaababbaabaaaabbaabaaaabbaaabbabaaaaabaaabbabbbbbbaaaabbaabaaabbbbaaaaaaabbbbaaabbaabaaabaaabbabaabbabaaaaaaaababbaabababaaaaaaaabbbaabbbbabaabaaabaaabaaabbaaaaababababbbbbabbaaababaaaaaabbaabbaabaaaabbbbbaaaaaabbbabbaabbaaababbbabaabbabaabaaabbbbabababaabaabbbaaabbbbabaaabbbabaabbbaaababbaaabbababbaabbaaababaababbbabbbabbbabaabbbbbbaaaaabbabbaabbababababbbbbabbaaaabaaaaabbbbbaabbabbbabbabbabbbbaaabbbbbababbabbabbbbbaabbaabaaaababbbbbbaababbabbbabaabbbbbbaaabaababbbaaaabbabaabbbbbbbbbaabbaaabbabbbbbaabbaaaaaaababababababbbaabbbaababbbbaaaabbbbbbababbbbaaaabaabaabbbbbbaaabbaabbaaaababaaaaaaabbaaaaabbbbbbbaabababbbbbaabbaaaaabaaabbaaabbbbabbbabbabbbaaaaaabaabbaabaabbabbaabaababbabaaaaabaaababbbaabbabbaababaababbbabbaabaaabaabaabaaaababaaaaabaaababaababbabaababbaaaabbaabbaabaababbbbbabbabbabbaababababbaaaabbbbaabbbbabaababaaabbbababaaabbabababbbbbbbbbabaabaabbbaaabaaabbbabbbababbabbbbbaabbaaaabbabbaaaabaaaaabbbbbbbbbaaabaabaaaababaababbbbaaabbbaabbbbabbaabbbaaaabaaabababaabababaaabbabbbbbbbaababbaaababbaababaabaabbabbbaaabbabbaaababbaabaaabbabbbbbabbbaabbbbaaabbbbbbabaaaaaaabbaabaababbabbaabaaaaabbabbbabbbbbaaababbabaaaabaaababbbbbaabbbbabbbabbbaababbbbbaaabaaabbbabbbbbbabbaaaababaaaabbaaabbbababaabbbabaabababbbbbbbbaabbaaabbbbbbaabbabbbaaabaabaaabbbaabbabbaaaaaabaaaaabbbbbbbaabaabbbaabaababaabbbbabbbaaabbbbbaabbaaaabaababbabbbabbaabaabbabbbabbabbbbbbbabaaaaaaabbabbaabbaabaabaaaaaababbabbabbbabbabbabaaaababaabaabaaaaaaaaaaaabbbbbbaabaaaabbbbaaabbaabbaabbbbaababaaabbabababbbababbbabababbbabaaabbaaaabaabbaabbabbaaabaabbabbbaaabbabaaabaaaaaababaababbabaabbabbaabbbbbbbababbbbbaabbabbbabbaabbbaaabbababbababbbbbabbaababaaaaaabaaabaabbbbabbaaaababaaabbbbbbaabbababaabbaabbaaabbabbababbabaabaababbbbabbabbabaababbabaaaabaabababbaabbabaabbbbbaabbabbaaaaaaabbbbbaababaaaabbbbbbabbaaaabbaababaaaaabbbabbbbbabbabbaabaababbbaabaabbbbbbbbabaabaabbbbaaabbbbaaaabaabaaababaabababbaaaabaaabbbbbaabbbbbbaabababbbbbaaaabbaabbabababbaaabaabbbbbbbabaababbbbaaaabbbaaabaabbbbaabbbaaaabaaaaaabbaabbabaaababaabbaaaabbbbbbaababaabbbabbabaabbaababbababbaaaaababbbbabbabbababaaaaaabaaababababbaaabaaababaaabbbbaaabaaabaabbaabbbbaabbbaaabaaabbbbbaababbaabbbabbabaabaabbbaaaaabaaaaabbaaabbabbabbbbbaabbaabaabbabbabbaabbabaabaaabbabaaaabaababbbabbbbbbbbabbaaabaaabababaaabbaaaabbbbabbabbbaaaaaaababaaaabbbabbabaaaababaaaaabbbbbbaababbbbaabababababababbbbaabbbaababbaaaaabbaaabaaabbaababbaaababbaaaaababaabbbbabababbabbbabaababbabaabbbaababaaaaababbaaaaabbabbbbaabbbbabbbabababaabbbbbababbbbbbaabababaaabbabbbbabbbabababbabbabbabbbbabbbababbaaaaabbbabababbababbbbbbaabaaabaaabbaaabbbabbabbaaaaababaaabaabbabbaabaabbbabaabbabababbaabaabaaaababbbabaabaaabbabaababbabaababbaaaaaaaababbaaaaabbbaabaababbbabbaabbaaabababbabaaabbbabbbabaabbaaabbbaababbbbbbbaababababbbbbbbaaaaababababbbabaabaabbabbbbbbababbbbaabbaaabbaaabbabbaaaaabaabaabbaababbaabbabaaabababbbbbbbbbbbbaabbaaaabaabaababbbabababbaabbabababbbbbbbbabaaabbabbababbaaaabaaabbbbaaabbbbbbbbbbabbbabbabaaabbbaaaaababaaabbbaabbbabaaabababbaaaababbbabbaababababbbabbbaaabbbababbbabbaaaabababaaaabbbabbbaabbaabaabbbabbbaabbabaaaabaabbbbabbbaabababbabaabababbaabbbbabaaabaaabbababbbbababbababababaabaabbbbbaaaaaabababbbaaaaabaaabbaabbbaabaabaaaaabbbbbbbabbbbaaabbaabbbabbabbbbaaaababaaaaabbbaaaaaaaabaabaabbbaabbbabaaababaaabbaabbbbabaabbbaabaababababbaabababababbbbbbbbabbaaababbaaabaabbaaabbabbbbaaabbaabbabbaaaabbbabbbabbbababbabbbaabbbabaaaaaaabaabbbbbabbbaabbabaaaabaaabbbaababaaabbaaabaabababaaababbabbaababbaaaabaabbabaabbabaaaababbaabbabbbabaabaabaaabaabababbaababaabbabaababaabaabbabbabaaabbabbbbabaababbabbbbabbbababbbababbbaabaabbaabbaaaababaaabbbbbbbaaaaababbbbaabaababaababababababbbaabaaaabbbaababbbaaaaaabaababbbbbbbabbbbaaaaabababbaabaaabbbabbbabbabaaabababaabbabbbaabaabaabbbabbabbbbaaababbbbbaaabbabaababbbbabbbbaaabaaabbaaabababbbabbbbaabbbbaaabaabbaabbbababababaabbbbabbbbbbabaaabaabbaaaabbbbbbbabbaaabbabbababbabaaaabbbbaaababbaabbbbaaabbababbaabbbabbabbbbbaaaaabbaababbabbaababbbbbaabaaaabbbabbbbbaabbabbbabaaaabbbbabaaabaaabaaaabbaabbaabbabbabaabbbaababaabaabbaaababbbbbaabbabaaabbbababbbababaaaababbbbbbabaaaababbbaaabbbbaabbabaabaaababaababaaabbbbabbbaaaabababbbabaaababaaaaaaaabaaaababaabababbaabaabaabaaabbaaaabbaabbaabbababbbbaabbbbababbaabbabbbbaababaabbbbaabbabaabaaaababaabbabbbabbaababaabbaabbbbabaaabbbabbabbabaabbaababababaabaabaaababbbbaabaabbabaabaabbabbababbabaaabbaabbbaabaabaaaabaaabbbbaaababbbabababbabbabaabaaaaaabbbabbbabbabbbabbabbbbaabababbbbabbaaabbbbbaababbbbbababbaabbaabbabbbbbbbaabbaababbbbaaaababbaaabbabababaabbaaabababbbaabbbbaaaaaabbaaabbbaabaabbbbaabababbbbbabbbabaaaababbbbbabbbabbaaaaaaaababababbbaabbaaababaabbabbaaaaababaaababaaaababbbaaaaabbbbabbabaababaaabbbbabbbaaababaabaaababbaaabbbaaaaaabaaaaabbababaabbbbbbabbbababbabaabaabaabaaaaabaaaabaaababababbaababaabbbbaabbaabbaabaabaaabbabbababaabbbaababababbbbbbaaabbbbaabaaabaabaaabbabababbabbaabbbaabbbaaabbbaaaaabbabababaaaaaaaaaababaaabaaaabababbbbbabbbbabbbbabaabaaabbabbabbbabaabbaababbbabbaaaabababbbbabbaaaabbbbbabbaaabbbaaabbbaaaabbbbbaabbaaaaababbbbaaaaaaabbbbbaababaaaaabbabbaabbbbaaaabbbabbabbbbbbbabbabaaaabbbbaaabbababbbabababaaabbaabbababaabaabbbaaabaaabaaaabaaabaaabaaabbbaaabaabaababbbabbbaaaabababaabbaaaabbbbbbaaaabbaabaaaabaabaaabbbaaababbbbbbabbbbbbabbbbaabbbbbabbabbbabbaaaababbababbbbaaababbbabaabbbaaaabbabababbbbabababaaaaaabaabaaabaaaaabaaabababbabbbaaaaaaabaaabaaaaabbbbbbbaaabbbabaaababaabaaabaaabaaabbbbbbbaababaabbbbaabaaaababbbabbbbabbbbbababbbaababababaaaaaaabbabaabaabaaabaaaabbbbabbaaabbaabaabababaaabaabbaabbabaabaababbbbbbaabaaabaabbbabaaaaabaaaababbbabbabbaabbabaababaabaaabbbbabbbabbabbbbaaaabbaaaaaaaaababaaababaabaabaabaababaaaaabaabaaabaabaabbaaaabaabbaaabbbbaaababbaaabaabbaaabababaababaabbabaaabbbbbbbbbaabaaaaabbaaaaaaaabbabaaabababaabbbbabaaaaabbbaaabbbbbbabbbababbababaabaabbbabbbbababbaaaaaabaaabbabbabaabbbaabbbababbbbbbbabbbbabbaabbaaabbbbabaaaaaabbababbbabbaaabbabbbabbabbabbbabbaaabbaaaabbaabbababaaabbaaabbababaabababbbbaaababbaababbbaabaabaabbabbaaaabaaaabbbbbaababbabaaabababbbabaabbaabaabbabbaaaaabababaaabaabababbaabaabbabbbbabbbbbbbbbbaababbbabaabbbbabababbbbbababbababaabbababbaabbaaabaabbababaaabbbabbabaaababbbbaaabaabbbbaaabaabbaabbaaaaababbbbababbbbbaabaaabaaaababbbbbbbbaaabaaaabaabbabaaaaababbabbbbaaabbabaabbaaaabbababbbbbabbaabababbabaabababbabbaabbbbabbbbbaababaabbbabbbbabababbaababaabbbababbbaabababbbbbbbabbbababbbababbabaaaaaabbababbaabbbbababbbbabbaabbbbbabbbababaabbabbaabababbbbababbbaaabaaabaaaaabbbaaaaabaabaabaabbbbabaaababbabbaaabbbabbaabaabbaabbaabaaaaaababaababbbaaabaabbababbbabababababbbaaaaabbbbaaaabababbbbbbaabbaabaaabbababaaababaaaabaabbbbabaaabaaaabaabaaaabbbbbbababaaabbbbaababbabbaaaaaababbaaaabaabbaabaabbbbaaaabbabaabaabaabbaabbbbabbaabbbaabaaabbaabbbbbabababbaaaabbbbbbbaabaabbaabbabbabbabaabababaabbabbabaabbababbabaaabbabbaaababbaaaaabababbababaaaabaabbababbbaabbabbaaabbbbbbbbabaabbaabaabbbbbbabababbbbbbbaaababaabbbbbbbbaaabbbbbbabaababbbbaaaababbbbabbabbabaaababbabaaababbaababaaaaaaababbbabbbaabaaaaabaabbbaabababbabbaaabbaababbababbbbbaabbabbbbbabbabbabaababbbababbaabbaababbbbbbbaabaaabbbababbbbbbbaaaabbbbbabaabaaaaababaabbbabaababbabaabaaabbaaababbbbbbbbabbbbbaabbabbbbaabbaaaaaababaaaabbaaaabaaaaaabbbbbbbaabbabbbaabbabaabbbabaabbabaaaaabaabbaaaaabababababaabbabaaaababbbabbbbaabbbbaaaaaabaabbaaaabbbbbabaabbbaaabababaaababaabbaaaabbaabbaabababbabaaaaabbababbababbaaababbbaababbabbbaaabbbbabababaaabbaabababbabbbbbbbaaaabbbaaaaabaaaabbbbabbabbbbbbbbbbbabbbabaaabbaababbbbbaaabababaabaaababbaabbbbbbbbababaaabaabaabbabbbabbabaaabaaabbbbabaabbbaaabbbaabaabbaabaaabaaaaababababaaaabbbbbbbaabbbaababaabaabbabaaabbabbababbaabbababaababaababbabababaaabbbbaaaabababbaabbaababbabbaababaaaabbaaabbaabababaababaaabbaaaaaaababaaaaaaabbbbbbbaabbbabbbbbbabaabbabaabaaaaaababaababaabababaabbaaabaabbaabaaaaaabbabbabbabbbbaaaaabaaaabbabaaaaabbaabababbaabbbabababbabbbaabaabbabbaaababbabbbbbbbbabbbbaaabbaaaabaaabbbbbaaabbabbbbaaaabbaabababaababaaaaaabbabbabbbbabbaaaaabababbabbbaaaabbbaababbbabaabaaaabbbaabaaabaaababaabbabbbbabaaaaabbaabbbaaabbabbaaaaaaaababbbabaaaaababaaabbabbaaaaaabbaaaababbabbbbbaaaaabbbabaaaaaaabaabbabababbbaabbaabbbbaabbbabababbabbbbababbbaaabbbbaabbabababbaaaaaabaaabaabbbaaabaabbbaabaabaabbbbabbabaabbbbbbbbabaaaaaaaaaabaabbabbaaaaabbbaaabaaaabaabbbbabbabbabbbaaabbbaababaabbaaabbbabbaaabaaaaabababbbaaaabaaaaaabaaabaabababbaaaabaaabaaaaababbbabbbbabbbaaaaaaaaabaaabaabbbbaabaabbaabbbaabbbbbbbbaabbaabbbbbbabbaabbabbbaaababbbbbbaabbbbabaabababbabbbbabababbbbbbabbababababaaabbbabbbbaaaaabaaaaabbbbbaababaabbabbbabababbaaabaaaaaabbbaabbabbabbabaaababbaaaabababbbbaaaaaabbaaaaabbabbbbbbbbaaabbabbaaaabbbbbbaaaaababaaaaababaababbaababbbabaaaabbaabbabbbbaaaaabaabbbabbaaabbbabbaabbbaaabaabbbbaaaaaaabbbbaababaabbbabaaabbaaaaaaabbaaaaaabbbaaabbabbaaaababbaaaabbabaabbbabbaaaabaabbabbbaabaaaaaaabbaaabababababbaabbabaaaaaaabbbaabbabbaaaaababaaababababaaaaaabbbaaaaaaabaabbbabbbabbbbabbaaaabbbabbaaaaabababaabaababaabbbaaaabaabbabbabaaababababbbaabbababbaaaaaaabbababbbaabaabaaabababbbaaaaaabbabbabaababbbaaaaaabbaabbaaabaaabbbbabbbbbbaaababababbbbabbbbbbaaaaabababaabbbbbbbbbaaaaabaabbaabaaabbbabbbbbabbababbaaabaababaababbbabbababbabbaaabbbaaabbababbbaaabaaaabbaaababbabbbabbbabbbaaabababbaabbbaabbbabaababbbbaaaabababbbababbbbbbbbababbbabbbbabbbaaaababbabaaababaaaaabbaabaababaabbbbabaabbaabbabaaaaaabbaabbbbabaaaabbaaaabababbbabbaaaabbabbaabaabababbababbaabbabbbbbbaababbabbbaabbaaababababaabaaabbbbbbbabbabbbbbabbabaaaabbabbaaabbbbaaababbaaaabbbbabaababaabaabbabaaabbbaabaaaaabaaabaaabaaababbaabbabbabbaaabbbabbbbbaaaaabaaaaabaaaabbbababbbaabbbbaaabbaabaabababaaabababbbabababbbbbbbaaababbbbaabbbababbaaabbbabbbbbaabbbaaaabbaabbaababbbabbbbbbaaaabaaabaabbbabbbaababaabbbbbbbaabbaaaabbaabaabbaaaabaabbbabbaabbbaabbbabbbbabbababbababaaaababbabaaaaabbbaaaaabbabbbaababbbaababbbaaabaaabaaabbbbbababbbaabbabbaaababbbaabababaabbbaababbabbbbbabaaaaaabaaaaaaababaabbabbbaababbaababaaaaabbabbbbbaaaabaaabbaabaaaabbbaababbaabbbbbbbbababaabbbbaaabbbbaabbbaabbbbbbaaaaaaaabaabbaaabbabaabaabaabbaabaabbbbaaaabababbbbababbaaabaaababaaaaabbbaabaabbbbbabaaabaaabaabbabaaaabbaabaabbbbbaaabbabbabbbaababaabbaabaaabaaabbaaaaaaaaaabbbaaabbabababbbaaabbabbababbbabbabaaaabaaaaabbbaababaaaaaabaaabbabbbbaaabbabaabbbababaaabababaabbbabbbbbabbaabababaababaaaaaabaaabaaabbaaaaababbaabaaabbaabbaaabaaaababbbabaaaabaaaabbaaaaabbaabbaaabaaaabbaababbbaabaaaaaabaaabaabbabbaababaaabaabbabbababbbabaaaababbbbbaabbaabbbbaaaabababaabaaaaabaabbbabaabababaababbbbabbababbbbaaaaabbaaaabbaababbaabaaabbbaabbababbaabbababaaaaaaabbbababbabaaaaabbaabbbbaabbaaaaaaaaabbababbababbbabababaaabbbaaaabbabbbbaabbbbaaabbbabaaabbbbbaaaaaabbabaaaaababbabbaaaaaababbaabbaabbabaababbbababbaabbaaababbbaaaababbaaaaaaabbababbbabbaaaaaaabbbbbababbabaabababaaaabaaaaaabbbbabbbbaaaaababababbaabaaabbaaaaabaabbaaaabaaababababaababaabababbabbbbabababbbabaabbababbbababbababbabbbbbbbaabbbbaabbabbbbaaabbbbbbaababaababbaabaaaaaababbbbbbababbbbabbabbaaaabaaababaabbbababbababbabababbabbaabaabaaababbaabaaaabaabbaaaabababaababbbabaabbbaabaabbbaaababbbababbbbaabbabaaaababababaaabaaababbbbaabbbaaaabaabaabbabababbbabaabbabbbbbaaabaabbabbababbbabaabababbbbaabbaaaaabbbaabbbaabbaababbbbbbababbaabbabaaaaaaabbaabaabaaabaaaaabbbbbbbabaaababaabbabbbbbabbaaaabaaaaabbbbabaaaabbaaaaabaaaabaaabbbbbabbaaabaaabbbbbaaaabbabbabbababababbaabbbaabaababaaabbbababbbaaababbaaaaaaabaabbababbababbbbbaababaabaaaaaabbabbbabbabaaaabbbabaabababbbabaabbaababbabaabbabababbbaababaabababababbaabbbbabaabbabababbbbbbaabaaaaaabaaabbaabbaaabbbbabaaaaabbbbaaaabababbbbbaaaabbbabaaaabaababbaabbbabbabbaaaaaaababaaabbbaabbaabbaaababaabbaabbabbbaaababbbabbabbbaabbababaaababbbbbabbbaabbbabbaabbbbbaaaaaababbaaabbbabbbbaaabbbaaaaaabbaabbbbabbabaabbbabaabaabbaaaabbbaaabbbabbbbaaaabaaababbbaababababbbabbbaabbabaabababababaaaababbbababbaaabbbbbbbbbbbaabbaaaaaabbbaabaabbbbabbaabbabbbaaaababbbabaabbbbbaabbbbabaaaabbbbbbabbbbabbababababbabbbaaaaabaaabbbaabbaabbbbbababbbbbabbababababaaaaaaaaaaabaaaaabaaaaaaaabbbaaabaababaaabaabbaabbabaaaaababbbabbbaaaaabbaaaaaabaaaabaaabbbaabbaabbbbaabbbaaaaabbabbbbabbbbabbaabbbaaaaabbaabbbbaabbbababbabbaabaabbbbbababaabaaaaaababbbbabaaababbabaabbaaaaaababaabbaaabaaaabaaaaabbbbbbaaaabbaabbbbaaaaabaaaabbaaabbabbaabbaabababbbaaaabaabaabbbbbaaababbbbaaabbabbbababbaaaaabbabaababaababbaabababbabbbbbaababaababaaaabbabbaaabbaabababbbaabbbaababbaababbaaaabbbaaabbabbabbaabbbababaabaaabaaabbaaaabbbbbaabbaabbaaababaabbbbbaababababaaaabbbbbaaabbaabbbaaabbbbbbababbbbaaaabbabbabbaabbabbbbaabbbbbbbbabbbababaaaababbbbbbabbbbbbabaaaabbbabbbaabbbbabaababaaabaaaaaabbbababbbaabaaabbabaaabaaabbababbbbbbbbbabbbabaabbabaaabbabaaaaaaababbabbbbaabaaaaaababaabbabbababbbaaaabaaababaaabbaababbbabbababbaabbbababbabbaaabbbabbaaabbbbabbaabbabbbbabbabaaaaababbbbbbaaabbabaabbbaabbbbabbbabbabbaabaababaaabaababbaabaabbbbbabbaaabbbbaaabbbabaaaaaabbbbbbababbbbbbaabbbababbbabaaabbbaababbaaaabbaaabaaaabaaabbaaaabbabbabaababbaaaaabbbbaabababaaaaaaaaaabbbbabaabbbaabbbbaaaabaaaaabaaaababaaabaaabbbbaaabbabbaaabaaababbbabaabbabbbbbaababaabababaabbbbabbbbbaabbbabbbbaaabaaaabaaaaaaaabbaababaabbabbbaaaababbabaabaaaaaabaabaabbaabababababaabbbbabbaabaaababaaabbbbabbabbbaabaababbbbbbabbbbaaabbbbbbbaaababbaaaaaabbbbbabbbaababbbaaabaaabbaaaababaaaaabbbbabaabbbabaaaaaaaaaabbbaabaaaaabaaaabbbaabaabaaaabbaaaaaabbabaaaabaaabababaababbaabbbaaaaabbaaababbaabbbbbaabbaaaabbaababbbbaaabaaaabaaaaaabaabbabbbabababababbbababbaaabaabababbaabaaaabbbaabbbbabbbbaabbbbbaababbaaaaababbaabbababbbbbbbababaababaaaaabaabaaaabbbbbabbabababbbabbbbaabbabbbababbaaaaaabbbaabaaaabaaaabbaaaabaaaabbabbabababbaaabaaabaabbaaabaaaaabaababbbaabaaaaabbbabbaabababbaaaaabaabbbabbabbabbbbbabababbabbbabbabbaaaaaabbaaabbbabbaabbbabababbbabbbbababbaabbbbaaabaaababaabbabbbabaabaabbabaaaabaaaaaabbabababaabaabbabbbbabbabbbbbabaabaaabbaaaaaababbabaaaabaaaabbabbabababbbbbbaaabbbbaababbbabbbabbababbabbabaaabbbbabbabaabaaabbabaabbbabbabbaabbbbabaabaabbabbbaabaaaaaabaabbbbbbaabababbbaaabbbabbababbbaaaaabaaabaaaababbbbaabaaaabababaaaabbbabbaaaabbbbabababbaabbabaaababaaaaababbbaaababbbaababbababbaabaabbbbbbababaabbaaaababbbbabaaababaaaabbababababbbaaabbabaaabababbaaabaaabbbbaaabbbbaaabaaaabaaababaaabbbaaaaabbabbbabaabaabbbbbabbbabababaaaaaaababbbbbaababbbabaaabbaabbaaaaaabbababaaabaabbabaababaabbabaababbabbbbaaaabbbbabbaaaaaabbbaaabbbabaababbbbbbabaaaaababbbbaabbaabaababaaabababbaaabaabbbbaabbaabbbabaaaaabaabbbbaabbbaabbbbbaaababbabbaabbbababbaabbbbaaabaaaababbababbbbabaaabbabbabbbaaaaaaaaaabaabbaaaabbbbaaabaaaaaaabbaaaabaababbbaabaabbabbabaaababbbaaaabbaaaaabaabbbaaabaaaababababbbaabbababbaabbaaaaaabbabababbaaaabbbbbabbbababaababbbbabbbaababbbbbababaaabbababbabbbaaabbaaaaaabaabbbaaababbbababbbbbababbaabababaaabaabbbbaabbbbaaabaaabbbaaaaaaaaabbabbaaabbabbabaaaabbbbaabaaaabaaabbabbbaabbabaaaaaabaaabbbbbabbaabababaababbaababbaabbbbbababaababbaabaababaaaaaaabababbbabaabbaabbbabbaaabaabaabababbabbbaabababbbbabbabbaaabaabbbaababbbabbbbbbabbbabbaabaaabbaaabababbaaabbbaabaababbaaaababbbbbabbabababaaaababbaaaaaabbbbaaaaaaabaabaaaaabaaabbbbaabbbaabaabbbbaabaabbaaaababababaabbbbaabbbaabbbbbbbabbbbabbaaaaaabaaaaaababbabaaaaaabbabaaaabababbaabaababaababbababaabbaabaababbaabbbbbbbabbbbbabbbaaabbaaabbabaaabbbababbbbababbbbaaaabbaabbbaabaaaabbbaababababbaaabbbbabbababaaabbaaabbaaabaabbaaabbaaabaaabaabaaaaabbbbbbabbbbbbaaabbbabababbaaabbabbabbbaababbbbabaaaaababbbabbabaabbaabaaaaaababbbaaaaabbbaabbbbaaaabababaaabbabbbbbbabbbaabbbbbabbabbbabbabbabababbbaaababbbbaaabaaaaabbbbbbbbbbbbbaabbbbaaaaaaabbabbaaabababababbbbababbaaaaababbabababbbaaabbabaabbabaababbababbbabbbbbabbaabbbabbbbbaabaaabaabbbbbbaaabaaabbbaaaabbbbbbbbbabaaabbabbaaaaabbabbaababaaabbaaabbabbaaaaabbbaaababbababbbaaaaabbbabbbabbaabbabbbaababbbaaababbbaaabbaababbaaabbaaaaabaabaabbbaaabbabababbaaabaabbabbbbbbaaababaabbbbbabababbbabbabaabbaababaabbbbaabaaaababbbabbbbbaabbabbabbabbbbaabbabaaaaaaaaaaabbbbabaaaaaaabbabaabbbababaaaababbaababbbbabaaaababbbabbbbbbbbaaabbbbaaaabbaaabbbaaababaabbabbaaababaaabaabbbabbbaabaabaabaababaaabaaabbbaabaaabbbbbbbbababaaaaaabaabbbbbbabaabbabaabbabbbbbaababababbbababaabaabaababaaabababaabbaabaabbbaaaaaaababbbbbabaaabbbbbbbbaaabaaabbbbbaaabbaabbaabaabbababbabbaababababbabbbbaaabbabababaababaaaaaabababbabbaababbbbbabaaaababaababbabaaabbbbabbbbabbbbaaaabaaababaaabaabbbaaabbaaabbbbbaabaabaababbbbbbbbbabaaababbaabbbaabaaaaaabbaaaabaaaaabaabaaabbbbaabaaabbaaaaaaabbbbbbbababbaaabbababababababbababaaabbbabbaaabbaaababbaaabaaaabbabbbabaaaabbaaabbbaabbbababbaaababaabaabababaaaaaaaaaaaaabaaababbbbbbbabbbaabbbbbbaabbbbaababbbbbabbaabbbaaaabaabaabbababbaaabbbbbaabbbbbbaaaabbaaabaaabbbaaabbbbbbbbabbaababbaababaaabaaababbbbababbbaaabbbbbbabbabbbbaaaaababbaabaaaaaaabbbbababaabbabbabbabaaabbbbabbbbbbabbbbbbabbabaabaaabbbbbaabbaabbbaabaaababbabbababbbababbabbbbabbabbbbbabaaabaababaababbbaaabaabbaaababababaababbbabbabbbabbabbabaaabaabaababbabbbbbaabaaabaabbbbbbaabbbabbbabbbaaabbabbbaaabbbabbbaaaaababbbbababbbbaaaaaaabbbbbbaabbababbbaabbbbbaabbabbaabaaaaaaaababaaabbaaaababbababaaabbbaaaabbbaaabbabbaabababbbaabbababbabbbbababbaaabbaabbaababbbabaabbabaabaababbbaabaabbaaabaabbaabbbaaaabaabbaabbaabbbbbbbaaaaaabaabbaaaababbbaaabaaaaaabbbbbbaaaaaaaaabaabaabbbababaaaaaaaabbabaaabbaaabbabbbbbaabbabaabaabababbbbbaabaaaaabbabbaababbbabbbabbababbbaaabbbbabaaaabbbabbbbaababaaabaaabbabaaabbaaaabababbbabaabbbbabbaaaabbaaababbaabbbaababababbbbaabbbababaabbbbbabbbabababbbaabaabaaababaabbaaaaabbabbaaaaabaaababaabaaaaaabbbababbbbbbaabababbbbaaaababaababababbaaaaaaaabbbabaaaabaabaaaaaaaaaaaabbbaabaaaabaababaabbabaaabaaabbabaaaabbaabbabaabbabaaaabaaabaaabaaababbbbabbabaabaaaababbaaaaababbaabbaabbaabababaaababababbaabbababbbbaabbbbabbaaabbabaabaabaabaabaaaababaaaaababbaaabaaaaabababbaaaababaaaabbaabaaaaaaabbbaabbaaaabbabbbabaababbaabbaabaabbabaabbbababbabaabbbabbaaaaaababbbbababababaaaaabbbabbbabbaaabbbaaababbbabbaaabbaaaaaababaababbabbbaaabaaaaabaaababbbaaaabbaababbabbaaababbababaaaabbbbabbabaaabaababbbbbbbbbaabbaaabbbabbaaabbbbabbabbabaaabaabbbbbbaaabaaabbbbbabaaabbbbaabbababbaabbbaaabaaaabbbaabaaabbbabbbbbbbbbabbbaaaabbbaabbbaaabababaabaaabbbaaabababbbabbbbabbbabbababbbaabaaaabbababbbbbabbbababaaabbaaabaabbbaabaabaaaabaaabbbabaaabababaaabbbbabbabbbabaababaaaabaaabbabbaabaabaabaabbbbbbbbbaaabaaaaababbabbbaabaaaaabbbbbabbbaaaaabbbbabaabababbabaababaabbabaaabbbbbbbbbbbabaaabaaabbbbaaababbabbaabbaabbaaabaababbabaaabbaaaaaaabbaaaaababbbbbabbbbbaabababbbaabbbaabbaaaabbabbbaaaabaaababaaaaabbbaaababaabbbabbbbabaaababbbabaaaababbbbabbaaaabbbaabbbaaabbabbabbaabbbaabbbaaaabaababbabbbbbbabaaababbbbbbbaaabbbbbbaaabaabbabaabaabaaaabbbaababababbaaaaabbbbaaabbbaaaababababbaabaaabbaaaabbbbbbbabbaaaaaababbbbbbabbaaabbbabababbaaaaababbabbbbabbbabbaabbbbabbbaaaabbaaaabbbaababbbbbabbbbbaababaabaaaabbbbbbaabaabbbabbabaaaaaabaabaaaabbbbababaabababbaabbaabbabbaaaaaaaaabbbaaababababababaaaaaaaaabbaaabbbabbabaababbaaabbbabbbbaabababababbbabbabbbabbaabbababaababbaaaaabaabbbaaabbaabbbbbbbabaaabbbaabaabbbbabbabbaaaaabbbabbaaabbbaabbaababbaaabbaabbbaaaaaabaabbabbbaabababababbbbabaabaaababbaaababaabbbaabaaabbbbabbaabbabbabbbaaaaabbaaabbaababbababbabbbabbbabbbbabbabbbabbabababbbbabaababaaabbabababbabababbaabaabbbababababababbbbbbaababbaabbaaababbbbbaaababbaabbabbabbababbaaaaaabbbbbabaabbbaaabbaabbaaabbbaababbabaabababbabbbaababaaaaababaaabababaaabaaabaabbaaaabaabbaaabbbaabbaaaaaaabaabbbbababaaabbabababbababbbbabbabababaabbabbaabbabaaabbaabbabbbaaaaaaabaaaabababbaabaaabbbaabbaabbbbbbbabbbaaabbaababbabbababbbbbaabbaaabbbbbbaaababbaaaaabaababbbabbabbbbabaaaababaababaaabaaabaaaaabaababbabbbbaabbababaababbbbaabaabbabababaabbaaaaabaaabbabaabbabaabbbaabbbabaaaabbbbaaabbbababbaabbbbababbbaaaaabaaabaaaabbaaabaaaabaabaaaaabbaaabbbaababaabbababbbaaaaabbaaabaabbbaaabbaaababaabababaababbbaaabaaabbaaabbbaababbbabaabbabaabbaaababaabaaabbabaababbbbaaaaabbaabababababbabbbaaababbbbaabbaaaabbbbaaababaaabaaaaababbbbbbaaabaababbbbbbbaaaababbbaabbaabbbbbaaabaaabbaababbabbabaabaaabababbbbbaabbbabaababbbbbabbbaabbbbbbbbabaaaabbbaaaabbababbaabaabbaaaabbabbbbbbaaabaaaabababaabbbbaaabababaaaaabbbbaabbaabbaaaabaabaabbbabbabababaaaabaaabaaabbaabbbaabbbbbaabbabbbbaabbbabaabbbbabaaababaababbbabaaabaaabaabaaabbbbbbbabbabaabaabababbabbbbaababbabababbaabbbbabbbaabbbaabbbbbbaabaaaaabaaaaabaababbabbabbbbbababaabbababaabbbababaababaabaabababbaaaaaabbbaabbbbbaaaabbaababbbbabbbababaaaaaaabbbabbbbabbbaabababbbabaaabbabbabbaabaabbbabbbaababbabbaababababbaaaabbbbaababbbbabbaabbaabbbaabbbaabaaaabbaabaaabaaabbbababaaabaaaaababaaabbbbbabbbaababbbaabbaabaaaabaaabaabaababaaabababbabbbabaabbabbaaaabbababaaaabababbaaabbaabbbabbbbbbbaabbbbaaaabaabaaabbbababaaabbbaaababbaababaabbabbbbaaababaababababaaaaaabbbbbaabaabababaaaababaaaaaabbababaaaabbabbabbaaaaaabbabbaabbbabaabaaabaaaaaabaaabaaabbaaaaaaaabababaaaaaabbabaabbbbbbabaabbbbbbbabaaaaaaaaaaabbaaaaaabbbbbaaaabaabbabbbbbaaabbbabbbaaabbabbbbbbbabaabbbabbaabbaabaabaabbbabbaaaaaaaabbbbbbaaabaababaabbbabbbabaabbbbbabaabaaababbbabbaabbbabaaaaabaabbaabbaabbababaababbabbbbaaaabbaabbbbbbbaabababbabbbbbaaabbbbbbaaaaababbbababaabbaabaaaabaaaabbbbbabbaabbbaabbabbaabbaaaababbaabbbabbabaabaabbbaababbaaaaabbababababbabbbabaaaabaababbbbbabbbbababaabbabaabbababbaaaabbbbbaaaaabbabababbbabaaaaaaaaabaaabbbbaaabbabbaaabbbaabaaaaaaabbaaaabaaabbbababbbbaaabbabaabaababbbbaabaaabaabaaabbbaaabbbabbbbaaabbabaababbbabbbbbabaabbaabbbababbaababbaaaabbabbaabababbbababbbaababbbbbaaaababbabbabaaababbbbbabaaabbbbbbaaaabaabababababbababbbababbabbaaaabbbaaaaaaabababbbabbbbabbaabbbbbbbbbbababbbbaaaababaaaabbabbaaabaabbabababbaaaabbbbbabbaabbbbabaabbaabaabaaababbaabaaaaabbaababaabaaababbbbbaaaabbbaaaabbbabaabbbaaabbabbabbaabbaabababbbabbbabaaaabaabaababaabaabbbbabbaaaabbaaaababaabbbabbaaabababaabaabbabbabbbbaaabaaababbabbaabbaaaaaaaaabaababbabbbbbaaaaabbbaababaaabaaabbaabbabaaabbbaababbbbabaaabbaabbbbbbbbbbaabbbabbbbababaabaaabaabbbababababaaaaaabaaaaaabbbabaaabbabaabbababaabaababbbaaabaababbbabbbbbaaababbaaabbbaabaababaabaaabbbabaaaaaababbbaaabbbaababaababbbaabbabbbaabbabbababbbababbaaababaaabbbaabaaabaabbbabbbbbbbbabaaaababaaabaaaabbbaaabbabbbabbabbabbabaaaaababbbabbaaababaaaaaaabbbbbbaaabbaabbaabbbbabbabaaabbbabaabbbabaaaaabababaabaabaaaabaaaaaaabbaabaaaaaabbbbabababbbbbbbbbaabbabaabbbbaaababbababbbaaaabbbbbbbaababbaabaabababaaaabbbabbbabbaaaaabababaabbbbaababbbaabbbbaabaaaaabbbbaabbaababababaaabababaaabbaabbbbbaaaaaaabbbaabababaaaaababaabbbaabbbaaabbaaaaaaaabababaababbabbbbabbabbbaaaabbbaaabbbbabbaaabaabaabababaabaabbaaaaaaaabbbaabbabbbaaaabbbabbbabbbbaabbbaabaaabaaababababaaaaaaaabbbbabbababbbaaabbbabbababaabbaabbbbaababbbaabbaabaabaababbbabbbbbabbabaaabaaababababababaaabbabbababaaabaabbabababaaaaabbbbbbababbbbbaaaababbabaaabaaaaabbbbabbaabaabbbaabaabbababbabbaaaaabbbbbaababbabababaaaaababaabaabababbaabababbbbbabbbaaaabbaabbbaababaabbbaabbbaababbabaaaabbbaaaabbbabbabbabbbaabbaababbbbabbaabbaabbaaabaabaababbaabbaaaabbbababbbaabaabababbbbaababaaaaaaabbbaaaabbababbaaaabaaaababaabbaabaaaabaabbababbbabaabbabbaabaaabbabaaaaabaabbbaaaaabbbabbbbaabbaaabbabaaaabaaaabbababbababbaaaaabbabbbaaababaaabbababaabaabbbaaaaabaababbaabbbaaababaabbabaababbbabaaaabababbaaabbbaaaaabbaaaaabaabaaaabaaaaabbabbbbbaabbaaaabaabbaaaabaaaaabbaababaaabaababaabababbaaababbbbbaabbaabababbabbaaaaababaabbabbbaaaabbbbbaabbaaababbbaaaabaababaaaabaaaabaaaabbbabaaaaabbbbaabaabaaababbbaabaabaaabbbbabbabaababbbbaaabababbabaaabbaabbbbaabaabbbbbbbbaaaabbbbbabaaaaaabbbaabaababababaaaabbbabbbabaaaabbbbaabbbbaabbbbbbaaaababaaaabbaaaaabaabbbaabaaaaaaabaabaaaabbabababbbbbabbaaaaabaabbbbabbbaaabbabbaabaaabaaaababbaaabababbabbaabbaaababbabbbbbabbabbaaababaaaaabaaaaaabaaaaabaabbbbbabaaaaabababbaabbabbbaaaabaababbaaaaababbbbbababaababbbaaaaababbbbbbababbbaabaaaaabbbaabbbababababbbbaababababababaabababbbbbabbabaabbbabaababbbbbaaabbababbaaaababaaabaaaaaabaabbaabbaabababbbbaabbaaabbaaaabbabbbabbbaaabababbaaaaaaaababbbbbaababbabaaabaababaaabbaabababbbbbbbbbabbabaabbbabaabaabbababaaababaababbabababbbbbbabbabbaaabaabbbabbbbaabbbbbaabaaaabbaabbabbbaaaabbbbaababaabbaabaaabbaaabababbaaabbbbaabbbbaaabaaaaaaababbabbbaaaaaabbabaabbabbbbbaaaaaaabaabaabbaaababaabbabbabbbbbababbaaabaaabaaaaaabbbaaabbabbbbbaaabbbbabbabaaaabbbaaabbaaaabbabaababababbbbbaaaabababbbbababbbabbaaabaaaaabbaabaabaababbaabaaabaaababbbbbaaaabbabaabbabbbaababaabaababaabaabbbbbaaaaaaaabaabbababbabbbbabbababaaababbbbbabbbabbaabbbabaaaaabbaababbabbbbabaaaaaabbaaababaaababbaabbaaabaabbbabbabaaaabbbaaaababbaabbabaaabaaaabaaabbbaaaabbabbbbaabbaaaabbbbaaabbababaabbaabbababbbabbbbbbbbbaaababbbabbabaabbbabaabbbaaaabaaaabbabaabbbaabbbbbababaababbbbabbaabbbbbbaabaabbbabbaaabbbaaabbbaaaaaabbaabbabaaabbaaaabaaaababbbbaabaaaaaabbabaaababaaabbaabaababbabaaaabaabababbaababaaaabaaababbbbbbabbaaabaaabababbbaabbaaaabababbbbbaabbaabbbbbabbabbaaabaaaabbaabbbabbbbaabbbaababbabbbaaabaabaabbaaaaaaaaaaaaaaaabaaabaaaabbaaaabababaabbabbabbaaaaabbbbaabbabbbaabbaabbbaaabbbabbaaabaaabbbbabababbabbbaabababababaabbbbbbbaaaabbaaabbaaaaabbabbabbaaabababbabbabababbbaaabaaabaaababbbbabbbaaaababbaaabbaaaaaabbabbaabbbbaaaaaabbababbbbbaabbbabbabbaabaaaaabaabbbbaaabbaaaaaabbbaaababbabbbaabaaaaaabbabbbbaaaabaaaaaabbbabaaaabbabaaabaabaaabbbabbababbbbbbbaaabaaabababbbabaaabbabbbbaabaabaaaaaababbaabbaabbabaaababbaabbbaababaaaabbbbbabbbaababbabaaaaaaabababaaaabbaabbabbbababaabbabbaaabbababbbbabaaababaababaabbbbaaaabaaabaabbaababbaaabbbbababbabbaaaaabbaabaabaabbbaabababbabaaabbaaaaaaabbabababbaababaaaabaaaabababbabaabbaaaababbabbbabaababbaaababaaaabbabaaaabababbbabbababaabaaabaaabbbabbbbabbbaabbbbabaaabaabbaaababaaabbaabaaabbabbbababbbaaaabbbaaabbbababbbaaabbabbbaababbaaaaaaabbbbaaababbbbbabaabaaababbaababaaaaabaaabbbbbaaabbbaabbbbaaabaabbabbbbbbbabbbbbababaabaaabaaaaabaabaabbabbbabbaaaabaaabbaaaabaababababbbaabbbaaabaababaaababaaaaaabbbabbbbaaaaaababbabaabbaabbabbabaaabaabbaaaaaaaababbaabbaabbabbbbbbbbabbabaabbbbbaaaabbaaaabaaabbbabaaaabbbaabaabbbaaababbbaaaaaabbbaaaababaaababbbbaabaabaabaaababbabaabbbaaababaaabaababbaababaababbbbbbbabbbaaaabaabbbabaaaababbaababbbaaababbabababbbabbbbaaabaaaabababbbbaabbbbaaabbbaaabbbabaaabaabbabababbabbababbabbaabbbbbaaabbabbbaaababbbbaabbbbbbbbbbaabbabbaaaabbabbabaababaaaabaabbbbaabbbbbaababbaaabbbbbbaaaabbaaaaababbbbaabbabbbbaabbbabbababbbabbbbabbbbbaaaaabbbbababbaaababbababbaaaaababbaabbabbbbabaaaaabbbbbbbaaababaaaabaabbaabababaabbabbbaaaaaababbbabbaabbabbaababbbbbaabbaaabbbbbababbabaaababbabbbababaaaababababbbbbbabbabaaabbbabbabaabbabbbbabaaaabaabbababbabbabbbbaaaabbbabbabbbabbabbaabbbbbabbaaaabbabbaaaaabbabaabaaabaabaabaabbabaabaaaaaabaaabbbabaabbabbbabbaabaabaaaabaabababbbbbbaaaaaabaabaaabbabbbbbababbabbababaabbaaaaaabababbaaaaabaabababbbbbabbbbaabbabababaababaaabbbabababbaaabaaaaaaaaabbaaabbabbbaaaaabbaaabbababbbbaaabaaabbbabbaabaaabbbaabbababbaabaaabbabbbabbaabbbaabaaabbbbabbbbababbbbbbaababaabaaaaabbabbbabaaaabababbabbaababaaabababbababababaaabaabaabaababbbabbaaaababbaabaaabbbbbbabbababababbbbaaabbabaabaaaaababbabbaaabaaabababbaabbbabaababaaabaaababaaababaaaaabbbaaaabbababaaaabbabbaabbbbabbbaaaabbbbbabaaaabbbaabaabbbbbbbbbbabbaaabaabaabbbabaaababaabbbaabbaabbaabbbbbabbaababaababbaaabaaaaaabbbbabbbbbbabbabbaabababababbaaabaabbaaaaaabababbbabbaaaaaabbabbaaaaaababbbbabaabaababbbbababbaabaaabbaaabababaababaabbaabbabbbabbababbabbbbababababbabaaaabaaaabbaaabbbbbababaababbaabaaaabaabaaaababbabbabaaaaaabbbaababbaaabbbbbabbbbbbbabababbabbbaaaabbaaaaaabbbbaaaaabbabbbbbaaaaaabaabbbbbababaaabbaaabbaaabbbbabbbaababaababaaabababbbababaaabbbabaaaaabaabbaaaaaabbaaaaabbabaabbbbbbaaabbbbbbbaababbaabbbbaabaaabbbbbbbbaabbaabababaabbaaaaabaabaabbbabbbbbbbaabaabbaaabbabbababbaaaabbabbbbbabaaaabaaaabaababbbababaaabaabaababaabaaababbbbbaaaaaaaabbababbbabbabaaabaabbbbabaaaaababbaaabaabbababababaabaaaabaababbaabababbbbbaababaaaabbababbbabaaabbbababbbaaabbbbabbaabaabbabbbbbababbbbbbabaabbaabababbbabbabaabbaaaabaaabbbbabaaababbbbbbabaaaabbabbabaaaaababaabaabbbbbabaabbbabaaaaabbbbababaabaabbaaabaabbbabbbbaaabbaabaaaababbbbaabbbaabbaabbabbbabbabbababbabaaabaaaabbaabababbbaabbaaabababaabbaabaaaabbabbabbababaabaabbaaaabbabababbbbaaaaabbaaabaaaaaaaabaaabbbbbaaabbaaababaaabbabaaaabbbaabbbbbaaaabbabbaaabbaaabbabbbabbabaaabbabbaaaaaaabbabbbbbabbbbaabaababaababbaaaabababbaaaaabbaaaababaabaababbabbabbabaaabbaabaaaabbbbabbbbbababababaaabababbabbaabbaabbbabbbbbaaabbababbbbaaaaabbaaaaaaabbbaaaaaaabbbbabaaabbaabaabbbabbbaabbaabbabaaabaaaabbabaabababaaaabaabababbababaabababaabbaaabbbbbaabaabbaabbbababbaababbbabbabbabbbaaaabbbaabaaabbbaaaabbabaababbbbaabbbbaabaabbaaaaaaaabaabaababbaaaaabaababaabaabbbbabaaaaaababaaaabbaaabbaaababbabaaaabababbbbbbbababbbbbbbaaabbbbbbbbbabbaaaaaaaaabaabbbbbbabbaaabbabbabababbbabbabaaabbaabbabbbaabaababaabbababbabbaabaaaabaaababbaaabbbaaabbbbabbbbbaababbababbbaababbbabbbbbbabbbbabaabaaababbaabbaaabbbbbaabaaabaaaaaaabaaaaaaaabbaabbbaaabbbbbaabbabaaababbbababbaabbababbababbbaaaababaaaaabaabbaaaaabbbbaaabbaabaababbaabbbabbbabababaababaaaababbbbbbabaaaaaababaabbbabbbbaaabbabbaabababbabbaabaaaaaaabaaaabbabbabbbbbbbaaabbaaabbbbbaabaaaabbabbbaaabbababaabbabbabaaabaaaabaaabbbabababbaaabbbbabababbbaaabaabaaaaaabaaabbbbbbbaaaaabbbaabababbbaaababbabbbbabbabbbaababbbbabbbaabbabaabbbababaaabbaaaaaaabbababbabbbababaaabbaaabbbaabbabaabbabbbaaababbabaaaaaaaabaaabbbbabaabaabbbbaaaabbbaabbabbbabbbbabaabbbaaabbaabbaaababbbbbbaababbabbaaabbbbabbaabbbbbbaabbbabbbbbbabbbabbababbabababbbbaabbbabaaabbabbaaaabaabbbaaabbabbbaaaabaabababbabbbaaabbbaabbaaababbbbaaabbbbbbabbbabaabbababababbbbbabbababbbbaabbaaabaabbbbaababbababaabbbbbaabaaabbbaaabbbaaaaabbbabbabaaabaabaaaaaababbbbabbabbaaababbbabaabbabbaaaababaabaabaaaabaababbabbaaaaabaaaaaababababbbbaaaaaababaaabbbababbbaaaaaaababbaababbabbabaabbaabbbabaabbaaabaabaaabbbabaabbbbabbbaaababbaabbbbbabbbaabababbbbaababababaabbaabbbabbaababaaabababaaaabbbbaabbabaaaaabaaaabaabababaaabbbbabaabaaaaaaaabbbaaaaabbaaaabbabababaabaaabbbbaabbababaabbaaaaaaaaababbbbbaabbaaabaabbabaaabaabbbbbaaaabbaabaabaaabaabbbaaababbbaabbbabbabbbaaabbabbaabbabbaabbaaabbbabaababbaaaabbbabababbaabbabaabaaabaabbbababbabaaaaaabaabbaabbabbbabbaaaaaabbaaaabbababbababbbbbabbabbaaaabaababababaababbbbbaaaabababbaabbaaaabbaabbbaaaaaaaabaaaabbababaabbaabababaaaaababaabbaaabababbabaaaaaababbbbababbabaaababaabbbbbaabbbbbbbaaaaaababbaabbbabaabbabbaabaaaabaaabaabbabbbbbbbabaaaaabaaabaaababaaaabaababaaaaababbbbabbabbbbbaabbbabababaabababbababaabaababbabbaabbaabaabbbbbbbababbaabaabaababbaababbababbaabbaabaaaabbbaabbbaabaaaabaabbbabaabbbabaaabaababbaaaaabaaaaaaaaabbbbbbaabbbaaabaabaaabbbbaabbbabbabbbbbabbbaaaaaabbbbbabaabaababbabaabaabbaaabbaababbabaababababbbaaaabaabbaabbabbbababaaabaabbbaaaababaaabbbabbbbaabbbaaaaaaabbbabaabaaabbabbabaababababbbaabbbbababaaaaabbbaaabbbbababbabbbbbbbaaabbbabaaabbababbbbaaaabbbaaaababbbbaababbbaababbabaabbababbbabbabbbaaaabbbabbaabbbabaabbababbabbbbbaabbbaaaababaaaaabaaaaabbbabbaaababbbabbbbbbbabababaaabbaaabbaabbaaaabbbbbbbbabababaabbabbbaabbabaaabbbaaaaaababbbbbbabbbabaaabbbaaabababbbaabaababaabaaaaabaaaaabbbbbbabababbabbaaaaaaaabababaaaabaabaaabaabbbaabababbaaaababbaabbabaaaaaabaaabbababaaaaababbbbbbababbaabbbaabababbbabbbbbbaaabbbbabbaabbbabbaabbbaabaabbbaababbbbbbaabbaaaaaababbaaabbabbbbbbbabbbababbaaaababaaabbbaaaababbaababbbbabbbbbbaaaabbabbbbbaaaaababbbabbbababaabaaabaaabbbbababaaaabaaababbbaaabaaaabbaabbabbaaabaaabbbabaabaaabbaaaabbaabbbbabaaaabaabbababababaabaaaaaaaabaababbabaaaaabaaaabbbbbabababbabbbaabbabbabbabbbbbbaaabbbbabbbaabaabababbbbbaaaabaababbaaaabaababaabababbaabbaaaaaaaabbaaaabaabaaaabbbbaabaaabbabbbbabbaaaabaababbbbbbbbbaaaabbabbbbbaabbbababaaaaabababaabbbaabbabaaabbaabababaabaaaaabbbaabbbbbbbabaaaaababbbbbbabbabbbabaababaababbbbabaabbbbbbabaabaababbabbbaabbbababaaabbbbababbababbbbbbabaaaabaaaaaaabbabbaaabaaabaabbabbabaaaaabaabbbaabbabaabbbbabaababbbbbbaabaaaababaaabbabaaabbbbaabbaaaaabaaabbabababbaaabaaabbbaabbabbbaaaaaaabaabaaababababaabbaabaaabbaaabaabaabbabbabaaabaabbbaabaabbababababaaaaaaabbaaabbababbbbbbbbbbbbbbbaabbbaabbbbaaaabbaabaabbbaaabbbaaaaaaabaabbbabbabbabbabbabaabbaababbaaababbabbbaabaaabbaaaaababbbabbbaabbabaaabbbabaaabababbbaaabbaabbbaaabbaababbbbbaababaaabbabbbbbabbaababbababaabaaaabbbbaabbababbbaabbbbbbbaaabaababbabbabaaabbbbaaababbabaabbbaaaababbbbbabbbaabbabaababaaaaabbabbababaababbabbbbabbabaaaaaaabbbababbbbaaabbabbaabaaaabbabbbbbaabbaabaaabaabbbbabaabbbbaababbbabbaaaaabbabaabaababbaabaabbabaabaabaabaaabaaabbbbbabbabaabbabbbbbbabaabbbabbbbabbaaaaaaabbbabbbbaaabaaabaababaaabbaabbbbabbbaababaabbababbabaabbaabbbabbbaaaaabbbbabaabbabababbabaaaababbbbababababbabbbbababbaabaaababababaaaaaaabbabbbaababbbbaabbaaaaabaaababbbbbaaababababaaabbaabaababababbbaabbbaababababaabbbbaabbaabaabaabaaabbabbabaaabbabaaabbbaabababbabbbaabbbaaaaaabaabbbabbaabababaaabaaaaabababbaababbaabbaabaababababababbaabaaaabbbaaabbbbbaabbabaaabbbaababaaabbbababababbbaabbaaabaaaabbbabbabaaaaaaaaaaabbabbbbbaabaababaabaaabbbabbabbaaabbbbababaabaaabaababbaaaaabbabbbbabaaabbabbaabbabaaabbbbabbbaababaaaaababbbaabaabaabbbbbbaaaabbbbbbaababbbbbabbbbababbbabaaabaaabaaabababaaabaaabbbababaabaaaabaaaaaababbbbbaabbababbbbbabaabbbaaaaaabababababaaabbaaaabaabbbabbbbababbbabbaababaaaabbaaabbbaaaabaaabababaaaaaabbbbabbaabbbbbbbbbababbbbabaabbbbaaababbbabaababbababbbbabbbabaabbbaababbbaabababbbabbbababaaaabbbaaabaabbbabaabbbabbbaabbaaaaababbbabbabaaabbbbbbbabaabbbaababaabbaaabbababbbbabaaabbbaabbaabababbaaabababbaaaababbbbbaabaaaabaaaabaababaaaababaaaabaabaabbbbbbaabbbbaabaaabaabbabbabbbbabbbabababaabbabbabbbaaabaaaabbbbaaaababaababaabbbbabbaabaabbbbaaaabbabbabbabaaabbaaaabbbaaababbbbabbbabbbbbbaaaaabababbbbbaababbbabbabaabbaaabaabaabbaaaaabaaaabbaaababbbaababbbbabaabbaaababababbababbaabbbbbabbbaaaabababababbaabaaaaaaaabbbabaabbbaabbaabbbbaaaaabbbbaaaaaababababbbaaabbaabbbabbbabbbbaabababbbbabbbaabaababbbaabaaabaaaaababaaabbaaaabaabbaaabbbbbaaaaaaabbabaaaaabbabbaababaabbbaaabaabaaaaabbbbababbaaabbbabaabbbbaaabaabaaabbbbabaababaaabababbabbaaababaabbaababababaaaaaaaababaababababbaabaabaabbaabbbabaababaabbabababbbaaaabaaaaaaabababbababbbbbbaababaaaabbaababaaabaababbaabbaabbbbaababbbbbaaabaabaabbbabaaaabbabbbbbaabbaabababbbbbbbaabbaabbaaabbbbaabbaababbbaaabbaabbababaaabbbaababbbaabaabbbaabbbbaabbbabaabbbabbababaaababbaabbaaaaaaaabbaabaaababaabbaabababaaaabbabaaaabbbababbbbbabbabbababaaabaabbaaaaaaaaaababaaabbbbbaabaaaaaabbaababbbbbaababbbbaaaaabababababbbaaaabaaaaababbbababbabaababaababaabbaaaaaaaaaabbbbbbbaabaaabbbbbbabaaabbbaababbbbaabbabbaabaaaabbbaaabaaabbabbaabbabaababbbbababbbababbababababbaabbbbbbbbbbaaababbabababababaabbbaabbaabbaaabaaaaabbbbaabababbaabbbaabbbbbabbaaaabbbaabaabaaabaababbbbaaabbbbaabbaaaaaaaaababbbaabaabbbbabbabaaaaabaabbabbbabbbaababaabaabaaaaababbaaaaaaaabbbbabababaabbaabaabbaaaabbbaaaaabbaabababaababaaabababbababababbbbabbbbabbbaaabbababaaaabaabababbbbbbbaababbabbbbababbaabbabbbbbbbababaaaaaabbaaabbaabbbbaabbbabaaaaabaabaaabbaaaaabaaaaabbbbaabaaaaabbbabaaaabababbabaabaabbbabbabbbbaababbbbbbaaababaabaabbabaaabbbbaabbaaaaaabbbbbaabababaaabaababbbbaababababaabbaaababaaaaaaabbbabbbabaaabbaaaabaaaabbbbababbaabababbbabbbaaabbbabbbbabbabaabbbaaabbababaabaababbaaabbbaabaaabababaaabababababbababbabbabbbbbabbbbbaaabbbbabbbbbbbbbbbaababaababbaabbbabbaabbaaaaabababaaabaaaaabbbbbaaababbbaabbabaaaabbaabbabbbabababaaabbaabaaaabaabaaaaaabbaabbbbbaaaaaabbbbabbaaabbbabaabbbbbababbbaaaabbbaaaaaaabbaababbababbbbabaabaaabaabbabbabbaabbbabbaabbabbbabbbbbaaabaaababbababababbababbbbbbaaaaaabbaaaaabbabaabbbaaaaaaababaabababbaabaabbaaaabbbaabaaaabaaabaaaaababbbbabaaabbabaaabababababbbbbbaabaabaaabbbbbabbbabaababbabbabbbbbabababaababbbaaababbbababbabbbaaababaabababaabaaaabaaaaabbbbaaaabbbabaabbbbaabbaaabaaabbbabbaaaaabaaabbaaaabbbbbaabbaabbabbaaabaabbbbaabbbbaabbbbabaababaabbbababbaabbabbabaabbbaabbbaaaabbbabaaabbababaaabbbabbbbabbbaaaababbaabababbaaaabbabbbbbabbbabaaabbaaaaaabbabbbbbaaaaaaabbababbbaabaaaabbaaabbbabbbaababbabbabbaababaabbbbabbabaaabbbabaabbaaabaaaabbbbbbbaabbabbabaaabbbbaabbbaabababaabaaabbabaaabbbbbababbaabbaabbbbbabaabbabbabaaabbabbabaaaabaaaaababaabbaabbaaababbbbabbaabbaaaaababaaaaabaaabbaabababbabaaaaabbaababababbaaaabbbaabaaabaaabbaaabbbbbabababbbbaababbbaaabbaabbabbaaaabbaababaababbbabbbbabaababaabbababababaabbababaaaabbbabbbababbaabaaabbbaaaabaabababbbbababbbaaabbbbbbaabbbbaaaabaaabbbabbbaabbbbbbaabaaabbabbbbbabaabaabbbbaababaabbbaaaaaaabababbbbababbbbbbabbabbabbbabbbbbaabaabbbabbabbaaaababbbaababaaaaaaaaabaaaabaaababaabaababbaabaaaabbaabbaabaababbabbaabbabaababbbaaabaabaabbababaaabbabbbbbabaaaaabbabbbaaabbbbbbabaabbbbbbbbbbabbbbbbbbbaaababbbababaababaabaaaaabbababbbabbbabbbbbaaaaaabaabababbbaababaabbabbaaababbbabbbaabbbaabaabbabbabbaaaaabbbbbaaaaababbbbabaabaaaabbbabbaaabbbaabbababbbabaabbbaababaabbbbaababbbbbbaaababbababbabbbabbbabaabbaaabbbbaababbabbbaabaabbbaabbabaabaabaabbbababbaaabbbabbabbaaabbbbbbbabbbbbababaababaababaabbbbababbabbbbbaababaababbababbaaaabaaaaabaaabaabbababaaabbbbaabbaaaaabababbbbbbabbbbaaaabaabaaaabaabaabbbabababaabbbbbabbaaaababbaaababaabaabaabaabbbbbbaababaababbbbabbaaabbaababbabbbabbaaaabaabbaabaaaaabbabbbaabbaaabbbbabaaabaababbbbabbabbabbbbabbababaabbbabbaabbabaaaaabbabbbbabbbabababbbbbabababbbbaaabababbabbbabaabaabbaabaabaababaababbbbaabaaaabaabababbaaabbabaabaabbabbbabbbabbaaaababbabaaabbabababaabbbaababababbabbbbaabbbabbbababbaaabbbbaaabbaabbbabbaaaabababbabbbaabaaabaababbababaaaaabbbbaaabbabbabbbababaaabababaaabababbaababbaababbabaabababaaaaabbbbbbabbaabababbbbababaabbaaaaaaaaabbbaabbaabbbbbabaabbabbbabaaabaaabbbbbbaabbaabbabbbabbaaabbabbababbbaabaaaababaabababbbaabbaabbbaabaaabaabbaaabbbbaaababbbaaaabbbabaabbaaabbaabaaabbabaababaabaabaabbaababaaabaababbbababaabbabbbbbababababbabbbbabaaabbbbababaaabaaabbbbababbbaaaaaaaabaaabaabbaabaaaaabbbbaababbbbabbaaabbaababababbaaabaaabaaaaaaaaaababaaabaabbabaabbbaababbbbbbabbbbbaabbbabbbbbabbbbabbababbbaaaabbbbababbbbaabbaabaaaaaaaabaaabaabbbaababaaabbbaaabbababbabbbaabbbbbabbbbabbbaababbbabbbbaababbababbbaaabbbabababbaaaabbbaaaabbaabbababaababbabaaababbbaabaaaabaaabbabbababababaaaabbbbaaaaababbbbabbbbbaaababbbaaaaaabbaaaaabbbabbabaaaaaaabbaabaabbbaaabbaaababbbabaababaabbbbbaabbbbabababbaabbaabbabaaaababbbabaaaaababbaaabbabbbbabbbabbbbbaabbabbbbabaababbbbaabbabaaaababaabbabbbbaabbbbabbaaaaaabbabaaaaaababaabbabbbbabaabbbbbbbabbbbaaabaaabbaaabbaaabbbbbbaababaabaabaabbbbbbbabbbbbbbbaabaabababbaabababbaaaababaabbbbaaabbabaaaaababaababaababaabaabbbbbaaaaaaabaaaabbaabbaaabaaaaababbabbbaaababbaabbabbaabaaabaaababbaaaabbaaabbbabaabbbababaaaaaabbaabbbabbababbbabaabbabbbbaabababbabbaaaabbabbbaaabbaabababbbbbbabaaabababaabbbaaaaabaabbbabbbbbbababbbababbbaaaabbaabbbabaabbbaaaaabbabaabbbaabbaaabaabbbbaaaaaaaabbbaaaabbbbbaababaabaababababbbbbbabbbbbaabbbbbbbaabbaabaabbbaaaaaaaababbbaabaabbabbaaaaabaabaababbbaaaabbbbababbbaabbbbaababaabbaabbaaabababbbbbabaabbaaabbbbaabbbababaabbaababaaaaabbaaaabbbabbbbbabaaaaabbbbbbbaaabbbbbabbbbbaabaabaababbbbbbbabbbaabaabbbbbbaaabaababaaabbbaabbabbbbabababbbabbbbbbbbbbbbaabbbabbaabbbabaabbbbabbabbaaaaabbabbbbbbbabaaabaabbbbbabbababaaaabbbababbababaaabbbbaabbbababbbbabbbabbaabaabbabababbaabbbbaabababbabbbbaaaababbabaabaaaaaaaabbbaaabbbbababaabbaabbababbbbaabbaababbaabbaaabbbababaababbbaaaabbaabaabbbaaabbbbbbbbaaaaaabbbbbbbaabbbaaababbbaaaaabaaabbbaabbbbbaaabaaaabbbbaabbbaaabbbaabbabbbbabababbbbbaaaaababbabaaababbaabaabaabababbaabababbbbbbbaabaababbbbbbaabaaaaabababbabbabbabaaabbbbaaabaaababbbabbbabbabbaaababbbababababbbbbaaababaaabbbbbbbbbbaaaabbabbbbbbbbbbbabbaabbbbaaaabbabaaaabbaaabbabaabaaabbaaaaabbaaabbababaaaaaabaaabbabbabbbabbbabaaabbaababaabbaaabaaababaabbbbabbabaaaabababbaabbbabbbaabbabbaaaabaaaabbabbbaababaababababbbaababaaaaaababbbbabaaabaaaabbaaabbaaabaaabaabaabaabaaabaabaaabbaababababaaaaaabaaaabbbbbaabbbabbbbbaabababbabbaaaababbbbbabbaaabbababababaabbbbabaaabbaabbabbbbbabbbbababbbaabbababbbbbbaaaaaabbbbbabbbbabbbbbbabbabbaaabbababbbbabababbabaaaabbbbbabaaaaaaabbabbbababaaabbabaaaaaaabbaaababbabaaabaabbaababbabbaaaabbaababbbbabbabaaabaababaababbbaabaabaabbabbbbabbbaaaaaabbbbabbbabababaaabbaababbaaabbbbabbaababaaaaabbaaaaabababaaabababbbbaabbbaaaaaaaabbbabbabaabaabbaababaaaabbbabbbbbbababbbbbaaaaababbbbbabaabbbaaaabaabbaabbbaabbbabbabbaabbabbaaaaaabaabaaabbabbabaaaabbabbabbaaabaaabaabbababababaabbbbbbbbbbbabbbbbbabbaaabaaaabbbbaaaaababbaaabababbbbbbababbbbbbabaabbabbabbbbbbabbaabaaaabbabbaaabbabbbaaabaaabaaaabbaaaabaabbabbabaabbaaabbbbbaaaaaabbbabbbbababbabbbbbaaabababbabbbabbabaababbaaabaababababbabaaabbabaaaabbabbbaaabbbabbababababbbbabbabbaaaabbbbbbbabbbaababbaabbabbabbabbbbbaababbaabbababaaaabaabbaabaabaabbababbababaaaabbabbbabbaabbaabbbababbbbbaaabababbaaabaaabababaababbaabbbbbbabbbaaaababaabbbabbbbabaaaabaabbaaaaaaaaaaabbbbbbabbaaabababbbabbbabbababbbbaaabaaaaaaaabaabaaaabbbabaaaaaababbbabaabbbabaabbbbaababaaaaababababbabbabaaabbaabbbbbabbaabbabababbaaaaabaaabaaabaabbbababbbaaaabaaabbabaaabbabbabbbbaaabbababbbaabaaaabaaabbaababbbbbaabaaaababbababbbabbbabbbaabbbabaabaabbaabbbbbbbbaaaaaaaababbaabababaaaaaabababbaaabbbbabaabaabaabababbbaaaaaababbbaaabbaaaaababbbbbaaabbabbbaababaaabbbbbbbabbbbabbbbbbbaaabaabaababaaababbbaabbbbabbbaaababababbbaababbbbbabaabababbaabbabaaabbbbbababaaaaaaaaaaabbabbbbabbbabbabaabbbbbaabbabaaabbabbbbbbaaabbaaababbabbbabbaabbabaaaabaaaabbabbbaabaaaaaabbabbbbaaabaabbbbaabbbaabaaabbbabbabbaabaababababaaaababbababbbbbbbbababaababbbabaaabaabaaabbaabbbbbbbbbbabbbabbaabbbaaabaabbbaaabbbabbababaabbbbbbbaabbaaaabbbabbbbbabaaabbabbaaaabaaabbabbbaabababaaabaabbbabbbaaaaaaaabababbbbbbbabaaababaabbaabbbbaaabaababbababaaabaaaabbbaabaabbbaababaaaabaaababaabbaabbababababbaabbaabbaababbbabbabaaabaabbabaababaabbbabbbbaaabaabababababaaabbabbaabbabaabbbaaabbabbabbbbbabbaaaaaaaababbbabbbbbaabbbabbabaabaaaaaababaababbaaabbaabbbabbbbaabaaaabaabbbbabbbababbabaaaabbabaaabbbabbabaabaabaaaaabaababbaaaabaababbaabbaaaabbbaabbaababaaaabaabaababaaaaabababbbbbaaaabaabbbaaabbabbaabaabaaaabbabababaabaaaabbbbabaababbaabbbababaabaabbaaaaabbabbabbbbaabbbaaabbbaabaaaabbabbbbbabaaaaaabaabbaabbbaaabbabbaabbbabbabaaaaaababababbababbaaaaabbabaaabbababbbbbbaaaaaabaaaabbaabababbaababbabaaaaabbababaaabaaabbbabbaaabaaabbbbabbbbaababbbbbaabbbbbbbbabbaaabaaaaaaababbbbbbbaabaaababbaabbaababaabaaaaaaabbbbaabbbbbbbbbabbabbbababaabbbbaaaabaaabababbbabbbaaabababbababbbbabababbbbbabaaabaabaaaaabbbbabbabbaabbbbbbaabbabbabbabbaaabbbaabbabbbaabbabaaaabbbababbbaabbaaabbbaabaababbbabbbbbbbbabababaabaaaaabaababbababbabbbaaaabbabbababaabababababbbaaabbbabbbaaabbbababbaababaaabaababbbaaabbaaabbaabaabbababbabaaabbabbbbbaaabaabbabbababbbaaabbbbaaaabbbbababbbbbabbabbbbaaabbbaababbbbababaabbababaaababbababbbabababaaabaaabbbbbbbabababbbaaaabaabaaaaaaaababbaaabaaaaabaabaaaabaabbbbbaaabaaabbaabbbabbbbbbaabaaaaabbbbababbbbaabbbbaabbabaaaabbbaabbabbbbbaabbaaaabbbbaababbaaaaaaabbbbbabbaaaabaabbabbaaababaabbbbabaaaabbaaaababbabababaaaaaabababbbabbbbabbbababaaababaabababbbbabbbabbaababaaababbaabbababaaababbbbabaababaabaaaaabbbbabaabbaabaabbaaabbbaabbbbaaaaababbaababababbbaabababbaaaaaaaaaaaaabbbbaabbbabbabaaaabbabbbaaaabababaaabbabbbbaababaaabbbbbababaaaaabbaaaabbbbbaabbbaabaabbaaabaaaabbbbaabbabbaaaabbbbabaaaababbbaaaaabbbbaababaaaabaabbabbbaabababbaabbbaaaaabaaaaababbabbaababaababaabbbbbababbbbaabbbbbabbababaabbabaabaabaababbbbbbbabbbaabbbbbabababaabaabbbbababbbaabaaaaabababaaaabbbaabbabbabbabbaabaabbbababaabbbabbbbabbaaabbaaabbabbabbabababbbaabaabbaabaaabaabbabbbbbbbababbbbabaababbbabbaaaaabababaaaabaaababbabbabababaaabaaaabbabbbbbaaaabbbaaaabbababbbbaaabbbabbabaabbbbbabbaaabaaaabbbababaaaaabbbaabaabbaabbbbabbabaaaabbaabababaaabbabbbaababbaabaababbbababbaaabababaababbbabbabbbbaababaabbaaaaaaaaabbbbbabbbabbaabaabaaaaababaaabbabaabbaabbbaabbababaababbbabbabbbbabaaabbaabbbabbbbaabbbbababbbbababbababbaaaabbbbbaabaabaaabbbababbbbaaaabbbbbabbbabbabbaabbbabbabbbabbbababaabbbbabbbbbbbbbababaaabbabbbbababbbbbbaabaabaaabbabbbbaaabbbaababbababaabbabaabaaaabbbaabaaaaabaabbabbbaabaaaabbabbbbababbbbabbaababbaaabababbaabababaabaabaaabbabaabaabbabbabbaabbbbbbaaaaaabaabbaabbaaabaaaaabbbbbabbaabbbbababaabbbabbaabaaaaaaabbaabbaabaaabababbaaabbbaaabbbaaabaabaabaaaaababbabbbabbaababbbabbabaabbbaaabbabaabaabaabbaabaaababbabbaaaabaaaabaaaabbabbbbbbaabbbbbabbaaaaabbbbababaababbbbbbababaaaaabbaaababbaababaabaaabaabbaabbbbbabaaabbababaabbbabbababbababbbbbbabbabaabbaaababbbabbbbaaaabaababbaaababbabbabaababbbaabaaababaabbaabbbabbbaaabbabaabbbabaaaaabbaabbabababbabaabaababaaabbbabbbaababbbbababababaabbaaabaabaabbbaaabaaababbaaabaabbbbbabbbbabbaaaabbabbbabbbbabababbabababaaaabaabababbaaabaaabbabbabbaaaaaabaaababaaabbababbbaabbabaaaabbbaaaabbaaaabaabababaabbbababbbbbabbaabbbabbaaabbaaaaabaabaaabbabaabbaabbaaaabababbabbabaaaaaababaaaaaabaababaaababaaabababaaabbabbaaaabababaaabbaabbaabaababaababbaaaabbaaabbabaabaaabbbbaaabaaaaaaaabaaabbababbbbbbbaabbaaaababaaabbbaababaabababaabbaabbaabbababaabbbbaaaababaaabbbbabaabbbbbaabbabbbbbbaabbabbbbabaaabbababaabbabbbbaaabbaababaaabbabbbaabaabaaaaaabbaabbaabbabbbbbabbbabbaabababbaaabaababbaababbbbbbabbabaaaaaabbaabbababbbbbbbabaababbbbbbbbbaabbbbbababaaabbbbbbbaaaaaababaaabbaabaaaabaaaaabababaabbbabaaaabbbabbabaaaabaaaaaaaaaaabbabaaaabbbbbbbbbabaaabbabbaababbaaababababaaaaaaaaabaaabbabbbabaabbbbaabaabababbbbbabaabbabaabbabaaaaaaaaaabaaabaaabaaaaaabbbabbaabbbaaabbbbabbbbbbaabbababbababaaabbbabbabbbbabbaaaaaabbabaabaabababbbabaababbabababaaaaabaababbbbaaababbbabaaaaabaababaabaababbaababababbbaabbbaaaabaabbbaabaabbabbbbbabaaaabbbaabbbbaaaaaabbaaaaaabaabababababbabbaabbaabaaabaaaababbbababbbbbbbabababababbbabaaababbbaabbaaaaabbaabbbaaaabbababababbbabaabbbbbabbbbbaabaabbbbabaaaabbababbbabbaaabbaababaaaababaaabbaabaaaaababbabababaabababaaaabababbbbbabbbbabbaaabbbbbaaabbbbbbbbabbbbaabababbabbbaaaaababbaabbbbababbababbbaabbabaababaaabaaaabaaaaabbaaabaaabaabababbaabaababbbababbbabaaaaaaabaaabbbbaaabaaaaaaaaaabababaaababaabababbbabbbabaaabbabbaaababbbabaabbabaaabbbbaaababaababaabaabbabbbaabaabbabaabbaabaabababaabbabababaaaabbbaaababbbbabaabbaababbbabbbbabaaaababababbaabbbbbbababbbbbaaabbbbaababbbaabaabbaaababababbbabbbababbbababbbabbbbbabababbbabbabaaaabbbbabaaabaaaaabbbaaabaabbaabbbbabaaabaaaaaaabbabbbaaaaabbbaabaabaaabababbbbbbaabbbaaabaabaabaaaabbbbaaaaababaaabaabbbbabbbbaababaabbbbbaabaaaaaaaaabbabbababaabaabbbbbabaabbabaaabbabbabaaababbabbaabaababababaabaaabaabbababaaaaaaaabbbbaaabaaaabaabaababaaabbaaaaaababbbbbbabbbaabbbabbbbabbabbaaabaabbababbabbbabbbbabbbbbabababbbbbabbaaaababbaabaababbaaaababbabbbbbabbabbaabbbabbbbabbaaabababbabaababaaabbbabbbaabaabbbaaaaaaabaabababbbaabbbaabbabbbbbaabaaabbaaaabbbbbaaaabbbbbbabbabbaaabbaababbaabbabaababbbbbbabbaabbbbababaaaabaabaaabaabbababbbabbbbbaaaaaabaaabbbbaaabbbbababaaaababaabbaabababbbbaaaabbbbbabbbababaababaabbabaaababaaaabbaabababbbbbaabbbaaababaabaaabbbbaaabbbaaaaabaababbaaaaabbababbababbbbaabaaabbbbbbbaabbabbaaabaababbaababaabaabbaaabbabbbbbbbaabbbabbbaaabbbabbaabbabbaaaabbabbabbababbbbabaababbaaababababaaaabbabaaabaaaaaaabaaabaabbbbabaabaabbabbabaabbaaaaaaabbbbababaabbbabbababaabbbaaabaabbbaaaaabbaaabaaaabbbabbaabbbaabbabaaabbbbbbabaaababababaabababbaabbaabbbbbaaabbabbbbabaabbbaaaabbbbaababbbababaaabbaabaabbbaaababbbbbababbababbbabaabbabbababaabbabbabbbaababaabaabbbbbaabaabbbbbabaaabbababababaaabbaabaabaaabbbabbbbbbbaaaababaaabbabbaaabbbababababaaaabababbaaaaababbbabbbbbabbbaababbababbbaaaaaaabaaaaabbbaaababbaaaaabbaaaaabbbbbaaaaaaaaaabaaabbbababaabbaabbbbabbaabbaaaaabaabaaaaaabaaabaaaabbaaaabbbaababbbaaabaaabaabbbbabbbaabababbaaaaabbbaababbaabaabbbaabaaaabbbabbbbbaaabaabbbabababbbbbbbababbaabaabababbbaabaabbaabbbbabaaabbbbbbaabaabaabbaaaabaabbbaabaabbaabaabaabaabaaaabaabbabaabbbbababbbbbababbbabbbaaabbbbaaabaabbaabbaaabbaaabaaabbbbabbbbbaabbbabaaaaabbaaabaabbbbaabaaabbbaaababbbaabbabbabaabbbbbaaabaaababababaaabbbabaababbabbbaabbbaaabbbaaaabbabaababaababbbbaaaaaabbbaaabababababaaabbabababbbbbaabbabbbbabbbabbababbbbbabbabaabbaaababbbbabbaaaaabaaaabbabbbabbabbbbaabaabaaabbaabababbaaabbbbbaaabababababbbbbabaaaaababaaabbbabbabbbaabaabaabbbbbbabaaabaababaaaababaabbbabbbbbaaabbaaabaaaabbbaaabaaabbaaabaabbbbabbabaaaabbabbaababaababaabbbbbabbabbabbbbbabaaababaabbaaaaabbaaabbbababbbbababababaaaaabbbbbabbabbbbbbabaabbbaabbbabbbbababbabbabbabbabaabababbbbbbbaabbbabbaabbbbbabaabbbbabbbaabbabbbbabaabbbaaaabaabbaabbbabaabbabbbababababaabaaabbbbaabaaaabbabbabbaaabababbbbaaabbaabbabbbababbbaaaabbbbaaabaaabababaabbbbaabbabababbbbaaabaabbbbaabaaaaabaabaabbbabaaabbaaaaaaaaaaabaaaaaabaabbbbbaabababaaaabbbbaabaaabaaabbaaaaaaabbbbbaabbbbbaabbaababbaababbbbababbbbabbbbbbabaaabbabbaaaabaabaabbaabbbaaabaabbbaaababbbaaabaabbbabbaababaaabbbaabbbbbabaababbabbaababaaabababaabbbabbbbaabbbbaaaabaabaaaaaabbaabbbbaabaaaabbabbbabbaabaaaabbaabbbbbababaabbabbaaaabbaaaaaabaaabbbaabababababbbbbbbbaaaabbabbbababbaabbaabaaaabbaaabbbabaaabababbbbbaaaabababaababbaababbaaabbbababbaaaaabbababaaabbbabbbaabbabbbaababbaabbbbaaaaabaaaaabbaaaabababbaaabbbbbbaabbbbaabaababbabbabaaaabbaaabbbbbbabbbbbabaabbbbbbaaabbbaaabaabbbbbaabaaabaabbabbaabbbbbaababbaaabababbaaabaabbabababababaaaababaaababbbababaabbbbaaaabbaabaaaaabbabababbaaaaabbbababbbbbabbbaabbabaabaaaaaabaaaababababaabbbabbababaaaaababbbbababbaabbabbbaaabbbaaababbbaaaaaabbabaabbabaababbbbaaaaabaababaabbbaabaaababbabbaabbbbabbabaabbaabbbbbbbbbbabababbbbbabbaabbbbbbabbbabbaabbaaabbaaabaaabbbbaaabaababbabaababaabbaabaaaaababaaabbbbbbbbbbabaaaaabaabbbaaabaabaabbaaabbbaaaabbaabaaabbbbbababbaababbbaaaaaabaababbbabbaabbaaabbabbbbaaaaabaaaabaaaababbabbbababbabaaaaaabbababbaaabbaabaaababbbbaabbbababbaaabbbabbabaaaabaabbbbaaaabbbbbaaabbbababbaaaaababbbbaaaaaabaaaabbbabbbbbabbbbabbaaabaaaaaaababbbbabaaaaabaaaaaabbabababababbaabbaaaaaabbbaaabbaaaaabababbbbaabaaaabaaababbaaabbaababbbbbbbbabbbabbaaabbaababbaababbbaaaabbaababaabaabaaaabaaabbaaabbaabbbaaaabaabbabaaababbabbababbbabaababbababbabbbabbbbbbbababbabababbbaaabaabbababbbbaabaabbabaabbaaaaaabababbaabbbaaabbbababbabaaabaabaaaaaababbbabaabbabbbaaabbaaabbbaabaabbabbabbaabaaabbababbbbaabbabbaabaaabaaabbbabbaabbbbabaabaaaabbbabababababaaaaabbbaaabbaaaabbbabbbbbabbbabbbabaaaaabababababbbaaabaaabbaaaaaababbabbaabbaaabababbabbbbbbbbbababbbbbbbaaabbbabbabbaabaababbbbbaabbababbbabbbbaaaabaababbbabbbbbbbaaaabbbaaababaabbaabaaaaaababbbaaaabaababbbbbbabaaaaaababbbaababbbabbaaaababbabbbbbabbbbbabbbabbabbbaaababbbabaaaaababbbabbaaaababaaaababaaabbbaaaabbaaabaabaaabaabaaabbbabbaaaabbbabbabaabaaabaababbaaabbbbabababbababbbabbabbbbbbbbabbbababbabbbbbaaaababbbbbaabbbaabaababbaaaabaababaabaabababaabbaaabbbaabbbbabbaababbabbaaabbbaababbbabbaaabbaaaababbbabbbbabaabbbaababbbaaabaaaababbbbbaabbbbabbababaaaabbbbabaabaabbaababbabaabbbbbbabbabbbbbbaabaaaabbbbbabaaabaaaaaabbababbbbbabaabbaaabaaababbabbaababaabbbbabababbbabbabaaabaabbbababbbabaaabaaabaaaaabbabbabbaaaababbaaaaababbaaaababaaabbaabaaabbaabbaabbabbbabaabaabbaaaaaabbaaaaaaabbbbabaaabababaabbbaabbabaaaabbaaabbbbababbaababaabbabbabbbbabbabbabaaabbaabaababbbabaaaabbababbabbabbbabbaaaabbbbbbabababbaaaabbaaaabaaaabababbababbaaabbabababbbbbbabbbabbababbbbbaabbbbbabbbaaabbbbaabaaabaabbbabaabbaabbbbbbbababaabbbbabbbbbbbaabbbaabaabbaaaaaabaaaabaabbaabaaaaaaabaaabbabaaabbabbbbbababbaabaabbababbbaaabbababaaabbaaabbbaabbaabbbbbaabaaabaaabaaabbbaababbaaaabaababbbbbbbabaaaabbaabaabbbabaababbabbabaaabbbabbaabbbabbbbaababbaabaaabbaabbabaaaabaabaababbbaaabaabaaabaabbababbbbabbbababbabaabbbabaababbaabaababbbabaabbbbbabbbaabbabbbaaababaaababbbbbbbaaabababaaaabbaaaaaaabbabbbaabbbbbaaababbbbabaaabbbababababbaabaababbbababbabaaabbbaabaaaaaabbbbabbaabbababbbaaaabbbbabbaabbaaaabaabbbbababbaabbbaababbaabbbabbbbaaaababbbbaabbaaabbbbabbbbaababaaaabbbbaaabaabababbbabbabaaaaaaaabbbbbaaaabbbbbaabbabbbbabbbaaaabababbabbbaababbbaaaaaabbaabaabbaaabbbbaaabaabaaaaaabbabbbaabbbbbaaaaaaabbbbaaabaaabaaabaabbbababaababbbbbaaabaaaabbbaabaaaabaaabaabbaaabbaaaabbabbbababbabbbaaaaaaaaaababbaabbaaaaaabaaababaabbbaaaabbaaabbbababaaaaabbbabaabbabbbaaabababaabbaaaabbabaabbbabaabaababbaabaaaaaabbaaababbabbbaababbbabbbabaaaaabbaaaaaaababbabaaaabaaaaaabaabbbbbaabaababaaaaaaababbbbbabbbaabbabbabbbbbaaabbabbababaaababbabababbbbbbbbbabbbbbbabbbabbaabbbaaaabaaabbbbaaaaaaaabbabbbbbbbbbbaabbaabbbabaabaaaabaaabbaabbabbbaaabaabbbbbaabbaabaabaaababbbbabababbaaababbabbaababbbbaaababaaaaabbbbbabaaaaaabaabababbbabaabbbbabaababbbababbbbbaabbabbaabbabaaabbbbbbbabaaabaabbabbabbaabaaaaaaabaaabbaaabbabaababbabbbbbbabaabaaabbabbaaaaaaabbbabaaaababbbababbbaaaabaaaabaabaaabaaaabaabbaaabbbaabaaabaabaaaabbaabaabbaabbabaabbabbabbaabbbbbbaabbaaabbaaaabaabbbabaaabbbabaabaaaabbbbaaaaabababbbabbbabbaababbbbbabaabbbabbbaaaaabbbabbabbbbaababbbbaabbbbaaaaabaaaaababbabaababababbbbabbbabbaaaaaababbaabbbbaabaabbbababaaaabaabbbaaabaaaababaaababbbaabbbbaabaababbaaabbabababbbbaababaaabababbaabbbaabbabaabaaaaababbbbabbabaabbbaaabaabaabaaabbabaabaabbabaababaaaabaabbaabaabbbabbababbaaabbabaabaaabbbbbbbbaabbaabababbbbbbabbaabaaabbaabaaabbbaaaababaaaaabaabbabaaabbbbbaaaaaabbaabbaaabbaaaabbbbabbaaaababaabbbaabbbbaaababaaabbabbabaaabbbbabbababaaabaabbbabaababaabaabbabbbbaabbabbaabaaaaaabaaabaabaabbabbbaabaabbbaaababaabbabbaaaabbbbbbbaabababaaaabbbbbabbbbbababbbaaaabaabbaaababaabbabaababbbbabbaabbbabbabbbbabababbabababaaaaabbbabaabbbbababbbbbaaabaaabbabbabaabaabbbaaababaababaaababaaabababababbbbbaaaaaabbabaaaaabaabbbbbaababbabbabbabbbbabaabababbaaabaababbbaabababaabbabbababaababbbbaabbbbababbaabbbaabbbabbbaabbbaabaabbaabbbaaababbbbabbbbbabbabbbbaaabbbbbbbababbbabaaabbbabbbaabbbbaaabaaabbabbaaaabbabbababbaababbaaaabaabbabbbbbbaaaaaabbbabbbaabbbbbaaabbbaabaaaabbbabbabbbabbbbbaaaabbbaabbabababaaaabbabbaaaabbababbabbbaaabababbababbaabbabaaaabaabbabbaababbbbbaaaabababbbbaaaabbbabbaaaaaabababbabbabbbaaaabaaaababbbababbbbaaaaababbababaaababaabbbbbabaaabbaabababaaabbaaabbbaabaabaabaaaaabaabaabbababbbbabbaaabbababaabaabaababbababbbbbbbbaaabbabaabababbbaaabbababbaaaaaabaaabbaabbabaaabbaaabbbbababaaaabbabbaabbbbaabaaaabbbaabababbbaabbabbabbbababbbababaabababbbbabbabaabaabaaaaabbabbbbbaaabbabbbbaabaaaabbbaaaabaabbaaaabbbaaaabbbbabbbbabaabbaaababababbbabbbabbaababaaaaabaaaabbbbaaaabbbababbbababaaabbbaabaabbbbbbbbaaababaababbbabbaabbbababbbaabababaaabbabbbabbabbabbaabbaaababbaababbaabaababaaaaabbbaaaabaabababbbaaaaabaaabbabaaabbbababbaababbabbabbbbbabaaaaaaababaabaaaabbbbabbabaaabbbaaaabbaabaaaaabbbbaabbbbbbbbbbaaaabbbaaaaaaabbaabbabbaababbbbbbaabbaaaabaabaaabaaaaaabababbaabaabaaababaaabababbbabaabbabaabbbaaabbbaabbbabbbabbaaabbbaababbbbbbbabbaabbbaaaaabbaaaabbbbaabaaaabbbbbabbaaaabaaaaaabbbbbabbabababaababbabbbbbbbaabbaaabbaaaaabaaaaaaaabbaaaabbbbbbaabababbaabbbabaababaabbabbaababaaaabbbabbabbabababbbaaaababaaababbaabaabbbbbbabbbaabaabababbaaabaabbaabbabbaaabaabbbbaaaaabbbaaaabbbbabbaabaaaabaaabbbbbaaaaaabaaaabbbabbaaabaaaabbabaaaababbaabaabbabbbbabaaabbabbababaabbaaabbbaaabaaabbabbabaabaabaaaabbabaabbbbabbaaabaabbbaaabbbbabbaaabaaaaaabaaaaaaabababaaaaaabbbbbaaaabaaabbbbaababbabbbbaaababaaabbaabbabaabbbaaabbaaaaaaabaabababbbaabaaabbbbbbaaabbaabbbaabaabababbaaaabbababbbbaaaabbababbaababaaabbbaabaaaaaabbbaaabaabbbbabaababaaaaabbaaaaabbbbabbababbabbbbbbabbabbabaababaaabbbaaabbbabbbaaabbbaaaabbaabbbbaaabaabbaaabbbbaabbabbaaaabbaaaababaababbbbabbbbbababaabbaaababbabbbabaaaaabaabaaabaababbaaabbaaaaabbaaabbbababaabbabaababaabaaabaabbaababbbbbaabaaabaabbbbaaaaabbbbbabaababaabbaaabbaabababbbabbbbbabababbabaaaaabaabbbababbbabaababbbabbaaabaaaabababbaababaabbbbbaababbaabaaabbbabaabbabaaaabbabbbbbabbbababaaabbaabaaabbabababbbbaaababaababaaabbbbaaaabbabbbbaabbbabbabbabababbababbbaaabbbaabaabbababbaababbbbabbbbbaabbbabbbaaaabbaabaabaabbbaabbbabbbabbaaabbbbabbbabaabaababaababbaabbaababbabbabbaabaaabaaaababaababbbbaabbabababbabbbbbbaababbbbbbbbbabaababbbbababaaabbaabaaababbabbbaababbaabbbbabbbbbaaaabbbabaaabbbbbababababbbbbbaabaaaaaabbaaaaaaababbabbaabaabaaabaabbbbbbbbbbbbabaabbaabbbbaaaaabbaaaaababbaabbbbbbabaabaabbbabaabaababaabbbaaaaabbabababbbbbaaabbbbaababbaabaaabababaaabbaaabbbaaabbbabaaabbbbbbbbbbababaaabbbabbaaabaaababbbbabbaabbaaababbbbabbabababaaabbaaaaaaabbabbaaaabaababaaabbaabbbbaaabbaaababbbaabababaabbbbababbaaabbabbbabbabbaaaaabbabbaaaaaabababababaabbaabbabbaabaabababbaabaabbaaabaabbaaabababbbaabbaaaabbabbbbabbbbbbbbbaaaabbbaaabaabaabaaaaabbbaaabbababbaaabbaaaabbabaabababababbababaaabbbbbbbbbaaabaabbbbabbbaaabaaaaaaaabbaaaababbabbbbbaaabbbbbbbbbbbbbabaabaaabbbaaabaabababaabbababbababbbabbbabaaabbabbaabbbbaaabaabbbabbabbbbabbababbbaabbaabbabbabbababbbbbbabbbbbbabbabbbaaababbbaaaabaabbbbbbabbbbaabababbbbbbbbaababababaabbaaaaababaaababaabbabbbababaaabbbaabaaaabbabaabbaaababbabbbbaaabbbbbabaaaaabbbbaaaaaaabaaabbbbbbababababababbaabaaabaaabbbbabbbbaaabbbabbbabaaabbbbbabaaababbaabbbaabaaababbaabbaabbaabbabaabbbaaaababbbabbaabaaabbabbabbbababbbbaabbaabbbbbaababbaaabaaabbabbaabbbbbabaabaabbaaabbaabbbbabaabbbabbabbbabbaaaaababaababbaabaabbbbbabbababbabaaaaaabaabbabababbabbabbabaaaababbabbbaababaaaaabbbbbbaabaaaaabaaaabbbabababbaaabbbabaabaabbbaaaaaaaabbbbbbbbabbbabbbabbaabbabbaaabbbababaaaaaaaaabbbbaaabaaababbbbabaabaaabaaaabbaaaababbbbbbbaaabaaaabbaaabbaaaaabbaaabaaabbbbabbaababaabaaabbbabbbaabbbabbababaaabababbbbababaaabaabbabbbaababbaaababababaaaaaabaaaaaabbbaabbaabbbababbaaaaabbbabbabaabaaabababbbbabbbbabbaabbbaaaabaaabaabbaaabbabbbaaaaababbabbaabaababaabaababbbabaaaaaabbbabbababaabbbbabbbbbbaaabbbabbbaaaabababbaaabbabaaaabbaaaaabaaaabbbabbabaaaababaaabaabbbbbaabaaaaaaaaaaaaaabbbbabbaabbbbabbbaabbabbaababaabaababababababaaabbbbabaabbaaabaababababbbabbaaabaabbaaabababbabbbbbaabbbaabababaabaabbbbbbabbabbabbabaababaababaaabbabbaaabbabbabbababababababaababbbbababaaaabbbaabbaaabbabaabbaabaabbabbabbbbbbbbabbbbbabababababaababbaaaabbabbbabbababaababbaabbbababaaaabbaaabbababbaababbbababaaabaaaabababaaaaaabbbbbabbabbaaabbbbbbbbabbaabbabbaababbbbaababbaabbababbbaababaabaababbbabbabaabababaabaaaaababbbabbbababbbaabbabbbbaaaabbbaaabbbabaabababbabbbbbaabbaabbaaabaaaaaaabbaabaaaaaaabbbbababbababbbabbbbaabbbabaaaabbbabbbaababababbabaabbbaaaaaaaabbbbbbabaabaaaabbabaaaaababbaaabbabaabbabbaaaaaaaabbabbabaaaabaaabaababababbaababaaabaababababababbbbababbabbaababbbabbbbbbbaaaaaaaabbbbbbabaabbabbabbbaaaabbbbbaaaababbbaabbabbbaabbbabaabbabbbababbaabaaabbbbbbaababbaabbaabaabaaaaababaabbabaaaabbabaababbababaababaabbbabbbabbabbbbbaabbbababababaaaabbabaaaaaaabbbabababbaababaaabbbaaaaababbaaaababbbaaabababaaabaabbbbbbaaaabaaabbbbbbbbbababaabaabbbabaaaabbbbbbabaabbbaaaababbaabaababbbaabbaaaabbbaabbbbabbabbbaabbababbaaababaaabbaaababababbabbbbbbbbabaabbbbabaabbaabbaaaabbbabaabbbbaabbababbbbbabbabaaaaaabbbbbaaabbabaababbaabababbaaaaaaaabababbbbbbbababbabaaaabaababaabaabbbbaaabbbababaabaabbaaabbabbbbababaaababbbbaababbbbabbbabaababaababaabbabbabababbbabbbabbbaabaabbbabbbbbbbaabbbbbaaabaababaabaaabaaabaaaabaaaaabbaaaaaaababbbbababbaabbbbabababbaaaaaabaaaabbbbaaaabaaaabbabaaabbaaaababaaabbbbabababaabbaaabbabbaaabbaabbbbaaababbabbbbbbabbbbaabaabaaabbabbaaaaabbabaabbbbbbaaabbababbaaaabbaaabaabbababbbbaaababbbbababaaaabbabbaabaababbaaaabbbbababaaaaaabbaaaabaaaabbabbaaababaabbabbaaabbbbbbbbbaaabbaababbaababbaababaaabbbabbbaababababbabaabbababaaabbbbaabbabbbaaabbbababaaaabbabbbaababaabbbbbababbbbaabaaabababaabbbaaabbababbaaaabbaabbbabbaabbbbbaabaaaabaaababbabbbbaabaabaabaabbaabaaaaabbbabbbbaaaabbaabbbbaaaaabbbbaabbabbbabbbbabbabababbaaabbbaaaababbaababbbaabaaaabbabbabaaaaaaabaaababaabbaabaaaaaababbbbbbaabbaaabbbbaabbabaaabbbbababaaaaaabbbbbaabaaabaaaababbbbbbbabbbaaabbabababaabbaabbbbaaaabaaaababbbabbbbabaababaaabbbaababbaaabaabbbaabaaaabbbabaabaababbaabbbaaabaaaaaaaabbbaabaabbbabbbbbbbaaaababbbabbaababbbaabbbabaabaaabbaaaaaaababbaaaabaababbbabbaabbbbaaabaaabaaabababbaababaabbaaabbababbabbbabaabbaabaaaaaabbabbbbbbaabbbbabbabbabaabaaabaaabbabbbaaabbbabaaaabaaabaabbaaaababbaababbaaabaaaabbababaaaaaaaabaabbbbbbabbaabaaabbaaabbbabbabbbbababaaabaaabbbabbaabbbabaaaabbaabaabaaaababaaabaaabbaababbabaababaabbbbaabbbbabaabababbbbbaabbbaababbabbbabbbaabbbabbabaaabbbaabaaababbbbaaaaabaabaaababbbbbabaabaaaabbaaaaabbabbaabbaaaaabbbabaaabaaababbaabaabbabbbbaaabbaabbbabbbbabaabbaaabbabaaabaababbabbaabbbbaabbbbabbbaababbbbaabbbbbbbbbbbaaaabababbaabbbababaaabaaababbaababaabaaaaaaabababaabbbabbabbbbabaabbaaaabaabbababbbbbabbbaabaabbbbabaaabaaaaaabbbabbbaabbaaaaababaaabababbabbaaabbbaabbbabbaabaababaabbbbbababbbbbaaabaabaaaabbabaabaabbbbaabbaaabbaababbababaabababaabbbbbbabaabaababbaaabbbbababaabaaabbabaabaaaaaaaaabaabbaabbaaabbabbbbaabbbabbaababaabbaaabaabaababaabababbbbabbbabbbbabaaabababbababaaaaaababbbaabbbabaaabababbbbbabaaababaaaabaaaabbabbaaaababbbaabaabbaaabbbbbabaabababbaabbbbbaabbbbabaabbaaabaababbabababaaabbbbbaaaaaaaabbaaaabaaaabbbbaaabbabaabaabbaaabbaaaabaabaaababaaababaaaabbaabababbabbababbaabaabbabbaababbabbbaababaaaaababaaabaabaabbbabbaaaabbaabbababbaaaabaababbbbaababbbbbabaaaabaabaaabbaaabababbabbaaaaabbaabaaabbaaaaababbaaaababbaabaaaaaaabababbbbaaaaabaabbabaaaabaaaaabbbbabaabbaabbaabababbaaabaaababbabbbaabbbbabbabaabaaaaaabbbabaabbbbbaaaaaababbaabbaaaaabaaaabbaabaaabaabaabaababaaaaaababaaabbbbbbbaabaabbaababbabbaabbbaaabbabbbabbaaaaabbbaaabaabaabbbbabbaabaaaaaaabbaabbbbbabbbabaabbbaabbabbbbbbaabbbaaabbbabbbababaaabaababababbaaaababbbaaaaaaabbbabbaaabbabbabbbbaabbabbababbbaaaaaabbbbbbabbaabaabaaaaabaabaabbbbbbabaababbbbaabbabbbbaabaaababbbabaabbbababbbbaabbaaaaaabbbabbaabbbababbbbbaabaabbaaaabbabaaaaaaaabbbbabbbbbbbbbbaaaababbbbbaaaabbbaaababaababaabbababaaaabbaababbbbaababbbaaaaabbbbbaabbbabaabaaabbabbbaabbabbaaaaabbaaaaaabaababbbaabaaaaabbbabaababbaababbbabbaaabbbbabaabaabbaaabababbbbabbbbabaaabbaabbbabbabbabababaabaaaaabbabbabababaaaabbbabbaaabbbababaaaaaaaabaabababbababbbaaaabbabaaaaabbbbaabbaaaabaabbaababaabaaabbaaabbababaababbaaaaaaababaaaabaabbbbababbaaaaaaabaabaaaaaabbaaabbbaabaaaaaabbababaababbbbaabaabbbabbababbbaabbabbabbabbabbbaaabaabaababbbaabbbaababbaaabaabbabbbbaaaabbbabbbaababaababbbbbbabbabbababababbabbbababaababbbabaabababbabbbbbabbababbbbabaabaaabbaababbbaabbaaabaabbbbbaabbaabbbbabbabababbababaabaaaaababbbaaabbabbabbbabbabbaabaaabbaabbaababbbababaaabababaabaaaababbabbabbaaabaababbabaabbababbbaabaababbabaabaaabbbbabbabaaaabbbaabaabbbbabaababbaaabbbaaabbabbbbaabaaaaabababbbabbababbbababbabaaabbaabaabbbaaaaaababbaabbaabbabaabbabaaabaaabbabbbabbbaabbaabbbbaaabbbabaababbbbbbaaababaabbabbababbbbabbababbbbbbabaabbaaaaababbabaaaaabbaaaabaaabbbababaababbbbaaaabbabbaabbaabbaabbbaaababbbbbbaababaaabbaaaabbaabaaabaaababbbaabbbaaabbabaababaabbabbababaababaababaaaaaabbaaaababbbbbbabbaabaabbbabbabbabbbaaaababbaabbabaaaaabbbbabbbaaabababababbaaaabbabaabbabbbaaabbbbababbaaaabbabbbbbbbaaaabaaabababaaababaabbababaaabbbaaaaaaaaabbbabaabbaaaaaaaaabbbabaababaabababbbbabaababbabbbaaabbbbaaabaabaababaaaaabbbbbbbabaaabbaabbbbbabbaabbaabbaabbabaaaaaabbbbbbaababaabbabaabaababbaaababbaabababbbbabaaaabbbbaabbbabaaabaaababbaabbbaabbaabbaabbabbbababbabaaababaaabaaababaaaabbbbaabaaababaabbbaaabababbabbabbbbaabbaaabbbbababaabbaaaababbbbbabbabbbbbabbbbabaababbaaabbabaaabbabaabbbbaabbabbbbbabababababbaaaabbaabbbaabbabaabbabaaabbbabbababaabaababbabbaabaaabbaaaaaabaaabbbbbaaababbbabbaabbbbababbbaabbbaaaaaabbbbaabbababbbababbbabbbbaabbbbbbaabbbbababbaabaabbaaaaaabbbaabaaabbbbbbbbaabbbbaaabbbabaababbaabaababbbaaabababbaaaaaabbabbaaaabbbabaabaaabaabbaabbababbbbbbbaabbaaababaaaabbabbbbbbaaababaaabaabababaabbaaabbbaabbaababbabbabbbabbaabaabbbbbaaababbaaabbbaabababbabababaaabaaabaaaaabaabbaaabbabaabbbbaabbbabaaaaabaaabaaabaabbabbabaabbbabaabbaaaabbbbbaababbbbabbabbbbbaababbabababababbabababaabbaaaaabbabaaaababbbaaababababbbbbaabbbbaaaaabbbbabbbbbababaabbbabbbbabaaababbbbbabababbaaabaabbaaaaaaabbbbbbbabbbbababababbbbabbaababbabaaababbbababaaaabbbbbaabbaabbabaaabbbabbbabbaaabababaabaaabbabaaaaaaaabbabbababaaabbbaaaabbbbababbaaaababbbbababbbababbbababaababbaababaaababbabbbaaabaabaaabbabbbbbbbabbaabbbbabbaabbabaababaaaabbbabaaaababbbbbabbaaaabaabaaababaabaaabbaaaabbaabbaaaababababaabaabbaaaaababbabaabbbbaabaaabbabaabbbbbbbababbaaabbaaaaaabbbbbabbabbbaabbabaabbbabbabaaaaabbbbbbbabaaabaaababbaabbbbbaaabbaaaaaabbaabbabaaaabbabbbababababbaaaabababbaaababbaabbaabbabababbababbbbaababbbaababbababbabaaabbbbaaababbaabbbbbbbaababbbbabbbbabbabaababbbbaaaaaabbabbbbabaaaabbaababbaaaababbaaaabbbbbaaaababbaabababbabaaabaaabbbaaababbbabaaaaabaabbbbaaaaaabbbaaababaaaabbaaabbababaabababbababbabbaababbabaabbabbabbababbaaabbaabbbbbaabbabbabbabaabbbbbbbabaabaaababaaaaaabaababbaabbbbaaaaaabbbbbaaababaaaaabbbbbaabaabaaaaaaabbababbbabbbabbbabaabbbbabbbbbbbbaaaaababaaaabbbaaabaaabaaabbaaabbbbabbbbbbbaabbabbbbaababbaaaaabaaaaaaaababbbbababbbabbabaabbbbabbbabaabaaaaabbabababbaaaabbbaaaaaaaaaabaaabaabaaaabbbbbabaabbbaabbbaabbbbbbbaaaabbaaaaabbbbabbaababaaabbbaaaaababbbaabaabaaaaaaababaababababbabbababbbbabababaabaababbaabbaaababbbbbabaaabbbabbbabbaaaaaabaabbaaaaabaabbbbbbabaaaaabbbbaabbbaabbababaaaaabbaababbbbbbbbbabbabbabaabbababbababbaabbaabbaaaabaabbabaabaabbbbabbbbbbaabaabbbababaaabbabbbaababaaaabaaaaaaabababbbaabaaabaaaaaaababaaaaaabbaaabbabababbabaababaaaababaaabbbbaaabbbaaabaabababbaaabbaaaabbbbbbaaabbaaaababbabbbbaabbbbabbbbabbabbabaabaaabbabbbbbaaaababababbbaaabbbaaabbbbaaaabbbabbbaabaaaabbbbaaabaabbababbbabbabbbabbbbaaaaaabbaabbabbbbbaaabaababaabbbaaaaabaabaabaaaaaabbbbabbabaabbabbbaabababaaababbaaaabbaaaaabababbbbbbaaaabababbbababbabaabbbabbaabaaaaaabbabbbaaababbbbbbaabbbaabaabbaaaababbabbabbbabbbbaababababababababbbaaaaabababbbaabaaababbbabbaaaabaabbbbaaababbaabbaaabbbbabbaababbbbaaaabbbbabaabaabbaabbbbaaaababaaaaabbbbbababbbaabaabbbbaababbaaabbbaababbbbaaaabbbababbaabbbbbbabbbbaaabaabbbbabbbaabbbaaababbbabbabbbbbbbaabaaabbbabaabbbbbaaaaabaababaaabbaaaabbaaaaaabaaabaabbabbaabbaaaababbbabbbababbabbabbaabbbabaaaabbaabbbaabbabbaaaabbbaababbabbbbaabbbababbbbbbbaabaaabbbababbbabaaabbbbbbbbababbbbbbababbbbbbabbbbbaababbbbbbbabbabbaaababbbababbabbabaaabbbaabaababaabbababbbabbaaabbaabbabbabbbaaababbaabbaabbbbbababbaabbaaabaababaaabbbabaababbbbbbbbbbabaabbbbaababababbbaabbbabaabaabbaaaabaaaaaabbabbbabaabaaababbaababbbbbbbbbabbbabaaaaabababbbaaabaaabaabbaaaaababaaaababbaaaaaaaababbbbabbabaabaaaabbaaaaaababaabbbaaabbababbbbaababababababaababaabbbabbabaaabaaabbbbbbaaabaaabbbbbbaababaabbaaababbaaaababbaaabbbaaaaaabababbabaaabaaabbbbabaaaaaaaaabbaaaabbabbabaababaaaaababbbbaaaaaaaaaabbabbaaaabbbaaaaaabbabbbbaaaaaabbaabbbabbababbbaaaaaaaaabaaabababbabaabbaaaabababbbbbbbaaaabbabaaababbbbabaaaaaabbababbbababbbbbababbbaaababaabbbbaaabbbabaababbabbaaabbbbbbaabbbababbbabaababbbbaababbaaaaaaabaaabbbaabbaabbabbabbababbbbaaaababbbababababbaabbaabababaaabaabbbaaaabababababaaaabaaabbaaababbababbbbbabbbabaabbababaaaabaaaaaabaabbababababbabbabbababaabbbabababaabbbabaaabbbabaababaaaaaabbaaabaababbaaabbaababbbaabbbabbbbaaababaaabbbbbaabbaaaaaaabbabbabbababaababaaababbababbbbabaabaabaaaababaaaaabaaabbabbbaaababbbabbabababaaabbbabaaabaabaaababbbabaaabbaabaaaabaabaabbababbaaabaabaabaaababaaabbabbaaababaaabbabbaaabbabbabaaabaabbbbbbabbaaabaabaaabbbbababababbbabbaabaabbaaabaabababbbaaabbabaabaaaababbbaaabbabbbbaabbabbaabbabbbaabbaaabbbaabbbbaaabaabbabaaaababababbabababbbabaaaaabbbbbabaaaaabbbbbbabbbababbaaabbbaabbaaaaabaaaabbaabbabbbbabbaaabaaababaababaababbbababaabbbabbabbbaaabbbabbbaabaaabbaabbbaabbabbbabaabaaaaaaaabbbaabbbabbbabbbbababbbaabbbbabbbbbababaabbabbaabaabbababbbaabbabbbbaabbbabbabaaaababaaabaabababbaabbbaabaaababbaababababbabbaaaaaaaaaabaabbbabbabbaaaababbbababbabbbbbbabaaabbbababaabbbabbabaaaabababbbaaabaaaaabbaabbaabbaabbaabbabbbbbaabaabbabbaabaabaababaabaaabbabbaabbbbbaabbbbbbaabbbbaababbaabbbaaaabaabaabbbabaaababaaaaaabbaaababbaaababaaabbbaaaaaaaababbabbaaaababbbaaaaaababaabbaaabbbabbababbababaaaaabbbabababbaaaaaabbbabbbbabbbbbbbaabbbbbbbbaabbaaaabaabaabbaaabbabbaabbababaaaaaaabbaabbaabbabaabbbbaaaaaabbbbabbabbbbabbaabaaaabaaaababbaaaababaaabbabababaabaabbaaababbbbbaabbaaabbbbbbbbbababababaaaabababbbaaaabaabaaabbbaabababaaaabaabbbbbbaaaabababbaababbabaaabaabaababaababaaaabababbabbabbbababbbaabbaabbaabbabbbbbbaabaabaaaaaabaabbabababaaaabbbbbaaaaaaaabbaababaabaaabaabaaaababaabbbabaabbabbbabbbabbaaabbaababbaabbaabaabbababaabbbababbabbabbabbaababaaaabbbbbabaaaaaaaaaaabaabaabbabaababaaaaaaaabaaaabbbbbbbabababbbbaaabaaabbbbbbbbbaaaabbbaababababbbabbbabbababaabaabbbbabbbababababbbabaaabababbbaaabaabbbaababbaaabbbbababbabbbabbbaabbabbabaaaabaaabbaaabbabbabbbbaaaabbabbbbabbabbbbababbaaabbbbabbbbbaaaabbabbbaabbbababababaabbbabbbaaabaaaaaaabbaaaabababababbbbabbbaabaabbbbabbbbbabababbabbabbbbbbbbbbaaababbbabbbbbabbaaababaaabababaaaaaabbbbaabbbabbabbaababbaaaabababbbbaababababaabbbaabaabaaababbabbaabaabaabaaaaaabaababaaabaaaababaababaaabbaaabababbbaaaaaaaaabbaabaabbaaaababbabbbabbbabababbaabbabababababbbabbaaaabbaaabaabbbbaabbaaabbaaabbaaaabaabaaabaabbabbbbbbaaaaabbbbaaaabaaabbababaabbaabbaababbabaaabaaaabbbbaaaabbabbbbaabbbbababbbbbaabaaaaaaababbaabbabbaabaaababbbaaaabbaaabaabbbaababbaababbbbaabababaaababbaabaaaababbbbbbbabaabbbbaabbbbabbbabbaabbabaaababbaabbaabbabbaaaaabbbabaaababbaaaaabaabbabbbbbabbbbabbbabbabbbabaabbaaabaaabbabaaabbbababbbbaababbbbbbaabbbbbbbabaabbabbbaabaaabaaaaaabbbbbaabbaaabbaaabaaababbbaaaabbabaabaabbababbabbbbbaabaababaaaabaaababbbbbbabbabbbaaaaabbabbbabbbbbbbbabaaaabbbaaaaaababbbaababbbbabaabaaabbaaabbabbaabbaaaaabaabaabbbbbbbabbbabbaababbbbaaababbbbaabaaababbaabaababbababaabaabaaabbbaaaabaabbabaabbbaaabaabbaabababaabaabaabbbababbabbbbababbbaabbbaabbbaaababbabbbaabaabbaabababaabbbbaabbbaaaaabbbbbaaababbabaaaabaabaaaabbaaababbababbaabbabbabbaaabaabbaabababbbaaaaaaaabaabaaaaaabaababbbbbbbabbbabbaaaabaaaabbabaabaaaabbababaababbbaabbabaabbababbbbbbbbabbbbbbbababaabaaababbbabbabbbabbbbabaabbaaabbaaabbabaabaaaaabbaabbbbbbbabbbabbabaaababbabaaaaabaaaaaababaaaaaaaabbaabbabbaabaaabbbbabbababbbbbaabbababaabaabbbabaababababaaabbaaababbaaaabaaaaabbbabbbbaaaabbababbaaaaabaabbbbabbabbababaaabaaaabbbbbaabaaaababaaaaaaaabaabbaaaababaaaabbaaaaaababbbbbbaaaabbabbaabaabbabbaaaaababbbabbabaaabaaaaabbabbabaaabbabbbabbaaaabbaaabbbbbabaabbaaaaaabaaabaabbbabbaabbbabbaaaabbaababbbbbbabbabbaabbbbbaaaaaaabbaaaaabababbbabbbbaabaabbaaabababbbaaaabbbaaaabaaaabaaaaababaabbabbaabaababababbbaabababbababbaabababaababbabbabbabbbaaaabaababbbbaabbaaaabaabbaabbbbabbaabaaaababbbbaaababbbbaaaabbaabbaababababbababababbbaaaaabaabababbbbbbbabbbaaabbaaaabaabbbaaabaaaaabaabbaaababaaaaaabbabbbabbabbbaabaabbaabbbaaabaaaabbbbababaabbbbaabaaaaaabbbbaaaaabaaaabaabbaaababbbbbbabbbabbaabbbbabbbaaababababbbaaabaaaabbbbaabbbbbbaabbbabbbbbababbbbabbbaaabababaaababbbaaabbbabbaaababaaaaabaababaabbbbbbbaababbbabaaabbaabbbbabaaabaababbbbaaaaabaaabaabbababbabaabbbaabbbabbaaabbbabbbbbabbaaabaaabaabbbaaabbbabbbaaabaabbbbaabaabababbbabbbabababbababbbaaabaabaaaabbaabaaaaababaaaababaabbabbbaababababaaabaabaaaabaaabbabaabaaabbaaaaabbbbabbbabbaaaabbabbbabbbaabbbbbbaaaaaabbaaaabaaabababbaaaabaabbababaaaaabbbaaaaabbaabbbbaabaabaabaabbaaaababbaaabbaaaabbbbbababbaaabbababaabbabaaaaababbbbaabababaabababbbabbabbbaabaabaabbaaabbabababbaaaabbabaabbbaabbbbbaaababbbaabbaaabaababbbbbbabbabbbaabbbabaaabaabbaabaabbbaabaababaabbbaaaabbaaabbababbbabaabbaabbaabaabbbababaaaabbbbaaaaaaabaabababaababbbbabbababbbbabababaabababbaabbbbbaaaaabbaaabababbaabbbbaaababaaaabbbbabbababbabbbababbbbbbaaaaabbaabaaaaaabbbaaaaaaabaaabaabbaabbbbbaaabbbababbaabaababaabbabbbaabbabbabaabbbaababbbbaaaabbbabbbbababbbbabbabbbbaaaaaaaaabaaabbbaaaaabbbaabaabbaaabaababaabababaabababbbbbbaabaaaabbaabbbabbaababbabbbbaababbbaabababbbabaaaaaababbbabaaaababbbaabbabaababaaaabbbababbaaaaababaabaaabbbbbabbaababbbbbabaabbbbaaaaaabbababbbbbbabbabaaaabbaabbaaaaabaaabaaabbbbbaabbababbabbbabbabbbabbbaaababaaabaaaabaabaabbbaabaaabbaabbbbaabbbbaabbbaaaabaabbbaababababaaabababbbaabaaabbaaaaababbbabbbbaabababbabbbbaabbaabaabbababbaaaabbabbaabbbbbaaabbaabaabbaaabababbbbbbaababbbbaaaabbbaaaabaaabaabaababbaabbaaaababaaaaabaaaabababaaaabbbabaabbbababbbbbabbabbbbabbabbabaaabbbbbbaabbaaaaabbabbbbabbbaabaababaababaabbaabbaaaababaaaababbbabbababaabbabaabaabbbabbaaabbabbbbbbbaabaaaabbbbabbbabbbbaaaaababaaaaaabbababbbaaabbababaabbbabaababaabaabbabaaaaaabbaababaaababababbbbbaaabbbbbaabbbbbbabbaaaabbabbababaabbbbbaabaabaaaaaabbaabaaaaaaabbbaaabbabaaabbbabbbaabbaabbaaabaabbbabbbabaaababaabaaaaababaabbbbaabaabbaabaabbabaaabbababababbabaaaababbaaabbabbaabbaaabaaaaabaaabaaaabaaaabaabbaabaaabbaaabbbaababaaaabbaabbaaababbbaaabaabaabaabbababbaaaaababaaaababaabababbaababbbaaaaaaaaaaababbaabbbabaabaaaaaabaaaabababbbababbaaabbbbaaababbbbaaabbabbaaabbabbabaaabababbaabbabbbaaabbbbbaabbbbbbabaaabbaaababbaabbbabbaabbbbbaabbbbaabbbabbabbabbabaabaabbaababbabbaabbbbaabbbabaababaabaababaaababbbbababbabaaabbbbbbbabaabbbbbabaaaaaaaaaaabaaaabbbaabbabaabaabbbaaababaaaaabaabaabbbabbabbabbaabaaababbbabaabababababbabbbababaaaabbbbbabbbbbaaabbbbbbbabbabbaabbababbbaabaababaaabaaaabbbabababababababbaababababbbbaaabbbaaabbbbabbabbaaaaabaabaabbaabaaabaabbbbaabaaaabaabbaabbbbbaaaabbbbabaaaabbabaaabbaaababbbbbaabbaabbabbabbabaaaabaaaaabbbaababbaaababaaabaababaabbbabababababbbabababaaaabaaababbbbabababababaabbabbabbaabbbaabbbbbbbaaabaaabbbabbbaaaaababbabababaabbaababababaaaabbabbaaabbabaaabbbababbbbbbababbbbabababbababbbbaabbaabaabaabababbbbbbaaabbaaababababbaaaaaaaabbbaabaaaabbbabbaaaabbbabbbabbabbabbabbaabbbbbbbaaaaababbaabaaaaabaabaabbbbaaaaabaaaabaabbbbbbaabaaaababbabaaaabbabbababaaaaaabbabaabbbbabbaaaaabbaabbaabaaabaabaabbbbaaabbaababaaaaaaabaaabbbbbabaababbabaabaababaaaaaabbbaabbaabbabbaabbbaababaabaaaaaabbaabbababbabbbabbbabbbbabbabababaaababbaaaaababaabbaabaabbbbaaaaabaabaabbbaaaabbbbaaababaabaababbabbbbbaaaaabbabaabaabaaabbbaababbabaabaaaababbababbbababbbbabbbbbabbbabbbbbbbbbababbbaaaaaabaaababaaaaaaabaaabbbabbbababbabbbabbaaaaaaababbaaabbabbaabbbbbbababaabbbabbbbbababaaaaaaabbabbbbabaaabaaababbbbaaaaabaabbbaabaabbbaabaababaabaabaaabbabbababaabbbbaaaababbabbabbbbaaababbbaaaabbbababbbabbabaabaaabbabbbabbaaaabbaaabbbbabaababbaaabbbaaabaaabbababaaabaabaaabaabaaaaaababaaabbbaabbbbabaabaaababbaababbbaaabaabaaaabbaaabbbbbaaaaaabaaaabaababbbbaaaaababaaaaabaabbaaaabaababbaabbaabbbabababbaaaaaaabaabbaabaabaaabaabaaabaababbabbaabbaabaaaabaaababbabbabaabababbababaaabbaaaaaabbbabaaaabaabaaaabbabbaaaaaaabbbbbbabaaabababababbbabababaabaabaaaababaaaaaaababaaababbbbbbbabbbaaabaaabbabababbbbbaababaababbabaaabaababaaababaabababbbbaabaabbbbbbbabbaaabbaaababaaaabbbbabbaabbbbabaabbaabbbabaabbababaaabbabaaaabaaababbbbabbabbabababaaaaabbbbaaabaaabaabbbbbaabbbbaaaabbabbbabbbbaaaabbbabababaababbbbababaaabbbaaabaabbbbababababababbaaababbbbaaaaaaabbbbaaabbbbbbaaaabbaabbbbbaaaaaabbbbaabbaaabaaaaabbbbbbbbabababbaababbbbaaababaaabaaabbaababababaaabbbaabbbaaaabaaabbbaaaabbaababaaaabbbaaaaaaaaababbbabaababbbaabbabbabaaaaaababbbbbbaaabbbababaabababaabbbabaabaaaaabbbbaababbabbabaabbababaaabbabbbbaabbaaabbaaababaaabaaabbaaaaabbbbbaaabbabbbbabbbaaaaaaaabbbaababaaaabaaaaaabbbaababababababbbbaaabaabaabbaabbabaaabaabbbaabaaabbbbbbbbbbbaaaabbbbbbbbbbbbaabaaababaabababaabbbaaaabaaaaabbabbbaaabbbbbaaabaabaaabaabbaababababbabababaaaaaabbbabbaabaabbaaabaabbbababababbbbbbaabbbbaaabaababbaaabbbbbaababaabaaabbbbbabbabaabaabaabaabbabaabbaabbaaabbbbabbbbbabbabbbbbbaaaababbaababbbbabaaabaabaaabbbabbaaabbaaaababbbaabbaabaaaaabababbabbabbabaabbabbabbabbbbaaaaabbbababbbbaabbaaaabaaaaaabbbabaaabaaaabbbbaabbbaaababbabbbabbabababbbaaaaabbbbbaaabaabbaababbababaabaaabbaaaabbaaabbaaabbaabbbbbbababbabbbbbbbaabbbabbbabbbbbbbbbabbabbbabbbbbbbbbabbbbbaaabaabaaabbaabbabbbbbbbabbaaabbabaaabbbbbbbbbbbbbbabbaabbbaaaababaaaaaaabaabbbbabbbbbbbbbbaabababababbbbabbbbabbaaabaabbaaaaabbaaababbbaaaaaabbaaababbababaababbbabababbabbbabaaaaaaabaaabbbabababaabbabaaaabbbbbbaaaababaabbbbaabbaaaaaabaaabbaaaabaaaaabaaaabbbabababbabaaababbbaaaabbaaaabbababbaabaabbaababbababbababbbabaababbbaaaabbbbaabbbabbabaaaaaaaaaaaabababaaaabaaaaababbbbabbbbabaabaabbbbbbabbbaabaabbbabaaaaabbabbaabbbaaaabbbbaaaabbabbaabbaabaaabbbbbabbaababbaabaabababaaabbabbaabaaaaaaababbaabaaaabbaabbabbbaaaababaaaababbaabbbaaaabbbaaabaaabbbbbbabaabbbaaababababbbbbbabbabbbaaaaababbbaabaaaabababbbaaaabaaaabbabaaaaaababaabaabaaabaabaabbaaaaaabaaaababbbbbbbabbababaabaababaaaabbaabaabbaabbaaaaaabaababbaaaaaaababbbbabaabbbbaaabbbaabbbbaababbbaabaaababbbabababaabaaabbabbabbbabababbabbbaabaaaaaabaabaaaaaaaabbaaaabaaaabaabbaababbabaaabababbbaaaaaaaababaabaabaaabaaaabaaaaaabbbbbaaaaaababbabbbabbbaabbbaaaaababaabbbbaaababbaabaababaababaaabababaaaaabbbababbbbabbbabbabababbbbbababbaabbbbabbaabbbbabaababbabbbabbbbbbbaabababbbbabbbbaaababbbbbbbbaaaababaabaabbaabbabaabaaabaababaabbbabbbaaaabababbbaaabababbababbaababbbabaababaaabbbaaabbbbabbbabbaaababababbaaaaaababbaaabbbaabbabaabaaaabbabbbabbaaabbbaaabbbbbabbaabaabaabbbaaabaabbbbbaababbbbabbbbabaaaaabaabbbbbabbaababaabbbbbbbbbabaaaaabaabaabababbbababbabbbaabaaabaaabababaaababaaaabbbbbabbbbabbbababbabbabbaaaabbbbaababaabbaaaaababbbbabbbaabaabaabaababbbaaabaaabbbbbbbaabbabbbbbbbabbbbbbaaababaabbbabbbbababbaaabaabaaabbababbbbabbababbabbaababbbbbbbbaabaabbbbaababbaaaaababaaaaababababaabbbaabaabbabaaabaaaabaaaaabababababbababababbbbbbbaaabbbbbbbbaaaaabaaaaaaabbbbaaaabbbababaaababbababbbabababbababaabbaaababbbabbbbabbaaaaabaabaababaaaabbbabbbbabaaaaaaabbbaabbabbbbbbaabbaabaabbaabbaaaabbabbaabbbabbaaaaaaaaabbbbaaababbbaaaabbaabaaaabbabbabbbaabbbbbabababaaabbabaabbaabbbbaaaaaaaaababababbbabbaaabaabababababbbaabaaabaaaabaaabaaaabbbbbbbbbababaaaababbbbbababaaabbbabbbabbaabaaabaabbbbabbbbbbaaaabbaaaaababbaabaaaaaababbbbbabbaaaaabbbabbaababaaaaaabbababbabbbbaabbbbbbabaaaabababbaaabbbababababaabaaaaaababaaaababaaabaaabaaaaababaaabbabbbaabbabaabbabbbababbababbaaababbbbbaabbbabababbabbabbaabbaabaaaabbaaaabbaabaabbbbbabbababaaaabaabbabaabbaaaababbaaabbbbbbbababababbabbabbbbbababbbbbbaabbaabaabbababbbbabaaabbbaabbabbaabaabababbababababbaaaaaaaaaabbabaabaabbaabaaabbbaaaabbbbbaaabbaabaaababaabbabaaaababbabbaababaaabaaabbbabaabaabbbabbabaaaaabbaabaaaaabbaabbaababababbaabaaaaaabaaabbabaaaabbbabaabbabbaabbbaaabbbaaaababaaabbabbabaaaabaaabbaabbbaaaaabbababaabbbbaaabbbbbbaabbabbbbbabababbabbaaabaabbabbbabaaaaaaaaabababbabbabaaaaaabbaaaabbbbaaabbbbaaabbabaaababbaaabbaaabbbbaaabbbbbbbabaaabbbbaaababbaabaabbbbbabaababbaaaababaababababbaabbbaabbbabbbabababbabbabbbaababbaaaabbabbababbbbaabaaaaaabababbbbababaaabbbbbbbbbabbbbbbaaaabbaabbbbbaabbabaaabababaaabbbbbababbbabaaaaabbaaabaaabbbaababbbbaabababbabbbababaaababbbaaaabaabababbbaabaaaabaabababbaabbbaaabababbbabaabbbabbaabaaabbaabbababbbbababbaaaabaaaaabababaaaabbbabbbbaaabbaaabaaaaabaabbbbbbaaaaabbaaaaaabbbbbbbbaaaaaaabaabbbaababbbbabaaababbabababbbbaabababbbababbaabbbabbaaaabbabaabaabbbbbbabbbabababbbaaaaabbaaaabbabbbaaababbababaabababaabaabaabaaabaaabbaaaabbaaaaaababbabbababababbaababaaababbabbbabaabbbbabbaabaabababbbbabaabaaaabbaaaaaaaaabbbabbbbabbbabbabaaabbbabababbbabbbbbaabbabbabbbaababbaaaaaabaabbabaabaaaabbbababbbbaaaaaababaabaaaabbababbaaaaabbbaaaaaaabababbaaabaaabaababaaaababbaaabbbabaaaabbbbabbababbabbbababbbbaaaaaaabbbabbabaaaaababbaababaaabbaababbabbbaabbababbbabbaabbbbbabaaabaabbabbbaabbbbbabababaaaaabaabbabababbbbaababaaababaababbbbbabababbabaababaabaabbbabaabbbaabbabbbabbababaaaaabbbaaaabbbbabaaabaabaabbbaababbabbbbaaaabbbaaaabaaabbaabbbbbabbbababbbaaaabababaaaababbbbbaabaaaabbbaabbaaabbaabaaaabbbbbaababaabbababaaabbabaaaababbaabaabaaabaabbbaababbbbabbbaabaaaaabbabababaabaaaabbbababbbbabbbbaaaaaaabaaabaabbbbaaaaababbaaabbbbabbbbbabbaaabaaabaabaabaaabbaabbbaabbabaaaabbbaaaabbabaaaaaaaabbbabbbaaaaabbabaaaaabbabbaaabbbabbaabaaaabbaaabbabbbbaaabaabbbbbbbabababababbaaabaabaaabaaabbaaabbaabbabaaabaabbaabbabbbbbbbbaaababbbbabbababbababbbbabbabaabaaaaaaabbbabababbaabbaaabaabbaabbabaaaabaabbaaabaabbbababaaabbbabbabbababbaabbaaababbabaabaabbaababaabaabbaabbbbaaabaaabbabbaaaababababaaaabaababbbbbaabbabbaababbaabbbbaabababbabaabaaaaaaabbaabbabbaaabbbbbababbbbbbaaababaabbbabbababbaaaaaaabbaabbbbabbbbbaabaababbaabbbbbaaaabababbbbaaaaabbababbababababaababbbbbabbabaaaaabbbbabaabbaabbbabbbbbaaaaabbbaaabbbabbabbbababaaaabbaababababaabababbaabbaabaaaabbbabbbababababbbaabbabbbaababbbaaabababaaaabaababaaaababaabaaaaaaaabababbabaaaabaaabbbbbabaaabaababbbbaaaababaabaaaaababbaaabaabbaaaaababaabaabbabbabbbaababababbbaaababaaaaaabbbbaaaabbabbbbabababaabbaaabbbbaabbaabaaabbbbbaaabbabaababaaabbbaaaabbaaabbbabbbbaabbbabaaabbbabbbababaaabbbbaaabbabbbbbabbaaababbbbbbababbabbbbaaaabaaabbaabbaaabbabbaaaaabaabbabababbbabbabaaabbbaabaaabaaaaabababbbbaaaabbbbabbbaabbababbaababababbbaaababbabaaabababbababbabbabaabaabbbbaaabaabaaabababbabababababbbbaaaaabababbabababaabaaaaaabbbbaabbbaabaabaaaaaaabbaaabbababbaabaabbbaabbaabbbaabaaabbbbaaaababbbbbbbbabbaabababbbaaababbabababbbbbaaabbabbaabbbbaabbabaaaabaaababaabbbaaaabbabbbbbaabbbbbbaaaababbaaabbaabaaabbaabaaababbbaaabbbaaaabbabbaaaaaabaabaabbbabaaaaabbbaaabbbbbbbbbbbaabbbbbbabbaaababbbaaaabbabbaabbaaababaabaaabaabbaaabbbbbaaaaabbbbbbbaababbbbabbbaaabbabaaaabbabbaaaabaaabbaaababbbabbaaaababbbbabbabbabaabbbabbababaaaaabbaabbababaaabababbaaaaaabbbbaaaaabbababbababbbabababbabbbbaabbabbbbbabaabbaabbbabbababbbbababaabbbaabaaabaaaaabbabababaaaaaabaabbbaaabaababababbabbaaabaaabaabbbbabaaaaababaababababbababababbaaaababbabbabbbbbaabbababbbbbaaababbbababbaabbbaaabbbbabbbbbabbbaabbaaabbaabbaababbabaabbababbbbbbabaaabaabbbbabbbbabaaabbaabaabbabbaaaaaaaaaabbbbbbbbabbbaabbbabbbbbbbaababaababbaaaaaababaaabbbbbbaaabbbbbaabaaaababaabaabbbabbabbaaaababaaabaabbaababbbaababbbbaaabababbabbabababaabbbbbbbbbaababbaaaabaaabbbbbaabababbaaaaaaaaabbaabbababbbabbbbbaabaaabbaabbaaabbbaabbaaaababaabbbaabaabbaabbbaabbabbabbaaabaababbbaababaaaabbbaabbbbbabaaabbbbbbaaaaaabbaabbbbbbbbabbbbbbbaaaabbbabaaabbbbabbbbbbabbababaabaaabaabbabaabbababababbaaabbbbbaaabbabaabbabbaaaababbaabaaaaabbbbbbabaaabaaaaaaabbbbabaaaabbbababaabbbabbbbaaaababaababaaabbabbaaaabbabbabbabaaabaabbaaabbbababbabbbababbaabbaaabbaabbbbaaabbbabbbbaaaaabbaaabbabbaaaaaaaababbababbabaababbaaaabbbbaabaababbbbbbbbabbbbabbabaaababbbbaaaaababaaaabaaaabaabbaaaaaabbaabbaabbbbbabaaababbabbbaaabbababaaaaababbabbbbabaaaaabaababababaabbabbaabaaaabaabbbabbababbabbbabababaabbbbabbbbaabaaabaabbbabbaabaaababbbaabaabbabbbbabaaaabbbabbbabbaabbbabbaaababbabaaaabaaaaaabbbabaabababaabaabaabaabbbaaaabaabbaabaabbbbaababaabbbbbabbaabaaabaabbbbabbbbabbaaabbaaabbaaabaaaaaaaabaabaaaabaaababbababbbbaaababbbbababbbaaaabbbbaabbababbbabbaaabbaaaabbbbabbaabaaabbaababaabbaaaabaaaabbaaaaabaababbbabbababbbbababbbbaaabbbbabababbbbabbbbaaaaabbbaabbbaabaaaabaabbabbbaabaababbbbaaabbbbbbaababbbbbaaaaaababbabbbbabababbbabbbabbbaabaabbbbbabbabbbbbaabbbabaaabababaaaaaaabaabababbaaabbaabbbababaaabbaababaaaabbbbaabbbbaaabbbabaaaaaaaabaaabaaabababbaaaaaabaaabbbbbabbabbaabababbababababaaaababbabbaabbabbabaaaabaaabaabbbabaabbbbbaabaababaaabababaabbbabbbbbbbbbbaaababbbbbbababaaaabbaabbbbaabbbababababbbaaaaabbabaaaaabbaaaabababbabaabbabbababbbbbabaaabbbbbbbbbaaabaaababaaaaabaabbaaaabbaabbbbbabbaabaabbaaaababaabbbbbabbbaaabaabbabbaaaabaaaabaaaaaaaabaabbabbbaabbababbbabaaabaabaaabbaababbbababbaabaaaabbabbbbbaaababbaabbaababbaabbbbbbababbabbaabababbbabbbbbbabbbabababbbbabbbaaababbaaabbbaabaaaabaaaabaabbbababbbbbbbbaaababbaabaaabbaaabbbbbabbbabbbababaabaaaaaaaaaabbbbbaabbbabbbbbabbabaabbabbbaabbbbabbabbbaaabbaababbabababaabbbbbaabbbbaabbbabbaaaaaabaabbabbbbbaaababbabbbababbbbbaaabaabbaaaaaabaaaaaabbbaabbaaabaababbaaabbabaabbbaababbaabbbbbbabbbbabaababbbbbaababbabaabbbaaaaabbbbbababbaabbababaabbabbbabbaaaaaabaaabbababbaabbbabbbabbabaabbaaabbaabbbbabbbaaaaaaaaabaabbbbababaababbbbababbbaaabbabbaabbababbaabababaabbaaabaabbababbbaababababbbababaababaaaabbaabbbaabaabbabbaaaaaaaaabbbbbabbbabaaaabbabaaababbaabaababaaabbaabbabbbabbaaabaaabbbbaaabbbabbabababbbbbbbbbaaabaabbaababbabaaaababbbbbababbabaabbabababaaaaababbabaaabbaaabbbbbaabbabbababbaaabbbaabbabaabaababbaaabbbbbaabbaaaaabbaabbbaabbbbabbabbabaaabbbabaaaaaaaababaaaababaaaaababaaaabaaaaaaaaababaabbbababbbbaabaaaaabbbababbabbaabbaaabb", + "babaaaabbbbabbababbabbbababbbb", + }, + + { + "moplvidmaagmsiyyrkchbyhivlqwqsjcgtumqscmxrxrvwsnjjvygrelcbjgbpounhuyealllginkitfaiviraqcycjmskrozcdqylbuejrgfnquercvghppljmojfvylcxakyjxnampmakyjbqgwbyokaybcuklkaqzawageypfqhhasetugatdaxpvtevrigynxbqodiyioapgxqkndujeranxgebnpgsukybyowbxhgpkwjfdywfkpufcxzzqiuglkakibbkobonunnzwbjktykebfcbobxdflnyzngheatpcvnhdwkkhnlwnjdnrmjaevqopvinnzgacjkbhvsdsvuuwwhwesgtdzuctshytyfugdqswvxisyxcxoihfgzxnidnfadphwumtgdfmhjkaryjxvfquucltmuoosamjwqqzeleaiplwcbbxjxxvgsnonoivbnmiwbnijkzgoenohqncjqnckxbhpvreasdyvffrolobxzrmrbvwkpdbfvbwwyibydhndmpvqyfmqjwosclwxhgxmwjiksjvsnwupraojuatksjfqkvvfroqxsraskbdbgtppjrnzpfzabmcczlwynwomebvrihxugvjmtrkzdwuafozjcfqacenabmmxzcueyqwvbtslhjeiopgbrbvfbnpmvlnyexopoahgmwplwxnxqzhucdieyvbgtkfmdeocamzenecqlbhqmdfrvpsqyxvkkyfrbyolzvcpcbkdprttijkzcrgciidavsmrczbollxbkytqjwbiupvsorvkorfriajdtsowenhpmdtvamkoqacwwlkqfdzorjtepwlemunyrghwlvjgaxbzawmikfhtaniwviqiaeinbsqidetfsdbgsydkxgwoqyztaqmyeefaihmgrbxzyheoegawthcsyyrpyvnhysynoaikwtvmwathsomddhltxpeuxettpbeftmmyrqclnzwljlpxazrzzdosemwmthcvgwtxtinffopqxbufjwsvhqamxpydcnpekqhsovvqugqhbgweaiheeicmkdtxltkalexbeftuxvwnxmqqjeyourvbdfikqnzdipmmmiltjapovlhkpunxljeutwhenrxyfeufmzipqvergdkwptkilwzdxlydxbjoxjzxwcfmznfqgoaemrrxuwpfkftwejubxkgjlizljoynvidqwxnvhngqakmmehtvykbjwrrrjvwnrteeoxmtygiiygynedvfzwkvmffghuduspyyrnftyvsvjstfohwwyxhmlfmwguxxzgwdzwlnnltpjvnzswhmbzgdwzhvbgkiddhirgljbflgvyksxgnsvztcywpvutqryzdeerlildbzmtsgnebvsjetdnfgikrbsktbrdamfccvcptfaaklmcaqmglneebpdxkvcwwpndrjqnpqgbgihsfeotgggkdbvcdwfjanvafvxsvvhzyncwlmqqsmledzfnxxfyvcmhtjreykqlrfiqlsqzraqgtmocijejneeezqxbtomkwugapwesrinfiaxwxradnuvbyssqkznwwpsbgatlsxfhpcidfgzrc", + "akyj", + }, + + { + "banana", + "ana", + }, + + { + "abcd", + "", + }, + + // 可以有多个 testcase +} + +func Test_longestDupSubstring(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ans := longestDupSubstring(tc.S) + ast.Equal(len(tc.ans), len(ans), "输入:%v", tc) + ast.True(isDupsub(tc.S, ans) && isLongest(tc.S, ans)) + } +} + +func isDupsub(S, sub string) bool { + i := strings.Index(S, sub) + if i == -1 || strings.Index(S[i+1:], sub) == -1 { + return false + } + return true +} + +func isLongest(S, sub string) bool { + for b := 'a'; b <= 'z'; b++ { + if isDupsub(S, sub+string(b)) || + isDupsub(S, string(b)+sub) { + return false + } + } + return true +} + +func Benchmark_longestDupSubstring(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + longestDupSubstring(tc.S) + } + } +} diff --git a/Algorithms/1046.last-stone-weight/README.md b/Algorithms/1046.last-stone-weight/README.md new file mode 100755 index 000000000..f2efc9830 --- /dev/null +++ b/Algorithms/1046.last-stone-weight/README.md @@ -0,0 +1,27 @@ +# [1046. Last Stone Weight](https://leetcode.com/problems/last-stone-weight/) + +We have a collection of rocks, each rock has a positive integer weight. + +Each turn, we choose the two heaviest rocks and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is: + +- If x == y, both stones are totally destroyed; +- If x != y, the stone of weight x is totally destroyed, and the stone of weight y has new weight y-x. + +At the end, there is at most 1 stone left. Return the weight of this stone (or 0 if there are no stones left.) + +Example 1: + +```text +Input: [2,7,4,1,8,1] +Output: 1 +Explanation: +We combine 7 and 8 to get 1 so the array converts to [2,4,1,1,1] then, +we combine 2 and 4 to get 2 so the array converts to [2,1,1,1] then, +we combine 2 and 1 to get 1 so the array converts to [1,1,1] then, +we combine 1 and 1 to get 0 so the array converts to [1] then that's the value of last stone. +``` + +Note: + +1. `1 <= stones.length <= 30` +1. `1 <= stones[i] <= 1000` diff --git a/Algorithms/1046.last-stone-weight/last-stone-weight.go b/Algorithms/1046.last-stone-weight/last-stone-weight.go new file mode 100755 index 000000000..c67097b93 --- /dev/null +++ b/Algorithms/1046.last-stone-weight/last-stone-weight.go @@ -0,0 +1,41 @@ +package problem1046 + +import "container/heap" + +func lastStoneWeight(stones []int) int { + pq := PQ(stones) + heap.Init(&pq) + for len(pq) >= 2 { + a, b := heap.Pop(&pq).(int), heap.Pop(&pq).(int) + if a == b { + continue + } + heap.Push(&pq, a-b) + } + if len(pq) == 0 { + return 0 + } + return pq[0] +} + +// PQ implements heap.Interface and holds entries. +type PQ []int + +func (pq PQ) Len() int { return len(pq) } + +func (pq PQ) Less(i, j int) bool { return pq[i] > pq[j] } + +func (pq PQ) Swap(i, j int) { pq[i], pq[j] = pq[j], pq[i] } + +// Push 往 pq 中放 int +func (pq *PQ) Push(x interface{}) { + temp := x.(int) + *pq = append(*pq, temp) +} + +// Pop 从 pq 中取出最优先的 int +func (pq *PQ) Pop() interface{} { + temp := (*pq)[len(*pq)-1] + *pq = (*pq)[0 : len(*pq)-1] + return temp +} diff --git a/Algorithms/1046.last-stone-weight/last-stone-weight_test.go b/Algorithms/1046.last-stone-weight/last-stone-weight_test.go new file mode 100755 index 000000000..9fefa525b --- /dev/null +++ b/Algorithms/1046.last-stone-weight/last-stone-weight_test.go @@ -0,0 +1,42 @@ +package problem1046 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + stones []int + ans int +}{ + + { + []int{1, 1, 1, 1}, + 0, + }, + + { + []int{2, 7, 4, 1, 8, 1}, + 1, + }, + + // 可以有多个 testcase +} + +func Test_lastStoneWeight(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, lastStoneWeight(tc.stones), "输入:%v", tc) + } +} + +func Benchmark_lastStoneWeight(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + lastStoneWeight(tc.stones) + } + } +} diff --git a/Algorithms/1047.remove-all-adjacent-duplicates-in-string/README.md b/Algorithms/1047.remove-all-adjacent-duplicates-in-string/README.md new file mode 100755 index 000000000..7d58c9107 --- /dev/null +++ b/Algorithms/1047.remove-all-adjacent-duplicates-in-string/README.md @@ -0,0 +1,21 @@ +# [1047. Remove All Adjacent Duplicates In String](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/) + +Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. + +We repeatedly make duplicate removals on S until we no longer can. + +Return the final string after all such duplicate removals have been made. It is guaranteed the answer is unique. + +Example 1: + +```text +Input: "abbaca" +Output: "ca" +Explanation: +For example, in "abbaca" we could remove "bb" since the letters are adjacent and equal, and this is the only possible move. The result of this move is that the string is "aaca", of which only "aa" is possible, so the final string is "ca". +``` + +Note: + +1. `1 <= S.length <= 20000` +1. `S consists only of English lowercase letters.` diff --git a/Algorithms/1047.remove-all-adjacent-duplicates-in-string/remove-all-adjacent-duplicates-in-string.go b/Algorithms/1047.remove-all-adjacent-duplicates-in-string/remove-all-adjacent-duplicates-in-string.go new file mode 100755 index 000000000..14b6b1bda --- /dev/null +++ b/Algorithms/1047.remove-all-adjacent-duplicates-in-string/remove-all-adjacent-duplicates-in-string.go @@ -0,0 +1,15 @@ +package problem1047 + +func removeDuplicates(S string) string { + bs := []byte(S) + stack, top := make([]byte, len(S)), -1 + for _, b := range bs { + if top >= 0 && stack[top] == b { + top-- + } else { + top++ + stack[top] = b + } + } + return string(stack[:top+1]) +} diff --git a/Algorithms/1047.remove-all-adjacent-duplicates-in-string/remove-all-adjacent-duplicates-in-string_test.go b/Algorithms/1047.remove-all-adjacent-duplicates-in-string/remove-all-adjacent-duplicates-in-string_test.go new file mode 100755 index 000000000..d27baa0c3 --- /dev/null +++ b/Algorithms/1047.remove-all-adjacent-duplicates-in-string/remove-all-adjacent-duplicates-in-string_test.go @@ -0,0 +1,37 @@ +package problem1047 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + S string + ans string +}{ + + { + "abbaca", + "ca", + }, + + // 可以有多个 testcase +} + +func Test_removeDuplicates(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, removeDuplicates(tc.S), "输入:%v", tc) + } +} + +func Benchmark_removeDuplicates(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + removeDuplicates(tc.S) + } + } +} diff --git a/Algorithms/1048.longest-string-chain/README.md b/Algorithms/1048.longest-string-chain/README.md new file mode 100755 index 000000000..9499a7e7a --- /dev/null +++ b/Algorithms/1048.longest-string-chain/README.md @@ -0,0 +1,23 @@ +# [1048. Longest String Chain](https://leetcode.com/problems/longest-string-chain/) + +Given a list of words, each word consists of English lowercase letters. + +Let's say word1 is a predecessor of word2 if and only if we can add exactly one letter anywhere in word1 to make it equal to word2. For example, "abc" is a predecessor of "abac". + +A word chain is a sequence of words [word_1, word_2, ..., word_k] with k >= 1, where word_1 is a predecessor of word_2, word_2 is a predecessor of word_3, and so on. + +Return the longest possible length of a word chain with words chosen from the given list of words. + +Example 1: + +```text +Input: ["a","b","ba","bca","bda","bdca"] +Output: 4 +Explanation: one of the longest word chain is "a","ba","bda","bdca". +``` + +Note: + +1. `1 <= words.length <= 1000` +1. `1 <= words[i].length <= 16` +1. `words[i] only consists of English lowercase letters.` diff --git a/Algorithms/1048.longest-string-chain/longest-string-chain.go b/Algorithms/1048.longest-string-chain/longest-string-chain.go new file mode 100755 index 000000000..48f2ffe95 --- /dev/null +++ b/Algorithms/1048.longest-string-chain/longest-string-chain.go @@ -0,0 +1,54 @@ +package problem1048 + +func longestStrChain(words []string) int { + indexs := make([][]int, 17) + count := make([]int, len(words)) + for i, word := range words { + l := len(word) + indexs[l] = append(indexs[l], i) + count[i] = 1 + } + + res := 1 + for length := 1; length+1 <= 16; length++ { + for _, i := range indexs[length] { + for _, j := range indexs[length+1] { + if count[j] > count[i] { + // because of isPredecessor is expensive + continue + } + if isPredecessor(words[i], words[j]) { + count[j] = count[i] + 1 + } + } + } + } + + for _, v := range count { + res = max(res, v) + } + return res +} + +func isPredecessor(w1, w2 string) bool { + n := len(w1) + diff := 0 + i, j := 0, 0 + for i < n && diff <= 1 { + if w1[i] != w2[j] { + diff++ + } else { + i++ + } + j++ + } + return diff == 1 || + i == j // w1[:i]==w2[:i] +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1048.longest-string-chain/longest-string-chain_test.go b/Algorithms/1048.longest-string-chain/longest-string-chain_test.go new file mode 100755 index 000000000..a47b9e650 --- /dev/null +++ b/Algorithms/1048.longest-string-chain/longest-string-chain_test.go @@ -0,0 +1,47 @@ +package problem1048 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + words []string + ans int +}{ + + { + []string{"biltnzk", "jxwakrfxsifoj", "uzdwyaxvcsr", "sqqgkhwbf", "tnoftkolx", "ipmtvxcwe", "zsucxrqkhahuo", "qngglugvm", "kvohqyedig", "njoxacsnddwrg", "vwtnxw", "kjjourlrzpgeem", "xcs", "pfsgimurs", "lsifyg", "uzwyxcsr", "muzdwcyanxvcstr", "teqyrlhbvcv", "rkga", "tudezgzbnzb", "uzwyaxvcsr", "qvzkmgfulby", "x", "muzdwcyianxvcstr", "koqyig", "gl", "aqcacmy", "pmvwe", "eskofqduddkhykr", "pm", "saxxd", "ds", "iemm", "tudegzbz", "yipsawmxbp", "qyrlhbvcv", "yxuhwkzvoczoz", "zsucxqkahuo", "kga", "zwziivbijeiig", "wffaheemjnjahzdd", "zcxkahuo", "djjjsulms", "plxh", "ffpasoizwhtu", "zwziivijeii", "fyvpzegautteiv", "qszaitzfzv", "uwoghcy", "qqgkhwbf", "eteqyrllhbvcvg", "qknspkhngorof", "qwvzkmgfuljbyz", "grkte", "grikrnwezryi", "xjbpvekneaxn", "cy", "wnhnyqmpbsum", "m", "offqllgj", "plxhib", "omblqcoktkyf", "pasw", "prsngzx", "offlj", "rvvudgpixa", "djjjjsulmmrs", "gt", "mpfsgimurs", "cxkahuo", "ipmtvxcwue", "pqrbaoquxqemv", "prqqv", "tnoftfkolx", "jfzzaw", "rshquwmrboghccy", "ebqhvwewzzmqif", "rrd", "dvjjjjqsulmmrs", "pfsiurs", "crnruydj", "rvqgeqql", "djsums", "prbaquqemv", "bs", "dzytccvny", "kce", "llfv", "jfzaw", "qwvzkmgbfuljbyz", "kgieph", "hnympsum", "ewv", "vfgel", "rklga", "llzqbfv", "gte", "jckqurkg", "qngglugm", "tudgzbz", "ipmvcwe", "rr", "kkcev", "djjjjsulmrs", "llqbfv", "offqlgj", "paswu", "tlrlcnnrsrf", "jcckqurkg", "jjourlpgeem", "nvl", "shquwmrboghccy", "vncfgelm", "dgcdgjcksk", "vvhvmibflb", "juifgeqkaectlcj", "scvdl", "whcy", "yipswmbp", "wcy", "hbqq", "bsth", "etjurltvpsuy", "dzvytcccevnceyq", "apqrbaoquxqemv", "kvohuqyediyig", "lenybbukzftz", "ffpasoiuztwhtu", "lzlhzqibfv", "wfeemjnjahzdd", "djsulms", "xtudezgzbnzb", "eemjhzdd", "scavdil", "guchrvaqbe", "nvll", "sxzfpzjmxvu", "dytccvny", "grikrnjwezryi", "prng", "ntvmcwwpzo", "laqgcacyxmym", "mglosifyg", "nynvlqll", "vwtn", "lh", "zhhxducgelhy", "prg", "kghierph", "zsucxrqkhahuom", "kvohqydig", "eemjhzd", "offiqcdllgji", "dyc", "toflx", "dzvytccvney", "ghvb", "to", "guchrvab", "wyimthhfzndppwt", "elbqhvwewzzmqif", "hkghiyerph", "hkghiyejrph", "hlsioorugbsuu", "c", "kgierph", "bstbghj", "prbquqev", "mpfsdgimurs", "zfpjvu", "zfpvu", "yxuhwkzvoczfgoz", "gel", "ntvmcpzo", "ekofqduddkhykr", "ekofqdddhykr", "rqeql", "nhnympsum", "xhoqlfolk", "ipmtvxcwuje", "wgmhjhdmnqot", "bsh", "rvncfgelm", "hkahpbb", "lzlzqibfv", "xoqlfok", "tnoftfkogwgplx", "ekofqdddkhykr", "zwiieii", "ujfzzaw", "jfzw", "djsms", "scavdpilj", "tnoftfkoglx", "ps", "vwtnw", "scavhdpilj", "scayvhdpuilji", "pdrshqngzx", "crnrud", "wmhjhdmnqot", "wghmhjhdmnqot", "vbyipsawmxbp", "qknsapkhngorof", "wymthhfzndppwt", "wxcs", "dzvytccevney", "acacmy", "dycy", "teqyrllhbvcv", "uzwyxcs", "wmhjhdmnqt", "qvzkmgfulbyz", "qngglum", "zhhxgdyukcgelhy", "oj", "iljes", "bstbh", "laqcacxmy", "tofx", "ke", "yivkqoek", "djjjsulmrs", "lbirdzvttzze", "l", "zhhxgdukcgelhy", "grikvrnjwezryi", "bltz", "npynvlqll", "gvb", "okzrs", "urbarfkmnlxxn", "qsyzaixtzfazv", "dytcy", "h", "kohqyig", "hgri", "ojdxm", "ujfdfzzaw", "qyrhbvcv", "ebqhvwewzmqif", "uzwxcs", "lebzf", "ysijvkwqmoekromh", "wffaeemjnjahzdd", "crnrduyndj", "ujfdmfzzaw", "laqgcacyxmzgym", "jjourlrpgeem", "kvohqyediyig", "lebukzf", "zwiijeii", "guchrvb", "omoktkyf", "hpgt", "yikoek", "ysijvkwqoekromh", "tvpo", "ysijvkqoekromh", "xbgq", "d", "abmtk", "ors", "rnrd", "xzrugvlzduaxhzc", "njoxacjsnddwrg", "yipswmxbp", "xqsyzaixtzfazv", "urbrfknlxxn", "sxzfpjxvu", "prbaquxqemv", "dvjjjjsulmmrs", "kviahvqu", "urbfknx", "qvmgfulby", "yikqoek", "zsucxrqkhfahuomm", "koqyg", "djss", "moxpfsdgimlurs", "qeql", "urbrfknlxn", "kgieh", "qnspkhngorof", "plxyhib", "scyayvhdpuiljki", "vvhvmbflb", "lpzluhzqxibfv", "kkcbev", "hpzgty", "nyvlqll", "kvahvu", "rklgja", "ipmtavxcwuje", "lbirdzvvttzze", "psw", "fpasoiwhtu", "dgcdgjckk", "qknhsapkhngorof", "qszaixtzfazv", "tvp", "abmtvk", "uwrboghcy", "hbq", "crnruyd", "etjurltvsuy", "etjurltyvpsuy", "lenbukzf", "teqyrllhbvcvg", "ipmvwe", "o", "crnryduyndj", "lbirdzvvqfttzze", "tnoftfkowglx", "ipmtavxcwujre", "omlcoktkyf", "rnperyemtmqh", "bltnzk", "sxzfpzjxvu", "uzdwyaxvcstr", "bq", "rvvugpixa", "laqcacxmym", "wffeemjnjahzdd", "fpvu", "xjbpvekngeyaxbn", "dzvytccevncey", "qgly", "scavdl", "fw", "tox", "toftklx", "prbaoquxqemv", "ztrobzqiukdkcbv", "yivkqoekr", "feemjnjhzdd", "plxhi", "cp", "fyvpzgauttei", "prshqngzx", "kplxyrhib", "suwrboghcy", "kviahvu", "mvwe", "dzvytccvny", "hbqwq", "prbquqemv", "lzlhzqxibfv", "ll", "omblcoktkyf", "toftlx", "lpzlhzqxibfv", "tudegzbnz", "ddgcdgjcgkspk", "kgih", "xjbpvekneaxbn", "suwrboghccy", "zwiiijeii", "dytccy", "ympsum", "jxwakfxsifoj", "uwhcy", "yxuhwkzvoczfoz", "xzfpjvu", "lenybbukzft", "b", "llqfv", "laqgcacyxmgym", "xq", "scavdilj", "zwziivbijaeiig", "scyayvhdpuilji", "amvevfulhsd", "dss", "tlrlcnnrs", "uzwyaxcsr", "qspkhngorof", "etjurtvsuy", "wgqhmhjhhdmnqot", "tvmpo", "tnoftklx", "qgflby", "mlosifyg", "oqyg", "gchvb", "t", "offqcdllgj", "ziieii", "zwziivbijeii", "vp", "lpb", "fyvprzegauttejiv", "vtn", "amefulhsd", "llf", "muzdwyaxvcstr", "zucxqkahuo", "pfsgiurs", "obstbghj", "ipmqtavxcwuzjrbe", "djjsulms", "qvmgflby", "ljpzluhzqxibfv", "jjourlrzpgeem", "zrugvlduaxhzc", "xbpvkneaxn", "ljpzluhzgqyxibfv", "yivkqoekrh", "laqcacyxmym", "nyvll", "muzdwcyaxvcstr", "fyvpzegauttejiv", "offlgj", "vnfgelm", "eteiqyrllhbvcvg", "zsucxrqkhahuomm", "ibiltnzk", "rklgjae", "fpasoizwhtu", "t", "zhhxdukcgelhy", "fpasoiwu", "xzfpjxvu", "tlrlcnnrysrf", "ojx", "mpum", "lxh", "eturtvsuy", "rklgbjaae", "kahpbb", "qngglugmfvmp", "fielbqtcri", "xzruogvlzduaxhzc", "rshquwmrbtoghccy", "nyvlll", "lbirdzvvqttzze", "dgcdgjckspk", "vvhvmibfilb", "dzvytcccevncey", "g", "vwe", "zwxcs", "k", "jourlpgeem", "cpk", "cds", "tlrlcnnrsr", "ivemm", "fgel", "grktse", "urbfknlxn", "qwvzkmgfulbyz", "xjbpvekngeaxbn", "wphuutlgczfspyga", "xbq", "offqcdllgji", "vbyipsakwmxbp", "qyrhbvc", "ygzpztbno", "xhogqlfolk", "ujffzzaw", "xbnmgq", "uwohcy", "rnperyemqh", "prbqqev", "lenybukzf", "mxpfsdgimurs", "ga", "hpt", "moxpfsdgimurs", "vb", "offqcllgj", "rklgbjae", "lifg", "ztrobzzqiukdkcbv", "xoqok", "cs", "snaxxd", "cdds", "qknhsapkhngorohf", "rvqgeql", "rnperyemmqh", "scavhdpuilji", "urbfknlx", "rvvugixa", "ygzpztbndon", "zrugvlzduaxhzc", "shuwmrboghccy", "mlsifyg", "xhoqlfok", "wfeemjnjhzdd", "lbzf", "wythhfzndppwt", "mglqosifyg", "ojxm", "kvohuqyevdiyig", "grte", "prsngz", "eteeiqyrllhbvcvg", "dytccny", "qngglugfvmp", "kohqydig", "fu", "qgfly", "tvmcpzo", "tnoftfkowgplx", "zruglduaxzc", "yijvkqoekrh", "xqsyzaixtzfdazv", "ipmqtavxcwuzjre", "omloktkyf", "ympum", "lzlzqbfv", "pasowu", "rvqeql", "qngglugvmp", "hkghierph", "eemjhz", "feemnjhzdd", "c", "yxpuhwkzvoczfgoz", "dgcgjckk", "lbz", "yxuwkzvoczoz", "zrugvlduaxzc", "ntvmcwpzo", "fzw", "ygzpmztbndon", "rvncfgxelm", "mpm", "tudezgzbnz", "bltzk", "ffpasoiuzwhtu", "cd", "r", "okrs", "byipsawmxbp", "prsqngzx", "wnhnyqmpsum", "ipmqtavxcwujre", "w", "fpasoiwtu", "plxyrhib", "bstbhj", "xbnmrgq", "ipmtvcwe", "urbfkn", "nympsum", "qtngglugmfvmpt", "jckqurg", "hgr", "hpzgt", "rvvxudgpixa", "ysijvkqoekrh", "lebkzf", "guchvb", "kvohqyediyg", "amvefulhsd", "suwmrboghccy", "fvu", "ibdiltnzk", "rnrud", "iem", "urbarfknlxxn", "ygzpztbnon", "prsng", "zcxqkahuo", "ffpeasoiuztwhtu", "laqcacmy", "qszaitzfazv", "xbngq", "qvkmgfulby", "scavhdpuilj", "zsucxrqkahuo", "v", "qtngglugmfvmp", "ysijvkqoekrmh", "lfg", "prqqev", "pasoiwu", "p", "tvmcpo", "kcev", "im", "crnrduydj", "vfgelm", "ddgcdgjckspk", "ivqemm", "ljpzluhzgqxibfv", "lenybukzft", "nhnyqmpsum", "iljesr", "hp", "tqyrlhbvcv", "eemnjhzdd", "xbpvekneaxn", "wghmhjhhdmnqot", "uwboghcy", "guchrvabe", "xoqfok", "fyvpzgautteiv", "pg", "zwiivijeii", "qvgflby", "lsifg"}, + 16, + }, + + { + []string{"ksqvsyq", "ks", "kss", "czvh", "zczpzvdhx", "zczpzvh", "zczpzvhx", "zcpzvh", "zczvh", "gr", "grukmj", "ksqvsq", "gruj", "kssq", "ksqsq", "grukkmj", "grukj", "zczpzfvdhx", "gru"}, + 7, + }, + + { + []string{"a", "b", "ba", "bca", "bda", "bdca"}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_longestStrChain(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, longestStrChain(tc.words), "输入:%v", tc) + } +} + +func Benchmark_longestStrChain(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + longestStrChain(tc.words) + } + } +} diff --git a/Algorithms/1049.last-stone-weight-ii/README.md b/Algorithms/1049.last-stone-weight-ii/README.md new file mode 100755 index 000000000..3bd2d0fe2 --- /dev/null +++ b/Algorithms/1049.last-stone-weight-ii/README.md @@ -0,0 +1,27 @@ +# [1049. Last Stone Weight II](https://leetcode.com/problems/last-stone-weight-ii/) + +We have a collection of rocks, each rock has a positive integer weight. + +Each turn, we choose any two rocks and smash them together. Suppose the stones have weights x and y with x <= y. The result of this smash is: + +- If x == y, both stones are totally destroyed; +- If x != y, the stone of weight x is totally destroyed, and the stone of weight y has new weight y-x. + +At the end, there is at most 1 stone left. Return the smallest possible weight of this stone (the weight is 0 if there are no stones left.) + +Example 1: + +```text +Input: [2,7,4,1,8,1] +Output: 1 +Explanation: +We can combine 2 and 4 to get 2 so the array converts to [2,7,1,8,1] then, +we can combine 7 and 8 to get 1 so the array converts to [2,1,1,1] then, +we can combine 2 and 1 to get 1 so the array converts to [1,1,1] then, +we can combine 1 and 1 to get 0 so the array converts to [1] then that's the optimal value. +``` + +Note: + +1. `1 <= stones.length <= 30` +1. `1 <= stones[i] <= 100` diff --git a/Algorithms/1049.last-stone-weight-ii/last-stone-weight-ii.go b/Algorithms/1049.last-stone-weight-ii/last-stone-weight-ii.go new file mode 100755 index 000000000..483039d37 --- /dev/null +++ b/Algorithms/1049.last-stone-weight-ii/last-stone-weight-ii.go @@ -0,0 +1,25 @@ +package problem1049 + +func lastStoneWeightII(stones []int) int { + hasSum := [3001]bool{} + hasSum[0] = true + sum := 0 + for _, s := range stones { + sum += s + for i := sum; i >= s; i-- { + // record all sum of any choose form stones + hasSum[i] = hasSum[i] || hasSum[i-s] + } + } + // now, sum is sum(stones) + // take stones to two group,weights are part and sum-part + // result is sum-part - part + // best is part = sum/2 + // if not, check part-- + // until part = 0 + part := sum / 2 + for part >= 0 && !hasSum[part] { + part-- + } + return sum - part - part +} diff --git a/Algorithms/1049.last-stone-weight-ii/last-stone-weight-ii_test.go b/Algorithms/1049.last-stone-weight-ii/last-stone-weight-ii_test.go new file mode 100755 index 000000000..9c37fe778 --- /dev/null +++ b/Algorithms/1049.last-stone-weight-ii/last-stone-weight-ii_test.go @@ -0,0 +1,62 @@ +package problem1049 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + stones []int + ans int +}{ + + { + []int{3}, + 3, + }, + + { + []int{1, 2, 3}, + 0, + }, + + { + []int{31, 26, 33, 21, 40}, + 5, + }, + + { + []int{21, 16, 23, 32, 25, 13, 20, 18, 22, 21, 84, 35, 33, 17, 27, 24, 10, 19, 31, 26, 94, 37, 31, 25, 24, 25, 15, 23, 17, 13}, + 1, + }, + + { + []int{3, 2, 1, 7, 3, 7}, + 1, + }, + + { + []int{2, 7, 4, 1, 8, 1}, + 1, + }, + + // 可以有多个 testcase +} + +func Test_lastStoneWeightII(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, lastStoneWeightII(tc.stones), "输入:%v", tc) + } +} + +func Benchmark_lastStoneWeightII(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + lastStoneWeightII(tc.stones) + } + } +} diff --git a/Algorithms/1051.height-checker/README.md b/Algorithms/1051.height-checker/README.md new file mode 100755 index 000000000..363d1868f --- /dev/null +++ b/Algorithms/1051.height-checker/README.md @@ -0,0 +1,19 @@ +# [1051. Height Checker](https://leetcode.com/problems/height-checker/) + +Students are asked to stand in non-decreasing order of heights for an annual photo. + +Return the minimum number of students not standing in the right positions. (This is the number of students that must move in order for all students to be standing in non-decreasing order of height.) + +Example 1: + +```text +Input: [1,1,4,2,1,3] +Output: 3 +Explanation: +Students with heights 4, 3 and the last 1 are not standing in the right positions. +``` + +Note: + +- 1 <= heights.length <= 100 +- 1 <= heights[i] <= 100 diff --git a/Algorithms/1051.height-checker/height-checker.go b/Algorithms/1051.height-checker/height-checker.go new file mode 100755 index 000000000..56c05acdb --- /dev/null +++ b/Algorithms/1051.height-checker/height-checker.go @@ -0,0 +1,16 @@ +package problem1051 + +import "sort" + +func heightChecker(heights []int) int { + sorted := make([]int, len(heights)) + copy(sorted, heights) + sort.Ints(sorted) + res := 0 + for i := 0; i < len(heights); i++ { + if heights[i] != sorted[i] { + res++ + } + } + return res +} diff --git a/Algorithms/1051.height-checker/height-checker_test.go b/Algorithms/1051.height-checker/height-checker_test.go new file mode 100755 index 000000000..892a666ec --- /dev/null +++ b/Algorithms/1051.height-checker/height-checker_test.go @@ -0,0 +1,37 @@ +package problem1051 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + heights []int + ans int +}{ + + { + []int{1, 1, 4, 2, 1, 3}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_heightChecker(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, heightChecker(tc.heights), "输入:%v", tc) + } +} + +func Benchmark_heightChecker(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + heightChecker(tc.heights) + } + } +} diff --git a/Algorithms/1052.grumpy-bookstore-owner/README.md b/Algorithms/1052.grumpy-bookstore-owner/README.md new file mode 100755 index 000000000..d09dc22c7 --- /dev/null +++ b/Algorithms/1052.grumpy-bookstore-owner/README.md @@ -0,0 +1,24 @@ +# [1052. Grumpy Bookstore Owner](https://leetcode.com/problems/grumpy-bookstore-owner/) + +Today, the bookstore owner has a store open for customers.length minutes. Every minute, some number of customers (customers[i]) enter the store, and all those customers leave after the end of that minute. + +On some minutes, the bookstore owner is grumpy. If the bookstore owner is grumpy on the i-th minute, grumpy[i] = 1, otherwise grumpy[i] = 0. When the bookstore owner is grumpy, the customers of that minute are not satisfied, otherwise they are satisfied. + +The bookstore owner knows a secret technique to keep themselves not grumpy for X minutes straight, but can only use it once. + +Return the maximum number of customers that can be satisfied throughout the day. + +Example 1: + +```text +Input: customers = [1,0,1,2,1,1,7,5], grumpy = [0,1,0,1,0,1,0,1], X = 3 +Output: 16 +Explanation: The bookstore owner keeps themselves not grumpy for the last 3 minutes. +The maximum number of customers that can be satisfied = 1 + 1 + 1 + 1 + 7 + 5 = 16. +``` + +Note: + +- `1 <= X <= customers.length == grumpy.length <= 20000` +- `0 <= customers[i] <= 1000` +- `0 <= grumpy[i] <= 1` diff --git a/Algorithms/1052.grumpy-bookstore-owner/grumpy-bookstore-owner.go b/Algorithms/1052.grumpy-bookstore-owner/grumpy-bookstore-owner.go new file mode 100755 index 000000000..6e992ad52 --- /dev/null +++ b/Algorithms/1052.grumpy-bookstore-owner/grumpy-bookstore-owner.go @@ -0,0 +1,25 @@ +package problem1052 + +func maxSatisfied(customers []int, grumpy []int, X int) int { + n := len(customers) + satisfied, dis, maxDis := 0, 0, 0 + for i := 0; i < n; i++ { + satisfied += customers[i] * (1 - grumpy[i]) + dis += customers[i] * grumpy[i] + if i-X >= 0 { + // NOTICE: len(A[i-X+1:i+1]) = X + // for keeping dis's length is X + // subscrip A[i-X]*grumpy[i-X] + dis -= customers[i-X] * grumpy[i-X] + } + maxDis = max(maxDis, dis) + } + return satisfied + maxDis +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1052.grumpy-bookstore-owner/grumpy-bookstore-owner_test.go b/Algorithms/1052.grumpy-bookstore-owner/grumpy-bookstore-owner_test.go new file mode 100755 index 000000000..9d24a60df --- /dev/null +++ b/Algorithms/1052.grumpy-bookstore-owner/grumpy-bookstore-owner_test.go @@ -0,0 +1,41 @@ +package problem1052 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + customers []int + grumpy []int + X int + ans int +}{ + + { + []int{1, 0, 1, 2, 1, 1, 7, 5}, + []int{0, 1, 0, 1, 0, 1, 0, 1}, + 3, + 16, + }, + + // 可以有多个 testcase +} + +func Test_maxSatisfied(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxSatisfied(tc.customers, tc.grumpy, tc.X), "输入:%v", tc) + } +} + +func Benchmark_maxSatisfied(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxSatisfied(tc.customers, tc.grumpy, tc.X) + } + } +} diff --git a/Algorithms/1053.previous-permutation-with-one-swap/README.md b/Algorithms/1053.previous-permutation-with-one-swap/README.md new file mode 100755 index 000000000..cd64303ab --- /dev/null +++ b/Algorithms/1053.previous-permutation-with-one-swap/README.md @@ -0,0 +1,40 @@ +# [1053. Previous Permutation With One Swap](https://leetcode.com/problems/previous-permutation-with-one-swap/) + +Given an array A of positive integers (not necessarily distinct), return the lexicographically largest permutation that is smaller than A, that can be made with one swap (A swap exchanges the positions of two numbers A[i] and A[j]). If it cannot be done, then return the same array. + +Example 1: + +```text +Input: [3,2,1] +Output: [3,1,2] +Explanation: Swapping 2 and 1. +``` + +Example 2: + +```text +Input: [1,1,5] +Output: [1,1,5] +Explanation: This is already the smallest permutation. +``` + +Example 3: + +```text +Input: [1,9,4,6,7] +Output: [1,7,4,6,9] +Explanation: Swapping 9 and 7. +``` + +Example 4: + +```text +Input: [3,1,1,3] +Output: [1,3,1,3] +Explanation: Swapping 1 and 3. +``` + +Note: + +1. `1 <= A.length <= 10000` +1. `1 <= A[i] <= 10000` diff --git a/Algorithms/1053.previous-permutation-with-one-swap/previous-permutation-with-one-swap.go b/Algorithms/1053.previous-permutation-with-one-swap/previous-permutation-with-one-swap.go new file mode 100755 index 000000000..342701569 --- /dev/null +++ b/Algorithms/1053.previous-permutation-with-one-swap/previous-permutation-with-one-swap.go @@ -0,0 +1,25 @@ +package problem1053 + +func prevPermOpt1(A []int) []int { + n := len(A) + stack, top := make([]int, n), 0 + stack[top] = n - 1 + + for i := n - 2; i >= 0; i-- { + if A[i] <= A[stack[top]] { + top++ + stack[top] = i + continue + } + for top-1 >= 0 && + A[stack[top]] < A[stack[top-1]] && + A[stack[top-1]] < A[i] { + top-- + } + j := stack[top] + A[i], A[j] = A[j], A[i] + break + } + + return A +} diff --git a/Algorithms/1053.previous-permutation-with-one-swap/previous-permutation-with-one-swap_test.go b/Algorithms/1053.previous-permutation-with-one-swap/previous-permutation-with-one-swap_test.go new file mode 100755 index 000000000..1dc57a474 --- /dev/null +++ b/Algorithms/1053.previous-permutation-with-one-swap/previous-permutation-with-one-swap_test.go @@ -0,0 +1,57 @@ +package problem1053 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans []int +}{ + + { + []int{1, 1, 5}, + []int{1, 1, 5}, + }, + + { + []int{2, 1, 1}, + []int{1, 2, 1}, + }, + + { + []int{3, 2, 1}, + []int{3, 1, 2}, + }, + + { + []int{1, 9, 4, 6, 7}, + []int{1, 7, 4, 6, 9}, + }, + + { + []int{3, 1, 1, 3}, + []int{1, 3, 1, 3}, + }, + + // 可以有多个 testcase +} + +func Test_prevPermOpt1(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, prevPermOpt1(tc.A), "输入:%v", tc) + } +} + +func Benchmark_prevPermOpt1(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + prevPermOpt1(tc.A) + } + } +} diff --git a/Algorithms/1054.distant-barcodes/README.md b/Algorithms/1054.distant-barcodes/README.md new file mode 100755 index 000000000..38c5510bb --- /dev/null +++ b/Algorithms/1054.distant-barcodes/README.md @@ -0,0 +1,24 @@ +# [1054. Distant Barcodes](https://leetcode.com/problems/distant-barcodes/) + +In a warehouse, there is a row of barcodes, where the i-th barcode is barcodes[i]. + +Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists. + +Example 1: + +```text +Input: [1,1,1,2,2,2] +Output: [2,1,2,1,2,1] +``` + +Example 2: + +```text +Input: [1,1,1,1,2,2,3,3] +Output: [1,3,1,3,2,1,2,1] +``` + +Note: + +1. `1 <= barcodes.length <= 10000` +1. `1 <= barcodes[i] <= 10000` diff --git a/Algorithms/1054.distant-barcodes/distant-barcodes.go b/Algorithms/1054.distant-barcodes/distant-barcodes.go new file mode 100755 index 000000000..d976f23f7 --- /dev/null +++ b/Algorithms/1054.distant-barcodes/distant-barcodes.go @@ -0,0 +1,31 @@ +package problem1054 + +import "sort" + +func rearrangeBarcodes(A []int) []int { + n := len(A) + + count := [10001]int{} + for _, a := range A { + count[a]++ + } + + sort.Slice(A, func(i int, j int) bool { + if count[A[i]] == count[A[j]] { + return A[i] < A[j] + } + return count[A[i]] > count[A[j]] + }) + + res := make([]int, n) + i := 0 + for _, a := range A { + res[i] = a + i += 2 + if i >= n { + i = 1 + } + } + + return res +} diff --git a/Algorithms/1054.distant-barcodes/distant-barcodes_test.go b/Algorithms/1054.distant-barcodes/distant-barcodes_test.go new file mode 100755 index 000000000..50d0f7756 --- /dev/null +++ b/Algorithms/1054.distant-barcodes/distant-barcodes_test.go @@ -0,0 +1,59 @@ +package problem1054 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + barcodes []int +}{ + + { + []int{7, 7, 7, 8, 5, 7, 5, 5, 5, 8}, + }, + + { + []int{2, 2, 1, 3}, + }, + + { + []int{2, 1, 1}, + }, + + { + []int{1, 1, 1, 2, 2, 2}, + }, + + { + []int{1, 1, 1, 1, 2, 2, 3, 3}, + }, + + // 可以有多个 testcase +} + +func isDiff(A []int) bool { + for i := 1; i < len(A); i++ { + if A[i-1] == A[i] { + return false + } + } + return true +} + +func Test_rearrangeBarcodes(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + ast.True(isDiff(rearrangeBarcodes(tc.barcodes)), "输入:%v", tc) + } +} + +func Benchmark_rearrangeBarcodes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + rearrangeBarcodes(tc.barcodes) + } + } +} diff --git a/Algorithms/1071.greatest-common-divisor-of-strings/README.md b/Algorithms/1071.greatest-common-divisor-of-strings/README.md new file mode 100755 index 000000000..c66ca16a5 --- /dev/null +++ b/Algorithms/1071.greatest-common-divisor-of-strings/README.md @@ -0,0 +1,32 @@ +# [1071. Greatest Common Divisor of Strings](https://leetcode.com/problems/greatest-common-divisor-of-strings/) + +For strings S and T, we say "T divides S" if and only if S = T + ... + T (T concatenated with itself 1 or more times) + +Return the largest string X such that X divides str1 and X divides str2. + +Example 1: + +```text +Input: str1 = "ABCABC", str2 = "ABC" +Output: "ABC" +``` + +Example 2: + +```text +Input: str1 = "ABABAB", str2 = "ABAB" +Output: "AB" +``` + +Example 3: + +```text +Input: str1 = "LEET", str2 = "CODE" +Output: "" +``` + +Note: + +1. `1 <= str1.length <= 1000` +1. `1 <= str2.length <= 1000` +1. `str1[i] and str2[i] are English uppercase letters.` diff --git a/Algorithms/1071.greatest-common-divisor-of-strings/greatest-common-divisor-of-strings.go b/Algorithms/1071.greatest-common-divisor-of-strings/greatest-common-divisor-of-strings.go new file mode 100755 index 000000000..99929972b --- /dev/null +++ b/Algorithms/1071.greatest-common-divisor-of-strings/greatest-common-divisor-of-strings.go @@ -0,0 +1,36 @@ +package problem1071 + +import "strings" + +func gcdOfStrings(s1, s2 string) string { + l1, l2 := len(s1), len(s2) + d := gcd(max(l1, l2), min(l1, l2)) + p := s2[:d] + if s1 == strings.Repeat(p, l1/d) && + s2 == strings.Repeat(p, l2/d) { + return p + } + return "" +} + +// a >= b +func gcd(a, b int) int { + if b == 0 { + return a + } + return gcd(b, a%b) +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1071.greatest-common-divisor-of-strings/greatest-common-divisor-of-strings_test.go b/Algorithms/1071.greatest-common-divisor-of-strings/greatest-common-divisor-of-strings_test.go new file mode 100755 index 000000000..5282b94be --- /dev/null +++ b/Algorithms/1071.greatest-common-divisor-of-strings/greatest-common-divisor-of-strings_test.go @@ -0,0 +1,75 @@ +package problem1071 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + str1 string + str2 string + ans string +}{ + + { + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", + }, + + { + "AAAABBB", + "AAAAAAAAAAB", + "", + }, + + { + "AAAAAAA", + "AAAAAAAAAAA", + "A", + }, + + { + "NLZGMNLZGMNLZGMNLZGMNLZGMNLZGMNLZGMNLZGM", + "NLZGMNLZGMNLZGMNLZGMNLZGMNLZGMNLZGMNLZGMNLZGM", + "NLZGM", + }, + + { + "ABCABC", + "ABC", + "ABC", + }, + + { + "ABABAB", + "ABAB", + "AB", + }, + + { + "LEET", + "CODE", + "", + }, + + // 可以有多个 testcase +} + +func Test_gcdOfStrings(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, gcdOfStrings(tc.str1, tc.str2), "输入:%v", tc) + } +} + +func Benchmark_gcdOfStrings(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + gcdOfStrings(tc.str1, tc.str2) + } + } +} diff --git a/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/README.md b/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/README.md new file mode 100755 index 000000000..264b55433 --- /dev/null +++ b/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/README.md @@ -0,0 +1,36 @@ +# [1072. Flip Columns For Maximum Number of Equal Rows](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows/) + +Given a matrix consisting of 0s and 1s, we may choose any number of columns in the matrix and flip every cell in that column. Flipping a cell changes the value of that cell from 0 to 1 or from 1 to 0. + +Return the maximum number of rows that have all values equal after some number of flips. + +Example 1: + +```text +Input: [[0,1],[1,1]] +Output: 1 +Explanation: After flipping no values, 1 row has all values equal. +``` + +Example 2: + +```text +Input: [[0,1],[1,0]] +Output: 2 +Explanation: After flipping values in the first column, both rows have equal values. +``` + +Example 3: + +```text +Input: [[0,0,0],[0,0,1],[1,1,0]] +Output: 2 +Explanation: After flipping values in the first two columns, the last two rows have equal values. +``` + +Note: + +1. `1 <= matrix.length <= 300` +1. `1 <= matrix[i].length <= 300` +1. `All matrix[i].length's are equal` +1. `matrix[i][j] is 0 or 1` diff --git a/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/flip-columns-for-maximum-number-of-equal-rows.go b/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/flip-columns-for-maximum-number-of-equal-rows.go new file mode 100755 index 000000000..b20c67935 --- /dev/null +++ b/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/flip-columns-for-maximum-number-of-equal-rows.go @@ -0,0 +1,31 @@ +package problem1072 + +import "strings" + +func maxEqualRowsAfterFlips(A [][]int) int { + count := make(map[string]int, 300) + var sb strings.Builder + for _, r := range A { + r0 := r[0] + for _, x := range r { + sb.WriteByte(byte(x ^ r0 + '0')) + } + count[sb.String()]++ + sb.Reset() + } + + res := 0 + + for _, c := range count { + res = max(res, c) + } + + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/flip-columns-for-maximum-number-of-equal-rows_test.go b/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/flip-columns-for-maximum-number-of-equal-rows_test.go new file mode 100755 index 000000000..f6ec2d24d --- /dev/null +++ b/Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows/flip-columns-for-maximum-number-of-equal-rows_test.go @@ -0,0 +1,100 @@ +package problem1072 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + matrix [][]int + ans int +}{ + + { + [][]int{{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, + 1, + }, + + { + [][]int{{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, + 1, + }, + + { + [][]int{{0, 1}, {1, 1}}, + 1, + }, + + { + [][]int{{0, 1}, {1, 0}}, + 2, + }, + + { + [][]int{{0, 0, 1}, {1, 1, 0}, {0, 0, 0}}, + 2, + }, + + { + [][]int{{0, 0, 0}, {0, 0, 1}, {1, 1, 0}}, + 2, + }, + + // 可以有多个 testcase +} + +func Test_maxEqualRowsAfterFlips(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxEqualRowsAfterFlips(tc.matrix), "输入:%v", tc) + } +} + +func Benchmark_maxEqualRowsAfterFlips(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxEqualRowsAfterFlips(tc.matrix) + } + } +} + +func Test_max(t *testing.T) { + type args struct { + a int + b int + } + tests := []struct { + name string + args args + want int + }{ + { + "a is bigger", + args{ + a: 1, + b: 0, + }, + 1, + }, + { + "b is bigger", + args{ + a: 1, + b: 2, + }, + 2, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := max(tt.args.a, tt.args.b); got != tt.want { + t.Errorf("max() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/Algorithms/1073.adding-two-negabinary-numbers/README.md b/Algorithms/1073.adding-two-negabinary-numbers/README.md new file mode 100755 index 000000000..48a121344 --- /dev/null +++ b/Algorithms/1073.adding-two-negabinary-numbers/README.md @@ -0,0 +1,23 @@ +# [1073. Adding Two Negabinary Numbers](https://leetcode.com/problems/adding-two-negabinary-numbers/) + +Given two numbers arr1 and arr2 in base -2, return the result of adding them together. + +Each number is given in array format: as an array of 0s and 1s, from most significant bit to least significant bit. For example, arr = [1,1,0,1] represents the number (-2)^3 + (-2)^2 + (-2)^0 = -3. A number arr in array format is also guaranteed to have no leading zeros: either arr == [0] or arr[0] == 1. + +Return the result of adding arr1 and arr2 in the same format: as an array of 0s and 1s with no leading zeros. + +Example 1: + +```text +Input: arr1 = [1,1,1,1,1], arr2 = [1,0,1] +Output: [1,0,0,0,0] +Explanation: arr1 represents 11, arr2 represents 5, the output represents 16. +``` + +Note: + +1. `1 <= arr1.length <= 1000` +1. `1 <= arr2.length <= 1000` +1. `arr1 and arr2 have no leading zeros` +1. `arr1[i] is 0 or 1` +1. `arr2[i] is 0 or 1` diff --git a/Algorithms/1073.adding-two-negabinary-numbers/adding-two-negabinary-numbers.go b/Algorithms/1073.adding-two-negabinary-numbers/adding-two-negabinary-numbers.go new file mode 100755 index 000000000..de035c93e --- /dev/null +++ b/Algorithms/1073.adding-two-negabinary-numbers/adding-two-negabinary-numbers.go @@ -0,0 +1,38 @@ +package problem1073 + +func addNegabinary(A, B []int) []int { + i, j := len(A)-1, len(B)-1 + res := make([]int, 0, i+j) + carry := 0 + for i >= 0 || j >= 0 || carry != 0 { + if i >= 0 { + carry += A[i] + i-- + } + if j >= 0 { + carry += B[j] + j-- + } + res = append(res, carry&1) + carry = -(carry >> 1) + } + + res = reverse(res) + + // cut leading zero + i, end := 0, len(res)-1 + for i < end && res[i] == 0 { + i++ + } + return res[i:] +} + +func reverse(A []int) []int { + i, j := 0, len(A)-1 + for i < j { + A[i], A[j] = A[j], A[i] + i++ + j-- + } + return A +} diff --git a/Algorithms/1073.adding-two-negabinary-numbers/adding-two-negabinary-numbers_test.go b/Algorithms/1073.adding-two-negabinary-numbers/adding-two-negabinary-numbers_test.go new file mode 100755 index 000000000..287ec39c9 --- /dev/null +++ b/Algorithms/1073.adding-two-negabinary-numbers/adding-two-negabinary-numbers_test.go @@ -0,0 +1,57 @@ +package problem1073 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + arr1 []int + arr2 []int + ans []int +}{ + + { + []int{1, 0, 0, 0, 0, 0, 0, 0}, + []int{1, 1, 0, 0, 0, 0, 0, 0, 0}, + []int{0}, + }, + + { + []int{1}, + []int{1, 1}, + []int{0}, + }, + + { + []int{1, 1, 1, 0, 1}, + []int{1, 0, 1}, + []int{1, 0, 1, 1, 0}, + }, + + { + []int{1, 1, 1, 1, 1}, + []int{1, 0, 1}, + []int{1, 0, 0, 0, 0}, + }, + + // 可以有多个 testcase +} + +func Test_addNegabinary(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, addNegabinary(tc.arr1, tc.arr2), "输入:%v", tc) + } +} + +func Benchmark_addNegabinary(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + addNegabinary(tc.arr1, tc.arr2) + } + } +} diff --git a/Algorithms/1074.number-of-submatrices-that-sum-to-target/README.md b/Algorithms/1074.number-of-submatrices-that-sum-to-target/README.md new file mode 100755 index 000000000..e71735ea3 --- /dev/null +++ b/Algorithms/1074.number-of-submatrices-that-sum-to-target/README.md @@ -0,0 +1,30 @@ +# [1074. Number of Submatrices That Sum to Target](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/) + +Given a matrix, and a target, return the number of non-empty submatrices that sum to target. + +A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2. + +Two submatrices (x1, y1, x2, y2) and (x1', y1', x2', y2') are different if they have some coordinate that is different: for example, if x1 != x1'. + +Example 1: + +```text +Input: matrix = [[0,1,0],[1,1,1],[0,1,0]], target = 0 +Output: 4 +Explanation: The four 1x1 submatrices that only contain 0. +``` + +Example 2: + +```text +Input: matrix = [[1,-1],[-1,1]], target = 0 +Output: 5 +Explanation: The two 1x2 submatrices, plus the two 2x1 submatrices, plus the 2x2 submatrix. +``` + +Note: + +1. `1 <= matrix.length <= 300` +1. `1 <= matrix[0].length <= 300` +1. `-1000 <= matrix[i] <= 1000` +1. `-10^8 <= target <= 10^8` diff --git a/Algorithms/1074.number-of-submatrices-that-sum-to-target/number-of-submatrices-that-sum-to-target.go b/Algorithms/1074.number-of-submatrices-that-sum-to-target/number-of-submatrices-that-sum-to-target.go new file mode 100755 index 000000000..052ca2755 --- /dev/null +++ b/Algorithms/1074.number-of-submatrices-that-sum-to-target/number-of-submatrices-that-sum-to-target.go @@ -0,0 +1,28 @@ +package problem1074 + +func numSubmatrixSumTarget(M [][]int, target int) int { + m, n := len(M), len(M[0]) + + S := [301][301]int{} + for i := 1; i <= m; i++ { + for j := 1; j <= n; j++ { + S[i][j] = S[i][j-1] + M[i-1][j-1] + } + } + + res := 0 + + for y1 := 0; y1 < n; y1++ { + for y2 := y1 + 1; y2 <= n; y2++ { + count := make(map[int]int, m) + sum := 0 + for x := 0; x <= m; x++ { + sum += S[x][y2] - S[x][y1] + res += count[sum-target] + count[sum]++ + } + } + } + + return res +} diff --git a/Algorithms/1074.number-of-submatrices-that-sum-to-target/number-of-submatrices-that-sum-to-target_test.go b/Algorithms/1074.number-of-submatrices-that-sum-to-target/number-of-submatrices-that-sum-to-target_test.go new file mode 100755 index 000000000..8635285d7 --- /dev/null +++ b/Algorithms/1074.number-of-submatrices-that-sum-to-target/number-of-submatrices-that-sum-to-target_test.go @@ -0,0 +1,152 @@ +package problem1074 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + matrix [][]int + target int + ans int +}{ + + { + [][]int{ + {1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0}, + {0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1}, + {0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1}, + {1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1}, + {1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1}, + {1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1}, + {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0}, + {1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0}, + {1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, + {0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0}, + {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1}, + {0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0}, + {1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0}, + {0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1}, + {1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1}, + {1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0}, + {0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1}, + {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1}, + {1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0}, + {0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0}, + {0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1}, + {1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0}, + {1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1}, + {1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0}, + {1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0}, + {0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0}, + {0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0}, + {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1}, + {1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0}, + {0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1}, + {0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0}, + {0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0}, + {1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1}, + {0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, + {1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0}, + {0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1}, + {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0}, + {1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0}, + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0}, + {1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1}, + {0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0}, + {1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0}, + {1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1}, + {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1}, + {1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0}, + {0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0}, + {1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0}, + {0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1}, + {1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0}, + {0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0}, + {1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1}, + {1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0}, + {1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0}, + {0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1}, + {0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1}, + {1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1}, + {1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1}, + {0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0}, + {1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1}, + {0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0}, + {1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0}, + {0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1}, + {0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1}, + {1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0}, + {0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1}, + {0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}, + {1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0}, + {0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1}, + {1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1}, + {0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1}, + {1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0}, + {1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0}, + {0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1}, + {1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1}, + {0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0}, + {1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0}, + {1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1}, + {0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0}, + {0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1}, + {1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1}, + {0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0}, + {0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1}, + {1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1}, + {1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0}, + {1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1}, + {1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0}, + {0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1}, + {1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0}, + {1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0}, + {0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1}, + {0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1}, + {1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0}, + {1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0}, + {1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0}, + {0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1}, + {0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0}, + {1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0}, + {1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1}, + }, + 0, + 15691, + }, + + { + [][]int{{1, -1}, {-1, 1}}, + 0, + 5, + }, + + { + [][]int{{0, 1, 0}, {1, 1, 1}, {0, 1, 0}}, + 0, + 4, + }, + + // 可以有多个 testcase +} + +func Test_numSubmatrixSumTarget(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numSubmatrixSumTarget(tc.matrix, tc.target), "输入:%v", tc) + } +} + +func Benchmark_numSubmatrixSumTarget(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numSubmatrixSumTarget(tc.matrix, tc.target) + } + } +} diff --git a/Algorithms/1078.occurrences-after-bigram/README.md b/Algorithms/1078.occurrences-after-bigram/README.md new file mode 100755 index 000000000..6049b7b03 --- /dev/null +++ b/Algorithms/1078.occurrences-after-bigram/README.md @@ -0,0 +1,26 @@ +# [1078. Occurrences After Bigram](https://leetcode.com/problems/occurrences-after-bigram/) + +Given words first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately after second. + +For each such occurrence, add "third" to the answer, and return the answer. + +Example 1: + +```text +Input: text = "alice is a good girl she is a good student", first = "a", second = "good" +Output: ["girl","student"] +``` + +Example 2: + +```text +Input: text = "we will we will rock you", first = "we", second = "will" +Output: ["we","rock"] +``` + +Note: + +1. `1 <= text.length <= 1000` +1. `text consists of space separated words, where each word consists of lowercase English letters.` +1. `1 <= first.length, second.length <= 10` +1. `first and second consist of lowercase English letters.` diff --git a/Algorithms/1078.occurrences-after-bigram/occurrences-after-bigram.go b/Algorithms/1078.occurrences-after-bigram/occurrences-after-bigram.go new file mode 100755 index 000000000..8267aff9e --- /dev/null +++ b/Algorithms/1078.occurrences-after-bigram/occurrences-after-bigram.go @@ -0,0 +1,16 @@ +package problem1078 + +import "strings" + +func findOcurrences(text string, first string, second string) []string { + words := strings.Split(text, " ") + n := len(words) + res := make([]string, 0, n) + for i := 0; i+2 < n; i++ { + if words[i] == first && + words[i+1] == second { + res = append(res, words[i+2]) + } + } + return res +} diff --git a/Algorithms/1078.occurrences-after-bigram/occurrences-after-bigram_test.go b/Algorithms/1078.occurrences-after-bigram/occurrences-after-bigram_test.go new file mode 100755 index 000000000..a1fed2b4e --- /dev/null +++ b/Algorithms/1078.occurrences-after-bigram/occurrences-after-bigram_test.go @@ -0,0 +1,48 @@ +package problem1078 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + text string + first string + second string + ans []string +}{ + + { + "alice is a good girl she is a good student", + "a", + "good", + []string{"girl", "student"}, + }, + + { + "we will we will rock you", + "we", + "will", + []string{"we", "rock"}, + }, + + // 可以有多个 testcase +} + +func Test_findOcurrences(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, findOcurrences(tc.text, tc.first, tc.second), "输入:%v", tc) + } +} + +func Benchmark_findOcurrences(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + findOcurrences(tc.text, tc.first, tc.second) + } + } +} diff --git a/Algorithms/1079.letter-tile-possibilities/README.md b/Algorithms/1079.letter-tile-possibilities/README.md new file mode 100755 index 000000000..4628920ad --- /dev/null +++ b/Algorithms/1079.letter-tile-possibilities/README.md @@ -0,0 +1,23 @@ +# [1079. Letter Tile Possibilities](https://leetcode.com/problems/letter-tile-possibilities/) + +You have a set of tiles, where each tile has one letter tiles[i] printed on it. Return the number of possible non-empty sequences of letters you can make. + +Example 1: + +```text +Input: "AAB" +Output: 8 +Explanation: The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA". +``` + +Example 2: + +```text +Input: "AAABBC" +Output: 188 +``` + +Note: + +1. `1 <= tiles.length <= 7` +1. `tiles consists of uppercase English letters.` diff --git a/Algorithms/1079.letter-tile-possibilities/letter-tile-possibilities.go b/Algorithms/1079.letter-tile-possibilities/letter-tile-possibilities.go new file mode 100755 index 000000000..d7d0d96ab --- /dev/null +++ b/Algorithms/1079.letter-tile-possibilities/letter-tile-possibilities.go @@ -0,0 +1,25 @@ +package problem1079 + +func numTilePossibilities(tiles string) int { + count := [26]int{} + for _, t := range tiles { + count[t-'A']++ + } + + var dfs func() int + dfs = func() int { + sum := 0 + for i := 0; i < 26; i++ { + if count[i] == 0 { + continue + } + sum++ + count[i]-- + sum += dfs() + count[i]++ + } + return sum + } + + return dfs() +} diff --git a/Algorithms/1079.letter-tile-possibilities/letter-tile-possibilities_test.go b/Algorithms/1079.letter-tile-possibilities/letter-tile-possibilities_test.go new file mode 100755 index 000000000..20c1528fb --- /dev/null +++ b/Algorithms/1079.letter-tile-possibilities/letter-tile-possibilities_test.go @@ -0,0 +1,46 @@ +package problem1079 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + tiles string + ans int +}{ + + { + "ABCDEFG", + 13699, + }, + { + "AAB", + 8, + }, + + { + "AAABBC", + 188, + }, + + // 可以有多个 testcase +} + +func Test_numTilePossibilities(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numTilePossibilities(tc.tiles), "输入:%v", tc) + } +} + +func Benchmark_numTilePossibilities(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numTilePossibilities(tc.tiles) + } + } +} diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/1.input.png b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/1.input.png new file mode 100644 index 000000000..b2c4ad0c4 Binary files /dev/null and b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/1.input.png differ diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/1.output.png b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/1.output.png new file mode 100644 index 000000000..ec06a936b Binary files /dev/null and b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/1.output.png differ diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/2.input.png b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/2.input.png new file mode 100644 index 000000000..b6728d985 Binary files /dev/null and b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/2.input.png differ diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/2.output.png b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/2.output.png new file mode 100644 index 000000000..22afb59a2 Binary files /dev/null and b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/2.output.png differ diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/3.input.png b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/3.input.png new file mode 100644 index 000000000..21953a544 Binary files /dev/null and b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/3.input.png differ diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/3.output.png b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/3.output.png new file mode 100644 index 000000000..f504e9bac Binary files /dev/null and b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/3.output.png differ diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/README.md b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/README.md new file mode 100755 index 000000000..6fdf0ae09 --- /dev/null +++ b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/README.md @@ -0,0 +1,46 @@ +# [1080. Insufficient Nodes in Root to Leaf Paths](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths/) + +Given the root of a binary tree, consider all root to leaf paths: paths from the root to any leaf. (A leaf is a node with no children.) + +A node is insufficient if every such root to leaf path intersecting this node has sum strictly less than limit. + +Delete all insufficient nodes simultaneously, and return the root of the resulting binary tree. + +Example 1: + +![1.input](1.input.png) + +![1.output](1.output.png) + +```text +Input: root = [1,2,3,4,-99,-99,7,8,9,-99,-99,12,13,-99,14], limit = 1 +Output: [1,2,3,4,null,null,7,8,9,null,14] +``` + +Example 2: + +![2.input](2.input.png) + +![2.output](2.output.png) + +```text +Input: root = [5,4,8,11,null,17,4,7,1,null,null,5,3], limit = 22 +Output: [5,4,8,11,null,17,4,7,null,null,null,5] +``` + +Example 3: + +![3.input](3.input.png) + +![3.output](3.output.png) + +```text +Input: root = [1,2,-3,-5,null,4,null], limit = -1 +Output: [1,null,-3,4] +``` + +Note: + +1. `The given tree will have between 1 and 5000 nodes.` +1. `-10^5 <= node.val <= 10^5` +1. `-10^9 <= limit <= 10^9` diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/insufficient-nodes-in-root-to-leaf-paths.go b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/insufficient-nodes-in-root-to-leaf-paths.go new file mode 100755 index 000000000..24d7b63f9 --- /dev/null +++ b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/insufficient-nodes-in-root-to-leaf-paths.go @@ -0,0 +1,32 @@ +package problem1080 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined... +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func sufficientSubset(root *TreeNode, limit int) *TreeNode { + if root == nil { + return nil + } + if root.Left == root.Right { // both nil + if root.Val < limit { + return nil + } + return root + } + limit -= root.Val + root.Left = sufficientSubset(root.Left, limit) + root.Right = sufficientSubset(root.Right, limit) + if root.Left == root.Right { // both nil + return nil + } + return root +} diff --git a/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/insufficient-nodes-in-root-to-leaf-paths_test.go b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/insufficient-nodes-in-root-to-leaf-paths_test.go new file mode 100755 index 000000000..500d7e446 --- /dev/null +++ b/Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths/insufficient-nodes-in-root-to-leaf-paths_test.go @@ -0,0 +1,60 @@ +package problem1080 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + limit int + ans []int +}{ + + { + []int{1, 2, -3, -5, kit.NULL, 4, kit.NULL}, + -1, + []int{1, kit.NULL, -3, 4}, + }, + + { + []int{1, 2, 3, 4, -99, -99, 7, 8, 9, -99, -99, 12, 13, -99, 14}, + 1, + []int{1, 2, 3, 4, kit.NULL, kit.NULL, 7, 8, 9, kit.NULL, 14}, + }, + + { + []int{5, 4, 8, 11, kit.NULL, 17, 4, 7, 1, kit.NULL, kit.NULL, 5, 3}, + 22, + []int{5, 4, 8, 11, kit.NULL, 17, 4, 7, kit.NULL, kit.NULL, kit.NULL, 5}, + }, + + { + []int{1, 2, -3, -5, kit.NULL, 4, kit.NULL}, + 100, + []int{}, + }, + + // 可以有多个 testcase +} + +func Test_sufficientSubset(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, kit.Tree2ints(sufficientSubset(root, tc.limit)), "输入:%v", tc) + } +} + +func Benchmark_sufficientSubset(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + sufficientSubset(root, tc.limit) + } + } +} diff --git a/Algorithms/1081.smallest-subsequence-of-distinct-characters/README.md b/Algorithms/1081.smallest-subsequence-of-distinct-characters/README.md new file mode 100755 index 000000000..8b5bfebe9 --- /dev/null +++ b/Algorithms/1081.smallest-subsequence-of-distinct-characters/README.md @@ -0,0 +1,36 @@ +# [1081. Smallest Subsequence of Distinct Characters](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/) + +Return the lexicographically smallest subsequence of text that contains all the distinct characters of text exactly once. + +Example 1: + +```text +Input: "cdadabcc" +Output: "adbc" +``` + +Example 2: + +```text +Input: "abcd" +Output: "abcd" +``` + +Example 3: + +```text +Input: "ecbacba" +Output: "eacb" +``` + +Example 4: + +```text +Input: "leetcode" +Output: "letcod" +``` + +Note: + +1. `1 <= text.length <= 1000` +1. `text consists of lowercase English letters.` diff --git a/Algorithms/1081.smallest-subsequence-of-distinct-characters/smallest-subsequence-of-distinct-characters.go b/Algorithms/1081.smallest-subsequence-of-distinct-characters/smallest-subsequence-of-distinct-characters.go new file mode 100755 index 000000000..6be566f4b --- /dev/null +++ b/Algorithms/1081.smallest-subsequence-of-distinct-characters/smallest-subsequence-of-distinct-characters.go @@ -0,0 +1,39 @@ +package problem1081 + +import "strings" + +func smallestSubsequence(S string) string { + n := len(S) + + last := [26]int{} + for i, c := range S { + last[c-'a'] = i + } + + stack, top := make([]int, n), -1 + hasSeen := [26]bool{} + for i := 0; i < n; i++ { + c := int(S[i] - 'a') + if hasSeen[c] { + continue + } + for top >= 0 && + stack[top] > c && + i < last[stack[top]] { + pop := stack[top] + top-- + hasSeen[pop] = false + } + top++ + stack[top] = c + hasSeen[c] = true + } + + var sb strings.Builder + for i := 0; i <= top; i++ { + b := byte(stack[i] + 'a') + sb.WriteByte(b) + } + + return sb.String() +} diff --git a/Algorithms/1081.smallest-subsequence-of-distinct-characters/smallest-subsequence-of-distinct-characters_test.go b/Algorithms/1081.smallest-subsequence-of-distinct-characters/smallest-subsequence-of-distinct-characters_test.go new file mode 100755 index 000000000..a2ab7af1f --- /dev/null +++ b/Algorithms/1081.smallest-subsequence-of-distinct-characters/smallest-subsequence-of-distinct-characters_test.go @@ -0,0 +1,57 @@ +package problem1081 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + text string + ans string +}{ + + { + "fduxqmmeghmsrohvpclyjmhwwxipnvqxhfmgtqtcutsbjhbmuollkwocxxdmoswsnksdflwbxetsvbuvlwtxonpyhyrodjmdbvoopfxinkojyugqegbprgqxjpghojhymsoqpylrmelsonpqrtjmjgbgmmpqklfiiaacgurrbqtbqyylfqiefbrfyotiptqujknegwjiyqybldgomccdbiikfsfnqwcilblilfwcxyytnvdrppmcslildixlungoetlqvpvpwgmhqvwwjmllomtipfavbhbahclcfdyvgyqhpxebmtovgxqtjwdiwkqtvnlumwjgvubghkcjsvkrydpasdknkdclutjcqbretopqobivwfdkqkvmwkkufwnrngfgixlinerxcnrmsbiybcxmmndhhdrwykwmgckxqhlhnabppswwkxbjpvpeplcyyhcvhjulxvvgabddcurghjurledjdatsytdkqlfyrpnasrqiyecvjtkoiuigawvqfemwwnpkhapxvaqrlnncxdepunrnimqwcinnbnifvsjkwhufoawtbeghauvxiggajubybemfyeropjwvuhjrtiggsoaddpbgfcftppwnnlgnhbrdbhycslqlfkwdiswxntapahkpsyufkthkgmbvtmbnutyhrpjhotpndnldiugmmgxmtsdxqjojaqbedotgxlgaqyempwjlvtgifybqmxvcfbuonwivfhpqrmxfakrhjrsxovxgfwcteuadldgyghvcrjaaomwisvouyqqdmdbsbuvepcaxtkuqtsvqjbmejvptmbmbxasbxadvauepxicyjnydhmsvlohnnqoevhewwmxuqingvgbniqouikflimmxpuygutamkthmkydlwtvigyeutikpvnoqisehcgaylunxgwdvanwhsbjkukxahuviutenigfmkblniwdtqxxnswjoxhqqooaltrubgbqvqqdmdmrixidgukqx", + "abcdefghijklmnopqrstuvwxy", + }, + + { + "cdadabcc", + "adbc", + }, + + { + "abcd", + "abcd", + }, + + { + "ecbacba", + "eacb", + }, + + { + "leetcode", + "letcod", + }, + + // 可以有多个 testcase +} + +func Test_smallestSubsequence(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, smallestSubsequence(tc.text), "输入:%v", tc) + } +} + +func Benchmark_smallestSubsequence(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + smallestSubsequence(tc.text) + } + } +} diff --git a/Algorithms/1089.duplicate-zeros/README.md b/Algorithms/1089.duplicate-zeros/README.md new file mode 100755 index 000000000..47ec664cf --- /dev/null +++ b/Algorithms/1089.duplicate-zeros/README.md @@ -0,0 +1,28 @@ +# [1089. Duplicate Zeros](https://leetcode.com/problems/duplicate-zeros/) + +Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. + +Note that elements beyond the length of the original array are not written. + +Do the above modifications to the input array in place, do not return anything from your function. + +Example 1: + +```text +Input: [1,0,2,3,0,4,5,0] +Output: null +Explanation: After calling your function, the input array is modified to: [1,0,0,2,3,0,0,4] +``` + +Example 2: + +```text +Input: [1,2,3] +Output: null +Explanation: After calling your function, the input array is modified to: [1,2,3] +``` + +Note: + +1. `1 <= arr.length <= 10000` +1. `0 <= arr[i] <= 9` diff --git a/Algorithms/1089.duplicate-zeros/duplicate-zeros.go b/Algorithms/1089.duplicate-zeros/duplicate-zeros.go new file mode 100755 index 000000000..b3d5b51f3 --- /dev/null +++ b/Algorithms/1089.duplicate-zeros/duplicate-zeros.go @@ -0,0 +1,29 @@ +package problem1089 + +func duplicateZeros(A []int) { + n := len(A) + // + count := 0 + for i := 0; i < n; i++ { + if A[i] == 0 { + count++ + } + } + // copy A[i] to A[j] + copy := func(i, j int) { + if j < n { + A[j] = A[i] + } + } + // + i, j := n-1, n+count-1 + for i < j { + copy(i, j) + if A[i] == 0 { + j-- + copy(i, j) + } + i-- + j-- + } +} diff --git a/Algorithms/1089.duplicate-zeros/duplicate-zeros_test.go b/Algorithms/1089.duplicate-zeros/duplicate-zeros_test.go new file mode 100755 index 000000000..a320ee76e --- /dev/null +++ b/Algorithms/1089.duplicate-zeros/duplicate-zeros_test.go @@ -0,0 +1,59 @@ +package problem1089 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + arr []int + ans []int +}{ + + { + + []int{8, 4, 5, 0, 0, 0, 0, 7}, + []int{8, 4, 5, 0, 0, 0, 0, 0}, + }, + + { + []int{0, 0, 0, 0, 0, 0, 0, 0}, + []int{0, 0, 0, 0, 0, 0, 0, 0}, + }, + + { + []int{0, 0, 0, 0, 0, 0, 0}, + []int{0, 0, 0, 0, 0, 0, 0}, + }, + + { + []int{1, 0, 2, 3, 0, 4, 5, 0}, + []int{1, 0, 0, 2, 3, 0, 0, 4}, + }, + + { + []int{1, 2, 3}, + []int{1, 2, 3}, + }, + + // 可以有多个 testcase +} + +func Test_duplicateZeros(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + duplicateZeros(tc.arr) + ast.Equal(tc.ans, tc.arr, "输入:%v", tc) + } +} + +func Benchmark_duplicateZeros(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + duplicateZeros(tc.arr) + } + } +} diff --git a/Algorithms/1090.largest-values-from-labels/README.md b/Algorithms/1090.largest-values-from-labels/README.md new file mode 100755 index 000000000..8e1c8d2bc --- /dev/null +++ b/Algorithms/1090.largest-values-from-labels/README.md @@ -0,0 +1,48 @@ +# [1090. Largest Values From Labels](https://leetcode.com/problems/largest-values-from-labels/) + +We have a set of items: the i-th item has value values[i] and label labels[i]. + +Then, we choose a subset S of these items, such that: + +- |S| <= num_wanted +- For every label L, the number of items in S with label L is <= use_limit. + +Return the largest possible sum of the subset S. + +Example 1: + +```text +Input: values = [5,4,3,2,1], labels = [1,1,2,2,3], num_wanted = 3, use_limit = 1 +Output: 9 +Explanation: The subset chosen is the first, third, and fifth item. +``` + +Example 2: + +```text +Input: values = [5,4,3,2,1], labels = [1,3,3,3,2], num_wanted = 3, use_limit = 2 +Output: 12 +Explanation: The subset chosen is the first, second, and third item. +``` + +Example 3: + +```text +Input: values = [9,8,8,7,6], labels = [0,0,0,1,1], num_wanted = 3, use_limit = 1 +Output: 16 +Explanation: The subset chosen is the first and fourth item. +``` + +Example 4: + +```text +Input: values = [9,8,8,7,6], labels = [0,0,0,1,1], num_wanted = 3, use_limit = 2 +Output: 24 +Explanation: The subset chosen is the first, second, and fourth item. +``` + +Note: + +1. `1 <= values.length == labels.length <= 20000` +1. `0 <= values[i], labels[i] <= 20000` +1. `1 <= num_wanted, use_limit <= values.length` diff --git a/Algorithms/1090.largest-values-from-labels/largest-values-from-labels.go b/Algorithms/1090.largest-values-from-labels/largest-values-from-labels.go new file mode 100755 index 000000000..01d937a95 --- /dev/null +++ b/Algorithms/1090.largest-values-from-labels/largest-values-from-labels.go @@ -0,0 +1,29 @@ +package problem1090 + +import "sort" + +func largestValsFromLabels(values []int, labels []int, num_wanted int, use_limit int) int { + for i, v := range values { + values[i] = v<<16 + labels[i] + } + + sort.Slice(values, func(i int, j int) bool { + return values[i] > values[j] + }) + + count := [20001]int{} + res := 0 + for _, v := range values { + if count[v&0xFFFF] == use_limit { + continue + } + res += v >> 16 + count[v&0xFFFF]++ + num_wanted-- + if num_wanted == 0 { + break + } + } + + return res +} diff --git a/Algorithms/1090.largest-values-from-labels/largest-values-from-labels_test.go b/Algorithms/1090.largest-values-from-labels/largest-values-from-labels_test.go new file mode 100755 index 000000000..d334fa9a0 --- /dev/null +++ b/Algorithms/1090.largest-values-from-labels/largest-values-from-labels_test.go @@ -0,0 +1,67 @@ +package problem1090 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + values []int + labels []int + num_wanted int + use_limit int + ans int +}{ + + { + []int{5, 4, 3, 2, 1}, + []int{1, 1, 2, 2, 3}, + 3, + 1, + 9, + }, + + { + []int{5, 4, 3, 2, 1}, + []int{1, 3, 3, 3, 2}, + 3, + 2, + 12, + }, + + { + []int{9, 8, 8, 7, 6}, + []int{0, 0, 0, 1, 1}, + 3, + 1, + 16, + }, + + { + []int{9, 8, 8, 7, 6}, + []int{0, 0, 0, 1, 1}, + 3, + 2, + 24, + }, + + // 可以有多个 testcase +} + +func Test_largestValsFromLabels(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, largestValsFromLabels(tc.values, tc.labels, tc.num_wanted, tc.use_limit), "输入:%v", tc) + } +} + +func Benchmark_largestValsFromLabels(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + largestValsFromLabels(tc.values, tc.labels, tc.num_wanted, tc.use_limit) + } + } +} diff --git a/Algorithms/1091.shortest-path-in-binary-matrix/README.md b/Algorithms/1091.shortest-path-in-binary-matrix/README.md new file mode 100755 index 000000000..ee445c64e --- /dev/null +++ b/Algorithms/1091.shortest-path-in-binary-matrix/README.md @@ -0,0 +1,31 @@ +# [1091. Shortest Path in Binary Matrix](https://leetcode.com/problems/shortest-path-in-binary-matrix/) + +In an N by N square grid, each cell is either empty (0) or blocked (1). + +A clear path from top-left to bottom-right has length k if and only if it is composed of cells C_1, C_2, ..., C_k such that: + +- Adjacent cells C_i and C_{i+1} are connected 8-directionally (ie., they are different and share an edge or corner) +- C_1 is at location (0, 0) (ie. has value grid[0][0]) +- C_k is at location (N-1, N-1) (ie. has value grid[N-1][N-1]) +- If C_i is located at (r, c), then grid[r][c] is empty (ie. grid[r][c] == 0). + +Return the length of the shortest such clear path from top-left to bottom-right. If such a path does not exist, return -1. + +Example 1: + +```text +Input: [[0,1],[1,0]] +Output: 2 +``` + +Example 2: + +```text +Input: [[0,0,0],[1,1,0],[1,1,0]] +Output: 4 +``` + +Note: + +1. `1 <= grid.length == grid[0].length <= 100` +2. `grid[r][c] is 0 or 1` diff --git a/Algorithms/1091.shortest-path-in-binary-matrix/shortest-path-in-binary-matrix.go b/Algorithms/1091.shortest-path-in-binary-matrix/shortest-path-in-binary-matrix.go new file mode 100755 index 000000000..d74666772 --- /dev/null +++ b/Algorithms/1091.shortest-path-in-binary-matrix/shortest-path-in-binary-matrix.go @@ -0,0 +1,41 @@ +package problem1091 + +var dx = []int{-1, -1, -1, 0, 1, 1, 1, 0} +var dy = []int{-1, 0, 1, 1, 1, 0, -1, -1} + +func shortestPathBinaryMatrix(grid [][]int) int { + if grid[0][0] == 1 { + return -1 + } + + N := len(grid) + + cells := make([][2]int, 1, N*N) + grid[0][0] = 1 + length := 1 + + for len(cells) > 0 { + size := len(cells) + for s := 0; s < size; s++ { + c := cells[s] + x, y := c[0], c[1] + if x == N-1 && y == N-1 { + return length + } + for k := 0; k < 8; k++ { + i, j := x+dx[k], y+dy[k] + if i < 0 || N <= i || + j < 0 || N <= j || + grid[i][j] == 1 { + continue + } + cells = append(cells, [2]int{i, j}) + grid[i][j] = 1 + } + } + length++ + cells = cells[size:] + } + + return -1 +} diff --git a/Algorithms/1091.shortest-path-in-binary-matrix/shortest-path-in-binary-matrix_test.go b/Algorithms/1091.shortest-path-in-binary-matrix/shortest-path-in-binary-matrix_test.go new file mode 100755 index 000000000..ea6ea9e4a --- /dev/null +++ b/Algorithms/1091.shortest-path-in-binary-matrix/shortest-path-in-binary-matrix_test.go @@ -0,0 +1,52 @@ +package problem1091 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + ans int +}{ + + { + [][]int{{1, 0, 0}, {1, 1, 0}, {1, 1, 0}}, + -1, + }, + + { + [][]int{{0, 1}, {1, 0}}, + 2, + }, + + { + [][]int{{0, 1, 0}, {1, 1, 0}, {1, 1, 0}}, + -1, + }, + + { + [][]int{{0, 0, 0}, {1, 1, 0}, {1, 1, 0}}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_shortestPathBinaryMatrix(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, shortestPathBinaryMatrix(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_shortestPathBinaryMatrix(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shortestPathBinaryMatrix(tc.grid) + } + } +} diff --git a/Algorithms/1092.shortest-common-supersequence/README.md b/Algorithms/1092.shortest-common-supersequence/README.md new file mode 100755 index 000000000..5acbbe009 --- /dev/null +++ b/Algorithms/1092.shortest-common-supersequence/README.md @@ -0,0 +1,21 @@ +# [1092. Shortest Common Supersequence](https://leetcode.com/problems/shortest-common-supersequence/) + +Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If multiple answers exist, you may return any of them. + +(A string S is a subsequence of string T if deleting some number of characters from T (possibly 0, and the characters are chosen anywhere from T) results in the string S.) + +Example 1: + +```text +Input: str1 = "abac", str2 = "cab" +Output: "cabac" +Explanation: +str1 = "abac" is a substring of "cabac" because we can delete the first "c". +str2 = "cab" is a substring of "cabac" because we can delete the last "ac". +The answer provided is the shortest such string that satisfies these properties. +``` + +Note: + +1. `1 <= str1.length, str2.length <= 1000` +1. `str1 and str2 consist of lowercase English letters.` diff --git a/Algorithms/1092.shortest-common-supersequence/shortest-common-supersequence.go b/Algorithms/1092.shortest-common-supersequence/shortest-common-supersequence.go new file mode 100755 index 000000000..86c6404f4 --- /dev/null +++ b/Algorithms/1092.shortest-common-supersequence/shortest-common-supersequence.go @@ -0,0 +1,64 @@ +package problem1092 + +import "strings" + +func shortestCommonSupersequence(A, B string) string { + m, n := len(A), len(B) + // 解题思路, + // 先求出 A 和 B 的 LCS, + // 然后,在 LCS 上添加缺少的字母 + // 利用 dp 求解 LCS , + // dp[i][j]=k 表示 A[:i] 与 B[:j] 的 LCS 的长度为 k + // 在递归过程中,会出现三种情况: + // 1. A[i]=B[j], 则 dp[i][j]= dp[i-1][j-1]+1 + // 2. A[i]!=B[j] 且 dp[i-1][j] >= dp[i][j-1],则 dp[i][j]=dp[i-1][j] + // 3. A[i]!=B[j] 且 dp[i-1][j] < dp[i][j-1],则 dp[i][j]=dp[i][j+1] + + dp := [1001][1001]int{} + b := [1001][1001]int{} // 记录哪种情况发生了,以便添加字母 + + for i := 1; i <= m; i++ { + for j := 1; j <= n; j++ { + if A[i-1] == B[j-1] { + dp[i][j] = dp[i-1][j-1] + 1 + b[i][j] = 1 + } else if dp[i-1][j] >= dp[i][j-1] { + dp[i][j] = dp[i-1][j] + b[i][j] = 2 + } else { + dp[i][j] = dp[i][j-1] + b[i][j] = 3 + } + } + } + + var sb strings.Builder + var dfs func(int, int) + dfs = func(i, j int) { + if i == 0 { + sb.WriteString(B[:j]) + return + } + + if j == 0 { + sb.WriteString(A[:i]) + return + } + + switch b[i][j] { + case 1: + dfs(i-1, j-1) + sb.WriteByte(A[i-1]) + case 2: + dfs(i-1, j) + sb.WriteByte(A[i-1]) + case 3: + dfs(i, j-1) + sb.WriteByte(B[j-1]) + } + } + + dfs(m, n) + + return sb.String() +} diff --git a/Algorithms/1092.shortest-common-supersequence/shortest-common-supersequence_test.go b/Algorithms/1092.shortest-common-supersequence/shortest-common-supersequence_test.go new file mode 100755 index 000000000..3bd4038a8 --- /dev/null +++ b/Algorithms/1092.shortest-common-supersequence/shortest-common-supersequence_test.go @@ -0,0 +1,51 @@ +package problem1092 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + str1 string + str2 string + ans string +}{ + + { + "abaa", + "aaaa", + "aabaa", + }, + + { + "cab", + "abac", + "cabac", + }, + + { + "abac", + "cab", + "cabac", + }, + + // 可以有多个 testcase +} + +func Test_shortestCommonSupersequence(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, shortestCommonSupersequence(tc.str1, tc.str2), "输入:%v", tc) + } +} + +func Benchmark_shortestCommonSupersequence(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shortestCommonSupersequence(tc.str1, tc.str2) + } + } +} diff --git a/Algorithms/1093.statistics-from-a-large-sample/README.md b/Algorithms/1093.statistics-from-a-large-sample/README.md new file mode 100755 index 000000000..0b86349a9 --- /dev/null +++ b/Algorithms/1093.statistics-from-a-large-sample/README.md @@ -0,0 +1,31 @@ +# [1093. Statistics from a Large Sample](https://leetcode.com/problems/statistics-from-a-large-sample/) + +We sampled integers between 0 and 255, and stored the results in an array count: count[k] is the number of integers we sampled equal to k. + +Return the minimum, maximum, mean, median, and mode of the sample respectively, as an array of floating point numbers. The mode is guaranteed to be unique. + +(Recall that the median of a sample is: + +- The middle element, if the elements of the sample were sorted and the number of elements is odd; +- The average of the middle two elements, if the elements of the sample were sorted and the number of elements is even.) + +Example 1: + +```text +Input: count = [0,1,3,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] +Output: [1.00000,3.00000,2.37500,2.50000,3.00000] +``` + +Example 2: + +```text +Input: count = [0,4,3,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] +Output: [1.00000,4.00000,2.18182,2.00000,1.00000] +``` + +Constraints: + +1. `count.length == 256` +1. `1 <= sum(count) <= 10^9` +1. `The mode of the sample that count represents is unique.` +1. `Answers within 10^-5 of the true value will be accepted as correct.` diff --git a/Algorithms/1093.statistics-from-a-large-sample/statistics-from-a-large-sample.go b/Algorithms/1093.statistics-from-a-large-sample/statistics-from-a-large-sample.go new file mode 100755 index 000000000..c93b75726 --- /dev/null +++ b/Algorithms/1093.statistics-from-a-large-sample/statistics-from-a-large-sample.go @@ -0,0 +1,86 @@ +package problem1093 + +import "sort" + +func sampleStats(count []int) []float64 { + return []float64{ + minimum(count), + maximum(count), + mean(count), + median(count), + mode(count), + } +} + +// minimum:最小值 +func minimum(count []int) float64 { + i := 0 + for ; i < len(count); i++ { + if count[i] != 0 { + break + } + } + return float64(i) +} + +// maximum:最大值 +func maximum(count []int) float64 { + i := len(count) - 1 + for ; i >= 0; i-- { + if count[i] != 0 { + break + } + } + return float64(i) +} + +// mean :平均数 +func mean(count []int) float64 { + sum, c := 0, 0 + for i := 0; i < len(count); i++ { + if count[i] == 0 { + continue + } + sum += i * count[i] + c += count[i] + } + return float64(sum) / float64(c) +} + +// median :中位数,排序后,位于正中间的数。 +func median(count []int) float64 { + k := make([]int, 0, 256) + c := make([]int, 0, 256) + sum := 0 + for i := 0; i < len(count); i++ { + if count[i] == 0 { + continue + } + sum += count[i] + k = append(k, i) + c = append(c, sum) + } + if sum%2 == 1 { + h := sum/2 + 1 + i := sort.SearchInts(c, h) + return float64(k[i]) + } + h := sum / 2 + i := sort.SearchInts(c, h) + j := sort.SearchInts(c, h+1) + return float64(k[i]+k[j]) / 2 +} + +// mode :出现次数最多的数 +func mode(count []int) float64 { + k, c := -1, -1 + for i := 0; i < len(count); i++ { + if count[i] == 0 { + continue + } + if c < count[i] { + k, c = i, count[i] + } + } + return float64(k) +} diff --git a/Algorithms/1093.statistics-from-a-large-sample/statistics-from-a-large-sample_test.go b/Algorithms/1093.statistics-from-a-large-sample/statistics-from-a-large-sample_test.go new file mode 100755 index 000000000..8a8addc94 --- /dev/null +++ b/Algorithms/1093.statistics-from-a-large-sample/statistics-from-a-large-sample_test.go @@ -0,0 +1,48 @@ +package problem1093 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + count []int + ans []float64 +}{ + + { + []int{2725123, 2529890, 2612115, 3807943, 3002363, 3107290, 2767526, 981092, 896521, 2576757, 2808163, 3315813, 2004022, 2516900, 607052, 1203189, 2907162, 1849193, 1486120, 743035, 3621726, 3366475, 639843, 3836904, 462733, 2614577, 1881392, 85099, 709390, 3534613, 360309, 404975, 715871, 2258745, 1682843, 3725079, 564127, 1893839, 2793387, 2236577, 522108, 1183512, 859756, 3431566, 907265, 1272267, 2261055, 2234764, 1901434, 3023329, 863353, 2140290, 2221702, 623198, 955635, 304443, 282157, 3133971, 1985993, 1113476, 2092502, 2896781, 1245030, 2681380, 2286852, 3423914, 3549428, 2720176, 2832468, 3608887, 174642, 1437770, 1545228, 650920, 2357584, 3037465, 3674038, 2450617, 578392, 622803, 3206006, 3685232, 2687252, 1001246, 3865843, 2755767, 184888, 2543886, 2567950, 1755006, 249516, 3241670, 1422728, 809805, 955992, 415481, 26094, 2757283, 995334, 3713918, 2772540, 2719728, 1204666, 1590541, 2962447, 779517, 1322374, 1675147, 3146304, 2412486, 902468, 259007, 3161334, 1735554, 2623893, 1863961, 520352, 167827, 3654335, 3492218, 1449347, 1460253, 983079, 1135, 208617, 969433, 2669769, 284741, 1002734, 3694338, 2567646, 3042965, 3186843, 906766, 2755956, 2075889, 1241484, 3790012, 2037406, 2776032, 1123633, 2537866, 3028339, 3375304, 1621954, 2299012, 1518828, 1380554, 2083623, 3521053, 1291275, 180303, 1344232, 2122185, 2519290, 832389, 1711223, 2828198, 2747583, 789884, 2116590, 2294299, 1038729, 1996529, 600580, 184130, 3044375, 261274, 3041086, 3473202, 2318793, 2967147, 2506188, 127448, 290011, 3868450, 1659949, 3662189, 1720152, 25266, 1126602, 1015878, 2635566, 619797, 2898869, 3470795, 2226675, 2348104, 2914940, 1907109, 604482, 2574752, 1841777, 880254, 616721, 3786049, 2278898, 3797514, 1328854, 1881493, 1802018, 3034791, 3615171, 400080, 2277949, 221689, 1021253, 544372, 3101480, 1155691, 3730276, 1827138, 3621214, 2348383, 2305429, 313820, 36481, 2581470, 2794393, 902504, 2589859, 740480, 2387513, 2716342, 1914543, 3219912, 1865333, 2388350, 3525289, 3758988, 961406, 1539328, 448809, 1326527, 1339048, 2924378, 2715811, 376047, 3642811, 2973602, 389167, 1026011, 3633833, 2848596, 3353421, 1426817, 219995, 1503946, 2311246, 2618861, 1497325, 3758762, 2115273, 3238053, 2419849, 2545790}, + []float64{0, 255, 128.64187, 131, 175}, + }, + + { + []int{0, 1, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + []float64{1.00000, 3.00000, 2.37500, 2.50000, 3.00000}, + }, + + { + []int{0, 4, 3, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, + []float64{1.00000, 4.00000, 2.18182, 2.00000, 1.00000}, + }, + + // 可以有多个 testcase +} + +func Test_sampleStats(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ans := sampleStats(tc.count) + ast.InDeltaSlice(tc.ans, ans, 0.00001, "输入:%v", tc) + } +} + +func Benchmark_sampleStats(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + sampleStats(tc.count) + } + } +} diff --git a/Algorithms/1094.car-pooling/README.md b/Algorithms/1094.car-pooling/README.md new file mode 100755 index 000000000..5a2d83522 --- /dev/null +++ b/Algorithms/1094.car-pooling/README.md @@ -0,0 +1,43 @@ +# [1094. Car Pooling](https://leetcode.com/problems/car-pooling/) + +You are driving a vehicle that has capacity empty seats initially available for passengers. The vehicle only drives east (ie. it cannot turn around and drive west.) + +Given a list of trips, trip[i] = [num_passengers, start_location, end_location] contains information about the i-th trip: the number of passengers that must be picked up, and the locations to pick them up and drop them off. The locations are given as the number of kilometers due east from your vehicle's initial location. + +Return true if and only if it is possible to pick up and drop off all passengers for all the given trips. + +Example 1: + +```text +Input: trips = [[2,1,5],[3,3,7]], capacity = 4 +Output: false +``` + +Example 2: + +```text +Input: trips = [[2,1,5],[3,3,7]], capacity = 5 +Output: true +``` + +Example 3: + +```text +Input: trips = [[2,1,5],[3,5,7]], capacity = 3 +Output: true +``` + +Example 4: + +```text +Input: trips = [[3,2,7],[3,7,9],[8,3,9]], capacity = 11 +Output: true +``` + +Constraints: + +1. `trips.length <= 1000` +1. `trips[i].length == 3` +1. `1 <= trips[i][0] <= 100` +1. `0 <= trips[i][1] < trips[i][2] <= 1000` +1. `1 <= capacity <= 100000` diff --git a/Algorithms/1094.car-pooling/car-pooling.go b/Algorithms/1094.car-pooling/car-pooling.go new file mode 100755 index 000000000..c5254f4c5 --- /dev/null +++ b/Algorithms/1094.car-pooling/car-pooling.go @@ -0,0 +1,19 @@ +package problem1094 + +func carPooling(trips [][]int, capacity int) bool { + location := [1001]int{} + for _, t := range trips { + num, start, end := t[0], t[1], t[2] + location[start] += num + location[end] -= num + } + + p := 0 + for _, c := range location { + p += c + if p > capacity { + return false + } + } + return true +} diff --git a/Algorithms/1094.car-pooling/car-pooling_test.go b/Algorithms/1094.car-pooling/car-pooling_test.go new file mode 100755 index 000000000..579a95bee --- /dev/null +++ b/Algorithms/1094.car-pooling/car-pooling_test.go @@ -0,0 +1,57 @@ +package problem1094 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + trips [][]int + capacity int + ans bool +}{ + + { + [][]int{{2, 1, 5}, {3, 3, 7}}, + 4, + false, + }, + + { + [][]int{{2, 1, 5}, {3, 3, 7}}, + 5, + true, + }, + + { + [][]int{{2, 1, 5}, {3, 5, 7}}, + 3, + true, + }, + + { + [][]int{{3, 2, 7}, {3, 7, 9}, {8, 3, 9}}, + 11, + true, + }, + + // 可以有多个 testcase +} + +func Test_carPooling(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, carPooling(tc.trips, tc.capacity), "输入:%v", tc) + } +} + +func Benchmark_carPooling(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + carPooling(tc.trips, tc.capacity) + } + } +} diff --git a/Algorithms/1095.find-in-mountain-array/README.md b/Algorithms/1095.find-in-mountain-array/README.md new file mode 100755 index 000000000..fc5694978 --- /dev/null +++ b/Algorithms/1095.find-in-mountain-array/README.md @@ -0,0 +1,41 @@ +# [1095. Find in Mountain Array](https://leetcode.com/problems/find-in-mountain-array/) + +(This problem is an interactive problem.) + +You may recall that an array A is a mountain array if and only if: + +- A.length >= 3 +- There exists some i with 0 < i < A.length - 1 such that: + - A[0] < A[1] < ... A[i-1] < A[i] + - A[i] > A[i+1] > ... > A[A.length - 1] + +Given a mountain array mountainArr, return the minimum index such that mountainArr.get(index) == target. If such an index doesn't exist, return -1. + +You can't access the mountain array directly. You may only access the array using a MountainArray interface: + +- MountainArray.get(k) returns the element of the array at index k (0-indexed). +- MountainArray.length() returns the length of the array. + +Submissions making more than 100 calls to MountainArray.get will be judged Wrong Answer. Also, any solutions that attempt to circumvent the judge will result in disqualification. + +Example 1: + +```text +Input: array = [1,2,3,4,5,3,1], target = 3 +Output: 2 +Explanation: 3 exists in the array, at index=2 and index=5. Return the minimum index, which is 2. +``` + +Example 2: + +```text +Input: array = [0,1,2,4,2,1], target = 3 +Output: -1 +Explanation: 3 does not exist in the array, so we return -1. +``` + +Constraints: + +1. `3 <= mountain_arr.length() <= 10000` +1. `0 <= target <= 10^9` +1. `0 <= mountain_arr.get(index) <= 10^9` diff --git a/Algorithms/1095.find-in-mountain-array/find-in-mountain-array.go b/Algorithms/1095.find-in-mountain-array/find-in-mountain-array.go new file mode 100755 index 000000000..41c8b4b70 --- /dev/null +++ b/Algorithms/1095.find-in-mountain-array/find-in-mountain-array.go @@ -0,0 +1,74 @@ +package problem1095 + +// MountainArray is required +type MountainArray []int + +func (m *MountainArray) get(index int) int { + return (*m)[index] +} +func (m *MountainArray) length() int { + return len(*m) +} + +/** + * This is the MountainArray's API interface. + * You should not implement it, or speculate about its implementation + * type MountainArray struct { + * } + * + * func (this *MountainArray) get(index int) int {} + * func (this *MountainArray) length() int {} + */ + +func findInMountainArray(target int, ma *MountainArray) int { + n := ma.length() + + peak := searchPeak(0, n-1, ma) + + index := searchLeft(0, peak, target, ma) + if index != -1 { + return index + } + return searchRight(peak, n-1, target, ma) +} + +func searchPeak(lo, hi int, ma *MountainArray) int { + for lo < hi { + mid := (lo + hi - 1) / 2 + if ma.get(mid) < ma.get(mid+1) { + lo = mid + 1 + } else { + hi = mid + } + } + return lo +} + +func searchLeft(lo, hi, target int, ma *MountainArray) int { + less := func(a, b int) bool { + return a < b + } + return binarySearch(lo, hi, target, ma, less) +} + +func searchRight(lo, hi, target int, ma *MountainArray) int { + less := func(a, b int) bool { + return a > b + } + return binarySearch(lo, hi, target, ma, less) +} + +func binarySearch(lo, hi, target int, ma *MountainArray, less func(a, b int) bool) int { + for lo <= hi { + mid := (lo + hi) / 2 + m := ma.get(mid) + if m == target { + return mid + } else if less(m, target) { + lo = mid + 1 + } else { + hi = mid - 1 + } + } + return -1 +} diff --git a/Algorithms/1095.find-in-mountain-array/find-in-mountain-array_test.go b/Algorithms/1095.find-in-mountain-array/find-in-mountain-array_test.go new file mode 100755 index 000000000..75f0675f6 --- /dev/null +++ b/Algorithms/1095.find-in-mountain-array/find-in-mountain-array_test.go @@ -0,0 +1,59 @@ +package problem1095 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + target int + mountainArr []int + ans int +}{ + + { + 2, + []int{1, 5, 2}, + 2, + }, + + { + 2, + []int{1, 2, 3, 4, 5, 3, 1}, + 1, + }, + + { + 3, + []int{1, 2, 3, 4, 5, 3, 1}, + 2, + }, + + { + 3, + []int{0, 1, 2, 4, 2, 1}, + -1, + }, + + // 可以有多个 testcase +} + +func Test_findInMountainArray(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + m := MountainArray(tc.mountainArr) + ast.Equal(tc.ans, findInMountainArray(tc.target, &m), "输入:%v", tc) + } +} + +func Benchmark_findInMountainArray(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + m := MountainArray(tc.mountainArr) + findInMountainArray(tc.target, &m) + } + } +} diff --git a/Algorithms/1096.brace-expansion-ii/README.md b/Algorithms/1096.brace-expansion-ii/README.md new file mode 100755 index 000000000..e13b35fca --- /dev/null +++ b/Algorithms/1096.brace-expansion-ii/README.md @@ -0,0 +1,44 @@ +# [1096. Brace Expansion II](https://leetcode.com/problems/brace-expansion-ii/) + +Under a grammar given below, strings can represent a set of lowercase words. Let's use R(expr) to denote the set of words the expression represents. + +Grammar can best be understood through simple examples: + +- Single letters represent a singleton set containing that word. + - R("a") = {"a"} + - R("w") = {"w"} +- When we take a comma delimited list of 2 or more expressions, we take the union of possibilities. + - R("{a,b,c}") = {"a","b","c"} + - R("{{a,b},{b,c}}") = {"a","b","c"} (notice the final set only contains each word at most once) +- When we concatenate two expressions, we take the set of possible concatenations between two words where the first word comes from the first expression and the second word comes from the second expression. + - R("{a,b}{c,d}") = {"ac","ad","bc","bd"} + - R("a{b,c}{d,e}f{g,h}") = {"abdfg", "abdfh", "abefg", "abefh", "acdfg", "acdfh", "acefg", "acefh"} + +Formally, the 3 rules for our grammar: + +- For every lowercase letter x, we have R(x) = {x} +- For expressions e_1, e_2, ... , e_k with k >= 2, we have R({e_1,e_2,...}) = R(e_1) ∪ R(e_2) ∪ ... +- For expressions e_1 and e_2, we have R(e_1 + e_2) = {a + b for (a, b) in R(e_1) × R(e_2)}, where + denotes concatenation, and × denotes the cartesian product. + +Given an expression representing a set of words under the given grammar, return the sorted list of words that the expression represents. + +Example 1: + +```text +Input: "{a,b}{c,{d,e}}" +Output: ["ac","ad","ae","bc","bd","be"] +``` + +Example 2: + +```text +Input: "{{a,z},a{b,c},{ab,z}}" +Output: ["a","ab","ac","z"] +Explanation: Each distinct word is written only once in the final answer. +``` + +Constraints: + +1. `1 <= expression.length <= 50` +1. `expression[i] consists of '{', '}', ','or lowercase English letters.` +1. `The given expression represents a set of words based on the grammar given in the description.` diff --git a/Algorithms/1096.brace-expansion-ii/brace-expansion-ii.go b/Algorithms/1096.brace-expansion-ii/brace-expansion-ii.go new file mode 100755 index 000000000..cd0d38a00 --- /dev/null +++ b/Algorithms/1096.brace-expansion-ii/brace-expansion-ii.go @@ -0,0 +1,141 @@ +package problem1096 + +import ( + "sort" + "strings" +) + +func braceExpansionII(exp string) []string { + n := len(exp) + + bytes := make([]byte, 1, n*2) + bytes[0] = exp[0] + pre := exp[0] + for i := 1; i < n; i++ { + cur := exp[i] + // add '*' symbol + if (isLetter(pre) && cur == '{') || + (pre == '}' && cur == '{') || + (pre == '}' && isLetter(cur)) { + bytes = append(bytes, '*') + } + // replace ',' with '+' symbol + if cur == ',' { + bytes = append(bytes, '+') + } else { + bytes = append(bytes, cur) + } + pre = cur + } + exp = string(bytes) + + return unique(doAdd(exp)) +} + +func isLetter(r byte) bool { + return 'a' <= r && r <= 'z' +} + +// split exp with symbol NOT in braces +// because braces change priority +func split(exp string, symbol byte) []string { + exp = removeOuterBrace(exp) + count := 0 + isInBraces := func() bool { + return count > 0 + } + bytes := []byte(exp) + for i, b := range bytes { + switch b { + case '{': + count++ + case '}': + count-- + case symbol: + if !isInBraces() { + bytes[i] = '@' + } + } + } + exp = string(bytes) + return strings.Split(exp, "@") +} + +func doAdd(exp string) []string { + if !strings.ContainsRune(exp, '*') { + exp = removeAllBraces(exp) + return strings.Split(exp, "+") + } + exps := split(exp, '+') + res := []string{} + for _, e := range exps { + res = add(res, doMultiply(e)) + } + return res +} + +func doMultiply(exp string) []string { + if !strings.ContainsRune(exp, '+') { + exp = removeAllBraces(exp) + exp = strings.Replace(exp, "*", "", -1) + return []string{exp} + } + exps := split(exp, '*') + res := []string{""} + for _, e := range exps { + res = multiply(res, doAdd(e)) + } + return res +} + +func removeAllBraces(exp string) string { + exp = strings.Replace(exp, "{", "", -1) + return strings.Replace(exp, "}", "", -1) +} + +func removeOuterBrace(exp string) string { + n := len(exp) + if exp[0] != '{' || + exp[n-1] != '}' { + return exp + } + count, i := 1, 1 + for ; i < n && count > 0; i++ { + if exp[i] == '{' { + count++ + } else if exp[i] == '}' { + count-- + } + } + if i == n { + return exp[1 : n-1] + } + return exp +} + +func add(A, B []string) []string { + return append(A, B...) +} + +func multiply(A, B []string) []string { + res := make([]string, 0, len(A)*len(B)) + for _, a := range A { + for _, b := range B { + res = append(res, a+b) + } + } + return res +} + +func unique(A []string) []string { + sort.Strings(A) + i, j, n := 0, 0, len(A) + for j < n { + if A[i] != A[j] { + i++ + A[i] = A[j] + } + j++ + } + return A[:i+1] +} diff --git a/Algorithms/1096.brace-expansion-ii/brace-expansion-ii_test.go b/Algorithms/1096.brace-expansion-ii/brace-expansion-ii_test.go new file mode 100755 index 000000000..fab62ffd2 --- /dev/null +++ b/Algorithms/1096.brace-expansion-ii/brace-expansion-ii_test.go @@ -0,0 +1,87 @@ +package problem1096 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + expression string + ans []string +}{ + + { + "{a,b}{a,b}{a,b}{a,b}{a,b}{a,b}{a,b}{a,b}{a,b}{a,b}", + []string{"aaaaaaaaaa", "aaaaaaaaab", "aaaaaaaaba", "aaaaaaaabb", "aaaaaaabaa", "aaaaaaabab", "aaaaaaabba", "aaaaaaabbb", "aaaaaabaaa", "aaaaaabaab", "aaaaaababa", "aaaaaababb", "aaaaaabbaa", "aaaaaabbab", "aaaaaabbba", "aaaaaabbbb", "aaaaabaaaa", "aaaaabaaab", "aaaaabaaba", "aaaaabaabb", "aaaaababaa", "aaaaababab", "aaaaababba", "aaaaababbb", "aaaaabbaaa", "aaaaabbaab", "aaaaabbaba", "aaaaabbabb", "aaaaabbbaa", "aaaaabbbab", "aaaaabbbba", "aaaaabbbbb", "aaaabaaaaa", "aaaabaaaab", "aaaabaaaba", "aaaabaaabb", "aaaabaabaa", "aaaabaabab", "aaaabaabba", "aaaabaabbb", "aaaababaaa", "aaaababaab", "aaaabababa", "aaaabababb", "aaaababbaa", "aaaababbab", "aaaababbba", "aaaababbbb", "aaaabbaaaa", "aaaabbaaab", "aaaabbaaba", "aaaabbaabb", "aaaabbabaa", "aaaabbabab", "aaaabbabba", "aaaabbabbb", "aaaabbbaaa", "aaaabbbaab", "aaaabbbaba", "aaaabbbabb", "aaaabbbbaa", "aaaabbbbab", "aaaabbbbba", "aaaabbbbbb", "aaabaaaaaa", "aaabaaaaab", "aaabaaaaba", "aaabaaaabb", "aaabaaabaa", "aaabaaabab", "aaabaaabba", "aaabaaabbb", "aaabaabaaa", "aaabaabaab", "aaabaababa", "aaabaababb", "aaabaabbaa", "aaabaabbab", "aaabaabbba", "aaabaabbbb", "aaababaaaa", "aaababaaab", "aaababaaba", "aaababaabb", "aaabababaa", "aaabababab", "aaabababba", "aaabababbb", "aaababbaaa", "aaababbaab", "aaababbaba", "aaababbabb", "aaababbbaa", "aaababbbab", "aaababbbba", "aaababbbbb", "aaabbaaaaa", "aaabbaaaab", "aaabbaaaba", "aaabbaaabb", "aaabbaabaa", "aaabbaabab", "aaabbaabba", "aaabbaabbb", "aaabbabaaa", "aaabbabaab", "aaabbababa", "aaabbababb", "aaabbabbaa", "aaabbabbab", "aaabbabbba", "aaabbabbbb", "aaabbbaaaa", "aaabbbaaab", "aaabbbaaba", "aaabbbaabb", "aaabbbabaa", "aaabbbabab", "aaabbbabba", "aaabbbabbb", "aaabbbbaaa", "aaabbbbaab", "aaabbbbaba", "aaabbbbabb", "aaabbbbbaa", "aaabbbbbab", "aaabbbbbba", "aaabbbbbbb", "aabaaaaaaa", "aabaaaaaab", "aabaaaaaba", "aabaaaaabb", "aabaaaabaa", "aabaaaabab", "aabaaaabba", "aabaaaabbb", "aabaaabaaa", "aabaaabaab", "aabaaababa", "aabaaababb", "aabaaabbaa", "aabaaabbab", "aabaaabbba", "aabaaabbbb", "aabaabaaaa", "aabaabaaab", "aabaabaaba", "aabaabaabb", "aabaababaa", "aabaababab", "aabaababba", "aabaababbb", "aabaabbaaa", "aabaabbaab", "aabaabbaba", "aabaabbabb", "aabaabbbaa", "aabaabbbab", "aabaabbbba", "aabaabbbbb", "aababaaaaa", "aababaaaab", "aababaaaba", "aababaaabb", "aababaabaa", "aababaabab", "aababaabba", "aababaabbb", "aabababaaa", "aabababaab", "aababababa", "aababababb", "aabababbaa", "aabababbab", "aabababbba", "aabababbbb", "aababbaaaa", "aababbaaab", "aababbaaba", "aababbaabb", "aababbabaa", "aababbabab", "aababbabba", "aababbabbb", "aababbbaaa", "aababbbaab", "aababbbaba", "aababbbabb", "aababbbbaa", "aababbbbab", "aababbbbba", "aababbbbbb", "aabbaaaaaa", "aabbaaaaab", "aabbaaaaba", "aabbaaaabb", "aabbaaabaa", "aabbaaabab", "aabbaaabba", "aabbaaabbb", "aabbaabaaa", "aabbaabaab", "aabbaababa", "aabbaababb", "aabbaabbaa", "aabbaabbab", "aabbaabbba", "aabbaabbbb", "aabbabaaaa", "aabbabaaab", "aabbabaaba", "aabbabaabb", "aabbababaa", "aabbababab", "aabbababba", "aabbababbb", "aabbabbaaa", "aabbabbaab", "aabbabbaba", "aabbabbabb", "aabbabbbaa", "aabbabbbab", "aabbabbbba", "aabbabbbbb", "aabbbaaaaa", "aabbbaaaab", "aabbbaaaba", "aabbbaaabb", "aabbbaabaa", "aabbbaabab", "aabbbaabba", "aabbbaabbb", "aabbbabaaa", "aabbbabaab", "aabbbababa", "aabbbababb", "aabbbabbaa", "aabbbabbab", "aabbbabbba", "aabbbabbbb", "aabbbbaaaa", "aabbbbaaab", "aabbbbaaba", "aabbbbaabb", "aabbbbabaa", "aabbbbabab", "aabbbbabba", "aabbbbabbb", "aabbbbbaaa", "aabbbbbaab", "aabbbbbaba", "aabbbbbabb", "aabbbbbbaa", "aabbbbbbab", "aabbbbbbba", "aabbbbbbbb", "abaaaaaaaa", "abaaaaaaab", "abaaaaaaba", "abaaaaaabb", "abaaaaabaa", "abaaaaabab", "abaaaaabba", "abaaaaabbb", "abaaaabaaa", "abaaaabaab", "abaaaababa", "abaaaababb", "abaaaabbaa", "abaaaabbab", "abaaaabbba", "abaaaabbbb", "abaaabaaaa", "abaaabaaab", "abaaabaaba", "abaaabaabb", "abaaababaa", "abaaababab", "abaaababba", "abaaababbb", "abaaabbaaa", "abaaabbaab", "abaaabbaba", "abaaabbabb", "abaaabbbaa", "abaaabbbab", "abaaabbbba", "abaaabbbbb", "abaabaaaaa", "abaabaaaab", "abaabaaaba", "abaabaaabb", "abaabaabaa", "abaabaabab", "abaabaabba", "abaabaabbb", "abaababaaa", "abaababaab", "abaabababa", "abaabababb", "abaababbaa", "abaababbab", "abaababbba", "abaababbbb", "abaabbaaaa", "abaabbaaab", "abaabbaaba", "abaabbaabb", "abaabbabaa", "abaabbabab", "abaabbabba", "abaabbabbb", "abaabbbaaa", "abaabbbaab", "abaabbbaba", "abaabbbabb", "abaabbbbaa", "abaabbbbab", "abaabbbbba", "abaabbbbbb", "ababaaaaaa", "ababaaaaab", "ababaaaaba", "ababaaaabb", "ababaaabaa", "ababaaabab", "ababaaabba", "ababaaabbb", "ababaabaaa", "ababaabaab", "ababaababa", "ababaababb", "ababaabbaa", "ababaabbab", "ababaabbba", "ababaabbbb", "abababaaaa", "abababaaab", "abababaaba", "abababaabb", "ababababaa", "ababababab", "ababababba", "ababababbb", "abababbaaa", "abababbaab", "abababbaba", "abababbabb", "abababbbaa", "abababbbab", "abababbbba", "abababbbbb", "ababbaaaaa", "ababbaaaab", "ababbaaaba", "ababbaaabb", "ababbaabaa", "ababbaabab", "ababbaabba", "ababbaabbb", "ababbabaaa", "ababbabaab", "ababbababa", "ababbababb", "ababbabbaa", "ababbabbab", "ababbabbba", "ababbabbbb", "ababbbaaaa", "ababbbaaab", "ababbbaaba", "ababbbaabb", "ababbbabaa", "ababbbabab", "ababbbabba", "ababbbabbb", "ababbbbaaa", "ababbbbaab", "ababbbbaba", "ababbbbabb", "ababbbbbaa", "ababbbbbab", "ababbbbbba", "ababbbbbbb", "abbaaaaaaa", "abbaaaaaab", "abbaaaaaba", "abbaaaaabb", "abbaaaabaa", "abbaaaabab", "abbaaaabba", "abbaaaabbb", "abbaaabaaa", "abbaaabaab", "abbaaababa", "abbaaababb", "abbaaabbaa", "abbaaabbab", "abbaaabbba", "abbaaabbbb", "abbaabaaaa", "abbaabaaab", "abbaabaaba", "abbaabaabb", "abbaababaa", "abbaababab", "abbaababba", "abbaababbb", "abbaabbaaa", "abbaabbaab", "abbaabbaba", "abbaabbabb", "abbaabbbaa", "abbaabbbab", "abbaabbbba", "abbaabbbbb", "abbabaaaaa", "abbabaaaab", "abbabaaaba", "abbabaaabb", "abbabaabaa", "abbabaabab", "abbabaabba", "abbabaabbb", "abbababaaa", "abbababaab", "abbabababa", "abbabababb", "abbababbaa", "abbababbab", "abbababbba", "abbababbbb", "abbabbaaaa", "abbabbaaab", "abbabbaaba", "abbabbaabb", "abbabbabaa", "abbabbabab", "abbabbabba", "abbabbabbb", "abbabbbaaa", "abbabbbaab", "abbabbbaba", "abbabbbabb", "abbabbbbaa", "abbabbbbab", "abbabbbbba", "abbabbbbbb", "abbbaaaaaa", "abbbaaaaab", "abbbaaaaba", "abbbaaaabb", "abbbaaabaa", "abbbaaabab", "abbbaaabba", "abbbaaabbb", "abbbaabaaa", "abbbaabaab", "abbbaababa", "abbbaababb", "abbbaabbaa", "abbbaabbab", "abbbaabbba", "abbbaabbbb", "abbbabaaaa", "abbbabaaab", "abbbabaaba", "abbbabaabb", "abbbababaa", "abbbababab", "abbbababba", "abbbababbb", "abbbabbaaa", "abbbabbaab", "abbbabbaba", "abbbabbabb", "abbbabbbaa", "abbbabbbab", "abbbabbbba", "abbbabbbbb", "abbbbaaaaa", "abbbbaaaab", "abbbbaaaba", "abbbbaaabb", "abbbbaabaa", "abbbbaabab", "abbbbaabba", "abbbbaabbb", "abbbbabaaa", "abbbbabaab", "abbbbababa", "abbbbababb", "abbbbabbaa", "abbbbabbab", "abbbbabbba", "abbbbabbbb", "abbbbbaaaa", "abbbbbaaab", "abbbbbaaba", "abbbbbaabb", "abbbbbabaa", "abbbbbabab", "abbbbbabba", "abbbbbabbb", "abbbbbbaaa", "abbbbbbaab", "abbbbbbaba", "abbbbbbabb", "abbbbbbbaa", "abbbbbbbab", "abbbbbbbba", "abbbbbbbbb", "baaaaaaaaa", "baaaaaaaab", "baaaaaaaba", "baaaaaaabb", "baaaaaabaa", "baaaaaabab", "baaaaaabba", "baaaaaabbb", "baaaaabaaa", "baaaaabaab", "baaaaababa", "baaaaababb", "baaaaabbaa", "baaaaabbab", "baaaaabbba", "baaaaabbbb", "baaaabaaaa", "baaaabaaab", "baaaabaaba", "baaaabaabb", "baaaababaa", "baaaababab", "baaaababba", "baaaababbb", "baaaabbaaa", "baaaabbaab", "baaaabbaba", "baaaabbabb", "baaaabbbaa", "baaaabbbab", "baaaabbbba", "baaaabbbbb", "baaabaaaaa", "baaabaaaab", "baaabaaaba", "baaabaaabb", "baaabaabaa", "baaabaabab", "baaabaabba", "baaabaabbb", "baaababaaa", "baaababaab", "baaabababa", "baaabababb", "baaababbaa", "baaababbab", "baaababbba", "baaababbbb", "baaabbaaaa", "baaabbaaab", "baaabbaaba", "baaabbaabb", "baaabbabaa", "baaabbabab", "baaabbabba", "baaabbabbb", "baaabbbaaa", "baaabbbaab", "baaabbbaba", "baaabbbabb", "baaabbbbaa", "baaabbbbab", "baaabbbbba", "baaabbbbbb", "baabaaaaaa", "baabaaaaab", "baabaaaaba", "baabaaaabb", "baabaaabaa", "baabaaabab", "baabaaabba", "baabaaabbb", "baabaabaaa", "baabaabaab", "baabaababa", "baabaababb", "baabaabbaa", "baabaabbab", "baabaabbba", "baabaabbbb", "baababaaaa", "baababaaab", "baababaaba", "baababaabb", "baabababaa", "baabababab", "baabababba", "baabababbb", "baababbaaa", "baababbaab", "baababbaba", "baababbabb", "baababbbaa", "baababbbab", "baababbbba", "baababbbbb", "baabbaaaaa", "baabbaaaab", "baabbaaaba", "baabbaaabb", "baabbaabaa", "baabbaabab", "baabbaabba", "baabbaabbb", "baabbabaaa", "baabbabaab", "baabbababa", "baabbababb", "baabbabbaa", "baabbabbab", "baabbabbba", "baabbabbbb", "baabbbaaaa", "baabbbaaab", "baabbbaaba", "baabbbaabb", "baabbbabaa", "baabbbabab", "baabbbabba", "baabbbabbb", "baabbbbaaa", "baabbbbaab", "baabbbbaba", "baabbbbabb", "baabbbbbaa", "baabbbbbab", "baabbbbbba", "baabbbbbbb", "babaaaaaaa", "babaaaaaab", "babaaaaaba", "babaaaaabb", "babaaaabaa", "babaaaabab", "babaaaabba", "babaaaabbb", "babaaabaaa", "babaaabaab", "babaaababa", "babaaababb", "babaaabbaa", "babaaabbab", "babaaabbba", "babaaabbbb", "babaabaaaa", "babaabaaab", "babaabaaba", "babaabaabb", "babaababaa", "babaababab", "babaababba", "babaababbb", "babaabbaaa", "babaabbaab", "babaabbaba", "babaabbabb", "babaabbbaa", "babaabbbab", "babaabbbba", "babaabbbbb", "bababaaaaa", "bababaaaab", "bababaaaba", "bababaaabb", "bababaabaa", "bababaabab", "bababaabba", "bababaabbb", "babababaaa", "babababaab", "bababababa", "bababababb", "babababbaa", "babababbab", "babababbba", "babababbbb", "bababbaaaa", "bababbaaab", "bababbaaba", "bababbaabb", "bababbabaa", "bababbabab", "bababbabba", "bababbabbb", "bababbbaaa", "bababbbaab", "bababbbaba", "bababbbabb", "bababbbbaa", "bababbbbab", "bababbbbba", "bababbbbbb", "babbaaaaaa", "babbaaaaab", "babbaaaaba", "babbaaaabb", "babbaaabaa", "babbaaabab", "babbaaabba", "babbaaabbb", "babbaabaaa", "babbaabaab", "babbaababa", "babbaababb", "babbaabbaa", "babbaabbab", "babbaabbba", "babbaabbbb", "babbabaaaa", "babbabaaab", "babbabaaba", "babbabaabb", "babbababaa", "babbababab", "babbababba", "babbababbb", "babbabbaaa", "babbabbaab", "babbabbaba", "babbabbabb", "babbabbbaa", "babbabbbab", "babbabbbba", "babbabbbbb", "babbbaaaaa", "babbbaaaab", "babbbaaaba", "babbbaaabb", "babbbaabaa", "babbbaabab", "babbbaabba", "babbbaabbb", "babbbabaaa", "babbbabaab", "babbbababa", "babbbababb", "babbbabbaa", "babbbabbab", "babbbabbba", "babbbabbbb", "babbbbaaaa", "babbbbaaab", "babbbbaaba", "babbbbaabb", "babbbbabaa", "babbbbabab", "babbbbabba", "babbbbabbb", "babbbbbaaa", "babbbbbaab", "babbbbbaba", "babbbbbabb", "babbbbbbaa", "babbbbbbab", "babbbbbbba", "babbbbbbbb", "bbaaaaaaaa", "bbaaaaaaab", "bbaaaaaaba", "bbaaaaaabb", "bbaaaaabaa", "bbaaaaabab", "bbaaaaabba", "bbaaaaabbb", "bbaaaabaaa", "bbaaaabaab", "bbaaaababa", "bbaaaababb", "bbaaaabbaa", "bbaaaabbab", "bbaaaabbba", "bbaaaabbbb", "bbaaabaaaa", "bbaaabaaab", "bbaaabaaba", "bbaaabaabb", "bbaaababaa", "bbaaababab", "bbaaababba", "bbaaababbb", "bbaaabbaaa", "bbaaabbaab", "bbaaabbaba", "bbaaabbabb", "bbaaabbbaa", "bbaaabbbab", "bbaaabbbba", "bbaaabbbbb", "bbaabaaaaa", "bbaabaaaab", "bbaabaaaba", "bbaabaaabb", "bbaabaabaa", "bbaabaabab", "bbaabaabba", "bbaabaabbb", "bbaababaaa", "bbaababaab", "bbaabababa", "bbaabababb", "bbaababbaa", "bbaababbab", "bbaababbba", "bbaababbbb", "bbaabbaaaa", "bbaabbaaab", "bbaabbaaba", "bbaabbaabb", "bbaabbabaa", "bbaabbabab", "bbaabbabba", "bbaabbabbb", "bbaabbbaaa", "bbaabbbaab", "bbaabbbaba", "bbaabbbabb", "bbaabbbbaa", "bbaabbbbab", "bbaabbbbba", "bbaabbbbbb", "bbabaaaaaa", "bbabaaaaab", "bbabaaaaba", "bbabaaaabb", "bbabaaabaa", "bbabaaabab", "bbabaaabba", "bbabaaabbb", "bbabaabaaa", "bbabaabaab", "bbabaababa", "bbabaababb", "bbabaabbaa", "bbabaabbab", "bbabaabbba", "bbabaabbbb", "bbababaaaa", "bbababaaab", "bbababaaba", "bbababaabb", "bbabababaa", "bbabababab", "bbabababba", "bbabababbb", "bbababbaaa", "bbababbaab", "bbababbaba", "bbababbabb", "bbababbbaa", "bbababbbab", "bbababbbba", "bbababbbbb", "bbabbaaaaa", "bbabbaaaab", "bbabbaaaba", "bbabbaaabb", "bbabbaabaa", "bbabbaabab", "bbabbaabba", "bbabbaabbb", "bbabbabaaa", "bbabbabaab", "bbabbababa", "bbabbababb", "bbabbabbaa", "bbabbabbab", "bbabbabbba", "bbabbabbbb", "bbabbbaaaa", "bbabbbaaab", "bbabbbaaba", "bbabbbaabb", "bbabbbabaa", "bbabbbabab", "bbabbbabba", "bbabbbabbb", "bbabbbbaaa", "bbabbbbaab", "bbabbbbaba", "bbabbbbabb", "bbabbbbbaa", "bbabbbbbab", "bbabbbbbba", "bbabbbbbbb", "bbbaaaaaaa", "bbbaaaaaab", "bbbaaaaaba", "bbbaaaaabb", "bbbaaaabaa", "bbbaaaabab", "bbbaaaabba", "bbbaaaabbb", "bbbaaabaaa", "bbbaaabaab", "bbbaaababa", "bbbaaababb", "bbbaaabbaa", "bbbaaabbab", "bbbaaabbba", "bbbaaabbbb", "bbbaabaaaa", "bbbaabaaab", "bbbaabaaba", "bbbaabaabb", "bbbaababaa", "bbbaababab", "bbbaababba", "bbbaababbb", "bbbaabbaaa", "bbbaabbaab", "bbbaabbaba", "bbbaabbabb", "bbbaabbbaa", "bbbaabbbab", "bbbaabbbba", "bbbaabbbbb", "bbbabaaaaa", "bbbabaaaab", "bbbabaaaba", "bbbabaaabb", "bbbabaabaa", "bbbabaabab", "bbbabaabba", "bbbabaabbb", "bbbababaaa", "bbbababaab", "bbbabababa", "bbbabababb", "bbbababbaa", "bbbababbab", "bbbababbba", "bbbababbbb", "bbbabbaaaa", "bbbabbaaab", "bbbabbaaba", "bbbabbaabb", "bbbabbabaa", "bbbabbabab", "bbbabbabba", "bbbabbabbb", "bbbabbbaaa", "bbbabbbaab", "bbbabbbaba", "bbbabbbabb", "bbbabbbbaa", "bbbabbbbab", "bbbabbbbba", "bbbabbbbbb", "bbbbaaaaaa", "bbbbaaaaab", "bbbbaaaaba", "bbbbaaaabb", "bbbbaaabaa", "bbbbaaabab", "bbbbaaabba", "bbbbaaabbb", "bbbbaabaaa", "bbbbaabaab", "bbbbaababa", "bbbbaababb", "bbbbaabbaa", "bbbbaabbab", "bbbbaabbba", "bbbbaabbbb", "bbbbabaaaa", "bbbbabaaab", "bbbbabaaba", "bbbbabaabb", "bbbbababaa", "bbbbababab", "bbbbababba", "bbbbababbb", "bbbbabbaaa", "bbbbabbaab", "bbbbabbaba", "bbbbabbabb", "bbbbabbbaa", "bbbbabbbab", "bbbbabbbba", "bbbbabbbbb", "bbbbbaaaaa", "bbbbbaaaab", "bbbbbaaaba", "bbbbbaaabb", "bbbbbaabaa", "bbbbbaabab", "bbbbbaabba", "bbbbbaabbb", "bbbbbabaaa", "bbbbbabaab", "bbbbbababa", "bbbbbababb", "bbbbbabbaa", "bbbbbabbab", "bbbbbabbba", "bbbbbabbbb", "bbbbbbaaaa", "bbbbbbaaab", "bbbbbbaaba", "bbbbbbaabb", "bbbbbbabaa", "bbbbbbabab", "bbbbbbabba", "bbbbbbabbb", "bbbbbbbaaa", "bbbbbbbaab", "bbbbbbbaba", "bbbbbbbabb", "bbbbbbbbaa", "bbbbbbbbab", "bbbbbbbbba", "bbbbbbbbbb"}, + }, + + { + "a{b,c}{d,e}f{g,h},z", + []string{"abdfg", "abdfh", "abefg", "abefh", "acdfg", "acdfh", "acefg", "acefh", "z"}, + }, + + { + "{{a,b},{b,c}}", + []string{"a", "b", "c"}, + }, + + { + "a", + []string{"a"}, + }, + + { + "w", + []string{"w"}, + }, + + { + "{a,b,c}", + []string{"a", "b", "c"}, + }, + + { + "{a,b}{c,d}", + []string{"ac", "ad", "bc", "bd"}, + }, + + { + "a{b,c}{d,e}f{g,h}", + []string{"abdfg", "abdfh", "abefg", "abefh", "acdfg", "acdfh", "acefg", "acefh"}, + }, + + { + "ab{{{c}}}", + []string{"abc"}, + }, + + { + "{a,b}{c,{d,e}}", + []string{"ac", "ad", "ae", "bc", "bd", "be"}, + }, + + { + "{{a,z},a{b,c},{ab,z}}", + []string{"a", "ab", "ac", "z"}, + }, + + // 可以有多个 testcase +} + +func Test_braceExpansionII(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, braceExpansionII(tc.expression), "输入:%v", tc) + } +} + +func Benchmark_braceExpansionII(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + braceExpansionII(tc.expression) + } + } +} diff --git a/Algorithms/1103.distribute-candies-to-people/README.md b/Algorithms/1103.distribute-candies-to-people/README.md new file mode 100755 index 000000000..06394685d --- /dev/null +++ b/Algorithms/1103.distribute-candies-to-people/README.md @@ -0,0 +1,40 @@ +# [1103. Distribute Candies to People](https://leetcode.com/problems/distribute-candies-to-people/) + +We distribute some number of candies, to a row of n = num_people people in the following way: + +We then give 1 candy to the first person, 2 candies to the second person, and so on until we give n candies to the last person. + +Then, we go back to the start of the row, giving n + 1 candies to the first person, n + 2 candies to the second person, and so on until we give 2 * n candies to the last person. + +This process repeats (with us giving one more candy each time, and moving to the start of the row after we reach the end) until we run out of candies. The last person will receive all of our remaining candies (not necessarily one more than the previous gift). + +Return an array (of length num_people and sum candies) that represents the final distribution of candies. + +Example 1: + +```text +Input: candies = 7, num_people = 4 +Output: [1,2,3,1] +Explanation: +On the first turn, ans[0] += 1, and the array is [1,0,0,0]. +On the second turn, ans[1] += 2, and the array is [1,2,0,0]. +On the third turn, ans[2] += 3, and the array is [1,2,3,0]. +On the fourth turn, ans[3] += 1 (because there is only one candy left), and the final array is [1,2,3,1]. +``` + +Example 2: + +```text +Input: candies = 10, num_people = 3 +Output: [5,2,3] +Explanation: +On the first turn, ans[0] += 1, and the array is [1,0,0]. +On the second turn, ans[1] += 2, and the array is [1,2,0]. +On the third turn, ans[2] += 3, and the array is [1,2,3]. +On the fourth turn, ans[0] += 4, and the final array is [5,2,3]. +``` + +Constraints: + +1. `1 <= candies <= 10^9` +1. `1 <= num_people <= 1000` diff --git a/Algorithms/1103.distribute-candies-to-people/distribute-candies-to-people.go b/Algorithms/1103.distribute-candies-to-people/distribute-candies-to-people.go new file mode 100755 index 000000000..f2f53a500 --- /dev/null +++ b/Algorithms/1103.distribute-candies-to-people/distribute-candies-to-people.go @@ -0,0 +1,34 @@ +package problem1103 + +import "math" + +func distributeCandies(candies, people int) []int { + res := make([]int, people) + + k := root(candies) + + // res[i] = (i+1) + (i+1+p) + (i+1+p*2) + ... + (i+1+n*p) + // n = (k-i-1)/p , p = people + candiesOf := func(i int) int { + c0 := i + 1 + n := (k - c0) / people + cn := c0 + n*people + return (n + 1) * (c0 + cn) / 2 + } + + // i= 0 { + res[i] = label + label = sum - label/2 + sum /= 2 + i-- + } + return res +} diff --git a/Algorithms/1104.path-in-zigzag-labelled-binary-tree/path-in-zigzag-labelled-binary-tree_test.go b/Algorithms/1104.path-in-zigzag-labelled-binary-tree/path-in-zigzag-labelled-binary-tree_test.go new file mode 100755 index 000000000..2b454b03e --- /dev/null +++ b/Algorithms/1104.path-in-zigzag-labelled-binary-tree/path-in-zigzag-labelled-binary-tree_test.go @@ -0,0 +1,42 @@ +package problem1104 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + label int + ans []int +}{ + + { + 14, + []int{1, 3, 4, 14}, + }, + + { + 26, + []int{1, 2, 6, 10, 26}, + }, + + // 可以有多个 testcase +} + +func Test_pathInZigZagTree(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, pathInZigZagTree(tc.label), "输入:%v", tc) + } +} + +func Benchmark_pathInZigZagTree(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + pathInZigZagTree(tc.label) + } + } +} diff --git a/Algorithms/1104.path-in-zigzag-labelled-binary-tree/tree.png b/Algorithms/1104.path-in-zigzag-labelled-binary-tree/tree.png new file mode 100644 index 000000000..50408e518 Binary files /dev/null and b/Algorithms/1104.path-in-zigzag-labelled-binary-tree/tree.png differ diff --git a/Algorithms/1105.filling-bookcase-shelves/1105.png b/Algorithms/1105.filling-bookcase-shelves/1105.png new file mode 100644 index 000000000..897d408ce Binary files /dev/null and b/Algorithms/1105.filling-bookcase-shelves/1105.png differ diff --git a/Algorithms/1105.filling-bookcase-shelves/README.md b/Algorithms/1105.filling-bookcase-shelves/README.md new file mode 100755 index 000000000..3cfc032f1 --- /dev/null +++ b/Algorithms/1105.filling-bookcase-shelves/README.md @@ -0,0 +1,29 @@ +# [1105. Filling Bookcase Shelves](https://leetcode.com/problems/filling-bookcase-shelves/) + +We have a sequence of books: the i-th book has thickness books[i][0] and height books[i][1]. + +We want to place these books in order onto bookcase shelves that have total width shelf_width. + +We choose some of the books to place on this shelf (such that the sum of their thickness is <= shelf_width), then build another level of shelf of the bookcase so that the total height of the bookcase has increased by the maximum height of the books we just put down. We repeat this process until there are no more books to place. + +Note again that at each step of the above process, __the order of the books we place is the same order as the given sequence of books.__ For example, if we have an ordered list of 5 books, we might place the first and second book onto the first shelf, the third book on the second shelf, and the fourth and fifth book on the last shelf. + +Return the minimum possible height that the total bookshelf can be after placing shelves in this manner. + +Example 1: + +![1105](1105.png) + +```text +Input: books = [[1,1],[2,3],[2,3],[1,1],[1,1],[1,1],[1,2]], shelf_width = 4 +Output: 6 +Explanation: +The sum of the heights of the 3 shelves are 1 + 3 + 2 = 6. +Notice that book number 2 does not have to be on the first shelf. +``` + +Constraints: + +1. `1 <= books.length <= 1000` +1. `1 <= books[i][0] <= shelf_width <= 1000` +1. `1 <= books[i][1] <= 1000` diff --git a/Algorithms/1105.filling-bookcase-shelves/filling-bookcase-shelves.go b/Algorithms/1105.filling-bookcase-shelves/filling-bookcase-shelves.go new file mode 100755 index 000000000..1d7bc14d6 --- /dev/null +++ b/Algorithms/1105.filling-bookcase-shelves/filling-bookcase-shelves.go @@ -0,0 +1,37 @@ +package problem1105 + +func minHeightShelves(books [][]int, width int) int { + m := len(books) + dp := make([]int, m+1) + + for i := 1; i <= m; i++ { + dp[i] = 1000000 + k := 1 + w, h := books[i-k][0], books[i-k][1] + for w <= width { + dp[i] = min(dp[i], dp[i-k]+h) + k++ + if i-k < 0 { + break + } + w += books[i-k][0] + h = max(h, books[i-k][1]) + } + } + + return dp[m] +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1105.filling-bookcase-shelves/filling-bookcase-shelves_test.go b/Algorithms/1105.filling-bookcase-shelves/filling-bookcase-shelves_test.go new file mode 100755 index 000000000..28c3c8cf3 --- /dev/null +++ b/Algorithms/1105.filling-bookcase-shelves/filling-bookcase-shelves_test.go @@ -0,0 +1,45 @@ +package problem1105 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + books [][]int + shelfWidth int + ans int +}{ + + { + [][]int{{1, 1}, {3, 3}, {2, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 2}}, + 4, + 8, + }, + + { + [][]int{{1, 1}, {2, 3}, {2, 3}, {1, 1}, {1, 1}, {1, 1}, {1, 2}}, + 4, + 6, + }, + + // 可以有多个 testcase +} + +func Test_minHeightShelves(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, minHeightShelves(tc.books, tc.shelfWidth), "输入:%v", tc) + } +} + +func Benchmark_minHeightShelves(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minHeightShelves(tc.books, tc.shelfWidth) + } + } +} diff --git a/Algorithms/1106.parsing-a-boolean-expression/README.md b/Algorithms/1106.parsing-a-boolean-expression/README.md new file mode 100755 index 000000000..e26307bb2 --- /dev/null +++ b/Algorithms/1106.parsing-a-boolean-expression/README.md @@ -0,0 +1,45 @@ +# [1106. Parsing A Boolean Expression](https://leetcode.com/problems/parsing-a-boolean-expression/) + +Return the result of evaluating a given boolean expression, represented as a string. + +An expression can either be: + +- "t", evaluating to True; +- "f", evaluating to False; +- "!(expr)", evaluating to the logical NOT of the inner expression expr; +- "&(expr1,expr2,...)", evaluating to the logical AND of 2 or more inner expressions expr1, expr2, ...; +- "|(expr1,expr2,...)", evaluating to the logical OR of 2 or more inner expressions expr1, expr2, ... + +Example 1: + +```text +Input: expression = "!(f)" +Output: true +``` + +Example 2: + +```text +Input: expression = "|(f,t)" +Output: true +``` + +Example 3: + +```text +Input: expression = "&(t,f)" +Output: false +``` + +Example 4: + +```text +Input: expression = "|(&(t,f,t),!(t))" +Output: false +``` + +Constraints: + +- 1 <= expression.length <= 20000 +- expression[i] consists of characters in {'(', ')', '&', '|', '!', 't', 'f', ','}. +- expression is a valid expression representing a boolean, as given in the description. diff --git a/Algorithms/1106.parsing-a-boolean-expression/parsing-a-boolean-expression.go b/Algorithms/1106.parsing-a-boolean-expression/parsing-a-boolean-expression.go new file mode 100755 index 000000000..f9dd4264c --- /dev/null +++ b/Algorithms/1106.parsing-a-boolean-expression/parsing-a-boolean-expression.go @@ -0,0 +1,63 @@ +package problem1106 + +import "strings" + +func parseBoolExpr(exp string) bool { + if exp == "t" || exp == "f" { + return exp == "t" + } + n := len(exp) + op, exp := exp[0], exp[2:n-1] + switch op { + case '&': + return and(split(exp)) + case '|': + return or(split(exp)) + default: // ! + return not(exp) + } +} + +func split(exp string) []string { + count := 0 + isUnbracketed := func() bool { + return count == 0 + } + bytes := []byte(exp) + for i, b := range bytes { + switch b { + case '(': + count++ + case ')': + count-- + case ',': + if isUnbracketed() { + bytes[i] = '@' + } + } + } + exp = string(bytes) + return strings.Split(exp, "@") +} + +func and(exps []string) bool { + for _, e := range exps { + if !parseBoolExpr(e) { + return false + } + } + return true +} + +func or(exps []string) bool { + for _, e := range exps { + if parseBoolExpr(e) { + return true + } + } + return false +} + +func not(exp string) bool { + return !parseBoolExpr(exp) +} diff --git a/Algorithms/1106.parsing-a-boolean-expression/parsing-a-boolean-expression_test.go b/Algorithms/1106.parsing-a-boolean-expression/parsing-a-boolean-expression_test.go new file mode 100755 index 000000000..7684b67d1 --- /dev/null +++ b/Algorithms/1106.parsing-a-boolean-expression/parsing-a-boolean-expression_test.go @@ -0,0 +1,67 @@ +package problem1106 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + expression string + ans bool +}{ + + { + "&(&(&(&(!(&(!(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t)))),&(&(!(t),!(|(f,f,t)),!(&(f))),!(|(f,f,t)),&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),!(t))),&(&(t,t,f),&(&(&(t,t,f),|(f,f,t),|(f)),&(&(!(&(f)),&(t),|(f,f,t)),&(t),&(t,t,f)),&(t,t,f)),!(&(&(t),&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)))),&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))))))),!(!(&(&(!(t),!(|(f,f,t)),!(&(f))),&(t),!(&(&(t),&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)))),&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t)))))))))),!(&(&(!(&(f)),&(t),|(f,f,t)),&(t),&(t,t,f))),&(&(!(t),!(|(f,f,t)),!(&(f))),!(&(f)),&(!(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t)))),&(&(!(t),!(|(f,f,t)),!(&(f))),!(|(f,f,t)),&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),!(t)))),!(!(&(&(!(&(f)),&(t),|(f,f,t)),&(t),&(t,t,f)))),!(&(!(&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t))))),!(!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t)))),&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f))))),&(!(&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))))),&(!(!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t)))),&(!(&(f)),&(t),|(f,f,t)),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)))),&(&(!(&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t))))),!(!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t)))),&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f))),&(!(&(!(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t)))),&(&(!(t),!(|(f,f,t)),!(&(f))),!(|(f,f,t)),&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),!(t))),&(&(t,t,f),&(&(&(t,t,f),|(f,f,t),|(f)),&(&(!(&(f)),&(t),|(f,f,t)),&(t),&(t,t,f)),&(t,t,f)),!(&(&(t),&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)))),&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))))))),!(!(&(&(!(t),!(|(f,f,t)),!(&(f))),&(t),!(&(&(t),&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)))),&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t)))))))))),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))))),&(&(&(!(t),!(|(f,f,t)),!(&(f))),!(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t)))),&(!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(!(&(f)),&(t),|(f,f,t)),|(t),|(f,f,t)),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))))),&(!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(!(&(&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t,t,f),&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))))),&(t,t,f),&(!(!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t)))),&(!(&(f)),&(t),|(f,f,t)),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t))))),!(&(&(!(&(f)),&(t),|(f,f,t)),&(t),&(t,t,f))),&(f))),!(&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))))),&(&(f),!(&(t)),&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(!(|(f,f,t))),&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f))))),&(&(!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),!(!(&(f))),&(!(t),&(f),|(f))),!(&(&(!(&(f)),&(t),|(f,f,t)),|(t),|(f,f,t))),&(!(&(t)),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t))),!(&(f))))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)))))", + false, + }, + + { + "&(&(|(f),&(&(&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)),&(&(t),&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)))),&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))))),&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f))),!(&(f)),&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t)))),!(!(&(&(t,t,f),|(f,f,t),|(f)))),&(&(t),&(&(&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))),&(&(&(!(&(f)),|(t),&(!(t),!(|(f,f,t)),!(&(f)))),!(|(f,f,t)),&(t,t,f)),&(f),&(&(t),&(!(t),!(|(f,f,t)),!(&(f))),|(f,f,t)))),&(&(&(t,t,f),|(f,f,t),|(f)),!(&(t)),!(&(|(f,f,t),&(&(f),&(!(t),&(f),|(f)),&(!(&(f)),&(t),|(f,f,t))),&(t))))))", + false, + }, + + { + "!(f)", + true, + }, + + { + "|(f,t)", + true, + }, + + { + "&(t,t,t,t,t,t)", + true, + }, + + { + "&(t,f)", + false, + }, + + { + "|(&(t,f,t),!(t))", + false, + }, + + // 可以有多个 testcase +} + +func Test_parseBoolExpr(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, parseBoolExpr(tc.expression), "输入:%v", tc) + } +} + +func Benchmark_parseBoolExpr(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + parseBoolExpr(tc.expression) + } + } +} diff --git a/Algorithms/1108.defanging-an-ip-address/README.md b/Algorithms/1108.defanging-an-ip-address/README.md new file mode 100755 index 000000000..01335c8f3 --- /dev/null +++ b/Algorithms/1108.defanging-an-ip-address/README.md @@ -0,0 +1,23 @@ +# [1108. Defanging an IP Address](https://leetcode.com/problems/defanging-an-ip-address/) + +Given a valid (IPv4) IP address, return a defanged version of that IP address. + +A defanged IP address replaces every period "." with "[.]". + +Example 1: + +```text +Input: address = "1.1.1.1" +Output: "1[.]1[.]1[.]1" +``` + +Example 2: + +```text +Input: address = "255.100.50.0" +Output: "255[.]100[.]50[.]0" +``` + +Constraints: + +1. The given address is a valid IPv4 address. diff --git a/Algorithms/1108.defanging-an-ip-address/defanging-an-ip-address.go b/Algorithms/1108.defanging-an-ip-address/defanging-an-ip-address.go new file mode 100755 index 000000000..e9f3b887d --- /dev/null +++ b/Algorithms/1108.defanging-an-ip-address/defanging-an-ip-address.go @@ -0,0 +1,7 @@ +package problem1108 + +import "strings" + +func defangIPaddr(address string) string { + return strings.Replace(address, ".", "[.]", -1) +} diff --git a/Algorithms/1108.defanging-an-ip-address/defanging-an-ip-address_test.go b/Algorithms/1108.defanging-an-ip-address/defanging-an-ip-address_test.go new file mode 100755 index 000000000..f027ea13a --- /dev/null +++ b/Algorithms/1108.defanging-an-ip-address/defanging-an-ip-address_test.go @@ -0,0 +1,42 @@ +package problem1108 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + address string + ans string +}{ + + { + "1.1.1.1", + "1[.]1[.]1[.]1", + }, + + { + "255.100.50.0", + "255[.]100[.]50[.]0", + }, + + // 可以有多个 testcase +} + +func Test_defangIPaddr(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, defangIPaddr(tc.address), "输入:%v", tc) + } +} + +func Benchmark_defangIPaddr(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + defangIPaddr(tc.address) + } + } +} diff --git a/Algorithms/1109.corporate-flight-bookings/README.md b/Algorithms/1109.corporate-flight-bookings/README.md new file mode 100755 index 000000000..dd7df9308 --- /dev/null +++ b/Algorithms/1109.corporate-flight-bookings/README.md @@ -0,0 +1,20 @@ +# [1109. Corporate Flight Bookings](https://leetcode.com/problems/corporate-flight-bookings/) + +There are n flights, and they are labeled from 1 to n. + +We have a list of flight bookings. The i-th booking bookings[i] = [i, j, k] means that we booked k seats from flights labeled i to j inclusive. + +Return an array answer of length n, representing the number of seats booked on each flight in order of their label. + +Example 1: + +```text +Input: bookings = [[1,2,10],[2,3,20],[2,5,25]], n = 5 +Output: [10,55,45,25,25] +``` + +Constraints: + +- `1 <= bookings.length <= 20000` +- `1 <= bookings[i][0] <= bookings[i][1] <= n <= 20000` +- `1 <= bookings[i][2] <= 10000` diff --git a/Algorithms/1109.corporate-flight-bookings/corporate-flight-bookings.go b/Algorithms/1109.corporate-flight-bookings/corporate-flight-bookings.go new file mode 100755 index 000000000..04462739f --- /dev/null +++ b/Algorithms/1109.corporate-flight-bookings/corporate-flight-bookings.go @@ -0,0 +1,16 @@ +package problem1109 + +func corpFlightBookings(bookings [][]int, n int) []int { + res := make([]int, n+1) + for _, b := range bookings { + i, j, k := b[0], b[1], b[2] + res[i-1] += k + res[j] -= k + } + + for i := 1; i < n; i++ { + res[i] += res[i-1] + } + + return res[:n] +} diff --git a/Algorithms/1109.corporate-flight-bookings/corporate-flight-bookings_test.go b/Algorithms/1109.corporate-flight-bookings/corporate-flight-bookings_test.go new file mode 100755 index 000000000..ca4092a2d --- /dev/null +++ b/Algorithms/1109.corporate-flight-bookings/corporate-flight-bookings_test.go @@ -0,0 +1,39 @@ +package problem1109 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + bookings [][]int + n int + ans []int +}{ + + { + [][]int{{1, 2, 10}, {2, 3, 20}, {2, 5, 25}}, + 5, + []int{10, 55, 45, 25, 25}, + }, + + // 可以有多个 testcase +} + +func Test_corpFlightBookings(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, corpFlightBookings(tc.bookings, tc.n), "输入:%v", tc) + } +} + +func Benchmark_corpFlightBookings(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + corpFlightBookings(tc.bookings, tc.n) + } + } +} diff --git a/Algorithms/1110.delete-nodes-and-return-forest/1.png b/Algorithms/1110.delete-nodes-and-return-forest/1.png new file mode 100644 index 000000000..385bb25aa Binary files /dev/null and b/Algorithms/1110.delete-nodes-and-return-forest/1.png differ diff --git a/Algorithms/1110.delete-nodes-and-return-forest/README.md b/Algorithms/1110.delete-nodes-and-return-forest/README.md new file mode 100755 index 000000000..06532c32a --- /dev/null +++ b/Algorithms/1110.delete-nodes-and-return-forest/README.md @@ -0,0 +1,23 @@ +# [1110. Delete Nodes And Return Forest](https://leetcode.com/problems/delete-nodes-and-return-forest/) + +Given the root of a binary tree, each node in the tree has a distinct value. + +After deleting all nodes with a value in to_delete, we are left with a forest (a disjoint union of trees). + +Return the roots of the trees in the remaining forest. You may return the result in any order. + +Example 1: + +![1](1.png) + +```text +Input: root = [1,2,3,4,5,6,7], to_delete = [3,5] +Output: [[1,2,null,4],[6],[7]] +``` + +Constraints: + +- The number of nodes in the given tree is at most 1000. +- Each node has a distinct value between 1 and 1000. +- to_delete.length <= 1000 +- to_delete contains distinct values between 1 and 1000. diff --git a/Algorithms/1110.delete-nodes-and-return-forest/delete-nodes-and-return-forest.go b/Algorithms/1110.delete-nodes-and-return-forest/delete-nodes-and-return-forest.go new file mode 100755 index 000000000..fe34366f6 --- /dev/null +++ b/Algorithms/1110.delete-nodes-and-return-forest/delete-nodes-and-return-forest.go @@ -0,0 +1,49 @@ +package problem1110 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined +type TreeNode = kit.TreeNode + +func delNodes(root *TreeNode, delete []int) []*TreeNode { + newRoot := &TreeNode{ + Val: 0, + Left: root, + } + + isDeleted := [10001]bool{} + isDeleted[0] = true + for _, d := range delete { + isDeleted[d] = true + } + + res := make([]*TreeNode, 0, 1000) + + var dfs func(*TreeNode) *TreeNode + dfs = func(node *TreeNode) *TreeNode { + if node == nil { + return nil + } + // + node.Left = dfs(node.Left) + node.Right = dfs(node.Right) + // + if !isDeleted[node.Val] { + return node + } + // + if node.Left != nil { + res = append(res, node.Left) + } + // + if node.Right != nil { + res = append(res, node.Right) + } + // + return nil + } + + dfs(newRoot) + + return res +} diff --git a/Algorithms/1110.delete-nodes-and-return-forest/delete-nodes-and-return-forest_test.go b/Algorithms/1110.delete-nodes-and-return-forest/delete-nodes-and-return-forest_test.go new file mode 100755 index 000000000..3708fc855 --- /dev/null +++ b/Algorithms/1110.delete-nodes-and-return-forest/delete-nodes-and-return-forest_test.go @@ -0,0 +1,47 @@ +package problem1110 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + delete []int + ans [][]int +}{ + + { + []int{1, 2, 3, 4, 5, 6, 7}, + []int{3, 5}, + [][]int{{6}, {7}, {1, 2, kit.NULL, 4}}, + }, + + // 可以有多个 testcase +} + +func Test_delNodes(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + tmps := delNodes(root, tc.delete) + ans := make([][]int, len(tmps)) + for i, t := range tmps { + ans[i] = kit.Tree2ints(t) + } + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_delNodes(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + delNodes(root, tc.delete) + } + } +} diff --git a/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/README.md b/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/README.md new file mode 100755 index 000000000..d60e9c5c1 --- /dev/null +++ b/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/README.md @@ -0,0 +1,39 @@ +# [1111. Maximum Nesting Depth of Two Valid Parentheses Strings](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/) + +A string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and: + +- It is the empty string, or +- It can be written as AB (A concatenated with B), where A and B are VPS's, or +- It can be written as (A), where A is a VPS. + +We can similarly define the nesting depth depth(S) of any VPS S as follows: + +- depth("") = 0 +- depth(A + B) = max(depth(A), depth(B)), where A and B are VPS's +- depth("(" + A + ")") = 1 + depth(A), where A is a VPS. + +For example, "", "()()", and "()(()())" are VPS's (with nesting depths 0, 1, and 2), and ")(" and "(()" are not VPS's. + +Given a VPS seq, split it into two disjoint subsequences A and B, such that A and B are VPS's (and A.length + B.length = seq.length). + +Now choose any such A and B such that max(depth(A), depth(B)) is the minimum possible value. + +Return an answer array (of length seq.length) that encodes such a choice of A and B: answer[i] = 0 if seq[i] is part of A, else answer[i] = 1. Note that even though multiple answers may exist, you may return any of them. + +Example 1: + +```text +Input: seq = "(()())" +Output: [0,1,1,1,1,0] +``` + +Example 2: + +```text +Input: seq = "()(())()" +Output: [0,0,0,1,1,0,1,1] +``` + +Constraints: + +- `1 <= seq.size <= 10000` diff --git a/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/maximum-nesting-depth-of-two-valid-parentheses-strings.go b/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/maximum-nesting-depth-of-two-valid-parentheses-strings.go new file mode 100755 index 000000000..c537aab73 --- /dev/null +++ b/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/maximum-nesting-depth-of-two-valid-parentheses-strings.go @@ -0,0 +1,16 @@ +package problem1111 + +func maxDepthAfterSplit(seq string) []int { + res := make([]int, len(seq)) + stack, top := make([]int, len(seq)), -1 + for i, r := range seq { + if r == '(' { + top++ + stack[top], res[i] = i, top%2 + } else { + res[i] = res[stack[top]] + top-- + } + } + return res +} diff --git a/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/maximum-nesting-depth-of-two-valid-parentheses-strings_test.go b/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/maximum-nesting-depth-of-two-valid-parentheses-strings_test.go new file mode 100755 index 000000000..9d533ff08 --- /dev/null +++ b/Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings/maximum-nesting-depth-of-two-valid-parentheses-strings_test.go @@ -0,0 +1,42 @@ +package problem1111 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + seq string + ans []int +}{ + + { + "(()())", + []int{0, 1, 1, 1, 1, 0}, + }, + + { + "()(())()", + []int{0, 0, 0, 1, 1, 0, 0, 0}, + }, + + // 可以有多个 testcase +} + +func Test_maxDepthAfterSplit(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxDepthAfterSplit(tc.seq), "输入:%v", tc) + } +} + +func Benchmark_maxDepthAfterSplit(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxDepthAfterSplit(tc.seq) + } + } +} diff --git a/Algorithms/1122.relative-sort-array/README.md b/Algorithms/1122.relative-sort-array/README.md new file mode 100755 index 000000000..d5ee6bd0e --- /dev/null +++ b/Algorithms/1122.relative-sort-array/README.md @@ -0,0 +1,19 @@ +# [1122. Relative Sort Array](https://leetcode.com/problems/relative-sort-array/) + +Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. + +Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that don't appear in arr2 should be placed at the end of arr1 in ascending order. + +Example 1: + +```text +Input: arr1 = [2,3,1,3,2,4,6,7,9,2,19], arr2 = [2,1,4,3,9,6] +Output: [2,2,2,1,4,3,3,9,6,7,19] +``` + +Constraints: + +- `arr1.length, arr2.length <= 1000` +- `0 <= arr1[i], arr2[i] <= 1000` +- `Each arr2[i] is distinct.` +- `Each arr2[i] is in arr1.` diff --git a/Algorithms/1122.relative-sort-array/relative-sort-array.go b/Algorithms/1122.relative-sort-array/relative-sort-array.go new file mode 100755 index 000000000..fb07ff0cc --- /dev/null +++ b/Algorithms/1122.relative-sort-array/relative-sort-array.go @@ -0,0 +1,24 @@ +package problem1122 + +func relativeSortArray(A, B []int) []int { + count := [1001]int{} + for _, a := range A { + count[a]++ + } + + res := make([]int, 0, len(A)) + for _, b := range B { + for count[b] > 0 { + res = append(res, b) + count[b]-- + } + } + for i := 0; i < 1001; i++ { + for count[i] > 0 { + res = append(res, i) + count[i]-- + } + } + + return res +} diff --git a/Algorithms/1122.relative-sort-array/relative-sort-array_test.go b/Algorithms/1122.relative-sort-array/relative-sort-array_test.go new file mode 100755 index 000000000..2ef8b13c1 --- /dev/null +++ b/Algorithms/1122.relative-sort-array/relative-sort-array_test.go @@ -0,0 +1,45 @@ +package problem1122 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + arr1 []int + arr2 []int + ans []int +}{ + + { + []int{940, 779, 194, 460, 545, 15, 143, 228, 733, 274, 652, 234, 831, 932, 939, 378, 159, 824, 614, 152, 989, 256, 919, 133, 922, 491, 208, 702, 503, 305, 906, 259, 346, 535, 683, 657, 929, 775, 384, 787, 966, 199, 623, 93, 507, 108, 643, 456, 897, 394, 628, 529, 277, 190, 438, 837, 341, 631, 988, 409, 629, 540, 98, 863, 678, 845, 452, 156, 600, 77, 360, 347, 522, 221, 325, 949, 162, 810, 688, 892, 665, 734, 475, 209, 816, 636, 421, 374, 792, 499, 386, 213, 442, 977, 310, 367, 379, 671, 626, 243, 482, 513, 128, 541, 705, 297, 290, 649, 265, 289, 762, 302, 418, 759, 204, 331, 288, 260, 389, 195, 60, 765, 107, 763, 441, 106, 743, 595, 461, 299, 616, 68, 19, 909, 978, 230, 925, 605, 27, 856, 180, 771, 361, 12, 911, 800, 655, 574, 3, 834, 6, 313, 84, 236, 923, 524, 884, 562, 86, 684, 757, 520, 927, 891, 240, 385, 565, 75, 33, 437, 1000, 537, 492, 607, 139, 877, 67, 53, 191, 263, 376, 741, 24, 487, 21, 687, 292, 92, 801, 161, 183, 716, 822, 231, 672, 189, 90, 343, 566, 8, 345, 865, 16, 560, 166, 575, 275, 878, 812, 739, 18, 531, 451, 171, 330, 679, 321, 89, 836, 550, 314, 425, 729, 309, 868, 916, 262, 176, 692, 711, 695, 797, 381, 375, 212, 814, 153, 366, 589, 690, 419, 738, 168, 337, 601, 899, 914, 453, 745, 145, 480, 23, 47, 510, 844, 71, 848, 114, 669, 157, 673, 591, 872, 205, 658, 774, 501, 323, 653, 606, 542, 434, 272, 901, 383, 39, 990, 728, 87, 693, 268, 890, 364, 70, 196, 617, 553, 766, 782, 273, 342, 188, 319, 704, 694, 584, 178, 430, 610, 650, 789, 903, 637, 455, 144, 536, 449, 339, 770, 777, 109, 724, 760, 737, 564, 250, 498, 284, 397, 357, 559, 829, 630, 594, 663, 353, 120, 618, 938, 767, 862, 577, 817, 276, 311, 576, 751, 28, 432, 833, 225, 468, 956, 710, 583, 5, 538, 363, 187, 700, 850, 502, 283, 459, 14, 981, 202, 484, 37, 422, 937, 736, 888, 490, 613, 373, 136, 568, 943, 344, 680, 900, 985, 995, 511, 44, 233, 134, 975, 883, 338, 497, 61, 905, 867, 110, 398, 917, 0, 298, 185, 644, 997, 244, 846, 137, 802, 926, 223, 62, 226, 315, 615, 138, 854, 852, 857, 725, 656, 703, 586, 744, 783, 318, 847, 301, 674, 219, 448, 48, 181, 882, 963, 20, 549, 116, 457, 602, 945, 111, 80, 586, 433, 184, 835, 991, 676, 181, 417, 944, 750, 494, 100, 640, 843, 963, 783, 819, 571, 670, 886, 493, 182, 796, 371, 933, 248, 639, 924, 706, 443, 635, 264, 611, 772, 875, 131, 755, 838, 387, 950, 660, 504, 662, 786, 76, 151, 206, 192, 349, 119, 295, 902, 124, 294, 532, 116, 329, 135, 63, 596, 971, 91, 286, 912, 698, 509, 72, 962, 994, 426, 95, 411, 151, 668, 980, 974, 474, 500, 555, 509, 830, 621, 783, 793, 898, 446, 640, 489, 556, 772, 201, 942, 113, 533, 619, 791, 552, 746, 675, 942, 251, 708, 908, 740, 521, 952, 380, 141, 554, 420, 494, 404, 676, 439, 619, 593, 668, 795, 942, 963, 279, 624, 380, 958, 224, 457, 172, 388, 764, 182, 454, 1, 151, 747, 970, 222, 130, 790, 983, 348, 332, 286, 840, 467, 388, 251, 811, 811, 11, 855, 718, 135, 718, 612, 462, 226, 372, 173, 828, 597, 640, 861, 40, 504, 962, 744, 543, 887, 509, 450, 830, 326, 329, 242, 532, 46, 192, 13, 436, 450, 241, 746, 436, 138, 556, 667, 561, 732, 570, 854, 539, 306, 10, 102, 445, 753, 740, 880, 224, 56, 795, 428, 101, 413, 586, 835, 973, 332, 348, 42, 132, 380, 291, 186, 382, 935, 885, 117, 112, 869, 115, 216, 485, 769, 732, 141, 596, 349, 462, 473, 731, 707, 410, 65, 838, 414, 355, 992, 570, 662, 790, 201, 95, 622, 795, 670, 206, 258, 811, 182, 281, 165, 572, 970, 352, 632, 968, 500, 232, 135, 795, 362, 755, 979, 116, 247, 847, 902, 744, 124, 924, 402, 428, 239, 29, 723, 13, 864, 65, 698, 805, 567, 785, 270, 910, 35, 526, 51, 406, 718, 307, 316, 13, 835, 588, 219, 320, 203, 908, 748, 443, 141, 612, 404, 160, 270, 982, 720, 193, 879, 849, 732, 962, 154, 181, 392, 886, 91, 252, 76, 681, 572, 876, 677, 328, 457, 951, 26, 880, 876, 252, 588, 457, 229, 426, 388, 721, 295, 481, 967, 934, 103, 308, 293, 326, 123, 76, 463, 715, 563, 993, 962, 296, 961, 94, 881, 151, 706, 179, 749, 660, 46, 544, 72, 443, 85, 715, 786, 278}, + []int{61, 153, 262, 606, 917, 434, 47, 409, 190, 899, 166, 503, 183, 156, 694, 911, 24, 765, 451, 244, 234, 480, 375, 438, 16, 290, 653, 511, 498, 814, 834, 128, 367, 688, 344, 501, 739, 339, 702, 687, 385, 939, 268, 27, 176, 468, 833, 204, 607, 421, 817, 87, 777, 824, 484, 724, 92, 455, 452, 692, 243, 779, 535, 789, 360, 628, 430, 679, 18, 460, 265, 600, 800, 8, 274, 644, 836, 196, 529, 774, 314, 575, 338, 977, 614, 110, 831, 381, 325, 995, 771, 613, 187, 848, 865, 273, 364, 39, 502, 705, 84, 845, 905, 704, 134, 292, 311, 925, 497, 671, 67, 566, 114, 693, 610, 510, 379, 975, 741, 762, 93, 213, 901, 678, 695, 751, 230, 492, 892, 212, 283, 161, 323, 536, 700, 914, 760, 297, 342, 309, 490, 6, 932, 792, 923, 199, 846, 345, 376, 816, 337, 331, 770, 98, 23, 862, 108, 711, 374, 966, 812, 649, 728, 617, 277, 903, 383, 194, 956, 574, 137, 595, 766, 185, 289, 168, 672, 346, 937, 856, 145, 658, 763, 343, 33, 171, 631, 545, 906, 542, 397, 900, 144, 456, 180, 21, 90, 441, 988, 537, 106, 208, 989, 366, 680, 890, 5, 652, 550, 298, 143, 629, 449, 782, 767, 276, 520, 710, 475, 940, 188, 442, 560, 341, 432, 883, 690, 891, 191, 231, 513, 373, 347, 12, 797, 288, 195, 386, 990, 636, 225, 884, 1000, 482, 487, 418, 319, 109, 863, 284, 745, 759, 801, 394, 829, 305, 363, 202, 259, 531, 616, 736, 44, 540, 321, 844, 152, 353, 565, 657, 802, 453, 663, 938, 68, 655, 729, 14, 491, 310, 228, 263, 605, 507, 637, 665, 205, 499, 949, 743, 589, 909, 878, 978, 53, 419, 330, 302, 256, 837, 757, 522, 221, 576, 240, 897, 981, 3, 15, 236, 524, 425, 583, 19, 60, 929, 716, 623, 107, 461, 684, 553, 868, 673, 361, 822, 275, 357, 422, 775, 926, 643, 594, 299, 398, 260, 71, 601, 538, 28, 564, 62, 922, 626, 568, 389, 120, 669, 162, 877, 810, 888, 133, 384, 541, 75, 139, 209, 70, 734, 733, 37, 159, 562, 916, 997, 683, 919, 927, 591, 787, 77, 136, 850, 189, 157, 559, 378, 738, 618, 233, 650, 584, 867, 86, 630, 985, 313, 0, 272, 250, 223, 943, 178, 437, 89, 737, 872, 577, 459}, + []int{61, 153, 262, 606, 917, 434, 47, 409, 190, 899, 166, 503, 183, 156, 694, 911, 24, 765, 451, 244, 234, 480, 375, 438, 16, 290, 653, 511, 498, 814, 834, 128, 367, 688, 344, 501, 739, 339, 702, 687, 385, 939, 268, 27, 176, 468, 833, 204, 607, 421, 817, 87, 777, 824, 484, 724, 92, 455, 452, 692, 243, 779, 535, 789, 360, 628, 430, 679, 18, 460, 265, 600, 800, 8, 274, 644, 836, 196, 529, 774, 314, 575, 338, 977, 614, 110, 831, 381, 325, 995, 771, 613, 187, 848, 865, 273, 364, 39, 502, 705, 84, 845, 905, 704, 134, 292, 311, 925, 497, 671, 67, 566, 114, 693, 610, 510, 379, 975, 741, 762, 93, 213, 901, 678, 695, 751, 230, 492, 892, 212, 283, 161, 323, 536, 700, 914, 760, 297, 342, 309, 490, 6, 932, 792, 923, 199, 846, 345, 376, 816, 337, 331, 770, 98, 23, 862, 108, 711, 374, 966, 812, 649, 728, 617, 277, 903, 383, 194, 956, 574, 137, 595, 766, 185, 289, 168, 672, 346, 937, 856, 145, 658, 763, 343, 33, 171, 631, 545, 906, 542, 397, 900, 144, 456, 180, 21, 90, 441, 988, 537, 106, 208, 989, 366, 680, 890, 5, 652, 550, 298, 143, 629, 449, 782, 767, 276, 520, 710, 475, 940, 188, 442, 560, 341, 432, 883, 690, 891, 191, 231, 513, 373, 347, 12, 797, 288, 195, 386, 990, 636, 225, 884, 1000, 482, 487, 418, 319, 109, 863, 284, 745, 759, 801, 394, 829, 305, 363, 202, 259, 531, 616, 736, 44, 540, 321, 844, 152, 353, 565, 657, 802, 453, 663, 938, 68, 655, 729, 14, 491, 310, 228, 263, 605, 507, 637, 665, 205, 499, 949, 743, 589, 909, 878, 978, 53, 419, 330, 302, 256, 837, 757, 522, 221, 576, 240, 897, 981, 3, 15, 236, 524, 425, 583, 19, 60, 929, 716, 623, 107, 461, 684, 553, 868, 673, 361, 822, 275, 357, 422, 775, 926, 643, 594, 299, 398, 260, 71, 601, 538, 28, 564, 62, 922, 626, 568, 389, 120, 669, 162, 877, 810, 888, 133, 384, 541, 75, 139, 209, 70, 734, 733, 37, 159, 562, 916, 997, 683, 919, 927, 591, 787, 77, 136, 850, 189, 157, 559, 378, 738, 618, 233, 650, 584, 867, 86, 630, 985, 313, 0, 272, 250, 223, 943, 178, 437, 89, 737, 872, 577, 459, 1, 10, 11, 13, 13, 13, 20, 26, 29, 35, 40, 42, 46, 46, 48, 51, 56, 63, 65, 65, 72, 72, 76, 76, 76, 80, 85, 91, 91, 94, 95, 95, 100, 101, 102, 103, 111, 112, 113, 115, 116, 116, 116, 117, 119, 123, 124, 124, 130, 131, 132, 135, 135, 135, 138, 138, 141, 141, 141, 151, 151, 151, 151, 154, 160, 165, 172, 173, 179, 181, 181, 181, 182, 182, 182, 184, 186, 192, 192, 193, 201, 201, 203, 206, 206, 216, 219, 219, 222, 224, 224, 226, 226, 229, 232, 239, 241, 242, 247, 248, 251, 251, 252, 252, 258, 264, 270, 270, 278, 279, 281, 286, 286, 291, 293, 294, 295, 295, 296, 301, 306, 307, 308, 315, 316, 318, 320, 326, 326, 328, 329, 329, 332, 332, 348, 348, 349, 349, 352, 355, 362, 371, 372, 380, 380, 380, 382, 387, 388, 388, 388, 392, 402, 404, 404, 406, 410, 411, 413, 414, 417, 420, 426, 426, 428, 428, 433, 436, 436, 439, 443, 443, 443, 445, 446, 448, 450, 450, 454, 457, 457, 457, 457, 462, 462, 463, 467, 473, 474, 481, 485, 489, 493, 494, 494, 500, 500, 504, 504, 509, 509, 509, 521, 526, 532, 532, 533, 539, 543, 544, 549, 552, 554, 555, 556, 556, 561, 563, 567, 570, 570, 571, 572, 572, 586, 586, 586, 588, 588, 593, 596, 596, 597, 602, 611, 612, 612, 615, 619, 619, 621, 622, 624, 632, 635, 639, 640, 640, 640, 656, 660, 660, 662, 662, 667, 668, 668, 670, 670, 674, 675, 676, 676, 677, 681, 698, 698, 703, 706, 706, 707, 708, 715, 715, 718, 718, 718, 720, 721, 723, 725, 731, 732, 732, 732, 740, 740, 744, 744, 744, 746, 746, 747, 748, 749, 750, 753, 755, 755, 764, 769, 772, 772, 783, 783, 783, 785, 786, 786, 790, 790, 791, 793, 795, 795, 795, 795, 796, 805, 811, 811, 811, 819, 828, 830, 830, 835, 835, 835, 838, 838, 840, 843, 847, 847, 849, 852, 854, 854, 855, 857, 861, 864, 869, 875, 876, 876, 879, 880, 880, 881, 882, 885, 886, 886, 887, 898, 902, 902, 908, 908, 910, 912, 924, 924, 933, 934, 935, 942, 942, 942, 944, 945, 950, 951, 952, 958, 961, 962, 962, 962, 962, 963, 963, 963, 967, 968, 970, 970, 971, 973, 974, 979, 980, 982, 983, 991, 992, 993, 994}, + }, + + { + []int{2, 3, 1, 3, 2, 4, 6, 7, 9, 2, 19}, + []int{2, 1, 4, 3, 9, 6}, + []int{2, 2, 2, 1, 4, 3, 3, 9, 6, 7, 19}, + }, + + // 可以有多个 testcase +} + +func Test_relativeSortArray(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, relativeSortArray(tc.arr1, tc.arr2), "输入:%v", tc) + } +} + +func Benchmark_relativeSortArray(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + relativeSortArray(tc.arr1, tc.arr2) + } + } +} diff --git a/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/README.md b/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/README.md new file mode 100755 index 000000000..974e29ba3 --- /dev/null +++ b/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/README.md @@ -0,0 +1,39 @@ +# [1123. Lowest Common Ancestor of Deepest Leaves](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/) + +Given a rooted binary tree, return the lowest common ancestor of its deepest leaves. + +Recall that: + +- The node of a binary tree is a leaf if and only if it has no children +- The depth of the root of the tree is 0, and if the depth of a node is d, the depth of each of its children is d+1. +- The lowest common ancestor of a set S of nodes is the node A with the largest depth such that every node in S is in the subtree with root A. + +Example 1: + +```text +Input: root = [1,2,3] +Output: [1,2,3] +Explanation: +The deepest leaves are the nodes with values 2 and 3. +The lowest common ancestor of these leaves is the node with value 1. +The answer returned is a TreeNode object (not an array) with serialization "[1,2,3]". +``` + +Example 2: + +```text +Input: root = [1,2,3,4] +Output: [4] +``` + +Example 3: + +```text +Input: root = [1,2,3,4,5] +Output: [2,4,5] +``` + +Constraints: + +- The given tree will have between 1 and 1000 nodes. +- Each node of the tree will have a distinct value between 1 and 1000. diff --git a/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/lowest-common-ancestor-of-deepest-leaves.go b/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/lowest-common-ancestor-of-deepest-leaves.go new file mode 100755 index 000000000..60df58fa4 --- /dev/null +++ b/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/lowest-common-ancestor-of-deepest-leaves.go @@ -0,0 +1,35 @@ +package problem1123 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func lcaDeepestLeaves(root *TreeNode) *TreeNode { + res, _ := dfs(root) + return res +} + +func dfs(node *TreeNode) (*TreeNode, int) { + if node == nil { + return nil, 0 + } + + l, ld := dfs(node.Left) + r, rd := dfs(node.Right) + + if ld > rd { + return l, ld + 1 + } + + if rd > ld { + return r, rd + 1 + } + + return node, ld + 1 +} diff --git a/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/lowest-common-ancestor-of-deepest-leaves_test.go b/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/lowest-common-ancestor-of-deepest-leaves_test.go new file mode 100755 index 000000000..39f491fd9 --- /dev/null +++ b/Algorithms/1123.lowest-common-ancestor-of-deepest-leaves/lowest-common-ancestor-of-deepest-leaves_test.go @@ -0,0 +1,56 @@ +package problem1123 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans []int +}{ + + { + []int{1, 2, 3}, + []int{1, 2, 3}, + }, + + { + []int{1, 2, 3, kit.NULL, kit.NULL, 4}, + []int{4}, + }, + + { + []int{1, 2, 3, 4}, + []int{4}, + }, + + { + []int{1, 2, 3, 4, 5}, + []int{2, 4, 5}, + }, + + // 可以有多个 testcase +} + +func Test_lcaDeepestLeaves(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ans := kit.Tree2ints(lcaDeepestLeaves(root)) + ast.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_lcaDeepestLeaves(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + lcaDeepestLeaves(root) + } + } +} diff --git a/Algorithms/1124.longest-well-performing-interval/README.md b/Algorithms/1124.longest-well-performing-interval/README.md new file mode 100755 index 000000000..9b8e3eb55 --- /dev/null +++ b/Algorithms/1124.longest-well-performing-interval/README.md @@ -0,0 +1,22 @@ +# [1124. Longest Well-Performing Interval](https://leetcode.com/problems/longest-well-performing-interval/) + +We are given hours, a list of the number of hours worked per day for a given employee. + +A day is considered to be a tiring day if and only if the number of hours worked is (strictly) greater than 8. + +A well-performing interval is an interval of days for which the number of tiring days is strictly larger than the number of non-tiring days. + +Return the length of the longest well-performing interval. + +Example 1: + +```text +Input: hours = [9,9,6,0,6,6,9] +Output: 3 +Explanation: The longest well-performing interval is [9,9,6]. +``` + +Constraints: + +- `1 <= hours.length <= 10000` +- `0 <= hours[i] <= 16` diff --git a/Algorithms/1124.longest-well-performing-interval/longest-well-performing-interval.go b/Algorithms/1124.longest-well-performing-interval/longest-well-performing-interval.go new file mode 100755 index 000000000..cd781df31 --- /dev/null +++ b/Algorithms/1124.longest-well-performing-interval/longest-well-performing-interval.go @@ -0,0 +1,32 @@ +package problem1124 + +func longestWPI(hours []int) int { + res, count := 0, 0 + rec := make([]int, len(hours)+2) + for i, h := range hours { + if h > 8 { + count++ + } else { + count-- + } + // + if count > 0 { + res = i + 1 + } else { + if rec[1-count] > 0 { + res = max(res, i-rec[1-count]+1) + } + if rec[-count] == 0 { + rec[-count] = i + 1 + } + } + } + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1124.longest-well-performing-interval/longest-well-performing-interval_test.go b/Algorithms/1124.longest-well-performing-interval/longest-well-performing-interval_test.go new file mode 100755 index 000000000..889ddc2e2 --- /dev/null +++ b/Algorithms/1124.longest-well-performing-interval/longest-well-performing-interval_test.go @@ -0,0 +1,62 @@ +package problem1124 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + hours []int + ans int +}{ + + { + []int{9, 6, 6, 6, 9, 9}, + 3, + }, + + { + []int{6, 9, 6}, + 1, + }, + + { + []int{13, 8, 13, 4, 10, 11, 12, 5, 3, 0, 14, 16, 9, 2, 11, 12, 11, 10, 6, 14, 8, 6, 3, 6, 2, 4, 3, 3, 10, 5, 10, 13, 0, 5, 16, 6, 15, 12, 5, 3, 5, 9, 7, 2, 6, 14, 12, 12, 16, 13, 1, 7, 2, 6, 9, 5, 16, 5, 4, 15, 0, 12, 4, 13, 8, 10, 0, 4, 15, 5, 3, 2, 11, 6, 7, 5, 12, 6, 4, 15, 16, 1, 1, 11, 13, 10, 16, 2, 11, 15, 0, 1, 10, 5, 15, 16, 9, 6, 9, 10, 5, 0, 6, 11, 12, 12, 6, 14, 13, 3, 8, 16, 16, 10, 16, 0, 9, 2, 5, 5, 7, 11, 8, 5, 15, 6, 16, 14, 13, 4, 7, 7, 1, 12, 3, 10, 1, 8, 10, 0, 12, 15, 14, 0, 3, 1, 5, 15, 5, 8, 4, 8, 12, 16, 10, 6, 11, 8, 5, 11, 6, 11, 15, 15, 5, 11, 1, 11, 9, 8, 13, 10, 9, 3, 7, 7, 6, 6, 15, 1, 15, 15, 2, 9, 6, 0, 6, 10, 3, 1, 4, 8, 4, 3, 0, 15, 10, 10, 9, 3, 12, 0, 13, 6, 2, 12, 11, 14, 9, 9, 1, 15, 10, 3, 7, 0, 11, 3, 8, 1, 9, 5, 14, 9, 12, 7, 8, 12, 14, 0, 3, 14, 12, 6, 1, 14, 0, 1, 0, 8, 12, 2, 2, 6, 0, 4, 4, 11, 11, 3, 7, 1, 3, 11, 4, 14, 4, 11, 12, 1, 13, 4, 3, 6, 9, 7, 7, 10, 15, 3, 2, 16, 14, 6, 14, 13, 8, 7, 0, 10, 4, 15, 3, 0, 12, 14, 0, 1, 14, 13, 14, 12, 7, 1, 9, 10, 3, 7, 8, 7, 0, 12, 15, 10, 3, 2, 3, 4, 6, 0, 4, 4, 13, 13, 0, 14, 12, 1, 13, 13, 16, 11, 3, 15, 5, 0, 2, 10, 6, 14, 16, 11, 11, 11, 12, 8, 3, 16, 7, 13, 2, 1, 13, 14, 1, 9, 8, 5, 14, 4, 8, 2, 12, 7, 7, 11, 2, 15, 15, 12, 12, 9, 9, 13, 8, 0, 12, 8, 2, 14, 2, 6, 1, 3, 3, 0, 0, 6, 0, 16, 10, 10, 9, 4, 4, 5, 12, 0, 3, 16, 11, 10, 0, 16, 15, 14, 2, 0, 1, 6, 15, 7, 12, 3, 1, 5, 2, 0, 11, 16, 2, 16, 1, 14, 7, 12, 16, 1, 5, 5, 6, 4, 3, 3, 12, 8, 14, 0, 2, 14, 3, 7, 9, 1, 8, 16, 12, 4, 13, 13, 9, 14, 12, 6, 16, 16, 9, 4, 15, 0, 2, 13, 4, 7, 10, 8, 2, 10, 13, 5, 9, 16, 10, 4, 15, 1, 10, 8, 7, 5, 3, 7, 6, 14, 1, 5, 3, 15, 2, 13, 2, 12, 13, 13, 11, 5, 6, 11, 9, 14, 11, 5, 8, 10, 0, 0, 12, 0, 7, 4, 0, 9, 12, 14, 13, 6, 7, 1, 14, 5, 5, 2, 5, 11, 5, 14, 3, 6, 9, 14, 12, 7, 7, 6, 0, 12, 1, 4, 1, 12, 6, 4, 0, 2, 16, 3, 4, 1, 12, 15, 16, 14, 3, 15, 7, 10, 7, 10, 14, 3, 8, 14, 5, 9, 3, 9, 0, 7, 7, 2, 1, 14, 16, 10, 2, 16, 4, 2, 3, 9, 2, 8, 11, 2, 10, 13, 9, 0, 4, 0, 16, 6, 9, 9, 14, 1, 8, 10, 5, 12, 9, 10, 14, 0, 5, 3, 7, 15, 11, 9, 8, 2, 16, 6, 10, 12, 2, 0, 13, 16, 4, 11, 8, 2, 3, 15, 11, 4, 16, 1, 2, 0, 15, 15, 11, 14, 10, 8, 14, 2, 11, 11, 14, 10, 2, 6, 11, 0, 15, 15, 3, 0, 6, 9, 10, 7, 11, 15, 16, 14, 10, 15, 6, 10, 4, 1, 1, 11, 10, 3, 8, 8, 11, 6, 8, 2, 15, 11, 16, 2, 15, 4, 5, 5, 13, 12, 1, 9, 14, 9, 10, 7, 7, 9, 10, 9, 6, 12, 12, 1, 14, 16, 13, 5, 5, 8, 8, 14, 0, 16, 15, 8, 10, 9, 15, 4, 12, 15, 5, 4, 12, 5, 9, 9, 1, 6, 12, 12, 1, 8, 2, 15, 1, 11, 1, 1, 1, 1, 10, 14, 3, 10, 12, 5, 6, 12, 16, 12, 6, 7, 0, 9, 12, 8, 5, 11, 5, 11, 5, 11, 6, 14, 1, 0, 13, 0, 14, 6, 7, 13, 5, 14, 1, 13, 16, 12, 8, 15, 13, 16, 16, 2, 14, 3, 16, 2, 1, 14, 2, 3, 9, 3, 10, 5, 5, 1, 2, 2, 3, 8, 0, 16, 14, 11, 3, 8, 16, 16, 16, 13, 16, 15, 15, 11, 13, 15, 7, 12, 5, 5, 10, 7, 1, 3, 15, 10, 16, 14, 16, 2, 4, 0, 12, 1, 5, 5, 15, 11, 6, 12, 1, 8, 10, 1, 4, 0, 15, 10, 16, 6, 5, 1, 0, 7, 12, 15, 12, 5, 0, 2, 0, 9, 10, 6, 9, 5, 7, 0, 12, 15, 8, 11, 16, 12, 12, 3, 2, 14, 5, 16, 7, 8, 15, 0, 16, 16, 6, 3, 7, 13, 14, 5, 9, 12, 9, 9, 0, 0, 7, 11, 8, 4, 5, 16, 10, 5, 0, 9, 0, 12, 9, 2, 3, 4, 11, 5, 14, 11, 1, 7, 12, 2, 2, 13, 11, 11, 2, 2, 12, 7, 12, 9, 16, 11, 14, 13, 14, 15, 13, 9, 10, 12, 12, 7, 14, 7, 10, 0, 6, 10, 1, 1, 13, 16, 11, 12, 13, 3, 10, 7, 3, 16, 2, 5, 8, 2, 0, 7, 14, 8, 1, 11, 13, 9, 4, 2, 13, 13, 11, 11, 14, 15, 12, 4, 3, 12, 15, 14, 12, 2, 4, 3, 11, 12, 8, 15, 7, 11, 15, 15, 6, 8, 14, 13, 0, 14, 7, 5, 10, 4}, + 617, + }, + + { + []int{6, 6, 6, 6, 9, 9, 9, 9, 9, 9, 6, 0, 6, 6, 9}, + 13, + }, + + { + []int{16, 15, 11, 2, 9, 3}, + 6, + }, + + { + []int{9, 9, 6, 0, 6, 6, 9}, + 3, + }, + + // 可以有多个 testcase +} + +func Test_longestWPI(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, longestWPI(tc.hours), "输入:%v", tc) + } +} + +func Benchmark_longestWPI(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + longestWPI(tc.hours) + } + } +} diff --git a/Algorithms/1125.smallest-sufficient-team/README.md b/Algorithms/1125.smallest-sufficient-team/README.md new file mode 100755 index 000000000..837d1387b --- /dev/null +++ b/Algorithms/1125.smallest-sufficient-team/README.md @@ -0,0 +1,33 @@ +# [1125. Smallest Sufficient Team](https://leetcode.com/problems/smallest-sufficient-team/) + +In a project, you have a list of required skills req_skills, and a list of people. The i-th person people[i] contains a list of skills that person has. + +Consider a sufficient team: a set of people such that for every required skill in req_skills, there is at least one person in the team who has that skill. We can represent these teams by the index of each person: for example, team = [0, 1, 3] represents the people with skills people[0], people[1], and people[3]. + +Return any sufficient team of the smallest possible size, represented by the index of each person. + +You may return the answer in any order. It is guaranteed an answer exists. + +Example 1: + +```text +Input: req_skills = ["java","nodejs","reactjs"], people = [["java"],["nodejs"],["nodejs","reactjs"]] +Output: [0,2] +``` + +Example 2: + +```text +Input: req_skills = ["algorithms","math","java","reactjs","csharp","aws"], people = [["algorithms","math","java"],["algorithms","math","reactjs"],["java","csharp","aws"],["reactjs","csharp"],["csharp","math"],["aws","java"]] +Output: [1,2] +``` + +Constraints: + +- `1 <= req_skills.length <= 16` +- `1 <= people.length <= 60` +- `1 <= people[i].length, req_skills[i].length, people[i][j].length <= 16` +- `Elements of req_skills and people[i] are (respectively) distinct.` +- `req_skills[i][j], people[i][j][k] are lowercase English letters.` +- `Every skill in people[i] is a skill in req_skills.` +- `It is guaranteed a sufficient team exists.` diff --git a/Algorithms/1125.smallest-sufficient-team/smallest-sufficient-team.go b/Algorithms/1125.smallest-sufficient-team/smallest-sufficient-team.go new file mode 100755 index 000000000..708af95ba --- /dev/null +++ b/Algorithms/1125.smallest-sufficient-team/smallest-sufficient-team.go @@ -0,0 +1,48 @@ +package problem1125 + +import "math" + +func smallestSufficientTeam(reqSkills []string, people [][]string) []int { + index := make(map[string]uint) + for i, skill := range reqSkills { + index[skill] = uint(i) + } + // encode person's skills to integer + personSkills := make([]int, len(people)) + // collect all candidates of a skill + cands := make([][]int, len(reqSkills)) + for i, p := range people { + skills := 0 + for _, skill := range p { + if _, ok := index[skill]; ok { + skills |= 1 << index[skill] + cands[index[skill]] = append(cands[index[skill]], i) + } + } + personSkills[i] = skills + } + + smallestTeam := map[int][]int{0: {}} + + var dfs func(int) []int + dfs = func(skills int) []int { + if team, ok := smallestTeam[skills]; ok { + return team + } + var minTeam []int + minTeamSize := 61 // people.length<=60 + skill := int(math.Log2(float64(skills & -skills))) + for _, c := range cands[skill] { + needSkills := skills & (^personSkills[c]) + team := dfs(needSkills) + if minTeamSize > len(team)+1 { + minTeamSize = len(team) + 1 + minTeam = append(team, c) + } + } + smallestTeam[skills] = minTeam + return minTeam + } + + return dfs(1< 0 { + size := len(nodes) + for k := 0; k < size; k++ { + i := nodes[k] + res[i] = min(res[i], count) + for _, j := range cur[i] { + if seenCur[j] { + continue + } + seenCur[j] = true + nodes = append(nodes, j) + } + } + nodes = nodes[size:] + count++ + // exchange colors + cur, next = next, cur + seenCur, seenNext = seenNext, seenCur + } + } + + red := trans(n, redEdges) + blue := trans(n, blueEdges) + + bfs(make([]int, 1, n*2), red, blue) + bfs(make([]int, 1, n*2), blue, red) + + for i := range res { + if res[i] == math.MaxInt64 { + res[i] = -1 + } + } + + return res +} + +// edge[i] contains all edges started form i +func trans(n int, edges [][]int) (edge [][]int) { + edge = make([][]int, n) + for _, e := range edges { + i, j := e[0], e[1] + edge[i] = append(edge[i], j) + } + return edge +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1129.shortest-path-with-alternating-colors/shortest-path-with-alternating-colors_test.go b/Algorithms/1129.shortest-path-with-alternating-colors/shortest-path-with-alternating-colors_test.go new file mode 100755 index 000000000..40f5fb657 --- /dev/null +++ b/Algorithms/1129.shortest-path-with-alternating-colors/shortest-path-with-alternating-colors_test.go @@ -0,0 +1,104 @@ +package problem1129 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + n int + reds [][]int + blues [][]int + ans []int +}{ + + { + 3, + [][]int{{0, 1}, {1, 2}}, + [][]int{{1, 1}}, + []int{0, 1, 3}, + }, + + { + 9, + [][]int{{3, 1}, {2, 3}, {7, 6}, {5, 1}, {1, 3}, {8, 1}, {5, 4}, {8, 4}, {6, 3}, {4, 7}, {0, 1}, {7, 8}, {3, 8}}, + [][]int{{4, 1}, {5, 8}, {3, 7}, {7, 1}, {1, 8}, {8, 7}, {5, 4}}, + []int{0, 1, -1, 5, 3, -1, 7, 6, 2}, + }, + + { + 5, + [][]int{{0, 1}, {1, 3}, {2, 1}, {3, 1}, {2, 0}, {1, 0}, {0, 2}}, + [][]int{{1, 2}, {3, 2}, {2, 4}, {3, 3}, {0, 3}, {1, 4}, {0, 1}, {0, 2}, {0, 0}, {4, 1}}, + []int{0, 1, 1, 1, 2}, + }, + + { + 5, + [][]int{{0, 1}, {1, 2}, {2, 3}, {3, 4}}, + [][]int{{1, 2}, {2, 3}, {3, 1}}, + []int{0, 1, 2, 3, 7}, + }, + + { + 3, + [][]int{{1, 2}}, + [][]int{{0, 1}}, + []int{0, 1, 2}, + }, + + { + 3, + [][]int{{0, 1}}, + [][]int{{1, 2}}, + []int{0, 1, 2}, + }, + + { + 3, + [][]int{{0, 1}, {1, 2}}, + [][]int{}, + []int{0, 1, -1}, + }, + + { + 3, + [][]int{{0, 1}}, + [][]int{{2, 1}}, + []int{0, 1, -1}, + }, + + { + 3, + [][]int{{1, 0}}, + [][]int{{2, 1}}, + []int{0, -1, -1}, + }, + + { + 3, + [][]int{{0, 1}, {0, 2}}, + [][]int{{1, 0}}, + []int{0, 1, 1}, + }, + + // 可以有多个 testcase +} + +func Test_shortestAlternatingPaths(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, shortestAlternatingPaths(tc.n, tc.reds, tc.blues), "输入:%v", tc) + } +} + +func Benchmark_shortestAlternatingPaths(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + shortestAlternatingPaths(tc.n, tc.reds, tc.blues) + } + } +} diff --git a/Algorithms/1130.minimum-cost-tree-from-leaf-values/README.md b/Algorithms/1130.minimum-cost-tree-from-leaf-values/README.md new file mode 100755 index 000000000..630ed104a --- /dev/null +++ b/Algorithms/1130.minimum-cost-tree-from-leaf-values/README.md @@ -0,0 +1,30 @@ +# [1130. Minimum Cost Tree From Leaf Values](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values/) + +Given an array arr of positive integers, consider all binary trees such that: + +- Each node has either 0 or 2 children; +- The values of arr correspond to the values of each leaf in an in-order traversal of the tree. (Recall that a node is a leaf if and only if it has 0 children.) +- The value of each non-leaf node is equal to the product of the largest leaf value in its left and right subtree respectively. + +Among all possible binary trees considered, return the smallest possible sum of the values of each non-leaf node. It is guaranteed this sum fits into a 32-bit integer. + +Example 1: + +```text +Input: arr = [6,2,4] +Output: 32 +Explanation: +There are two possible trees. The first has non-leaf node sum 36, and the second has non-leaf node sum 32. + + 24 24 + / \ / \ + 12 4 6 8 + / \ / \ +6 2 2 4 +``` + +Constraints: + +- `2 <= arr.length <= 40` +- `1 <= arr[i] <= 15` +- `It is guaranteed that the answer fits into a 32-bit signed integer (ie. it is less than 2^31).` diff --git a/Algorithms/1130.minimum-cost-tree-from-leaf-values/minimum-cost-tree-from-leaf-values.go b/Algorithms/1130.minimum-cost-tree-from-leaf-values/minimum-cost-tree-from-leaf-values.go new file mode 100755 index 000000000..9a8a3d772 --- /dev/null +++ b/Algorithms/1130.minimum-cost-tree-from-leaf-values/minimum-cost-tree-from-leaf-values.go @@ -0,0 +1,34 @@ +package problem1130 + +import "math" + +// ref: https://leetcode.com/problems/minimum-cost-tree-from-leaf-values/discuss/339959/One-Pass-O(N)-Time-and-Space +func mctFromLeafValues(A []int) int { + n := len(A) + + stack, top, pop := make([]int, n+1), 0, 0 + stack[top] = math.MaxInt64 + + res := 0 + for _, a := range A { + for stack[top] <= a { + pop, top = stack[top], top-1 + res += pop * min(stack[top], a) + } + stack[top+1], top = a, top+1 + } + + for top >= 2 { + pop, top = stack[top], top-1 + res += pop * stack[top] + } + + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1130.minimum-cost-tree-from-leaf-values/minimum-cost-tree-from-leaf-values_test.go b/Algorithms/1130.minimum-cost-tree-from-leaf-values/minimum-cost-tree-from-leaf-values_test.go new file mode 100755 index 000000000..fcf634d2d --- /dev/null +++ b/Algorithms/1130.minimum-cost-tree-from-leaf-values/minimum-cost-tree-from-leaf-values_test.go @@ -0,0 +1,47 @@ +package problem1130 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + arr []int + ans int +}{ + + { + []int{12, 4, 13, 8, 10, 1, 5, 14, 5, 4, 3, 11, 6, 7, 5, 12, 6, 4, 14, 15, 2, 2, 11, 13, 10, 15, 3, 11, 15, 1, 2, 10, 6, 14, 15, 9, 7, 9, 9, 5}, + 3898, + }, + + { + []int{1, 2, 3, 4, 5}, + 40, + }, + + { + []int{6, 2, 4}, + 32, + }, + + // 可以有多个 testcase +} + +func Test_mctFromLeafValues(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, mctFromLeafValues(tc.arr), "输入:%v", tc) + } +} + +func Benchmark_mctFromLeafValues(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + mctFromLeafValues(tc.arr) + } + } +} diff --git a/Algorithms/1131.maximum-of-absolute-value-expression/README.md b/Algorithms/1131.maximum-of-absolute-value-expression/README.md new file mode 100755 index 000000000..a21ca2183 --- /dev/null +++ b/Algorithms/1131.maximum-of-absolute-value-expression/README.md @@ -0,0 +1,26 @@ +# [1131. Maximum of Absolute Value Expression](https://leetcode.com/problems/maximum-of-absolute-value-expression/) + +Given two arrays of integers with equal lengths, return the maximum value of: + +|arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j| + +where the maximum is taken over all 0 <= i, j < arr1.length. + +Example 1: + +```text +Input: arr1 = [1,2,3,4], arr2 = [-1,4,5,6] +Output: 13 +``` + +Example 2: + +```text +Input: arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4] +Output: 20 +``` + +Constraints: + +- `2 <= arr1.length == arr2.length <= 40000` +- `-10^6 <= arr1[i], arr2[i] <= 10^6` diff --git a/Algorithms/1131.maximum-of-absolute-value-expression/maximum-of-absolute-value-expression.go b/Algorithms/1131.maximum-of-absolute-value-expression/maximum-of-absolute-value-expression.go new file mode 100755 index 000000000..32d74379d --- /dev/null +++ b/Algorithms/1131.maximum-of-absolute-value-expression/maximum-of-absolute-value-expression.go @@ -0,0 +1,35 @@ +package problem1131 + +// ref: https://leetcode.com/problems/maximum-of-absolute-value-expression/discuss/340070/topic + +func maxAbsValExpr(A, B []int) int { + Q := [2]int{-1, 1} + + n := len(A) + res := 0 + for _, a := range Q { + for _, b := range Q { + low := a*A[0] + b*B[0] + for i := 1; i < n; i++ { + cur := a*A[i] + b*B[i] + i + res = max(res, cur-low) + low = min(low, cur) + } + } + } + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1131.maximum-of-absolute-value-expression/maximum-of-absolute-value-expression_test.go b/Algorithms/1131.maximum-of-absolute-value-expression/maximum-of-absolute-value-expression_test.go new file mode 100755 index 000000000..91332749c --- /dev/null +++ b/Algorithms/1131.maximum-of-absolute-value-expression/maximum-of-absolute-value-expression_test.go @@ -0,0 +1,45 @@ +package problem1131 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + B []int + ans int +}{ + + { + []int{1, 2, 3, 4}, + []int{-1, 4, 5, 6}, + 13, + }, + + { + []int{1, -2, -5, 0, 10}, + []int{0, -2, -1, -7, -4}, + 20, + }, + + // 可以有多个 testcase +} + +func Test_maxAbsValExpr(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxAbsValExpr(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_maxAbsValExpr(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxAbsValExpr(tc.A, tc.B) + } + } +} diff --git a/Algorithms/1137.n-th-tribonacci-number/README.md b/Algorithms/1137.n-th-tribonacci-number/README.md new file mode 100755 index 000000000..e9dcad992 --- /dev/null +++ b/Algorithms/1137.n-th-tribonacci-number/README.md @@ -0,0 +1,29 @@ +# [1137. N-th Tribonacci Number](https://leetcode.com/problems/n-th-tribonacci-number/) + +The Tribonacci sequence Tn is defined as follows: + +T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. + +Given n, return the value of Tn. + +Example 1: + +```text +Input: n = 4 +Output: 4 +Explanation: +T_3 = 0 + 1 + 1 = 2 +T_4 = 1 + 1 + 2 = 4 +``` + +Example 2: + +```text +Input: n = 25 +Output: 1389537 +``` + +Constraints: + +- `0 <= n <= 37` +- `The answer is guaranteed to fit within a 32-bit integer, ie. answer <= 2^31 - 1.` diff --git a/Algorithms/1137.n-th-tribonacci-number/n-th-tribonacci-number.go b/Algorithms/1137.n-th-tribonacci-number/n-th-tribonacci-number.go new file mode 100755 index 000000000..d9e3b5462 --- /dev/null +++ b/Algorithms/1137.n-th-tribonacci-number/n-th-tribonacci-number.go @@ -0,0 +1,13 @@ +package problem1137 + +func tribonacci(n int) int { + if n < 2 { + return n + } + a, b, c := 0, 1, 1 + for n > 2 { + a, b, c = b, c, a+b+c + n-- + } + return c +} diff --git a/Algorithms/1137.n-th-tribonacci-number/n-th-tribonacci-number_test.go b/Algorithms/1137.n-th-tribonacci-number/n-th-tribonacci-number_test.go new file mode 100755 index 000000000..129175f09 --- /dev/null +++ b/Algorithms/1137.n-th-tribonacci-number/n-th-tribonacci-number_test.go @@ -0,0 +1,52 @@ +package problem1137 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + n int + ans int +}{ + + { + 35, + 615693474, + }, + + { + 0, + 0, + }, + + { + 4, + 4, + }, + + { + 25, + 1389537, + }, + + // 可以有多个 testcase +} + +func Test_tribonacci(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, tribonacci(tc.n), "输入:%v", tc) + } +} + +func Benchmark_tribonacci(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + tribonacci(tc.n) + } + } +} diff --git a/Algorithms/1138.alphabet-board-path/1138.png b/Algorithms/1138.alphabet-board-path/1138.png new file mode 100644 index 000000000..db370622e Binary files /dev/null and b/Algorithms/1138.alphabet-board-path/1138.png differ diff --git a/Algorithms/1138.alphabet-board-path/README.md b/Algorithms/1138.alphabet-board-path/README.md new file mode 100755 index 000000000..43ad06f21 --- /dev/null +++ b/Algorithms/1138.alphabet-board-path/README.md @@ -0,0 +1,38 @@ +# [1138. Alphabet Board Path](https://leetcode.com/problems/alphabet-board-path/) + +On an alphabet board, we start at position (0, 0), corresponding to character board[0][0]. + +![1138](1138.png) + +Here, board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"], as shown in the diagram below. + +We may make the following moves: + +- 'U' moves our position up one row, if the position exists on the board; +- 'D' moves our position down one row, if the position exists on the board; +- 'L' moves our position left one column, if the position exists on the board; +- 'R' moves our position right one column, if the position exists on the board; +- '!' adds the character board[r][c] at our current position (r, c) to the answer. + +(Here, the only positions that exist on the board are positions with letters on them.) + +Return a sequence of moves that makes our answer equal to target in the minimum number of moves. You may return any path that does so. + +Example 1: + +```text +Input: target = "leet" +Output: "DDR!UURRR!!DDD!" +``` + +Example 2: + +```text +Input: target = "code" +Output: "RR!DDRR!UUL!R!" +``` + +Constraints: + +- `1 <= target.length <= 100` +- `target consists only of English lowercase letters.` diff --git a/Algorithms/1138.alphabet-board-path/alphabet-board-path.go b/Algorithms/1138.alphabet-board-path/alphabet-board-path.go new file mode 100755 index 000000000..ded12f91b --- /dev/null +++ b/Algorithms/1138.alphabet-board-path/alphabet-board-path.go @@ -0,0 +1,44 @@ +package problem1138 + +import "strings" + +func alphabetBoardPath(target string) string { + var sb strings.Builder + + // form [x1,y1] move to [x2,y2] + move := func(x1, y1, x2, y2 int) { + for y1 > y2 { + y1-- + sb.WriteByte('L') + } + for x1 > x2 { + x1-- + sb.WriteByte('U') + } + for x1 < x2 { + x1++ + sb.WriteByte('D') + } + for y1 < y2 { + y1++ + sb.WriteByte('R') + } + return + } + + x1, y1 := 0, 0 + for _, r := range target { + x2, y2 := coordinate(r) + move(x1, y1, x2, y2) + sb.WriteByte('!') + x1, y1 = x2, y2 + } + + return sb.String() +} + +func coordinate(r rune) (x, y int) { + a := int(r - 'a') + x, y = a/5, a%5 + return +} diff --git a/Algorithms/1138.alphabet-board-path/alphabet-board-path_test.go b/Algorithms/1138.alphabet-board-path/alphabet-board-path_test.go new file mode 100755 index 000000000..22220cf38 --- /dev/null +++ b/Algorithms/1138.alphabet-board-path/alphabet-board-path_test.go @@ -0,0 +1,125 @@ +package problem1138 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + target string + ans string +}{ + + { + "dfdsfkjdfleiwllsgoidkjflsdfjdfierwsd", + "RRR!LLLD!URRR!DDD!LLLUU!D!URRRR!LU!LLLD!DR!UURRR!LD!LDDD!LUU!!DRR!LLUU!DRRR!LU!U!LLLDD!URRRR!LLLL!DR!DRR!UUU!LLLD!RRRR!LU!LLLD!RRR!UR!LLDDD!D!UR!UUU!", + }, + + { + "zz", + "DDDDD!!", + }, + + { + "zdz", + "DDDDD!UUUUURRR!LLLDDDDD!", + }, + + { + "zb", + "DDDDD!UUUUUR!", + }, + + { + "lazy", + "DDR!LUU!DDDDD!URRRR!", + }, + + { + "leet", + "DDR!UURRR!!DDD!", + }, + + { + "code", + "RR!DDRR!LUU!R!", + }, + + // 可以有多个 testcase +} + +func Test_alphabetBoardPath(t *testing.T) { + ast := assert.New(t) + for _, tc := range tcs { + ast.Equal(tc.ans, alphabetBoardPath(tc.target), "输入:%v", tc) + } +} + +func Benchmark_alphabetBoardPath(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + alphabetBoardPath(tc.target) + } + } +} + +func Test_coordinate(t *testing.T) { + type args struct { + r rune + } + tests := []struct { + name string + args args + wantX int + wantY int + }{ + { + "a 的坐标", + args{ + r: 'a', + }, + 0, 0, + }, + { + "z 的坐标", + args{ + r: 'z', + }, + 5, 0, + }, + { + "i 的坐标", + args{ + r: 'i', + }, + 1, 3, + }, + { + "m 的坐标", + args{ + r: 'm', + }, + 2, 2, + }, + { + "q 的坐标", + args{ + r: 'q', + }, + 3, 1, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gotX, gotY := coordinate(tt.args.r) + if gotX != tt.wantX { + t.Errorf("coordinate() gotX = %v, want %v", gotX, tt.wantX) + } + if gotY != tt.wantY { + t.Errorf("coordinate() gotY = %v, want %v", gotY, tt.wantY) + } + }) + } +} diff --git a/Algorithms/1139.largest-1-bordered-square/README.md b/Algorithms/1139.largest-1-bordered-square/README.md new file mode 100755 index 000000000..c5b90f73a --- /dev/null +++ b/Algorithms/1139.largest-1-bordered-square/README.md @@ -0,0 +1,23 @@ +# [1139. Largest 1-Bordered Square](https://leetcode.com/problems/largest-1-bordered-square/) + +Given a 2D grid of 0s and 1s, return the number of elements in the largest square subgrid that has all 1s on its border, or 0 if such a subgrid doesn't exist in the grid. + +Example 1: + +```text +Input: grid = [[1,1,1],[1,0,1],[1,1,1]] +Output: 9 +``` + +Example 2: + +```text +Input: grid = [[1,1,0,0]] +Output: 1 +``` + +Constraints: + +- `1 <= grid.length <= 100` +- `1 <= grid[0].length <= 100` +- `grid[i][j] is 0 or 1` diff --git a/Algorithms/1139.largest-1-bordered-square/largest-1-bordered-square.go b/Algorithms/1139.largest-1-bordered-square/largest-1-bordered-square.go new file mode 100755 index 000000000..19d9fb075 --- /dev/null +++ b/Algorithms/1139.largest-1-bordered-square/largest-1-bordered-square.go @@ -0,0 +1,39 @@ +package problem1139 + +func largest1BorderedSquare(A [][]int) int { + m, n := len(A), len(A[0]) + + h := [101][101]int{} + v := [101][101]int{} + + for i := 1; i <= m; i++ { + for j := 1; j <= n; j++ { + if A[i-1][j-1] == 1 { + h[i][j] = h[i][j-1] + 1 + v[i][j] = v[i-1][j] + 1 + } + } + } + + for w := min(m, n); w > 0; w-- { + for i := 1; i+w-1 <= m; i++ { + for j := 1; j+w-1 <= n; j++ { + if v[i+w-1][j] >= w && // left border + v[i+w-1][j+w-1] >= w && // right + h[i][j+w-1] >= w && // top + h[i+w-1][j+w-1] >= w { // buttom + return w * w + } + } + } + } + + return 0 +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1139.largest-1-bordered-square/largest-1-bordered-square_test.go b/Algorithms/1139.largest-1-bordered-square/largest-1-bordered-square_test.go new file mode 100755 index 000000000..3ea7ebee1 --- /dev/null +++ b/Algorithms/1139.largest-1-bordered-square/largest-1-bordered-square_test.go @@ -0,0 +1,52 @@ +package problem1139 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + ans int +}{ + + { + [][]int{{1, 1, 1, 1}, {1, 0, 0, 1}, {1, 1, 1, 1}}, + 1, + }, + + { + [][]int{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}, + 9, + }, + + { + [][]int{{0}}, + 0, + }, + + { + [][]int{{1, 1, 0, 0}}, + 1, + }, + + // 可以有多个 testcase +} + +func Test_largest1BorderedSquare(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, largest1BorderedSquare(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_largest1BorderedSquare(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + largest1BorderedSquare(tc.grid) + } + } +} diff --git a/Algorithms/1140.stone-game-ii/README.md b/Algorithms/1140.stone-game-ii/README.md new file mode 100755 index 000000000..c255a3408 --- /dev/null +++ b/Algorithms/1140.stone-game-ii/README.md @@ -0,0 +1,24 @@ +# [1140. Stone Game II](https://leetcode.com/problems/stone-game-ii/) + +Alex and Lee continue their games with piles of stones. There are a number of piles arranged in a row, and each pile has a positive integer number of stones piles[i]. The objective of the game is to end with the most stones. + +Alex and Lee take turns, with Alex starting first. Initially, M = 1. + +On each player's turn, that player can take all the stones in the first X remaining piles, where 1 <= X <= 2M. Then, we set M = max(M, X). + +The game continues until all the stones have been taken. + +Assuming Alex and Lee play optimally, return the maximum number of stones Alex can get. + +Example 1: + +```text +Input: piles = [2,7,9,4,4] +Output: 10 +Explanation: If Alex takes one pile at the beginning, Lee takes two piles, then Alex takes 2 piles again. Alex can get 2 + 4 + 4 = 10 piles in total. If Alex takes two piles at the beginning, then Lee can take all three piles left. In this case, Alex get 2 + 7 = 9 piles in total. So we return 10 since it's larger. +``` + +Constraints: + +- `1 <= piles.length <= 100` +- `1 <= piles[i] <= 10 ^ 4` diff --git a/Algorithms/1140.stone-game-ii/stone-game-ii.go b/Algorithms/1140.stone-game-ii/stone-game-ii.go new file mode 100755 index 000000000..2e1bd40a2 --- /dev/null +++ b/Algorithms/1140.stone-game-ii/stone-game-ii.go @@ -0,0 +1,41 @@ +package problem1140 + +func stoneGameII(A []int) int { + n := len(A) + + for i := n - 2; i >= 0; i-- { + A[i] += A[i+1] + } + + // new A[i] = sum of old A[i:] + + mem := [101][33]int{} + + var dp func(int, int) int + dp = func(i, m int) int { + if i+2*m >= n { + return A[i] + } + if mem[i][m] > 0 { + return mem[i][m] + } + res := 0 + for x := 1; x <= 2*m; x++ { + res = max( + res, + A[i]-dp(i+x, max(m, x)), + ) + } + mem[i][m] = res + return res + } + + return dp(0, 1) +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1140.stone-game-ii/stone-game-ii_test.go b/Algorithms/1140.stone-game-ii/stone-game-ii_test.go new file mode 100755 index 000000000..7cdcf7827 --- /dev/null +++ b/Algorithms/1140.stone-game-ii/stone-game-ii_test.go @@ -0,0 +1,47 @@ +package problem1140 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + piles []int + ans int +}{ + + { + []int{5819, 9551, 3626, 8100, 6991, 4067, 581, 3914, 895, 9859, 3463, 4463, 851, 1993, 6596, 408, 2950, 5818, 1433, 6552, 8416, 837, 7084, 5066, 1514, 6417, 9411, 9331, 5321, 7705, 1376, 6956, 6964, 2371, 5858, 9570, 6367, 9973, 7921, 2004, 8642, 8935, 861, 3857, 7807, 5708, 5020, 4558, 9641, 2286, 7931, 9637, 7542, 5899, 3814, 491, 6356, 9458, 9074, 8037, 7722, 5403, 7363, 8774, 9165, 3799, 7304, 2596, 2319, 5555, 3382, 8311, 6396, 7246, 2193, 7019, 3019, 4814, 6450, 1934, 9388, 4501, 909, 215, 1656, 3799, 6611, 8907, 739, 2678, 1342, 8707, 4648, 4223, 5271, 5970, 9702, 9413, 6121, 3915}, + 276186, + }, + + { + []int{8270, 7145, 575, 5156, 5126, 2905, 8793, 7817, 5532, 5726, 7071, 7730, 5200, 5369, 5763, 7148, 8287, 9449, 7567, 4850, 1385, 2135, 1737, 9511, 8065, 7063, 8023, 7729, 7084, 8407}, + 98008, + }, + + { + []int{2, 7, 9, 4, 4}, + 10, + }, + + // 可以有多个 testcase +} + +func Test_stoneGameII(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, stoneGameII(tc.piles), "输入:%v", tc) + } +} + +func Benchmark_stoneGameII(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + stoneGameII(tc.piles) + } + } +} diff --git a/Algorithms/1143.longest-common-subsequence/README.md b/Algorithms/1143.longest-common-subsequence/README.md new file mode 100755 index 000000000..e438e2e02 --- /dev/null +++ b/Algorithms/1143.longest-common-subsequence/README.md @@ -0,0 +1,37 @@ +# [1143. Longest Common Subsequence](https://leetcode.com/problems/longest-common-subsequence/) + +Given two strings text1 and text2, return the length of their longest common subsequence. + +A subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without changing the relative order of the remaining characters. (eg, "ace" is a subsequence of "abcde" while "aec" is not). A common subsequence of two strings is a subsequence that is common to both strings. + +If there is no common subsequence, return 0. + +Example 1: + +```text +Input: text1 = "abcde", text2 = "ace" +Output: 3 +Explanation: The longest common subsequence is "ace" and its length is 3. +``` + +Example 2: + +```text +Input: text1 = "abc", text2 = "abc" +Output: 3 +Explanation: The longest common subsequence is "abc" and its length is 3. +``` + +Example 3: + +```text +Input: text1 = "abc", text2 = "def" +Output: 0 +Explanation: There is no such common subsequence, so the result is 0. +``` + +Constraints: + +- `1 <= text1.length <= 1000` +- `1 <= text2.length <= 1000` +- `The input strings consist of lowercase English characters only.` diff --git a/Algorithms/1143.longest-common-subsequence/longest-common-subsequence.go b/Algorithms/1143.longest-common-subsequence/longest-common-subsequence.go new file mode 100755 index 000000000..d6d14270f --- /dev/null +++ b/Algorithms/1143.longest-common-subsequence/longest-common-subsequence.go @@ -0,0 +1,29 @@ +package problem1143 + +func longestCommonSubsequence(s1, s2 string) int { + m, n := len(s1), len(s2) + A, B := []byte(s1), []byte(s2) + + cur := make([]int, m+1) + prev := make([]int, m+1) + + for j := 0; j < n; j++ { + for i := 0; i < m; i++ { + rec := max(prev[i+1], cur[i]) + if A[i] == B[j] { + cur[i+1] = max(rec, prev[i]+1) + } else { + cur[i+1] = rec + } + } + cur, prev = prev, cur + } + return prev[m] +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1143.longest-common-subsequence/longest-common-subsequence_test.go b/Algorithms/1143.longest-common-subsequence/longest-common-subsequence_test.go new file mode 100755 index 000000000..a3fe06f00 --- /dev/null +++ b/Algorithms/1143.longest-common-subsequence/longest-common-subsequence_test.go @@ -0,0 +1,51 @@ +package problem1143 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A string + B string + ans int +}{ + + { + "abcde", + "ace", + 3, + }, + + { + "abc", + "abc", + 3, + }, + + { + "abc", + "def", + 0, + }, + + // 可以有多个 testcase +} + +func Test_longestCommonSubsequence(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, longestCommonSubsequence(tc.A, tc.B), "输入:%v", tc) + } +} + +func Benchmark_longestCommonSubsequence(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + longestCommonSubsequence(tc.A, tc.B) + } + } +} diff --git a/Algorithms/1144.decrease-elements-to-make-array-zigzag/README.md b/Algorithms/1144.decrease-elements-to-make-array-zigzag/README.md new file mode 100755 index 000000000..4bed7bd5d --- /dev/null +++ b/Algorithms/1144.decrease-elements-to-make-array-zigzag/README.md @@ -0,0 +1,29 @@ +# [1144. Decrease Elements To Make Array Zigzag](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag/) + +Given an array nums of integers, a move consists of choosing any element and decreasing it by 1. + +An array A is a zigzag array if either: + +Every even-indexed element is greater than adjacent elements, ie. A[0] > A[1] < A[2] > A[3] < A[4] > ... +OR, every odd-indexed element is greater than adjacent elements, ie. A[0] < A[1] > A[2] < A[3] > A[4] < ... +Return the minimum number of moves to transform the given array nums into a zigzag array. + +Example 1: + +```text +Input: nums = [1,2,3] +Output: 2 +Explanation: We can decrease 2 to 0 or 3 to 1. +``` + +Example 2: + +```text +Input: nums = [9,6,1,6,2] +Output: 4 +``` + +Constraints: + +- `1 <= nums.length <= 1000` +- `1 <= nums[i] <= 1000` diff --git a/Algorithms/1144.decrease-elements-to-make-array-zigzag/decrease-elements-to-make-array-zigzag.go b/Algorithms/1144.decrease-elements-to-make-array-zigzag/decrease-elements-to-make-array-zigzag.go new file mode 100755 index 000000000..d35495747 --- /dev/null +++ b/Algorithms/1144.decrease-elements-to-make-array-zigzag/decrease-elements-to-make-array-zigzag.go @@ -0,0 +1,37 @@ +package problem1144 + +import "math" + +func movesToMakeZigzag(A []int) int { + return min( + move(math.MaxInt64, 0, A), + move(A[0], 1, A), + ) +} + +// decrease A[i] to satisfy A[i-1] > A[i] < A[i+1] +func move(left, i int, A []int) int { + n := len(A) + res := 0 + for i+1 < n { + right := A[i+1] + minVal := min(left, right) + if A[i] >= minVal { + res += A[i] - minVal + 1 + } + left = right + i += 2 + } + if i+1 == n && + A[i] >= left { + res += A[i] - left + 1 + } + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1144.decrease-elements-to-make-array-zigzag/decrease-elements-to-make-array-zigzag_test.go b/Algorithms/1144.decrease-elements-to-make-array-zigzag/decrease-elements-to-make-array-zigzag_test.go new file mode 100755 index 000000000..029b90dd3 --- /dev/null +++ b/Algorithms/1144.decrease-elements-to-make-array-zigzag/decrease-elements-to-make-array-zigzag_test.go @@ -0,0 +1,47 @@ +package problem1144 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + nums []int + ans int +}{ + + { + []int{875, 303, 979, 293, 693, 803, 81, 17, 329, 262, 669, 10, 413, 142, 537, 82, 857, 283, 492, 779, 118, 216, 728, 920, 490, 258, 225, 109, 252, 292, 517, 653, 885, 680, 12, 2, 399, 286, 365, 234, 731, 927, 409, 325, 339, 416, 713, 946, 551, 122, 794, 308, 518, 505, 365, 285, 481, 167, 107, 861, 357, 299, 588, 669, 622, 520, 983, 728, 10, 995, 250, 790, 346, 34, 482, 551, 641, 376, 646, 561, 861, 311, 849, 231, 627, 810, 848, 840, 602, 872, 813, 818, 462, 990, 545, 936, 870, 745, 1, 654, 473, 517, 160, 245, 36, 445, 149, 968, 313, 488, 468, 625, 479, 256, 993, 127, 224, 558, 40, 450, 587, 400, 254, 830, 707, 300, 501, 86, 408, 448, 956, 658, 799, 669, 154, 226, 531, 907, 551, 713, 353, 245, 883, 683, 368, 777, 677, 597, 166, 226, 74, 208, 882, 940, 271, 586, 730, 346, 572, 742, 325, 293, 263, 617, 962, 781, 817, 73, 320, 41, 484, 849, 919, 266, 419, 685, 211, 240, 223, 596, 859, 662, 337, 14, 803, 476, 763, 62, 115, 491, 840, 623, 593, 22, 763, 145, 616, 115, 393, 51, 239, 264, 968, 998, 391, 49, 159, 297, 410, 807, 787, 510, 860, 769, 703, 834, 298, 249, 229, 960, 98, 849, 65, 704, 340, 60, 174, 263, 261, 38, 79, 661, 237, 853, 930, 205, 602, 498, 117, 461, 918, 540, 261, 71, 440, 476, 801, 455, 235, 346, 673, 385, 205, 379, 238, 443, 861, 844, 718, 451, 492, 708, 528, 219, 749, 500, 67, 219, 489, 966, 165, 403, 359, 684, 961, 547, 832, 678, 674, 446, 831, 804, 479, 696, 471, 164, 577, 482, 237, 557, 123, 669, 940, 809, 546, 120, 973, 835, 549, 958, 960, 494, 369, 496, 600, 594, 485, 517, 403, 174, 308, 705, 431, 644, 441, 220, 836, 919, 634, 542, 564, 763, 481, 993, 603, 300, 379, 990, 377, 631, 147, 185, 997, 244, 972, 482, 410, 97, 167, 103, 235, 316, 149, 894, 399, 706, 651, 881, 185, 683, 479, 791, 5, 161, 746, 34, 735, 151, 405, 616, 478, 372, 831, 798, 918, 218, 752, 368, 208, 852, 582, 496, 281, 789, 339, 887, 90, 447, 40, 156, 163, 242, 276, 159, 175, 122, 3, 403, 327, 168, 353, 634, 935, 144, 411, 321, 956, 931, 632, 548, 710, 932, 366, 820, 46, 113, 780, 637, 738, 64, 253, 129, 279, 885, 476, 493, 712, 410, 325, 85, 435, 552, 545, 936, 247, 598, 615, 546, 637, 582, 300, 571, 425, 180, 446, 552, 509, 109, 653, 404, 739, 387, 650, 535, 247, 590, 628, 455, 993, 19, 108, 513, 316, 975, 534, 375, 850, 911, 403, 476, 713, 426, 904, 934, 8, 306, 41, 517, 491, 744, 720, 517, 589, 21, 354, 954, 63, 922, 863, 687, 376, 421, 185, 988, 643, 96, 724, 210, 218, 612, 207, 437, 927, 728, 666, 598, 142, 670, 165, 561, 942, 447, 916, 363, 731, 441, 318, 613, 750, 108, 176, 472, 85, 855, 144, 635, 78, 115, 586, 209, 845, 149, 905, 891, 390, 921, 741, 874, 691, 212, 784, 580, 364, 324, 907, 830, 669, 204, 31, 340, 830, 7, 15, 742, 17, 197, 223, 615, 335, 684, 172, 685, 193, 44, 19, 669, 446, 525, 361, 591, 847, 900, 734, 928, 56, 939, 412, 488, 732, 186, 816, 165, 77, 564, 147, 376, 712, 82, 128, 726, 555, 72, 316, 983, 330, 219, 339, 30, 283, 557, 879, 774, 7, 372, 215, 106, 322, 207, 946, 389, 333, 348, 969, 730, 899, 95, 301, 489, 407, 688, 929, 438, 672, 513, 210, 533, 38, 604, 160, 541, 80, 932, 871, 510, 78, 450, 884, 306, 867, 466, 530, 766, 220, 907, 736, 571, 70, 380, 700, 216, 482, 414, 670, 47, 481, 389, 634, 199, 178, 455, 90, 579, 484, 988, 38, 160, 545, 21, 234, 712, 221, 813, 566, 847, 605, 183, 338, 513, 304, 667, 982, 426, 335, 982, 420, 956, 809, 809, 876, 118, 577, 276, 965, 944, 917, 383, 315, 518, 96, 376, 648, 247, 831, 61, 872, 146, 572, 446, 203, 243, 86, 791, 418, 629, 485, 306, 411, 539, 83, 126, 589, 119, 545, 580, 627, 15, 909, 135, 539, 15, 764, 58, 120, 595, 846, 687, 397, 969, 144, 179, 308, 867, 569, 202, 492, 581, 130, 111, 630, 966, 378, 463, 349, 589, 241, 423, 774, 54, 639, 594, 492, 974, 766, 744, 540, 301, 565, 139, 123, 110, 216, 539, 480, 656, 647, 63, 369, 847, 546, 623, 584, 786, 407, 289, 361, 792, 329, 782, 686, 132, 98, 343, 582, 999, 427, 310, 376, 254, 980, 397, 912, 975, 201, 636, 538, 883, 245, 505, 493, 894, 766, 772, 340, 458, 112, 128, 803, 395, 989, 558, 296, 94, 837, 653, 360, 866, 325, 675, 435, 93, 127, 199, 531, 165, 892, 80, 648, 496, 127, 253, 959, 703, 912, 216, 228, 615, 412, 868, 212, 768, 626, 827, 653, 77, 998, 148, 593, 745, 807, 917, 468, 289, 909, 267, 639, 649, 743, 527, 26, 591, 857, 997, 860, 83, 736, 412, 9, 293, 872, 792, 248, 755, 380, 401, 804, 15, 229, 196, 350, 760, 1, 433, 541, 626, 359, 271, 426, 20, 548, 24, 377, 326, 583, 89, 376, 342, 831, 629, 349, 317, 377, 401, 369, 852, 930, 286, 200, 170, 332, 316, 427, 425, 377, 325, 987, 599, 463, 127, 348, 519, 754, 361, 917, 176, 821, 7, 775, 346, 597, 369, 362, 646, 19, 926, 976, 28, 912, 209, 378, 671, 401, 627, 754, 50, 11, 143, 554, 810, 896, 586, 235, 293, 379, 628, 202, 606, 930, 807, 707, 530, 602, 219, 246, 229, 596, 481, 789, 429, 778, 379, 684, 474, 210, 2, 19, 874, 357, 247, 259, 334, 615, 667, 534, 578, 178, 743, 953, 399, 583, 689, 858, 536, 829, 661, 402, 401, 477, 859, 257, 92}, + 113084, + }, + + { + []int{1, 2, 3}, + 2, + }, + + { + []int{9, 6, 1, 6, 2}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_movesToMakeZigzag(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, movesToMakeZigzag(tc.nums), "输入:%v", tc) + } +} + +func Benchmark_movesToMakeZigzag(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + movesToMakeZigzag(tc.nums) + } + } +} diff --git a/Algorithms/1145.binary-tree-coloring-game/1.png b/Algorithms/1145.binary-tree-coloring-game/1.png new file mode 100644 index 000000000..e81767a8b Binary files /dev/null and b/Algorithms/1145.binary-tree-coloring-game/1.png differ diff --git a/Algorithms/1145.binary-tree-coloring-game/README.md b/Algorithms/1145.binary-tree-coloring-game/README.md new file mode 100755 index 000000000..1104833ed --- /dev/null +++ b/Algorithms/1145.binary-tree-coloring-game/README.md @@ -0,0 +1,27 @@ +# [1145. Binary Tree Coloring Game](https://leetcode.com/problems/binary-tree-coloring-game/) + +Two players play a turn based game on a binary tree. We are given the root of this binary tree, and the number of nodes n in the tree. n is odd, and each node has a distinct value from 1 to n. + +Initially, the first player names a value x with 1 <= x <= n, and the second player names a value y with 1 <= y <= n and y != x. The first player colors the node with value x red, and the second player colors the node with value y blue. + +Then, the players take turns starting with the first player. In each turn, that player chooses a node of their color (red if player 1, blue if player 2) and colors an uncolored neighbor of the chosen node (either the left child, right child, or parent of the chosen node.) + +If (and only if) a player cannot choose such a node in this way, they must pass their turn. If both players pass their turn, the game ends, and the winner is the player that colored more nodes. + +You are the second player. If it is possible to choose such a y to ensure you win the game, return true. If it is not possible, return false. + +Example 1: + +![1](1.png) + +```text +Input: root = [1,2,3,4,5,6,7,8,9,10,11], n = 11, x = 3 +Output: true +Explanation: The second player can choose the node with value 2. +``` + +Constraints: + +- `root is the root of a binary tree with n nodes and distinct node values from 1 to n.` +- `n is odd.` +- `1 <= x <= n <= 100` diff --git a/Algorithms/1145.binary-tree-coloring-game/binary-tree-coloring-game.go b/Algorithms/1145.binary-tree-coloring-game/binary-tree-coloring-game.go new file mode 100755 index 000000000..8c2e9adc4 --- /dev/null +++ b/Algorithms/1145.binary-tree-coloring-game/binary-tree-coloring-game.go @@ -0,0 +1,41 @@ +package problem1145 + +import ( + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined... +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func btreeGameWinningMove(root *TreeNode, n int, x int) bool { + var left, right int + + var dfs func(*TreeNode) int + dfs = func(node *TreeNode) int { + if node == nil { + return 0 + } + l, r := dfs(node.Left), dfs(node.Right) + if node.Val == x { + left, right = l, r + } + return l + r + 1 + } + + dfs(root) + + up := n - left - right - 1 + n /= 2 + + return left > n || right > n || up > n +} + +// node-x split tree into 3 parts: +// node-x.Left, node-x.Right and up(node-x parent plus node-x brother) +// second player must takes the biggest part +// second player win the game if his part > n/2 diff --git a/Algorithms/1145.binary-tree-coloring-game/binary-tree-coloring-game_test.go b/Algorithms/1145.binary-tree-coloring-game/binary-tree-coloring-game_test.go new file mode 100755 index 000000000..7fe661cec --- /dev/null +++ b/Algorithms/1145.binary-tree-coloring-game/binary-tree-coloring-game_test.go @@ -0,0 +1,58 @@ +package problem1145 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + n int + x int + ans bool +}{ + + { + []int{6, 3, kit.NULL, 7, 4, kit.NULL, kit.NULL, kit.NULL, 2, kit.NULL, 1, kit.NULL, 5}, + 7, + 3, + true, + }, + + { + []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, + 11, + 3, + true, + }, + + { + []int{3, kit.NULL, 6, kit.NULL, 7, 4, kit.NULL, 1, 2, kit.NULL, kit.NULL, 5}, + 7, + 4, + false, + }, + + // 可以有多个 testcase +} + +func Test_btreeGameWinningMove(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, btreeGameWinningMove(root, tc.n, tc.x), "输入:%v", tc) + } +} + +func Benchmark_btreeGameWinningMove(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + btreeGameWinningMove(root, tc.n, tc.x) + } + } +} diff --git a/Algorithms/1146.snapshot-array/README.md b/Algorithms/1146.snapshot-array/README.md new file mode 100755 index 000000000..9fb14f90e --- /dev/null +++ b/Algorithms/1146.snapshot-array/README.md @@ -0,0 +1,30 @@ +# [1146. Snapshot Array](https://leetcode.com/problems/snapshot-array/) + +Implement a SnapshotArray that supports the following interface: + +- SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0. +- void set(index, val) sets the element at the given index to be equal to val. +- int snap() takes a snapshot of the array and returns the snap_id: the total number of times we called snap() minus 1. +- int get(index, snap_id) returns the value at the given index, at the time we took the snapshot with the given snap_id + +Example 1: + +```text +Input: ["SnapshotArray","set","snap","set","get"] +[[3],[0,5],[],[0,6],[0,0]] +Output: [null,null,0,null,5] +Explanation: +SnapshotArray snapshotArr = new SnapshotArray(3); // set the length to be 3 +snapshotArr.set(0,5); // Set array[0] = 5 +snapshotArr.snap(); // Take a snapshot, return snap_id = 0 +snapshotArr.set(0,6); +snapshotArr.get(0,0); // Get the value of array[0] with snap_id = 0, return 5 +``` + +Constraints: + +- `1 <= length <= 50000` +- `At most 50000 calls will be made to set, snap, and get.` +- `0 <= index < length` +- `0 <= snap_id < (the total number of times we call snap())` +- `0 <= val <= 10^9` diff --git a/Algorithms/1146.snapshot-array/snapshot-array.go b/Algorithms/1146.snapshot-array/snapshot-array.go new file mode 100755 index 000000000..c4611fe7d --- /dev/null +++ b/Algorithms/1146.snapshot-array/snapshot-array.go @@ -0,0 +1,43 @@ +package problem1146 + +// SnapshotArray can snap a array +type SnapshotArray struct { + snaps []map[int]int + current map[int]int + id int +} + +// Constructor resturn s a SnapshotArray +func Constructor(length int) SnapshotArray { + s := make([]map[int]int, 0, 128) + c := make(map[int]int, 32) + return SnapshotArray{ + snaps: s, + current: c, + id: 0, + } +} + +// Set val in index +func (sa *SnapshotArray) Set(index int, val int) { + sa.current[index] = val +} + +// Snap make snapshot +func (sa *SnapshotArray) Snap() int { + sa.snaps = append(sa.snaps, sa.current) + sa.current = make(map[int]int) + sa.id++ + return sa.id - 1 +} + +// Get returns val in the snap +func (sa *SnapshotArray) Get(index int, snap int) int { + for id := snap; id >= 0; id-- { + history := sa.snaps[id] + if t, ok := history[index]; ok { + return t + } + } + return 0 //default value +} diff --git a/Algorithms/1146.snapshot-array/snapshot-array_test.go b/Algorithms/1146.snapshot-array/snapshot-array_test.go new file mode 100755 index 000000000..5176c0821 --- /dev/null +++ b/Algorithms/1146.snapshot-array/snapshot-array_test.go @@ -0,0 +1,54 @@ +package problem1146 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_SnapshotArray(t *testing.T) { + ast := assert.New(t) + + sa := Constructor(3) + + sa.Set(0, 5) + + ast.Equal(0, sa.Snap()) + + sa.Set(0, 6) + + ast.Equal(5, sa.Get(0, 0)) + + sa.Set(1, 7) + + ast.Equal(0, sa.Get(1, 0)) + + ast.Equal(0, sa.Get(2, 0)) + +} + +func Test_SnapshotArray_2(t *testing.T) { + ast := assert.New(t) + + sa := Constructor(3) + + sa.Set(1, 14) + + ast.Equal(0, sa.Snap()) + ast.Equal(1, sa.Snap()) + ast.Equal(2, sa.Snap()) + + sa.Set(0, 14) + + ast.Equal(3, sa.Snap()) + ast.Equal(4, sa.Snap()) + + sa.Set(2, 0) + sa.Set(0, 5) + + ast.Equal(14, sa.Get(0, 3)) + + ast.Equal(5, sa.Snap()) + ast.Equal(6, sa.Snap()) + +} diff --git a/Algorithms/1147.longest-chunked-palindrome-decomposition/README.md b/Algorithms/1147.longest-chunked-palindrome-decomposition/README.md new file mode 100755 index 000000000..f517f5ce0 --- /dev/null +++ b/Algorithms/1147.longest-chunked-palindrome-decomposition/README.md @@ -0,0 +1,44 @@ +# [1147. Longest Chunked Palindrome Decomposition](https://leetcode.com/problems/longest-chunked-palindrome-decomposition/) + +Return the largest possible k such that there exists a_1, a_2, ..., a_k such that: + +- Each a_i is a non-empty string; +- Their concatenation a_1 + a_2 + ... + a_k is equal to text; +- For all 1 <= i <= k, a_i = a_{k+1 - i}. + +Example 1: + +```text +Input: text = "ghiabcdefhelloadamhelloabcdefghi" +Output: 7 +Explanation: We can split the string on "(ghi)(abcdef)(hello)(adam)(hello)(abcdef)(ghi)". +``` + +Example 2: + +```text +Input: text = "merchant" +Output: 1 +Explanation: We can split the string on "(merchant)". +``` + +Example 3: + +```text +Input: text = "antaprezatepzapreanta" +Output: 11 +Explanation: We can split the string on "(a)(nt)(a)(pre)(za)(tpe)(za)(pre)(a)(nt)(a)". +``` + +Example 4: + +```text +Input: text = "aaa" +Output: 3 +Explanation: We can split the string on "(a)(a)(a)". +``` + +Constraints: + +- `text consists only of lowercase English characters.` +- `1 <= text.length <= 1000` diff --git a/Algorithms/1147.longest-chunked-palindrome-decomposition/longest-chunked-palindrome-decomposition.go b/Algorithms/1147.longest-chunked-palindrome-decomposition/longest-chunked-palindrome-decomposition.go new file mode 100755 index 000000000..693971bba --- /dev/null +++ b/Algorithms/1147.longest-chunked-palindrome-decomposition/longest-chunked-palindrome-decomposition.go @@ -0,0 +1,17 @@ +package problem1147 + +import "strings" + +func longestDecomposition(S string) int { + if S == "" { + return 0 + } + n := len(S) + for i := 1; i*2 <= n; i++ { + left := S[:i] + if strings.HasSuffix(S, left) { + return 2 + longestDecomposition(S[i:n-i]) + } + } + return 1 +} diff --git a/Algorithms/1147.longest-chunked-palindrome-decomposition/longest-chunked-palindrome-decomposition_test.go b/Algorithms/1147.longest-chunked-palindrome-decomposition/longest-chunked-palindrome-decomposition_test.go new file mode 100755 index 000000000..16e24de99 --- /dev/null +++ b/Algorithms/1147.longest-chunked-palindrome-decomposition/longest-chunked-palindrome-decomposition_test.go @@ -0,0 +1,57 @@ +package problem1147 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + text string + ans int +}{ + + { + "ykpwikcghnoxoumuggqqybujrbkmnjlccsvjpoglirbrpgwkwxlmnfcpveijqluopugmksmmrfblaciqqtyidjxdrrefhoszhywhzjlvxmvfcmtszcclkhzkarheolcwikciixvarpffcdserxpzfpmrlxgmahxonomqzjfhjznvzbvsmwxfalcsdbaknspktjvydykivtfwvzicnausanqabozwcxpmimmldzpeiujilsixyrvxiisaeataeeydfodjqbpbserygikmcczluabsujnkfgemcdszftwkyteeagthkspkvkehlvdxkjnwuwmoyhdyksybqoqwdbrrabhkxuolvxrnyopxsqucilfakiiuwvwnhxclxnwvgxqsevcgdwuiaqtqbbkwporlsgbnotnhbcumfzzzvldzlqyiyhdfgsdqyifzyqecyesuygxynosctshoohumujzmrwfzaxjcjtubzugtiwekrtlluudmlqooqldmtlluuiwekrubzugtxjcjtzafjzmrwoohumutshynoscuygxesyqecydqyifzfgsyiyhdqdzlzzvlcumfzbhnotngblsbkwporiaqtqbvcgdwuqsenwvgxlxvwnhxciuwfakiluciqopxsvxrnykxuolrabhdbrqoqwybdyksuwmoyhdxkjnwehlvkpkvkseagthtwkytemcdszfnkfgeuabsujzlikmccgbseryodjqbpydfaeesaeatvxiisixyreiujilpldzmimmcxpqabozwnausanvzicfwdykivtpktjvyknsaalcsdbsmwxfnvzbvjfhjzqzommahxonxgmrlpzfpdserxffcxvarpikciwiheolchzkarzcclkfcmtsjlvxmvhywhzzsrefhojxdrqtyidaciqfblmrgmksmpuluoveijqpnfcmlpgwkwxbroglirvjpjlccskmnybujrbmuggqqnoxouikcghykpw", + 288, + }, + + { + "ghiabcdefhelloadamhelloabcdefghi", + 7, + }, + + { + "merchant", + 1, + }, + + { + "antaprezatepzapreanta", + 11, + }, + + { + "aaa", + 3, + }, + + // 可以有多个 testcase +} + +func Test_longestDecomposition(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, longestDecomposition(tc.text), "输入:%v", tc) + } +} + +func Benchmark_longestDecomposition(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + longestDecomposition(tc.text) + } + } +} diff --git a/Algorithms/1154.day-of-the-year/README.md b/Algorithms/1154.day-of-the-year/README.md new file mode 100755 index 000000000..2eafc7ee2 --- /dev/null +++ b/Algorithms/1154.day-of-the-year/README.md @@ -0,0 +1,38 @@ +# [1154. Day of the Year](https://leetcode.com/problems/day-of-the-year/) + +Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year. + +Example 1: + +```text +Input: date = "2019-01-09" +Output: 9 +Explanation: Given date is the 9th day of the year in 2019. +``` + +Example 2: + +```text +Input: date = "2019-02-10" +Output: 41 +``` + +Example 3: + +```text +Input: date = "2003-03-01" +Output: 60 +``` + +Example 4: + +```text +Input: date = "2004-03-01" +Output: 61 +``` + +Constraints: + +- date.length == 10 +- date[4] == date[7] == '-', and all other date[i]'s are digits +- date represents a calendar date between Jan 1st, 1900 and Dec 31, 2019. diff --git a/Algorithms/1154.day-of-the-year/day-of-the-year.go b/Algorithms/1154.day-of-the-year/day-of-the-year.go new file mode 100755 index 000000000..0685e7c95 --- /dev/null +++ b/Algorithms/1154.day-of-the-year/day-of-the-year.go @@ -0,0 +1,11 @@ +package problem1154 + +import "time" + +func dayOfYear(date string) int { + first := date[:4] + "-01-01" + firstDay, _ := time.Parse("2006-01-02", first) + dateDay, _ := time.Parse("2006-01-02", date) + duration := dateDay.Sub(firstDay) + return int(duration.Hours())/24 + 1 +} diff --git a/Algorithms/1154.day-of-the-year/day-of-the-year_test.go b/Algorithms/1154.day-of-the-year/day-of-the-year_test.go new file mode 100755 index 000000000..3496ed40d --- /dev/null +++ b/Algorithms/1154.day-of-the-year/day-of-the-year_test.go @@ -0,0 +1,52 @@ +package problem1154 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + date string + ans int +}{ + + { + "2019-01-09", + 9, + }, + + { + "2019-02-10", + 41, + }, + + { + "2003-03-01", + 60, + }, + + { + "2004-03-01", + 61, + }, + + // 可以有多个 testcase +} + +func Test_dayOfYear(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, dayOfYear(tc.date), "输入:%v", tc) + } +} + +func Benchmark_dayOfYear(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + dayOfYear(tc.date) + } + } +} diff --git a/Algorithms/1155.number-of-dice-rolls-with-target-sum/README.md b/Algorithms/1155.number-of-dice-rolls-with-target-sum/README.md new file mode 100755 index 000000000..8c4bdbe64 --- /dev/null +++ b/Algorithms/1155.number-of-dice-rolls-with-target-sum/README.md @@ -0,0 +1,56 @@ +# [1155. Number of Dice Rolls With Target Sum](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/) + +You have d dice, and each die has f faces numbered 1, 2, ..., f. + +Return the number of possible ways (out of fd total ways) modulo 10^9 + 7 to roll the dice so the sum of the face up numbers equals target. + +Example 1: + +```text +Input: d = 1, f = 6, target = 3 +Output: 1 +Explanation: +You throw one die with 6 faces. There is only one way to get a sum of 3. +``` + +Example 2: + +```text +Input: d = 2, f = 6, target = 7 +Output: 6 +Explanation: +You throw two dice, each with 6 faces. There are 6 ways to get a sum of 7: +1+6, 2+5, 3+4, 4+3, 5+2, 6+1. +``` + +Example 3: + +```text +Input: d = 2, f = 5, target = 10 +Output: 1 +Explanation: +You throw two dice, each with 5 faces. There is only one way to get a sum of 10: 5+5. +``` + +Example 4: + +```text +Input: d = 1, f = 2, target = 3 +Output: 0 +Explanation: +You throw one die with 2 faces. There is no way to get a sum of 3. +``` + +Example 5: + +```text +Input: d = 30, f = 30, target = 500 +Output: 222616187 +Explanation: +The answer must be returned modulo 10^9 + 7. +``` + +Constraints: + +- `1 <= d, f <= 30` +- `1 <= target <= 1000` diff --git a/Algorithms/1155.number-of-dice-rolls-with-target-sum/number-of-dice-rolls-with-target-sum.go b/Algorithms/1155.number-of-dice-rolls-with-target-sum/number-of-dice-rolls-with-target-sum.go new file mode 100755 index 000000000..a001bcff3 --- /dev/null +++ b/Algorithms/1155.number-of-dice-rolls-with-target-sum/number-of-dice-rolls-with-target-sum.go @@ -0,0 +1,28 @@ +package problem1155 + +const mod = 1e9 + 7 + +func numRollsToTarget(dices, faces, target int) int { + dp := [31][1001]int{} + dp[0][0] = 1 + + for d := 1; d <= dices; d++ { + maxT := min(target, d*faces) + for t := d; t <= maxT; t++ { + maxF := min(faces, t) + for f := 1; f <= maxF; f++ { + dp[d][t] += dp[d-1][t-f] + } + dp[d][t] %= mod + } + } + + return dp[dices][target] +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1155.number-of-dice-rolls-with-target-sum/number-of-dice-rolls-with-target-sum_test.go b/Algorithms/1155.number-of-dice-rolls-with-target-sum/number-of-dice-rolls-with-target-sum_test.go new file mode 100755 index 000000000..a6ec82ae2 --- /dev/null +++ b/Algorithms/1155.number-of-dice-rolls-with-target-sum/number-of-dice-rolls-with-target-sum_test.go @@ -0,0 +1,69 @@ +package problem1155 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + d int + f int + target int + ans int +}{ + + { + 1, + 6, + 3, + 1, + }, + + { + 2, + 6, + 7, + 6, + }, + + { + 2, + 5, + 10, + 1, + }, + + { + 1, + 2, + 3, + 0, + }, + + { + 30, + 30, + 500, + 222616187, + }, + + // 可以有多个 testcase +} + +func Test_numRollsToTarget(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, numRollsToTarget(tc.d, tc.f, tc.target), "输入:%v", tc) + } +} + +func Benchmark_numRollsToTarget(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numRollsToTarget(tc.d, tc.f, tc.target) + } + } +} diff --git a/Algorithms/1156.swap-for-longest-repeated-character-substring/README.md b/Algorithms/1156.swap-for-longest-repeated-character-substring/README.md new file mode 100755 index 000000000..9120a4b8d --- /dev/null +++ b/Algorithms/1156.swap-for-longest-repeated-character-substring/README.md @@ -0,0 +1,46 @@ +# [1156. Swap For Longest Repeated Character Substring](https://leetcode.com/problems/swap-for-longest-repeated-character-substring/) + +Given a string text, we are allowed to swap two of the characters in the string. Find the length of the longest substring with repeated characters. + +Example 1: + +```text +Input: text = "ababa" +Output: 3 +Explanation: We can swap the first 'b' with the last 'a', or the last 'b' with the first 'a'. Then, the longest repeated character substring is "aaa", which its length is 3. +``` + +Example 2: + +```text +Input: text = "aaabaaa" +Output: 6 +Explanation: Swap 'b' with the last 'a' (or the first 'a'), and we get longest repeated character substring "aaaaaa", which its length is 6. +``` + +Example 3: + +```text +Input: text = "aaabbaaa" +Output: 4 +``` + +Example 4: + +```text +Input: text = "aaaaa" +Output: 5 +Explanation: No need to swap, longest repeated character substring is "aaaaa", length is 5. +``` + +Example 5: + +```text +Input: text = "abcdef" +Output: 1 +``` + +Constraints: + +- `1 <= text.length <= 20000` +- `text consist of lowercase English characters only.` diff --git a/Algorithms/1156.swap-for-longest-repeated-character-substring/swap-for-longest-repeated-character-substring.go b/Algorithms/1156.swap-for-longest-repeated-character-substring/swap-for-longest-repeated-character-substring.go new file mode 100755 index 000000000..6856275a7 --- /dev/null +++ b/Algorithms/1156.swap-for-longest-repeated-character-substring/swap-for-longest-repeated-character-substring.go @@ -0,0 +1,66 @@ +package problem1156 + +import "strings" + +func maxRepOpt1(text string) int { + rec := [26][][3]int{} + segments, index := split(text), 0 + for _, s := range segments { + b, n := int(s[0]-'a'), len(s) + rec[b] = append(rec[b], [3]int{index, index + n + 1, n}) + index += n + } + + res := 0 + for _, r := range rec { + n := len(r) + if n == 0 { + continue + } + // extension a lonely segment + ext := 0 + if n > 1 { + ext = 1 + } + // connect two neighbor segments + con := 0 + if n > 2 { + con = 1 + } + prev := r[0] + res = max(res, ext+prev[2]) + for i := 1; i < len(r); i++ { + cur := r[i] + if prev[1] == cur[0] { + res = max(res, con+prev[2]+cur[2]) + } else { + res = max(res, ext+cur[2]) + } + prev = cur + } + } + + return res +} + +func split(s string) []string { + var sb strings.Builder + p := s[0] + sb.WriteByte(p) + for i := 1; i < len(s); i++ { + n := s[i] + if p != n { + sb.WriteByte('\n') + } + sb.WriteByte(n) + p = n + } + return strings.Split(sb.String(), "\n") +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1156.swap-for-longest-repeated-character-substring/swap-for-longest-repeated-character-substring_test.go b/Algorithms/1156.swap-for-longest-repeated-character-substring/swap-for-longest-repeated-character-substring_test.go new file mode 100755 index 000000000..8fd057b0b --- /dev/null +++ b/Algorithms/1156.swap-for-longest-repeated-character-substring/swap-for-longest-repeated-character-substring_test.go @@ -0,0 +1,62 @@ +package problem1156 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + text string + ans int +}{ + + { + "ababa", + 3, + }, + + { + "aaabaaa", + 6, + }, + + { + "aaabbbbbaaa", + 5, + }, + + { + "aaabbaaa", + 4, + }, + + { + "aaaaa", + 5, + }, + + { + "abcdef", + 1, + }, + + // 可以有多个 testcase +} + +func Test_maxRepOpt1(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxRepOpt1(tc.text), "输入:%v", tc) + } +} + +func Benchmark_maxRepOpt1(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxRepOpt1(tc.text) + } + } +} diff --git a/Algorithms/1157.online-majority-element-in-subarray/README.md b/Algorithms/1157.online-majority-element-in-subarray/README.md new file mode 100755 index 000000000..64185a22b --- /dev/null +++ b/Algorithms/1157.online-majority-element-in-subarray/README.md @@ -0,0 +1,27 @@ +# [1157. Online Majority Element In Subarray](https://leetcode.com/problems/online-majority-element-in-subarray/) + +implementing the class MajorityChecker, which has the following API: + +- MajorityChecker(int[] arr) constructs an instance of MajorityChecker with the given array arr; +- int query(int left, int right, int threshold) has arguments such that: + - 0 <= left <= right < arr.length representing a subarray of arr; + - 2 * threshold > right - left + 1, ie. the threshold is always a strict majority of the length of the subarray + +Each query(...) returns the element in arr[left], arr[left+1], ..., arr[right] that occurs at least threshold times, or -1 if no such element exists. + +Example: + +```text +MajorityChecker majorityChecker = new MajorityChecker([1,1,2,2,1,1]); +majorityChecker.query(0,5,4); // returns 1 +majorityChecker.query(0,3,3); // returns -1 +majorityChecker.query(2,3,2); // returns 2 +``` + +Constraints: + +- `1 <= arr.length <= 20000` +- `1 <= arr[i] <= 20000` +- `For each query, 0 <= left <= right < len(arr)` +- `For each query, 2 * threshold > right - left + 1` +- `The number of queries is at most 10000` diff --git a/Algorithms/1157.online-majority-element-in-subarray/online-majority-element-in-subarray.go b/Algorithms/1157.online-majority-element-in-subarray/online-majority-element-in-subarray.go new file mode 100755 index 000000000..476199cc7 --- /dev/null +++ b/Algorithms/1157.online-majority-element-in-subarray/online-majority-element-in-subarray.go @@ -0,0 +1,42 @@ +package problem1157 + +import ( + "math/rand" + "sort" +) + +// ref: https://leetcode.com/problems/online-majority-element-in-subarray/discuss/355848/Python-Binary-Search-%2B-Find-the-Majority-Element + +// MajorityChecker is .. +type MajorityChecker struct { + arr []int + a2i map[int][]int +} + +// Constructor is ... +func Constructor(arr []int) MajorityChecker { + a2i := make(map[int][]int, 64) + for i, a := range arr { + a2i[a] = append(a2i[a], i) + } + return MajorityChecker{ + arr: arr, + a2i: a2i, + } +} + +// Query is ... +func (mc *MajorityChecker) Query(left int, right int, threshold int) int { + for i := 0; i < 20; i++ { + index := rand.Intn(right-left+1) + left + a := mc.arr[index] + a2i := mc.a2i[a] + n := len(a2i) + l := sort.Search(n, func(i int) bool { return a2i[i] >= left }) + r := sort.Search(n, func(i int) bool { return a2i[i] > right }) + if r-l >= threshold { + return a + } + } + return -1 +} diff --git a/Algorithms/1157.online-majority-element-in-subarray/online-majority-element-in-subarray_test.go b/Algorithms/1157.online-majority-element-in-subarray/online-majority-element-in-subarray_test.go new file mode 100755 index 000000000..53afe1986 --- /dev/null +++ b/Algorithms/1157.online-majority-element-in-subarray/online-majority-element-in-subarray_test.go @@ -0,0 +1,39 @@ +package problem1157 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_MajorityChecker(t *testing.T) { + a := assert.New(t) + // + arr := []int{1, 1, 2, 2, 1, 1} + mc := Constructor(arr) + tcs := []struct { + left, right, threshold, ans int + }{ + {0, 3, 3, -1}, + {0, 5, 4, 1}, + {2, 3, 2, 2}, + } + for _, tc := range tcs { + a.Equal(tc.ans, mc.Query(tc.left, tc.right, tc.threshold)) + } +} + +func Test_MajorityChecker_long(t *testing.T) { + a := assert.New(t) + // + arr := []int{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1} + mc := Constructor(arr) + tcs := []struct { + left, right, threshold, ans int + }{ + {0, 19999, 13818, 1}, {0, 19999, 10332, 1}, {0, 19999, 10291, 1}, {0, 19999, 16784, 1}, {0, 19999, 15886, 1}, {0, 19999, 12386, 1}, {0, 19999, 12455, 1}, {0, 19999, 17788, 1}, {0, 19999, 17394, 1}, {0, 19999, 19738, 1}, {0, 19999, 19806, 1}, {0, 19999, 16961, 1}, {0, 19999, 13068, 1}, {0, 19999, 15500, 1}, {0, 19999, 10887, 1}, {0, 19999, 11200, 1}, {0, 19999, 18695, 1}, {0, 19999, 16869, 1}, {0, 19999, 14319, 1}, {0, 19999, 14091, 1}, {0, 19999, 14026, 1}, {0, 19999, 15299, 1}, {0, 19999, 15039, 1}, {0, 19999, 12617, 1}, {0, 19999, 10904, 1}, {0, 19999, 14778, 1}, {0, 19999, 10356, 1}, {0, 19999, 13095, 1}, {0, 19999, 16701, 1}, {0, 19999, 11881, 1}, {0, 19999, 18687, 1}, {0, 19999, 10917, 1}, {0, 19999, 17364, 1}, {0, 19999, 12395, 1}, {0, 19999, 18531, 1}, {0, 19999, 16709, 1}, {0, 19999, 11717, 1}, {0, 19999, 13149, 1}, {0, 19999, 18314, 1}, {0, 19999, 17058, 1}, {0, 19999, 14793, 1}, {0, 19999, 15061, 1}, {0, 19999, 15714, 1}, {0, 19999, 12135, 1}, {0, 19999, 18306, 1}, {0, 19999, 11725, 1}, {0, 19999, 19031, 1}, {0, 19999, 15090, 1}, {0, 19999, 17692, 1}, {0, 19999, 13478, 1}, {0, 19999, 17870, 1}, {0, 19999, 19275, 1}, {0, 19999, 13934, 1}, {0, 19999, 17035, 1}, {0, 19999, 19890, 1}, {0, 19999, 17442, 1}, {0, 19999, 15291, 1}, {0, 19999, 14468, 1}, {0, 19999, 11575, 1}, {0, 19999, 11538, 1}, {0, 19999, 13618, 1}, {0, 19999, 15670, 1}, {0, 19999, 15166, 1}, {0, 19999, 18451, 1}, {0, 19999, 15050, 1}, {0, 19999, 15797, 1}, {0, 19999, 14465, 1}, {0, 19999, 13155, 1}, {0, 19999, 11565, 1}, {0, 19999, 15656, 1}, {0, 19999, 10843, 1}, {0, 19999, 15821, 1}, {0, 19999, 14175, 1}, {0, 19999, 18029, 1}, {0, 19999, 10328, 1}, {0, 19999, 19796, 1}, {0, 19999, 11913, 1}, {0, 19999, 16466, 1}, {0, 19999, 10383, 1}, {0, 19999, 16003, 1}, {0, 19999, 19538, 1}, {0, 19999, 11910, 1}, {0, 19999, 15918, 1}, {0, 19999, 19290, 1}, {0, 19999, 15743, 1}, {0, 19999, 10506, 1}, {0, 19999, 10561, 1}, {0, 19999, 11523, 1}, {0, 19999, 10861, 1}, {0, 19999, 14599, 1}, {0, 19999, 15885, 1}, {0, 19999, 13906, 1}, {0, 19999, 17113, 1}, {0, 19999, 15518, 1}, {0, 19999, 16834, 1}, {0, 19999, 11849, 1}, {0, 19999, 15471, 1}, {0, 19999, 11251, 1}, {0, 19999, 10893, 1}, {0, 19999, 13640, 1}, {0, 19999, 16190, 1}, {0, 19999, 19535, 1}, {0, 19999, 11513, 1}, {0, 19999, 13176, 1}, {0, 19999, 14422, 1}, {0, 19999, 19033, 1}, {0, 19999, 14406, 1}, {0, 19999, 14995, 1}, {0, 19999, 11614, 1}, {0, 19999, 18921, 1}, {0, 19999, 10749, 1}, {0, 19999, 11106, 1}, {0, 19999, 14815, 1}, {0, 19999, 17077, 1}, {0, 19999, 14032, 1}, {0, 19999, 12689, 1}, {0, 19999, 19382, 1}, {0, 19999, 13879, 1}, {0, 19999, 17884, 1}, {0, 19999, 17391, 1}, {0, 19999, 17463, 1}, {0, 19999, 11403, 1}, {0, 19999, 10609, 1}, {0, 19999, 17538, 1}, {0, 19999, 19920, 1}, {0, 19999, 15474, 1}, {0, 19999, 12632, 1}, {0, 19999, 13808, 1}, {0, 19999, 16098, 1}, {0, 19999, 19476, 1}, {0, 19999, 18678, 1}, {0, 19999, 15869, 1}, {0, 19999, 17123, 1}, {0, 19999, 13306, 1}, {0, 19999, 12631, 1}, {0, 19999, 11092, 1}, {0, 19999, 17926, 1}, {0, 19999, 11834, 1}, {0, 19999, 12098, 1}, {0, 19999, 12305, 1}, {0, 19999, 15798, 1}, {0, 19999, 17897, 1}, {0, 19999, 18907, 1}, {0, 19999, 12132, 1}, {0, 19999, 17006, 1}, {0, 19999, 10959, 1}, {0, 19999, 18102, 1}, {0, 19999, 18112, 1}, {0, 19999, 15868, 1}, {0, 19999, 17073, 1}, {0, 19999, 10770, 1}, {0, 19999, 13272, 1}, {0, 19999, 16213, 1}, {0, 19999, 10147, 1}, {0, 19999, 11207, 1}, {0, 19999, 19900, 1}, {0, 19999, 10812, 1}, {0, 19999, 10941, 1}, {0, 19999, 14380, 1}, {0, 19999, 11454, 1}, {0, 19999, 17702, 1}, {0, 19999, 15877, 1}, {0, 19999, 17745, 1}, {0, 19999, 13484, 1}, {0, 19999, 13535, 1}, {0, 19999, 12423, 1}, {0, 19999, 11717, 1}, {0, 19999, 10217, 1}, {0, 19999, 18425, 1}, {0, 19999, 11984, 1}, {0, 19999, 18344, 1}, {0, 19999, 15288, 1}, {0, 19999, 10130, 1}, {0, 19999, 17944, 1}, {0, 19999, 11233, 1}, {0, 19999, 19633, 1}, {0, 19999, 11595, 1}, {0, 19999, 16062, 1}, {0, 19999, 15866, 1}, {0, 19999, 14899, 1}, {0, 19999, 17256, 1}, {0, 19999, 17772, 1}, {0, 19999, 18563, 1}, {0, 19999, 18140, 1}, {0, 19999, 17901, 1}, {0, 19999, 11598, 1}, {0, 19999, 17699, 1}, {0, 19999, 14176, 1}, {0, 19999, 11551, 1}, {0, 19999, 16119, 1}, {0, 19999, 13400, 1}, {0, 19999, 16324, 1}, {0, 19999, 13479, 1}, {0, 19999, 19180, 1}, {0, 19999, 12395, 1}, {0, 19999, 10810, 1}, {0, 19999, 19442, 1}, {0, 19999, 10202, 1}, {0, 19999, 13818, 1}, {0, 19999, 16180, 1}, {0, 19999, 19257, 1}, {0, 19999, 13049, 1}, {0, 19999, 17126, 1}, {0, 19999, 10637, 1}, {0, 19999, 11101, 1}, {0, 19999, 14244, 1}, {0, 19999, 14235, 1}, {0, 19999, 15896, 1}, {0, 19999, 17876, 1}, {0, 19999, 11161, 1}, {0, 19999, 18147, 1}, {0, 19999, 14399, 1}, {0, 19999, 15438, 1}, {0, 19999, 12013, 1}, {0, 19999, 16982, 1}, {0, 19999, 15552, 1}, {0, 19999, 14905, 1}, {0, 19999, 11355, 1}, {0, 19999, 12804, 1}, {0, 19999, 14722, 1}, {0, 19999, 17486, 1}, {0, 19999, 18031, 1}, {0, 19999, 16736, 1}, {0, 19999, 19704, 1}, {0, 19999, 19177, 1}, {0, 19999, 13090, 1}, {0, 19999, 12097, 1}, {0, 19999, 11991, 1}, {0, 19999, 13387, 1}, {0, 19999, 13911, 1}, {0, 19999, 10474, 1}, {0, 19999, 11339, 1}, {0, 19999, 12525, 1}, {0, 19999, 11392, 1}, {0, 19999, 16465, 1}, {0, 19999, 11124, 1}, {0, 19999, 11944, 1}, {0, 19999, 13209, 1}, {0, 19999, 10263, 1}, {0, 19999, 16138, 1}, {0, 19999, 10564, 1}, {0, 19999, 17117, 1}, {0, 19999, 12331, 1}, {0, 19999, 18662, 1}, {0, 19999, 19366, 1}, {0, 19999, 11874, 1}, {0, 19999, 17268, 1}, {0, 19999, 13854, 1}, {0, 19999, 12178, 1}, {0, 19999, 10215, 1}, {0, 19999, 15394, 1}, {0, 19999, 13166, 1}, {0, 19999, 10750, 1}, {0, 19999, 15890, 1}, {0, 19999, 12634, 1}, {0, 19999, 15395, 1}, {0, 19999, 14561, 1}, {0, 19999, 15033, 1}, {0, 19999, 13328, 1}, {0, 19999, 12049, 1}, {0, 19999, 15475, 1}, {0, 19999, 11508, 1}, {0, 19999, 15885, 1}, {0, 19999, 14781, 1}, {0, 19999, 17473, 1}, {0, 19999, 18050, 1}, {0, 19999, 14415, 1}, {0, 19999, 14552, 1}, {0, 19999, 13616, 1}, {0, 19999, 16698, 1}, {0, 19999, 14474, 1}, {0, 19999, 13855, 1}, {0, 19999, 10991, 1}, {0, 19999, 13721, 1}, {0, 19999, 12743, 1}, {0, 19999, 19526, 1}, {0, 19999, 12948, 1}, {0, 19999, 10257, 1}, {0, 19999, 19674, 1}, {0, 19999, 17884, 1}, {0, 19999, 15898, 1}, {0, 19999, 10753, 1}, {0, 19999, 19004, 1}, {0, 19999, 16084, 1}, {0, 19999, 15765, 1}, {0, 19999, 19384, 1}, {0, 19999, 17416, 1}, {0, 19999, 17339, 1}, {0, 19999, 19712, 1}, {0, 19999, 16064, 1}, {0, 19999, 11983, 1}, {0, 19999, 13984, 1}, {0, 19999, 12282, 1}, {0, 19999, 12138, 1}, {0, 19999, 12424, 1}, {0, 19999, 12331, 1}, {0, 19999, 11725, 1}, {0, 19999, 10748, 1}, {0, 19999, 11325, 1}, {0, 19999, 15581, 1}, {0, 19999, 17072, 1}, {0, 19999, 13285, 1}, {0, 19999, 14227, 1}, {0, 19999, 10999, 1}, {0, 19999, 12160, 1}, {0, 19999, 18037, 1}, {0, 19999, 17385, 1}, {0, 19999, 15294, 1}, {0, 19999, 11108, 1}, {0, 19999, 17625, 1}, {0, 19999, 13551, 1}, {0, 19999, 13276, 1}, {0, 19999, 19599, 1}, {0, 19999, 17090, 1}, {0, 19999, 15660, 1}, {0, 19999, 11369, 1}, {0, 19999, 19082, 1}, {0, 19999, 12525, 1}, {0, 19999, 14237, 1}, {0, 19999, 16996, 1}, {0, 19999, 14341, 1}, {0, 19999, 18233, 1}, {0, 19999, 18129, 1}, {0, 19999, 16340, 1}, {0, 19999, 13531, 1}, {0, 19999, 14865, 1}, {0, 19999, 18763, 1}, {0, 19999, 15991, 1}, {0, 19999, 17328, 1}, {0, 19999, 15752, 1}, {0, 19999, 15089, 1}, {0, 19999, 13357, 1}, {0, 19999, 19807, 1}, {0, 19999, 11039, 1}, {0, 19999, 14664, 1}, {0, 19999, 12356, 1}, {0, 19999, 16416, 1}, {0, 19999, 17332, 1}, {0, 19999, 15766, 1}, {0, 19999, 12321, 1}, {0, 19999, 17350, 1}, {0, 19999, 18652, 1}, {0, 19999, 19614, 1}, {0, 19999, 12415, 1}, {0, 19999, 13370, 1}, {0, 19999, 10507, 1}, {0, 19999, 18948, 1}, {0, 19999, 18705, 1}, {0, 19999, 14702, 1}, {0, 19999, 14591, 1}, {0, 19999, 10971, 1}, {0, 19999, 13551, 1}, {0, 19999, 19021, 1}, {0, 19999, 19594, 1}, {0, 19999, 10830, 1}, {0, 19999, 19236, 1}, {0, 19999, 16789, 1}, {0, 19999, 14060, 1}, {0, 19999, 11856, 1}, {0, 19999, 19780, 1}, {0, 19999, 15788, 1}, {0, 19999, 13393, 1}, {0, 19999, 19064, 1}, {0, 19999, 17935, 1}, {0, 19999, 16146, 1}, {0, 19999, 13412, 1}, {0, 19999, 14706, 1}, {0, 19999, 13204, 1}, {0, 19999, 15765, 1}, {0, 19999, 17434, 1}, {0, 19999, 13734, 1}, {0, 19999, 16037, 1}, {0, 19999, 11097, 1}, {0, 19999, 18012, 1}, {0, 19999, 18254, 1}, {0, 19999, 15800, 1}, {0, 19999, 19586, 1}, {0, 19999, 12212, 1}, {0, 19999, 13734, 1}, {0, 19999, 15042, 1}, {0, 19999, 15097, 1}, {0, 19999, 16469, 1}, {0, 19999, 18905, 1}, {0, 19999, 14437, 1}, {0, 19999, 10801, 1}, {0, 19999, 12793, 1}, {0, 19999, 10780, 1}, {0, 19999, 14010, 1}, {0, 19999, 14978, 1}, {0, 19999, 11561, 1}, {0, 19999, 15111, 1}, {0, 19999, 11611, 1}, {0, 19999, 15143, 1}, {0, 19999, 17386, 1}, {0, 19999, 17957, 1}, {0, 19999, 19578, 1}, {0, 19999, 11300, 1}, {0, 19999, 15678, 1}, {0, 19999, 12231, 1}, {0, 19999, 18067, 1}, {0, 19999, 17950, 1}, {0, 19999, 14506, 1}, {0, 19999, 13971, 1}, {0, 19999, 11174, 1}, {0, 19999, 13400, 1}, {0, 19999, 16788, 1}, {0, 19999, 15860, 1}, {0, 19999, 17802, 1}, {0, 19999, 14319, 1}, {0, 19999, 15836, 1}, {0, 19999, 10461, 1}, {0, 19999, 12335, 1}, {0, 19999, 13715, 1}, {0, 19999, 15289, 1}, {0, 19999, 10260, 1}, {0, 19999, 14687, 1}, {0, 19999, 15395, 1}, {0, 19999, 10994, 1}, {0, 19999, 10420, 1}, {0, 19999, 10502, 1}, {0, 19999, 18196, 1}, {0, 19999, 19220, 1}, {0, 19999, 13859, 1}, {0, 19999, 18437, 1}, {0, 19999, 18418, 1}, {0, 19999, 19045, 1}, {0, 19999, 15874, 1}, {0, 19999, 17910, 1}, {0, 19999, 19604, 1}, {0, 19999, 12212, 1}, {0, 19999, 17870, 1}, {0, 19999, 17323, 1}, {0, 19999, 17005, 1}, {0, 19999, 18549, 1}, {0, 19999, 12213, 1}, {0, 19999, 16499, 1}, {0, 19999, 12100, 1}, {0, 19999, 11594, 1}, {0, 19999, 16071, 1}, {0, 19999, 10211, 1}, {0, 19999, 19142, 1}, {0, 19999, 12787, 1}, {0, 19999, 17230, 1}, {0, 19999, 13283, 1}, {0, 19999, 10840, 1}, {0, 19999, 15506, 1}, {0, 19999, 10443, 1}, {0, 19999, 17254, 1}, {0, 19999, 10318, 1}, {0, 19999, 15462, 1}, {0, 19999, 13660, 1}, {0, 19999, 10119, 1}, {0, 19999, 14425, 1}, {0, 19999, 11614, 1}, {0, 19999, 19337, 1}, {0, 19999, 19652, 1}, {0, 19999, 15673, 1}, {0, 19999, 16954, 1}, {0, 19999, 10622, 1}, {0, 19999, 16511, 1}, {0, 19999, 12415, 1}, {0, 19999, 16185, 1}, {0, 19999, 14854, 1}, {0, 19999, 17393, 1}, {0, 19999, 13553, 1}, {0, 19999, 17139, 1}, {0, 19999, 10434, 1}, {0, 19999, 18397, 1}, {0, 19999, 16377, 1}, {0, 19999, 17115, 1}, {0, 19999, 14653, 1}, {0, 19999, 17849, 1}, {0, 19999, 10498, 1}, {0, 19999, 14193, 1}, {0, 19999, 12526, 1}, {0, 19999, 13510, 1}, {0, 19999, 13039, 1}, {0, 19999, 11288, 1}, {0, 19999, 12335, 1}, {0, 19999, 13830, 1}, {0, 19999, 14975, 1}, {0, 19999, 17768, 1}, {0, 19999, 17146, 1}, {0, 19999, 12635, 1}, {0, 19999, 10139, 1}, {0, 19999, 10177, 1}, {0, 19999, 11354, 1}, {0, 19999, 13990, 1}, {0, 19999, 16792, 1}, {0, 19999, 17881, 1}, {0, 19999, 11391, 1}, {0, 19999, 15235, 1}, {0, 19999, 19958, 1}, {0, 19999, 13225, 1}, {0, 19999, 12299, 1}, {0, 19999, 10182, 1}, {0, 19999, 13295, 1}, {0, 19999, 17087, 1}, {0, 19999, 17853, 1}, {0, 19999, 14113, 1}, {0, 19999, 16041, 1}, {0, 19999, 13620, 1}, {0, 19999, 12371, 1}, {0, 19999, 13267, 1}, {0, 19999, 14863, 1}, {0, 19999, 18378, 1}, {0, 19999, 10110, 1}, {0, 19999, 11228, 1}, {0, 19999, 17314, 1}, {0, 19999, 10943, 1}, {0, 19999, 17353, 1}, {0, 19999, 10212, 1}, {0, 19999, 17146, 1}, {0, 19999, 18011, 1}, {0, 19999, 18379, 1}, {0, 19999, 17995, 1}, {0, 19999, 11422, 1}, {0, 19999, 12764, 1}, {0, 19999, 18548, 1}, {0, 19999, 10650, 1}, {0, 19999, 16810, 1}, {0, 19999, 11774, 1}, {0, 19999, 13218, 1}, {0, 19999, 10907, 1}, {0, 19999, 17505, 1}, {0, 19999, 10914, 1}, {0, 19999, 12001, 1}, {0, 19999, 18031, 1}, {0, 19999, 19866, 1}, {0, 19999, 14532, 1}, {0, 19999, 16847, 1}, {0, 19999, 10319, 1}, {0, 19999, 18888, 1}, {0, 19999, 10804, 1}, {0, 19999, 11020, 1}, {0, 19999, 17911, 1}, {0, 19999, 13807, 1}, {0, 19999, 19712, 1}, {0, 19999, 14961, 1}, {0, 19999, 19023, 1}, {0, 19999, 15405, 1}, {0, 19999, 11243, 1}, {0, 19999, 14362, 1}, {0, 19999, 11766, 1}, {0, 19999, 18258, 1}, {0, 19999, 18858, 1}, {0, 19999, 10132, 1}, {0, 19999, 15706, 1}, {0, 19999, 17382, 1}, {0, 19999, 11055, 1}, {0, 19999, 13866, 1}, {0, 19999, 15013, 1}, {0, 19999, 10278, 1}, {0, 19999, 19239, 1}, {0, 19999, 19780, 1}, {0, 19999, 11606, 1}, {0, 19999, 10546, 1}, {0, 19999, 13507, 1}, {0, 19999, 16875, 1}, {0, 19999, 11953, 1}, {0, 19999, 10098, 1}, {0, 19999, 14712, 1}, {0, 19999, 18921, 1}, {0, 19999, 18921, 1}, {0, 19999, 15877, 1}, {0, 19999, 13416, 1}, {0, 19999, 15711, 1}, {0, 19999, 16385, 1}, {0, 19999, 19062, 1}, {0, 19999, 10032, 1}, {0, 19999, 18651, 1}, {0, 19999, 17999, 1}, {0, 19999, 17244, 1}, {0, 19999, 17420, 1}, {0, 19999, 11188, 1}, {0, 19999, 11581, 1}, {0, 19999, 15812, 1}, {0, 19999, 14048, 1}, {0, 19999, 12233, 1}, {0, 19999, 10857, 1}, {0, 19999, 18730, 1}, {0, 19999, 18513, 1}, {0, 19999, 15388, 1}, {0, 19999, 19484, 1}, {0, 19999, 13154, 1}, {0, 19999, 17750, 1}, {0, 19999, 17999, 1}, {0, 19999, 17166, 1}, {0, 19999, 17008, 1}, {0, 19999, 19917, 1}, {0, 19999, 12373, 1}, {0, 19999, 13112, 1}, {0, 19999, 14335, 1}, {0, 19999, 11202, 1}, {0, 19999, 15392, 1}, {0, 19999, 13772, 1}, {0, 19999, 17759, 1}, {0, 19999, 13578, 1}, {0, 19999, 19553, 1}, {0, 19999, 16859, 1}, {0, 19999, 16258, 1}, {0, 19999, 13184, 1}, {0, 19999, 19196, 1}, {0, 19999, 16925, 1}, {0, 19999, 10787, 1}, {0, 19999, 14158, 1}, {0, 19999, 11789, 1}, {0, 19999, 13003, 1}, {0, 19999, 10366, 1}, {0, 19999, 13316, 1}, {0, 19999, 17438, 1}, {0, 19999, 10783, 1}, {0, 19999, 10580, 1}, {0, 19999, 18755, 1}, {0, 19999, 16537, 1}, {0, 19999, 17987, 1}, {0, 19999, 13501, 1}, {0, 19999, 14079, 1}, {0, 19999, 12436, 1}, {0, 19999, 12892, 1}, {0, 19999, 10298, 1}, {0, 19999, 19474, 1}, {0, 19999, 17000, 1}, {0, 19999, 14496, 1}, {0, 19999, 11268, 1}, {0, 19999, 11860, 1}, {0, 19999, 16030, 1}, {0, 19999, 14088, 1}, {0, 19999, 14640, 1}, {0, 19999, 17041, 1}, {0, 19999, 13092, 1}, {0, 19999, 15215, 1}, {0, 19999, 12512, 1}, {0, 19999, 19271, 1}, {0, 19999, 16021, 1}, {0, 19999, 12609, 1}, {0, 19999, 11128, 1}, {0, 19999, 16590, 1}, {0, 19999, 13324, 1}, {0, 19999, 15110, 1}, {0, 19999, 12118, 1}, {0, 19999, 15779, 1}, {0, 19999, 12683, 1}, {0, 19999, 11294, 1}, {0, 19999, 15687, 1}, {0, 19999, 10547, 1}, {0, 19999, 16506, 1}, {0, 19999, 13196, 1}, {0, 19999, 15585, 1}, {0, 19999, 10409, 1}, {0, 19999, 15667, 1}, {0, 19999, 17219, 1}, {0, 19999, 18378, 1}, {0, 19999, 10863, 1}, {0, 19999, 18371, 1}, {0, 19999, 14542, 1}, {0, 19999, 15998, 1}, {0, 19999, 19533, 1}, {0, 19999, 12025, 1}, {0, 19999, 13854, 1}, {0, 19999, 16601, 1}, {0, 19999, 14403, 1}, {0, 19999, 14101, 1}, {0, 19999, 15323, 1}, {0, 19999, 19570, 1}, {0, 19999, 14811, 1}, {0, 19999, 11489, 1}, {0, 19999, 16828, 1}, {0, 19999, 15720, 1}, {0, 19999, 17955, 1}, {0, 19999, 15512, 1}, {0, 19999, 13307, 1}, {0, 19999, 13751, 1}, {0, 19999, 19237, 1}, {0, 19999, 11603, 1}, {0, 19999, 17844, 1}, {0, 19999, 17651, 1}, {0, 19999, 14734, 1}, {0, 19999, 11155, 1}, {0, 19999, 19376, 1}, {0, 19999, 18382, 1}, {0, 19999, 17639, 1}, {0, 19999, 13917, 1}, {0, 19999, 11323, 1}, {0, 19999, 12589, 1}, {0, 19999, 19947, 1}, {0, 19999, 11087, 1}, {0, 19999, 18263, 1}, {0, 19999, 13554, 1}, {0, 19999, 12731, 1}, {0, 19999, 17419, 1}, {0, 19999, 19302, 1}, {0, 19999, 16946, 1}, {0, 19999, 19229, 1}, {0, 19999, 17828, 1}, {0, 19999, 14528, 1}, {0, 19999, 19663, 1}, {0, 19999, 17371, 1}, {0, 19999, 12363, 1}, {0, 19999, 11086, 1}, {0, 19999, 18821, 1}, {0, 19999, 12564, 1}, {0, 19999, 17672, 1}, {0, 19999, 14725, 1}, {0, 19999, 13012, 1}, {0, 19999, 16746, 1}, {0, 19999, 11607, 1}, {0, 19999, 18447, 1}, {0, 19999, 15943, 1}, {0, 19999, 18234, 1}, {0, 19999, 18224, 1}, {0, 19999, 11506, 1}, {0, 19999, 15273, 1}, {0, 19999, 18171, 1}, {0, 19999, 10185, 1}, {0, 19999, 11766, 1}, {0, 19999, 17406, 1}, {0, 19999, 14529, 1}, {0, 19999, 11289, 1}, {0, 19999, 16594, 1}, {0, 19999, 13378, 1}, {0, 19999, 19675, 1}, {0, 19999, 16346, 1}, {0, 19999, 17247, 1}, {0, 19999, 11061, 1}, {0, 19999, 17721, 1}, {0, 19999, 13407, 1}, {0, 19999, 17726, 1}, {0, 19999, 13022, 1}, {0, 19999, 19272, 1}, {0, 19999, 14567, 1}, {0, 19999, 16168, 1}, {0, 19999, 13051, 1}, {0, 19999, 15002, 1}, {0, 19999, 11528, 1}, {0, 19999, 14186, 1}, {0, 19999, 19059, 1}, {0, 19999, 15869, 1}, {0, 19999, 13995, 1}, {0, 19999, 17636, 1}, {0, 19999, 18685, 1}, {0, 19999, 19521, 1}, {0, 19999, 19961, 1}, {0, 19999, 19088, 1}, {0, 19999, 17952, 1}, {0, 19999, 18399, 1}, {0, 19999, 17195, 1}, {0, 19999, 18309, 1}, {0, 19999, 17403, 1}, {0, 19999, 19186, 1}, {0, 19999, 18574, 1}, {0, 19999, 15067, 1}, {0, 19999, 12863, 1}, {0, 19999, 18107, 1}, {0, 19999, 13205, 1}, {0, 19999, 16603, 1}, {0, 19999, 16412, 1}, {0, 19999, 13664, 1}, {0, 19999, 14463, 1}, {0, 19999, 18715, 1}, {0, 19999, 19557, 1}, {0, 19999, 12312, 1}, {0, 19999, 17489, 1}, {0, 19999, 10987, 1}, {0, 19999, 16940, 1}, {0, 19999, 12173, 1}, {0, 19999, 15765, 1}, {0, 19999, 14801, 1}, {0, 19999, 13413, 1}, {0, 19999, 11705, 1}, {0, 19999, 16323, 1}, {0, 19999, 12141, 1}, {0, 19999, 11146, 1}, {0, 19999, 14043, 1}, {0, 19999, 12677, 1}, {0, 19999, 11723, 1}, {0, 19999, 12805, 1}, {0, 19999, 13797, 1}, {0, 19999, 17403, 1}, {0, 19999, 14682, 1}, {0, 19999, 17183, 1}, {0, 19999, 19210, 1}, {0, 19999, 18809, 1}, {0, 19999, 16282, 1}, {0, 19999, 19914, 1}, {0, 19999, 18322, 1}, {0, 19999, 19977, 1}, {0, 19999, 13708, 1}, {0, 19999, 10979, 1}, {0, 19999, 15439, 1}, {0, 19999, 16942, 1}, {0, 19999, 17420, 1}, {0, 19999, 17463, 1}, {0, 19999, 12849, 1}, {0, 19999, 12708, 1}, {0, 19999, 10215, 1}, {0, 19999, 14272, 1}, {0, 19999, 16753, 1}, {0, 19999, 10290, 1}, {0, 19999, 16745, 1}, {0, 19999, 11712, 1}, {0, 19999, 17739, 1}, {0, 19999, 14536, 1}, {0, 19999, 16067, 1}, {0, 19999, 19861, 1}, {0, 19999, 11346, 1}, {0, 19999, 18545, 1}, {0, 19999, 18170, 1}, {0, 19999, 12988, 1}, {0, 19999, 12524, 1}, {0, 19999, 15766, 1}, {0, 19999, 17560, 1}, {0, 19999, 16592, 1}, {0, 19999, 19991, 1}, {0, 19999, 11526, 1}, {0, 19999, 11072, 1}, {0, 19999, 18479, 1}, {0, 19999, 15064, 1}, {0, 19999, 16562, 1}, {0, 19999, 11574, 1}, {0, 19999, 17859, 1}, {0, 19999, 12536, 1}, {0, 19999, 13810, 1}, {0, 19999, 13840, 1}, {0, 19999, 14204, 1}, {0, 19999, 11749, 1}, {0, 19999, 17333, 1}, {0, 19999, 12832, 1}, {0, 19999, 19437, 1}, {0, 19999, 15046, 1}, {0, 19999, 17460, 1}, {0, 19999, 15570, 1}, {0, 19999, 13678, 1}, {0, 19999, 14802, 1}, {0, 19999, 10314, 1}, {0, 19999, 19131, 1}, {0, 19999, 10331, 1}, {0, 19999, 10840, 1}, {0, 19999, 15735, 1}, {0, 19999, 11356, 1}, {0, 19999, 15266, 1}, {0, 19999, 19793, 1}, {0, 19999, 17477, 1}, {0, 19999, 17630, 1}, {0, 19999, 15819, 1}, {0, 19999, 11809, 1}, {0, 19999, 15517, 1}, {0, 19999, 18509, 1}, {0, 19999, 19917, 1}, {0, 19999, 14985, 1}, {0, 19999, 15584, 1}, {0, 19999, 15914, 1}, {0, 19999, 10658, 1}, {0, 19999, 14415, 1}, {0, 19999, 14499, 1}, {0, 19999, 16466, 1}, {0, 19999, 15482, 1}, {0, 19999, 16984, 1}, {0, 19999, 11632, 1}, {0, 19999, 10465, 1}, {0, 19999, 19810, 1}, {0, 19999, 16108, 1}, {0, 19999, 16458, 1}, {0, 19999, 10910, 1}, {0, 19999, 14495, 1}, {0, 19999, 10630, 1}, {0, 19999, 19671, 1}, {0, 19999, 10384, 1}, {0, 19999, 13887, 1}, {0, 19999, 19827, 1}, {0, 19999, 16698, 1}, {0, 19999, 12289, 1}, {0, 19999, 14523, 1}, {0, 19999, 11160, 1}, {0, 19999, 16969, 1}, {0, 19999, 12298, 1}, {0, 19999, 18380, 1}, {0, 19999, 19293, 1}, {0, 19999, 15752, 1}, {0, 19999, 15186, 1}, {0, 19999, 16779, 1}, {0, 19999, 13720, 1}, {0, 19999, 11594, 1}, {0, 19999, 17321, 1}, {0, 19999, 16018, 1}, {0, 19999, 12772, 1}, {0, 19999, 19356, 1}, {0, 19999, 17621, 1}, {0, 19999, 10887, 1}, {0, 19999, 15804, 1}, {0, 19999, 12756, 1}, {0, 19999, 10771, 1}, {0, 19999, 16950, 1}, {0, 19999, 19232, 1}, {0, 19999, 19140, 1}, {0, 19999, 14188, 1}, {0, 19999, 12544, 1}, {0, 19999, 12516, 1}, {0, 19999, 12729, 1}, {0, 19999, 19883, 1}, {0, 19999, 19110, 1}, {0, 19999, 13699, 1}, {0, 19999, 11062, 1}, {0, 19999, 18107, 1}, {0, 19999, 11483, 1}, {0, 19999, 19571, 1}, {0, 19999, 17260, 1}, {0, 19999, 10636, 1}, {0, 19999, 18778, 1}, {0, 19999, 18320, 1}, {0, 19999, 14999, 1}, {0, 19999, 14219, 1}, {0, 19999, 10287, 1}, {0, 19999, 18901, 1}, {0, 19999, 15274, 1}, {0, 19999, 13093, 1}, {0, 19999, 11361, 1}, {0, 19999, 18006, 1}, {0, 19999, 13381, 1}, {0, 19999, 12105, 1}, {0, 19999, 15793, 1}, {0, 19999, 10386, 1}, {0, 19999, 11177, 1}, {0, 19999, 19096, 1}, {0, 19999, 13692, 1}, {0, 19999, 14114, 1}, {0, 19999, 15378, 1}, {0, 19999, 11250, 1}, {0, 19999, 11921, 1}, {0, 19999, 11878, 1}, {0, 19999, 13907, 1}, {0, 19999, 16550, 1}, {0, 19999, 15175, 1}, {0, 19999, 19624, 1}, {0, 19999, 18272, 1}, {0, 19999, 18484, 1}, {0, 19999, 18084, 1}, {0, 19999, 13666, 1}, {0, 19999, 16055, 1}, {0, 19999, 10401, 1}, {0, 19999, 14085, 1}, {0, 19999, 17328, 1}, {0, 19999, 17871, 1}, {0, 19999, 19458, 1}, {0, 19999, 12684, 1}, {0, 19999, 17321, 1}, {0, 19999, 15604, 1}, {0, 19999, 12806, 1}, {0, 19999, 18978, 1}, {0, 19999, 12976, 1}, {0, 19999, 19442, 1}, {0, 19999, 10316, 1}, {0, 19999, 19224, 1}, {0, 19999, 16182, 1}, {0, 19999, 18574, 1}, {0, 19999, 14187, 1}, {0, 19999, 10011, 1}, {0, 19999, 18649, 1}, {0, 19999, 12391, 1}, {0, 19999, 19424, 1}, {0, 19999, 14870, 1}, {0, 19999, 11180, 1}, {0, 19999, 15596, 1}, {0, 19999, 17326, 1}, {0, 19999, 19146, 1}, {0, 19999, 14385, 1}, {0, 19999, 14989, 1}, {0, 19999, 16839, 1}, {0, 19999, 12247, 1}, {0, 19999, 18275, 1}, {0, 19999, 17248, 1}, {0, 19999, 15562, 1}, {0, 19999, 16938, 1}, {0, 19999, 14081, 1}, {0, 19999, 14903, 1}, {0, 19999, 12308, 1}, {0, 19999, 13254, 1}, {0, 19999, 19823, 1}, {0, 19999, 15295, 1}, {0, 19999, 18938, 1}, {0, 19999, 12135, 1}, {0, 19999, 12001, 1}, {0, 19999, 15733, 1}, {0, 19999, 14621, 1}, {0, 19999, 15960, 1}, {0, 19999, 10758, 1}, {0, 19999, 17708, 1}, {0, 19999, 14076, 1}, {0, 19999, 18852, 1}, {0, 19999, 17167, 1}, {0, 19999, 14256, 1}, {0, 19999, 19232, 1}, {0, 19999, 19804, 1}, {0, 19999, 14523, 1}, {0, 19999, 18487, 1}, {0, 19999, 16812, 1}, {0, 19999, 15713, 1}, {0, 19999, 16538, 1}, {0, 19999, 14754, 1}, {0, 19999, 19857, 1}, {0, 19999, 19832, 1}, {0, 19999, 15710, 1}, {0, 19999, 11559, 1}, {0, 19999, 15812, 1}, {0, 19999, 17977, 1}, {0, 19999, 12443, 1}, {0, 19999, 18141, 1}, {0, 19999, 10145, 1}, {0, 19999, 17823, 1}, {0, 19999, 19797, 1}, {0, 19999, 11981, 1}, {0, 19999, 16336, 1}, {0, 19999, 17828, 1}, {0, 19999, 12936, 1}, {0, 19999, 10335, 1}, {0, 19999, 18557, 1}, {0, 19999, 14556, 1}, {0, 19999, 12200, 1}, {0, 19999, 13243, 1}, {0, 19999, 19903, 1}, {0, 19999, 15811, 1}, {0, 19999, 14393, 1}, {0, 19999, 16677, 1}, {0, 19999, 17789, 1}, {0, 19999, 12962, 1}, {0, 19999, 13140, 1}, {0, 19999, 12331, 1}, {0, 19999, 11031, 1}, {0, 19999, 10274, 1}, {0, 19999, 11395, 1}, {0, 19999, 13571, 1}, {0, 19999, 11891, 1}, {0, 19999, 15009, 1}, {0, 19999, 16180, 1}, {0, 19999, 19900, 1}, {0, 19999, 12735, 1}, {0, 19999, 14928, 1}, {0, 19999, 14088, 1}, {0, 19999, 11153, 1}, {0, 19999, 18977, 1}, {0, 19999, 10608, 1}, {0, 19999, 16945, 1}, {0, 19999, 19654, 1}, {0, 19999, 13625, 1}, {0, 19999, 11142, 1}, {0, 19999, 16733, 1}, {0, 19999, 12189, 1}, {0, 19999, 15140, 1}, {0, 19999, 12482, 1}, {0, 19999, 16290, 1}, {0, 19999, 12512, 1}, {0, 19999, 17482, 1}, {0, 19999, 18341, 1}, {0, 19999, 15935, 1}, {0, 19999, 10972, 1}, {0, 19999, 13815, 1}, {0, 19999, 18864, 1}, {0, 19999, 16720, 1}, {0, 19999, 13098, 1}, {0, 19999, 14779, 1}, {0, 19999, 13962, 1}, {0, 19999, 19182, 1}, {0, 19999, 11646, 1}, {0, 19999, 16628, 1}, {0, 19999, 12881, 1}, {0, 19999, 16308, 1}, {0, 19999, 19251, 1}, {0, 19999, 11389, 1}, {0, 19999, 18813, 1}, {0, 19999, 12778, 1}, {0, 19999, 16180, 1}, {0, 19999, 12759, 1}, {0, 19999, 15667, 1}, {0, 19999, 15390, 1}, {0, 19999, 19711, 1}, {0, 19999, 15204, 1}, {0, 19999, 14609, 1}, {0, 19999, 16671, 1}, {0, 19999, 11388, 1}, {0, 19999, 18183, 1}, {0, 19999, 12113, 1}, {0, 19999, 14325, 1}, {0, 19999, 19598, 1}, {0, 19999, 13748, 1}, {0, 19999, 17727, 1}, {0, 19999, 16704, 1}, {0, 19999, 19828, 1}, {0, 19999, 11960, 1}, {0, 19999, 17991, 1}, {0, 19999, 15275, 1}, {0, 19999, 13366, 1}, {0, 19999, 12757, 1}, {0, 19999, 10077, 1}, {0, 19999, 16706, 1}, {0, 19999, 17644, 1}, {0, 19999, 11979, 1}, {0, 19999, 14907, 1}, {0, 19999, 16265, 1}, {0, 19999, 17530, 1}, {0, 19999, 17992, 1}, {0, 19999, 15872, 1}, {0, 19999, 10693, 1}, {0, 19999, 18460, 1}, {0, 19999, 10025, 1}, {0, 19999, 18058, 1}, {0, 19999, 19883, 1}, {0, 19999, 16306, 1}, {0, 19999, 18877, 1}, {0, 19999, 15920, 1}, {0, 19999, 14185, 1}, {0, 19999, 19964, 1}, {0, 19999, 12836, 1}, {0, 19999, 15683, 1}, {0, 19999, 15188, 1}, {0, 19999, 19161, 1}, {0, 19999, 19286, 1}, {0, 19999, 13314, 1}, {0, 19999, 11036, 1}, {0, 19999, 16056, 1}, {0, 19999, 19374, 1}, {0, 19999, 13857, 1}, {0, 19999, 18618, 1}, {0, 19999, 10475, 1}, {0, 19999, 14822, 1}, {0, 19999, 15966, 1}, {0, 19999, 14129, 1}, {0, 19999, 19341, 1}, {0, 19999, 15500, 1}, {0, 19999, 18922, 1}, {0, 19999, 10079, 1}, {0, 19999, 18445, 1}, {0, 19999, 14050, 1}, {0, 19999, 16925, 1}, {0, 19999, 16366, 1}, {0, 19999, 12866, 1}, {0, 19999, 10114, 1}, {0, 19999, 19521, 1}, {0, 19999, 15955, 1}, {0, 19999, 16857, 1}, {0, 19999, 14931, 1}, {0, 19999, 13218, 1}, {0, 19999, 17783, 1}, {0, 19999, 14473, 1}, {0, 19999, 11876, 1}, {0, 19999, 17917, 1}, {0, 19999, 19135, 1}, {0, 19999, 12534, 1}, {0, 19999, 15487, 1}, {0, 19999, 15144, 1}, {0, 19999, 12257, 1}, {0, 19999, 14819, 1}, {0, 19999, 10094, 1}, {0, 19999, 14011, 1}, {0, 19999, 11656, 1}, {0, 19999, 16998, 1}, {0, 19999, 10843, 1}, {0, 19999, 14003, 1}, {0, 19999, 12149, 1}, {0, 19999, 10627, 1}, {0, 19999, 14596, 1}, {0, 19999, 15281, 1}, {0, 19999, 14093, 1}, {0, 19999, 18551, 1}, {0, 19999, 18723, 1}, {0, 19999, 18328, 1}, {0, 19999, 11911, 1}, {0, 19999, 16538, 1}, {0, 19999, 11049, 1}, {0, 19999, 12763, 1}, {0, 19999, 12713, 1}, {0, 19999, 17113, 1}, {0, 19999, 19278, 1}, {0, 19999, 16194, 1}, {0, 19999, 19317, 1}, {0, 19999, 18723, 1}, {0, 19999, 10210, 1}, {0, 19999, 10341, 1}, {0, 19999, 16191, 1}, {0, 19999, 15907, 1}, {0, 19999, 11810, 1}, {0, 19999, 15506, 1}, {0, 19999, 17828, 1}, {0, 19999, 18846, 1}, {0, 19999, 11644, 1}, {0, 19999, 17102, 1}, {0, 19999, 17611, 1}, {0, 19999, 15823, 1}, {0, 19999, 14723, 1}, {0, 19999, 14084, 1}, {0, 19999, 19295, 1}, {0, 19999, 15076, 1}, {0, 19999, 18321, 1}, {0, 19999, 18677, 1}, {0, 19999, 14706, 1}, {0, 19999, 18323, 1}, {0, 19999, 17614, 1}, {0, 19999, 11325, 1}, {0, 19999, 17498, 1}, {0, 19999, 12287, 1}, {0, 19999, 15282, 1}, {0, 19999, 10313, 1}, {0, 19999, 16545, 1}, {0, 19999, 10310, 1}, {0, 19999, 11477, 1}, {0, 19999, 17667, 1}, {0, 19999, 11728, 1}, {0, 19999, 19244, 1}, {0, 19999, 11596, 1}, {0, 19999, 16983, 1}, {0, 19999, 11272, 1}, {0, 19999, 12476, 1}, {0, 19999, 13926, 1}, {0, 19999, 18168, 1}, {0, 19999, 19928, 1}, {0, 19999, 11695, 1}, {0, 19999, 11878, 1}, {0, 19999, 19933, 1}, {0, 19999, 12753, 1}, {0, 19999, 19870, 1}, {0, 19999, 14504, 1}, {0, 19999, 17687, 1}, {0, 19999, 15821, 1}, {0, 19999, 13165, 1}, {0, 19999, 19420, 1}, {0, 19999, 13492, 1}, {0, 19999, 12277, 1}, {0, 19999, 13582, 1}, {0, 19999, 14568, 1}, {0, 19999, 15678, 1}, {0, 19999, 18575, 1}, {0, 19999, 18351, 1}, {0, 19999, 13606, 1}, {0, 19999, 10653, 1}, {0, 19999, 12896, 1}, {0, 19999, 11907, 1}, {0, 19999, 19682, 1}, {0, 19999, 12476, 1}, {0, 19999, 15275, 1}, {0, 19999, 19315, 1}, {0, 19999, 15669, 1}, {0, 19999, 13316, 1}, {0, 19999, 12385, 1}, {0, 19999, 16111, 1}, {0, 19999, 16484, 1}, {0, 19999, 19397, 1}, {0, 19999, 12791, 1}, {0, 19999, 10762, 1}, {0, 19999, 15789, 1}, {0, 19999, 13987, 1}, {0, 19999, 10543, 1}, {0, 19999, 10766, 1}, {0, 19999, 13284, 1}, {0, 19999, 10555, 1}, {0, 19999, 13985, 1}, {0, 19999, 18557, 1}, {0, 19999, 11485, 1}, {0, 19999, 17120, 1}, {0, 19999, 11564, 1}, {0, 19999, 12821, 1}, {0, 19999, 10239, 1}, {0, 19999, 19845, 1}, {0, 19999, 15723, 1}, {0, 19999, 18186, 1}, {0, 19999, 18603, 1}, {0, 19999, 15083, 1}, {0, 19999, 10496, 1}, {0, 19999, 18494, 1}, {0, 19999, 10141, 1}, {0, 19999, 17633, 1}, {0, 19999, 16514, 1}, {0, 19999, 12258, 1}, {0, 19999, 17761, 1}, {0, 19999, 18405, 1}, {0, 19999, 18950, 1}, {0, 19999, 14397, 1}, {0, 19999, 13469, 1}, {0, 19999, 19935, 1}, {0, 19999, 17376, 1}, {0, 19999, 13593, 1}, {0, 19999, 17499, 1}, {0, 19999, 15799, 1}, {0, 19999, 11795, 1}, {0, 19999, 19762, 1}, {0, 19999, 16736, 1}, {0, 19999, 15670, 1}, {0, 19999, 19794, 1}, {0, 19999, 10821, 1}, {0, 19999, 11189, 1}, {0, 19999, 11669, 1}, {0, 19999, 18532, 1}, {0, 19999, 12144, 1}, {0, 19999, 19582, 1}, {0, 19999, 19313, 1}, {0, 19999, 13555, 1}, {0, 19999, 10429, 1}, {0, 19999, 13361, 1}, {0, 19999, 12683, 1}, {0, 19999, 17767, 1}, {0, 19999, 19722, 1}, {0, 19999, 16623, 1}, {0, 19999, 15367, 1}, {0, 19999, 14233, 1}, {0, 19999, 16446, 1}, {0, 19999, 13610, 1}, {0, 19999, 15979, 1}, {0, 19999, 18222, 1}, {0, 19999, 15966, 1}, {0, 19999, 14458, 1}, {0, 19999, 16832, 1}, {0, 19999, 17859, 1}, {0, 19999, 15732, 1}, {0, 19999, 11983, 1}, {0, 19999, 16815, 1}, {0, 19999, 15068, 1}, {0, 19999, 12312, 1}, {0, 19999, 15532, 1}, {0, 19999, 17606, 1}, {0, 19999, 16940, 1}, {0, 19999, 13904, 1}, {0, 19999, 11811, 1}, {0, 19999, 16936, 1}, {0, 19999, 10747, 1}, {0, 19999, 10031, 1}, {0, 19999, 19245, 1}, {0, 19999, 11461, 1}, {0, 19999, 14086, 1}, {0, 19999, 10239, 1}, {0, 19999, 11995, 1}, {0, 19999, 17865, 1}, {0, 19999, 18452, 1}, {0, 19999, 10727, 1}, {0, 19999, 11677, 1}, {0, 19999, 14407, 1}, {0, 19999, 14769, 1}, {0, 19999, 17373, 1}, {0, 19999, 16393, 1}, {0, 19999, 12217, 1}, {0, 19999, 12799, 1}, {0, 19999, 10358, 1}, {0, 19999, 17949, 1}, {0, 19999, 19492, 1}, {0, 19999, 15881, 1}, {0, 19999, 14671, 1}, {0, 19999, 13503, 1}, {0, 19999, 15235, 1}, {0, 19999, 19945, 1}, {0, 19999, 12844, 1}, {0, 19999, 18497, 1}, {0, 19999, 18100, 1}, {0, 19999, 10262, 1}, {0, 19999, 19899, 1}, {0, 19999, 16019, 1}, {0, 19999, 18867, 1}, {0, 19999, 11057, 1}, {0, 19999, 19517, 1}, {0, 19999, 11520, 1}, {0, 19999, 11038, 1}, {0, 19999, 17637, 1}, {0, 19999, 18398, 1}, {0, 19999, 11837, 1}, {0, 19999, 10155, 1}, {0, 19999, 16242, 1}, {0, 19999, 15896, 1}, {0, 19999, 13570, 1}, {0, 19999, 14141, 1}, {0, 19999, 14363, 1}, {0, 19999, 19850, 1}, {0, 19999, 12815, 1}, {0, 19999, 15023, 1}, {0, 19999, 15652, 1}, {0, 19999, 19578, 1}, {0, 19999, 18146, 1}, {0, 19999, 19968, 1}, {0, 19999, 18117, 1}, {0, 19999, 18771, 1}, {0, 19999, 18013, 1}, {0, 19999, 16987, 1}, {0, 19999, 10894, 1}, {0, 19999, 17239, 1}, {0, 19999, 10155, 1}, {0, 19999, 13762, 1}, {0, 19999, 18718, 1}, {0, 19999, 14017, 1}, {0, 19999, 12771, 1}, {0, 19999, 18768, 1}, {0, 19999, 16011, 1}, {0, 19999, 11437, 1}, {0, 19999, 10897, 1}, {0, 19999, 11907, 1}, {0, 19999, 13206, 1}, {0, 19999, 13632, 1}, {0, 19999, 13105, 1}, {0, 19999, 10308, 1}, {0, 19999, 17657, 1}, {0, 19999, 12607, 1}, {0, 19999, 18610, 1}, {0, 19999, 16008, 1}, {0, 19999, 15069, 1}, {0, 19999, 11384, 1}, {0, 19999, 12921, 1}, {0, 19999, 12540, 1}, {0, 19999, 11350, 1}, {0, 19999, 13804, 1}, {0, 19999, 19061, 1}, {0, 19999, 17481, 1}, {0, 19999, 13456, 1}, {0, 19999, 10500, 1}, {0, 19999, 18952, 1}, {0, 19999, 19206, 1}, {0, 19999, 15573, 1}, {0, 19999, 10704, 1}, {0, 19999, 15105, 1}, {0, 19999, 16598, 1}, {0, 19999, 16473, 1}, {0, 19999, 19935, 1}, {0, 19999, 18715, 1}, {0, 19999, 19626, 1}, {0, 19999, 15478, 1}, {0, 19999, 17303, 1}, {0, 19999, 13190, 1}, {0, 19999, 14754, 1}, {0, 19999, 13442, 1}, {0, 19999, 11380, 1}, {0, 19999, 13930, 1}, {0, 19999, 17681, 1}, {0, 19999, 19026, 1}, {0, 19999, 16532, 1}, {0, 19999, 10670, 1}, {0, 19999, 11018, 1}, {0, 19999, 12310, 1}, {0, 19999, 11016, 1}, {0, 19999, 15498, 1}, {0, 19999, 16773, 1}, {0, 19999, 19763, 1}, {0, 19999, 15088, 1}, {0, 19999, 17259, 1}, {0, 19999, 19773, 1}, {0, 19999, 10482, 1}, {0, 19999, 19212, 1}, {0, 19999, 10233, 1}, {0, 19999, 10780, 1}, {0, 19999, 14196, 1}, {0, 19999, 16509, 1}, {0, 19999, 12907, 1}, {0, 19999, 12354, 1}, {0, 19999, 10482, 1}, {0, 19999, 17331, 1}, {0, 19999, 11041, 1}, {0, 19999, 11686, 1}, {0, 19999, 12524, 1}, {0, 19999, 15468, 1}, {0, 19999, 16881, 1}, {0, 19999, 17154, 1}, {0, 19999, 15309, 1}, {0, 19999, 19011, 1}, {0, 19999, 18212, 1}, {0, 19999, 17535, 1}, {0, 19999, 12412, 1}, {0, 19999, 16050, 1}, {0, 19999, 14894, 1}, {0, 19999, 10204, 1}, {0, 19999, 10137, 1}, {0, 19999, 15207, 1}, {0, 19999, 12426, 1}, {0, 19999, 18747, 1}, {0, 19999, 18621, 1}, {0, 19999, 17163, 1}, {0, 19999, 12731, 1}, {0, 19999, 19749, 1}, {0, 19999, 10252, 1}, {0, 19999, 11337, 1}, {0, 19999, 13885, 1}, {0, 19999, 10060, 1}, {0, 19999, 16903, 1}, {0, 19999, 10881, 1}, {0, 19999, 17027, 1}, {0, 19999, 19470, 1}, {0, 19999, 18918, 1}, {0, 19999, 19202, 1}, {0, 19999, 12185, 1}, {0, 19999, 10084, 1}, {0, 19999, 12657, 1}, {0, 19999, 10557, 1}, {0, 19999, 12592, 1}, {0, 19999, 17564, 1}, {0, 19999, 11061, 1}, {0, 19999, 17189, 1}, {0, 19999, 15615, 1}, {0, 19999, 13621, 1}, {0, 19999, 15850, 1}, {0, 19999, 18810, 1}, {0, 19999, 15975, 1}, {0, 19999, 16713, 1}, {0, 19999, 10976, 1}, {0, 19999, 10638, 1}, {0, 19999, 18024, 1}, {0, 19999, 14830, 1}, {0, 19999, 19077, 1}, {0, 19999, 14747, 1}, {0, 19999, 12106, 1}, {0, 19999, 13568, 1}, {0, 19999, 16805, 1}, {0, 19999, 12553, 1}, {0, 19999, 18866, 1}, {0, 19999, 15788, 1}, {0, 19999, 12640, 1}, {0, 19999, 12247, 1}, {0, 19999, 14599, 1}, {0, 19999, 11524, 1}, {0, 19999, 10745, 1}, {0, 19999, 16710, 1}, {0, 19999, 10462, 1}, {0, 19999, 12618, 1}, {0, 19999, 12615, 1}, {0, 19999, 11207, 1}, {0, 19999, 12812, 1}, {0, 19999, 13225, 1}, {0, 19999, 16013, 1}, {0, 19999, 13255, 1}, {0, 19999, 15926, 1}, {0, 19999, 18595, 1}, {0, 19999, 12501, 1}, {0, 19999, 19033, 1}, {0, 19999, 16819, 1}, {0, 19999, 17002, 1}, {0, 19999, 16212, 1}, {0, 19999, 11858, 1}, {0, 19999, 14421, 1}, {0, 19999, 11843, 1}, {0, 19999, 16617, 1}, {0, 19999, 19787, 1}, {0, 19999, 19097, 1}, {0, 19999, 16641, 1}, {0, 19999, 14280, 1}, {0, 19999, 16113, 1}, {0, 19999, 18890, 1}, {0, 19999, 18032, 1}, {0, 19999, 12994, 1}, {0, 19999, 10981, 1}, {0, 19999, 11957, 1}, {0, 19999, 15989, 1}, {0, 19999, 13242, 1}, {0, 19999, 12286, 1}, {0, 19999, 13596, 1}, {0, 19999, 10186, 1}, {0, 19999, 11762, 1}, {0, 19999, 10898, 1}, {0, 19999, 19049, 1}, {0, 19999, 18898, 1}, {0, 19999, 10360, 1}, {0, 19999, 11937, 1}, {0, 19999, 14041, 1}, {0, 19999, 13138, 1}, {0, 19999, 15366, 1}, {0, 19999, 14563, 1}, {0, 19999, 19562, 1}, {0, 19999, 16537, 1}, {0, 19999, 13275, 1}, {0, 19999, 18852, 1}, {0, 19999, 12339, 1}, {0, 19999, 17576, 1}, {0, 19999, 16502, 1}, {0, 19999, 17246, 1}, {0, 19999, 18289, 1}, {0, 19999, 19103, 1}, {0, 19999, 15334, 1}, {0, 19999, 16303, 1}, {0, 19999, 14546, 1}, {0, 19999, 15737, 1}, {0, 19999, 14918, 1}, {0, 19999, 18393, 1}, {0, 19999, 11612, 1}, {0, 19999, 17725, 1}, {0, 19999, 19615, 1}, {0, 19999, 15717, 1}, {0, 19999, 14756, 1}, {0, 19999, 19104, 1}, {0, 19999, 13359, 1}, {0, 19999, 12429, 1}, {0, 19999, 17661, 1}, {0, 19999, 13315, 1}, {0, 19999, 10990, 1}, {0, 19999, 11439, 1}, {0, 19999, 10508, 1}, {0, 19999, 18514, 1}, {0, 19999, 16385, 1}, {0, 19999, 17495, 1}, {0, 19999, 14175, 1}, {0, 19999, 13767, 1}, {0, 19999, 17183, 1}, {0, 19999, 15556, 1}, {0, 19999, 17202, 1}, {0, 19999, 15946, 1}, {0, 19999, 17101, 1}, {0, 19999, 11598, 1}, {0, 19999, 17615, 1}, {0, 19999, 12820, 1}, {0, 19999, 17834, 1}, {0, 19999, 18393, 1}, {0, 19999, 12738, 1}, {0, 19999, 16225, 1}, {0, 19999, 19154, 1}, {0, 19999, 14698, 1}, {0, 19999, 11251, 1}, {0, 19999, 11416, 1}, {0, 19999, 12936, 1}, {0, 19999, 18262, 1}, {0, 19999, 11363, 1}, {0, 19999, 19900, 1}, {0, 19999, 12813, 1}, {0, 19999, 18944, 1}, {0, 19999, 18584, 1}, {0, 19999, 19712, 1}, {0, 19999, 10530, 1}, {0, 19999, 11034, 1}, {0, 19999, 19827, 1}, {0, 19999, 13883, 1}, {0, 19999, 10807, 1}, {0, 19999, 17946, 1}, {0, 19999, 15654, 1}, {0, 19999, 17428, 1}, {0, 19999, 11147, 1}, {0, 19999, 13180, 1}, {0, 19999, 17561, 1}, {0, 19999, 10264, 1}, {0, 19999, 11198, 1}, {0, 19999, 17355, 1}, {0, 19999, 19021, 1}, {0, 19999, 17864, 1}, {0, 19999, 14193, 1}, {0, 19999, 13399, 1}, {0, 19999, 15727, 1}, {0, 19999, 18945, 1}, {0, 19999, 10585, 1}, {0, 19999, 16613, 1}, {0, 19999, 12177, 1}, {0, 19999, 18398, 1}, {0, 19999, 18661, 1}, {0, 19999, 13695, 1}, {0, 19999, 12774, 1}, {0, 19999, 15808, 1}, {0, 19999, 15901, 1}, {0, 19999, 19269, 1}, {0, 19999, 12427, 1}, {0, 19999, 15101, 1}, {0, 19999, 12626, 1}, {0, 19999, 12073, 1}, {0, 19999, 16914, 1}, {0, 19999, 12781, 1}, {0, 19999, 12590, 1}, {0, 19999, 12620, 1}, {0, 19999, 11809, 1}, {0, 19999, 16341, 1}, {0, 19999, 12661, 1}, {0, 19999, 13985, 1}, {0, 19999, 10486, 1}, {0, 19999, 13622, 1}, {0, 19999, 11332, 1}, {0, 19999, 10691, 1}, {0, 19999, 11715, 1}, {0, 19999, 15251, 1}, {0, 19999, 15565, 1}, {0, 19999, 18512, 1}, {0, 19999, 12493, 1}, {0, 19999, 16923, 1}, {0, 19999, 16951, 1}, {0, 19999, 17312, 1}, {0, 19999, 14211, 1}, {0, 19999, 19759, 1}, {0, 19999, 17185, 1}, {0, 19999, 14918, 1}, {0, 19999, 19847, 1}, {0, 19999, 12950, 1}, {0, 19999, 11180, 1}, {0, 19999, 14456, 1}, {0, 19999, 13353, 1}, {0, 19999, 10874, 1}, {0, 19999, 12703, 1}, {0, 19999, 14038, 1}, {0, 19999, 13927, 1}, {0, 19999, 17719, 1}, {0, 19999, 11192, 1}, {0, 19999, 18776, 1}, {0, 19999, 11446, 1}, {0, 19999, 11822, 1}, {0, 19999, 15642, 1}, {0, 19999, 13869, 1}, {0, 19999, 12957, 1}, {0, 19999, 13051, 1}, {0, 19999, 19653, 1}, {0, 19999, 13300, 1}, {0, 19999, 12657, 1}, {0, 19999, 10640, 1}, {0, 19999, 17312, 1}, {0, 19999, 15679, 1}, {0, 19999, 14761, 1}, {0, 19999, 19288, 1}, {0, 19999, 15084, 1}, {0, 19999, 16174, 1}, {0, 19999, 14482, 1}, {0, 19999, 19261, 1}, {0, 19999, 17572, 1}, {0, 19999, 14039, 1}, {0, 19999, 11390, 1}, {0, 19999, 17199, 1}, {0, 19999, 10316, 1}, {0, 19999, 14351, 1}, {0, 19999, 17817, 1}, {0, 19999, 14385, 1}, {0, 19999, 10228, 1}, {0, 19999, 18720, 1}, {0, 19999, 17083, 1}, {0, 19999, 12481, 1}, {0, 19999, 13281, 1}, {0, 19999, 12506, 1}, {0, 19999, 15543, 1}, {0, 19999, 13259, 1}, {0, 19999, 12357, 1}, {0, 19999, 16997, 1}, {0, 19999, 13620, 1}, {0, 19999, 12219, 1}, {0, 19999, 17771, 1}, {0, 19999, 11529, 1}, {0, 19999, 18842, 1}, {0, 19999, 16582, 1}, {0, 19999, 18876, 1}, {0, 19999, 16339, 1}, {0, 19999, 12570, 1}, {0, 19999, 14762, 1}, {0, 19999, 10399, 1}, {0, 19999, 15857, 1}, {0, 19999, 15401, 1}, {0, 19999, 19174, 1}, {0, 19999, 19159, 1}, {0, 19999, 11522, 1}, {0, 19999, 16582, 1}, {0, 19999, 11747, 1}, {0, 19999, 10010, 1}, {0, 19999, 11126, 1}, {0, 19999, 10021, 1}, {0, 19999, 15003, 1}, {0, 19999, 11489, 1}, {0, 19999, 13055, 1}, {0, 19999, 10200, 1}, {0, 19999, 12598, 1}, {0, 19999, 17664, 1}, {0, 19999, 11235, 1}, {0, 19999, 11986, 1}, {0, 19999, 17945, 1}, {0, 19999, 13829, 1}, {0, 19999, 13925, 1}, {0, 19999, 10975, 1}, {0, 19999, 14777, 1}, {0, 19999, 14337, 1}, {0, 19999, 18223, 1}, {0, 19999, 10337, 1}, {0, 19999, 18573, 1}, {0, 19999, 13988, 1}, {0, 19999, 14665, 1}, {0, 19999, 17403, 1}, {0, 19999, 17454, 1}, {0, 19999, 12713, 1}, {0, 19999, 12801, 1}, {0, 19999, 11831, 1}, {0, 19999, 15004, 1}, {0, 19999, 18896, 1}, {0, 19999, 12009, 1}, {0, 19999, 14733, 1}, {0, 19999, 12489, 1}, {0, 19999, 18295, 1}, {0, 19999, 17322, 1}, {0, 19999, 10904, 1}, {0, 19999, 10582, 1}, {0, 19999, 18229, 1}, {0, 19999, 13096, 1}, {0, 19999, 18997, 1}, {0, 19999, 18930, 1}, {0, 19999, 13859, 1}, {0, 19999, 14142, 1}, {0, 19999, 18416, 1}, {0, 19999, 13008, 1}, {0, 19999, 13927, 1}, {0, 19999, 17812, 1}, {0, 19999, 15329, 1}, {0, 19999, 12522, 1}, {0, 19999, 15301, 1}, {0, 19999, 17972, 1}, {0, 19999, 16524, 1}, {0, 19999, 16783, 1}, {0, 19999, 17496, 1}, {0, 19999, 14022, 1}, {0, 19999, 12691, 1}, {0, 19999, 12577, 1}, {0, 19999, 19454, 1}, {0, 19999, 15532, 1}, {0, 19999, 18601, 1}, {0, 19999, 14217, 1}, {0, 19999, 17424, 1}, {0, 19999, 15359, 1}, {0, 19999, 17501, 1}, {0, 19999, 15831, 1}, {0, 19999, 18924, 1}, {0, 19999, 18147, 1}, {0, 19999, 10936, 1}, {0, 19999, 13600, 1}, {0, 19999, 18084, 1}, {0, 19999, 19466, 1}, {0, 19999, 10459, 1}, {0, 19999, 10976, 1}, {0, 19999, 13808, 1}, {0, 19999, 13587, 1}, {0, 19999, 19694, 1}, {0, 19999, 17416, 1}, {0, 19999, 11186, 1}, {0, 19999, 19420, 1}, {0, 19999, 16965, 1}, {0, 19999, 13430, 1}, {0, 19999, 12017, 1}, {0, 19999, 16737, 1}, {0, 19999, 17863, 1}, {0, 19999, 18112, 1}, {0, 19999, 15384, 1}, {0, 19999, 12362, 1}, {0, 19999, 18139, 1}, {0, 19999, 17800, 1}, {0, 19999, 13925, 1}, {0, 19999, 16839, 1}, {0, 19999, 14834, 1}, {0, 19999, 16804, 1}, {0, 19999, 14465, 1}, {0, 19999, 19783, 1}, {0, 19999, 10389, 1}, {0, 19999, 18243, 1}, {0, 19999, 11075, 1}, {0, 19999, 10869, 1}, {0, 19999, 13183, 1}, {0, 19999, 15895, 1}, {0, 19999, 19374, 1}, {0, 19999, 12671, 1}, {0, 19999, 12487, 1}, {0, 19999, 17374, 1}, {0, 19999, 19221, 1}, {0, 19999, 17845, 1}, {0, 19999, 19302, 1}, {0, 19999, 16993, 1}, {0, 19999, 12818, 1}, {0, 19999, 13091, 1}, {0, 19999, 11494, 1}, {0, 19999, 13445, 1}, {0, 19999, 10452, 1}, {0, 19999, 17359, 1}, {0, 19999, 16150, 1}, {0, 19999, 11837, 1}, {0, 19999, 16158, 1}, {0, 19999, 18012, 1}, {0, 19999, 17492, 1}, {0, 19999, 16088, 1}, {0, 19999, 12576, 1}, {0, 19999, 12295, 1}, {0, 19999, 10341, 1}, {0, 19999, 17368, 1}, {0, 19999, 16482, 1}, {0, 19999, 16793, 1}, {0, 19999, 15689, 1}, {0, 19999, 19256, 1}, {0, 19999, 12649, 1}, {0, 19999, 17306, 1}, {0, 19999, 15140, 1}, {0, 19999, 14494, 1}, {0, 19999, 12148, 1}, {0, 19999, 17909, 1}, {0, 19999, 16555, 1}, {0, 19999, 13707, 1}, {0, 19999, 14727, 1}, {0, 19999, 10679, 1}, {0, 19999, 11248, 1}, {0, 19999, 14672, 1}, {0, 19999, 18173, 1}, {0, 19999, 10942, 1}, {0, 19999, 13228, 1}, {0, 19999, 15022, 1}, {0, 19999, 15878, 1}, {0, 19999, 13450, 1}, {0, 19999, 18959, 1}, {0, 19999, 13324, 1}, {0, 19999, 13731, 1}, {0, 19999, 13773, 1}, {0, 19999, 16500, 1}, {0, 19999, 15886, 1}, {0, 19999, 13518, 1}, {0, 19999, 19840, 1}, {0, 19999, 17839, 1}, {0, 19999, 12269, 1}, {0, 19999, 11185, 1}, {0, 19999, 15742, 1}, {0, 19999, 15448, 1}, {0, 19999, 14832, 1}, {0, 19999, 10290, 1}, {0, 19999, 18646, 1}, {0, 19999, 17794, 1}, {0, 19999, 13089, 1}, {0, 19999, 14551, 1}, {0, 19999, 14224, 1}, {0, 19999, 15726, 1}, {0, 19999, 10588, 1}, {0, 19999, 13023, 1}, {0, 19999, 19728, 1}, {0, 19999, 12917, 1}, {0, 19999, 16199, 1}, {0, 19999, 16840, 1}, {0, 19999, 10432, 1}, {0, 19999, 10705, 1}, {0, 19999, 12222, 1}, {0, 19999, 12852, 1}, {0, 19999, 16869, 1}, {0, 19999, 16008, 1}, {0, 19999, 17691, 1}, {0, 19999, 16439, 1}, {0, 19999, 12221, 1}, {0, 19999, 12534, 1}, {0, 19999, 15087, 1}, {0, 19999, 13020, 1}, {0, 19999, 19738, 1}, {0, 19999, 10790, 1}, {0, 19999, 18713, 1}, {0, 19999, 18636, 1}, {0, 19999, 11169, 1}, {0, 19999, 12401, 1}, {0, 19999, 14549, 1}, {0, 19999, 13224, 1}, {0, 19999, 19626, 1}, {0, 19999, 19135, 1}, {0, 19999, 19077, 1}, {0, 19999, 11559, 1}, {0, 19999, 12942, 1}, {0, 19999, 19000, 1}, {0, 19999, 18788, 1}, {0, 19999, 16109, 1}, {0, 19999, 14342, 1}, {0, 19999, 16885, 1}, {0, 19999, 17022, 1}, {0, 19999, 19546, 1}, {0, 19999, 14170, 1}, {0, 19999, 17975, 1}, {0, 19999, 19665, 1}, {0, 19999, 19953, 1}, {0, 19999, 10934, 1}, {0, 19999, 12334, 1}, {0, 19999, 16725, 1}, {0, 19999, 18049, 1}, {0, 19999, 18170, 1}, {0, 19999, 14631, 1}, {0, 19999, 11150, 1}, {0, 19999, 14707, 1}, {0, 19999, 13188, 1}, {0, 19999, 10753, 1}, {0, 19999, 17957, 1}, {0, 19999, 14383, 1}, {0, 19999, 14487, 1}, {0, 19999, 13774, 1}, {0, 19999, 18076, 1}, {0, 19999, 10726, 1}, {0, 19999, 16201, 1}, {0, 19999, 14079, 1}, {0, 19999, 12206, 1}, {0, 19999, 16895, 1}, {0, 19999, 10946, 1}, {0, 19999, 13831, 1}, {0, 19999, 13303, 1}, {0, 19999, 19141, 1}, {0, 19999, 10446, 1}, {0, 19999, 10983, 1}, {0, 19999, 11677, 1}, {0, 19999, 14389, 1}, {0, 19999, 15062, 1}, {0, 19999, 11422, 1}, {0, 19999, 14188, 1}, {0, 19999, 11634, 1}, {0, 19999, 14084, 1}, {0, 19999, 11745, 1}, {0, 19999, 11455, 1}, {0, 19999, 13924, 1}, {0, 19999, 18409, 1}, {0, 19999, 16797, 1}, {0, 19999, 18083, 1}, {0, 19999, 18287, 1}, {0, 19999, 18036, 1}, {0, 19999, 16251, 1}, {0, 19999, 19700, 1}, {0, 19999, 14579, 1}, {0, 19999, 15105, 1}, {0, 19999, 17803, 1}, {0, 19999, 19314, 1}, {0, 19999, 12099, 1}, {0, 19999, 14512, 1}, {0, 19999, 10664, 1}, {0, 19999, 13692, 1}, {0, 19999, 10951, 1}, {0, 19999, 12202, 1}, {0, 19999, 11626, 1}, {0, 19999, 16245, 1}, {0, 19999, 13904, 1}, {0, 19999, 19811, 1}, {0, 19999, 11240, 1}, {0, 19999, 13110, 1}, {0, 19999, 11827, 1}, {0, 19999, 13927, 1}, {0, 19999, 19702, 1}, {0, 19999, 16172, 1}, {0, 19999, 14081, 1}, {0, 19999, 15393, 1}, {0, 19999, 16400, 1}, {0, 19999, 16710, 1}, {0, 19999, 19970, 1}, {0, 19999, 18278, 1}, {0, 19999, 12754, 1}, {0, 19999, 14098, 1}, {0, 19999, 16565, 1}, {0, 19999, 12278, 1}, {0, 19999, 14380, 1}, {0, 19999, 14985, 1}, {0, 19999, 13968, 1}, {0, 19999, 17075, 1}, {0, 19999, 14892, 1}, {0, 19999, 14214, 1}, {0, 19999, 18729, 1}, {0, 19999, 16401, 1}, {0, 19999, 10868, 1}, {0, 19999, 17626, 1}, {0, 19999, 13131, 1}, {0, 19999, 14577, 1}, {0, 19999, 19417, 1}, {0, 19999, 13864, 1}, {0, 19999, 13391, 1}, {0, 19999, 18219, 1}, {0, 19999, 14904, 1}, {0, 19999, 10715, 1}, {0, 19999, 18274, 1}, {0, 19999, 14632, 1}, {0, 19999, 10169, 1}, {0, 19999, 16251, 1}, {0, 19999, 15180, 1}, {0, 19999, 12988, 1}, {0, 19999, 17748, 1}, {0, 19999, 10326, 1}, {0, 19999, 19619, 1}, {0, 19999, 14754, 1}, {0, 19999, 15742, 1}, {0, 19999, 17626, 1}, {0, 19999, 18644, 1}, {0, 19999, 17591, 1}, {0, 19999, 18267, 1}, {0, 19999, 16501, 1}, {0, 19999, 17232, 1}, {0, 19999, 10596, 1}, {0, 19999, 10275, 1}, {0, 19999, 17414, 1}, {0, 19999, 19526, 1}, {0, 19999, 10406, 1}, {0, 19999, 15164, 1}, {0, 19999, 19207, 1}, {0, 19999, 19392, 1}, {0, 19999, 16638, 1}, {0, 19999, 11601, 1}, {0, 19999, 12002, 1}, {0, 19999, 17638, 1}, {0, 19999, 17559, 1}, {0, 19999, 19630, 1}, {0, 19999, 14939, 1}, {0, 19999, 12573, 1}, {0, 19999, 19420, 1}, {0, 19999, 13782, 1}, {0, 19999, 12882, 1}, {0, 19999, 11901, 1}, {0, 19999, 11345, 1}, {0, 19999, 14769, 1}, {0, 19999, 17517, 1}, {0, 19999, 15793, 1}, {0, 19999, 12301, 1}, {0, 19999, 13149, 1}, {0, 19999, 18786, 1}, {0, 19999, 16892, 1}, {0, 19999, 11850, 1}, {0, 19999, 11172, 1}, {0, 19999, 18515, 1}, {0, 19999, 19407, 1}, {0, 19999, 16066, 1}, {0, 19999, 15875, 1}, {0, 19999, 11093, 1}, {0, 19999, 17721, 1}, {0, 19999, 14041, 1}, {0, 19999, 19706, 1}, {0, 19999, 15459, 1}, {0, 19999, 13264, 1}, {0, 19999, 12619, 1}, {0, 19999, 15531, 1}, {0, 19999, 10541, 1}, {0, 19999, 15337, 1}, {0, 19999, 19458, 1}, {0, 19999, 11102, 1}, {0, 19999, 14638, 1}, {0, 19999, 11571, 1}, {0, 19999, 12518, 1}, {0, 19999, 10635, 1}, {0, 19999, 13092, 1}, {0, 19999, 18933, 1}, {0, 19999, 19679, 1}, {0, 19999, 10346, 1}, {0, 19999, 14410, 1}, {0, 19999, 14397, 1}, {0, 19999, 19205, 1}, {0, 19999, 18718, 1}, {0, 19999, 14571, 1}, {0, 19999, 16810, 1}, {0, 19999, 16529, 1}, {0, 19999, 19768, 1}, {0, 19999, 19132, 1}, {0, 19999, 14423, 1}, {0, 19999, 17075, 1}, {0, 19999, 12923, 1}, {0, 19999, 18575, 1}, {0, 19999, 16448, 1}, {0, 19999, 10963, 1}, {0, 19999, 17281, 1}, {0, 19999, 13179, 1}, {0, 19999, 18777, 1}, {0, 19999, 13422, 1}, {0, 19999, 17437, 1}, {0, 19999, 16050, 1}, {0, 19999, 17380, 1}, {0, 19999, 14494, 1}, {0, 19999, 10266, 1}, {0, 19999, 18160, 1}, {0, 19999, 14998, 1}, {0, 19999, 14019, 1}, {0, 19999, 19808, 1}, {0, 19999, 19616, 1}, {0, 19999, 12788, 1}, {0, 19999, 18338, 1}, {0, 19999, 12397, 1}, {0, 19999, 19166, 1}, {0, 19999, 14622, 1}, {0, 19999, 14442, 1}, {0, 19999, 19778, 1}, {0, 19999, 11017, 1}, {0, 19999, 12778, 1}, {0, 19999, 13495, 1}, {0, 19999, 13671, 1}, {0, 19999, 17783, 1}, {0, 19999, 14722, 1}, {0, 19999, 14664, 1}, {0, 19999, 10114, 1}, {0, 19999, 19201, 1}, {0, 19999, 15725, 1}, {0, 19999, 16623, 1}, {0, 19999, 14892, 1}, {0, 19999, 17186, 1}, {0, 19999, 18332, 1}, {0, 19999, 14185, 1}, {0, 19999, 17023, 1}, {0, 19999, 11025, 1}, {0, 19999, 14559, 1}, {0, 19999, 16062, 1}, {0, 19999, 11827, 1}, {0, 19999, 16274, 1}, {0, 19999, 14440, 1}, {0, 19999, 18005, 1}, {0, 19999, 12672, 1}, {0, 19999, 10801, 1}, {0, 19999, 14955, 1}, {0, 19999, 18249, 1}, {0, 19999, 11982, 1}, {0, 19999, 19177, 1}, {0, 19999, 12819, 1}, {0, 19999, 15603, 1}, {0, 19999, 12036, 1}, {0, 19999, 18459, 1}, {0, 19999, 10850, 1}, {0, 19999, 16692, 1}, {0, 19999, 12486, 1}, {0, 19999, 17039, 1}, {0, 19999, 19625, 1}, {0, 19999, 17985, 1}, {0, 19999, 15043, 1}, {0, 19999, 12810, 1}, {0, 19999, 12087, 1}, {0, 19999, 18709, 1}, {0, 19999, 11919, 1}, {0, 19999, 18149, 1}, {0, 19999, 12186, 1}, {0, 19999, 17948, 1}, {0, 19999, 15876, 1}, {0, 19999, 18497, 1}, + } + for _, tc := range tcs { + a.Equal(tc.ans, mc.Query(tc.left, tc.right, tc.threshold)) + } +} diff --git a/Algorithms/1160.find-words-that-can-be-formed-by-characters/README.md b/Algorithms/1160.find-words-that-can-be-formed-by-characters/README.md new file mode 100755 index 000000000..26b097f48 --- /dev/null +++ b/Algorithms/1160.find-words-that-can-be-formed-by-characters/README.md @@ -0,0 +1,31 @@ +# [1160. Find Words That Can Be Formed by Characters](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/) + +You are given an array of strings words and a string chars. + +A string is good if it can be formed by characters from chars (each character can only be used once). + +Return the sum of lengths of all good strings in words. + +Example 1: + +```text +Input: words = ["cat","bt","hat","tree"], chars = "atach" +Output: 6 +Explanation: +The strings that can be formed are "cat" and "hat" so the answer is 3 + 3 = 6. +``` + +Example 2: + +```text +Input: words = ["hello","world","leetcode"], chars = "welldonehoneyr" +Output: 10 +Explanation: +The strings that can be formed are "hello" and "world" so the answer is 5 + 5 = 10. +``` + +Note: + +- `1 <= words.length <= 1000` +- `1 <= words[i].length, chars.length <= 100` +- `All strings contain lowercase English letters only.` diff --git a/Algorithms/1160.find-words-that-can-be-formed-by-characters/find-words-that-can-be-formed-by-characters.go b/Algorithms/1160.find-words-that-can-be-formed-by-characters/find-words-that-can-be-formed-by-characters.go new file mode 100755 index 000000000..ba2c78afc --- /dev/null +++ b/Algorithms/1160.find-words-that-can-be-formed-by-characters/find-words-that-can-be-formed-by-characters.go @@ -0,0 +1,32 @@ +package problem1160 + +func countCharacters(words []string, chars string) int { + char := parse(chars) + res := 0 + for _, word := range words { + res += count(char, word) + } + return res +} + +func parse(s string) []int { + res := make([]int, 26) + for _, r := range s { + res[r-'a']++ + } + return res +} + +func count(char []int, word string) int { + res := 0 + w := make([]int, 26) + for _, r := range word { + b := r - 'a' + w[b]++ + if w[b] > char[b] { + return 0 + } + res++ + } + return res +} diff --git a/Algorithms/1160.find-words-that-can-be-formed-by-characters/find-words-that-can-be-formed-by-characters_test.go b/Algorithms/1160.find-words-that-can-be-formed-by-characters/find-words-that-can-be-formed-by-characters_test.go new file mode 100755 index 000000000..b31dc8265 --- /dev/null +++ b/Algorithms/1160.find-words-that-can-be-formed-by-characters/find-words-that-can-be-formed-by-characters_test.go @@ -0,0 +1,45 @@ +package problem1160 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + words []string + chars string + ans int +}{ + + { + []string{"cat", "bt", "hat", "tree"}, + "atach", + 6, + }, + + { + []string{"hello", "world", "leetcode"}, + "welldonehoneyr", + 10, + }, + + // 可以有多个 testcase +} + +func Test_countCharacters(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, countCharacters(tc.words, tc.chars), "输入:%v", tc) + } +} + +func Benchmark_countCharacters(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + countCharacters(tc.words, tc.chars) + } + } +} diff --git a/Algorithms/1161.maximum-level-sum-of-a-binary-tree/1.JPG b/Algorithms/1161.maximum-level-sum-of-a-binary-tree/1.JPG new file mode 100644 index 000000000..f524e7484 Binary files /dev/null and b/Algorithms/1161.maximum-level-sum-of-a-binary-tree/1.JPG differ diff --git a/Algorithms/1161.maximum-level-sum-of-a-binary-tree/README.md b/Algorithms/1161.maximum-level-sum-of-a-binary-tree/README.md new file mode 100755 index 000000000..7c1a2a23b --- /dev/null +++ b/Algorithms/1161.maximum-level-sum-of-a-binary-tree/README.md @@ -0,0 +1,24 @@ +# [1161. Maximum Level Sum of a Binary Tree](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/) + +Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. + +Return the smallest level X such that the sum of all the values of nodes at level X is maximal. + +Example 1: + +![1](1.JPG) + +```text +Input: [1,7,0,7,-8,null,null] +Output: 2 +Explanation: +Level 1 sum = 1. +Level 2 sum = 7 + 0 = 7. +Level 3 sum = 7 + -8 = -1. +So we return the level with the maximum sum which is level 2. +``` + +Note: + +- The number of nodes in the given tree is between 1 and 10^4. +- -10^5 <= node.val <= 10^5 diff --git a/Algorithms/1161.maximum-level-sum-of-a-binary-tree/maximum-level-sum-of-a-binary-tree.go b/Algorithms/1161.maximum-level-sum-of-a-binary-tree/maximum-level-sum-of-a-binary-tree.go new file mode 100755 index 000000000..d7f4a82f4 --- /dev/null +++ b/Algorithms/1161.maximum-level-sum-of-a-binary-tree/maximum-level-sum-of-a-binary-tree.go @@ -0,0 +1,47 @@ +package problem1161 + +import ( + "math" + + "github.com/aQuaYi/LeetCode-in-Go/kit" +) + +// TreeNode is pre-defined... +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +func maxLevelSum(root *TreeNode) int { + queue := make([]*TreeNode, 1, 1<<10) + queue[0] = root + + res, max := 0, math.MinInt64 + level, sum := 1, 0 + // BFS + for len(queue) > 0 { + size := len(queue) + for i := 0; i < size; i++ { + node := queue[i] + sum += node.Val + if node.Left != nil { + queue = append(queue, node.Left) + } + if node.Right != nil { + queue = append(queue, node.Right) + } + } + + if max < sum { + res, max = level, sum + } + + level, sum = level+1, 0 + + queue = queue[size:] + } + + return res +} diff --git a/Algorithms/1161.maximum-level-sum-of-a-binary-tree/maximum-level-sum-of-a-binary-tree_test.go b/Algorithms/1161.maximum-level-sum-of-a-binary-tree/maximum-level-sum-of-a-binary-tree_test.go new file mode 100755 index 000000000..b416e14f0 --- /dev/null +++ b/Algorithms/1161.maximum-level-sum-of-a-binary-tree/maximum-level-sum-of-a-binary-tree_test.go @@ -0,0 +1,40 @@ +package problem1161 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + root []int + ans int +}{ + + { + []int{1, 7, 0, 7, -8, kit.NULL, kit.NULL}, + 2, + }, + + // 可以有多个 testcase +} + +func Test_maxLevelSum(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + ast.Equal(tc.ans, maxLevelSum(root), "输入:%v", tc) + } +} + +func Benchmark_maxLevelSum(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + root := kit.Ints2TreeNode(tc.root) + maxLevelSum(root) + } + } +} diff --git a/Algorithms/1162.as-far-from-land-as-possible/1.JPG b/Algorithms/1162.as-far-from-land-as-possible/1.JPG new file mode 100644 index 000000000..072ff73fb Binary files /dev/null and b/Algorithms/1162.as-far-from-land-as-possible/1.JPG differ diff --git a/Algorithms/1162.as-far-from-land-as-possible/2.JPG b/Algorithms/1162.as-far-from-land-as-possible/2.JPG new file mode 100644 index 000000000..337d4c4af Binary files /dev/null and b/Algorithms/1162.as-far-from-land-as-possible/2.JPG differ diff --git a/Algorithms/1162.as-far-from-land-as-possible/README.md b/Algorithms/1162.as-far-from-land-as-possible/README.md new file mode 100755 index 000000000..f2c4a66ff --- /dev/null +++ b/Algorithms/1162.as-far-from-land-as-possible/README.md @@ -0,0 +1,34 @@ +# [1162. As Far from Land as Possible](https://leetcode.com/problems/as-far-from-land-as-possible/) + +Given an N x N grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized and return the distance. + +The distance used in this problem is the Manhattan distance: the distance between two cells (x0, y0) and (x1, y1) is |x0 - x1| + |y0 - y1|. + +If no land or water exists in the grid, return -1. + +Example 1: + +![1](1.JPG) + +```text +Input: [[1,0,1],[0,0,0],[1,0,1]] +Output: 2 +Explanation: +The cell (1, 1) is as far as possible from all the land with distance 2. +``` + +Example 2: + +![2](2.JPG) + +```text +Input: [[1,0,0],[0,0,0],[0,0,0]] +Output: 4 +Explanation: +The cell (2, 2) is as far as possible from all the land with distance 4. +``` + +Note: + +- `1 <= grid.length == grid[0].length <= 100` +- `grid[i][j] is 0 or 1` diff --git a/Algorithms/1162.as-far-from-land-as-possible/as-far-from-land-as-possible.go b/Algorithms/1162.as-far-from-land-as-possible/as-far-from-land-as-possible.go new file mode 100755 index 000000000..db593af81 --- /dev/null +++ b/Algorithms/1162.as-far-from-land-as-possible/as-far-from-land-as-possible.go @@ -0,0 +1,45 @@ +package problem1162 + +var dx = []int{-1, 1, 0, 0} +var dy = []int{0, 0, -1, 1} + +func maxDistance(grid [][]int) int { + n := len(grid) + + lands := make([][2]int, 0, n) + for i := 0; i < n; i++ { + for j := 0; j < n; j++ { + if grid[i][j] == 1 { + lands = append(lands, [2]int{i, j}) + } + } + } + + if len(lands) == n*n { + return -1 + } + + dist := -1 + // BFS + for len(lands) > 0 { + dist++ + size := len(lands) + for s := 0; s < size; s++ { + g := lands[s] + x, y := g[0], g[1] + for k := 0; k < 4; k++ { + i, j := x+dx[k], y+dy[k] + if i < 0 || n <= i || + j < 0 || n <= j || + grid[i][j] == 1 { + continue + } + lands = append(lands, [2]int{i, j}) + grid[i][j] = 1 + } + } + lands = lands[size:] + } + + return dist +} diff --git a/Algorithms/1162.as-far-from-land-as-possible/as-far-from-land-as-possible_test.go b/Algorithms/1162.as-far-from-land-as-possible/as-far-from-land-as-possible_test.go new file mode 100755 index 000000000..3ad754c26 --- /dev/null +++ b/Algorithms/1162.as-far-from-land-as-possible/as-far-from-land-as-possible_test.go @@ -0,0 +1,47 @@ +package problem1162 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + grid [][]int + ans int +}{ + + { + [][]int{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}, + -1, + }, + + { + [][]int{{1, 0, 1}, {0, 0, 0}, {1, 0, 1}}, + 2, + }, + + { + [][]int{{1, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + 4, + }, + + // 可以有多个 testcase +} + +func Test_maxDistance(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, maxDistance(tc.grid), "输入:%v", tc) + } +} + +func Benchmark_maxDistance(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxDistance(tc.grid) + } + } +} diff --git a/Algorithms/1163.last-substring-in-lexicographical-order/README.md b/Algorithms/1163.last-substring-in-lexicographical-order/README.md new file mode 100755 index 000000000..50a95369b --- /dev/null +++ b/Algorithms/1163.last-substring-in-lexicographical-order/README.md @@ -0,0 +1,23 @@ +# [1163. Last Substring in Lexicographical Order](https://leetcode.com/problems/last-substring-in-lexicographical-order/) + +Given a string s, return the last substring of s in lexicographical order. + +Example 1: + +```text +Input: "abab" +Output: "bab" +Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab". +``` + +Example 2: + +```text +Input: "leetcode" +Output: "tcode" +``` + +Note: + +- `1 <= s.length <= 4 * 10^5` +- `s contains only lowercase English letters.` diff --git a/Algorithms/1163.last-substring-in-lexicographical-order/last-substring-in-lexicographical-order.go b/Algorithms/1163.last-substring-in-lexicographical-order/last-substring-in-lexicographical-order.go new file mode 100755 index 000000000..e67cbdc0a --- /dev/null +++ b/Algorithms/1163.last-substring-in-lexicographical-order/last-substring-in-lexicographical-order.go @@ -0,0 +1,31 @@ +package problem1163 + +func lastSubstring(s string) string { + last, n := 0, len(s) + for i := 1; i < n; i++ { + if s[i-1] == s[i] { + // all of s[last:i+1] are the same letter. + // 'i' has no chance to be the new 'last' + // the reason is + // 1. s[i+1] > s[i], 'i+1' is the new 'last' + // 2. s[i+1] < s[i], 'last' is still 'last' + // 3. s[i+1] = s[i], 'i+1' is the new 'i' + // like above, need a different letter to make decision + continue + } + for l := 0; i+l < n; l++ { + if s[last+l] < s[i+l] { + // s[i:] is bigger than s[last:] + // new begin is here + last = i + break + } + if s[last+l] > s[i+l] { + // s[last:] is bigger than s[i:] + // no need to compare continue + break + } + } + } + return s[last:] +} diff --git a/Algorithms/1163.last-substring-in-lexicographical-order/last-substring-in-lexicographical-order_test.go b/Algorithms/1163.last-substring-in-lexicographical-order/last-substring-in-lexicographical-order_test.go new file mode 100755 index 000000000..1a09b6f8e --- /dev/null +++ b/Algorithms/1163.last-substring-in-lexicographical-order/last-substring-in-lexicographical-order_test.go @@ -0,0 +1,57 @@ +package problem1163 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + s string + ans string +}{ + + { + "abcdexyzfzz", + "zz", + }, + + { + "nodkzqossehfztonbzkejoemqrhkpqbmwquxkgxeuvtqeersrxhbeeqewmjfrkhbzureouvhwylolikewlttwgbyyvjfcatnfkuudtlftbakfdljklqcnudunbuxunebafbkauymfmosrvtkdddwlpbhtdfftuzaxtptqoqdisqevvnetxqpnfejwbpxbwmchfcvdwyfjcpixywqfzmrudaicmnxuzoapkfjrkcomvyzwtywsvkncjlzdycqfavckdjdnmdppthmarkirtloegoubetuygwsvppwjlguhkqninxuqbttcaawpooenkphiotyjxiwqybrasqxjulwplspovvffhzolifstzyhtdlfgsioxnriymcgdpxrhuqxidybiulypufciqezuuxwoxxtfeeeguaoathsdyqaotidoudsnimtncdifrpmsuaytsgooysemdcsddgflgntondsecxtlxoqqmbfzprpskgiwxghvdcutebvjpemijnmbkqiitecgykyglgjlaudothmegnaenpxawkfspspmbnozipqlgbraekfxsengmubullzqnzxevjnvnchldkciumsflnutzkvawmeujxtsylkzkpfotnczscqkrcumvjsgdjlpaxgzbhsnsxddupmetxdqnoqxknqtmlvtnpsbmzkviezndfgtilvyajcepkriphiyuvxewfwffrciyhkkgojgnmrhxhxredxvlkyogvqqvfhcbkwpxvfpisqvtcedxkcpaivpncqmvwbmifqtrqyccqkgordnlwgqxfvrojlrgstvxvfdnqjzvdkaxycekqhgjicuqqzzedjxoupdtqeshroabzjoffwpdocacyczjlrcfqdradlwvplzpduskdedrxdlsqdzfwuxtjzrmaswqltcagiytnzptqovzeimwwrlelzfxusnppijsgyxdsmwronsbbdalyiglnnwoaarixdrrliorrhbfsxdcbwzcgqpqhrgbxmlgrxbynsykbellcqrqyfiiupufulotnjbhezsqbqkbqxrzuasvcjxsmtmlptqbcnkzudjusaphgttqlmvybqipuyoyupwbwnduchdmcqgoffibvybivbzyteapzbiaqgwtcmrbdbpgucpeosepcaokgsnaamsxyikbeslpdlinvuwyutrmjbyormeogbyabrapzamqcyxjnqoxseziqauivcjrhfpodycxzfowqpwznxmzcrqhljdltkoxncezlxeptqojzrghgqmujeyzrvylejwvchklqlajemhgavoymnyivifwbmisdptswkxqdynsgescrezrojrjyumexfbznpswteafhzrekxuezeiijmfqhfiyodedlvkslnocayharrpmpgakrxfnkhsgygjdiuacdkglngdbinfyrbhhjasyaffierzfempsfotuuayffxbyzqhwewiowkerbomwghyutgtsvdnwqtytivfzjswsylyqlfrpamdqxfrpwgwfcxaemvcgymigppssgzbnnfyimhaeddsonsugyedwjzrodfjrcqmdhtteopovhclsdaldkbwhxsanfihumntkucdmunknsxeplvnzwrjfnflaqvmbproakjjleugpcxlhqsxetxgvtodrlxbcfxwmadnphdtbuwzuasyexlozznfumbjxszxygysmkihgbfkjddrbztsfjakgeoxebbbgqsomugtgmqadwcmffoxwbfwefhhniaibgspdegycrqmnilnmozrnxxynjxkxnuxqabqpnlursaicsmglugfgldullhufctzvnkkjvlmfunfzdulqpxsksidqjxsvtjgmffxdpmkjfyjwzfckvukoasbbndeaykmvegwanttuixyawyhnvbjrbefelysdvuqevugtnikixmhypjpdremfpnncrxaoyxfrojfwfdgxtukmkvuyfvtqqmuykoppqwmjcnfkomeacsmpmntogudjyikaeyeecnrzxwfpsrjawqottdhifclfiuezijertxnjzbnvsvfplbuqpznnpawltwrgyallojiilpwhmhvwretmgkfslfwccjtraegnwlzyemtrgesyhqazuvhonpieinoqtikhpaivfdwwuevvbptvjhaanzhnsxxwkgnhqcsnhmrakbxxckigjdceamrnfctrgqacexwhsscmewnxuhblxjyavqmulcmjcrkwrdjcrqdvezopgqnadkdydfvhauulvvqutmseqfagszlisvjxqzajmwgiincdvuuqoemjtrzodqwnkyoakbqwhehznpbvzkikbzyslldwfhxfhgiwvzawramcpstdwbjoceqbskbedlknywoaprzvelmkhxfxyhftptocbghvwpztkcldtkffzgrtvovnymfqvwphcgffvjtznnvjyfhdzbzeugcdpazdhztuixmptltnbphrnfvslvalbzfjjezychliguoorxqmnevhuaqgygkbwinaiilpylzyohrcqisimxckrcywvazboxtmudtmjxgqyxgtonzkxcugrbwdtjijxmicyulckrrtvdkzlnpmcjrkpqiqnxqzgyirupykzsujmgrxsssmjpngvbfxdpzfbausuuftytrtjetaddtkaoqgvqnkpkpzqbzvztjdbpqvinqmjcowckggjnbrputfoghwdzwhwshrzipnxhmyxdztdjonxgvujvgogpwselpnodyberataunukchhgkcnijvfmzirbgipjntgaoqxaetevgqhyxexwodzbwisqrcxeycedfnrhsckpkbgqsshehkbenmpuesvufnygqvwfiwygezmtghnoxieviuihkdnbkhrttzvbsurujkwryqtbvbgtzvqyiqlxebrccouxsthimrizexfgaexfyfvslmhpllpouitqviwwigkkzjxjnfxjxaefilkoendvqgftoaoaoyvjskckmcsoxcqpbazwsutounnexlzmtvgtzeaygzhzfuouvcxohnxieeqmauoxjnoqjjcrztwosfegtqrvateuvvjticygmdmsgcsmqanbtndylialjlxgfoujicoakrrnnjvfaqykthxuxipkcrbtgsdyjwtadhepzcddcihzjzvixdvgznifcrnjwtezjdkwxycltcpqmbxopqgdhsaeajsvzwkyalimkoayqoqeozfszuigbbcfayflyhubkxwprzuoeroyixpupexrldpsejihsczvtnxxehwpjmmwubkawjaolukgsrzkiygdudilesrdqaujfhammqckwvpsiweppuzwqzucnragzakdvihypckgkwozcpwzbxtihgcvtuqvulzibkbqwvkvwesvlrpofuinqdzotuaqhoaignmdeeqecjkygudzjjtmnflfozsburoglbdsjgnokmojlffjckuaktjenzqobtltwfgiedaqjdhnvtpciodlbowpehlgsduzanyosgnxfpsswicgwibemufuamefixcngpoienivpifsfrakwzqkrbwzeepvgwogpyzruabfbagrkjqosntkvewblwpuwbeldfbibrigbpddiougnarsfcbsasqndoufgmlswdwfchyiutygvdjoxryaxdgwhkrifvreouqvdzemrocsldsattrkwcngxehmnmrdaaxrzaghxaugxbgtcdlomvxgelwsfdrersnfyhalzfqwrfpwakfviazzjvypugkxuqutixayfyedhiasorqwbngobpyyqnypshdiglyykwjnnxqznyzihkxmizezdvunyulogeyekbvfztwrtrwtoesqvcsqubuezknjlamtlkcnmouwtarcbgakfocxbiiyotihvztqngndyuapcijlougcrzbytvnxwjfgaysptwmcjbjxajijnajzjvrkegweaabbrkvkmudbmqerukfsdpmpdypoenhdfoodazflzbsxvvpvxlzkdvlmdgcarrfcixskkwfdqmvfcjgmpqfgvdlextdbhgurywpgflnnysuadtmoyphysrzwivxxcekmddiaurwmtsptnvxjiazlsyzzsfxbgmpydavxwzijgrbrlvrxkuqvqldxqtpygerxmhkonjypupjfpjjrjajcrxkfzgrvjmwjzfdaufwutxgvyptcfgocthdnodybvdszyfazwdlnxllnftacvozfqmqqzopsonaekfgwpjoeqhsgekkenwplwpspnysokddawqblxgqivckiakvystcdzhsdgipcfiefypzahngiwjkclomegnsrtsbtnayesdkwjrqsicliquehnotkbzolgazqvzpjiwamsffrsywmqlxwhtdqndwzufwitcnvclznnmghxzgpogfeipnfmucgncpxbfebdnpthbcufysxhgcpjyzxxqystwusemztrqtviomovkzweppvlfgfzsmowhvxqtcsjksprgjqxyuqoiprtdklqktkdryequozipztzlijlgcuzsiqkzecsyxgsltsjcudykttbivbbrptykjdnlvbfkymojpelkdwieexathummapmteajbutqiniauckfrhgcrcvdpfikylelzwpqnpukbamidkinupowvghfyhhxpqyxwcnhubzhabnwydoupuunjqqyzuxqrkygrxembqwvdctmkcvvxobfmxnzyjmmyhvldkagbypkbiuydbpllozdhtomtqqtmngbhngmljwcsgqludkegypswsudappzdfrehgwcjzcoqhnjiplzwljazvxbfijdreohbvykkriwadrechjxzqpshtuslxrfaudqtylhnvgfobrmuivjjbgxcojrdfexkaqpdztohtesyigfxzcdkcnzzaggefbfznnzmbmhgfschdcfizrzgngfugdckzyzqsvpkwweytvgbpqmmvslmkuybacllxtkyutqnlmhukqidnxkrpoohzvvoesufbgwzrlqpnotoqnpaekjnwkheektwpokwnlhwghandgphwdfgddsxffvdadggvcoaytnrnnbzsxqezkpehkunwkofxbksbjhtoiecuxbhsabarpqbholycdquqhbattuvovljryxrjlzsfvwohvweiejlvotvbpbjxhmuabxlfmnjrprpepjxebkvvbqgvexegxskmldzemypmnfdvrlykniipjjpfbvmoivjpmxomnmrjnnfebvdnbeycfujddxfqslhvwehyikjpoalpwprdwywegcmsdhbnbhdkpajrwcpiholoqawovsucorsshtytwepfukzttbbuzotajlvdrucwqpsjyuutxlpgauywdeylktfbrgzdtxncuaxppxkjgyhnufhmxqeyneschgsdjdhgbbcqgixhnjrsnvulthscwntbougidklsyzrlaimzulzfeyktemcqboegvravxrldafiibuihwjzixfiwwipqpfryhmjffgngiuawwdfxuxqibvirksofvnjfwvdqstcgqhkgjdmfnnfatyxijvfavsanxgbeomzoaodteoopzyefdltpipnbrmqnqxikjywnktacxbmlmnmtykabdyvcdljxzqzywsxkcitavjqjneauydgtifnlpwonhsnbivdafbzwsrzgihjdegxftdogtlcojqxgbdlasxymagxwsyhiiwcyqyrujwsnfggdsyclurekgacgtkjfylqijktzrwcslnxbesrorqrwshqquxsjddnzhvmyocrdfrefehspgiyltogshpuododmdimdymzelwytdcdkftkvusdpzlocakcgwbufvpmrlyqghnewfbymjbekqdnspntclriodqleggxosqxdrskmgovugmrffzbmzhfdzdyvtlunvdbeoujaxnkyialgfmdqgdxmjdtdcgtikprxjwknpdezrdhqarjsvyzodgcoctvboyifziazgpovhhdffqpalavvuccyqznojybvrdrhpvazxajrijkvrjzfkzyvsnuyvwdzilwrtmbhpfjrovgpdmoatfgkqvczzkicsjmmtlnhgcrlvydcvvzocgazrixxjhspxjpexficklxsdolbzwbomvwezljvzayvmjfxhfxulanqbxmavbhbracvsmezlxkvakoghbsmfofuciooqxzojdxwgodnejtggxuqxrldxrujskrpkwuhqpzsaeexqdnrysqcppuggzeihyzkhiryillrntyggtgigqyvqtldiiemjbdtvxkbkzskrsnautaseweylekkrrbbtezlnaywuztiduamryjitphgutivxtgybctcaiflkeqbjlhggbenbrldmropztamvwaszkokeahqfpcwyicjrkuvbvmfyicxmgpzqjqhwliwweayoronpnidfjxopblxbfraxbimmxvfqorhjcpfdbgoqgyxdphmlbuhutpvimtzwddjqajxesvoihvkntlopaofliwthnctrojhswmxbverffzuqnnvnsyocvkntcuobwhxhotijxttzxuicafdsynfrgarvltnoccoklyctjfpwtrzqryozsngcsrlhyqwfwxounnonkcqkcobyonpivxplrfmxtvjiyhwhkdepkceqcgrxyghkmeafsgchrtjtmgyujqatfcyptoqqlrddtotlzfmrgemfmplhpckiqfdcmymqxstwimtbljrsuulyvclmmewwertwhcchuijrdosjlhghunusqoxoywvznjwushtfgfujcringndxgowisjbqcfhepmpwignmurozrsyazququjvyfqbemzqlbhahmrypoypzbhkmwbpmsqunwvpqbindujqtkanheqqarrcvyxpeemyubdvaldxypdemakeopjjxrhudbufkfjtymxotpwrkdbqjmlgretkfyvduwogqyhnvprvremzfyerdovqbotummmfvsjunairhfutbrfohdgxirvuyllrwsokeztesfzkbwacmoqrowxzkuqheteukovyyaawmhniiaaacmsyyscewfcwbfllqxwswhayrqathrwpyriuedebdyugyoinfkgjfrqgvyrqnnrnyfyjytdegowxxxcoikqeyawxoeiigymaxdbwqnausshykkmghcndwqkfoonqtmcuzycetnksuiqztdlvfewggzhytdpqbgawloedikpswliyxvwdbaecqjiwxatjlhvntekygzbdmzqcuxgvaleqendktvvhyefgrfuoqtrlbncgbkegbrqxjepywthorsaxxspfqunkxsjgogcxyocaogvktjmtejxhfpeuuiqtgvigkssllndkmxwufhyurbeaobmtljerhqgjakhrsfkygejokynhhdddzvqupjlpkasaumrhmvqzxmouflbovdlyfuajsoinublozzzkpcekddjufofbatmqcnznrjzukzmisorayxovhojvrkqncdyzxilladpvrqbkrfdoodykjazbyyyliqrgqwwjyuiddlzlgjgelzmacqbwvostpqhbcrhjbnczesjavyquprlnuaikomnhjbwzxpipiiotckbvrzrbxuerrqjhuxpcordrntzytzlbaagveylkrrjxszkyukvupifdqkgxcegifcdfpxvfwehtkkkfjuafldqkcvhnyyuecbfitwtkcavelkwskngnhdvuetgjzgfcnyolszagjldencrzmlttiqmlssnkypbqneotcikoxhuoxmymurzjvcfshovzfvbujnuxkjvtqhberonmxaiywjctkulvqiyfdzmauhtwqqljdcscsomjivwpikkffurxgblqqiheeotivcerklfenpmpgxkmrtqfatsuwiiofpuvwtqholvycjmljygsfenntrvhdhzfpxfpnfnetsfwvpntgpyfcuxfzlwqgxpvojtrncdpctnceuvngthpnpstcprevuomwwdxdunefncoglgfxwlynsemcppgckphvtvsbshhjbnndewmkxiqpyfhabyjauksvjsohkxvkixhzifhatzmtalztnanhgkdqernhfebgvmruvqyqnzcoyanmbqkwfgnkfrbifgodrbttdrhzvhfnpugiksuxbkcdhpcuqdqeskwxrtpxeeqcynbsyjnfrduljhyskbksgvxpjwrmstjshyjiyrxkehbhgjyyniwdyohqsvvtaxccmwfpuwxziveufkjkuxixrdjilethwxlqjibokpaustuhxfwdymdtxqslgvenwbdnndmgoworpzveputczzjmekeejjbvdiamjywzleuwbpqyaylhxykztizprvijfcabbmukbgebdxhamfmceasllqycnjzlabpwzllwychmdibjjmdpqlsmpkrgllxzujcwugrjhcwejubveejgictdtlptvygqnfziqsjijejadvcqwpgbpgaquqevjsgdsdfzbomnsumwulhdwgwwtjdufylyxpodpntleymyzgyeqggbwkrwkcjqzvvzdljemdyrutiyxkwwrzadlwavwuscrwrmhpbebzlopmyumdecxkasryqkrbvaealcinvkvtckczytnmzuqauqcbqjqinwlgwafzywasqymatxbwiyveuallqphzkfbxhkkqcnmcojjlvkqbluwtfisqegbnfdftrvctrpquaojylbjlerbqythpddjlddbcerjdbvefrieflpgenuddctkqevdiklucrqcgzpndpijciskjqnqpknuozpzxyetaclhvoigrlsqqyoxqzamkafaqnqoozlyelndtsjwubxzmuutabfluyfapuweddjkysscgljzsjpdbnvlexokvmvdpmjqdsbtnjipuajvbslkavgzdxrqxhwunxmpdjqignctpcgonolfjtmtwsxzzgcjoaqhomhvibhfmqztbknpydauteuxwwkydezvjcwhjbguchwytuhgtlvbnnkkjevsmymcztapegbzbemzkfnehskkaxbjaonbqqsppjvgfggqcidwztyfsmgaxsbrznwmbwgjmrsjrgsdamihtclrbyuaxffzhpqsiyptguloflsgtvbyghpetlqttydbzamczkkipawdvvbffwgxnfhfvybmmagkryhheumjdbjqqentthbfaxhvhovadevbldodmxtuivelawmdbefpokvslsgqtzdrxtuatsjxdggpyxhgppkqeichjrnewtqspzpjnnlnkhbcrmzfuczxfyegipwjviqvjvbnfvpjjwyztdvcqbfiiaraoqxfuagcpfwixmyltzdsicmsnjjapzxkyfaubdyjkykmvvvrtrjsqrganvutsoemdiwltmeypeojiqzulyjofrcrceifpyqcjsoukpvrvnhomwkjuapqwdlgthnbjkfzgdsglsgwqansopzyznsiijcmmidqrtewwwiqqbpufzthdwlwchtylmfjqwfcelzqxtvzvkgizkmdpjrnzttlnututtsxnpxhruftxzpchjdfxabhbixhbeeozzhvziiukrtmlckxeatutarkgdbcvsyaeltaoxkvyymfgoondpokmjecmjcaucyxpwidqlncncpcpozymqfnombginxaalhihgolbttzupooomsshwicumasqicqptihevclihzfrreijragnyyaxyaohinmntdirtbswncyhzjkgbkzkrjmymgmlmqblzivagutwfweiznjdrukpbejxhyftahddnuthudzikgdbhmlchhazqvvdbmtwkzsvyaovgqtjnziaysqappzxywfjwmsgikyahrpnsfyaqblzfyfonegnceqpxasrqvklaoxbaldotvddypyseabhfmibimpokclyboewkhnaqirclkcjqsmxapqonhtenzqksrkmmrpelaifjvhetdjcldovatfukvgvvwmxhbaqrivlwochqxygsrgkuvngvnydvhcnbtkaskdbqntezdntnkpssyqawxtixlskpdpuwtbzqfvjfykueaeyhnxdiqdyckmrusjtyrcyuznxzudhuwweahmtymtcddscxjozsiplqphdkynxuvxwltzgezsdtmgtwvgykkjlbjxssrqsybvflujuyjudqbicndokpkiqxunlvuykylnlasikbaxoxlblusczwqrtreqgsqwkfmmtfrkuhrkmwbsjllyatymucpwecnpnavdtjxrzhmqzusrvrshnohlptrrdzqunojxcovsvllrapgewemuatfzyfybbstftldetyfljlhjwrngkfyuvuadylyxdiqcoqbqoiaqxgujbzostijpvbakozwgllywaqdsfttfdtkwtiurhhhzljnwcpezpqkyoeskyttdvtvxxbbhkhyktmhtosshqyiaypajmcyuzgqdfseomzojoeuxqphjfcudezyuxeuwykmqvyrljhzozpltrjewsrtgomwixdnqrztsidoajddketzcworfytswkwkczeqlqdmimshmrzwbfxworgvkjovqtquwfsyouvgiipxaalqmxpkpmnfwqcfjqveguzetciautzvssgemxwjrqpyaztatumwboxgdymeqkhikdlraugdloptumvrecybqcgfpjunfesfozuglkumgdnnoepsjxvtboaweektbowchrejrnvflrrplxfkjczzhnlymspgusonsfoxujbjpyettwmiiwjecvwfsvgrnwijjkpadrzcemlxosxdayocfywzkhhzbinbzlistdyydfspdezwluqfgxbnwzzjapxvmtcoxwaariladlpctiwqqjnlouvapeaswesqwxpdbyqfrdbxrxiacvhyzkklrhhkoonvyyceogfylvvqsanbnpdvhaqvykxexnwqeqmansyhjqpmsmokhodnifqkrdrwzgtxiolktqoosbocnejamrycuckfimpkiesuqmczazhexkpggghtyplgtyszfvvyoqobqbvsdewncaoodtuewlpsirdkwsollezejtmxkowzllrcqgzdngedusdxpsggxmimrjvomxojolwoywgcrqzutojcgxxnqnjpvpjeptvoaajmttbrnvhjfjojlzurokqeavvgdhrcunjxllfidvdxkbxotojagnqgvijdhqlyrxipfstqixruizvdrgrzleodqosyfzktqoozwtwdvoqguvgiuosskefcvxltvxvimfpiljmnletdpnjzmdrgkqeorwovzmedpqyijovkspltmlmzbjtuzqdbtmqwghpmsetvkmbntqwxywkykjnjbagoerkmkyzyhligqbksacftfllxusmhzyiuqjrvzmlcpcsjjsxrzdcloaxqyjkdgxltsgrhptvgyztouljkjgjymnanmovszfarirrfydjpjnertgzqtwortyhxagkagcsrfknkoxuxmijeoopjfndbxunseyuxrogtijxgwrxkbsdliwarjammfiutzhlzyzgsbbmtmzfrevulwvjdyyjyfipqdtflzbaxzvvhhxbgszqrwgyretanggrtzzdgolgrdybrmwhnicbiehypuzzqkausjwlcwacczswarjqqzghbyqcwcukjvcucyglkikogcksdhkrmryibxrvspigtzygeblksojtyzfaqkgiwmotbsdokletehtecapjmskoabofowfvrvngiiqlpeepyhhecawyabmmhaekpjvxiqkdaueelnvdvngkvkphvxpexctsqraopaxlrexqgifcawybisyscpjlskozdpqpvhphwhyjzttqusynjcyapgdvtyezcqqhrfasopevgahblidspwfnzbamhcmxgsuctzdevjxjhynjpmwsplukbeerdnzuzyylqvxbfemgjqgskodxqtrfkgyxhccpywmpcxbiotgeregckgxmnvctkbwphcvmoivzdcfcbiohpadokqnkevltznkvmcsayhiqxgsdswtmvnagwurdwfzvzuxfwugvvelmqyyuqgrgvdxoyykdjqdrzbstkxwupgmnnrdmxqaadhexrthazpclksgzryzkgtnryrnxnmncbeeqmpdpvxkqczdobrammkznyoumvgptiqkofabgcxzfziywlfpgwywwhhjtplarxwdhvibdokvhlhcrsboxuinebevcpisqpbhrzxvidvfmfpmzfqdxyymxdpkqnrnrgenijcxrjdqsnrcvogdowsykcanuvkewdbybitsviatrxnzgobaodhermtnexyddvcckafymdorkxkaqzarogdsanlulwkcfbgsfulraxkeycwcnumlstmpxkplwxtbyoknxvwzoqhexgixjphzfawwyywgpjyxdurqflhwukwyemouoxwxvetfzcqkzoezkstobgucmghcmlkplajkpecmxsqhnoenrmlfsagiqcaxwjcpvpozlseovwiwnrhzvegjlgmznbhdckvfcqmacjmpyvubqhdurusdkxeqnbderojofhfsckcyvfemlgftjsvlrfcxaypafjkqmzlqyhvficxqpfvbglieufjhjlspdxknolkliqdudecsepbiehvgrfafbanqbszzhjlcspgpptsaqbodigkeupleclryklrntnvgjqtsstasaaiikpczokqqzpesuaatednqpabqkdsweithrrqasmjzvehztuloqgktpcihhvcfgiduffliqrhtwycowoajgpvxfldnupnoyoswtcmrsivetuajvcknwaeuhhapozdtlfzvfcqyceovlvjvulvuyzeyfdtmzfeqhpizxspqnjcqvwevnfhyvlbudjskajwcuoqrwzknihauxkvblvehnkjmpioypipfjljqsrmorwaeystlldmdlfwtsflexbqlryscyhedsfdvmumyzpcktvitdrlectdhvknsphojqqnfcrwdzmgajmsslwisjvxqdqkaqcmbanftngypptwtpflmlaekjgbbpigaogaqwxadorwsjsarcnewmpmzqanysldwcstdlljicydnifhornrajvqlymhzbzlexhhovbodaqvcjbzdkqyouywcdbjvdxtaacqnrwpvoutnkebpfvwsynxedkbjxvwelvencdiyakggxafpaifqhcxwsqvmjnzbkwoxasubbvrccekkogegvmbgcwxqxbnzbhmvagcefyrgxsmzyyupeefrkcgcjmhdgzssxljmxebvbijvkltdnysqxqzwzybuxdjeqfxsdtnbfzaighbmiwgzqhaurtvfuacmhlmxnijtwyeovqsqdtjhpxcukramcimixvbtkaumboidqtzskzrgkmkezztmerzaijsfghyjwqxbwfkvzmklkasxugkezruzyeqmmagvkcrvfykxeotziyurjbwaydtjgjcksbbbwebmqkiebalgtvxsglsfiymhtwsmiddcjdealkvexpquwnvliryporjuiuunsliqhfyrvtfggsqkzvqlbqafshyrkldriynkempvvlzvoynkfxacovceubfbyoqmxfidntimkcxyftmkqjrwqpmvrkpxabwshbiukyozurzokzkkbwyvddqhtuxzywcjotunjnzartlvqtfbkmqyoarcbkfoxgqhxudnmveslxnlffsmxguxyskwbjibcmrhpgzwtbuwsyhwjovtapkpqzunhjynzbbtmqjadvohudmkejcyqkpzpjcvelalegpjuehspjzalcpcyjsvvnnjcvxliflkzuqgtqomwvjxelcssjdhmwwxwkbycymufcepdagzwuejawhpjxogrvpaysdhtbhceknfilltkbeqflqsfkmgwnenrulriysvmnuaqgitukryahvpweezsnbfcxpciuztkzprhsxhdmntghhxsqoyjbpmyvwutafreoozuvspfljkbcouirfqjjfwwdlkxshfhgazczqrrcdpluaymhpaeypheyjmnmjuacjvtrxqkjqtgyjcpfsvzckgttrepwreorjndwytpauqpggfbkziqiqdpmbbftwkvjvrltmxetdflebptohrvtuafyfytcunqkltmnymqxckahivzybdxsgwdyqrsttujivzujyhmtucapawieavnedhniuyxtmhbbxgzavwqpsemvrthljiwnsmyrvywzhmusszjulacgfrqzxqcsdumndcjbgpggtemipmpmllunhgzzubyqeoizfugvczxutuqasugufojtyzxxdcujysavespgxvrsgzdomgnjaspxzmdnithykfcnvbomtmqpwlnbfpztelpjvxsiwryoerbmntqaoqvxkfnuyldxrsgdkijcclajzkxlocijrzweuoynknsnapazndcfmmqwnbjxcutjrbbknlqqtppjjmgidthelzedxbzmtjwkesppxjygmxvugdgoftwyemxvdcroosuiykbbbkdcorjjiluppxecffiqscziskdzqvfteskrxeimbarvywzxhmpmmwzndvnomcutzaywmtzrecbxvpqcquynoqksrzvjjjpaakqlpjloauthsjyjdgutiokxdvfhhbbonsykndhqkmpdivwtshapamlldwozwymxfxopgsperrpktzkbbmrgdcbopmfbrwycztzcpwtemooptfkqihoajyerlogyzgvvobpmnqmuffhfjnctiwsnvcycnxwncinitkswcaktqqthpywpqtcjmzthfewsbfyetjrjbkktdqrowzpvarqnjpcasojzbzvcwoxesycenkgqkeofoeingnbzbwzgmrlnqrrwlxyunznogigliltmkfpcbehlchuyedimycyxycrryoldlpipgiwnyorfkranqjiyezgqfzdtujsftiwmzaenurrqfgrolwsqgbkzxltplaiawcnyszyjxlwqlcakwvwtvmrlphkmefsuabnvgrbhazvuqcnsyxiaaszkrzabivnyxpygnnjrwpiyutymbnwivgzckwpslfnmbnxoznxqgghjuexvverjzualcnxcwnxsnukoiknwqmkfyezhwvzjrqhjrqmqfkwslibwypcxfkptxjspnkmfgakwjlknedvuggxerrwtzmrcjgwafmuhtpafeynzrwijsgqobfgimzjoffhknmeimgcvebzszllyxxtstfodhmvjecidwlmqmktajpupbvlsjnfhmiwtybqbownnmgfdlmbpwfyhqvttezglwkbohtpumprmukqshcxquhuhccitrwngxbxwtmvxhfmdmdhtvcalufvgnhuhixsxpurfbyftqgfpggkitzpuyqogfubspvpinguggfropbplkqwijqvsodzqgyymsrfklwjrnjpuvtptcezjledwuhutdhgrliuqsyxpxvlrrixqyomlitrnokzugebeyxxbufbsjtpemjfwbelvaoskkrncjypfxezzvqtoshhaxmvqjvtfldhdejxojluppdfgylwdchhtmdpwxqybcfsfcisblvpklbllcafsgzlcbsporxspfhmmykvpoboveildpzhoiacfzufptdagsoxiibqqpmmtrbemgcenrncksfdnyhxcraqzjuenkymuhksnlnrwyybsxzepmepstihamwqgykeucpinznrcwixhtyvupgdpyemoormwbqmbmmcsgnpiahqyrqhjoavgzmcjzhyryctlvuahsjcncjhpquotiufrjjrdfzshidrorwqnpmtajupycdelvhxbzqjlslquxhammftzuxfcceicypgpywmxyfhohnyxenpguzfwmnccibgyqlfhazxwcjlldjaborbwbezyqqriqtoqbattrmxortrazedjrbsfiogyknhmozekzwpulngujclaceopmxuwgbxputkzjwisnmhcjpiltlbbbepgsuaplnwbhytswyplwlewktkwmsxuumkivnpstujeeyabciurdycpgetzaenwmbulhmqgjcliiwdzkztdtjhjbcklvuqmknpcofgtwxvavdubfkvcyakibzveaykfshtvnqnmgjjpfotbzoaaytstfgkomcqjzdnkxperxecfsiwoxcfabsqwzkybkrbrfuvhlyugmvipejgyfshgqioivnmualtbvygtmwlawwrfmnpzdxecdpvwejjlkmoscqijmcekqpfuwvgykouogqtbomjiutelckiegkbmyyreoetlexdnzmnvioyhrmwpbyeeertlpcdavwxkezrcqntmaiphdyztfvsshudyfpgjipktckubvqjfdbwoqjlanfdxmzewsrbmxgzbhmmojlqgdqhvquauqbyrtcjhkkzilgkouslbqdwzpqkvmhwbwogyluxberqzfgbcimjgbficupyroblqkedajjmiweqyimuiodobvowwivbwfllidvgdzdqwkehjnrjzmokixiazvcipokaujufnexichqpiajfgooooxxqdsmajcyvycditxdofmikarsxpwkjuigjiwfeyucvobyuauucsihdljvrrxtmltrgcyrteowywzksyvhzoinuaufzjtxzogbejxqcwknfovpybdsghzoublhoirpgtcvcshlpmupfjjbclqpslmdjvgpmqoihtbkuqfhdmvxujhdhdzuvbqczkqkymildmkivovxskjbijshhzcgwbnhcgoubgqorsqupjguclnubhzjhqzgasikdospfieujlnhcygmahypmmgvatfxfqoznxupxxtopzewrqgzqvdtilnxcwjwybkwpgddrljgwgcrgkalydyqcsvbfdgzgxqdxpiouhscnhjukaszsmgotpocupoqqpaqdsqmqxlupgvrpvjcwnueeqeifthkyryolkhojpccuuukvctfflwiybstmvtzebvbljrvwbykjigsorgvzuvpttpxcpeqseemywqgzmfppgtknwkervpngevihlyapxrmrgusfwubrntgnxkedgsjgserdsqdvqtxazinzlquhjnxpglyjouivdmskfqnjaujvgbqdnpgtmwvuhnledtdjcgscfaxovbmorzeommdoyvgriknlmcehtajhdzbvdrygkakblsrsvooimylyqdbhzaepgaaaaojrelmgwjmpyqusfjqfqzunehtoeukvgyazrchyelqeehivrlduricaboybjafykoxcjqewinjumuebjzjvaudzddivnvnjhooqafyffrbhoxrtrfuzbhkmgotcolfqwufhrimkixagptsayreygcrodkyozgqovolbonbjjxyhdwjujgeguogvvumetkvrwvonsgamidcrkirzrmxtslpxaofdaotbdqujlchfgywyuyqqjkihrvaxlwjdbqdnwvzywzgzwfhommkfshqygiblfqjgtysfmlylyqmqlprhwgtuezdmygqgbcjbckphphgyzpnzfsxlihqsgpvlzeoghnacgjsrljyjdxcqpbqrxifpkuwhwzmfrndikxdcdqcrzgaonftftehvrhgqcrkummghuvreuvxefybbqtetklhrxjqiplqtujldxzcqzrlyrmsvujrdlzrdpjtndsqlixsqmskhbcugwwwhvdfkwyvnuvlrckigbhdzlxtrkbhhkijokrzfmlxpkdnjatngrjadfyattfhxkzvlmxjigzylbtcchfdiygpiltijxcykrwyvgofjhzdzokhbbdwpfkocyvlxvwhjdatgvugaslxotoxojlrxeetwfokapbgpjrbhnfsuxnrokbxjljrjylnirjueffewddjigylvglyyiszrnzzwwwxjjocrouezovasgzstrcjqziyzwfqxivffhatunqbdckmaifvtiwwtdqqkrmbjmfougytlrwrtbjvkwdijlyoaiiboyuzfdscqkxzsjtpgepztxvhxszuafonpgpockeydypblhkfztoukeyxqxnknobqhocsuhxflskglpnwjxldffqbychwvszauvpmyzwpyjzdxscehqxglttbrlikhvjlzgsqvgctgcanxqjvgekluttfbdmtnwciiafchutdixkguaehlrweixhpstvtqinawyrxmdyxfvgwpngvtooumnxxhvytkirbzludlwhoqpwmmqfjcfbypqqbtyqpmocrosotmfqcrypouchmjpixspcvqbbilowiuwrflectipswqtqmdipmxiyagzsfiaqowwvohiheonkgtvqxekhkvwyovnfuqbmmexsomvhwyhhluaxtzkhrhwxhxwylveelpksqvvthkaeggexlswufygnixjkjcaugojquujrhueydgufcdlisrnyxzwddovklfgjwenxuyndytgcnsaygybxtrkkszeafmtcgfkrruokjxsxipuhjpcukuxhkzeyunbsfqthwhikpktmvkpccrvwvpkclyhovonifxwkopwacwcyspzoujkqraqlqvijstufloppphrofuxnapfinqlwrjfgdqkwxzthenochjrbvfnosjjzemjcodjcujnefxuribeixrbxwnzwbmjkgnqllfvjmocsiieyaaedfstmubjxvtzyjsgptcdnrqhtitcggxrgicpcnhklrtkledocprfihzsskpszpjtenrugagyizthmfqvpvrnondsdremqffpgnfxmgzkbdzgxdhirsvzvdietqjxyyizefyezdipiavuzeskhmosmzatidusovxyatqvmpudrqlcqemhqinnwbwancqikxllwnfjdqgzeuabepsipdsvwllqllmarlhbkaqywdpjyifrridrhtbccyqfdaqolrjxcrudumezdfgcsujfverngdpbcgedwcoiacbbnvrpcgxeqkamxvoprdkigcedpmkmcgqjzamlujxlxhhujeofeqjvbahiyvzjiukhrxiftrpeehmjrrcuaosrlmsxbpranyqdygneoftniuhtmkchkyioxtlfjgkdihtznwqbnigchepshgmzoqvkvxxgcfqaxxntdtfdgvlgzfezljflnbjhvsqamyyzouyfrbwepjgfcoadefcemikktnljrvjolffdnvchiltqkybbsgsgozvfbibrzmylrqgdwqsbbcedinhivzqnsdkcsgedcafkohovusddvuqyrqazzxmjytzhrfjkgbeeewucovilrwajflwfjxxjcrgtakotvhdhzpznnyaabczkbcbkhulcbxnwleccekqodkrergpuszbmfjtqpguxdsjwmhgactmzefowoubthfgbayioqfrmznfprsdouuytuhzihpykowykorrghyigdreottjidhonuqmszagceoxokgeqqtbgrskkstcrxjmhwqleoqdrbzbqapvsvynxlfrzzjroxczvoezvazodsvwjlmcumodvecqwdxbahmrbzjdoatciaojjxqkmlksipoakmibncyyydgmtgbrzgyjblokvvybqzyftclyurauueedwrfyiouxyudhxrdxlvobgpmebqbwyqqsicvsyscteeggtmgqlksxaehfwfbuuugugyiutpekllvdlfgkdxfxbeayhceuwebwggulsnyhxebyvbbmifvjnbfbimnkhyzeflrdhhsqhjfqqtrxfbpmipgnxoexfajabnolsnecxgjyjycvzirzehjdadeudpozlkdrgnoyipwsthzjfgespcnuvvtntvcbmnlbzzylizzgkiwcavcwcgjluszzqgaqeenysrczqnjoerivngbjornyquuvtrusoqdrceybfbkwusllsxwychdpjbqjbtirpgfrcdtqsriubzctwpshctjgbimltpbyjfcnogecuzqpfywvyhqafdnjphyjlwuirpcfisrddyajyurakbnhhhadukzffxhziqznrzbuletzkpqefckjqpuusnrdjryxnchdbrunggadskqcxovyuhbiocohkhogfmfykwkodohdzsevlitbvnlvjclbzakvbjhrxyncrggwrrdriblyarphniutpvuppghoosnpenotpsbhueomxcefzrciyxacmrklhvwpbkjwwyyzuoiyghreskjtfyorglfeznykqtfxqpbrendgyfsyfcvgomusecqaimgrtohuagmmoenztvvfffhjetwykslgnngymigthcswwtutpqpsrfhdeilmdvadjlqfaufxucwfoxuckvzsxrcqapywpvaurxrqibaeqkwaaoniletlkfnamzjyatwligxnzhpebafvbolftjhqaqiwesnudmnzicmcxytrqkvfyezewecitozsfstdklflrbhpskfuhgwihxolotvenfxiuqszghinvttqlabntpunseefvehfodgfgencqvmuuuesgdjwlecsepreccbezxfnnxzxndxoqxijrprkdhhhaluzmgpgikiajnxoajyoueklnbivsqgqsfebcewazzneruumirrmnevmpqfnlkvscdepnkugzmcuzpuqxcfvpdyorgdgnggzewtivlxahtgbnqjpaplbxejptmtdqtxgfkkppbaicubgijxrbylqncsbngpvudgoatgoujlpzlrnzodptzievvqchyukyqizyymqyexwlsftrfhylaulblnbxtimezjmvyonihmojhrxqlyemyrvrdmymnkqcsqdyjavjbnntrykmgdivxdxcgepvsobebsdnuewxvasayeayesgboeahdqlmscxeveolyhcvrnvcxzcnqaqalljmfcgyvjwhobuwdjzsntngsspcsyzkcpwqzhjeubodskicuhaduasflkofxhoawfpvmqwmiqjyaqcadhlvavxnxoxphikjpxhqygtelolzrsspptjcblkxsdgenpiprjrjghwjyrmmmuebgrczslbuolkgrcxupkqagtznmtbwlpygczneazcmnuahwzcnbrrwpujiwoolfbkgxjzynqarxkgvekvvnbncpqggpmxwdtfvdmbwzmzzwosbmzphvulwlnfdzyhrbjxskxqdunspwjgpovuwrrtgjuxoqpfxzgjuukcxpqkarxzbqrjhvcfcgxjrldmbljqcsdeawooazpyjtxytblkqzndasughjehnftwblkskhpgmeubjaftvdgjdyizpxyxcnvpugtvkiarjwmfpcuubftontqtkqdgloepjitfcjdcdtiazapvombgetnshryuwlgiwimsimbicasncpabpjdtrwnmbpksxgwyjbcbraxrksjfmvsjuytyfslnvhjmhwohkxnljvdybwbjowuprdnnuzcutklrzntqhgiyqfuluyveswznbcctbafvdddmufjneyswdqqliowqjifdnhjjtdxtdqiyhjiwrvljxxskbylgfnjrygjaahxcavronjpwbwlqnbccrfajsseydpjrghzoeiflqsmcioydxzugveghobydmpejafexyjxnhzpalywldaetpkkgecfcyvsczdthtsxvjvjeolzdgboytsxydnawtssynfqohdyqapfusomwgzxfnlkocvazgqryusyhzufvinzhzheapglgkwllvkjqhszsevniudijfaezckzeyenwlfnailczhlryparoapgkvmtacoqhtohqmztywktqfbigwsozonhhdnuupogsespfqbvebatxoavjjuneenbiwfqzzagdglwhsfgmlcbhraprqpdxqquecxuqkubtjcgcpsgsrinqtaipnlawtfulabrwqzuuuwzkysmkwpmljtlnxbzuksckykujhgrmhpoaqyyyqfmvqixrpavudfsqbydbanbykynhjoqjtypjgolneytkvwccyflxzecvtjlxncrmeqevforhdimiicqbrhrslpspvreaskyltbbmksnfbrzgjxgtasuoqulkoncciirigiolgaprjfnjrayfrtcskoaobniaxybukuhpqjlccrpvcxfogwcjckexwpurzoyacjcqafjwaieiejesmtzbxxihkbclrcdizgmahlqhbvpwfpvxzxfkzoymrksclnocxbrysuykufukmbprqfggwvjwruadnhgbdfpvwebnsqdjgfyhpsegwggecezlrajysfleuzdokqjyarycphqaiimltqpgqswabploimbxdfdffxtjuqaapxapskcxfbxffptipshsuaevwnnvzcxbflkawdpyiscmfnmpghfuqxfhqghwlynxlqhfveehfdpopibjeckcshwlfmvrjkeulhrnhzmirocbxpzcclwsbhbemvxfdasgkkwufgyqxylzifomsjjtqnjhfhfodjwsgkootsijiqyhgtamxanditxatwacbzcxnkxytctekvkxnckivlcycxlkcbymvamgumksmtcbahbffuyyypkkylzikvmrdmkwxcjxmgrhsfnhjfmidwoezwkafrreazfumjmaqubxuhsuvaobiemtimgpmekrlansfdrxifeyztcqwcrfafyaunemtpucxmamtgkhxoldwfzvqhycxfyrwmwlvqbzhhclkgpdrhhlhfdrwwethahpjtrhmadawsssnjnbtlhzrajoernddzpvscmqpppyqnualvexgtadfcvkhaycxnxneqbbambrvqerzgrokrbjnodggxkkmugtlrbxrxayjqelcnylsipgureytnosojbkcvkagbkgvaeucrfmblooggkiljyzhlcerabumftylkhefkjpbdlueepgewmhfdezjwahwjfqyqowpxpbxsudrrasxbgbjtgszevrbpnkvcnkzuaprbxemyjctbbdkvenjyhrnrweszurmgylimegzifyuiiioinbynlpmnjnygmmxpigissiisszbptltyjrlybwyraxflrkpyqjuezxjxjqvxfzlrgqsbnjtxjxcqmdqagdxqeuugnyirvydiujifqycwczirsxppntarnxjwmbkmcjjrvpmckwpggknnkuwmwnstqsreubaalkxrihpfnprvumzefzfkolteclthynkinujnnbacphzgayapuabnqkgdvvbgkkbzafcprwyhoihpftlcgqehbfotxjbsndesakbekjkvcfdblcnqrampssqmpcdjolisgqvewthorrwwmtrzvwnuotjjasgfwyzfdenaveelrpaahqxbgwowfwtqfqhomofxpmlcoxafbnzichsdggqeflcgtlaiewiptvxrlcuaihvderygfkvpyzmojzkgisebzfliuvwlspmzuofmycimigkhcdyvhtlwpbwgekfnfkjkmyayvmgwdgyvwjozbmuuyggbulwhoeurbpdejvbejlfmcfpdpfcndvdnvojsoafewbwuvebvcqvefxxgapxryrmkitlpxxcsszjboaicznkprhanmzqomteipgwonpsreeiaapobepsqptplwwornhtjktawdxcfioujhliinhtcsememxfpkzfoedjqhjwyubpmwzrantmeyqjfahljmzlbgwvudmelotfpieyyciewwitnofiefimyriiwvschyptfpotbrbwxghrlfrbtfyrqtomchonfytfariknqvowwklkrjpekgtrwflmgjerrughpteujeqokkyslctahrgshbhzarltsiodzsjygkncdosxprfxgrxeszfejttyqbfulwyepdimwnananmnmdvbvdktqwtbgkdihgxuxuzknjzwxavujhfgpcoyjfdfktjynewfflyaducqqxbyknkfodpdxcxjqvxqdlzaofikfpwwmipxercydszxiimcqoudobesbkugrixeagrbisxgveqgzcpowgcomvxodqovvpmccutimpwgrglkaqrmwgdkmqqocasmwnwuimgzwmajgwwazjgaqwefunxzemnejljqwpvqohsjkhypswvlumxhunhexinvmsjsjbooojprhdkpoqwrvbmmfqicmbtgjirbjvgcpzsfofdtpjawxhylntmkjjoeiabmpidezpqldpyenitllqbmcftrtitmgouyvasxobxqstjueaqzezskmdlzutmuvytlcxvuzmusjgbolseiuqujwcxkobmcjzgjhvspxvezfptkorzjfaeaphrgajlfdscrusjryqzhlxfnncvgtfqrnwgsdqblgwmposbmmzlzmqidoyjjuzckyhltqkbockxbryqjvjboqxwhcfwawwsilnbqlidkhfomqtogrdlcflayfypdvohskpkwkccqrfwvcxvqgtzbrwjtzycmxxrwtxebssuehvpqxzsdynzqbucgsigczfcssmcspimvzkirwzbjmnkjxbjmyzqxvvcxgufyluviibzudplpvcuglosfdhqrpiaezfogqwzpfbygsxrmhrueyjuyeijxwignwfmyugemoiamaqnxmdebvssowrnpdcumiyofpwvhtqwoykhhisvyhyuhionpvqmslxtxwcwoiihbmkecoghnpajjkuduszojftcnisgdvlkmfgidgpojohpvqlhqqorfbikhoygsieuowiifdtkkmpoprbvllorjtewjonkaeoioyqnzxscijelknxqsvcakqmqqfagnvclrbgcxqvvyguvsbpttqytuuhukdiqpisnhpdkzeshkdjclpektdeqhwdubyoqreuhlkwdqiywzixukoqgedzwixntqaruhjjkrumlhwoyakxziqnnfeyxrwbkzmtcdpjgmqtsyednghrlvynhccsvxtpikzxxvjstjcfpsqtuxwbelcwfqzyguicabmclnktngdcsqphacmibvwkrlvmpadxgtycamaeszdlkchpomwvnmutjsntwzjbuqyzubpbttjkdihzympyobhygbfkqoifhzavaqlsoiwkmruvyylqwgocpdgrenssezqxttochuvzefyzxqwtshgqcthttccyzcwqerliptjzlckzmgdxhcwzfcwgqtccdufniqhryfplsnfwzoboqwsopmshvpimqsatmdlmqvilzzfahhlierrhsjbyxikgflycvwurpfcckdxlmulfgizosbhwjoafhntdjxvzvyhcixwjzwuxcwmhlnetigtssimizztaqyufdecqvjgnkrupplswdygilhmsekoeyvvqlenvuzwxlhdrwauzkwloqhupmokhztwvassrcepktgouqtiosgszwwpnvpuwjmumgtmyrtyayoklkodyvfgqdqtbwnuygwiaczxshljazagunopworusmvkjddftcazdybdxaezoypfokmostomqgrxaetgmfocmzkkkriqzgoezcaqmqpvngectvvugxfqxdkuatyzqprsejpcklszwoflpfusvxaymrprljgilfrosbpfmwjxgwsqxknylajhuijzekicucfrabhhwjdcuftwnuexuxnmnebbmudvteombelfqpbloojxiufgdkwgthhbwhwaiyshyukcppztfmxfkkuxxicmgbzvegbylinasltnejpqpulvwuzhjflxymtfnhduyxtyrtyzoxleoedvvqzyuddwpreljyhsyyisxldyopsdqeydmmzfyqgmmahxnilnfkgicbhfhxsqnrzkpietvzzdousvosqrndgqzcucnzmjzdpxecwiripyiszidmqzzeprvgoibrllavmcuhvszwgkuqjexafxughhxlwcoutgktwxspghqcukhrnycovpyxnpjpljrphkxtftcxeouhcwalaldtzrrcteuuyxbqpsdgfucnjutisxnnpbdoqmligqbjnqgsgcgahozkqtpgheucodsgwppsijhufvtzklakzqoesbclwodrmzspwptepnwxvuyqimhvgeuhdmmjballfqyutpnpwpaxrsugyxlotpkizgzzkeofpqqhsmgvufizualhajhtcfdlakkovrhauqtdhqijasqogclujotajlfipckqzntvilxvduketvehytixztpmuzbrgfvkuwjxgpoeliqiqafhxxzqwaqkjjdfhdafqihrgatkpllzwbimfurffxaafnwkyrhtoxtzwvlcsbubzdprdszbeochwjzoenzahbgrorjgxbyrvhppfpowgscfwokhtcvseokswgdppnkazxvqwdrdicwkqzjrmhqprfnqnjsqdskrmerwzfjvzvkvduyxxvfpdrfaxqikblbysxbqjseemrfrfqasnybjaoaggvvoenzkwdycobnxlgiavkijnpsdunobjiwyaaxquxpthejauvmqjbpqlrogutbvbgezgzyvsneigbhirwamjsjesrlpvwbqkloorikedqjurdwzjugysnrnwjvicxbbuuxlwgorsuxjxfhqjayxrrnosinguotoqauxwhqmjfhnefmqeinzsowfikzwbnvmjhkgeiuktmyeobawoyfudzrrengdzaoaymghnpcqppppiplplyhntkvgrnozdcjyyxjfcftahfhhqxdoosgvkfpgtmfktwcryfvrnwmzfqqiknjdfmschljobthsdruscyiomnzjzyyqlloalzfnpukffmowjmmwazvanyaokrzvtmmizeymptggubgqpfnfsknttyplaazfqipegxcntzdtgvwcrzzgemibuksygtzmfnykwrttwhwziifrydmiuqniccqhshkaxwrwnreektnlpkushlppxvyklpvqkzbrtobtnojcmrhmvhonaztcgcyqgubovdndkmyygjeheuvjefipsrcjglzjjmiebujidvahygfrrzxycjhsohpxmqdfvoplbntqgtvdsrtceyjldxwlavfnszzjohbgcmmtrswmbguxsgxtvvxdhjaftujbgawkekgcqutzdxmqcizjuzokdenlfogbrwjvmwxavzeqdyvegmcythzmwpilspjedjimcnkvkmezazszqmndltnczppivnipxaqmmtfktstmscqvpvalchuitcfbnjudrihhktsiftwgupcixrfejtcypvwznklbrjzcfbsxfrzfdrcjpyidacthidrmeviyrgxhiqbmbslwkakodjyadsienybectjwfzfdyhkjskwrtswhwaskjeydbqznzlaskhigxpitalsjwykfjsfqidajlqjwbhhewpqujhzxxxiixplkvadilvkuemkazugmremldecjdnmzhhlxdvodvwixsqxbhmsewkyfokaohmwhejyqduygsfiuugbavzkutnyzeeukhqcmejgigtmwkhoeecncflqajgemsmguchjuuewfigxgwzzeqabpxiycttkvpyiyrpxpajgrxojvcmecuhxcncmpkjnnsckvmgmmnqlxcedncdzesqdybnaewhtrboyyteqzqcynodecbcofdelmbuvyamugggiuatlgarvvbqttqkaybufjdeddkcggudarakcyjtwgsoevftqijrzxfzindllazoqzunnewirwpkrxkslhddtwhbgrtysqbwlgpgcqkazxhginpqipvfgftbbftstbrzchimhbncyzfpvqfdcocchnmnomhvnfhjabwveynngnfqiypsfdukvuzxbjxyizlvnvletssxpszlmpuztiwbetuarvgkjpaaypklztichwdywiiorhrjwmbyniuxgrbbgqpuzboqrpyxyjqlnymnpkmhlsjumieixgcqamvvgdtqypbsfddvyxhaxesgivauozqxicnqbvgerhbwwemcexrctlhjhgvznhefrqkjqrfzwfblnzmaynhqfqtqcltxedtkbrfhtqqhfisxldiagtuhotkzbvizvxlpdenqxwxccgjobxihwfvmwactijgxjyzibsjkxkqoghlevbwntkuvxleatgkufrcedgkzdbkrabwlpxygmvdroimzoltxecttqcjibgqzmpoftdttyskmioofxbjavzqkadmagbauwgtxvolvainpubenupugbcfpmzcqtixtvbguroxxyuygelneaknstaamwllhgossddkfkkngljiefztguootxlwxceetimkhartyjbuhjamvjnsfsntguolbibktsuomibbsvohrudhkucbyvudabmgajydlsyczernptqwiokwwrovdljsvcysfyrrmyhocaarrxehbkshupkmfosxukekrzkpqobphygkacomgrvpeubaqtsljbsojiuosapryqdiakcrzvoflsesgehrjyjwgrszwndruwfvbopwlzgfyukidqigkqkqzvvevavhevcodqsltfipdnpqofevsnehqcxpzaysrszbrvlptqkzcfsivjzdjemlwuttdnuhncdaxicnpaxmvpdubuubpknwweqylfamymjmheyqqwiicnvawzoincwcbenbjaxmiccdwpfjxsvwctalwbvikizzaaqgftpdcirjdycuvbqxwalojpwdbsiznecneeuoofiyjsiaidctdogibeonykvjnofxvnkchlyzwtskdmyozppcivwdsdiadfosevpqkeurqpxxlsvysvaxxfwdtoclmelhbxezwxgybnizngoaxzextkupwccnzrxhwjynrboydzjwdruspboevoeejdztvhcsnemuduwsfyexbcqgbsgidwhycbvphrewpgppwbniffxhdxxirtdwwmgjfujuegbjaogyrxujmmiimacocgtbzoiwxqsylmswmjagfrszmggmtuxkvhcnwdcpdswhpwwykqbthsabmprvszppoxhnjpdmvwiagvubvymjfycoufoswoumolvzbdlubtevsygofqsvcnczjfasovdxrfredjgjsepioklllafwpdisodppjxndppslilqgvumamkpazxngayhpabdjpfzjfkdmpuqagdxndxgpczfvqiqmvufbzlrmqncoiheodhcebuuiopixvxzghkbcfsrlphkdvzivkswfjqrvojajcjefctdcrwrgxlueaqcafodyzwdbkcqoipcaaqaqvbmppduevenqvrtfepwqoluvmxgftysggpnauqjqqqlkuazjbbjkymzmsgriinkujphxzbyrkcomvhxxljkwsqsbjwukqmskafgdqtgwqmeevahnbgjmlvzyuogljvubqjyvrwjyfpgitexqoaufqodimlxmcipbeurowlaeghrczywtsortjepizgjuycovvhcbcfjinbtjjrblkxxuwtyredsfrzwjmqunddbmygukvtlbbrbuoescmstpppliraurprhmygqmitigyyawvbhnahmamkwhmskrlzmvaxjmkbwxvucwvinghpywwgdrznrkanhamsvrlaryodxcwtpcrvgawoewhzrkgtjjuuiraqunsehjjlsiqmanojfxfxxolskzrzlyrnytsdhiznlpwiqfscnsaczjjxiyywemkeakgrwalwfmnxmypdnuiqqzphxoyjpttkowmtvazizgbssfcdzijeepiyquzqsbrzrtttrmazzvjvmtwzukbsyllwpofgartindcnvxlepejpjwwnhcwtaqroqupmacrfqrtubsgqiagufhcwbabethnvtajbedyjgezfanwldxsceattkwstkvvfbxyadslzczlcbeoluringguhmwhxckdbwibuogtamfmkdqbbnijlzdcntljeodxkedrtoblvzjnufefsufrsaxupiabyayysqzpvpjmxbjgfsrqwukvvbllwbvtyfgircqyvaxivjoosddmzxsehnpgddqwxathxwbvalhreomtsbftejhzmhqjqhlaywffrcfrqoerbguugvxdrbzxxsunzmgmalqbdjfvczgksotlioyydqyjkmnzqvoatalwevlispnvpsarzawunkoavfkampxvynxbpgglrthfrfdwrbbnnbbmmvnmzstowuxtsawuztnspswnccamcucjjpoovdvnsbhrouiselwkozgyrxdfyahhnwpyayvfotgvybvggosgelmtippakgpqtbxehmkwbmwehquomaqpsmhggjzmjtbrwptshhiisfkojiurwdpwkvapsykrwsaugztfevnbytlwnwixdbqedawleavcmhrisopclbplqnxfutftghbompivskeihedethncfihkyujbywdgzbwovlybggqxujztwhfdvzxhuuzfbucfliwkrxjscxcxceifyyiuvxeualfzmioywlzhyqoqbefgyzsjhfbwbjfmsxdijlbmpectugedfyfgwnceqnzoqbsbazrrrxjffiajshyrhkxxnrdtarrqyobsqatcttbumhisilfgqfrkwdmdcdpeljyxijkdoozhsvsrogufgodvfyzopodpynngkqvuyzscngtxxyxqjvdfmxpnhdetprxzpwajgjjjtvcwfcxfxoukdrrujevqxlzvvgovnxmpcdkbldlnrzdzvylfvrfmlpgsublooeuxffbdjperqdxzplwzwyafsmqhhafefrkjxjgyzogciuiqscytxdlavkqmzzjmrvhhqdcgnjmznsfjguratgtfiohuqmdmxfnyklcxsaiaiiupkpptkvjffcesczcqyiobckajiqqfpctnzejgwffyqhoodfcyxvsjcoiyxkdvdbvmxcxtqqlmupxgnnthwjvdptyizdhmvendsqfohpodocjvjxhbhaollqruihnsrughgnflhqplvarpybmggsahmeofuajjezgqmyxxdvocwiecuyewpbnyqpcljehqjydvzftcojytewbwhdwylkneizbudiewtcbhudwrcxuygplojqxstovszpqgrxamxruzzzaxwmpyitokjvcvteribiyvrmdieagtmovboudcjfxerwplrphlisineyntcpvwyqjeyqtjxrpkchkhogshifujrsntmhlvuhuebetgbfgqdbxdjtmdshifvpurdnuiitbpyrqjcuuwtefvhxjcoylwbbykmyfzfxvgmukhkffccjohdaucvljicgwrsjzxzmaeixztrqtzgdjkeeiifhjmhqkiwnplkvtgikiznnafxbpougjruwhshggfjidvmlfgywyicgmzccqexyrxhdamvootnwgfvvnwyxlwtrdzgobgtrxqgvxmaeoxxtpkzhrhrjkhcyuaecosyxdzrskwghqrvwiifqwzyoutqzwtdpqeenhgxocsnqlyufrwbmkwbjpnxtgxgaiwrhenyhgxhoyrwoexnalbryyeopuyovwzoznjxyphovaipargnrukzhppiqbtmkriqoxqbdjofythyvxqnohimnnxspquscqyvstacjheopvfwujsuhzrueklehfgcyyrdbiqgebtburwrhdynfyhzakghoefbrstwterkuenndfufugiwtibfumcedybwwsysobdbghtcdwpnlkdupzzwswkzzkfkjqgqrvorpuqvxrpkthonlbvxjqoifussmtgxiyaarsneithnielmgmxjykrihvkkusquxhqkchjzymnlfwgoszcvflpocczziibrpvwsotclphncxrqgfqrzedgmkolawvwmteapzlgyqnkiqvslzdmexqmtfglycnuvvecmyydnwxertszelgpvawrfthqtwjkyeoevmdarscplheaxdvlegbhsowjucwjzxtosbyajvcvpvrhipfdiuithrpipxgyqholgnwzsjspqbfqxgbhrzvwydzebveldtqoblzktdyxvrefvigmyocjfvqqjagbikzalaasqogzxjkxllhhzqcjojqjegiypfwbrekrrcfbkttfzilclsgrvfadxgvqhrevxclglctathkqjqoyksnldfnizsqhksgrwjuiebzvlynthrmspthznqetapmhootkbtetphwyeubcuvacppyiqzeqjqldcqbtpyngyyuxdcamgmseyddinhfrfpjryvwdvnmgvtyflavmjewwusgqbsqkippfcrwxnxvadkkrgckdzzyeijwnvagqhdjhshbiqgnbeplvidkpmpsifkpypuvuqroayfswqcftytbkguxhdfzolpiqdodvkjbbiwrvnvjfyseaktgtnybzvkacodfxqdwzegxhgsrbirxjcjdwichflmyqxvrmzebuhxjrfqnnqtrhtsgnyccswugwxpfccxppowkmdyimntymkzgtcpbfpsakrqebtkdugqnjanzcbwtakacweapzkckrqeishyxgegzqsnpavwhxolirfeculnjyoekxknpsssyazngqdufpuvebnljjrpmeexchovccgfmutnkbobsjhzucmjmhxnpvefexfxrsfgemdioaoiqqifnlzjsbwdgmagxejruazxbnthtpsqjmlezqllfwfnvmjygtpcxtgsvpmmonmkiplggwzyfwfkydaxuiooxcvkkdqyqahvvqqhcbekvfcxssaxxkfbcinqzbpvxajujpsjjzemfngvopravrqqpcmdsatfiyipzvfpfkovkbbaxpincdhrnjreammhdumjwsinxjfasezucdjdxwzkjenlzsbfwakrzofyaaulhflytwksvoxtntfnlfaadhfritqpgvnvhsiqaqryqezvprvqtepuoqoqjbfhdxpgadlcmkdpmjbdllalgdadvylrcqucaeeqobqykyarztmrulsledmvstlsstagxenhuabmxexawrinycmmlbwfptsmxdayttemwpuyygygoqhtefckpekiqwmlchetjqllndgekfhcrekjfoqluomxyohywqdczkwwegfsdrdbvdkcpvpnblhizueylgmvbjuuvzwcjqgpiquzkzvutabwbxqdcshjsshyoxirednwonjmpzosfjfzoikyrllnayqthvzszykxdxjhchcjscqidaciucrlqhwuhstzghmhjfltnwafirectyeuczswyhhbcmgmxdjmpkndgagatawgyftuhztwgeeaxtsyfqbdrkjwmqocozovdyugokuugahszpjkvxrxprgawfqvynjyzmqjjemmdkyajeiukieaizdyahrghtktdsvamviqjykjreyrvcehmgrnzodsmkktqhkmizldlbxlyneoenbaxtugauwhjwlevtvqrzoukwpvntdifcpxhicxpryvwpvtbcnvkhtyuqntqewyrlwatcunpshlnshlrjwvccihrpcljawtrtkgsulzdsmwmkpdcascfngmdlsjkaqicyfngeyylswwkbvbexbppbjwudrtankopldjrhdfjpkvyjtvlytcrkslahfjqfgqtdcljtvzjoqgykcurrgniworuvrjjirisuthqyiribyhwywqmlcpsscumqtdtutulvebdyvskohpduwudiuiwymczrdaptpdopawzemaretrbycylpgnxlqgpthqxdtxvftmgicxhxffgijwkbcrjuskfceuavuxpqdhzhaovjxlxebwoeivkosclcqmkhdkmdfrobnyedmhwzmtjmmhiqbauztsddoyvcmerpqefghtvemfocrmjawlbmgofuscohnymobybxjzlykbsyfeymjjulojjszervkfgydxpgycklmxubymjsoklpcuvyfpupdgwepceokmfuoprflqwiudqvqeznfburympmfbgvfwnpmyihqjknzgxiacrfwchfdmsxzvrpiufltaczfrgnnilmexfpodmwprjbjerdluelsevbnycruieaphaekmstiszbphahbxpqvpqrlyxrhlvityhqvlccpvvzuhtpgzqujaslnuqyrqoxccydlepbukcrqveeyljiatsytkfnxcyzrqqepzuppfxogactndrpdsnzcglhqwuiuiklgkogwshtsdzlunrifswaywphviweptgyptmmhhcunbsqlwxyfvrwmmvhuofcrirfaeblhmdztyedmelveosuapvuptuxkskemyyrnfnvtduowlgmueezzxlkjrpfulcuwpodfwroxfzifoitridskjothvemnhvrtwckkjasrbempcqgfjopljwxvtjsafyiyilhtauprwbjswshtopstyfvsautjotfmtsocooknsndnnmcsmkvpornoaeuulebjtarfznvxfvnsjcbhrndzdmqsymzsnqzilqmcwnyjikwtgikxaoyozalndzwgpmlaocrewczjziyclzbmrbykrlqinpubacbuhiyibihsxzntvsdigqjjdvyjchjacnsvpwmamatztxejmgxjbwqyqgykfvakqhyxkohdxokzwsdkckwiudltwdaatlpfvlvyyqedhofnoilvcsyvfvgbwxhpqhxkdftpwqzgfjvmrikvhqyluxkjduhnultdvllnmnkmvttmqxdflkhgdfsdzlkhtrolzqflvtcnnwxqxafozhsfodiihrpizcbuymbvebupbnrmwujblthzytwafmpmswxqtxxvnqxuglpaqkvicoolrthitkfuukfnbrhlissubsczaocfsrwsqnlgbpfkukcdvcitjrorwmallohcgamvlvibzwecrpejcykoqxsopwbwhowplkjgspevkolhjpmhkbyqonnpfnpyvgjtopggmrtwvzaspvaqvabxnlgrodtvglniwrsimikmqvbduajmozjatifxneuzxwcycccnwnyfxabhdnbwuumpixzwtqzitnfzerpymqylcmbgzmjpbsmyiyzlbmijxcxllbqzfwvukyhofkwphcvaekgytatyilzseieqozupkyookoegccosqidspaqmdchmfzpvsfyrnlqttlesygrxpdrjkslimxojgpgpaitwdwqyrwffoaujwgljrxfsgzmivcvcwenejpfuzqtrecjyuefjidhazrknfkgngbeogyuekfqyfchfwufvsadtukbicqkyksnqqvkypntsutbggtcsjxsnleoyqwruwrzdxtksfpfhqpiyzfrlffmazmgjvrqhmsvjpelxhzuywetfyesudiqecofrvjiaxrvgqzmdfvjnicgagbtgeyxtlkqfjsowfvukhelscaacinhzwsguuzbrmaalesfncuktohhdnlmuomfktxvuxfaclllywkjbwxywvidwnrapfmaydfdzfndcalejkcyohklygtsvkvujbcerrofhxtlyaymspyluyxbwppbpsibopptscpkhmeavfnmmgcwevcqqempdchhjvfjjcjgtlzlutundggcsdkowpifyzejegykffwlrxiaowyqvzoyartbxkfjkryckfdrxrheesbiblmleiljehuxwjaszpexabrxkaojaivgdaumqfdffrhtkzpfxwqggphinvkamuxzgfsqwbjktsbrhakuyddytdppixckussjmjommnpcifktvoipwmmrxlgtyoiibtoitikneadegvvyingzjpnaeepknvolxijqmajioevzuokzqcmlpcizimixgimltyveyauegshvifqwpqbmvqkzabwvpxbveqbsercywhobshndrfavorbkgkuxmcdbyaaohxmvlwxauhdtbvdbipuukhklamwddmkmosctosurwarmbmvmqhyuwhlqibxbuntvbslivnqwgpkezoausptbxndutmjugvgsniwgdakhbvcjoigztcnhtabxtqcplljmalziopbhzawuovnuhwalczytxascdwtkwwkfzkitotkzqodqehpfxmbzeetnllodmcvcgnsklxkbitiqkaqzqjrbfkbzmtrbyiaoouiozsazcqcysoztetcqxbgewfojztnnqoackzjzqtiqcqxilhkrudcyghmcvqtsrxkfljpfcwjdndyqzxcbxswkescndrtoqzwmlrtkctgmgcpjpjqtwlhkwtyryznxubdfcozgfwvxmalxyxlxmupvyvbatjjkygqywpjxlzjdzsvlvwtpdyjgeixrxkcprgosdfdyibbantvalsglaaojkjjligxkasqpkmyrsyeffsqcvxxnyzwgnqzdvwplceescylgcqbvtdzljnnuyeudcdeqqlqokbrkwliulhxkoacctikejrkfbvoxeijisbfbglmopocjzuizrefrwwsblchwzfcqcziwwqvwcnuczzjagyldgbvnxhfztptvjtzafxuorepdpmqfxyubuyragvclstnbfvpzsgwpchyfonwdpcxoxlexgjhxgqoierllasbqgsrojcxcpcfrzlhvktsruprnguiisrtyvaxfdpfwkrqtvxzbodazfwazhynvytyghlaxmkpibafcpslxsoqhslqgjyxlcnxbqwtmlyqdojsmpdaityfykbywojermghyduquepqmgkwoooroointsduqhthmlyatzwzfbbykgwqbcwoaxpnoilzdppkajhylhyannwqfqwgctciuaojfckkxxzwbdmzlgxzwonumndrfihuelplnrfephlagbggebumcgzcgbutsqdhuloiwvyhcmxafirunzqzgvaafjailxxyzzsoyhutqhhclzflvojwomkbpbxjtrbpxalydfhlexxncwyehkogpyzqlzkkwgzgwcnjuyfisdohrprhwehtpcskicyfqidjvbakykwurfkdqkinkeiparmbvdwsyjyispdmpeaoryumvqeuwgpqxtbzpbivhnouqnrjastnaabvplbwjtqabmqvjwxktywnjirxennzbqnedwfzmjwlycsqzdqrwfjpkbtqugaxgafdeevwaexcfnhnqtuidddfxjokhfzkwrvpoiajxyeottylygkqwntqyozzhkxjchxmncditqzijnoutmtqcqpbfmszzezdbepdcyfgqwujoesuwjoviowycdzvkdgtybzhusdkwhxfajcbzovlzshukvqzcazwfswfqejmninnmxaorazdbtotwbgcwwgwufmabykunjrmgvparhjhwqocpdxrrufbecvmiyhiuydwyrpcudkiglbxhznnitxgasvkcswjxjkoegxgshokjbzzsriwlnbqkyhexfltmjjkoopfapcksxwpfimxwfobiqjgkjqzhqasgblinwxuvsyndjhtkeqmxfizvrlltfxvoezoxoitftcxsujhsisdcarosfrjyjqonqjvfclutdxnjfffhkhtgugcwjccxtkrffdpgluspdzzcdepvudqcacmumkkwnmlowissyoocgrggqjehwljtnceclnuizfbdkyyagsucrgxydpabjtghzbfvpplrqwipbqpbswypoamasfutrvdypbcrqswkvoyjlphnkkrinkxzawhlgsnaxywzmoombjuykrqerqldivdlxxpucpkpuhckcesqzcjiurcilytijadjaydmmxbzzazepvsryabajkswzucwmqsiggrzygeyxxpqkytilioqkkyuqaqwpkujdqushtjjyeemrkyconpaghsouwxsvrxrjcskdgtrnknvdelwgjfkuvzknnyxdwjztotkrmxaejwayrypiteyocynkvzjtamlycwrbeejucqghzhjeywyrqiahqnsakxdrpovobqmperkbmocqkvemiokjxewkcgtmotbjvhpnastsikdqyaszrcsdwzqtxnwtsodzkqxtzdreaanlsgeytkbykitnmcyfdfkghctdimilamuqkdhiubbodtqidlnfmczoxgucfljoazwoikvtgowkxwcgxtfklkrthtnjwdlqkprjdwwivdzvlrvpojjqnkdotcjbbpymkvyzktxijlfesbxunzbajqbtaiekwtzrktdscwwanijcmtznywnplppamddtioenszvtupqkpobiwhfybdwjlxzontaflsqjfwxzjtggdygspzigrfzfzsdjylkitlgogjnaalsxrcnhvmurvkehfjblrtfgqfgbanwtvwutatoaraaqcblkjsurjbrbogtijtznqqljxkriufoaxytxehqkymllrsjuyhhnepwlwmrqarjympvoesljcqtrxyxeqvepeofshghgnnxzecsqdjsgmzynmjjbzupwmaavntkbagibosoetetwmyofvhpfwpbloxfzekwzpmrzsljizezmerdxzytfchdovfxhnjxbrysumlsmjgqylcmxitocwqupeziuazbxdnmpmlvxnyinwlatvrgcnftrcfsmmucpbeaofoudmcyrpnpaginepjpgiomtmenrpfyobgrywisbjqtzoiufxryrwkvqfzzihbikviqlwqlwpjgwumielxtkzvnncfhcssqixkqhollugwrqpbijtsnxcxapzzahodobdeimpafagmgvcpkildzbbyhqvsmpuvabbocvvkvmzftdivfwwbtwrzgdshwnswpupuphglvxmxvqhoqlzqcopxqqhibrogtbnoxflowsxnuxjcnwcngkueczphhvxmdpwizczoldawzofdqhcndmhcdumleesjugetvtlndrgociseavtqkaaldtevmapamlkmfwwrngwfjrqmqdieqskhlwgwwxhqjbhciwwcnqpbztncearsptfqhzugibzbbuqkyvrqsaplbwhjhlrrhwcdeljpupkjoliibcsfiromlglctxjdchjlkhxwjdbwxqbxmqbaekpfjblvasreifqabpwaxysjaluyloblrtlefdaiieqwfryflobrtnskcbwnpkarijlizlireliognzvsiyjewyaglghqvsircrkxmykgolbefmskxpquwktpwqacxwghaegvpprtkxwrgadcjqczeeahqtrzcqmkxuunvfrzlhrysmvtkvmimmnzpwhoxrurlrvrpnjjxbftglcluipemuyztoyxyogztcoakigxmdbczpixggagvuohsssfbhmycezqcnjpayoxgdpmcudmamcfongfyzmxcilrywenntvuajyagrjelsssesjvkipurxrbfyuvjzsptrlkfcvucrkwemsvralmxlcbmlcjddudvrjbpfkdcnhrplolcbinllzeurlaaoomgavjzyuxtscqgabzluexthwwdqfwtsfdbwkecwjwunutmxjzldruhvbvnswddrmcihlrfqqodpmapniqeobbrrriiadfrfrdoalpmrnfczfcjxvwvvosyqheecmgosqpeunymsaexwtwurphioyjeyryqmodyjakjroywmtegllaarviepocayoptdnffbnudwjrlqrkqktctxkhgvckekqjevxvcqpwtotbsgyzbnyvvfuyhbumryjrninvqptkkgketytueuzjomdaoddgdudjyjhnkkfzftouvkpfznutbnyvaxgzumbvqfpzrycoduxngplhilswqlexkadordraemzgphwqztxgsokpmkenztekcsfmzzjedwguztkheyssrttwaxnzpvjooshwbkyrzheoatmkdywyfaxprnxhvloxkivhpzpyuoomhjdbzliuuqicazdmpoeywjhaenruhcllkkkcbpgvfzmigusdvappuuxtbnjwnxtdowvkqvmiinhnkzpgpebfhdwuficntxhdbyutpfzujdojipckzefxvnfblnxtxfxwhulwqanxhewrpkosdeytojxqijkkuzueuqwlqrqmbxnxojyabwjrecwtcwgymxdsvqajclsjusrzpybwuexhgrfmwqypuaxxistasfnyllgyhbdwnhbotagqcrcbulsgduxxlhuaaesyypbtlhrrritfaorpcnzoqsvoealekjabodcawcmsecyusefzwrrflrdtxybbeysaemjytxekwqfmuujluvttezusqebiqccfqraiidhetffveuqopkjlkuoefsnqyxfsighlfgdqkkgfohbbxnyqmhzxfdkoujczyqzrkfhgmyamwmceqvgvcodjmmtgafrckbkrojskxfldsndvkegritxdsnvfiiwxfvpwjvioqnbiasxsgnmacokqpiclrbdmtkqqckzejxhlhofhxdpgptqrmhsdpexvpywgjfnbeqgnvprvtfqexwagwdsqwdmsaerhkbbqxkzhiqcltvwqjqyuplayakfqqsmzmgaxcxwclwsbtiydfctzxxzqfsvbgtjsdkjmyuniyazshibbmwjseagdtaysqdebzlojovxeoytycjyhwjbalhcfjmcrtrfmlydsczdhcskqwxwekoglrracveadsrywrcdxvgdcrllfqsuxaqcdufunoudxlxrsuwicnckttgsfmeueqxtuuxouoteabbjjcgvsechdqxhytteeqjnhozaqcrdemjfzbyjyvnryzafzrevroyuoyvcokuarapninjophycsungelzmwqqdjebcnqgghsdjtklrqauhqenukjjwqhpfobcmuqawnysyyvciytbofqwsyoghantuxvukvzwyuhatpxxtypcnphsjopjcriceaviedzztxkngfngwaucbvyerlczsaotqiqidvtjzfwlxqyydsynqhoxzxbievzwvkeklrltsmcdhnpqgxuojjnpckrahtuenmrwfzazdxjkzdanakcxijvlsvyymbetfsuagwhuhkzrimujsgcmtypidguezhphwoutwzcqecnfvyjhqcxutzrvysckmmuanbmttxepwxewzhyligbsznvyywprfaofmhxvuyekfkqzdxvhqpzxcbrgpenmwikkilcqkyewubaryrqesiljvharqggfotyqbvxhmxemptboyqazdnrkdyzughypwmtdtnrwgqoijfnwohdhxhcgdnypyhgccwgoydjvucoqyvdwesqhiipyhsbfnogoorwawvjyuewlfkazfscjrptqbwdecjobbamaoudabelowmtuglpyemklyujguqtpqyvcrsdeermcexdcmjefeawchqvlxptmumpknzhqfquhbcwonzttocykqjuibvwnbrqwivffxusecizkxdughtshoaobhqucapxkplvrvngmcxncpuzswlzxvdnqocqjiqxuqaslsaxjeopmelkwcidbklsurftcyzxjxwtnkwptytfcasgqdmgbhtihutxduglzrgksujnqekzprsqcylcevlyuwdcpkeujaqmjblksrtogbcdzuhtdnxnvkaqlqfpkwkgudosmklrbflsmchgyzjpougoukzinmarixslkmhkqfljyjdktltkweklvjisjjhuxwseocmpixklmjybxaaymvjwsbxgpmtjasdjibgwmxplctoejntfiyvmdohyztzxjnlcvrhpgwkjwbzybwhluwjpyxqxyopkuebwzbtpaenmlwnvfrnyuqbaaypyxkgqwdabfnpxylnmrdssepxcuconhoxdrodzojicjnoafhwibrvtvdenfzedccznecjmwefpnjspyuiatrwksfnuieyyadggfsyjicnrtpnvbojukbavdkucilpzqxwqjeqkcujgakdcqpgobypxvcwbeaqtwymsfktkdcravulicczdltmekhqyclwwglbvfrivlfazrwjcixcacxzkfztyioywhshfbxavucuibvdzbhmalwbwbqutktvxinuoqfghsupwdfuyfvjcyzubzsdxyslwalaifuxfwhxaufiuroiylhgjoontjzsoxbuczcaengcodfqfydbzdsemseildblbexyeaxxmlqzreevdvibtgdhjvwsosjejdtovzokqqotdgzbfrytpcvoscwylritavxpbkhagxgfisbnbgqjgttllmdevdtemafpoyzymrcwjzsmclplqpacicssfeqccfoasfdgbolhfvdkhjaydbxgeipgpxukytfbieofdrusxzcdwpuanbpzniuyjdlvknrcschkpgbtyzoazdzqsjyblfybpkngmmhxrbpiqdxsthgouxvqwoqyssyyjghdghnsjrnftwejoegvokkwzyfluohjxzbzzltunjfmmpvtrzhegbigakgkvdgeuqnuqizfmafnyvfqialgzbnsoklipxkuigfdzacxahvtjpfdaejksdbsrvubhphxoshlykjolzxbtrmqhicgenvcguzbkcgwrrxlriqmaemyjoerslkpjewvphgsidmfgysdlkcfawbbubxxbwxwaogwbiajyqhseorhsofjcwoifpuzsmmdzheuzhzqftqribuaqcwnubblsdmoedbnaxpzaiqfjfvkpgeiwazgufridmjezxdecilncnwpptaawioxvoguoiwvmosfjbkpuxhvnzwixceemzcrbnkejloxmmdnspixzpmgodmgxppvoymxuqhuzgznlczcomgtsjwsikbdwchridnifgejuvthabpntbhqvpgiebqvsgncxhqmgoiitmpjxzgrtrihnsgygjeimteezafhuaaufoiiasgcnjojumpqnyoozszdcuemergxgcfmtxczjjxsqilivnaxvlzbvidudymcjudhtosiaiqwgivcszmadqioxzxnkuixdfmdcujnfkfyezpdqiveuhupwdbwfggtchaykqccdcdnpdsaihmhsgyedcceexssolwqssizwmrdubsmvddhvkhsukeomlgzduvzkbkoibsdondgcnmrddysegroemkeujjofwnhjtmwrgpvwxlcvetiwcavelylgghjcwhbayluvjndfoivtpyfswcrsdcwdlsncwbgescjrtwicpyzvgamyicjzsjrhfwswrfuwwbezppnpoleerlcwhsklpnckkrauyjibbbjnikbgerhfneojbrzoqqcfrwenizlhyxmydlpdocwcvnhqvyewzpozffxpucpxeysdflnzqlfnhwnjfybwoyojvtcdmunzcttnphduphykqewcfdhkcwtdjwtpunuwikzjvzbbwppjevzeehffcliapawvxfloygbmwfmdqbhckkfitmvhvszmaakripmchutvcvrffbzpoywyxrokpnhqmfdmxnyhjkoaiebepiimnhzschexehjrllhegfihgqhbqssxpssnesaoounrpmdubgsfjrarwytxntevlbpmftfelgxyvxxhedybhmndqdkvxpjakvkxyweqelbyepmdmvpnuwdqtxnpsqjezlatqlkctnibexajexswbonqmgaqhrvkbjsfzrnunqyxavpnmylsizpsbqgfulmhvxqjukiqsxyrshzkgfumpersvmjrczpwgcipwogdeuuvhvidfdqapewzcvbcmqfpmkqcudpfnpksfdtykbwmxspebedocmydqjvusdqtufxvswjdkpildkxqrbfopwrcztzcefwhaqgrocflultpchcijavkiayvxtfcocfoqgabeiwpyktxbwejbaxodpxljlwsjqnodjjfasicokjppqfxieenjoliiywvfboioekuigfpuwpslfshmzpfdqrfusqwndoabctgcchrhhxdloolbtlyowalxzsdvkfzdponixtbxouragcqzsnwdnumskewhhuxjpvdjtrrzgkiosbqcrcnacweqcjbnassomfsvujuyrbsjdvzxvkiveaesgueamvqveorhdezlhgwqfhvyrajrcvlonvqunnngvcjrrrnmdpdmsdmhdwzxdpbbunwtyqgzzmvhmwiberfoxnwrilldkglstfenkmyyioeyvosfifgjcevbghezoeknbbfbyibyhqjwkgrhigbqdbfkzugfatqpbjabsuufqlftrbeajibefaoqpopsgcqjmhfdyabtnfcyikjvbgtjnczhoalclpqkfdaxlhdmplzbuflbyvfzimrxqeuazpmqjgehpsnyzqqrfrnrbwrzzwgrnxaslgupjropdcnwdlmisozfqtzzkphhoydazvwsxamxwongyompquzcwohuagtimjhlwnqhnrlrpcwyflxfkltojrjaeqiwnjgzpqyqvkpqvdgqgrjjymibkyswyaqaqappbqdzijkiwxugwwyvqwxfreheftlpjopycywmhksilinrkbpgmrsmvqfcurmowluzomoygqdqhozsveqrtbazhzllgikbmmzdxbjmxhgxlaadjomcievxehtfomcurypvgicawcbdzqtpmsplowngnzaudssaxqlpqrkzegqmgvxeblwcufduiiamxstmekudjuqhfwtjyouszyycghiwamvnbniqdetnxwcledqflhizjaiqqvowkalijcwedluzcdlrcebqpwrfmezgpgimdtrgqvgkzzxtpunfdzatbwrzqzpxjizoeojbswxfkcfcnggxfuuucpwthgyckuxyuuwmwbpfdbcxwgqqaqdepadjlcapyqusxwftetokeskbfvaqzggugmqlldgztylxczitykiylfqshscdtomgedtzvvexcprnppcvtfpvtzurokcniknsqjwcumndewawrmzuhijppvgjuuzjibijvpyhvxhwpmxwttjtgjowdxnurdxsbyzphplgscoscyzpwahbbtlxuefldhbvsbxrlieyuoroyegbfnlcohflgevrnrtnywhujofievxnjoiskhbyivvyptnxkfmqtensnqionwvxlmhcqzabgbvbkgqqforoqznurzebuzpxfnphhtipjcxezsljrdvlpxyygirihkscrwjrtxzkmmnrfohnwyazfdhianoucnewyeycpjhwxrjryevvuviotdmatzvidhftobkfznnjzxqvarbhllfmbfxbxbhrhpycejspuwbxtnteddydswdxhpcdkqmuwwhngfaswoxquuzfxjybxetvvfhqpvyvrfgmuyixwuotnicvyykddhocfkyukouiqhwllmvrvnagxsgxohaalzvxpjsvuilzqawbtltjlndqrxlitqgiauutgpxismrlrkpksdmzsvlxgbaexizbxymxsmnsjqubfiyrpjqnrlxrfkrrplbbcltlqigpkztplpuvevvmebgvupdnuunswuavdstcjhhdqifutjpikbrwzwmmwkhpdcflnmritkjwlzvagxgympbhxrbsxvaprmxllfvzfbrpympvtoxkfkgidhhrfrybvezxeifprkaiyomrdubasdomihpecgmmgejwsqwvouodqevexlsllovwegvvrdbapidrhistnpzeohrwdywpcmlfzkmcxykukghphejhtfdrfvzykajtawegghhvcbqytgphtbuwmkzwvfktenjtmedxtblgrgwdxjmuqrtyvqoptsoelouaiqpfapmsykeqnsktevdozdbgzstojgafxvzcobxvpqkrueeztpwwyvlzvrssoyxvypndltbqvsroavpxyzeaecqnlpcrxrtkjhkfxhifbmdrlzgkrzzepgtuqcvftbogghurlvcklcepmcupcmbnhhkbxdvmovqrwvdsrqgsdxfrzhfucpttolskorhuuaaaqmusqgndbuygobcraphyqjmevvnhclvrwwpvidvpdzopzchwmzgowsqcauwrffaylfkhmsurxrvqulztpygfzpqzhqkdbgrdwmkkryxftjpqncbzvqkcuapkojzdogvkklzclmzjigodqjewqfgqwckdiyteacqxalwypshgjqwiqdvkhbxtrlwdnzhlexthcyohnrhnifiwrcrbhgedpgkdzsmizrawuhxfxfiqlavyqlitgeawriawehjhxelehdtwmvaempchpasvlmbvprgkllaefgzwahpkhagtwqbpufzcnrgpgjhadqvlrdixynquueaevzdgvhvvemnhykwppnqtlhlvcousbwfhlgpcacdysjtvwzkniyidjfaxqwhhbpaimwecqlhtikcjfnlvybsfsntukanazzbrnedgjofvzmxsasiqkeelzysboknbiwfovjatfozbcnmgzoqawuqeiuavoyjvjxxupberohdeffawaohysnxqzqukgovjyhvmcjcuefobdwavlbtvvovtnbqboyqdipsexbbngaiejxdqwineutwllxgglrpgfxlusmhxuueiszlblkbioutzieazqmqbesirwxokyaomkpobxkexcjinukjlazcynhylmhjdqzjqejibhaampnknocbyqkrdqlibixsixtjfefodsftgodivdllekbqgtykiltzvpdmdmxjphyzbtdigcisucarrbrqoybkviawpasofnlfwuhxcqbwnkgwiqbaydjixuwatnrpstgnmxkpqahxefvapbqlrpjqsouyyjjwzkvamrepvrxfxpcsztshfdoohpwxrknhaynczxvcjperudqdgsbqjmvdjbavperxmxhadkmtbhrzucwijivhvynsmbubohqsxwrgwyckgktyghniydhfnjrthnmotbdkdmlbopokaufwdzmxdfufsusawpayeyagwbszvnlidzwzmgpgbjovpdpiasetmlvbcsxazwhyiknsujdhryamznbpctialcdsnrascorcfeopamgxwktoftcrkjthparbudnxhznapvlmqzbubnrhjdqkddhpvlfjcscxkrnljyptrwxpgjbjxyqmaegqkprfcfrswpceukhmpmvuveoeobukxmuojexonhdvwttxwbjsvtqyedilbiffnlkqxskybptbuqvooxkmtygtvxmhursisahiubfdlfguubzagkwskilouaalbtufjwlwgbayikmxwmlmepnawnudvzbcecogqubtfiweqfahtkeyopbzjyxytyjmcxpiypjmxrgqijgasnvztdlmhqxnvpexxltrexdezntkxbafufxawdevzjjbcsskdnqfrgekbudxsybgohmozxedqsfhbjaharjgaeimoxscbsszonklgmojildfavfxhgeykhbhhuqhzzuiliuhjdilmvgkmuuadxzmuctjypvpglvwrdumymgsmwecynujxdstgnjoztucqzzkyssnnivyibztuygiyrhlnmxlisfrocanlqigrknfkttrnzwcljrfxwpwfvihgluxkcbgwejnudqtkbueupeyeybsbkhviucilceecnuqbwzykiidqwptgurefoyfhjkhhiujvepqscgokqhhajesthfyswglpyrqofhonpsruqmjwivekirmtdlfhsuuzsgdwbictdyalswwccouajyaljfgpsavhthoyiesgyhpwnkrgslavztzkpbuggpcbxfntubgmrlipcfqyqljardklnaibctezbtksdwpjmddotnpdtzgjsjbglbvmndxecjizfubzzzaezwaiagliyprdwgwkosdumdclyaestbmisjoevisbtigcsncvynkiftveqpruuxzwsnwybphhefcmxsaftwkkoxbttyoatogcftpjebegmgqvkdnmykfwmlueczkvcdzlfyhssdaoqldywnxaxmhlmflvxnpuohdicsgosnjwlnqrewylnjxuqhtxunawkxacpsonyupddkvcjfhwweqvdtidqnwrororhkwhwdpvjtragxaotkcdvhskemhibdoityyxkgzzohqvaxlercvofzngdlahlykfuktvvwbjleqplmuwwwikwzggebdeahwlocroxdrufndmxnxjhzzsqnocygxjihtghoffynqctibnlvpcysebxwrrrggwgqmrkvwkwuidhgxuqmoqttwmdgdkhirgzztmgwwqmonjrexymlbnxgpxafanxpgzwtgjboqoeleoegwpvhhtobjvtbwdwaniuqwpzsywbisxtxoabjuxgnvlsojoarlhkilopaaqbkbyvazocvxveyuuicalgceleildjhhczdbdobcjjnumqrpemnmgghaidsyvwglqwpaxciusbywgdznvimjtjxemttjxicndatplejumszucxohkrvzuzbkbdcnotvmxpaofrpfjszjouiiclfofpprxuvjmwkndvsoubmptmmdnvsslrofuxtrwlgjyqfklbuctexcsmrausuzcudyshvpppemctxtcqbjowwgdortakllugyrqihoyjdurazprahoznisgxmghtrsftavoitpfoomjfzyzxoqvekzngohccurtkwaszznbnppooojaltvujkyukyocgfadzaevjrknppwloujbgplmzxipzxiirlvsrefarolgpkjugatzxsikdhqfllqwblivymadslapqslurpzbbqyefsvoubywwhterzwmbuyrdovmwzrzoveydyefvjxswmvhxroqnrhaneeujqeoyvbdeizygdibioxcvllsnvogoaqjjgvzoqsexhlbdbxlryvtceivzqcesnnfqmrqvwaonvyinfotdirotuztshsdkstgjnlkeflcrxdmutzvqmjkpioxyikppozfninlkithnbiehgmpnjcgomeebxlarjdhjbybbsrhqonztqcctlpsxpcjcuorcuynukhzvxybcnlwglysahufgstinzklwxcnjjdffuwydqholgfhwmzbundqacyspgsnvtvuofdmdcnymvbqilnpenagbztcuvtgyppkejqklzeqbdezbepodercpkplybzomkpdtfsgjtqqsyetwbscdvwfjzsqqusvrorejlfszzuuqzdvfujgsgxbaqqezhgkbxmeimnbbbvqtwvqaeqeneohrextbvvyapgdmkvivzjxfewdmzmdjmbrhbykjgpcjhiclxfhbtugqrrtkeirxdfjslzggpofkobbnydjjkdcczeyjruclxpvdqknmofkqcefcxrzmpmzbytijvgpxwekcdrgjlbzsqvyxkcybdcvywfmlquinwfgyycctonuofqwqecdwkrdankqjbdhslvxfazyxgcdpnqcowlklntekahuuofeydxkzprrkpjwodfglksfdibevqqhtcjdptcbwcxjoijlpyirjemgcdxlkqvtakgudnvurpcpsbkborovppeihpejvhcjofotsjeaiaszvgonnifclwobszhfqotamhemacldpyvesjrqpymgccyjumiojxzmmibsbhtyqwzujajjceswlrlogibuvlkvudqrhrzatpbvxlvkmslbsffjlanzglqjrlxaajixizhpdmbnlzcjuiivhrilgrtrpfidgekqvcavtndwfloqyuwyebptwygpeheboewzicbwzpsrksevcnepmswcuzbmqltlszwoxqxsavadmmndkzmkraiigppoocsnaguzaarenihepxbkrcgaghucbmpepebjwqmaknmubgifczfvzrfpvyuzcplohakqgivnxkwyxzgdcrdmzsmphhejfcvebvrndwwhueknyemfemqsyfykcwcudeqabthnhqhymokbuclvuxuzipvsbrzrvyqutcmqqdsbynnpreqykhjmcocbf", + "zzzkpcekddjufofbatmqcnznrjzukzmisorayxovhojvrkqncdyzxilladpvrqbkrfdoodykjazbyyyliqrgqwwjyuiddlzlgjgelzmacqbwvostpqhbcrhjbnczesjavyquprlnuaikomnhjbwzxpipiiotckbvrzrbxuerrqjhuxpcordrntzytzlbaagveylkrrjxszkyukvupifdqkgxcegifcdfpxvfwehtkkkfjuafldqkcvhnyyuecbfitwtkcavelkwskngnhdvuetgjzgfcnyolszagjldencrzmlttiqmlssnkypbqneotcikoxhuoxmymurzjvcfshovzfvbujnuxkjvtqhberonmxaiywjctkulvqiyfdzmauhtwqqljdcscsomjivwpikkffurxgblqqiheeotivcerklfenpmpgxkmrtqfatsuwiiofpuvwtqholvycjmljygsfenntrvhdhzfpxfpnfnetsfwvpntgpyfcuxfzlwqgxpvojtrncdpctnceuvngthpnpstcprevuomwwdxdunefncoglgfxwlynsemcppgckphvtvsbshhjbnndewmkxiqpyfhabyjauksvjsohkxvkixhzifhatzmtalztnanhgkdqernhfebgvmruvqyqnzcoyanmbqkwfgnkfrbifgodrbttdrhzvhfnpugiksuxbkcdhpcuqdqeskwxrtpxeeqcynbsyjnfrduljhyskbksgvxpjwrmstjshyjiyrxkehbhgjyyniwdyohqsvvtaxccmwfpuwxziveufkjkuxixrdjilethwxlqjibokpaustuhxfwdymdtxqslgvenwbdnndmgoworpzveputczzjmekeejjbvdiamjywzleuwbpqyaylhxykztizprvijfcabbmukbgebdxhamfmceasllqycnjzlabpwzllwychmdibjjmdpqlsmpkrgllxzujcwugrjhcwejubveejgictdtlptvygqnfziqsjijejadvcqwpgbpgaquqevjsgdsdfzbomnsumwulhdwgwwtjdufylyxpodpntleymyzgyeqggbwkrwkcjqzvvzdljemdyrutiyxkwwrzadlwavwuscrwrmhpbebzlopmyumdecxkasryqkrbvaealcinvkvtckczytnmzuqauqcbqjqinwlgwafzywasqymatxbwiyveuallqphzkfbxhkkqcnmcojjlvkqbluwtfisqegbnfdftrvctrpquaojylbjlerbqythpddjlddbcerjdbvefrieflpgenuddctkqevdiklucrqcgzpndpijciskjqnqpknuozpzxyetaclhvoigrlsqqyoxqzamkafaqnqoozlyelndtsjwubxzmuutabfluyfapuweddjkysscgljzsjpdbnvlexokvmvdpmjqdsbtnjipuajvbslkavgzdxrqxhwunxmpdjqignctpcgonolfjtmtwsxzzgcjoaqhomhvibhfmqztbknpydauteuxwwkydezvjcwhjbguchwytuhgtlvbnnkkjevsmymcztapegbzbemzkfnehskkaxbjaonbqqsppjvgfggqcidwztyfsmgaxsbrznwmbwgjmrsjrgsdamihtclrbyuaxffzhpqsiyptguloflsgtvbyghpetlqttydbzamczkkipawdvvbffwgxnfhfvybmmagkryhheumjdbjqqentthbfaxhvhovadevbldodmxtuivelawmdbefpokvslsgqtzdrxtuatsjxdggpyxhgppkqeichjrnewtqspzpjnnlnkhbcrmzfuczxfyegipwjviqvjvbnfvpjjwyztdvcqbfiiaraoqxfuagcpfwixmyltzdsicmsnjjapzxkyfaubdyjkykmvvvrtrjsqrganvutsoemdiwltmeypeojiqzulyjofrcrceifpyqcjsoukpvrvnhomwkjuapqwdlgthnbjkfzgdsglsgwqansopzyznsiijcmmidqrtewwwiqqbpufzthdwlwchtylmfjqwfcelzqxtvzvkgizkmdpjrnzttlnututtsxnpxhruftxzpchjdfxabhbixhbeeozzhvziiukrtmlckxeatutarkgdbcvsyaeltaoxkvyymfgoondpokmjecmjcaucyxpwidqlncncpcpozymqfnombginxaalhihgolbttzupooomsshwicumasqicqptihevclihzfrreijragnyyaxyaohinmntdirtbswncyhzjkgbkzkrjmymgmlmqblzivagutwfweiznjdrukpbejxhyftahddnuthudzikgdbhmlchhazqvvdbmtwkzsvyaovgqtjnziaysqappzxywfjwmsgikyahrpnsfyaqblzfyfonegnceqpxasrqvklaoxbaldotvddypyseabhfmibimpokclyboewkhnaqirclkcjqsmxapqonhtenzqksrkmmrpelaifjvhetdjcldovatfukvgvvwmxhbaqrivlwochqxygsrgkuvngvnydvhcnbtkaskdbqntezdntnkpssyqawxtixlskpdpuwtbzqfvjfykueaeyhnxdiqdyckmrusjtyrcyuznxzudhuwweahmtymtcddscxjozsiplqphdkynxuvxwltzgezsdtmgtwvgykkjlbjxssrqsybvflujuyjudqbicndokpkiqxunlvuykylnlasikbaxoxlblusczwqrtreqgsqwkfmmtfrkuhrkmwbsjllyatymucpwecnpnavdtjxrzhmqzusrvrshnohlptrrdzqunojxcovsvllrapgewemuatfzyfybbstftldetyfljlhjwrngkfyuvuadylyxdiqcoqbqoiaqxgujbzostijpvbakozwgllywaqdsfttfdtkwtiurhhhzljnwcpezpqkyoeskyttdvtvxxbbhkhyktmhtosshqyiaypajmcyuzgqdfseomzojoeuxqphjfcudezyuxeuwykmqvyrljhzozpltrjewsrtgomwixdnqrztsidoajddketzcworfytswkwkczeqlqdmimshmrzwbfxworgvkjovqtquwfsyouvgiipxaalqmxpkpmnfwqcfjqveguzetciautzvssgemxwjrqpyaztatumwboxgdymeqkhikdlraugdloptumvrecybqcgfpjunfesfozuglkumgdnnoepsjxvtboaweektbowchrejrnvflrrplxfkjczzhnlymspgusonsfoxujbjpyettwmiiwjecvwfsvgrnwijjkpadrzcemlxosxdayocfywzkhhzbinbzlistdyydfspdezwluqfgxbnwzzjapxvmtcoxwaariladlpctiwqqjnlouvapeaswesqwxpdbyqfrdbxrxiacvhyzkklrhhkoonvyyceogfylvvqsanbnpdvhaqvykxexnwqeqmansyhjqpmsmokhodnifqkrdrwzgtxiolktqoosbocnejamrycuckfimpkiesuqmczazhexkpggghtyplgtyszfvvyoqobqbvsdewncaoodtuewlpsirdkwsollezejtmxkowzllrcqgzdngedusdxpsggxmimrjvomxojolwoywgcrqzutojcgxxnqnjpvpjeptvoaajmttbrnvhjfjojlzurokqeavvgdhrcunjxllfidvdxkbxotojagnqgvijdhqlyrxipfstqixruizvdrgrzleodqosyfzktqoozwtwdvoqguvgiuosskefcvxltvxvimfpiljmnletdpnjzmdrgkqeorwovzmedpqyijovkspltmlmzbjtuzqdbtmqwghpmsetvkmbntqwxywkykjnjbagoerkmkyzyhligqbksacftfllxusmhzyiuqjrvzmlcpcsjjsxrzdcloaxqyjkdgxltsgrhptvgyztouljkjgjymnanmovszfarirrfydjpjnertgzqtwortyhxagkagcsrfknkoxuxmijeoopjfndbxunseyuxrogtijxgwrxkbsdliwarjammfiutzhlzyzgsbbmtmzfrevulwvjdyyjyfipqdtflzbaxzvvhhxbgszqrwgyretanggrtzzdgolgrdybrmwhnicbiehypuzzqkausjwlcwacczswarjqqzghbyqcwcukjvcucyglkikogcksdhkrmryibxrvspigtzygeblksojtyzfaqkgiwmotbsdokletehtecapjmskoabofowfvrvngiiqlpeepyhhecawyabmmhaekpjvxiqkdaueelnvdvngkvkphvxpexctsqraopaxlrexqgifcawybisyscpjlskozdpqpvhphwhyjzttqusynjcyapgdvtyezcqqhrfasopevgahblidspwfnzbamhcmxgsuctzdevjxjhynjpmwsplukbeerdnzuzyylqvxbfemgjqgskodxqtrfkgyxhccpywmpcxbiotgeregckgxmnvctkbwphcvmoivzdcfcbiohpadokqnkevltznkvmcsayhiqxgsdswtmvnagwurdwfzvzuxfwugvvelmqyyuqgrgvdxoyykdjqdrzbstkxwupgmnnrdmxqaadhexrthazpclksgzryzkgtnryrnxnmncbeeqmpdpvxkqczdobrammkznyoumvgptiqkofabgcxzfziywlfpgwywwhhjtplarxwdhvibdokvhlhcrsboxuinebevcpisqpbhrzxvidvfmfpmzfqdxyymxdpkqnrnrgenijcxrjdqsnrcvogdowsykcanuvkewdbybitsviatrxnzgobaodhermtnexyddvcckafymdorkxkaqzarogdsanlulwkcfbgsfulraxkeycwcnumlstmpxkplwxtbyoknxvwzoqhexgixjphzfawwyywgpjyxdurqflhwukwyemouoxwxvetfzcqkzoezkstobgucmghcmlkplajkpecmxsqhnoenrmlfsagiqcaxwjcpvpozlseovwiwnrhzvegjlgmznbhdckvfcqmacjmpyvubqhdurusdkxeqnbderojofhfsckcyvfemlgftjsvlrfcxaypafjkqmzlqyhvficxqpfvbglieufjhjlspdxknolkliqdudecsepbiehvgrfafbanqbszzhjlcspgpptsaqbodigkeupleclryklrntnvgjqtsstasaaiikpczokqqzpesuaatednqpabqkdsweithrrqasmjzvehztuloqgktpcihhvcfgiduffliqrhtwycowoajgpvxfldnupnoyoswtcmrsivetuajvcknwaeuhhapozdtlfzvfcqyceovlvjvulvuyzeyfdtmzfeqhpizxspqnjcqvwevnfhyvlbudjskajwcuoqrwzknihauxkvblvehnkjmpioypipfjljqsrmorwaeystlldmdlfwtsflexbqlryscyhedsfdvmumyzpcktvitdrlectdhvknsphojqqnfcrwdzmgajmsslwisjvxqdqkaqcmbanftngypptwtpflmlaekjgbbpigaogaqwxadorwsjsarcnewmpmzqanysldwcstdlljicydnifhornrajvqlymhzbzlexhhovbodaqvcjbzdkqyouywcdbjvdxtaacqnrwpvoutnkebpfvwsynxedkbjxvwelvencdiyakggxafpaifqhcxwsqvmjnzbkwoxasubbvrccekkogegvmbgcwxqxbnzbhmvagcefyrgxsmzyyupeefrkcgcjmhdgzssxljmxebvbijvkltdnysqxqzwzybuxdjeqfxsdtnbfzaighbmiwgzqhaurtvfuacmhlmxnijtwyeovqsqdtjhpxcukramcimixvbtkaumboidqtzskzrgkmkezztmerzaijsfghyjwqxbwfkvzmklkasxugkezruzyeqmmagvkcrvfykxeotziyurjbwaydtjgjcksbbbwebmqkiebalgtvxsglsfiymhtwsmiddcjdealkvexpquwnvliryporjuiuunsliqhfyrvtfggsqkzvqlbqafshyrkldriynkempvvlzvoynkfxacovceubfbyoqmxfidntimkcxyftmkqjrwqpmvrkpxabwshbiukyozurzokzkkbwyvddqhtuxzywcjotunjnzartlvqtfbkmqyoarcbkfoxgqhxudnmveslxnlffsmxguxyskwbjibcmrhpgzwtbuwsyhwjovtapkpqzunhjynzbbtmqjadvohudmkejcyqkpzpjcvelalegpjuehspjzalcpcyjsvvnnjcvxliflkzuqgtqomwvjxelcssjdhmwwxwkbycymufcepdagzwuejawhpjxogrvpaysdhtbhceknfilltkbeqflqsfkmgwnenrulriysvmnuaqgitukryahvpweezsnbfcxpciuztkzprhsxhdmntghhxsqoyjbpmyvwutafreoozuvspfljkbcouirfqjjfwwdlkxshfhgazczqrrcdpluaymhpaeypheyjmnmjuacjvtrxqkjqtgyjcpfsvzckgttrepwreorjndwytpauqpggfbkziqiqdpmbbftwkvjvrltmxetdflebptohrvtuafyfytcunqkltmnymqxckahivzybdxsgwdyqrsttujivzujyhmtucapawieavnedhniuyxtmhbbxgzavwqpsemvrthljiwnsmyrvywzhmusszjulacgfrqzxqcsdumndcjbgpggtemipmpmllunhgzzubyqeoizfugvczxutuqasugufojtyzxxdcujysavespgxvrsgzdomgnjaspxzmdnithykfcnvbomtmqpwlnbfpztelpjvxsiwryoerbmntqaoqvxkfnuyldxrsgdkijcclajzkxlocijrzweuoynknsnapazndcfmmqwnbjxcutjrbbknlqqtppjjmgidthelzedxbzmtjwkesppxjygmxvugdgoftwyemxvdcroosuiykbbbkdcorjjiluppxecffiqscziskdzqvfteskrxeimbarvywzxhmpmmwzndvnomcutzaywmtzrecbxvpqcquynoqksrzvjjjpaakqlpjloauthsjyjdgutiokxdvfhhbbonsykndhqkmpdivwtshapamlldwozwymxfxopgsperrpktzkbbmrgdcbopmfbrwycztzcpwtemooptfkqihoajyerlogyzgvvobpmnqmuffhfjnctiwsnvcycnxwncinitkswcaktqqthpywpqtcjmzthfewsbfyetjrjbkktdqrowzpvarqnjpcasojzbzvcwoxesycenkgqkeofoeingnbzbwzgmrlnqrrwlxyunznogigliltmkfpcbehlchuyedimycyxycrryoldlpipgiwnyorfkranqjiyezgqfzdtujsftiwmzaenurrqfgrolwsqgbkzxltplaiawcnyszyjxlwqlcakwvwtvmrlphkmefsuabnvgrbhazvuqcnsyxiaaszkrzabivnyxpygnnjrwpiyutymbnwivgzckwpslfnmbnxoznxqgghjuexvverjzualcnxcwnxsnukoiknwqmkfyezhwvzjrqhjrqmqfkwslibwypcxfkptxjspnkmfgakwjlknedvuggxerrwtzmrcjgwafmuhtpafeynzrwijsgqobfgimzjoffhknmeimgcvebzszllyxxtstfodhmvjecidwlmqmktajpupbvlsjnfhmiwtybqbownnmgfdlmbpwfyhqvttezglwkbohtpumprmukqshcxquhuhccitrwngxbxwtmvxhfmdmdhtvcalufvgnhuhixsxpurfbyftqgfpggkitzpuyqogfubspvpinguggfropbplkqwijqvsodzqgyymsrfklwjrnjpuvtptcezjledwuhutdhgrliuqsyxpxvlrrixqyomlitrnokzugebeyxxbufbsjtpemjfwbelvaoskkrncjypfxezzvqtoshhaxmvqjvtfldhdejxojluppdfgylwdchhtmdpwxqybcfsfcisblvpklbllcafsgzlcbsporxspfhmmykvpoboveildpzhoiacfzufptdagsoxiibqqpmmtrbemgcenrncksfdnyhxcraqzjuenkymuhksnlnrwyybsxzepmepstihamwqgykeucpinznrcwixhtyvupgdpyemoormwbqmbmmcsgnpiahqyrqhjoavgzmcjzhyryctlvuahsjcncjhpquotiufrjjrdfzshidrorwqnpmtajupycdelvhxbzqjlslquxhammftzuxfcceicypgpywmxyfhohnyxenpguzfwmnccibgyqlfhazxwcjlldjaborbwbezyqqriqtoqbattrmxortrazedjrbsfiogyknhmozekzwpulngujclaceopmxuwgbxputkzjwisnmhcjpiltlbbbepgsuaplnwbhytswyplwlewktkwmsxuumkivnpstujeeyabciurdycpgetzaenwmbulhmqgjcliiwdzkztdtjhjbcklvuqmknpcofgtwxvavdubfkvcyakibzveaykfshtvnqnmgjjpfotbzoaaytstfgkomcqjzdnkxperxecfsiwoxcfabsqwzkybkrbrfuvhlyugmvipejgyfshgqioivnmualtbvygtmwlawwrfmnpzdxecdpvwejjlkmoscqijmcekqpfuwvgykouogqtbomjiutelckiegkbmyyreoetlexdnzmnvioyhrmwpbyeeertlpcdavwxkezrcqntmaiphdyztfvsshudyfpgjipktckubvqjfdbwoqjlanfdxmzewsrbmxgzbhmmojlqgdqhvquauqbyrtcjhkkzilgkouslbqdwzpqkvmhwbwogyluxberqzfgbcimjgbficupyroblqkedajjmiweqyimuiodobvowwivbwfllidvgdzdqwkehjnrjzmokixiazvcipokaujufnexichqpiajfgooooxxqdsmajcyvycditxdofmikarsxpwkjuigjiwfeyucvobyuauucsihdljvrrxtmltrgcyrteowywzksyvhzoinuaufzjtxzogbejxqcwknfovpybdsghzoublhoirpgtcvcshlpmupfjjbclqpslmdjvgpmqoihtbkuqfhdmvxujhdhdzuvbqczkqkymildmkivovxskjbijshhzcgwbnhcgoubgqorsqupjguclnubhzjhqzgasikdospfieujlnhcygmahypmmgvatfxfqoznxupxxtopzewrqgzqvdtilnxcwjwybkwpgddrljgwgcrgkalydyqcsvbfdgzgxqdxpiouhscnhjukaszsmgotpocupoqqpaqdsqmqxlupgvrpvjcwnueeqeifthkyryolkhojpccuuukvctfflwiybstmvtzebvbljrvwbykjigsorgvzuvpttpxcpeqseemywqgzmfppgtknwkervpngevihlyapxrmrgusfwubrntgnxkedgsjgserdsqdvqtxazinzlquhjnxpglyjouivdmskfqnjaujvgbqdnpgtmwvuhnledtdjcgscfaxovbmorzeommdoyvgriknlmcehtajhdzbvdrygkakblsrsvooimylyqdbhzaepgaaaaojrelmgwjmpyqusfjqfqzunehtoeukvgyazrchyelqeehivrlduricaboybjafykoxcjqewinjumuebjzjvaudzddivnvnjhooqafyffrbhoxrtrfuzbhkmgotcolfqwufhrimkixagptsayreygcrodkyozgqovolbonbjjxyhdwjujgeguogvvumetkvrwvonsgamidcrkirzrmxtslpxaofdaotbdqujlchfgywyuyqqjkihrvaxlwjdbqdnwvzywzgzwfhommkfshqygiblfqjgtysfmlylyqmqlprhwgtuezdmygqgbcjbckphphgyzpnzfsxlihqsgpvlzeoghnacgjsrljyjdxcqpbqrxifpkuwhwzmfrndikxdcdqcrzgaonftftehvrhgqcrkummghuvreuvxefybbqtetklhrxjqiplqtujldxzcqzrlyrmsvujrdlzrdpjtndsqlixsqmskhbcugwwwhvdfkwyvnuvlrckigbhdzlxtrkbhhkijokrzfmlxpkdnjatngrjadfyattfhxkzvlmxjigzylbtcchfdiygpiltijxcykrwyvgofjhzdzokhbbdwpfkocyvlxvwhjdatgvugaslxotoxojlrxeetwfokapbgpjrbhnfsuxnrokbxjljrjylnirjueffewddjigylvglyyiszrnzzwwwxjjocrouezovasgzstrcjqziyzwfqxivffhatunqbdckmaifvtiwwtdqqkrmbjmfougytlrwrtbjvkwdijlyoaiiboyuzfdscqkxzsjtpgepztxvhxszuafonpgpockeydypblhkfztoukeyxqxnknobqhocsuhxflskglpnwjxldffqbychwvszauvpmyzwpyjzdxscehqxglttbrlikhvjlzgsqvgctgcanxqjvgekluttfbdmtnwciiafchutdixkguaehlrweixhpstvtqinawyrxmdyxfvgwpngvtooumnxxhvytkirbzludlwhoqpwmmqfjcfbypqqbtyqpmocrosotmfqcrypouchmjpixspcvqbbilowiuwrflectipswqtqmdipmxiyagzsfiaqowwvohiheonkgtvqxekhkvwyovnfuqbmmexsomvhwyhhluaxtzkhrhwxhxwylveelpksqvvthkaeggexlswufygnixjkjcaugojquujrhueydgufcdlisrnyxzwddovklfgjwenxuyndytgcnsaygybxtrkkszeafmtcgfkrruokjxsxipuhjpcukuxhkzeyunbsfqthwhikpktmvkpccrvwvpkclyhovonifxwkopwacwcyspzoujkqraqlqvijstufloppphrofuxnapfinqlwrjfgdqkwxzthenochjrbvfnosjjzemjcodjcujnefxuribeixrbxwnzwbmjkgnqllfvjmocsiieyaaedfstmubjxvtzyjsgptcdnrqhtitcggxrgicpcnhklrtkledocprfihzsskpszpjtenrugagyizthmfqvpvrnondsdremqffpgnfxmgzkbdzgxdhirsvzvdietqjxyyizefyezdipiavuzeskhmosmzatidusovxyatqvmpudrqlcqemhqinnwbwancqikxllwnfjdqgzeuabepsipdsvwllqllmarlhbkaqywdpjyifrridrhtbccyqfdaqolrjxcrudumezdfgcsujfverngdpbcgedwcoiacbbnvrpcgxeqkamxvoprdkigcedpmkmcgqjzamlujxlxhhujeofeqjvbahiyvzjiukhrxiftrpeehmjrrcuaosrlmsxbpranyqdygneoftniuhtmkchkyioxtlfjgkdihtznwqbnigchepshgmzoqvkvxxgcfqaxxntdtfdgvlgzfezljflnbjhvsqamyyzouyfrbwepjgfcoadefcemikktnljrvjolffdnvchiltqkybbsgsgozvfbibrzmylrqgdwqsbbcedinhivzqnsdkcsgedcafkohovusddvuqyrqazzxmjytzhrfjkgbeeewucovilrwajflwfjxxjcrgtakotvhdhzpznnyaabczkbcbkhulcbxnwleccekqodkrergpuszbmfjtqpguxdsjwmhgactmzefowoubthfgbayioqfrmznfprsdouuytuhzihpykowykorrghyigdreottjidhonuqmszagceoxokgeqqtbgrskkstcrxjmhwqleoqdrbzbqapvsvynxlfrzzjroxczvoezvazodsvwjlmcumodvecqwdxbahmrbzjdoatciaojjxqkmlksipoakmibncyyydgmtgbrzgyjblokvvybqzyftclyurauueedwrfyiouxyudhxrdxlvobgpmebqbwyqqsicvsyscteeggtmgqlksxaehfwfbuuugugyiutpekllvdlfgkdxfxbeayhceuwebwggulsnyhxebyvbbmifvjnbfbimnkhyzeflrdhhsqhjfqqtrxfbpmipgnxoexfajabnolsnecxgjyjycvzirzehjdadeudpozlkdrgnoyipwsthzjfgespcnuvvtntvcbmnlbzzylizzgkiwcavcwcgjluszzqgaqeenysrczqnjoerivngbjornyquuvtrusoqdrceybfbkwusllsxwychdpjbqjbtirpgfrcdtqsriubzctwpshctjgbimltpbyjfcnogecuzqpfywvyhqafdnjphyjlwuirpcfisrddyajyurakbnhhhadukzffxhziqznrzbuletzkpqefckjqpuusnrdjryxnchdbrunggadskqcxovyuhbiocohkhogfmfykwkodohdzsevlitbvnlvjclbzakvbjhrxyncrggwrrdriblyarphniutpvuppghoosnpenotpsbhueomxcefzrciyxacmrklhvwpbkjwwyyzuoiyghreskjtfyorglfeznykqtfxqpbrendgyfsyfcvgomusecqaimgrtohuagmmoenztvvfffhjetwykslgnngymigthcswwtutpqpsrfhdeilmdvadjlqfaufxucwfoxuckvzsxrcqapywpvaurxrqibaeqkwaaoniletlkfnamzjyatwligxnzhpebafvbolftjhqaqiwesnudmnzicmcxytrqkvfyezewecitozsfstdklflrbhpskfuhgwihxolotvenfxiuqszghinvttqlabntpunseefvehfodgfgencqvmuuuesgdjwlecsepreccbezxfnnxzxndxoqxijrprkdhhhaluzmgpgikiajnxoajyoueklnbivsqgqsfebcewazzneruumirrmnevmpqfnlkvscdepnkugzmcuzpuqxcfvpdyorgdgnggzewtivlxahtgbnqjpaplbxejptmtdqtxgfkkppbaicubgijxrbylqncsbngpvudgoatgoujlpzlrnzodptzievvqchyukyqizyymqyexwlsftrfhylaulblnbxtimezjmvyonihmojhrxqlyemyrvrdmymnkqcsqdyjavjbnntrykmgdivxdxcgepvsobebsdnuewxvasayeayesgboeahdqlmscxeveolyhcvrnvcxzcnqaqalljmfcgyvjwhobuwdjzsntngsspcsyzkcpwqzhjeubodskicuhaduasflkofxhoawfpvmqwmiqjyaqcadhlvavxnxoxphikjpxhqygtelolzrsspptjcblkxsdgenpiprjrjghwjyrmmmuebgrczslbuolkgrcxupkqagtznmtbwlpygczneazcmnuahwzcnbrrwpujiwoolfbkgxjzynqarxkgvekvvnbncpqggpmxwdtfvdmbwzmzzwosbmzphvulwlnfdzyhrbjxskxqdunspwjgpovuwrrtgjuxoqpfxzgjuukcxpqkarxzbqrjhvcfcgxjrldmbljqcsdeawooazpyjtxytblkqzndasughjehnftwblkskhpgmeubjaftvdgjdyizpxyxcnvpugtvkiarjwmfpcuubftontqtkqdgloepjitfcjdcdtiazapvombgetnshryuwlgiwimsimbicasncpabpjdtrwnmbpksxgwyjbcbraxrksjfmvsjuytyfslnvhjmhwohkxnljvdybwbjowuprdnnuzcutklrzntqhgiyqfuluyveswznbcctbafvdddmufjneyswdqqliowqjifdnhjjtdxtdqiyhjiwrvljxxskbylgfnjrygjaahxcavronjpwbwlqnbccrfajsseydpjrghzoeiflqsmcioydxzugveghobydmpejafexyjxnhzpalywldaetpkkgecfcyvsczdthtsxvjvjeolzdgboytsxydnawtssynfqohdyqapfusomwgzxfnlkocvazgqryusyhzufvinzhzheapglgkwllvkjqhszsevniudijfaezckzeyenwlfnailczhlryparoapgkvmtacoqhtohqmztywktqfbigwsozonhhdnuupogsespfqbvebatxoavjjuneenbiwfqzzagdglwhsfgmlcbhraprqpdxqquecxuqkubtjcgcpsgsrinqtaipnlawtfulabrwqzuuuwzkysmkwpmljtlnxbzuksckykujhgrmhpoaqyyyqfmvqixrpavudfsqbydbanbykynhjoqjtypjgolneytkvwccyflxzecvtjlxncrmeqevforhdimiicqbrhrslpspvreaskyltbbmksnfbrzgjxgtasuoqulkoncciirigiolgaprjfnjrayfrtcskoaobniaxybukuhpqjlccrpvcxfogwcjckexwpurzoyacjcqafjwaieiejesmtzbxxihkbclrcdizgmahlqhbvpwfpvxzxfkzoymrksclnocxbrysuykufukmbprqfggwvjwruadnhgbdfpvwebnsqdjgfyhpsegwggecezlrajysfleuzdokqjyarycphqaiimltqpgqswabploimbxdfdffxtjuqaapxapskcxfbxffptipshsuaevwnnvzcxbflkawdpyiscmfnmpghfuqxfhqghwlynxlqhfveehfdpopibjeckcshwlfmvrjkeulhrnhzmirocbxpzcclwsbhbemvxfdasgkkwufgyqxylzifomsjjtqnjhfhfodjwsgkootsijiqyhgtamxanditxatwacbzcxnkxytctekvkxnckivlcycxlkcbymvamgumksmtcbahbffuyyypkkylzikvmrdmkwxcjxmgrhsfnhjfmidwoezwkafrreazfumjmaqubxuhsuvaobiemtimgpmekrlansfdrxifeyztcqwcrfafyaunemtpucxmamtgkhxoldwfzvqhycxfyrwmwlvqbzhhclkgpdrhhlhfdrwwethahpjtrhmadawsssnjnbtlhzrajoernddzpvscmqpppyqnualvexgtadfcvkhaycxnxneqbbambrvqerzgrokrbjnodggxkkmugtlrbxrxayjqelcnylsipgureytnosojbkcvkagbkgvaeucrfmblooggkiljyzhlcerabumftylkhefkjpbdlueepgewmhfdezjwahwjfqyqowpxpbxsudrrasxbgbjtgszevrbpnkvcnkzuaprbxemyjctbbdkvenjyhrnrweszurmgylimegzifyuiiioinbynlpmnjnygmmxpigissiisszbptltyjrlybwyraxflrkpyqjuezxjxjqvxfzlrgqsbnjtxjxcqmdqagdxqeuugnyirvydiujifqycwczirsxppntarnxjwmbkmcjjrvpmckwpggknnkuwmwnstqsreubaalkxrihpfnprvumzefzfkolteclthynkinujnnbacphzgayapuabnqkgdvvbgkkbzafcprwyhoihpftlcgqehbfotxjbsndesakbekjkvcfdblcnqrampssqmpcdjolisgqvewthorrwwmtrzvwnuotjjasgfwyzfdenaveelrpaahqxbgwowfwtqfqhomofxpmlcoxafbnzichsdggqeflcgtlaiewiptvxrlcuaihvderygfkvpyzmojzkgisebzfliuvwlspmzuofmycimigkhcdyvhtlwpbwgekfnfkjkmyayvmgwdgyvwjozbmuuyggbulwhoeurbpdejvbejlfmcfpdpfcndvdnvojsoafewbwuvebvcqvefxxgapxryrmkitlpxxcsszjboaicznkprhanmzqomteipgwonpsreeiaapobepsqptplwwornhtjktawdxcfioujhliinhtcsememxfpkzfoedjqhjwyubpmwzrantmeyqjfahljmzlbgwvudmelotfpieyyciewwitnofiefimyriiwvschyptfpotbrbwxghrlfrbtfyrqtomchonfytfariknqvowwklkrjpekgtrwflmgjerrughpteujeqokkyslctahrgshbhzarltsiodzsjygkncdosxprfxgrxeszfejttyqbfulwyepdimwnananmnmdvbvdktqwtbgkdihgxuxuzknjzwxavujhfgpcoyjfdfktjynewfflyaducqqxbyknkfodpdxcxjqvxqdlzaofikfpwwmipxercydszxiimcqoudobesbkugrixeagrbisxgveqgzcpowgcomvxodqovvpmccutimpwgrglkaqrmwgdkmqqocasmwnwuimgzwmajgwwazjgaqwefunxzemnejljqwpvqohsjkhypswvlumxhunhexinvmsjsjbooojprhdkpoqwrvbmmfqicmbtgjirbjvgcpzsfofdtpjawxhylntmkjjoeiabmpidezpqldpyenitllqbmcftrtitmgouyvasxobxqstjueaqzezskmdlzutmuvytlcxvuzmusjgbolseiuqujwcxkobmcjzgjhvspxvezfptkorzjfaeaphrgajlfdscrusjryqzhlxfnncvgtfqrnwgsdqblgwmposbmmzlzmqidoyjjuzckyhltqkbockxbryqjvjboqxwhcfwawwsilnbqlidkhfomqtogrdlcflayfypdvohskpkwkccqrfwvcxvqgtzbrwjtzycmxxrwtxebssuehvpqxzsdynzqbucgsigczfcssmcspimvzkirwzbjmnkjxbjmyzqxvvcxgufyluviibzudplpvcuglosfdhqrpiaezfogqwzpfbygsxrmhrueyjuyeijxwignwfmyugemoiamaqnxmdebvssowrnpdcumiyofpwvhtqwoykhhisvyhyuhionpvqmslxtxwcwoiihbmkecoghnpajjkuduszojftcnisgdvlkmfgidgpojohpvqlhqqorfbikhoygsieuowiifdtkkmpoprbvllorjtewjonkaeoioyqnzxscijelknxqsvcakqmqqfagnvclrbgcxqvvyguvsbpttqytuuhukdiqpisnhpdkzeshkdjclpektdeqhwdubyoqreuhlkwdqiywzixukoqgedzwixntqaruhjjkrumlhwoyakxziqnnfeyxrwbkzmtcdpjgmqtsyednghrlvynhccsvxtpikzxxvjstjcfpsqtuxwbelcwfqzyguicabmclnktngdcsqphacmibvwkrlvmpadxgtycamaeszdlkchpomwvnmutjsntwzjbuqyzubpbttjkdihzympyobhygbfkqoifhzavaqlsoiwkmruvyylqwgocpdgrenssezqxttochuvzefyzxqwtshgqcthttccyzcwqerliptjzlckzmgdxhcwzfcwgqtccdufniqhryfplsnfwzoboqwsopmshvpimqsatmdlmqvilzzfahhlierrhsjbyxikgflycvwurpfcckdxlmulfgizosbhwjoafhntdjxvzvyhcixwjzwuxcwmhlnetigtssimizztaqyufdecqvjgnkrupplswdygilhmsekoeyvvqlenvuzwxlhdrwauzkwloqhupmokhztwvassrcepktgouqtiosgszwwpnvpuwjmumgtmyrtyayoklkodyvfgqdqtbwnuygwiaczxshljazagunopworusmvkjddftcazdybdxaezoypfokmostomqgrxaetgmfocmzkkkriqzgoezcaqmqpvngectvvugxfqxdkuatyzqprsejpcklszwoflpfusvxaymrprljgilfrosbpfmwjxgwsqxknylajhuijzekicucfrabhhwjdcuftwnuexuxnmnebbmudvteombelfqpbloojxiufgdkwgthhbwhwaiyshyukcppztfmxfkkuxxicmgbzvegbylinasltnejpqpulvwuzhjflxymtfnhduyxtyrtyzoxleoedvvqzyuddwpreljyhsyyisxldyopsdqeydmmzfyqgmmahxnilnfkgicbhfhxsqnrzkpietvzzdousvosqrndgqzcucnzmjzdpxecwiripyiszidmqzzeprvgoibrllavmcuhvszwgkuqjexafxughhxlwcoutgktwxspghqcukhrnycovpyxnpjpljrphkxtftcxeouhcwalaldtzrrcteuuyxbqpsdgfucnjutisxnnpbdoqmligqbjnqgsgcgahozkqtpgheucodsgwppsijhufvtzklakzqoesbclwodrmzspwptepnwxvuyqimhvgeuhdmmjballfqyutpnpwpaxrsugyxlotpkizgzzkeofpqqhsmgvufizualhajhtcfdlakkovrhauqtdhqijasqogclujotajlfipckqzntvilxvduketvehytixztpmuzbrgfvkuwjxgpoeliqiqafhxxzqwaqkjjdfhdafqihrgatkpllzwbimfurffxaafnwkyrhtoxtzwvlcsbubzdprdszbeochwjzoenzahbgrorjgxbyrvhppfpowgscfwokhtcvseokswgdppnkazxvqwdrdicwkqzjrmhqprfnqnjsqdskrmerwzfjvzvkvduyxxvfpdrfaxqikblbysxbqjseemrfrfqasnybjaoaggvvoenzkwdycobnxlgiavkijnpsdunobjiwyaaxquxpthejauvmqjbpqlrogutbvbgezgzyvsneigbhirwamjsjesrlpvwbqkloorikedqjurdwzjugysnrnwjvicxbbuuxlwgorsuxjxfhqjayxrrnosinguotoqauxwhqmjfhnefmqeinzsowfikzwbnvmjhkgeiuktmyeobawoyfudzrrengdzaoaymghnpcqppppiplplyhntkvgrnozdcjyyxjfcftahfhhqxdoosgvkfpgtmfktwcryfvrnwmzfqqiknjdfmschljobthsdruscyiomnzjzyyqlloalzfnpukffmowjmmwazvanyaokrzvtmmizeymptggubgqpfnfsknttyplaazfqipegxcntzdtgvwcrzzgemibuksygtzmfnykwrttwhwziifrydmiuqniccqhshkaxwrwnreektnlpkushlppxvyklpvqkzbrtobtnojcmrhmvhonaztcgcyqgubovdndkmyygjeheuvjefipsrcjglzjjmiebujidvahygfrrzxycjhsohpxmqdfvoplbntqgtvdsrtceyjldxwlavfnszzjohbgcmmtrswmbguxsgxtvvxdhjaftujbgawkekgcqutzdxmqcizjuzokdenlfogbrwjvmwxavzeqdyvegmcythzmwpilspjedjimcnkvkmezazszqmndltnczppivnipxaqmmtfktstmscqvpvalchuitcfbnjudrihhktsiftwgupcixrfejtcypvwznklbrjzcfbsxfrzfdrcjpyidacthidrmeviyrgxhiqbmbslwkakodjyadsienybectjwfzfdyhkjskwrtswhwaskjeydbqznzlaskhigxpitalsjwykfjsfqidajlqjwbhhewpqujhzxxxiixplkvadilvkuemkazugmremldecjdnmzhhlxdvodvwixsqxbhmsewkyfokaohmwhejyqduygsfiuugbavzkutnyzeeukhqcmejgigtmwkhoeecncflqajgemsmguchjuuewfigxgwzzeqabpxiycttkvpyiyrpxpajgrxojvcmecuhxcncmpkjnnsckvmgmmnqlxcedncdzesqdybnaewhtrboyyteqzqcynodecbcofdelmbuvyamugggiuatlgarvvbqttqkaybufjdeddkcggudarakcyjtwgsoevftqijrzxfzindllazoqzunnewirwpkrxkslhddtwhbgrtysqbwlgpgcqkazxhginpqipvfgftbbftstbrzchimhbncyzfpvqfdcocchnmnomhvnfhjabwveynngnfqiypsfdukvuzxbjxyizlvnvletssxpszlmpuztiwbetuarvgkjpaaypklztichwdywiiorhrjwmbyniuxgrbbgqpuzboqrpyxyjqlnymnpkmhlsjumieixgcqamvvgdtqypbsfddvyxhaxesgivauozqxicnqbvgerhbwwemcexrctlhjhgvznhefrqkjqrfzwfblnzmaynhqfqtqcltxedtkbrfhtqqhfisxldiagtuhotkzbvizvxlpdenqxwxccgjobxihwfvmwactijgxjyzibsjkxkqoghlevbwntkuvxleatgkufrcedgkzdbkrabwlpxygmvdroimzoltxecttqcjibgqzmpoftdttyskmioofxbjavzqkadmagbauwgtxvolvainpubenupugbcfpmzcqtixtvbguroxxyuygelneaknstaamwllhgossddkfkkngljiefztguootxlwxceetimkhartyjbuhjamvjnsfsntguolbibktsuomibbsvohrudhkucbyvudabmgajydlsyczernptqwiokwwrovdljsvcysfyrrmyhocaarrxehbkshupkmfosxukekrzkpqobphygkacomgrvpeubaqtsljbsojiuosapryqdiakcrzvoflsesgehrjyjwgrszwndruwfvbopwlzgfyukidqigkqkqzvvevavhevcodqsltfipdnpqofevsnehqcxpzaysrszbrvlptqkzcfsivjzdjemlwuttdnuhncdaxicnpaxmvpdubuubpknwweqylfamymjmheyqqwiicnvawzoincwcbenbjaxmiccdwpfjxsvwctalwbvikizzaaqgftpdcirjdycuvbqxwalojpwdbsiznecneeuoofiyjsiaidctdogibeonykvjnofxvnkchlyzwtskdmyozppcivwdsdiadfosevpqkeurqpxxlsvysvaxxfwdtoclmelhbxezwxgybnizngoaxzextkupwccnzrxhwjynrboydzjwdruspboevoeejdztvhcsnemuduwsfyexbcqgbsgidwhycbvphrewpgppwbniffxhdxxirtdwwmgjfujuegbjaogyrxujmmiimacocgtbzoiwxqsylmswmjagfrszmggmtuxkvhcnwdcpdswhpwwykqbthsabmprvszppoxhnjpdmvwiagvubvymjfycoufoswoumolvzbdlubtevsygofqsvcnczjfasovdxrfredjgjsepioklllafwpdisodppjxndppslilqgvumamkpazxngayhpabdjpfzjfkdmpuqagdxndxgpczfvqiqmvufbzlrmqncoiheodhcebuuiopixvxzghkbcfsrlphkdvzivkswfjqrvojajcjefctdcrwrgxlueaqcafodyzwdbkcqoipcaaqaqvbmppduevenqvrtfepwqoluvmxgftysggpnauqjqqqlkuazjbbjkymzmsgriinkujphxzbyrkcomvhxxljkwsqsbjwukqmskafgdqtgwqmeevahnbgjmlvzyuogljvubqjyvrwjyfpgitexqoaufqodimlxmcipbeurowlaeghrczywtsortjepizgjuycovvhcbcfjinbtjjrblkxxuwtyredsfrzwjmqunddbmygukvtlbbrbuoescmstpppliraurprhmygqmitigyyawvbhnahmamkwhmskrlzmvaxjmkbwxvucwvinghpywwgdrznrkanhamsvrlaryodxcwtpcrvgawoewhzrkgtjjuuiraqunsehjjlsiqmanojfxfxxolskzrzlyrnytsdhiznlpwiqfscnsaczjjxiyywemkeakgrwalwfmnxmypdnuiqqzphxoyjpttkowmtvazizgbssfcdzijeepiyquzqsbrzrtttrmazzvjvmtwzukbsyllwpofgartindcnvxlepejpjwwnhcwtaqroqupmacrfqrtubsgqiagufhcwbabethnvtajbedyjgezfanwldxsceattkwstkvvfbxyadslzczlcbeoluringguhmwhxckdbwibuogtamfmkdqbbnijlzdcntljeodxkedrtoblvzjnufefsufrsaxupiabyayysqzpvpjmxbjgfsrqwukvvbllwbvtyfgircqyvaxivjoosddmzxsehnpgddqwxathxwbvalhreomtsbftejhzmhqjqhlaywffrcfrqoerbguugvxdrbzxxsunzmgmalqbdjfvczgksotlioyydqyjkmnzqvoatalwevlispnvpsarzawunkoavfkampxvynxbpgglrthfrfdwrbbnnbbmmvnmzstowuxtsawuztnspswnccamcucjjpoovdvnsbhrouiselwkozgyrxdfyahhnwpyayvfotgvybvggosgelmtippakgpqtbxehmkwbmwehquomaqpsmhggjzmjtbrwptshhiisfkojiurwdpwkvapsykrwsaugztfevnbytlwnwixdbqedawleavcmhrisopclbplqnxfutftghbompivskeihedethncfihkyujbywdgzbwovlybggqxujztwhfdvzxhuuzfbucfliwkrxjscxcxceifyyiuvxeualfzmioywlzhyqoqbefgyzsjhfbwbjfmsxdijlbmpectugedfyfgwnceqnzoqbsbazrrrxjffiajshyrhkxxnrdtarrqyobsqatcttbumhisilfgqfrkwdmdcdpeljyxijkdoozhsvsrogufgodvfyzopodpynngkqvuyzscngtxxyxqjvdfmxpnhdetprxzpwajgjjjtvcwfcxfxoukdrrujevqxlzvvgovnxmpcdkbldlnrzdzvylfvrfmlpgsublooeuxffbdjperqdxzplwzwyafsmqhhafefrkjxjgyzogciuiqscytxdlavkqmzzjmrvhhqdcgnjmznsfjguratgtfiohuqmdmxfnyklcxsaiaiiupkpptkvjffcesczcqyiobckajiqqfpctnzejgwffyqhoodfcyxvsjcoiyxkdvdbvmxcxtqqlmupxgnnthwjvdptyizdhmvendsqfohpodocjvjxhbhaollqruihnsrughgnflhqplvarpybmggsahmeofuajjezgqmyxxdvocwiecuyewpbnyqpcljehqjydvzftcojytewbwhdwylkneizbudiewtcbhudwrcxuygplojqxstovszpqgrxamxruzzzaxwmpyitokjvcvteribiyvrmdieagtmovboudcjfxerwplrphlisineyntcpvwyqjeyqtjxrpkchkhogshifujrsntmhlvuhuebetgbfgqdbxdjtmdshifvpurdnuiitbpyrqjcuuwtefvhxjcoylwbbykmyfzfxvgmukhkffccjohdaucvljicgwrsjzxzmaeixztrqtzgdjkeeiifhjmhqkiwnplkvtgikiznnafxbpougjruwhshggfjidvmlfgywyicgmzccqexyrxhdamvootnwgfvvnwyxlwtrdzgobgtrxqgvxmaeoxxtpkzhrhrjkhcyuaecosyxdzrskwghqrvwiifqwzyoutqzwtdpqeenhgxocsnqlyufrwbmkwbjpnxtgxgaiwrhenyhgxhoyrwoexnalbryyeopuyovwzoznjxyphovaipargnrukzhppiqbtmkriqoxqbdjofythyvxqnohimnnxspquscqyvstacjheopvfwujsuhzrueklehfgcyyrdbiqgebtburwrhdynfyhzakghoefbrstwterkuenndfufugiwtibfumcedybwwsysobdbghtcdwpnlkdupzzwswkzzkfkjqgqrvorpuqvxrpkthonlbvxjqoifussmtgxiyaarsneithnielmgmxjykrihvkkusquxhqkchjzymnlfwgoszcvflpocczziibrpvwsotclphncxrqgfqrzedgmkolawvwmteapzlgyqnkiqvslzdmexqmtfglycnuvvecmyydnwxertszelgpvawrfthqtwjkyeoevmdarscplheaxdvlegbhsowjucwjzxtosbyajvcvpvrhipfdiuithrpipxgyqholgnwzsjspqbfqxgbhrzvwydzebveldtqoblzktdyxvrefvigmyocjfvqqjagbikzalaasqogzxjkxllhhzqcjojqjegiypfwbrekrrcfbkttfzilclsgrvfadxgvqhrevxclglctathkqjqoyksnldfnizsqhksgrwjuiebzvlynthrmspthznqetapmhootkbtetphwyeubcuvacppyiqzeqjqldcqbtpyngyyuxdcamgmseyddinhfrfpjryvwdvnmgvtyflavmjewwusgqbsqkippfcrwxnxvadkkrgckdzzyeijwnvagqhdjhshbiqgnbeplvidkpmpsifkpypuvuqroayfswqcftytbkguxhdfzolpiqdodvkjbbiwrvnvjfyseaktgtnybzvkacodfxqdwzegxhgsrbirxjcjdwichflmyqxvrmzebuhxjrfqnnqtrhtsgnyccswugwxpfccxppowkmdyimntymkzgtcpbfpsakrqebtkdugqnjanzcbwtakacweapzkckrqeishyxgegzqsnpavwhxolirfeculnjyoekxknpsssyazngqdufpuvebnljjrpmeexchovccgfmutnkbobsjhzucmjmhxnpvefexfxrsfgemdioaoiqqifnlzjsbwdgmagxejruazxbnthtpsqjmlezqllfwfnvmjygtpcxtgsvpmmonmkiplggwzyfwfkydaxuiooxcvkkdqyqahvvqqhcbekvfcxssaxxkfbcinqzbpvxajujpsjjzemfngvopravrqqpcmdsatfiyipzvfpfkovkbbaxpincdhrnjreammhdumjwsinxjfasezucdjdxwzkjenlzsbfwakrzofyaaulhflytwksvoxtntfnlfaadhfritqpgvnvhsiqaqryqezvprvqtepuoqoqjbfhdxpgadlcmkdpmjbdllalgdadvylrcqucaeeqobqykyarztmrulsledmvstlsstagxenhuabmxexawrinycmmlbwfptsmxdayttemwpuyygygoqhtefckpekiqwmlchetjqllndgekfhcrekjfoqluomxyohywqdczkwwegfsdrdbvdkcpvpnblhizueylgmvbjuuvzwcjqgpiquzkzvutabwbxqdcshjsshyoxirednwonjmpzosfjfzoikyrllnayqthvzszykxdxjhchcjscqidaciucrlqhwuhstzghmhjfltnwafirectyeuczswyhhbcmgmxdjmpkndgagatawgyftuhztwgeeaxtsyfqbdrkjwmqocozovdyugokuugahszpjkvxrxprgawfqvynjyzmqjjemmdkyajeiukieaizdyahrghtktdsvamviqjykjreyrvcehmgrnzodsmkktqhkmizldlbxlyneoenbaxtugauwhjwlevtvqrzoukwpvntdifcpxhicxpryvwpvtbcnvkhtyuqntqewyrlwatcunpshlnshlrjwvccihrpcljawtrtkgsulzdsmwmkpdcascfngmdlsjkaqicyfngeyylswwkbvbexbppbjwudrtankopldjrhdfjpkvyjtvlytcrkslahfjqfgqtdcljtvzjoqgykcurrgniworuvrjjirisuthqyiribyhwywqmlcpsscumqtdtutulvebdyvskohpduwudiuiwymczrdaptpdopawzemaretrbycylpgnxlqgpthqxdtxvftmgicxhxffgijwkbcrjuskfceuavuxpqdhzhaovjxlxebwoeivkosclcqmkhdkmdfrobnyedmhwzmtjmmhiqbauztsddoyvcmerpqefghtvemfocrmjawlbmgofuscohnymobybxjzlykbsyfeymjjulojjszervkfgydxpgycklmxubymjsoklpcuvyfpupdgwepceokmfuoprflqwiudqvqeznfburympmfbgvfwnpmyihqjknzgxiacrfwchfdmsxzvrpiufltaczfrgnnilmexfpodmwprjbjerdluelsevbnycruieaphaekmstiszbphahbxpqvpqrlyxrhlvityhqvlccpvvzuhtpgzqujaslnuqyrqoxccydlepbukcrqveeyljiatsytkfnxcyzrqqepzuppfxogactndrpdsnzcglhqwuiuiklgkogwshtsdzlunrifswaywphviweptgyptmmhhcunbsqlwxyfvrwmmvhuofcrirfaeblhmdztyedmelveosuapvuptuxkskemyyrnfnvtduowlgmueezzxlkjrpfulcuwpodfwroxfzifoitridskjothvemnhvrtwckkjasrbempcqgfjopljwxvtjsafyiyilhtauprwbjswshtopstyfvsautjotfmtsocooknsndnnmcsmkvpornoaeuulebjtarfznvxfvnsjcbhrndzdmqsymzsnqzilqmcwnyjikwtgikxaoyozalndzwgpmlaocrewczjziyclzbmrbykrlqinpubacbuhiyibihsxzntvsdigqjjdvyjchjacnsvpwmamatztxejmgxjbwqyqgykfvakqhyxkohdxokzwsdkckwiudltwdaatlpfvlvyyqedhofnoilvcsyvfvgbwxhpqhxkdftpwqzgfjvmrikvhqyluxkjduhnultdvllnmnkmvttmqxdflkhgdfsdzlkhtrolzqflvtcnnwxqxafozhsfodiihrpizcbuymbvebupbnrmwujblthzytwafmpmswxqtxxvnqxuglpaqkvicoolrthitkfuukfnbrhlissubsczaocfsrwsqnlgbpfkukcdvcitjrorwmallohcgamvlvibzwecrpejcykoqxsopwbwhowplkjgspevkolhjpmhkbyqonnpfnpyvgjtopggmrtwvzaspvaqvabxnlgrodtvglniwrsimikmqvbduajmozjatifxneuzxwcycccnwnyfxabhdnbwuumpixzwtqzitnfzerpymqylcmbgzmjpbsmyiyzlbmijxcxllbqzfwvukyhofkwphcvaekgytatyilzseieqozupkyookoegccosqidspaqmdchmfzpvsfyrnlqttlesygrxpdrjkslimxojgpgpaitwdwqyrwffoaujwgljrxfsgzmivcvcwenejpfuzqtrecjyuefjidhazrknfkgngbeogyuekfqyfchfwufvsadtukbicqkyksnqqvkypntsutbggtcsjxsnleoyqwruwrzdxtksfpfhqpiyzfrlffmazmgjvrqhmsvjpelxhzuywetfyesudiqecofrvjiaxrvgqzmdfvjnicgagbtgeyxtlkqfjsowfvukhelscaacinhzwsguuzbrmaalesfncuktohhdnlmuomfktxvuxfaclllywkjbwxywvidwnrapfmaydfdzfndcalejkcyohklygtsvkvujbcerrofhxtlyaymspyluyxbwppbpsibopptscpkhmeavfnmmgcwevcqqempdchhjvfjjcjgtlzlutundggcsdkowpifyzejegykffwlrxiaowyqvzoyartbxkfjkryckfdrxrheesbiblmleiljehuxwjaszpexabrxkaojaivgdaumqfdffrhtkzpfxwqggphinvkamuxzgfsqwbjktsbrhakuyddytdppixckussjmjommnpcifktvoipwmmrxlgtyoiibtoitikneadegvvyingzjpnaeepknvolxijqmajioevzuokzqcmlpcizimixgimltyveyauegshvifqwpqbmvqkzabwvpxbveqbsercywhobshndrfavorbkgkuxmcdbyaaohxmvlwxauhdtbvdbipuukhklamwddmkmosctosurwarmbmvmqhyuwhlqibxbuntvbslivnqwgpkezoausptbxndutmjugvgsniwgdakhbvcjoigztcnhtabxtqcplljmalziopbhzawuovnuhwalczytxascdwtkwwkfzkitotkzqodqehpfxmbzeetnllodmcvcgnsklxkbitiqkaqzqjrbfkbzmtrbyiaoouiozsazcqcysoztetcqxbgewfojztnnqoackzjzqtiqcqxilhkrudcyghmcvqtsrxkfljpfcwjdndyqzxcbxswkescndrtoqzwmlrtkctgmgcpjpjqtwlhkwtyryznxubdfcozgfwvxmalxyxlxmupvyvbatjjkygqywpjxlzjdzsvlvwtpdyjgeixrxkcprgosdfdyibbantvalsglaaojkjjligxkasqpkmyrsyeffsqcvxxnyzwgnqzdvwplceescylgcqbvtdzljnnuyeudcdeqqlqokbrkwliulhxkoacctikejrkfbvoxeijisbfbglmopocjzuizrefrwwsblchwzfcqcziwwqvwcnuczzjagyldgbvnxhfztptvjtzafxuorepdpmqfxyubuyragvclstnbfvpzsgwpchyfonwdpcxoxlexgjhxgqoierllasbqgsrojcxcpcfrzlhvktsruprnguiisrtyvaxfdpfwkrqtvxzbodazfwazhynvytyghlaxmkpibafcpslxsoqhslqgjyxlcnxbqwtmlyqdojsmpdaityfykbywojermghyduquepqmgkwoooroointsduqhthmlyatzwzfbbykgwqbcwoaxpnoilzdppkajhylhyannwqfqwgctciuaojfckkxxzwbdmzlgxzwonumndrfihuelplnrfephlagbggebumcgzcgbutsqdhuloiwvyhcmxafirunzqzgvaafjailxxyzzsoyhutqhhclzflvojwomkbpbxjtrbpxalydfhlexxncwyehkogpyzqlzkkwgzgwcnjuyfisdohrprhwehtpcskicyfqidjvbakykwurfkdqkinkeiparmbvdwsyjyispdmpeaoryumvqeuwgpqxtbzpbivhnouqnrjastnaabvplbwjtqabmqvjwxktywnjirxennzbqnedwfzmjwlycsqzdqrwfjpkbtqugaxgafdeevwaexcfnhnqtuidddfxjokhfzkwrvpoiajxyeottylygkqwntqyozzhkxjchxmncditqzijnoutmtqcqpbfmszzezdbepdcyfgqwujoesuwjoviowycdzvkdgtybzhusdkwhxfajcbzovlzshukvqzcazwfswfqejmninnmxaorazdbtotwbgcwwgwufmabykunjrmgvparhjhwqocpdxrrufbecvmiyhiuydwyrpcudkiglbxhznnitxgasvkcswjxjkoegxgshokjbzzsriwlnbqkyhexfltmjjkoopfapcksxwpfimxwfobiqjgkjqzhqasgblinwxuvsyndjhtkeqmxfizvrlltfxvoezoxoitftcxsujhsisdcarosfrjyjqonqjvfclutdxnjfffhkhtgugcwjccxtkrffdpgluspdzzcdepvudqcacmumkkwnmlowissyoocgrggqjehwljtnceclnuizfbdkyyagsucrgxydpabjtghzbfvpplrqwipbqpbswypoamasfutrvdypbcrqswkvoyjlphnkkrinkxzawhlgsnaxywzmoombjuykrqerqldivdlxxpucpkpuhckcesqzcjiurcilytijadjaydmmxbzzazepvsryabajkswzucwmqsiggrzygeyxxpqkytilioqkkyuqaqwpkujdqushtjjyeemrkyconpaghsouwxsvrxrjcskdgtrnknvdelwgjfkuvzknnyxdwjztotkrmxaejwayrypiteyocynkvzjtamlycwrbeejucqghzhjeywyrqiahqnsakxdrpovobqmperkbmocqkvemiokjxewkcgtmotbjvhpnastsikdqyaszrcsdwzqtxnwtsodzkqxtzdreaanlsgeytkbykitnmcyfdfkghctdimilamuqkdhiubbodtqidlnfmczoxgucfljoazwoikvtgowkxwcgxtfklkrthtnjwdlqkprjdwwivdzvlrvpojjqnkdotcjbbpymkvyzktxijlfesbxunzbajqbtaiekwtzrktdscwwanijcmtznywnplppamddtioenszvtupqkpobiwhfybdwjlxzontaflsqjfwxzjtggdygspzigrfzfzsdjylkitlgogjnaalsxrcnhvmurvkehfjblrtfgqfgbanwtvwutatoaraaqcblkjsurjbrbogtijtznqqljxkriufoaxytxehqkymllrsjuyhhnepwlwmrqarjympvoesljcqtrxyxeqvepeofshghgnnxzecsqdjsgmzynmjjbzupwmaavntkbagibosoetetwmyofvhpfwpbloxfzekwzpmrzsljizezmerdxzytfchdovfxhnjxbrysumlsmjgqylcmxitocwqupeziuazbxdnmpmlvxnyinwlatvrgcnftrcfsmmucpbeaofoudmcyrpnpaginepjpgiomtmenrpfyobgrywisbjqtzoiufxryrwkvqfzzihbikviqlwqlwpjgwumielxtkzvnncfhcssqixkqhollugwrqpbijtsnxcxapzzahodobdeimpafagmgvcpkildzbbyhqvsmpuvabbocvvkvmzftdivfwwbtwrzgdshwnswpupuphglvxmxvqhoqlzqcopxqqhibrogtbnoxflowsxnuxjcnwcngkueczphhvxmdpwizczoldawzofdqhcndmhcdumleesjugetvtlndrgociseavtqkaaldtevmapamlkmfwwrngwfjrqmqdieqskhlwgwwxhqjbhciwwcnqpbztncearsptfqhzugibzbbuqkyvrqsaplbwhjhlrrhwcdeljpupkjoliibcsfiromlglctxjdchjlkhxwjdbwxqbxmqbaekpfjblvasreifqabpwaxysjaluyloblrtlefdaiieqwfryflobrtnskcbwnpkarijlizlireliognzvsiyjewyaglghqvsircrkxmykgolbefmskxpquwktpwqacxwghaegvpprtkxwrgadcjqczeeahqtrzcqmkxuunvfrzlhrysmvtkvmimmnzpwhoxrurlrvrpnjjxbftglcluipemuyztoyxyogztcoakigxmdbczpixggagvuohsssfbhmycezqcnjpayoxgdpmcudmamcfongfyzmxcilrywenntvuajyagrjelsssesjvkipurxrbfyuvjzsptrlkfcvucrkwemsvralmxlcbmlcjddudvrjbpfkdcnhrplolcbinllzeurlaaoomgavjzyuxtscqgabzluexthwwdqfwtsfdbwkecwjwunutmxjzldruhvbvnswddrmcihlrfqqodpmapniqeobbrrriiadfrfrdoalpmrnfczfcjxvwvvosyqheecmgosqpeunymsaexwtwurphioyjeyryqmodyjakjroywmtegllaarviepocayoptdnffbnudwjrlqrkqktctxkhgvckekqjevxvcqpwtotbsgyzbnyvvfuyhbumryjrninvqptkkgketytueuzjomdaoddgdudjyjhnkkfzftouvkpfznutbnyvaxgzumbvqfpzrycoduxngplhilswqlexkadordraemzgphwqztxgsokpmkenztekcsfmzzjedwguztkheyssrttwaxnzpvjooshwbkyrzheoatmkdywyfaxprnxhvloxkivhpzpyuoomhjdbzliuuqicazdmpoeywjhaenruhcllkkkcbpgvfzmigusdvappuuxtbnjwnxtdowvkqvmiinhnkzpgpebfhdwuficntxhdbyutpfzujdojipckzefxvnfblnxtxfxwhulwqanxhewrpkosdeytojxqijkkuzueuqwlqrqmbxnxojyabwjrecwtcwgymxdsvqajclsjusrzpybwuexhgrfmwqypuaxxistasfnyllgyhbdwnhbotagqcrcbulsgduxxlhuaaesyypbtlhrrritfaorpcnzoqsvoealekjabodcawcmsecyusefzwrrflrdtxybbeysaemjytxekwqfmuujluvttezusqebiqccfqraiidhetffveuqopkjlkuoefsnqyxfsighlfgdqkkgfohbbxnyqmhzxfdkoujczyqzrkfhgmyamwmceqvgvcodjmmtgafrckbkrojskxfldsndvkegritxdsnvfiiwxfvpwjvioqnbiasxsgnmacokqpiclrbdmtkqqckzejxhlhofhxdpgptqrmhsdpexvpywgjfnbeqgnvprvtfqexwagwdsqwdmsaerhkbbqxkzhiqcltvwqjqyuplayakfqqsmzmgaxcxwclwsbtiydfctzxxzqfsvbgtjsdkjmyuniyazshibbmwjseagdtaysqdebzlojovxeoytycjyhwjbalhcfjmcrtrfmlydsczdhcskqwxwekoglrracveadsrywrcdxvgdcrllfqsuxaqcdufunoudxlxrsuwicnckttgsfmeueqxtuuxouoteabbjjcgvsechdqxhytteeqjnhozaqcrdemjfzbyjyvnryzafzrevroyuoyvcokuarapninjophycsungelzmwqqdjebcnqgghsdjtklrqauhqenukjjwqhpfobcmuqawnysyyvciytbofqwsyoghantuxvukvzwyuhatpxxtypcnphsjopjcriceaviedzztxkngfngwaucbvyerlczsaotqiqidvtjzfwlxqyydsynqhoxzxbievzwvkeklrltsmcdhnpqgxuojjnpckrahtuenmrwfzazdxjkzdanakcxijvlsvyymbetfsuagwhuhkzrimujsgcmtypidguezhphwoutwzcqecnfvyjhqcxutzrvysckmmuanbmttxepwxewzhyligbsznvyywprfaofmhxvuyekfkqzdxvhqpzxcbrgpenmwikkilcqkyewubaryrqesiljvharqggfotyqbvxhmxemptboyqazdnrkdyzughypwmtdtnrwgqoijfnwohdhxhcgdnypyhgccwgoydjvucoqyvdwesqhiipyhsbfnogoorwawvjyuewlfkazfscjrptqbwdecjobbamaoudabelowmtuglpyemklyujguqtpqyvcrsdeermcexdcmjefeawchqvlxptmumpknzhqfquhbcwonzttocykqjuibvwnbrqwivffxusecizkxdughtshoaobhqucapxkplvrvngmcxncpuzswlzxvdnqocqjiqxuqaslsaxjeopmelkwcidbklsurftcyzxjxwtnkwptytfcasgqdmgbhtihutxduglzrgksujnqekzprsqcylcevlyuwdcpkeujaqmjblksrtogbcdzuhtdnxnvkaqlqfpkwkgudosmklrbflsmchgyzjpougoukzinmarixslkmhkqfljyjdktltkweklvjisjjhuxwseocmpixklmjybxaaymvjwsbxgpmtjasdjibgwmxplctoejntfiyvmdohyztzxjnlcvrhpgwkjwbzybwhluwjpyxqxyopkuebwzbtpaenmlwnvfrnyuqbaaypyxkgqwdabfnpxylnmrdssepxcuconhoxdrodzojicjnoafhwibrvtvdenfzedccznecjmwefpnjspyuiatrwksfnuieyyadggfsyjicnrtpnvbojukbavdkucilpzqxwqjeqkcujgakdcqpgobypxvcwbeaqtwymsfktkdcravulicczdltmekhqyclwwglbvfrivlfazrwjcixcacxzkfztyioywhshfbxavucuibvdzbhmalwbwbqutktvxinuoqfghsupwdfuyfvjcyzubzsdxyslwalaifuxfwhxaufiuroiylhgjoontjzsoxbuczcaengcodfqfydbzdsemseildblbexyeaxxmlqzreevdvibtgdhjvwsosjejdtovzokqqotdgzbfrytpcvoscwylritavxpbkhagxgfisbnbgqjgttllmdevdtemafpoyzymrcwjzsmclplqpacicssfeqccfoasfdgbolhfvdkhjaydbxgeipgpxukytfbieofdrusxzcdwpuanbpzniuyjdlvknrcschkpgbtyzoazdzqsjyblfybpkngmmhxrbpiqdxsthgouxvqwoqyssyyjghdghnsjrnftwejoegvokkwzyfluohjxzbzzltunjfmmpvtrzhegbigakgkvdgeuqnuqizfmafnyvfqialgzbnsoklipxkuigfdzacxahvtjpfdaejksdbsrvubhphxoshlykjolzxbtrmqhicgenvcguzbkcgwrrxlriqmaemyjoerslkpjewvphgsidmfgysdlkcfawbbubxxbwxwaogwbiajyqhseorhsofjcwoifpuzsmmdzheuzhzqftqribuaqcwnubblsdmoedbnaxpzaiqfjfvkpgeiwazgufridmjezxdecilncnwpptaawioxvoguoiwvmosfjbkpuxhvnzwixceemzcrbnkejloxmmdnspixzpmgodmgxppvoymxuqhuzgznlczcomgtsjwsikbdwchridnifgejuvthabpntbhqvpgiebqvsgncxhqmgoiitmpjxzgrtrihnsgygjeimteezafhuaaufoiiasgcnjojumpqnyoozszdcuemergxgcfmtxczjjxsqilivnaxvlzbvidudymcjudhtosiaiqwgivcszmadqioxzxnkuixdfmdcujnfkfyezpdqiveuhupwdbwfggtchaykqccdcdnpdsaihmhsgyedcceexssolwqssizwmrdubsmvddhvkhsukeomlgzduvzkbkoibsdondgcnmrddysegroemkeujjofwnhjtmwrgpvwxlcvetiwcavelylgghjcwhbayluvjndfoivtpyfswcrsdcwdlsncwbgescjrtwicpyzvgamyicjzsjrhfwswrfuwwbezppnpoleerlcwhsklpnckkrauyjibbbjnikbgerhfneojbrzoqqcfrwenizlhyxmydlpdocwcvnhqvyewzpozffxpucpxeysdflnzqlfnhwnjfybwoyojvtcdmunzcttnphduphykqewcfdhkcwtdjwtpunuwikzjvzbbwppjevzeehffcliapawvxfloygbmwfmdqbhckkfitmvhvszmaakripmchutvcvrffbzpoywyxrokpnhqmfdmxnyhjkoaiebepiimnhzschexehjrllhegfihgqhbqssxpssnesaoounrpmdubgsfjrarwytxntevlbpmftfelgxyvxxhedybhmndqdkvxpjakvkxyweqelbyepmdmvpnuwdqtxnpsqjezlatqlkctnibexajexswbonqmgaqhrvkbjsfzrnunqyxavpnmylsizpsbqgfulmhvxqjukiqsxyrshzkgfumpersvmjrczpwgcipwogdeuuvhvidfdqapewzcvbcmqfpmkqcudpfnpksfdtykbwmxspebedocmydqjvusdqtufxvswjdkpildkxqrbfopwrcztzcefwhaqgrocflultpchcijavkiayvxtfcocfoqgabeiwpyktxbwejbaxodpxljlwsjqnodjjfasicokjppqfxieenjoliiywvfboioekuigfpuwpslfshmzpfdqrfusqwndoabctgcchrhhxdloolbtlyowalxzsdvkfzdponixtbxouragcqzsnwdnumskewhhuxjpvdjtrrzgkiosbqcrcnacweqcjbnassomfsvujuyrbsjdvzxvkiveaesgueamvqveorhdezlhgwqfhvyrajrcvlonvqunnngvcjrrrnmdpdmsdmhdwzxdpbbunwtyqgzzmvhmwiberfoxnwrilldkglstfenkmyyioeyvosfifgjcevbghezoeknbbfbyibyhqjwkgrhigbqdbfkzugfatqpbjabsuufqlftrbeajibefaoqpopsgcqjmhfdyabtnfcyikjvbgtjnczhoalclpqkfdaxlhdmplzbuflbyvfzimrxqeuazpmqjgehpsnyzqqrfrnrbwrzzwgrnxaslgupjropdcnwdlmisozfqtzzkphhoydazvwsxamxwongyompquzcwohuagtimjhlwnqhnrlrpcwyflxfkltojrjaeqiwnjgzpqyqvkpqvdgqgrjjymibkyswyaqaqappbqdzijkiwxugwwyvqwxfreheftlpjopycywmhksilinrkbpgmrsmvqfcurmowluzomoygqdqhozsveqrtbazhzllgikbmmzdxbjmxhgxlaadjomcievxehtfomcurypvgicawcbdzqtpmsplowngnzaudssaxqlpqrkzegqmgvxeblwcufduiiamxstmekudjuqhfwtjyouszyycghiwamvnbniqdetnxwcledqflhizjaiqqvowkalijcwedluzcdlrcebqpwrfmezgpgimdtrgqvgkzzxtpunfdzatbwrzqzpxjizoeojbswxfkcfcnggxfuuucpwthgyckuxyuuwmwbpfdbcxwgqqaqdepadjlcapyqusxwftetokeskbfvaqzggugmqlldgztylxczitykiylfqshscdtomgedtzvvexcprnppcvtfpvtzurokcniknsqjwcumndewawrmzuhijppvgjuuzjibijvpyhvxhwpmxwttjtgjowdxnurdxsbyzphplgscoscyzpwahbbtlxuefldhbvsbxrlieyuoroyegbfnlcohflgevrnrtnywhujofievxnjoiskhbyivvyptnxkfmqtensnqionwvxlmhcqzabgbvbkgqqforoqznurzebuzpxfnphhtipjcxezsljrdvlpxyygirihkscrwjrtxzkmmnrfohnwyazfdhianoucnewyeycpjhwxrjryevvuviotdmatzvidhftobkfznnjzxqvarbhllfmbfxbxbhrhpycejspuwbxtnteddydswdxhpcdkqmuwwhngfaswoxquuzfxjybxetvvfhqpvyvrfgmuyixwuotnicvyykddhocfkyukouiqhwllmvrvnagxsgxohaalzvxpjsvuilzqawbtltjlndqrxlitqgiauutgpxismrlrkpksdmzsvlxgbaexizbxymxsmnsjqubfiyrpjqnrlxrfkrrplbbcltlqigpkztplpuvevvmebgvupdnuunswuavdstcjhhdqifutjpikbrwzwmmwkhpdcflnmritkjwlzvagxgympbhxrbsxvaprmxllfvzfbrpympvtoxkfkgidhhrfrybvezxeifprkaiyomrdubasdomihpecgmmgejwsqwvouodqevexlsllovwegvvrdbapidrhistnpzeohrwdywpcmlfzkmcxykukghphejhtfdrfvzykajtawegghhvcbqytgphtbuwmkzwvfktenjtmedxtblgrgwdxjmuqrtyvqoptsoelouaiqpfapmsykeqnsktevdozdbgzstojgafxvzcobxvpqkrueeztpwwyvlzvrssoyxvypndltbqvsroavpxyzeaecqnlpcrxrtkjhkfxhifbmdrlzgkrzzepgtuqcvftbogghurlvcklcepmcupcmbnhhkbxdvmovqrwvdsrqgsdxfrzhfucpttolskorhuuaaaqmusqgndbuygobcraphyqjmevvnhclvrwwpvidvpdzopzchwmzgowsqcauwrffaylfkhmsurxrvqulztpygfzpqzhqkdbgrdwmkkryxftjpqncbzvqkcuapkojzdogvkklzclmzjigodqjewqfgqwckdiyteacqxalwypshgjqwiqdvkhbxtrlwdnzhlexthcyohnrhnifiwrcrbhgedpgkdzsmizrawuhxfxfiqlavyqlitgeawriawehjhxelehdtwmvaempchpasvlmbvprgkllaefgzwahpkhagtwqbpufzcnrgpgjhadqvlrdixynquueaevzdgvhvvemnhykwppnqtlhlvcousbwfhlgpcacdysjtvwzkniyidjfaxqwhhbpaimwecqlhtikcjfnlvybsfsntukanazzbrnedgjofvzmxsasiqkeelzysboknbiwfovjatfozbcnmgzoqawuqeiuavoyjvjxxupberohdeffawaohysnxqzqukgovjyhvmcjcuefobdwavlbtvvovtnbqboyqdipsexbbngaiejxdqwineutwllxgglrpgfxlusmhxuueiszlblkbioutzieazqmqbesirwxokyaomkpobxkexcjinukjlazcynhylmhjdqzjqejibhaampnknocbyqkrdqlibixsixtjfefodsftgodivdllekbqgtykiltzvpdmdmxjphyzbtdigcisucarrbrqoybkviawpasofnlfwuhxcqbwnkgwiqbaydjixuwatnrpstgnmxkpqahxefvapbqlrpjqsouyyjjwzkvamrepvrxfxpcsztshfdoohpwxrknhaynczxvcjperudqdgsbqjmvdjbavperxmxhadkmtbhrzucwijivhvynsmbubohqsxwrgwyckgktyghniydhfnjrthnmotbdkdmlbopokaufwdzmxdfufsusawpayeyagwbszvnlidzwzmgpgbjovpdpiasetmlvbcsxazwhyiknsujdhryamznbpctialcdsnrascorcfeopamgxwktoftcrkjthparbudnxhznapvlmqzbubnrhjdqkddhpvlfjcscxkrnljyptrwxpgjbjxyqmaegqkprfcfrswpceukhmpmvuveoeobukxmuojexonhdvwttxwbjsvtqyedilbiffnlkqxskybptbuqvooxkmtygtvxmhursisahiubfdlfguubzagkwskilouaalbtufjwlwgbayikmxwmlmepnawnudvzbcecogqubtfiweqfahtkeyopbzjyxytyjmcxpiypjmxrgqijgasnvztdlmhqxnvpexxltrexdezntkxbafufxawdevzjjbcsskdnqfrgekbudxsybgohmozxedqsfhbjaharjgaeimoxscbsszonklgmojildfavfxhgeykhbhhuqhzzuiliuhjdilmvgkmuuadxzmuctjypvpglvwrdumymgsmwecynujxdstgnjoztucqzzkyssnnivyibztuygiyrhlnmxlisfrocanlqigrknfkttrnzwcljrfxwpwfvihgluxkcbgwejnudqtkbueupeyeybsbkhviucilceecnuqbwzykiidqwptgurefoyfhjkhhiujvepqscgokqhhajesthfyswglpyrqofhonpsruqmjwivekirmtdlfhsuuzsgdwbictdyalswwccouajyaljfgpsavhthoyiesgyhpwnkrgslavztzkpbuggpcbxfntubgmrlipcfqyqljardklnaibctezbtksdwpjmddotnpdtzgjsjbglbvmndxecjizfubzzzaezwaiagliyprdwgwkosdumdclyaestbmisjoevisbtigcsncvynkiftveqpruuxzwsnwybphhefcmxsaftwkkoxbttyoatogcftpjebegmgqvkdnmykfwmlueczkvcdzlfyhssdaoqldywnxaxmhlmflvxnpuohdicsgosnjwlnqrewylnjxuqhtxunawkxacpsonyupddkvcjfhwweqvdtidqnwrororhkwhwdpvjtragxaotkcdvhskemhibdoityyxkgzzohqvaxlercvofzngdlahlykfuktvvwbjleqplmuwwwikwzggebdeahwlocroxdrufndmxnxjhzzsqnocygxjihtghoffynqctibnlvpcysebxwrrrggwgqmrkvwkwuidhgxuqmoqttwmdgdkhirgzztmgwwqmonjrexymlbnxgpxafanxpgzwtgjboqoeleoegwpvhhtobjvtbwdwaniuqwpzsywbisxtxoabjuxgnvlsojoarlhkilopaaqbkbyvazocvxveyuuicalgceleildjhhczdbdobcjjnumqrpemnmgghaidsyvwglqwpaxciusbywgdznvimjtjxemttjxicndatplejumszucxohkrvzuzbkbdcnotvmxpaofrpfjszjouiiclfofpprxuvjmwkndvsoubmptmmdnvsslrofuxtrwlgjyqfklbuctexcsmrausuzcudyshvpppemctxtcqbjowwgdortakllugyrqihoyjdurazprahoznisgxmghtrsftavoitpfoomjfzyzxoqvekzngohccurtkwaszznbnppooojaltvujkyukyocgfadzaevjrknppwloujbgplmzxipzxiirlvsrefarolgpkjugatzxsikdhqfllqwblivymadslapqslurpzbbqyefsvoubywwhterzwmbuyrdovmwzrzoveydyefvjxswmvhxroqnrhaneeujqeoyvbdeizygdibioxcvllsnvogoaqjjgvzoqsexhlbdbxlryvtceivzqcesnnfqmrqvwaonvyinfotdirotuztshsdkstgjnlkeflcrxdmutzvqmjkpioxyikppozfninlkithnbiehgmpnjcgomeebxlarjdhjbybbsrhqonztqcctlpsxpcjcuorcuynukhzvxybcnlwglysahufgstinzklwxcnjjdffuwydqholgfhwmzbundqacyspgsnvtvuofdmdcnymvbqilnpenagbztcuvtgyppkejqklzeqbdezbepodercpkplybzomkpdtfsgjtqqsyetwbscdvwfjzsqqusvrorejlfszzuuqzdvfujgsgxbaqqezhgkbxmeimnbbbvqtwvqaeqeneohrextbvvyapgdmkvivzjxfewdmzmdjmbrhbykjgpcjhiclxfhbtugqrrtkeirxdfjslzggpofkobbnydjjkdcczeyjruclxpvdqknmofkqcefcxrzmpmzbytijvgpxwekcdrgjlbzsqvyxkcybdcvywfmlquinwfgyycctonuofqwqecdwkrdankqjbdhslvxfazyxgcdpnqcowlklntekahuuofeydxkzprrkpjwodfglksfdibevqqhtcjdptcbwcxjoijlpyirjemgcdxlkqvtakgudnvurpcpsbkborovppeihpejvhcjofotsjeaiaszvgonnifclwobszhfqotamhemacldpyvesjrqpymgccyjumiojxzmmibsbhtyqwzujajjceswlrlogibuvlkvudqrhrzatpbvxlvkmslbsffjlanzglqjrlxaajixizhpdmbnlzcjuiivhrilgrtrpfidgekqvcavtndwfloqyuwyebptwygpeheboewzicbwzpsrksevcnepmswcuzbmqltlszwoxqxsavadmmndkzmkraiigppoocsnaguzaarenihepxbkrcgaghucbmpepebjwqmaknmubgifczfvzrfpvyuzcplohakqgivnxkwyxzgdcrdmzsmphhejfcvebvrndwwhueknyemfemqsyfykcwcudeqabthnhqhymokbuclvuxuzipvsbrzrvyqutcmqqdsbynnpreqykhjmcocbf", + }, + + { + "xbylisvborylklftlkcioajuxwdhahdgezvyjbgaznzayfwsaumeccpfwamfzmkinezzwobllyxktqeibfoupcpptncggrdqbkji", + "zzwobllyxktqeibfoupcpptncggrdqbkji", + }, + + { + "abab", + "bab", + }, + + { + "leetcode", + "tcode", + }, + + // 可以有多个 testcase +} + +func Test_lastSubstring(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, lastSubstring(tc.s), "输入:%v", tc) + } +} + +func Benchmark_lastSubstring(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + lastSubstring(tc.s) + } + } +} diff --git a/Algorithms/1169.invalid-transactions/README.md b/Algorithms/1169.invalid-transactions/README.md new file mode 100755 index 000000000..194e93ba0 --- /dev/null +++ b/Algorithms/1169.invalid-transactions/README.md @@ -0,0 +1,40 @@ +# [1169. Invalid Transactions](https://leetcode.com/problems/invalid-transactions/) + +A transaction is possibly invalid if: + +- the amount exceeds $1000, or; +- if it occurs within (and including) 60 minutes of another transaction with the same name in a different city. + +Each transaction string transactions[i] consists of comma separated values representing the name, time (in minutes), amount, and city of the transaction. + +Given a list of transactions, return a list of transactions that are possibly invalid. You may return the answer in any order. + +Example 1: + +```text +Input: transactions = ["alice,20,800,mtv","alice,50,100,beijing"] +Output: ["alice,20,800,mtv","alice,50,100,beijing"] +Explanation: The first transaction is invalid because the second transaction occurs within a difference of 60 minutes, have the same name and is in a different city. Similarly the second one is invalid too. +``` + +Example 2: + +```text +Input: transactions = ["alice,20,800,mtv","alice,50,1200,mtv"] +Output: ["alice,50,1200,mtv"] +``` + +Example 3: + +```text +Input: transactions = ["alice,20,800,mtv","bob,50,1200,mtv"] +Output: ["bob,50,1200,mtv"] +``` + +Constraints: + +- `transactions.length <= 1000` +- `Each transactions[i] takes the form "{name},{time},{amount},{city}"` +- `Each {name} and {city} consist of lowercase English letters, and have lengths between 1 and 10.` +- `Each {time} consist of digits, and represent an integer between 0 and 1000.` +- `Each {amount} consist of digits, and represent an integer between 0 and 2000.` diff --git a/Algorithms/1169.invalid-transactions/invalid-transactions.go b/Algorithms/1169.invalid-transactions/invalid-transactions.go new file mode 100755 index 000000000..129a40ca8 --- /dev/null +++ b/Algorithms/1169.invalid-transactions/invalid-transactions.go @@ -0,0 +1,72 @@ +package problem1169 + +import ( + "sort" + "strconv" + "strings" +) + +func invalidTransactions(transactions []string) []string { + n := len(transactions) + + isInvalid := make([]bool, n) + tps := make([]*trans, 0, n) + for i, t := range transactions { + tp := newTrans(i, t) + if tp.amount > 1000 { + isInvalid[i] = true + } + tps = append(tps, tp) + } + + sort.Slice(tps, func(i int, j int) bool { + return tps[i].time < tps[j].time + }) + + for i := 0; i < n; i++ { + for j := i + 1; j < n; j++ { + if tps[i].time+60 < tps[j].time { + break + } + if tps[i].name == tps[j].name && + tps[i].city != tps[j].city { + isInvalid[tps[i].index] = true + isInvalid[tps[j].index] = true + } + } + } + + res := make([]string, 0, n) + for i := range isInvalid { + if isInvalid[i] { + res = append(res, transactions[i]) + } + } + + return res +} + +type trans struct { + index, time, amount int + name, city string +} + +func newTrans(i int, t string) *trans { + name, time, amount, city := parse(t) + return &trans{ + index: i, + time: time, + amount: amount, + name: name, + city: city, + } +} + +func parse(t string) (name string, time, amount int, city string) { + items := strings.Split(t, ",") + name = items[0] + time, _ = strconv.Atoi(items[1]) + amount, _ = strconv.Atoi(items[2]) + city = items[3] + return +} diff --git a/Algorithms/1169.invalid-transactions/invalid-transactions_test.go b/Algorithms/1169.invalid-transactions/invalid-transactions_test.go new file mode 100755 index 000000000..23f7c11aa --- /dev/null +++ b/Algorithms/1169.invalid-transactions/invalid-transactions_test.go @@ -0,0 +1,52 @@ +package problem1169 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + transactions []string + ans []string +}{ + + { + []string{"alice,120,800,mtv", "alice,20,800,mtv", "alice,50,100,beijing"}, + []string{"alice,20,800,mtv", "alice,50,100,beijing"}, + }, + + { + []string{"alice,20,800,mtv", "alice,50,100,beijing"}, + []string{"alice,20,800,mtv", "alice,50,100,beijing"}, + }, + + { + []string{"alice,20,800,mtv", "alice,50,1200,mtv"}, + []string{"alice,50,1200,mtv"}, + }, + + { + []string{"alice,20,800,mtv", "bob,50,1200,mtv"}, + []string{"bob,50,1200,mtv"}, + }, + + // 可以有多个 testcase +} + +func Test_invalidTransactions(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, invalidTransactions(tc.transactions), "输入:%v", tc) + } +} + +func Benchmark_invalidTransactions(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + invalidTransactions(tc.transactions) + } + } +} diff --git a/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/README.md b/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/README.md new file mode 100755 index 000000000..2b68a127c --- /dev/null +++ b/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/README.md @@ -0,0 +1,28 @@ +# [1170. Compare Strings by Frequency of the Smallest Character](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character/) + +Let's define a function f(s) over a non-empty string s, which calculates the frequency of the smallest character in s. For example, if s = "dcce" then f(s) = 2 because the smallest character is "c" and its frequency is 2. + +Now, given string arrays queries and words, return an integer array answer, where each answer[i] is the number of words such that f(queries[i]) < f(W), where W is a word in words. + +Example 1: + +```text +Input: queries = ["cbd"], words = ["zaaaz"] +Output: [1] +Explanation: On the first query we have f("cbd") = 1, f("zaaaz") = 3 so f("cbd") < f("zaaaz"). +``` + +Example 2: + +```text +Input: queries = ["bbb","cc"], words = ["a","aa","aaa","aaaa"] +Output: [1,2] +Explanation: On the first query only f("bbb") < f("aaaa"). On the second query both f("aaa") and f("aaaa") are both > f("cc"). +``` + +Constraints: + +- `1 <= queries.length <= 2000` +- `1 <= words.length <= 2000` +- `1 <= queries[i].length, words[i].length <= 10` +- `queries[i][j], words[i][j] are English lowercase letters.` diff --git a/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/compare-strings-by-frequency-of-the-smallest-character.go b/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/compare-strings-by-frequency-of-the-smallest-character.go new file mode 100755 index 000000000..89777af68 --- /dev/null +++ b/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/compare-strings-by-frequency-of-the-smallest-character.go @@ -0,0 +1,32 @@ +package problem1170 + +import "sort" + +func numSmallerByFrequency(queries []string, words []string) []int { + n := len(words) + ws := make([]int, n) + for i, w := range words { + ws[i] = f(w) + } + sort.Ints(ws) + + res := make([]int, len(queries)) + for i, q := range queries { + fq := f(q) + res[i] = n - sort.Search(n, func(i int) bool { return fq < ws[i] }) + } + + return res +} + +func f(s string) int { + count := [26]int{} + for _, b := range s { + count[b-'a']++ + } + i := 0 + for count[i] == 0 { + i++ + } + return count[i] +} diff --git a/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/compare-strings-by-frequency-of-the-smallest-character_test.go b/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/compare-strings-by-frequency-of-the-smallest-character_test.go new file mode 100755 index 000000000..a13768e6e --- /dev/null +++ b/Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character/compare-strings-by-frequency-of-the-smallest-character_test.go @@ -0,0 +1,45 @@ +package problem1170 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + queries []string + words []string + ans []int +}{ + + { + []string{"cbd"}, + []string{"zaaaz"}, + []int{1}, + }, + + { + []string{"bbb", "cc"}, + []string{"a", "aa", "aaa", "aaaa"}, + []int{1, 2}, + }, + + // 可以有多个 testcase +} + +func Test_numSmallerByFrequency(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, numSmallerByFrequency(tc.queries, tc.words), "输入:%v", tc) + } +} + +func Benchmark_numSmallerByFrequency(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numSmallerByFrequency(tc.queries, tc.words) + } + } +} diff --git a/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/README.md b/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/README.md new file mode 100755 index 000000000..98cb8c065 --- /dev/null +++ b/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/README.md @@ -0,0 +1,34 @@ +# [1171. Remove Zero Sum Consecutive Nodes from Linked List](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/) + +Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. + +After doing so, return the head of the final linked list. You may return any such answer. + +(Note that in the examples below, all sequences are serializations of ListNode objects.) + +Example 1: + +```text +Input: head = [1,2,-3,3,1] +Output: [3,1] +Note: The answer [1,2,1] would also be accepted. +``` + +Example 2: + +```text +Input: head = [1,2,3,-3,4] +Output: [1,2,4] +``` + +Example 3: + +```text +Input: head = [1,2,3,-3,-2] +Output: [1] +``` + +Constraints: + +- The given linked list will contain between 1 and 1000 nodes. +- Each node in the linked list has -1000 <= node.val <= 1000. diff --git a/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/remove-zero-sum-consecutive-nodes-from-linked-list.go b/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/remove-zero-sum-consecutive-nodes-from-linked-list.go new file mode 100755 index 000000000..e36f6865d --- /dev/null +++ b/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/remove-zero-sum-consecutive-nodes-from-linked-list.go @@ -0,0 +1,34 @@ +package problem1171 + +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// ListNode is ... +type ListNode = kit.ListNode + +func removeZeroSumSublists(head *ListNode) *ListNode { + headPre := &ListNode{ + Val: 2000000, // bigger than 1000*1000 + Next: head, + } + + node := make(map[int]*ListNode, 1000) + stack, top := make([]int, 1000), -1 + sum, cur := 0, headPre + for cur != nil { + sum += cur.Val + if node[sum] == nil { + node[sum] = cur + top++ + stack[top] = sum + } else { + node[sum].Next = cur.Next + for stack[top] != sum { + node[stack[top]] = nil + top-- + } + } + cur = cur.Next + } + + return headPre.Next +} diff --git a/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/remove-zero-sum-consecutive-nodes-from-linked-list_test.go b/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/remove-zero-sum-consecutive-nodes-from-linked-list_test.go new file mode 100755 index 000000000..c878da450 --- /dev/null +++ b/Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list/remove-zero-sum-consecutive-nodes-from-linked-list_test.go @@ -0,0 +1,76 @@ +package problem1171 + +import ( + "testing" + + "github.com/aQuaYi/LeetCode-in-Go/kit" + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + head []int + ans []int +}{ + + { + []int{0, 1, 1, -3, 6, -3, 0, 1}, + []int{1, 1, 1}, + }, + + { + []int{0, 1, 1, -3, 6, -3, 1}, + []int{1, 1, 1}, + }, + + { + []int{1, 1, -3, 6, -3, 1}, + []int{1, 1, 1}, + }, + + { + []int{1, 2, -2, 5, -3, 1}, + []int{1, 5, -3, 1}, + }, + + { + []int{1, 2, -8, 3, 1}, + []int{1, 2, -8, 3, 1}, + }, + + { + []int{1, 2, -3, 3, 1}, + []int{3, 1}, + }, + + { + []int{1, 2, 3, -3, 4}, + []int{1, 2, 4}, + }, + + { + []int{1, 2, 3, -3, -2}, + []int{1}, + }, + + // 可以有多个 testcase +} + +func Test_removeZeroSumSublists(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + head := kit.Ints2List(tc.head) + ans := kit.List2Ints(removeZeroSumSublists(head)) + a.Equal(tc.ans, ans, "输入:%v", tc) + } +} + +func Benchmark_removeZeroSumSublists(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + head := kit.Ints2List(tc.head) + removeZeroSumSublists(head) + } + } +} diff --git a/Algorithms/1172.dinner-plate-stacks/README.md b/Algorithms/1172.dinner-plate-stacks/README.md new file mode 100755 index 000000000..35d228749 --- /dev/null +++ b/Algorithms/1172.dinner-plate-stacks/README.md @@ -0,0 +1,61 @@ +# [1172. Dinner Plate Stacks](https://leetcode.com/problems/dinner-plate-stacks/) + +You have an infinite number of stacks arranged in a row and numbered (left to right) from 0, each of the stacks has the same maximum capacity. + +Implement the DinnerPlates class: + +- DinnerPlates(int capacity) Initializes the object with the maximum capacity of the stacks. +- void push(int val) pushes the given positive integer val into the leftmost stack with size less than capacity. +- int pop() returns the value at the top of the rightmost non-empty stack and removes it from that stack, and returns -1 if all stacks are empty. +- int popAtStack(int index) returns the value at the top of the stack with the given index and removes it from that stack, and returns -1 if the stack with that given index is empty. + +Example: + +```text +Input: +["DinnerPlates","push","push","push","push","push","popAtStack","push","push","popAtStack","popAtStack","pop","pop","pop","pop","pop"] +[[2],[1],[2],[3],[4],[5],[0],[20],[21],[0],[2],[],[],[],[],[]] +Output: +[null,null,null,null,null,null,2,null,null,20,21,5,4,3,1,-1] + +Explanation: +DinnerPlates D = DinnerPlates(2); // Initialize with capacity = 2 +D.push(1); +D.push(2); +D.push(3); +D.push(4); +D.push(5); // The stacks are now: 2 4 + 1 3 5 + ﹈ ﹈ ﹈ +D.popAtStack(0); // Returns 2. The stacks are now: 4 + 1 3 5 + ﹈ ﹈ ﹈ +D.push(20); // The stacks are now: 20 4 + 1 3 5 + ﹈ ﹈ ﹈ +D.push(21); // The stacks are now: 20 4 21 + 1 3 5 + ﹈ ﹈ ﹈ +D.popAtStack(0); // Returns 20. The stacks are now: 4 21 + 1 3 5 + ﹈ ﹈ ﹈ +D.popAtStack(2); // Returns 21. The stacks are now: 4 + 1 3 5 + ﹈ ﹈ ﹈ +D.pop() // Returns 5. The stacks are now: 4 + 1 3 + ﹈ ﹈ +D.pop() // Returns 4. The stacks are now: 1 3 + ﹈ ﹈ +D.pop() // Returns 3. The stacks are now: 1 + ﹈ +D.pop() // Returns 1. There are no stacks. +D.pop() // Returns -1. There are still no stacks. +``` + +Constraints: + +- `1 <= capacity <= 20000` +- `1 <= val <= 20000` +- `0 <= index <= 100000` +- `At most 200000 calls will be made to push, pop, and popAtStack.` diff --git a/Algorithms/1172.dinner-plate-stacks/dinner-plate-stacks.go b/Algorithms/1172.dinner-plate-stacks/dinner-plate-stacks.go new file mode 100755 index 000000000..c77c7312f --- /dev/null +++ b/Algorithms/1172.dinner-plate-stacks/dinner-plate-stacks.go @@ -0,0 +1,110 @@ +package problem1172 + +// DinnerPlates is ... +type DinnerPlates struct { + cap int + // plate's index of next push + in int + // plate's index of next pop + // when out is -1, plates is empty, unable to pop + out int + plates []*plate +} + +// Constructor is ... +func Constructor(capacity int) DinnerPlates { + plates := make([]*plate, 1, 1024) + plates[0] = newPlate(capacity) + return DinnerPlates{ + cap: capacity, + in: 0, + out: -1, // not possible to pop at beginning + plates: plates, + } +} + +// Push is ... +func (d *DinnerPlates) Push(val int) { + d.plates[d.in].push(val) + // after push into a empty plate at end + // d.out need point to the last nonempty plate + if d.out < d.in { + d.out = d.in + } + // make d.in to be the index of left-most nonfull plate + for d.in < len(d.plates) && d.plates[d.in].isFull() { + d.in++ + } + // if no nonfull plate , create a new plate + // JUST NOW, d.out < d.in + if d.in == len(d.plates) { + d.plates = append(d.plates, newPlate(d.cap)) + } +} + +// Pop is a special condition of PopAtStack +func (d *DinnerPlates) Pop() int { + if d.out == -1 { + return -1 + } + return d.PopAtStack(d.out) +} + +// PopAtStack is ... +func (d *DinnerPlates) PopAtStack(i int) (res int) { + if len(d.plates) <= i { + return -1 + } + p := d.plates[i] + // set value and remove it from the plate + if p.isEmpty() { + return -1 + } + res = p.pop() + // make d.in to be the index of left-most nonfull plate + d.in = min(d.in, i) + // PopAtStack could make some empty plate in d.plates + // need jump over these holes + // make sure d.plates[d.out] have val to pop + for d.out >= 0 && d.plates[d.out].isEmpty() { + d.out-- + } + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +type plate struct { + cap int + stack []int +} + +func newPlate(cap int) *plate { + return &plate{ + cap: cap, + stack: make([]int, 0, cap), + } +} + +func (p *plate) push(val int) { + p.stack = append(p.stack, val) +} + +func (p *plate) pop() (res int) { + n := len(p.stack) + p.stack, res = p.stack[:n-1], p.stack[n-1] + return res +} + +func (p *plate) isEmpty() bool { + return len(p.stack) == 0 +} + +func (p *plate) isFull() bool { + return len(p.stack) == p.cap +} diff --git a/Algorithms/1172.dinner-plate-stacks/dinner-plate-stacks_test.go b/Algorithms/1172.dinner-plate-stacks/dinner-plate-stacks_test.go new file mode 100755 index 000000000..9980ae203 --- /dev/null +++ b/Algorithms/1172.dinner-plate-stacks/dinner-plate-stacks_test.go @@ -0,0 +1,70 @@ +package problem1172 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func Test_1(t *testing.T) { + a := assert.New(t) + // + d := Constructor(2) + // + for i := 1; i <= 5; i++ { + d.Push(i) + } + // + a.Equal(2, d.PopAtStack(0)) + // + d.Push(20) + d.Push(21) + a.Equal(20, d.PopAtStack(0)) + a.Equal(21, d.PopAtStack(2)) + // + a.Equal(5, d.Pop()) + a.Equal(4, d.Pop()) + a.Equal(3, d.Pop()) + a.Equal(1, d.Pop()) + // + a.Equal(-1, d.Pop()) +} + +func Test_2(t *testing.T) { + a := assert.New(t) + // + d := Constructor(1) + // + for i := 1; i <= 3; i++ { + d.Push(i) + } + // + a.Equal(2, d.PopAtStack(1)) + // + // + a.Equal(3, d.Pop()) + a.Equal(1, d.Pop()) +} + +func Test_3(t *testing.T) { + a := assert.New(t) + // + d := Constructor(1) + // + for i := 1; i <= 2; i++ { + d.Push(i) + } + // + a.Equal(2, d.PopAtStack(1)) + a.Equal(-1, d.PopAtStack(1)) + a.Equal(-1, d.PopAtStack(8)) + // + a.Equal(1, d.Pop()) + // + for i := 1; i <= 2; i++ { + d.Push(i) + } + // + a.Equal(2, d.Pop()) + a.Equal(1, d.Pop()) +} diff --git a/Algorithms/1175.prime-arrangements/README.md b/Algorithms/1175.prime-arrangements/README.md new file mode 100755 index 000000000..dddd4d43e --- /dev/null +++ b/Algorithms/1175.prime-arrangements/README.md @@ -0,0 +1,26 @@ +# [1175. Prime Arrangements](https://leetcode.com/problems/prime-arrangements/) + +Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) + +(Recall that an integer is prime if and only if it is greater than 1, and cannot be written as a product of two positive integers both smaller than it.) + +Since the answer may be large, return the answer modulo 10^9 + 7. + +Example 1: + +```text +Input: n = 5 +Output: 12 +Explanation: For example [1,2,5,4,3] is a valid permutation, but [5,2,3,4,1] is not because the prime number 5 is at index 1. +``` + +Example 2: + +```text +Input: n = 100 +Output: 682289015 +``` + +Constraints: + +- 1 <= n <= 100 diff --git a/Algorithms/1175.prime-arrangements/prime-arrangements.go b/Algorithms/1175.prime-arrangements/prime-arrangements.go new file mode 100755 index 000000000..3ab13c3a3 --- /dev/null +++ b/Algorithms/1175.prime-arrangements/prime-arrangements.go @@ -0,0 +1,25 @@ +package problem1175 + +import "sort" + +const mod = 1e9 + 7 + +var primes = []int{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97} + +func numPrimeArrangements(n int) int { + c := count(n) + return factorial(c) * factorial(n-c) % mod +} + +func count(n int) int { + return sort.Search(25, func(i int) bool { + return primes[i] > n + }) +} + +func factorial(n int) int { + if n == 1 || n == 0 { + return 1 + } + return n * factorial(n-1) % mod +} diff --git a/Algorithms/1175.prime-arrangements/prime-arrangements_test.go b/Algorithms/1175.prime-arrangements/prime-arrangements_test.go new file mode 100755 index 000000000..619980bcc --- /dev/null +++ b/Algorithms/1175.prime-arrangements/prime-arrangements_test.go @@ -0,0 +1,47 @@ +package problem1175 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + n int + ans int +}{ + + { + 1, + 1, + }, + + { + 5, + 12, + }, + + { + 100, + 682289015, + }, + + // 可以有多个 testcase +} + +func Test_numPrimeArrangements(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, numPrimeArrangements(tc.n), "输入:%v", tc) + } +} + +func Benchmark_numPrimeArrangements(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + numPrimeArrangements(tc.n) + } + } +} diff --git a/Algorithms/1176.diet-plan-performance/README.md b/Algorithms/1176.diet-plan-performance/README.md new file mode 100755 index 000000000..f7370ce5f --- /dev/null +++ b/Algorithms/1176.diet-plan-performance/README.md @@ -0,0 +1,41 @@ +# [1176. Diet Plan Performance](https://leetcode.com/problems/diet-plan-performance/) + +A dieter consumes calories[i] calories on the i-th day. For every consecutive sequence of k days,they look at T, the total calories consumed during that sequence of k days: + +- If T < lower, they performed poorly on their diet and lose 1 point; +- If T > upper, they performed well on their diet and gain 1 point; +- Otherwise, they performed normally and there is no change in points. + +Return the total number of points the dieter has after all calories.length days. + +Note that: The total points could be negative. + +Example 1: + +```text +Input: calories = [1,2,3,4,5], k = 1, lower = 3, upper = 3 +Output: 0 +Explanation: calories[0], calories[1] < lower and calories[3], calories[4] > upper, total points = 0.` +``` + +Example 2: + +```text +Input: calories = [3,2], k = 2, lower = 0, upper = 1 +Output: 1 +Explanation: calories[0] + calories[1] > upper, total points = 1. +``` + +Example 3: + +```text +Input: calories = [6,5,0,0], k = 2, lower = 1, upper = 5 +Output: 0 +Explanation: calories[0] + calories[1] > upper, calories[2] + calories[3] < lower, total points = 0. +``` + +Constraints: + +- `1 <= k <= calories.length <= 10^5` +- `0 <= calories[i] <= 20000` +- `0 <= lower <= upper` diff --git a/Algorithms/1176.diet-plan-performance/diet-plan-performance.go b/Algorithms/1176.diet-plan-performance/diet-plan-performance.go new file mode 100755 index 000000000..3c3f78af8 --- /dev/null +++ b/Algorithms/1176.diet-plan-performance/diet-plan-performance.go @@ -0,0 +1,28 @@ +package problem1176 + +func dietPlanPerformance(calories []int, k int, lower int, upper int) int { + point := func(t int) int { + if t < lower { + return -1 + } + if t > upper { + return 1 + } + return 0 + } + + T := 0 + res := 0 + for i, c := range calories { + T += c + if i < k-1 { + continue + } + if i-k >= 0 { + T -= calories[i-k] + } + res += point(T) + } + + return res +} diff --git a/Algorithms/1176.diet-plan-performance/diet-plan-performance_test.go b/Algorithms/1176.diet-plan-performance/diet-plan-performance_test.go new file mode 100755 index 000000000..1f5e17286 --- /dev/null +++ b/Algorithms/1176.diet-plan-performance/diet-plan-performance_test.go @@ -0,0 +1,59 @@ +package problem1176 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + calories []int + k int + lower int + upper int + ans int +}{ + + { + []int{1, 2, 3, 4, 5}, + 1, + 3, + 3, + 0, + }, + + { + []int{3, 2}, + 2, + 0, + 1, + 1, + }, + + { + []int{6, 5, 0, 0}, + 2, + 1, + 5, + 0, + }, + + // 可以有多个 testcase +} + +func Test_dietPlanPerformance(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, dietPlanPerformance(tc.calories, tc.k, tc.lower, tc.upper), "输入:%v", tc) + } +} + +func Benchmark_dietPlanPerformance(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + dietPlanPerformance(tc.calories, tc.k, tc.lower, tc.upper) + } + } +} diff --git a/Algorithms/1177.can-make-palindrome-from-substring/README.md b/Algorithms/1177.can-make-palindrome-from-substring/README.md new file mode 100755 index 000000000..d6293a6f8 --- /dev/null +++ b/Algorithms/1177.can-make-palindrome-from-substring/README.md @@ -0,0 +1,31 @@ +# [1177. Can Make Palindrome from Substring](https://leetcode.com/problems/can-make-palindrome-from-substring/) + +Given a string s, we make queries on substrings of s. + +For each query queries[i] = [left, right, k], we may rearrange the substring s[left], ..., s[right], and then choose up to k of them to replace with any lowercase English letter. + +If the substring is possible to be a palindrome string after the operations above, the result of the query is true. Otherwise, the result is false. + +Return an array answer[], where answer[i] is the result of the i-th query queries[i]. + +Note that: Each letter is counted individually for replacement so if for example s[left..right] = "aaa", and k = 2, we can only replace two of the letters. (Also, note that the initial string s is never modified by any query.) + +Example : + +```text +Input: s = "abcda", queries = [[3,3,0],[1,2,0],[0,3,1],[0,3,2],[0,4,1]] +Output: [true,false,false,true,true] +Explanation: +queries[0] : substring = "d", is palindrome. +queries[1] : substring = "bc", is not palindrome. +queries[2] : substring = "abcd", is not palindrome after replacing only 1 character. +queries[3] : substring = "abcd", could be changed to "abba" which is palindrome. Also this can be changed to "baab" first rearrange it "bacd" then replace "cd" with "ab". +queries[4] : substring = "abcda", could be changed to "abcba" which is palindrome. +``` + +Constraints: + +- `1 <= s.length, queries.length <= 10^5` +- `0 <= queries[i][0] <= queries[i][1] < s.length` +- `0 <= queries[i][2] <= s.length` +- `s only contains lowercase English letters.` diff --git a/Algorithms/1177.can-make-palindrome-from-substring/can-make-palindrome-from-substring.go b/Algorithms/1177.can-make-palindrome-from-substring/can-make-palindrome-from-substring.go new file mode 100755 index 000000000..5ecd7e33e --- /dev/null +++ b/Algorithms/1177.can-make-palindrome-from-substring/can-make-palindrome-from-substring.go @@ -0,0 +1,36 @@ +package problem1177 + +// TODO: unaccepted. the biggest test case spent 4500 ms. Limit Time Exceeded. + +func canMakePaliQueries(s string, queries [][]int) []bool { + n := len(queries) + + cnt := make([]int, 1, n+1) + c := 0 + for _, l := range s { + c ^= 1 << uint(l-'a') + cnt = append(cnt, c) + } + + res := make([]bool, n) + for i, q := range queries { + lo, hi, k := q[0], q[1], q[2] + if k >= 13 { + res[i] = true + continue + } + remains := bits(cnt[hi+1] ^ cnt[lo]) + res[i] = remains/2 <= k + } + + return res +} + +func bits(n int) int { + res := 0 + for n > 0 { + res += n & 1 + n >>= 1 + } + return res +} diff --git a/Algorithms/1177.can-make-palindrome-from-substring/can-make-palindrome-from-substring_test.go b/Algorithms/1177.can-make-palindrome-from-substring/can-make-palindrome-from-substring_test.go new file mode 100755 index 000000000..07f611166 --- /dev/null +++ b/Algorithms/1177.can-make-palindrome-from-substring/can-make-palindrome-from-substring_test.go @@ -0,0 +1,45 @@ +package problem1177 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + s string + queries [][]int + ans []bool +}{ + + { +"lybypsnwvozshezupkrubmrapgbsbininmjmjkbkjkvoxcpqrsvwfshmtulqrypyhofubmnylkrapqhgxgdofcvmrylqpejqbalahwryrkzavgdmdgtqpgpmjghexybyrgzczyhafcdqbgncrcbihkdmhunuzqrkzsnidwbunszulspmhwpazoxijwbqpapmretkborsrurgtinansnupotstmnkfcfavaxglyzebsbuxmtcfmtodclszghejevmhcvshclydqrulwbyhajgtargjctqvijshexyjcjcrepyzazexujqtsjebcnadahobwfuvirivwbkdijstyjgdahmtutavapazcdspcnolsvmlorqxazglyjqfmtclsfaxchgjavqrifqbkzspazwnczivetoxqjclwbwtibqvelwxsdazixefcvarevabmfabqfivodqfaluxqpcxwfkzyxabytijcnohgzgbchwpshwnufcvqfcnglshwpgxujwrylqzejmdubkxsbctsfwdelkdqzshupmrufyxklsjurevipyfobudkbgpqtadspgvinafefktctinyvgfkpurgrihwbkjsrybmnqrgnubufebatwberilmrejgzsbqpkdonytkbknstsxifofmrktcpqhklcrebcjipetgnmlqvijovmlgripwratarmtmvkpujoxebyvmjqbmbsrcvejqpodehsjingfetapqpypwrcjsjsfotqzcdmvmfinetotshixutorylcnqdmvsdopkvqvejijcdyxetuzonuhuzkpelmvabklgfivmpozinybwlovcnafqfybodkhabyrglsnenkbergfcfyzatglgdolydcxyfyrmjcxmrepqnulwjipqvqparqvqrgjqtehglapuxqbihovktgzgtijohgfabwbmvcnwrmxcfcxabkxcvgbozmpspsbenazglyxkpibgzqbmpmlstotylonkvmhqjyxmnqzctonqtobahcrcbibgzgxopmtqvejqvudezchsloxizynabehqbyzknunobehkzqtktsrwbovohkvqhwrwvizebsrszcxepqrenilmvadqxuncpwhedknkdizqxkdczafixidorgfcnkrirmhmzqbcfuvojsxwraxedulixqfgvipenkfubgtyxujixspoxmhgvahqdmzmlyhajerqzwhydynkfslsrmvyhonyjenyrenojofafmnafmfyhyjebwhqpwhctqdkfctanypmxqxktqfwfgnwjqpsbgpydovufgfqbyvqpufujypcbmdupybalwpkbidypqbwhefijytypwdwbsharqdurkrslqlqlajodcpirubsryvudgpwncrmtypatunqpkhehuhkdmbctyxghsfktazkvwrkharmnqpwxyhejgvybifmncdorglsfqlidupyvcnypwvglormjirmdqnwnelyturkdobypezwvonqpubedetansrkjgzyzgpuxajgdajizelohidwdcxilkvytazgfozonwrkbalcpizgtmzuhkbsfefshmtctuvcrwjmzoncvihmlmvgdujopwrajuxmjefonivyvkncnwnkjaxkritkporsjazopevefqpmvkvctwhgnivoxqlwrmfyrslyjqlufgxkponkbgpqtifyhgbgdsvqvkjmritatgzspyfwpozuzwpujqfctepatuponctwpejwzmbwzarojohergrwzsjgjmnwfwjyxyhafstetgbydobynmxabavodsfwbqbevozkjkpwvwpgrwlabutilctsrgbgxorwjezspgxwredqjklabwterwzyzstwpobwjujwjkbyvcxytipcbotezezipavebqxcbkxarahalozyhetotejkrehilazkzgbsngrmxcloxexmvqzmfcvunongdgxotqbirwlyxqfijwduhivclefufubetsvefotmvwhstufgfqlspqpidwrmjexifslkzobcjqvwlevghglynojchkvufqnwxixqnercbabmxuhadmbsbabqzirgrcxazcxypmjebgxyzmlepcdezwbsjkjalgdotcjavojehsvaxkbslkrchgpapizsxydmpcjmloxydgzmrujypqzsnmrspmjspwpczetwtctqrkxafktihwzupidotwrufgbiruzujyvaxypibobwnejcfohwnwtwnqjqzkpulklivgfmtctaxihchencvyjipqvgvsjapghwhmhqjclmpwrqfavchutgpajutqdiholadqnkpmpwdqbifqbunypwrsnyjerwzcjabufutofgbqnylglinkrubebaxuhmtobutovoxqlcvorypijudsfmzilqvsnilmjinmvmdohabuzyrorkbanijqfebkjydkxsvotanwpipypwjkxoxkdojctmlufqvshahytslodyhynoxglqdyjqbizidwhcdmjshobodgdytsbefaxmfczilgvslqlchgdmhslmjahcrevehypctavipchurmnqxwfubqryhcdmpyvuxslkpengranercjmrejcdmnodyrcdczehuhkrgxgxwzuxwpmloxkxanghalshgbqhwnmzmfwhafszirozoroxsxcpwbedqvuxujaxcfebwzghylytodqdaronqdmzgzyvqnixangpopidibchobmdspetqfgnaduvsdqrofazqlijulstufkpipydijwvwvwhylmbixevorifidopalcbobutkhabafmdavelsfejwhwdixqvqvcdoxypgxwpgvqhmdehensngpyjijyxkdyroxcpibgfmlibuxynulmnulaxoxyhsrmxifkxubwpizadmjobmdofazynoxsngxarqzapejmlelidsbuxkfgdkpaxotelsjgnwzgdkdkxinubehytirahinixidqnizyfclcjcdyjgvsjqjetclaxqpinodihmzubkbopmxenshejqhgbkhyrgbmjoxifcbslcrghizopkvonuhqdgtotkjijqfgxefknipklurolotqboduzubebwdmjmxmdozytidajmbcnydevclojqrmvanklyxyfqrktsxktafkhcvajolyvaxmnuhavcfobwlsbcnadgvmjmbunipavmvgpydobypabebilyfslalutklytypibijgrodofmtshajcnivmjkjklgxirolybqnmtsfslovstgjadszojufsbmpsnefodwzkzeretgpstkbivsbinsvghsfolutulszyxonwbubgdupmhidsvoruzchyritodwpahydqnmxktmpcdwngzqbalovalcrmribapk", +[][]int{{3193,3223,3},{1926,3311,517},{519,3172,1953},{2572,3043,96},{245,1456,676},{1282,2683,1343},{1731,2764,576},{456,999,51},{417,1647,1083},{2030,2907,650},{1487,2571,939},{1556,2839,483},{365,1311,287},{1002,3287,195},{1691,2497,797},{2640,3103,409},{2841,3407,259},{1462,2481,241},{2567,3091,283},{284,771,358},{2933,2970,14},{946,2799,1187},{579,1922,364},{1608,1983,120},{785,3325,1271},{126,1083,621},{1631,1840,192},{692,1987,314},{1165,1212,15},{2730,3265,98},{1259,2318,562},{1712,2223,247},{313,3062,2181},{3110,3387,88},{327,708,271},{1740,2547,10},{245,836,220},{2898,3189,46},{2179,2421,225},{2808,3071,88},{2785,3144,0},{1198,3191,1705},{3151,3342,120},{3252,3315,63},{1661,2547,831},{618,3161,1829},{939,2160,708},{1424,2879,237},{649,1043,315},{1334,3407,1954},{3207,3221,1},{2508,3239,613},{3061,3078,7},{2802,2805,2},{2195,2268,39},{1688,3079,1150},{2065,3123,499},{2718,2749,11},{2495,3132,493},{3044,3235,43},{989,2568,987},{10,821,627},{1195,2560,689},{1680,2607,423},{2633,2685,13},{1078,3301,477},{631,2370,939},{1260,2571,1238},{2741,3312,115},{1762,3029,104},{707,1963,655},{216,439,163},{2513,3362,833},{1982,2985,835},{2783,2940,58},{2628,3019,235},{909,2800,1369},{2314,2507,40},{1211,1254,43},{784,1823,511},{2313,2533,145},{2534,2729,30},{3239,3267,9},{1612,3351,964},{3269,3314,28},{2306,3311,834},{1715,2994,517},{2456,2839,257},{1233,1486,237},{1374,1795,316},{2271,2490,105},{3396,3399,0},{3277,3400,94},{1450,1491,10},{2923,2926,3},{384,1679,40},{809,2932,822},{2166,2825,529},{1687,2732,709},{572,1099,388},{3061,3257,17},{1346,3333,321},{2467,2607,11},{232,1023,566},{2945,3350,1},{1086,2883,354},{2943,3026,69},{404,2071,180},{3117,3132,6},{3226,3377,59},{3211,3340,21},{1744,2623,296},{2921,3113,59},{3190,3227,31},{1623,2368,712},{3340,3383,12},{453,2131,479},{2114,2175,50},{1859,1888,14},{1784,1951,7},{881,2210,93},{382,1427,419},{2111,2487,291},{1012,1671,363},{2029,2089,25},{1290,2099,571},{203,507,51},{240,2351,1676},{3401,3401,1},{2006,2797,656},{3255,3404,112},{1228,2451,974},{2517,3211,7},{2354,3097,398},{2675,3083,45},{3384,3399,15},{2225,2233,1},{1102,2219,234},{1279,2087,483},{1556,2179,198},{3149,3285,133},{2938,2947,6},{219,2604,859},{688,3359,1670},{3401,3402,2},{1878,2583,92},{599,1760,1089},{236,1191,740},{3013,3173,65},{434,1901,896},{2435,3096,455},{1880,2551,571},{2529,2955,123},{3326,3373,39},{2319,3325,793},{1364,1403,38},{1117,2555,407},{602,2109,828},{3211,3372,22},{2880,3023,131},{1129,3300,859},{2726,3365,613},{2391,3069,273},{2060,3319,274},{1253,2117,113},{1570,2877,371},{851,2883,371},{648,2399,755},{1985,2083,75},{2382,3091,705},{2367,2528,104},{1556,2607,690},{2717,2959,3},{1338,3115,1368},{2763,3240,247},{2048,2351,115},{2393,3323,607},{1302,2931,874},{2375,2801,373},{2124,2367,38},{1957,2172,90},{2914,3203,150},{3283,3287,5},{2712,3327,511},{3105,3167,43},{638,3339,1750},{1471,1855,171},{2644,3127,194},{509,1495,131},{2986,3039,7},{875,3311,2397},{2624,3279,274},{2393,3314,509},{1110,2033,98},{2039,3405,601},{924,1995,8},{1061,2940,420},{610,3327,1029},{3299,3399,67},{1720,2975,946},{785,1363,155},{270,2541,415},{1887,2441,489},{1636,2139,13},{1165,1248,36},{1434,2505,1004},{2651,2778,23},{128,1007,488},{329,480,7},{2534,2539,3},{2791,2810,20},{2940,2999,18},{1909,2451,159},{2978,3007,4},{819,3005,1425},{3256,3399,8},{2081,2965,741},{1662,1705,11},{1455,1476,15},{580,2263,89},{2301,2859,311},{2362,3189,703},{1691,3263,293},{1280,1855,523},{2217,2654,413},{2742,3307,269},{823,2241,1141},{2172,2263,50},{3157,3310,56},{2002,2531,509},{1555,2167,367},{888,1719,733},{2449,2733,245},{2510,3163,426},{2191,3178,135},{452,3307,481},{1725,1970,181},{298,1763,613},{2571,2631,51},{3104,3375,28},{409,2649,1005},{742,947,126},{1879,3193,149},{1068,2823,1178},{3077,3166,38},{1810,3005,705},{2723,3065,133},{2648,2687,12},{2449,2976,446},{1678,2417,576},{2255,3232,266},{2372,2403,31},{941,3291,1047},{778,2037,129},{1963,2606,499},{272,2927,1791},{1193,2656,235},{694,2023,714},{1607,1628,10},{2028,2095,32},{21,1511,279},{18,2309,468},{2995,3226,93},{1224,2847,798},{1345,1994,177},{2302,2443,22},{1151,1937,461},{468,2523,1523},{797,2432,1004},{3306,3375,34},{2971,3090,0},{2704,3359,143},{633,1283,359},{1638,2451,291},{3239,3289,21},{2780,3223,367},{3173,3270,48},{834,2103,962},{2691,3000,266},{1624,1639,13},{849,1755,271},{3102,3343,100},{63,227,109},{2084,2575,77},{669,1169,439},{2394,2435,22},{1931,2178,53},{1056,2895,209},{889,1932,525},{358,2533,1578},{3031,3398,252},{3308,3335,21},{3173,3219,15},{2098,2313,210},{2371,2668,155},{1544,2695,1106},{721,2206,319},{3390,3405,0},{1551,2333,617},{2404,2983,569},{2861,3219,159},{1498,2983,1127},{3355,3369,5},{2240,2895,120},{1929,1946,8},{1094,2827,1044},{583,3304,581},{1052,3087,990},{373,3318,12},{2002,2513,401},{2499,2755,45},{2312,2823,441},{2097,2465,359},{78,2523,2163},{367,2062,1032},{3044,3187,48},{877,2197,531},{778,1359,206},{1339,2107,281},{1088,2687,877},{2217,3351,35},{1350,2669,268},{983,2790,1780},{1820,2803,838},{2005,3164,893},{722,2487,981},{3,1088,425},{792,959,126},{977,1777,675},{1422,2325,749},{927,3323,59},{484,1939,106},{717,3180,142},{1770,3105,693},{2875,3250,291},{2384,3039,420},{1273,2654,290},{1670,2493,202},{2103,2259,89},{2268,3155,698},{2293,3252,946},{1346,1613,104},{2611,2816,84},{1320,1527,69},{561,2252,583},{1166,1593,428},{639,2525,1177},{564,3111,592},{2701,3063,191},{1978,2863,322},{2107,2734,393},{1664,2415,739},{1049,1927,211},{2550,2771,61},{711,2098,1121},{2764,3015,246},{2325,2844,68},{2338,2623,239},{2195,2573,161},{3016,3167,80},{353,1153,581},{1662,1769,102},{591,2905,561},{356,2203,1506},{2877,3269,195},{1930,3203,27},{1019,1790,624},{928,1551,568},{409,2571,1503},{2982,3043,49},{151,2192,1169},{3068,3083,4},{3333,3374,8},{2434,2485,49},{2947,3128,29},{1576,2223,263},{3361,3376,0},{2942,3383,424},{191,2525,537},{2820,3143,189},{3197,3252,32},{538,1955,1381},{2395,2682,30},{2976,3135,152},{1993,3017,139},{1142,1523,213},{3015,3329,133},{268,1743,1091},{1125,2018,293},{3282,3405,59},{2771,3355,353},{2856,3191,249},{81,764,256},{1038,2795,1579},{511,3009,1197},{404,535,10},{3197,3242,3},{2554,3263,98},{2011,2940,610},{192,303,21},{2025,2576,113},{1366,2883,486},{871,2808,1522},{1644,2023,45},{2981,3098,95},{2642,2861,9},{1587,1864,56},{2296,3087,449},{3137,3291,123},{1854,2477,153},{1887,3105,217},{1220,3039,788},{2765,2901,5},{2810,3117,276},{2411,2990,423},{656,1615,447},{441,1193,287},{1734,3369,365},{759,2289,717},{684,1831,182},{869,1488,70},{1746,2627,529},{2707,3100,86},{2488,2623,136},{161,2708,972},{3006,3101,17},{2815,3037,73},{1092,1895,322},{1021,3248,908},{330,3217,271},{2523,2862,238},{240,2911,2423},{2745,3015,195},{3350,3355,3},{3351,3358,3},{396,2251,1214},{2245,3377,591},{2338,3403,535},{2979,3112,114},{1672,3095,601},{1825,1851,15},{2094,2489,217},{95,2307,1617},{1988,2191,129},{1645,2158,47},{3322,3353,30},{2747,3392,587},{3216,3247,16},{2777,2891,71},{1894,2203,253},{1959,2884,69},{908,1303,249},{21,3110,619},{1186,1979,141},{1859,2238,178},{584,1975,325},{2017,2056,29},{2782,2861,34},{3039,3231,191},{2100,2403,205},{3085,3235,119},{2650,3321,490},{363,986,340},{2448,2463,14},{1609,3178,281},{934,2531,266},{231,2033,265},{332,3263,575},{2917,3360,205},{2434,2673,175},{995,1097,85},{2728,3407,316},{2833,3172,322},{2478,3071,272},{335,2612,812},{1156,2099,339},{3405,3407,3},{1962,3291,675},{1355,2034,108},{528,783,129},{617,2065,387},{2614,3285,503},{567,2333,817},{3244,3283,37},{3237,3312,41},{2,3303,2274},{1395,2485,1013},{3400,3407,5},{2609,3236,213},{862,2981,158},{415,1659,1197},{2836,3075,159},{125,1984,1292},{3226,3387,155},{1963,2693,193},{3264,3407,71},{57,456,112},{598,3031,917},{2119,2737,1},{2476,2771,128},{2837,3391,335},{2722,3215,64},{259,2426,356},{680,1655,746},{65,1139,495},{1246,2107,683},{207,1786,217},{3252,3347,50},{1629,2350,402},{1434,3349,572},{59,2157,1601},{1296,2351,106},{2121,2321,17},{1638,2099,47},{1959,3218,626},{1052,3239,208},{1621,3053,1099},{2930,2997,56},{787,2870,932},{936,1215,47},{1057,1071,11},{222,933,284},{1679,2029,169},{1892,3275,1183},{3341,3393,53},{42,2327,1380},{1259,2673,397},{1376,1679,273},{1417,2724,400},{2870,3159,245},{135,1058,59},{2940,3243,73},{2821,3099,151},{2066,2237,77},{675,2432,347},{2456,2511,26},{1761,2364,518},{526,1543,176},{831,3042,440},{1780,2659,1},{2157,3272,1024},{1850,2227,88},{2123,2182,37},{3120,3183,61},{2201,2210,7},{3190,3353,3},{1271,2888,350},{172,3111,1811},{2229,3006,249},{2242,2287,17},{339,3197,1757},{2312,3135,261},{561,1126,499},{1182,1215,20},{159,1338,1145},{2740,3151,201},{3005,3271,115},{3098,3101,4},{3371,3390,4},{2512,2559,3},{1913,3273,921},{1766,2769,124},{2215,3194,744},{2796,3255,259},{69,380,268},{994,1753,334},{1875,3044,923},{1096,3351,419},{1169,3026,1038},{1230,2573,88},{1151,1852,469},{1396,1899,292},{733,3001,2009},{650,3049,1327},{2283,3213,25},{1056,1471,408},{2425,2889,341},{406,1377,913},{7,173,65},{1228,2087,230},{1941,2002,45},{2322,2791,132},{195,2011,1031},{1256,2975,502},{2417,3234,6},{1038,3097,608},{1935,2771,531},{964,1487,230},{2685,3087,75},{234,2401,1534},{2907,3379,65},{3232,3295,55},{153,1294,175},{2662,2665,3},{567,2097,1165},{140,1915,602},{741,892,116},{2930,3365,90},{2819,2856,26},{536,1703,260},{2769,3185,383},{2254,2873,427},{2751,3007,179},{3332,3351,3},{2733,3397,145},{3290,3309,20},{1851,3012,488},{3328,3407,79},{2345,2783,323},{2262,3145,78},{2375,2791,33},{1532,1571,24},{661,3175,403},{1650,2291,423},{1235,1984,745},{2920,3039,11},{17,2384,90},{1390,2895,930},{1663,2819,919},{724,2675,1207},{2733,3158,66},{58,2537,1148},{635,2636,1291},{2624,3103,175},{1561,2738,651},{1126,2297,1084},{343,1330,416},{540,2275,468},{2133,2887,535},{2626,2949,279},{1475,1766,275},{3240,3367,72},{2913,3186,221},{430,2909,933},{2079,2423,301},{740,2091,674},{1709,2984,903},{2138,2255,116},{1947,2122,29},{2384,2927,430},{41,1490,139},{1622,2431,233},{871,1025,21},{2252,3115,22},{3285,3293,1},{370,1033,142},{1699,2006,125},{1112,1463,321},{3105,3369,179},{1390,2057,373},{655,3250,299},{628,1803,427},{3261,3375,95},{298,2415,1404},{539,3347,2515},{576,3343,1853},{3209,3295,19},{3078,3243,133},{1639,2786,519},{860,2167,1269},{1861,1952,79},{3362,3405,5},{2115,2813,485},{744,3087,2100},{1153,1820,579},{30,3119,2189},{1231,2679,989},{2596,3375,235},{1869,2161,207},{3258,3301,31},{331,1175,479},{976,1615,207},{2793,2872,13},{726,1733,600},{919,2086,494},{3356,3407,23},{3173,3222,1},{658,1291,398},{307,2149,645},{1048,1311,51},{2961,3066,60},{3150,3247,59},{1887,1947,35},{3396,3407,5},{2173,3190,625},{810,2805,962},{2843,3018,98},{1584,2815,311},{1705,2089,201},{1222,2045,718},{2247,2782,176},{572,2571,1882},{613,2199,519},{706,2279,776},{3363,3385,21},{1512,2695,245},{993,1900,676},{1406,2175,769},{223,413,89},{1988,2511,335},{1821,2231,151},{2730,3021,149},{1819,2587,309},{2240,2799,231},{73,822,163},{918,1835,229},{855,1597,209},{2412,2995,314},{2133,3155,751},{2770,3207,38},{1491,2861,849},{1672,3127,1112},{657,3032,1073},{1150,2011,231},{3119,3255,93},{2388,3215,129},{2029,3243,7},{1514,3253,163},{3067,3107,11},{2512,2655,127},{1881,2054,74},{1158,1223,40},{2231,2782,124},{476,2739,1421},{517,2743,607},{2994,3295,210},{2627,3319,641},{1240,3223,369},{705,2176,1451},{382,2035,1494},{1119,2914,347},{148,1995,374},{1069,3260,155},{58,1977,1727},{3131,3187,3},{928,2655,206},{2265,3348,713},{2886,3265,310},{2919,3249,1},{1596,2163,19},{2197,3020,330},{2594,2997,332},{2003,2007,3},{648,3071,1348},{2401,3156,580},{3150,3349,60},{2127,2511,195},{868,1911,797},{2285,2590,287},{10,2891,942},{2939,3195,257},{2400,2799,159},{3097,3257,5},{198,2923,446},{1687,2936,701},{2220,2347,71},{725,2865,841},{770,3191,2190},{1107,1599,253},{24,1847,730},{1345,3240,473},{430,2785,301},{1103,1524,378},{1988,2735,54},{1421,2618,700},{714,1033,166},{507,2760,701},{32,1471,752},{3193,3240,15},{518,877,242},{3111,3219,27},{2284,2699,76},{3365,3388,0},{978,1501,492},{211,2519,1177},{2472,2871,42},{1265,1370,83},{3054,3215,0},{2255,2482,65},{836,2899,118},{2605,2707,95},{2186,2799,423},{2923,3398,211},{2512,2591,42},{2713,3386,315},{2342,2999,516},{1911,1958,47},{2444,2455,10},{517,1539,991},{2770,3109,30},{2595,2930,200},{472,1599,278},{1809,1965,135},{1166,2635,1275},{2223,3112,342},{2660,2987,112},{1645,2970,686},{42,2615,2371},{2891,3060,44},{2288,2607,112},{2985,3192,87},{70,1769,1700},{2295,3082,594},{3068,3375,280},{1061,2500,215},{1138,1641,340},{835,1329,141},{840,1207,21},{2801,3017,5},{3054,3285,223},{1375,3110,1388},{2036,3115,997},{3277,3310,3},{1514,2027,339},{395,2858,2289},{1200,1279,77},{3225,3359,27},{2374,3339,67},{2871,3081,61},{1628,1635,5},{1653,2624,688},{994,1607,8},{2915,3123,17},{3064,3255,155},{3201,3290,5},{1006,1271,112},{2495,2927,37},{2484,2899,147},{3341,3376,15},{3130,3213,65},{2171,3324,391},{224,847,202},{1337,3222,768},{1414,1953,167},{1063,3091,81},{2764,3131,115},{3013,3137,27},{1394,1529,83},{3171,3384,89},{2104,2367,207},{2721,3264,106},{3102,3335,89},{895,966,10},{1684,2955,817},{1997,2362,112},{2458,2757,224},{2187,2818,538},{2768,3295,331},{617,2382,1143},{1414,3147,598},{71,1117,33},{1468,1591,76},{2389,2675,95},{3394,3403,2},{1315,2510,284},{552,1247,64},{1665,2865,967},{2254,2873,380},{3375,3387,7},{2804,3031,3},{3405,3406,0},{362,819,323},{2187,3287,139},{1840,2639,620},{1193,2383,467},{2086,2677,93},{2791,2838,28},{1532,3327,1284},{2085,2676,562},{2946,3089,87},{835,1844,694},{1192,1895,549},{2401,2975,315},{334,2501,1581},{655,2017,881},{2516,2547,9},{1533,1965,265},{1050,3213,628},{2507,2566,30},{880,2847,130},{3177,3254,12},{1302,3115,925},{2375,2922,378},{732,3379,1210},{1285,2621,895},{2514,2597,74},{1059,2935,375},{456,2479,904},{1825,2968,563},{2782,3405,257},{1407,2864,329},{2196,3259,614},{2733,3184,75},{2330,3385,994},{507,2705,389},{16,2287,207},{3129,3187,35},{2710,2779,55},{855,951,71},{220,1735,1440},{1541,2722,117},{882,2675,99},{2755,3018,70},{2744,3071,254},{2865,2897,31},{2174,2847,120},{2415,3292,812},{52,2779,2132},{2381,2535,23},{362,547,127},{555,2224,1530},{3072,3343,228},{2777,3367,163},{1622,1871,40},{2791,2811,7},{2876,3315,410},{1509,3250,1515},{1522,2325,755},{403,2166,1597},{1000,2271,227},{2449,2970,138},{3230,3353,86},{3375,3400,24},{1108,1827,551},{925,1221,41},{714,939,180},{2411,3219,665},{480,2303,1102},{2905,2947,15},{1350,1487,1},{2743,2961,185},{44,591,538},{1861,2643,719},{1218,2793,231},{3075,3293,193},{2792,3079,229},{209,1751,659},{1918,2565,162},{2319,2847,279},{180,843,513},{349,2373,1629},{3066,3195,107},{363,2299,229},{2864,3263,66},{1833,2673,773},{2438,2953,511},{1367,2354,335},{2124,2667,255},{277,2332,1669},{2146,3203,659},{2179,2794,480},{312,3135,2363},{49,1297,1077},{1230,1585,116},{1343,2950,1192},{2500,2715,83},{3389,3402,14},{1114,1709,518},{2555,3225,165},{816,1839,763},{505,774,70},{2950,3243,200},{2807,3170,66},{220,3239,1388},{1525,1950,312},{1874,1913,23},{2819,3009,125},{1816,2551,56},{353,2836,1762},{1262,2047,667},{751,2035,1257},{2228,2923,656},{77,1246,641},{2394,2423,3},{747,809,21},{1808,2591,25},{1513,2764,19},{3286,3311,10},{3319,3395,67},{1548,3263,1238},{85,1084,373},{1970,1989,20},{2531,3111,289},{952,1095,56},{945,2747,183},{1294,1443,91},{2911,3241,161},{3396,3403,8},{1117,2834,525},{634,2515,428},{2907,3390,429},{176,3279,2421},{2793,3039,59},{1670,3191,1092},{3031,3257,93},{1292,2583,226},{1669,2449,651},{274,2325,1898},{595,1570,677},{3320,3399,16},{609,3176,468},{3374,3381,5},{2367,2643,227},{1860,1879,19},{3309,3312,2},{1130,1629,477},{59,368,172},{2960,3263,53},{697,2682,1240},{550,3125,956},{1031,1828,623},{1676,2223,111},{1909,2121,25},{2994,3201,207},{2563,3059,221},{2936,2975,28},{961,1025,63},{1502,2045,19},{2303,3313,869},{1172,3379,1528},{1949,2835,375},{218,1015,565},{2715,3398,115},{544,2639,235},{3401,3404,3},{2598,3321,338},{1767,3082,631},{2156,3203,930},{981,2617,211},{3138,3399,146},{723,723,1},{2424,3295,654},{481,3036,1136},{2926,2969,28},{575,1391,163},{1716,2599,837},{3325,3363,7},{794,1235,385},{2779,2811,7},{2128,2591,156},{1913,3006,473},{2134,3257,469},{823,3261,1297},{1436,2607,529},{2757,2912,126},{1314,2595,137},{595,763,131},{1848,2671,66},{1713,2757,21},{3342,3357,5},{271,2351,835},{1604,2899,925},{1133,1735,491},{1354,1617,107},{427,456,8},{2368,2767,17},{153,1794,270},{54,739,56},{2407,3129,181},{3292,3347,28},{2517,3023,383},{1138,1449,289},{1827,2082,130},{696,1735,264},{1521,2641,545},{2126,2763,197},{2703,3070,105},{2788,2823,23},{2221,3057,5},{1418,2115,189},{939,2207,849},{2768,3071,79},{393,1555,931},{2806,2985,66},{2679,2826,111},{2956,3291,238},{1733,2852,880},{1906,2453,393},{2083,2233,69},{760,1999,478},{161,412,13},{3406,3407,2},{559,761,9},{692,2811,1989},{349,1009,463},{490,2361,1248},{2571,2910,166},{3040,3071,8},{2825,3203,287},{1862,1893,4},{1863,1928,58},{3196,3379,80},{1013,1869,89},{1570,2223,542},{755,2677,1337},{2200,2647,303},{2161,3155,467},{286,913,381},{1167,2205,601},{1956,2583,536},{557,1112,186},{2634,3213,152},{1595,3276,1033},{2784,3391,221},{2441,2707,135},{1366,3319,521},{2823,3230,28},{2876,3143,83},{1829,3145,23},{98,2127,1863},{2835,2848,7},{1896,2791,856},{2769,3107,67},{2366,3199,67},{1359,2571,231},{724,2215,455},{1805,3091,839},{2154,2979,821},{2939,3087,113},{864,2367,649},{2441,3337,147},{1286,1399,47},{855,911,45},{2412,2799,351},{453,2690,2218},{450,2361,235},{51,513,221},{648,927,278},{945,2935,51},{2590,3101,118},{2943,3033,45},{2740,2911,79},{2557,3021,379},{3002,3009,1},{2475,2582,40},{1984,2751,574},{953,2167,979},{902,2167,723},{1639,1671,25},{3340,3347,2},{3253,3393,47},{2450,2845,190},{2195,2403,59},{344,2687,509},{1265,3234,1024},{766,909,142},{3135,3201,33},{2612,2659,36},{2493,2600,20},{3226,3233,1},{331,1816,502},{3152,3183,15},{1849,2645,761},{630,967,192},{2519,2901,49},{364,2595,1067},{581,1314,2},{3058,3235,144},{3043,3326,121},{2712,3327,475},{17,534,355},{1054,2397,1003},{3231,3306,36},{580,587,0},{1709,2287,359},{1498,3249,430},{1835,2206,229},{2384,2463,80},{137,1120,936},{422,2929,671},{23,2743,1435},{2620,2643,4},{1813,2662,454},{818,1247,201},{211,617,245},{1880,2615,259},{2369,3284,149},{3006,3393,360},{3039,3358,305},{468,2991,1793},{3357,3400,0},{2442,2617,51},{2923,3127,61},{2880,3327,337},{185,1792,553},{310,3095,1534},{2391,2427,9},{1820,3047,291},{2469,2913,343},{1682,2727,904},{2851,3248,81},{2008,3247,589},{881,1448,399},{1054,1811,755},{2975,3131,89},{2100,2351,250},{2845,2870,25},{1866,3299,314},{923,1296,209},{800,3279,1450},{1097,3056,1543},{6,1455,1440},{775,1742,297},{2076,2551,357},{1973,2385,299},{434,1955,1018},{1587,2312,301},{3240,3375,72},{305,2530,118},{1118,1539,181},{367,2384,1100},{3060,3215,118},{941,2127,811},{954,1927,713},{59,2243,1073},{1024,1455,69},{2393,2575,155},{1910,2473,123},{231,1853,1121},{892,2123,1017},{1509,2491,687},{3250,3283,34},{1603,2242,370},{2200,2535,193},{1841,3321,1275},{2126,3161,143},{1663,3167,471},{276,2927,1641},{2077,3013,315},{90,1705,32},{1771,2181,277},{656,2271,688},{1689,3198,1217},{2902,3201,105},{1879,2158,120},{1324,2179,502},{565,823,159},{226,1733,1503},{147,2348,1794},{104,1231,343},{2673,3389,129},{478,2891,2379},{2367,2911,97},{3172,3299,20},{3101,3309,27},{618,2229,1046},{2107,2645,317},{3248,3343,91},{1033,1230,165},{1398,3131,71},{759,3259,273},{1436,2731,1031},{1125,2142,384},{2162,2739,297},{419,2827,473},{3320,3335,4},{1441,3388,1574},{750,2415,1402},{2687,2870,99},{1284,3359,135},{2749,3354,517},{2154,2663,172},{1979,3318,521},{2064,3071,316},{1689,2322,548},{438,2679,254},{519,3378,188},{860,1823,443},{2613,2914,280},{3074,3289,104},{3171,3344,155},{152,1055,228},{641,2524,348},{2894,3143,243},{431,3233,397},{1156,3263,317},{1901,3371,663},{1850,2159,309},{3115,3308,35},{960,3311,248},{2265,3252,600},{470,1203,652},{2327,3006,648},{1820,2891,833},{2645,2662,0},{2242,2263,17},{3331,3362,20},{776,2087,1197},{913,1414,163},{1182,2887,20},{2191,3052,627},{2388,3039,341},{1613,1722,13},{2282,2431,80},{1035,1136,67},{2848,3023,65},{649,665,17},{1830,2075,245},{1719,2722,825},{1372,2391,94},{3173,3282,55},{2402,3089,9},{659,1250,120},{1480,2063,459},{2817,2888,64},{1982,3091,906},{1999,2704,426},{1876,1911,20},{909,3031,415},{506,2351,1581},{827,1989,153},{2000,2383,286},{1145,2625,1315},{1126,1569,204},{3239,3378,5},{1852,2203,42},{3157,3382,35},{642,3013,768},{1763,2308,493},{552,3295,2395},{2257,2809,265},{1342,1459,66},{3343,3379,11},{3300,3331,28},{141,2825,1357},{1210,2947,1472},{3371,3398,21},{2704,2879,86},{2793,3253,409},{758,1865,180},{3111,3217,101},{2252,2303,49},{1557,2927,447},{3186,3309,116},{1491,2073,461},{1176,1767,512},{1921,3321,991},{2670,3219,34},{511,1932,193},{1124,3403,773},{1677,3286,1401},{2906,3403,494},{3179,3346,114},{464,3119,102},{2169,2737,323},{2838,2847,4},{2663,3198,83},{236,523,133},{1093,1366,139},{3250,3407,68},{1795,2288,438},{1592,3023,398},{305,3280,977},{1582,2045,312},{2751,2815,65},{996,2747,1098},{1101,2455,171},{266,2609,494},{2507,3040,186},{2400,2815,22},{1289,2087,563},{1046,1409,95},{2519,2983,397},{2524,3291,630},{1125,1887,167},{3250,3261,8},{3331,3372,21},{888,919,15},{1441,3249,171},{1262,1831,364},{2943,3221,89},{1108,1939,150},{1549,2287,599},{2314,2417,42},{779,1061,225},{3280,3343,14},{921,1443,135},{1430,1931,500},{3239,3359,75},{588,927,109},{2853,3250,210},{3170,3269,29},{1827,2628,339},{2904,3047,81},{1793,1855,59},{1518,1837,192},{3135,3207,51},{1876,3371,1255},{2061,2586,82},{1354,1993,83},{843,3175,1061},{2192,2751,138},{57,2304,833},{838,943,51},{3351,3406,36},{2636,3303,477},{3365,3404,12},{1634,3089,216},{3267,3364,87},{2232,2447,81},{225,753,29},{94,2639,1117},{1951,2038,66},{2212,2319,54},{973,1991,923},{1450,2587,965},{1179,1411,115},{2592,3215,439},{1881,2059,55},{1798,2675,840},{1127,3180,689},{236,1115,392},{837,2989,1035},{3378,3385,5},{963,1595,161},{3240,3351,36},{945,2148,1094},{1710,2641,740},{415,2027,439},{1220,3339,458},{1677,2068,350},{1962,2213,66},{2843,3321,117},{1840,2591,116},{1689,2589,751},{870,2245,1164},{1287,2719,669},{428,1147,540},{2853,3100,135},{914,1539,305},{707,2475,65},{1192,3223,1723},{145,167,11},{3278,3285,2},{623,699,49},{2980,3039,22},{509,584,42},{1162,1805,472},{1547,1928,270},{2128,3023,149},{345,1358,95},{2166,2991,131},{983,2896,1225},{636,1839,524},{325,2689,2337},{2306,2927,57},{1891,2767,133},{3048,3383,281},{1489,1749,255},{3006,3075,54},{735,845,73},{1844,2355,444},{1933,2858,734},{3114,3125,10},{1755,1858,41},{1136,3263,1431},{1305,1371,31},{1238,2153,496},{1271,1304,20},{2796,3279,121},{1461,3256,479},{1538,1655,47},{2147,2214,22},{3288,3295,4},{3393,3393,1},{1214,1993,357},{1615,2953,85}}, +[]bool{false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, false, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, false, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true}, + }, + + { + "abcda", + [][]int{{3, 3, 0}, {1, 2, 0}, {0, 3, 1}, {0, 3, 2}, {0, 4, 1}}, + []bool{true, false, false, true, true}, + }, + + // 可以有多个 testcase +} + +func Test_canMakePaliQueries(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, canMakePaliQueries(tc.s, tc.queries), "输入:%v", tc) + } +} + +func Benchmark_canMakePaliQueries(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + canMakePaliQueries(tc.s, tc.queries) + } + } +} diff --git a/Algorithms/1178.number-of-valid-words-for-each-puzzle/README.md b/Algorithms/1178.number-of-valid-words-for-each-puzzle/README.md new file mode 100755 index 000000000..b1261b482 --- /dev/null +++ b/Algorithms/1178.number-of-valid-words-for-each-puzzle/README.md @@ -0,0 +1,34 @@ +# [1178. Number of Valid Words for Each Puzzle](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/) + +With respect to a given puzzle string, a word is valid if both the following conditions are satisfied: + +- word contains the first letter of puzzle. +- For each letter in word, that letter is in puzzle. +- For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid words are "beefed" (doesn't include "a") and "based" (includes "s" which isn't in the puzzle). + +Return an array answer, where answer[i] is the number of words in the given word list words that are valid with respect to the puzzle puzzles[i]. + +Example : + +```text +Input: +words = ["aaaa","asas","able","ability","actt","actor","access"], +puzzles = ["aboveyz","abrodyz","abslute","absoryz","actresz","gaswxyz"] +Output: [1,1,3,2,4,0] +Explanation: +1 valid word for "aboveyz" : "aaaa" +1 valid word for "abrodyz" : "aaaa" +3 valid words for "abslute" : "aaaa", "asas", "able" +2 valid words for "absoryz" : "aaaa", "asas" +4 valid words for "actresz" : "aaaa", "asas", "actt", "access" +There're no valid words for "gaswxyz" cause none of the words in the list contains letter 'g'. +``` + +Constraints: + +- `1 <= words.length <= 10^5` +- `4 <= words[i].length <= 50` +- `1 <= puzzles.length <= 10^4` +- `puzzles[i].length == 7` +- `words[i][j], puzzles[i][j] are English lowercase letters.` +- `Each puzzles[i] doesn't contain repeated characters.` diff --git a/Algorithms/1178.number-of-valid-words-for-each-puzzle/number-of-valid-words-for-each-puzzle.go b/Algorithms/1178.number-of-valid-words-for-each-puzzle/number-of-valid-words-for-each-puzzle.go new file mode 100755 index 000000000..5adbd531f --- /dev/null +++ b/Algorithms/1178.number-of-valid-words-for-each-puzzle/number-of-valid-words-for-each-puzzle.go @@ -0,0 +1,40 @@ +package problem1178 + +func findNumOfValidWords(words []string, puzzles []string) []int { + count := make(map[int]int, len(words)) + for _, w := range words { + count[mask(w)]++ + } + + res := make([]int, len(puzzles)) + + for i, p := range puzzles { + subs := subsWithHead(p) + for _, s := range subs { + res[i] += count[s] + } + } + + return res +} + +func mask(w string) int { + res := 0 + for _, l := range w { + res |= 1 << uint(l-'a') + } + return res +} + +func subsWithHead(p string) []int { + n := len(p) + res := make([]int, 1, 128) + res[0] = 1 << uint(p[0]-'a') + for i := 1; i < n; i++ { + x := 1 << uint(p[i]-'a') + for _, r := range res { + res = append(res, r|x) + } + } + return res +} diff --git a/Algorithms/1178.number-of-valid-words-for-each-puzzle/number-of-valid-words-for-each-puzzle_test.go b/Algorithms/1178.number-of-valid-words-for-each-puzzle/number-of-valid-words-for-each-puzzle_test.go new file mode 100755 index 000000000..c7a3675f2 --- /dev/null +++ b/Algorithms/1178.number-of-valid-words-for-each-puzzle/number-of-valid-words-for-each-puzzle_test.go @@ -0,0 +1,39 @@ +package problem1178 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + words []string + puzzles []string + ans []int +}{ + + { + []string{"aaaa", "asas", "able", "ability", "actt", "actor", "access"}, + []string{"aboveyz", "abrodyz", "abslute", "absoryz", "actresz", "gaswxyz"}, + []int{1, 1, 3, 2, 4, 0}, + }, + + // 可以有多个 testcase +} + +func Test_findNumOfValidWords(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, findNumOfValidWords(tc.words, tc.puzzles), "输入:%v", tc) + } +} + +func Benchmark_findNumOfValidWords(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + findNumOfValidWords(tc.words, tc.puzzles) + } + } +} diff --git a/Algorithms/1184.distance-between-bus-stops/1.jpg b/Algorithms/1184.distance-between-bus-stops/1.jpg new file mode 100644 index 000000000..a7809665f Binary files /dev/null and b/Algorithms/1184.distance-between-bus-stops/1.jpg differ diff --git a/Algorithms/1184.distance-between-bus-stops/2.jpg b/Algorithms/1184.distance-between-bus-stops/2.jpg new file mode 100644 index 000000000..c51417365 Binary files /dev/null and b/Algorithms/1184.distance-between-bus-stops/2.jpg differ diff --git a/Algorithms/1184.distance-between-bus-stops/3.jpg b/Algorithms/1184.distance-between-bus-stops/3.jpg new file mode 100644 index 000000000..829a374fd Binary files /dev/null and b/Algorithms/1184.distance-between-bus-stops/3.jpg differ diff --git a/Algorithms/1184.distance-between-bus-stops/README.md b/Algorithms/1184.distance-between-bus-stops/README.md new file mode 100755 index 000000000..2fd71dacc --- /dev/null +++ b/Algorithms/1184.distance-between-bus-stops/README.md @@ -0,0 +1,44 @@ +# [1184. Distance Between Bus Stops](https://leetcode.com/problems/distance-between-bus-stops/) + +A bus has n stops numbered from 0 to n - 1 that form a circle. We know the distance between all pairs of neighboring stops where distance[i] is the distance between the stops number i and (i + 1) % n. + +The bus goes along both directions i.e. clockwise and counterclockwise. + +Return the shortest distance between the given start and destination stops. + +Example 1: + +![1](1.jpg) + +```text +Input: distance = [1,2,3,4], start = 0, destination = 1 +Output: 1 +Explanation: Distance between 0 and 1 is 1 or 9, minimum is 1. +``` + +Example 2: + +![2](2.jpg) + +```text +Input: distance = [1,2,3,4], start = 0, destination = 2 +Output: 3 +Explanation: Distance between 0 and 2 is 3 or 7, minimum is 3. +``` + +Example 3: + +![3](3.jpg) + +```text +Input: distance = [1,2,3,4], start = 0, destination = 3 +Output: 4 +Explanation: Distance between 0 and 3 is 6 or 4, minimum is 4. +``` + +Constraints: + +- `1 <= n <= 10^4` +- `distance.length == n` +- `0 <= start, destination < n` +- `0 <= distance[i] <= 10^4` diff --git a/Algorithms/1184.distance-between-bus-stops/distance-between-bus-stops.go b/Algorithms/1184.distance-between-bus-stops/distance-between-bus-stops.go new file mode 100755 index 000000000..9af6767ee --- /dev/null +++ b/Algorithms/1184.distance-between-bus-stops/distance-between-bus-stops.go @@ -0,0 +1,24 @@ +package problem1184 + +func distanceBetweenBusStops(distance []int, start int, destination int) int { + if start > destination { + start, destination = destination, start + } + + total, part := 0, 0 + for i, d := range distance { + total += d + if start <= i && i < destination { + part += d + } + } + + return min(part, total-part) +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1184.distance-between-bus-stops/distance-between-bus-stops_test.go b/Algorithms/1184.distance-between-bus-stops/distance-between-bus-stops_test.go new file mode 100755 index 000000000..7465a3b49 --- /dev/null +++ b/Algorithms/1184.distance-between-bus-stops/distance-between-bus-stops_test.go @@ -0,0 +1,62 @@ +package problem1184 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + distance []int + start int + destination int + ans int +}{ + + { + []int{7, 10, 1, 12, 11, 14, 5, 0}, + 7, + 2, + 17, + }, + + { + []int{1, 2, 3, 4}, + 0, + 1, + 1, + }, + + { + []int{1, 2, 3, 4}, + 0, + 2, + 3, + }, + + { + []int{1, 2, 3, 4}, + 0, + 3, + 4, + }, + + // 可以有多个 testcase +} + +func Test_distanceBetweenBusStops(t *testing.T) { + ast := assert.New(t) + + for _, tc := range tcs { + ast.Equal(tc.ans, distanceBetweenBusStops(tc.distance, tc.start, tc.destination), "输入:%v", tc) + } +} + +func Benchmark_distanceBetweenBusStops(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + distanceBetweenBusStops(tc.distance, tc.start, tc.destination) + } + } +} diff --git a/Algorithms/1185.day-of-the-week/README.md b/Algorithms/1185.day-of-the-week/README.md new file mode 100755 index 000000000..3afceebea --- /dev/null +++ b/Algorithms/1185.day-of-the-week/README.md @@ -0,0 +1,32 @@ +# [1185. Day of the Week](https://leetcode.com/problems/day-of-the-week/) + +Given a date, return the corresponding day of the week for that date. + +The input is given as three integers representing the day, month and year respectively. + +Return the answer as one of the following values {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}. + +Example 1: + +```text +Input: day = 31, month = 8, year = 2019 +Output: "Saturday" +``` + +Example 2: + +```text +Input: day = 18, month = 7, year = 1999 +Output: "Sunday" +``` + +Example 3: + +```text +Input: day = 15, month = 8, year = 1993 +Output: "Sunday" +``` + +Constraints: + +- The given dates are valid dates between the years 1971 and 2100. diff --git a/Algorithms/1185.day-of-the-week/day-of-the-week.go b/Algorithms/1185.day-of-the-week/day-of-the-week.go new file mode 100755 index 000000000..a7cf9c5b0 --- /dev/null +++ b/Algorithms/1185.day-of-the-week/day-of-the-week.go @@ -0,0 +1,7 @@ +package problem1185 + +import "time" + +func dayOfTheWeek(day int, month int, year int) string { + return time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.Local).Weekday().String() +} diff --git a/Algorithms/1185.day-of-the-week/day-of-the-week_test.go b/Algorithms/1185.day-of-the-week/day-of-the-week_test.go new file mode 100755 index 000000000..0afde4f7f --- /dev/null +++ b/Algorithms/1185.day-of-the-week/day-of-the-week_test.go @@ -0,0 +1,55 @@ +package problem1185 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + day int + month int + year int + ans string +}{ + + { + 31, + 8, + 2019, + "Saturday", + }, + + { + 18, + 7, + 1999, + "Sunday", + }, + + { + 15, + 8, + 1993, + "Sunday", + }, + + // 可以有多个 testcase +} + +func Test_dayOfTheWeek(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, dayOfTheWeek(tc.day, tc.month, tc.year), "输入:%v", tc) + } +} + +func Benchmark_dayOfTheWeek(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + dayOfTheWeek(tc.day, tc.month, tc.year) + } + } +} diff --git a/Algorithms/1186.maximum-subarray-sum-with-one-deletion/README.md b/Algorithms/1186.maximum-subarray-sum-with-one-deletion/README.md new file mode 100755 index 000000000..f3a2e03dd --- /dev/null +++ b/Algorithms/1186.maximum-subarray-sum-with-one-deletion/README.md @@ -0,0 +1,34 @@ +# [1186. Maximum Subarray Sum with One Deletion](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/) + +Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion. In other words, you want to choose a subarray and optionally delete one element from it so that there is still at least one element left and the sum of the remaining elements is maximum possible. + +Note that the subarray needs to be non-empty after deleting one element. + +Example 1: + +```text +Input: arr = [1,-2,0,3] +Output: 4 +Explanation: Because we can choose [1, -2, 0, 3] and drop -2, thus the subarray [1, 0, 3] becomes the maximum value. +``` + +Example 2: + +```text +Input: arr = [1,-2,-2,3] +Output: 3 +Explanation: We just choose [3] and it's the maximum sum. +``` + +Example 3: + +```text +Input: arr = [-1,-1,-1,-1] +Output: -1 +Explanation: The final subarray needs to be non-empty. You can't choose [-1] and delete -1 from it, then get an empty subarray to make the sum equals to 0. +``` + +Constraints: + +- `1 <= arr.length <= 10^5` +- `-10^4 <= arr[i] <= 10^4` diff --git a/Algorithms/1186.maximum-subarray-sum-with-one-deletion/maximum-subarray-sum-with-one-deletion.go b/Algorithms/1186.maximum-subarray-sum-with-one-deletion/maximum-subarray-sum-with-one-deletion.go new file mode 100755 index 000000000..015877f8e --- /dev/null +++ b/Algorithms/1186.maximum-subarray-sum-with-one-deletion/maximum-subarray-sum-with-one-deletion.go @@ -0,0 +1,30 @@ +package problem1186 + +// ref: https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/discuss/377397/Intuitive-Java-Solution-With-Explanation + +func maximumSum(A []int) int { + n := len(A) + maxRightIs := make([]int, n) + maxLeftIs := make([]int, n) + maxRightIs[0] = A[0] + maxLeftIs[n-1] = A[n-1] + res := A[0] + for i := 1; i < n; i++ { + maxRightIs[i] = max(A[i], maxRightIs[i-1]+A[i]) + j := n - i - 1 + maxLeftIs[j] = max(A[j], A[j]+maxLeftIs[j+1]) + // 最大的子数组,也有可能是仅由一段组成 + res = max(res, maxRightIs[i]) + } + for i := 1; i < n-1; i++ { + res = max(res, maxRightIs[i-1]+maxLeftIs[i+1]) + } + return res +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} diff --git a/Algorithms/1186.maximum-subarray-sum-with-one-deletion/maximum-subarray-sum-with-one-deletion_test.go b/Algorithms/1186.maximum-subarray-sum-with-one-deletion/maximum-subarray-sum-with-one-deletion_test.go new file mode 100755 index 000000000..49d35ee7c --- /dev/null +++ b/Algorithms/1186.maximum-subarray-sum-with-one-deletion/maximum-subarray-sum-with-one-deletion_test.go @@ -0,0 +1,72 @@ +package problem1186 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + arr []int + ans int +}{ + +{ + []int{ -50 }, +-50, +}, + + { +[]int{ 1,-2,-2,3 }, +3, + }, + + { + []int{11, -10, -11, 8, 7, -6, 9, 4, 11, 6, 5, 0}, + 50, + }, + + { + []int{1, -4, -5, -2, 5, 0, -1, 2}, + 7, + }, + + { + []int{8, -1, 6, -7, -4, 5, -4, 7, -6}, + 17, + }, + + { + []int{1, -2, 0, 3}, + 4, + }, + + { + []int{1, -2, -2, 3}, + 3, + }, + + { + []int{-1, -1, -1, -1}, + -1, + }, + + // 可以有多个 testcase +} + +func Test_maximumSum(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, maximumSum(tc.arr), "输入:%v", tc) + } +} + +func Benchmark_maximumSum(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maximumSum(tc.arr) + } + } +} diff --git a/Algorithms/1189.maximum-number-of-balloons/1.jpeg b/Algorithms/1189.maximum-number-of-balloons/1.jpeg new file mode 100644 index 000000000..00c66e32e Binary files /dev/null and b/Algorithms/1189.maximum-number-of-balloons/1.jpeg differ diff --git a/Algorithms/1189.maximum-number-of-balloons/2.jpeg b/Algorithms/1189.maximum-number-of-balloons/2.jpeg new file mode 100644 index 000000000..1c5258c61 Binary files /dev/null and b/Algorithms/1189.maximum-number-of-balloons/2.jpeg differ diff --git a/Algorithms/1189.maximum-number-of-balloons/README.md b/Algorithms/1189.maximum-number-of-balloons/README.md new file mode 100755 index 000000000..4a5b872d9 --- /dev/null +++ b/Algorithms/1189.maximum-number-of-balloons/README.md @@ -0,0 +1,35 @@ +# [1189. Maximum Number of Balloons](https://leetcode.com/problems/maximum-number-of-balloons/) + +Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. + +You can use each character in text at most once. Return the maximum number of instances that can be formed. + +Example 1: + +![1](1.jpeg) + +```text +Input: text = "nlaebolko" +Output: 1 +``` + +Example 2: + +![2](2.jpeg) + +```text +Input: text = "loonbalxballpoon" +Output: 2 +``` + +Example 3: + +```text +Input: text = "leetcode" +Output: 0 +``` + +Constraints: + +- `1 <= text.length <= 10^4` +- `text consists of lower case English letters only.` diff --git a/Algorithms/1189.maximum-number-of-balloons/maximum-number-of-balloons.go b/Algorithms/1189.maximum-number-of-balloons/maximum-number-of-balloons.go new file mode 100755 index 000000000..2d4294709 --- /dev/null +++ b/Algorithms/1189.maximum-number-of-balloons/maximum-number-of-balloons.go @@ -0,0 +1,29 @@ +package problem1189 + +func maxNumberOfBalloons(text string) int { + b, a, l, o, n := 0, 0, 0, 0, 0 + for _, r := range text { + switch r { + case 'b': + b++ + case 'a': + a++ + case 'l': + l++ + case 'o': + o++ + case 'n': + n++ + } + } + res := min(b, min(a, n)) + res = min(res, min(l/2, o/2)) + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1189.maximum-number-of-balloons/maximum-number-of-balloons_test.go b/Algorithms/1189.maximum-number-of-balloons/maximum-number-of-balloons_test.go new file mode 100755 index 000000000..f0f7c6d9a --- /dev/null +++ b/Algorithms/1189.maximum-number-of-balloons/maximum-number-of-balloons_test.go @@ -0,0 +1,52 @@ +package problem1189 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + text string + ans int +}{ + + { + "nlaeolko", + 0, + }, + + { + "nlaebolko", + 1, + }, + + { + "loonbalxballpoon", + 2, + }, + + { + "leetcode", + 0, + }, + + // 可以有多个 testcase +} + +func Test_maxNumberOfBalloons(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, maxNumberOfBalloons(tc.text), "输入:%v", tc) + } +} + +func Benchmark_maxNumberOfBalloons(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + maxNumberOfBalloons(tc.text) + } + } +} diff --git a/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/README.md b/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/README.md new file mode 100755 index 000000000..f1d0bb5a2 --- /dev/null +++ b/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/README.md @@ -0,0 +1,43 @@ +# [1190. Reverse Substrings Between Each Pair of Parentheses](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/) + +You are given a string s that consists of lower case English letters and brackets. + +Reverse the strings in each pair of matching parentheses, starting from the innermost one. + +Your result should not contain any brackets. + +Example 1: + +```text +Input: s = "(abcd)" +Output: "dcba" +``` + +Example 2: + +```text +Input: s = "(u(love)i)" +Output: "iloveu" +Explanation: The substring "love" is reversed first, then the whole string is reversed. +``` + +Example 3: + +```text +Input: s = "(ed(et(oc))el)" +Output: "leetcode" +Explanation: First, we reverse the substring "oc", then "etco", and finally, the whole string. +``` + +Example 4: + +```text +Input: s = "a(bcdefghijkl(mno)p)q" +Output: "apmnolkjihgfedcbq" +``` + +Constraints: + +- 0 <= s.length <= 2000 +- s only contains lower case English characters and parentheses. +- It's guaranteed that all parentheses are balanced. diff --git a/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/reverse-substrings-between-each-pair-of-parentheses.go b/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/reverse-substrings-between-each-pair-of-parentheses.go new file mode 100755 index 000000000..0693d3b04 --- /dev/null +++ b/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/reverse-substrings-between-each-pair-of-parentheses.go @@ -0,0 +1,35 @@ +package problem1190 + +import "strings" + +// ref: https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/discuss/383670/JavaC%2B%2BPython-Why-not-O(N) + +func reverseParentheses(s string) string { + n := len(s) + stack, top := make([]int, n), -1 + pair := make([]int, n) + + for i := 0; i < n; i++ { + switch s[i] { + case '(': + top++ + stack[top] = i + case ')': + j := stack[top] + top-- + pair[i], pair[j] = j, i + } + } + var sb strings.Builder + + for i, d := 0, 1; i < n; i += d { + if s[i] == '(' || s[i] == ')' { + i = pair[i] + d = -d + } else { + sb.WriteByte(s[i]) + } + } + + return sb.String() +} diff --git a/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/reverse-substrings-between-each-pair-of-parentheses_test.go b/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/reverse-substrings-between-each-pair-of-parentheses_test.go new file mode 100755 index 000000000..b691d366d --- /dev/null +++ b/Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses/reverse-substrings-between-each-pair-of-parentheses_test.go @@ -0,0 +1,67 @@ +package problem1190 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + s string + ans string +}{ + + { + "(x(ab)y(cd)z)", + "zcdyabx", + }, + + { + "(uoy(love)mi(hate)ko)", + "okhateimloveyou", + }, + + { + "(u(love)i(love)k)", + "kloveiloveu", + }, + + { + "(abcd)", + "dcba", + }, + + { + "(u(love)i)", + "iloveu", + }, + + { + "(ed(et(oc))el)", + "leetcode", + }, + + { + "a(bcdefghijkl(mno)p)q", + "apmnolkjihgfedcbq", + }, + + // 可以有多个 testcase +} + +func Test_reverseParentheses(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, reverseParentheses(tc.s), "输入:%v", tc) + } +} + +func Benchmark_reverseParentheses(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + reverseParentheses(tc.s) + } + } +} diff --git a/Algorithms/1200.minimum-absolute-difference/README.md b/Algorithms/1200.minimum-absolute-difference/README.md new file mode 100755 index 000000000..003216b21 --- /dev/null +++ b/Algorithms/1200.minimum-absolute-difference/README.md @@ -0,0 +1,36 @@ +# [1200. Minimum Absolute Difference](https://leetcode.com/problems/minimum-absolute-difference/) + +Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements. + +Return a list of pairs in ascending order(with respect to pairs), each pair [a, b] follows + +- a, b are from arr +- a < b +- b - a equals to the minimum absolute difference of any two elements in arr + +Example 1: + +```text +Input: arr = [4,2,1,3] +Output: [[1,2],[2,3],[3,4]] +Explanation: The minimum absolute difference is 1. List all pairs with difference equal to 1 in ascending order. +``` + +Example 2: + +```text +Input: arr = [1,3,6,10,15] +Output: [[1,3]] +``` + +Example 3: + +```text +Input: arr = [3,8,-10,23,19,-4,-14,27] +Output: [[-14,-10],[19,23],[23,27]] +``` + +Constraints: + +- `2 <= arr.length <= 10^5` +- `-10^6 <= arr[i] <= 10^6` diff --git a/Algorithms/1200.minimum-absolute-difference/minimum-absolute-difference.go b/Algorithms/1200.minimum-absolute-difference/minimum-absolute-difference.go new file mode 100755 index 000000000..1a5afda7b --- /dev/null +++ b/Algorithms/1200.minimum-absolute-difference/minimum-absolute-difference.go @@ -0,0 +1,33 @@ +package problem1200 + +import ( + "math" + "sort" +) + +func minimumAbsDifference(A []int) [][]int { + sort.Ints(A) + n := len(A) + + minDiff := math.MaxInt64 + for i := 1; i < n; i++ { + minDiff = min(minDiff, A[i]-A[i-1]) + } + + res := make([][]int, 0, n) + + for i := 1; i < n; i++ { + if A[i]-A[i-1] == minDiff { + res = append(res, []int{A[i-1], A[i]}) + } + } + + return res +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1200.minimum-absolute-difference/minimum-absolute-difference_test.go b/Algorithms/1200.minimum-absolute-difference/minimum-absolute-difference_test.go new file mode 100755 index 000000000..d53f38683 --- /dev/null +++ b/Algorithms/1200.minimum-absolute-difference/minimum-absolute-difference_test.go @@ -0,0 +1,47 @@ +package problem1200 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + arr []int + ans [][]int +}{ + + { + []int{4, 2, 1, 3}, + [][]int{{1, 2}, {2, 3}, {3, 4}}, + }, + + { + []int{1, 3, 6, 10, 15}, + [][]int{{1, 3}}, + }, + + { + []int{3, 8, -10, 23, 19, -4, -14, 27}, + [][]int{{-14, -10}, {19, 23}, {23, 27}}, + }, + + // 可以有多个 testcase +} + +func Test_minimumAbsDifference(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, minimumAbsDifference(tc.arr), "输入:%v", tc) + } +} + +func Benchmark_minimumAbsDifference(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minimumAbsDifference(tc.arr) + } + } +} diff --git a/Algorithms/1202.smallest-string-with-swaps/README.md b/Algorithms/1202.smallest-string-with-swaps/README.md new file mode 100755 index 000000000..946ce063f --- /dev/null +++ b/Algorithms/1202.smallest-string-with-swaps/README.md @@ -0,0 +1,46 @@ +# [1202. Smallest String With Swaps](https://leetcode.com/problems/smallest-string-with-swaps/) + +You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string. + +You can swap the characters at any pair of indices in the given pairs any number of times. + +Return the lexicographically smallest string that s can be changed to after using the swaps. + +Example 1: + +```text +Input: s = "dcab", pairs = [[0,3],[1,2]] +Output: "bacd" +Explanation: +Swap s[0] and s[3], s = "bcad" +Swap s[1] and s[2], s = "bacd" +``` + +Example 2: + +```text +Input: s = "dcab", pairs = [[0,3],[1,2],[0,2]] +Output: "abcd" +Explanation: +Swap s[0] and s[3], s = "bcad" +Swap s[0] and s[2], s = "acbd" +Swap s[1] and s[2], s = "abcd" +``` + +Example 3: + +```text +Input: s = "cba", pairs = [[0,1],[1,2]] +Output: "abc" +Explanation: +Swap s[0] and s[1], s = "bca" +Swap s[1] and s[2], s = "bac" +Swap s[0] and s[1], s = "abc" +``` + +Constraints: + +- `1 <= s.length <= 10^5` +- `0 <= pairs.length <= 10^5` +- `0 <= pairs[i][0], pairs[i][1] < s.length` +- `s only contains lower case English letters.` diff --git a/Algorithms/1202.smallest-string-with-swaps/smallest-string-with-swaps.go b/Algorithms/1202.smallest-string-with-swaps/smallest-string-with-swaps.go new file mode 100755 index 000000000..96b1e9528 --- /dev/null +++ b/Algorithms/1202.smallest-string-with-swaps/smallest-string-with-swaps.go @@ -0,0 +1,64 @@ +package problem1202 + +import "sort" + +func smallestStringWithSwaps(s string, pairs [][]int) string { + n := len(s) + uf := newUnionFind(n) + + for _, p := range pairs { + uf.connect(p[0], p[1]) + } + + groups := make(map[int][]int, n) + for c, p := range uf.parent { + p = uf.find(p) + // 相连的索引值,全部放在一起 + groups[p] = append(groups[p], c) + } + + bytes := []byte(s) + res := make([]byte, n) + for _, g := range groups { + size := len(g) + a := make([]int, size) + copy(a, g) + // a 中的索引值,按照其在 bytes 中对应的字符大小来排序 + sort.Slice(a, func(i, j int) bool { + return bytes[a[i]] < bytes[a[j]] + }) + // g 中的索引值,按照其自身的大小排序 + sort.Ints(g) + // 越小的位置,放入的值也越小 + for i := 0; i < size; i++ { + res[g[i]] = bytes[a[i]] + } + } + + return string(res) +} + +type unionFind struct { + parent []int +} + +func newUnionFind(size int) *unionFind { + parent := make([]int, size) + for i := range parent { + parent[i] = i + } + return &unionFind{ + parent: parent, + } +} + +func (uf *unionFind) connect(x, y int) { + uf.parent[uf.find(x)] = uf.find(y) +} + +func (uf *unionFind) find(i int) int { + if uf.parent[i] != i { + uf.parent[i] = uf.find(uf.parent[i]) + } + return uf.parent[i] +} diff --git a/Algorithms/1202.smallest-string-with-swaps/smallest-string-with-swaps_test.go b/Algorithms/1202.smallest-string-with-swaps/smallest-string-with-swaps_test.go new file mode 100755 index 000000000..636b8d4ec --- /dev/null +++ b/Algorithms/1202.smallest-string-with-swaps/smallest-string-with-swaps_test.go @@ -0,0 +1,51 @@ +package problem1202 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + s string + pairs [][]int + ans string +}{ + + { + "dcab", + [][]int{{0, 3}, {1, 2}}, + "bacd", + }, + + { + "dcab", + [][]int{{0, 3}, {1, 2}, {0, 2}}, + "abcd", + }, + + { + "cba", + [][]int{{0, 1}, {1, 2}}, + "abc", + }, + + // 可以有多个 testcase +} + +func Test_smallestStringWithSwaps(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, smallestStringWithSwaps(tc.s, tc.pairs), "输入:%v", tc) + } +} + +func Benchmark_smallestStringWithSwaps(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + smallestStringWithSwaps(tc.s, tc.pairs) + } + } +} diff --git a/Algorithms/1207.unique-number-of-occurrences/README.md b/Algorithms/1207.unique-number-of-occurrences/README.md new file mode 100755 index 000000000..09d7d3d16 --- /dev/null +++ b/Algorithms/1207.unique-number-of-occurrences/README.md @@ -0,0 +1,30 @@ +# [1207. Unique Number of Occurrences](https://leetcode.com/problems/unique-number-of-occurrences/) + +Given an array of integers arr, write a function that returns true if and only if the number of occurrences of each value in the array is unique. + +Example 1: + +```text +Input: arr = [1,2,2,1,1,3] +Output: true +Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. +``` + +Example 2: + +```text +Input: arr = [1,2] +Output: false +``` + +Example 3: + +```text +Input: arr = [-3,0,1,-3,1,1,1,-3,10,0] +Output: true +``` + +Constraints: + +- `1 <= arr.length <= 1000` +- `-1000 <= arr[i] <= 1000` diff --git a/Algorithms/1207.unique-number-of-occurrences/unique-number-of-occurrences.go b/Algorithms/1207.unique-number-of-occurrences/unique-number-of-occurrences.go new file mode 100755 index 000000000..fc2c7e5e3 --- /dev/null +++ b/Algorithms/1207.unique-number-of-occurrences/unique-number-of-occurrences.go @@ -0,0 +1,16 @@ +package problem1207 + +func uniqueOccurrences(A []int) bool { + count := make(map[int]int, len(A)) + for _, a := range A { + count[a]++ + } + hasSeen := make(map[int]bool, len(count)) + for _, c := range count { + if hasSeen[c] { + return false + } + hasSeen[c] = true + } + return true +} diff --git a/Algorithms/1207.unique-number-of-occurrences/unique-number-of-occurrences_test.go b/Algorithms/1207.unique-number-of-occurrences/unique-number-of-occurrences_test.go new file mode 100755 index 000000000..63254aeeb --- /dev/null +++ b/Algorithms/1207.unique-number-of-occurrences/unique-number-of-occurrences_test.go @@ -0,0 +1,47 @@ +package problem1207 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + A []int + ans bool +}{ + + { + []int{1, 2, 2, 1, 1, 3}, + true, + }, + + { + []int{1, 2}, + false, + }, + + { + []int{-3, 0, 1, -3, 1, 1, 1, -3, 10, 0}, + true, + }, + + // 可以有多个 testcase +} + +func Test_uniqueOccurrences(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, uniqueOccurrences(tc.A), "输入:%v", tc) + } +} + +func Benchmark_uniqueOccurrences(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + uniqueOccurrences(tc.A) + } + } +} diff --git a/Algorithms/1217.play-with-chips/README.md b/Algorithms/1217.play-with-chips/README.md new file mode 100755 index 000000000..d083b1af3 --- /dev/null +++ b/Algorithms/1217.play-with-chips/README.md @@ -0,0 +1,32 @@ +# [1217. Play with Chips](https://leetcode.com/problems/play-with-chips/) + +There are some chips, and the i-th chip is at position chips[i]. + +You can perform any of the two following types of moves any number of times (possibly zero) on any chip: + +- Move the i-th chip by 2 units to the left or to the right with a cost of 0. +- Move the i-th chip by 1 unit to the left or to the right with a cost of 1. + +There can be two or more chips at the same position initially. + +Return the minimum cost needed to move all the chips to the same position (any position). + +Example 1: + +```text +Input: chips = [1,2,3] +Output: 1 +Explanation: Second chip will be moved to positon 3 with cost 1. First chip will be moved to position 3 with cost 0. Total cost is 1. +``` + +Example 2: + +```text +Input: chips = [2,2,2,3,3] +Output: 2 +Explanation: Both fourth and fifth chip will be moved to position two with cost 1. Total minimum cost will be 2. + +Constraints: + +- `1 <= chips.length <= 100` +- `1 <= chips[i] <= 10^9` diff --git a/Algorithms/1217.play-with-chips/play-with-chips.go b/Algorithms/1217.play-with-chips/play-with-chips.go new file mode 100755 index 000000000..3d0acab15 --- /dev/null +++ b/Algorithms/1217.play-with-chips/play-with-chips.go @@ -0,0 +1,20 @@ +package problem1217 + +func minCostToMoveChips(chips []int) int { + odd, even := 0, 0 + for _, p := range chips { + if p%2 == 0 { + even++ + } else { + odd++ + } + } + return min(odd, even) +} + +func min(a, b int) int { + if a < b { + return a + } + return b +} diff --git a/Algorithms/1217.play-with-chips/play-with-chips_test.go b/Algorithms/1217.play-with-chips/play-with-chips_test.go new file mode 100755 index 000000000..e9748d779 --- /dev/null +++ b/Algorithms/1217.play-with-chips/play-with-chips_test.go @@ -0,0 +1,42 @@ +package problem1217 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + chips []int + ans int +}{ + + { + []int{1, 2, 3}, + 1, + }, + + { + []int{2, 2, 2, 3, 3}, + 2, + }, + + // 可以有多个 testcase +} + +func Test_minCostToMoveChips(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, minCostToMoveChips(tc.chips), "输入:%v", tc) + } +} + +func Benchmark_minCostToMoveChips(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + minCostToMoveChips(tc.chips) + } + } +} diff --git a/Algorithms/1221.split-a-string-in-balanced-strings/README.md b/Algorithms/1221.split-a-string-in-balanced-strings/README.md new file mode 100755 index 000000000..6eadbaec3 --- /dev/null +++ b/Algorithms/1221.split-a-string-in-balanced-strings/README.md @@ -0,0 +1,36 @@ +# [1221. Split a String in Balanced Strings](https://leetcode.com/problems/split-a-string-in-balanced-strings/) + +Balanced strings are those who have equal quantity of 'L' and 'R' characters. + +Given a balanced string s split it in the maximum amount of balanced strings. + +Return the maximum amount of splitted balanced strings. + +Example 1: + +```text +Input: s = "RLRRLLRLRL" +Output: 4 +Explanation: s can be split into "RL", "RRLL", "RL", "RL", each substring contains same number of 'L' and 'R'. +``` + +Example 2: + +```text +Input: s = "RLLLLRRRLR" +Output: 3 +Explanation: s can be split into "RL", "LLLRRR", "LR", each substring contains same number of 'L' and 'R'. +``` + +Example 3: + +```text +Input: s = "LLLLRRRR" +Output: 1 +Explanation: s can be split into "LLLLRRRR". +``` + +Constraints: + +- `1 <= s.length <= 1000` +- `s[i] = 'L' or 'R'` diff --git a/Algorithms/1221.split-a-string-in-balanced-strings/split-a-string-in-balanced-strings.go b/Algorithms/1221.split-a-string-in-balanced-strings/split-a-string-in-balanced-strings.go new file mode 100755 index 000000000..4c6bf823a --- /dev/null +++ b/Algorithms/1221.split-a-string-in-balanced-strings/split-a-string-in-balanced-strings.go @@ -0,0 +1,16 @@ +package problem1221 + +func balancedStringSplit(s string) int { + res, count := 0, 0 + for _, b := range s { + if b == 'L' { + count++ + } else { + count-- + } + if count == 0 { + res++ + } + } + return res +} diff --git a/Algorithms/1221.split-a-string-in-balanced-strings/split-a-string-in-balanced-strings_test.go b/Algorithms/1221.split-a-string-in-balanced-strings/split-a-string-in-balanced-strings_test.go new file mode 100755 index 000000000..aa1084880 --- /dev/null +++ b/Algorithms/1221.split-a-string-in-balanced-strings/split-a-string-in-balanced-strings_test.go @@ -0,0 +1,47 @@ +package problem1221 + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +// tcs is testcase slice +var tcs = []struct { + s string + ans int +}{ + + { + "RLRRLLRLRL", + 4, + }, + + { + "RLLLLRRRLR", + 3, + }, + + { + "LLLLRRRR", + 1, + }, + + // 可以有多个 testcase +} + +func Test_balancedStringSplit(t *testing.T) { + a := assert.New(t) + + for _, tc := range tcs { + a.Equal(tc.ans, balancedStringSplit(tc.s), "输入:%v", tc) + } +} + +func Benchmark_balancedStringSplit(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, tc := range tcs { + balancedStringSplit(tc.s) + } + } +} diff --git a/Algorithms/go.mod b/Algorithms/go.mod new file mode 100644 index 000000000..c54be9340 --- /dev/null +++ b/Algorithms/go.mod @@ -0,0 +1,5 @@ +module github.com/aQuaYi/LeetCode-in-Go/Algorithms + +go 1.13 + +require github.com/stretchr/testify v1.4.0 diff --git a/Algorithms/go.sum b/Algorithms/go.sum new file mode 100644 index 000000000..e863f517e --- /dev/null +++ b/Algorithms/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/Favorite.md b/Favorite.md new file mode 100755 index 000000000..fa6485fbb --- /dev/null +++ b/Favorite.md @@ -0,0 +1,350 @@ +# 我收藏的 345 题 + +|题号|题目|通过率|难度|收藏| +|:-:|:-|:-: | :-: | :-: | +|[0085](https://leetcode.com/problems/maximal-rectangle/)|[Maximal Rectangle](./Algorithms/0085.maximal-rectangle)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0087](https://leetcode.com/problems/scramble-string/)|[Scramble String](./Algorithms/0087.scramble-string)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0093](https://leetcode.com/problems/restore-ip-addresses/)|[Restore IP Addresses](./Algorithms/0093.restore-ip-addresses)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0095](https://leetcode.com/problems/unique-binary-search-trees-ii/)|[Unique Binary Search Trees II](./Algorithms/0095.unique-binary-search-trees-ii)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0097](https://leetcode.com/problems/interleaving-string/)|[Interleaving String](./Algorithms/0097.interleaving-string)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0098](https://leetcode.com/problems/validate-binary-search-tree/)|[Validate Binary Search Tree](./Algorithms/0098.validate-binary-search-tree)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0099](https://leetcode.com/problems/recover-binary-search-tree/)|[Recover Binary Search Tree](./Algorithms/0099.recover-binary-search-tree)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0101](https://leetcode.com/problems/symmetric-tree/)|[Symmetric Tree](./Algorithms/0101.symmetric-tree)|44%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0105](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)|[Construct Binary Tree from Preorder and Inorder Traversal](./Algorithms/0105.construct-binary-tree-from-preorder-and-inorder-traversal)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0106](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/)|[Construct Binary Tree from Inorder and Postorder Traversal](./Algorithms/0106.construct-binary-tree-from-inorder-and-postorder-traversal)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0114](https://leetcode.com/problems/flatten-binary-tree-to-linked-list/)|[Flatten Binary Tree to Linked List](./Algorithms/0114.flatten-binary-tree-to-linked-list)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0115](https://leetcode.com/problems/distinct-subsequences/)|[Distinct Subsequences](./Algorithms/0115.distinct-subsequences)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0120](https://leetcode.com/problems/triangle/)|[Triangle](./Algorithms/0120.triangle)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0124](https://leetcode.com/problems/binary-tree-maximum-path-sum/)|[Binary Tree Maximum Path Sum](./Algorithms/0124.binary-tree-maximum-path-sum)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0126](https://leetcode.com/problems/word-ladder-ii/)|[Word Ladder II](./Algorithms/0126.word-ladder-ii)|19%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0127](https://leetcode.com/problems/word-ladder/)|[Word Ladder](./Algorithms/0127.word-ladder)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0130](https://leetcode.com/problems/surrounded-regions/)|[Surrounded Regions](./Algorithms/0130.surrounded-regions)|24%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0131](https://leetcode.com/problems/palindrome-partitioning/)|[Palindrome Partitioning](./Algorithms/0131.palindrome-partitioning)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0132](https://leetcode.com/problems/palindrome-partitioning-ii/)|[Palindrome Partitioning II](./Algorithms/0132.palindrome-partitioning-ii)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0134](https://leetcode.com/problems/gas-station/)|[Gas Station](./Algorithms/0134.gas-station)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0139](https://leetcode.com/problems/word-break/)|[Word Break](./Algorithms/0139.word-break)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0140](https://leetcode.com/problems/word-break-ii/)|[Word Break II](./Algorithms/0140.word-break-ii)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0142](https://leetcode.com/problems/linked-list-cycle-ii/)|[Linked List Cycle II](./Algorithms/0142.linked-list-cycle-ii)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0143](https://leetcode.com/problems/reorder-list/)|[Reorder List](./Algorithms/0143.reorder-list)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0144](https://leetcode.com/problems/binary-tree-preorder-traversal/)|[Binary Tree Preorder Traversal](./Algorithms/0144.binary-tree-preorder-traversal)|53%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0146](https://leetcode.com/problems/lru-cache/)|[LRU Cache](./Algorithms/0146.lru-cache)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0147](https://leetcode.com/problems/insertion-sort-list/)|[Insertion Sort List](./Algorithms/0147.insertion-sort-list)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0148](https://leetcode.com/problems/sort-list/)|[Sort List](./Algorithms/0148.sort-list)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0149](https://leetcode.com/problems/max-points-on-a-line/)|[Max Points on a Line](./Algorithms/0149.max-points-on-a-line)|16%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0152](https://leetcode.com/problems/maximum-product-subarray/)|[Maximum Product Subarray](./Algorithms/0152.maximum-product-subarray)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0166](https://leetcode.com/problems/fraction-to-recurring-decimal/)|[Fraction to Recurring Decimal](./Algorithms/0166.fraction-to-recurring-decimal)|20%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0168](https://leetcode.com/problems/excel-sheet-column-title/)|[Excel Sheet Column Title](./Algorithms/0168.excel-sheet-column-title)|29%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0169](https://leetcode.com/problems/majority-element/)|[Majority Element](./Algorithms/0169.majority-element)|54%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0173](https://leetcode.com/problems/binary-search-tree-iterator/)|[Binary Search Tree Iterator](./Algorithms/0173.binary-search-tree-iterator)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0174](https://leetcode.com/problems/dungeon-game/)|[Dungeon Game](./Algorithms/0174.dungeon-game)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0179](https://leetcode.com/problems/largest-number/)|[Largest Number](./Algorithms/0179.largest-number)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0188](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/)|[Best Time to Buy and Sell Stock IV](./Algorithms/0188.best-time-to-buy-and-sell-stock-iv)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0198](https://leetcode.com/problems/house-robber/)|[House Robber](./Algorithms/0198.house-robber)|41%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0201](https://leetcode.com/problems/bitwise-and-of-numbers-range/)|[Bitwise AND of Numbers Range](./Algorithms/0201.bitwise-and-of-numbers-range)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0204](https://leetcode.com/problems/count-primes/)|[Count Primes](./Algorithms/0204.count-primes)|30%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0205](https://leetcode.com/problems/isomorphic-strings/)|[Isomorphic Strings](./Algorithms/0205.isomorphic-strings)|38%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0207](https://leetcode.com/problems/course-schedule/)|[Course Schedule](./Algorithms/0207.course-schedule)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0208](https://leetcode.com/problems/implement-trie-prefix-tree/)|[Implement Trie (Prefix Tree)](./Algorithms/0208.implement-trie-prefix-tree)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0211](https://leetcode.com/problems/add-and-search-word-data-structure-design/)|[Add and Search Word - Data structure design](./Algorithms/0211.add-and-search-word-data-structure-design)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0212](https://leetcode.com/problems/word-search-ii/)|[Word Search II](./Algorithms/0212.word-search-ii)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0214](https://leetcode.com/problems/shortest-palindrome/)|[Shortest Palindrome](./Algorithms/0214.shortest-palindrome)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0215](https://leetcode.com/problems/kth-largest-element-in-an-array/)|[Kth Largest Element in an Array](./Algorithms/0215.kth-largest-element-in-an-array)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0218](https://leetcode.com/problems/the-skyline-problem/)|[The Skyline Problem](./Algorithms/0218.the-skyline-problem)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0220](https://leetcode.com/problems/contains-duplicate-iii/)|[Contains Duplicate III](./Algorithms/0220.contains-duplicate-iii)|20%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0221](https://leetcode.com/problems/maximal-square/)|[Maximal Square](./Algorithms/0221.maximal-square)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0229](https://leetcode.com/problems/majority-element-ii/)|[Majority Element II](./Algorithms/0229.majority-element-ii)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0233](https://leetcode.com/problems/number-of-digit-one/)|[Number of Digit One](./Algorithms/0233.number-of-digit-one)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0235](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/)|[Lowest Common Ancestor of a Binary Search Tree](./Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree)|46%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0236](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/)|[Lowest Common Ancestor of a Binary Tree](./Algorithms/0236.lowest-common-ancestor-of-a-binary-tree)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0237](https://leetcode.com/problems/delete-node-in-a-linked-list/)|[Delete Node in a Linked List](./Algorithms/0237.delete-node-in-a-linked-list)|56%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0239](https://leetcode.com/problems/sliding-window-maximum/)|[Sliding Window Maximum](./Algorithms/0239.sliding-window-maximum)|39%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0240](https://leetcode.com/problems/search-a-2d-matrix-ii/)|[Search a 2D Matrix II](./Algorithms/0240.search-a-2d-matrix-ii)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0260](https://leetcode.com/problems/single-number-iii/)|[Single Number III](./Algorithms/0260.single-number-iii)|58%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0264](https://leetcode.com/problems/ugly-number-ii/)|[Ugly Number II](./Algorithms/0264.ugly-number-ii)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0273](https://leetcode.com/problems/integer-to-english-words/)|[Integer to English Words](./Algorithms/0273.integer-to-english-words)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0275](https://leetcode.com/problems/h-index-ii/)|[H-Index II](./Algorithms/0275.h-index-ii)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0279](https://leetcode.com/problems/perfect-squares/)|[Perfect Squares](./Algorithms/0279.perfect-squares)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0282](https://leetcode.com/problems/expression-add-operators/)|[Expression Add Operators](./Algorithms/0282.expression-add-operators)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0287](https://leetcode.com/problems/find-the-duplicate-number/)|[Find the Duplicate Number](./Algorithms/0287.find-the-duplicate-number)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0289](https://leetcode.com/problems/game-of-life/)|[Game of Life](./Algorithms/0289.game-of-life)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0292](https://leetcode.com/problems/nim-game/)|[Nim Game](./Algorithms/0292.nim-game)|55%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0295](https://leetcode.com/problems/find-median-from-data-stream/)|[Find Median from Data Stream](./Algorithms/0295.find-median-from-data-stream)|39%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0300](https://leetcode.com/problems/longest-increasing-subsequence/)|[Longest Increasing Subsequence](./Algorithms/0300.longest-increasing-subsequence)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0301](https://leetcode.com/problems/remove-invalid-parentheses/)|[Remove Invalid Parentheses](./Algorithms/0301.remove-invalid-parentheses)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0309](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/)|[Best Time to Buy and Sell Stock with Cooldown](./Algorithms/0309.best-time-to-buy-and-sell-stock-with-cooldown)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0312](https://leetcode.com/problems/burst-balloons/)|[Burst Balloons](./Algorithms/0312.burst-balloons)|48%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0313](https://leetcode.com/problems/super-ugly-number/)|[Super Ugly Number](./Algorithms/0313.super-ugly-number)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0316](https://leetcode.com/problems/remove-duplicate-letters/)|[Remove Duplicate Letters](./Algorithms/0316.remove-duplicate-letters)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0318](https://leetcode.com/problems/maximum-product-of-word-lengths/)|[Maximum Product of Word Lengths](./Algorithms/0318.maximum-product-of-word-lengths)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0319](https://leetcode.com/problems/bulb-switcher/)|[Bulb Switcher](./Algorithms/0319.bulb-switcher)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0321](https://leetcode.com/problems/create-maximum-number/)|[Create Maximum Number](./Algorithms/0321.create-maximum-number)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0322](https://leetcode.com/problems/coin-change/)|[Coin Change](./Algorithms/0322.coin-change)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0326](https://leetcode.com/problems/power-of-three/)|[Power of Three](./Algorithms/0326.power-of-three)|41%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0327](https://leetcode.com/problems/count-of-range-sum/)|[Count of Range Sum](./Algorithms/0327.count-of-range-sum)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0328](https://leetcode.com/problems/odd-even-linked-list/)|[Odd Even Linked List](./Algorithms/0328.odd-even-linked-list)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0329](https://leetcode.com/problems/longest-increasing-path-in-a-matrix/)|[Longest Increasing Path in a Matrix](./Algorithms/0329.longest-increasing-path-in-a-matrix)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0331](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/)|[Verify Preorder Serialization of a Binary Tree](./Algorithms/0331.verify-preorder-serialization-of-a-binary-tree)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0332](https://leetcode.com/problems/reconstruct-itinerary/)|[Reconstruct Itinerary](./Algorithms/0332.reconstruct-itinerary)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0334](https://leetcode.com/problems/increasing-triplet-subsequence/)|[Increasing Triplet Subsequence](./Algorithms/0334.increasing-triplet-subsequence)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0336](https://leetcode.com/problems/palindrome-pairs/)|[Palindrome Pairs](./Algorithms/0336.palindrome-pairs)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0337](https://leetcode.com/problems/house-robber-iii/)|[House Robber III](./Algorithms/0337.house-robber-iii)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0350](https://leetcode.com/problems/intersection-of-two-arrays-ii/)|[Intersection of Two Arrays II](./Algorithms/0350.intersection-of-two-arrays-ii)|49%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0354](https://leetcode.com/problems/russian-doll-envelopes/)|[Russian Doll Envelopes](./Algorithms/0354.russian-doll-envelopes)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0355](https://leetcode.com/problems/design-twitter/)|[Design Twitter](./Algorithms/0355.design-twitter)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0357](https://leetcode.com/problems/count-numbers-with-unique-digits/)|[Count Numbers with Unique Digits](./Algorithms/0357.count-numbers-with-unique-digits)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0363](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k/)|[Max Sum of Rectangle No Larger Than K](./Algorithms/0363.max-sum-of-rectangle-no-larger-than-k)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0365](https://leetcode.com/problems/water-and-jug-problem/)|[Water and Jug Problem](./Algorithms/0365.water-and-jug-problem)|29%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0368](https://leetcode.com/problems/largest-divisible-subset/)|[Largest Divisible Subset](./Algorithms/0368.largest-divisible-subset)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0371](https://leetcode.com/problems/sum-of-two-integers/)|[Sum of Two Integers](./Algorithms/0371.sum-of-two-integers)|50%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0373](https://leetcode.com/problems/find-k-pairs-with-smallest-sums/)|[Find K Pairs with Smallest Sums](./Algorithms/0373.find-k-pairs-with-smallest-sums)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0376](https://leetcode.com/problems/wiggle-subsequence/)|[Wiggle Subsequence](./Algorithms/0376.wiggle-subsequence)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0378](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/)|[Kth Smallest Element in a Sorted Matrix](./Algorithms/0378.kth-smallest-element-in-a-sorted-matrix)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0380](https://leetcode.com/problems/insert-delete-getrandom-o1/)|[Insert Delete GetRandom O(1)](./Algorithms/0380.insert-delete-getrandom-o1)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0381](https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/)|[Insert Delete GetRandom O(1) - Duplicates allowed](./Algorithms/0381.insert-delete-getrandom-o1-duplicates-allowed)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0384](https://leetcode.com/problems/shuffle-an-array/)|[Shuffle an Array](./Algorithms/0384.shuffle-an-array)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0385](https://leetcode.com/problems/mini-parser/)|[Mini Parser](./Algorithms/0385.mini-parser)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0390](https://leetcode.com/problems/elimination-game/)|[Elimination Game](./Algorithms/0390.elimination-game)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0392](https://leetcode.com/problems/is-subsequence/)|[Is Subsequence](./Algorithms/0392.is-subsequence)|47%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0393](https://leetcode.com/problems/utf-8-validation/)|[UTF-8 Validation](./Algorithms/0393.utf-8-validation)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0396](https://leetcode.com/problems/rotate-function/)|[Rotate Function](./Algorithms/0396.rotate-function)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0397](https://leetcode.com/problems/integer-replacement/)|[Integer Replacement](./Algorithms/0397.integer-replacement)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0399](https://leetcode.com/problems/evaluate-division/)|[Evaluate Division](./Algorithms/0399.evaluate-division)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0400](https://leetcode.com/problems/nth-digit/)|[Nth Digit](./Algorithms/0400.nth-digit)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0402](https://leetcode.com/problems/remove-k-digits/)|[Remove K Digits](./Algorithms/0402.remove-k-digits)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0403](https://leetcode.com/problems/frog-jump/)|[Frog Jump](./Algorithms/0403.frog-jump)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0406](https://leetcode.com/problems/queue-reconstruction-by-height/)|[Queue Reconstruction by Height](./Algorithms/0406.queue-reconstruction-by-height)|61%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0416](https://leetcode.com/problems/partition-equal-subset-sum/)|[Partition Equal Subset Sum](./Algorithms/0416.partition-equal-subset-sum)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0420](https://leetcode.com/problems/strong-password-checker/)|[Strong Password Checker](./Algorithms/0420.strong-password-checker)|16%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0421](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/)|[Maximum XOR of Two Numbers in an Array](./Algorithms/0421.maximum-xor-of-two-numbers-in-an-array)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0424](https://leetcode.com/problems/longest-repeating-character-replacement/)|[Longest Repeating Character Replacement](./Algorithms/0424.longest-repeating-character-replacement)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0432](https://leetcode.com/problems/all-oone-data-structure/)|[All O`one Data Structure](./Algorithms/0432.all-oone-data-structure)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0435](https://leetcode.com/problems/non-overlapping-intervals/)|[Non-overlapping Intervals](./Algorithms/0435.non-overlapping-intervals)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0437](https://leetcode.com/problems/path-sum-iii/)|[Path Sum III](./Algorithms/0437.path-sum-iii)|44%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0440](https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/)|[K-th Smallest in Lexicographical Order](./Algorithms/0440.k-th-smallest-in-lexicographical-order)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0443](https://leetcode.com/problems/string-compression/)|[String Compression](./Algorithms/0443.string-compression)|38%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0445](https://leetcode.com/problems/add-two-numbers-ii/)|[Add Two Numbers II](./Algorithms/0445.add-two-numbers-ii)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0446](https://leetcode.com/problems/arithmetic-slices-ii-subsequence/)|[Arithmetic Slices II - Subsequence](./Algorithms/0446.arithmetic-slices-ii-subsequence)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0450](https://leetcode.com/problems/delete-node-in-a-bst/)|[Delete Node in a BST](./Algorithms/0450.delete-node-in-a-bst)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0456](https://leetcode.com/problems/132-pattern/)|[132 Pattern](./Algorithms/0456.132-pattern)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0459](https://leetcode.com/problems/repeated-substring-pattern/)|[Repeated Substring Pattern](./Algorithms/0459.repeated-substring-pattern)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0464](https://leetcode.com/problems/can-i-win/)|[Can I Win](./Algorithms/0464.can-i-win)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0466](https://leetcode.com/problems/count-the-repetitions/)|[Count The Repetitions](./Algorithms/0466.count-the-repetitions)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0467](https://leetcode.com/problems/unique-substrings-in-wraparound-string/)|[Unique Substrings in Wraparound String](./Algorithms/0467.unique-substrings-in-wraparound-string)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0470](https://leetcode.com/problems/implement-rand10-using-rand7/)|[Implement Rand10() Using Rand7()](./Algorithms/0470.implement-rand10-using-rand7)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0473](https://leetcode.com/problems/matchsticks-to-square/)|[Matchsticks to Square](./Algorithms/0473.matchsticks-to-square)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0477](https://leetcode.com/problems/total-hamming-distance/)|[Total Hamming Distance](./Algorithms/0477.total-hamming-distance)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0480](https://leetcode.com/problems/sliding-window-median/)|[Sliding Window Median](./Algorithms/0480.sliding-window-median)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0483](https://leetcode.com/problems/smallest-good-base/)|[Smallest Good Base](./Algorithms/0483.smallest-good-base)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0488](https://leetcode.com/problems/zuma-game/)|[Zuma Game](./Algorithms/0488.zuma-game)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0491](https://leetcode.com/problems/increasing-subsequences/)|[Increasing Subsequences](./Algorithms/0491.increasing-subsequences)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0492](https://leetcode.com/problems/construct-the-rectangle/)|[Construct the Rectangle](./Algorithms/0492.construct-the-rectangle)|48%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0494](https://leetcode.com/problems/target-sum/)|[Target Sum](./Algorithms/0494.target-sum)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0501](https://leetcode.com/problems/find-mode-in-binary-search-tree/)|[Find Mode in Binary Search Tree](./Algorithms/0501.find-mode-in-binary-search-tree)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0503](https://leetcode.com/problems/next-greater-element-ii/)|[Next Greater Element II](./Algorithms/0503.next-greater-element-ii)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0516](https://leetcode.com/problems/longest-palindromic-subsequence/)|[Longest Palindromic Subsequence](./Algorithms/0516.longest-palindromic-subsequence)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0517](https://leetcode.com/problems/super-washing-machines/)|[Super Washing Machines](./Algorithms/0517.super-washing-machines)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0518](https://leetcode.com/problems/coin-change-2/)|[Coin Change 2](./Algorithms/0518.coin-change-2)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0523](https://leetcode.com/problems/continuous-subarray-sum/)|[Continuous Subarray Sum](./Algorithms/0523.continuous-subarray-sum)|24%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0525](https://leetcode.com/problems/contiguous-array/)|[Contiguous Array](./Algorithms/0525.contiguous-array)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0526](https://leetcode.com/problems/beautiful-arrangement/)|[Beautiful Arrangement](./Algorithms/0526.beautiful-arrangement)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0530](https://leetcode.com/problems/minimum-absolute-difference-in-bst/)|[Minimum Absolute Difference in BST](./Algorithms/0530.minimum-absolute-difference-in-bst)|51%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0542](https://leetcode.com/problems/01-matrix/)|[01 Matrix](./Algorithms/0542.01-matrix)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0546](https://leetcode.com/problems/remove-boxes/)|[Remove Boxes](./Algorithms/0546.remove-boxes)|39%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0547](https://leetcode.com/problems/friend-circles/)|[Friend Circles](./Algorithms/0547.friend-circles)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0552](https://leetcode.com/problems/student-attendance-record-ii/)|[Student Attendance Record II](./Algorithms/0552.student-attendance-record-ii)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0560](https://leetcode.com/problems/subarray-sum-equals-k/)|[Subarray Sum Equals K](./Algorithms/0560.subarray-sum-equals-k)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0572](https://leetcode.com/problems/subtree-of-another-tree/)|[Subtree of Another Tree](./Algorithms/0572.subtree-of-another-tree)|42%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0576](https://leetcode.com/problems/out-of-boundary-paths/)|[Out of Boundary Paths](./Algorithms/0576.out-of-boundary-paths)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0581](https://leetcode.com/problems/shortest-unsorted-continuous-subarray/)|[Shortest Unsorted Continuous Subarray](./Algorithms/0581.shortest-unsorted-continuous-subarray)|30%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0583](https://leetcode.com/problems/delete-operation-for-two-strings/)|[Delete Operation for Two Strings](./Algorithms/0583.delete-operation-for-two-strings)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0587](https://leetcode.com/problems/erect-the-fence/)|[Erect the Fence](./Algorithms/0587.erect-the-fence)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0591](https://leetcode.com/problems/tag-validator/)|[Tag Validator](./Algorithms/0591.tag-validator)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0600](https://leetcode.com/problems/non-negative-integers-without-consecutive-ones/)|[Non-negative Integers without Consecutive Ones](./Algorithms/0600.non-negative-integers-without-consecutive-ones)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0605](https://leetcode.com/problems/can-place-flowers/)|[Can Place Flowers](./Algorithms/0605.can-place-flowers)|31%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0611](https://leetcode.com/problems/valid-triangle-number/)|[Valid Triangle Number](./Algorithms/0611.valid-triangle-number)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0621](https://leetcode.com/problems/task-scheduler/)|[Task Scheduler](./Algorithms/0621.task-scheduler)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0628](https://leetcode.com/problems/maximum-product-of-three-numbers/)|[Maximum Product of Three Numbers](./Algorithms/0628.maximum-product-of-three-numbers)|46%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0630](https://leetcode.com/problems/course-schedule-iii/)|[Course Schedule III](./Algorithms/0630.course-schedule-iii)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0636](https://leetcode.com/problems/exclusive-time-of-functions/)|[Exclusive Time of Functions](./Algorithms/0636.exclusive-time-of-functions)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0638](https://leetcode.com/problems/shopping-offers/)|[Shopping Offers](./Algorithms/0638.shopping-offers)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0641](https://leetcode.com/problems/design-circular-deque/)|[Design Circular Deque](./Algorithms/0641.design-circular-deque)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0645](https://leetcode.com/problems/set-mismatch/)|[Set Mismatch](./Algorithms/0645.set-mismatch)|41%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0647](https://leetcode.com/problems/palindromic-substrings/)|[Palindromic Substrings](./Algorithms/0647.palindromic-substrings)|58%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0649](https://leetcode.com/problems/dota2-senate/)|[Dota2 Senate](./Algorithms/0649.dota2-senate)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0654](https://leetcode.com/problems/maximum-binary-tree/)|[Maximum Binary Tree](./Algorithms/0654.maximum-binary-tree)|77%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0658](https://leetcode.com/problems/find-k-closest-elements/)|[Find K Closest Elements](./Algorithms/0658.find-k-closest-elements)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0659](https://leetcode.com/problems/split-array-into-consecutive-subsequences/)|[Split Array into Consecutive Subsequences](./Algorithms/0659.split-array-into-consecutive-subsequences)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0664](https://leetcode.com/problems/strange-printer/)|[Strange Printer](./Algorithms/0664.strange-printer)|38%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0670](https://leetcode.com/problems/maximum-swap/)|[Maximum Swap](./Algorithms/0670.maximum-swap)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0673](https://leetcode.com/problems/number-of-longest-increasing-subsequence/)|[Number of Longest Increasing Subsequence](./Algorithms/0673.number-of-longest-increasing-subsequence)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0675](https://leetcode.com/problems/cut-off-trees-for-golf-event/)|[Cut Off Trees for Golf Event](./Algorithms/0675.cut-off-trees-for-golf-event)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0677](https://leetcode.com/problems/map-sum-pairs/)|[Map Sum Pairs](./Algorithms/0677.map-sum-pairs)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0678](https://leetcode.com/problems/valid-parenthesis-string/)|[Valid Parenthesis String](./Algorithms/0678.valid-parenthesis-string)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0679](https://leetcode.com/problems/24-game/)|[24 Game](./Algorithms/0679.24-game)|44%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0685](https://leetcode.com/problems/redundant-connection-ii/)|[Redundant Connection II](./Algorithms/0685.redundant-connection-ii)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0686](https://leetcode.com/problems/repeated-string-match/)|[Repeated String Match](./Algorithms/0686.repeated-string-match)|31%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0691](https://leetcode.com/problems/stickers-to-spell-word/)|[Stickers to Spell Word](./Algorithms/0691.stickers-to-spell-word)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0695](https://leetcode.com/problems/max-area-of-island/)|[Max Area of Island](./Algorithms/0695.max-area-of-island)|59%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0698](https://leetcode.com/problems/partition-to-k-equal-sum-subsets/)|[Partition to K Equal Sum Subsets](./Algorithms/0698.partition-to-k-equal-sum-subsets)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0707](https://leetcode.com/problems/design-linked-list/)|[Design Linked List](./Algorithms/0707.design-linked-list)|20%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0710](https://leetcode.com/problems/random-pick-with-blacklist/)|[Random Pick with Blacklist](./Algorithms/0710.random-pick-with-blacklist)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0712](https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings/)|[Minimum ASCII Delete Sum for Two Strings](./Algorithms/0712.minimum-ascii-delete-sum-for-two-strings)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0713](https://leetcode.com/problems/subarray-product-less-than-k/)|[Subarray Product Less Than K](./Algorithms/0713.subarray-product-less-than-k)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0714](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/)|[Best Time to Buy and Sell Stock with Transaction Fee](./Algorithms/0714.best-time-to-buy-and-sell-stock-with-transaction-fee)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0718](https://leetcode.com/problems/maximum-length-of-repeated-subarray/)|[Maximum Length of Repeated Subarray](./Algorithms/0718.maximum-length-of-repeated-subarray)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0719](https://leetcode.com/problems/find-k-th-smallest-pair-distance/)|[Find K-th Smallest Pair Distance](./Algorithms/0719.find-k-th-smallest-pair-distance)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0721](https://leetcode.com/problems/accounts-merge/)|[Accounts Merge](./Algorithms/0721.accounts-merge)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0722](https://leetcode.com/problems/remove-comments/)|[Remove Comments](./Algorithms/0722.remove-comments)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0726](https://leetcode.com/problems/number-of-atoms/)|[Number of Atoms](./Algorithms/0726.number-of-atoms)|46%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0730](https://leetcode.com/problems/count-different-palindromic-subsequences/)|[Count Different Palindromic Subsequences](./Algorithms/0730.count-different-palindromic-subsequences)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0731](https://leetcode.com/problems/my-calendar-ii/)|[My Calendar II](./Algorithms/0731.my-calendar-ii)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0736](https://leetcode.com/problems/parse-lisp-expression/)|[Parse Lisp Expression](./Algorithms/0736.parse-lisp-expression)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0739](https://leetcode.com/problems/daily-temperatures/)|[Daily Temperatures](./Algorithms/0739.daily-temperatures)|61%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0740](https://leetcode.com/problems/delete-and-earn/)|[Delete and Earn](./Algorithms/0740.delete-and-earn)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0752](https://leetcode.com/problems/open-the-lock/)|[Open the Lock](./Algorithms/0752.open-the-lock)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0753](https://leetcode.com/problems/cracking-the-safe/)|[Cracking the Safe](./Algorithms/0753.cracking-the-safe)|48%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0754](https://leetcode.com/problems/reach-a-number/)|[Reach a Number](./Algorithms/0754.reach-a-number)|33%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0756](https://leetcode.com/problems/pyramid-transition-matrix/)|[Pyramid Transition Matrix](./Algorithms/0756.pyramid-transition-matrix)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0770](https://leetcode.com/problems/basic-calculator-iv/)|[Basic Calculator IV](./Algorithms/0770.basic-calculator-iv)|46%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0784](https://leetcode.com/problems/letter-case-permutation/)|[Letter Case Permutation](./Algorithms/0784.letter-case-permutation)|59%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0785](https://leetcode.com/problems/is-graph-bipartite/)|[Is Graph Bipartite?](./Algorithms/0785.is-graph-bipartite)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0786](https://leetcode.com/problems/k-th-smallest-prime-fraction/)|[K-th Smallest Prime Fraction](./Algorithms/0786.k-th-smallest-prime-fraction)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0787](https://leetcode.com/problems/cheapest-flights-within-k-stops/)|[Cheapest Flights Within K Stops](./Algorithms/0787.cheapest-flights-within-k-stops)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0790](https://leetcode.com/problems/domino-and-tromino-tiling/)|[Domino and Tromino Tiling](./Algorithms/0790.domino-and-tromino-tiling)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0792](https://leetcode.com/problems/number-of-matching-subsequences/)|[Number of Matching Subsequences](./Algorithms/0792.number-of-matching-subsequences)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0793](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function/)|[Preimage Size of Factorial Zeroes Function](./Algorithms/0793.preimage-size-of-factorial-zeroes-function)|39%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0795](https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/)|[Number of Subarrays with Bounded Maximum](./Algorithms/0795.number-of-subarrays-with-bounded-maximum)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0798](https://leetcode.com/problems/smallest-rotation-with-highest-score/)|[Smallest Rotation with Highest Score](./Algorithms/0798.smallest-rotation-with-highest-score)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0799](https://leetcode.com/problems/champagne-tower/)|[Champagne Tower](./Algorithms/0799.champagne-tower)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0801](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing/)|[Minimum Swaps To Make Sequences Increasing](./Algorithms/0801.minimum-swaps-to-make-sequences-increasing)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0802](https://leetcode.com/problems/find-eventual-safe-states/)|[Find Eventual Safe States](./Algorithms/0802.find-eventual-safe-states)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0803](https://leetcode.com/problems/bricks-falling-when-hit/)|[Bricks Falling When Hit](./Algorithms/0803.bricks-falling-when-hit)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0805](https://leetcode.com/problems/split-array-with-same-average/)|[Split Array With Same Average](./Algorithms/0805.split-array-with-same-average)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0810](https://leetcode.com/problems/chalkboard-xor-game/)|[Chalkboard XOR Game](./Algorithms/0810.chalkboard-xor-game)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0813](https://leetcode.com/problems/largest-sum-of-averages/)|[Largest Sum of Averages](./Algorithms/0813.largest-sum-of-averages)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0815](https://leetcode.com/problems/bus-routes/)|[Bus Routes](./Algorithms/0815.bus-routes)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0818](https://leetcode.com/problems/race-car/)|[Race Car](./Algorithms/0818.race-car)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0820](https://leetcode.com/problems/short-encoding-of-words/)|[Short Encoding of Words](./Algorithms/0820.short-encoding-of-words)|48%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0826](https://leetcode.com/problems/most-profit-assigning-work/)|[Most Profit Assigning Work](./Algorithms/0826.most-profit-assigning-work)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0827](https://leetcode.com/problems/making-a-large-island/)|[Making A Large Island](./Algorithms/0827.making-a-large-island)|44%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0828](https://leetcode.com/problems/unique-letter-string/)|[Unique Letter String](./Algorithms/0828.unique-letter-string)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0829](https://leetcode.com/problems/consecutive-numbers-sum/)|[Consecutive Numbers Sum](./Algorithms/0829.consecutive-numbers-sum)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0834](https://leetcode.com/problems/sum-of-distances-in-tree/)|[Sum of Distances in Tree](./Algorithms/0834.sum-of-distances-in-tree)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0837](https://leetcode.com/problems/new-21-game/)|[New 21 Game](./Algorithms/0837.new-21-game)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0838](https://leetcode.com/problems/push-dominoes/)|[Push Dominoes](./Algorithms/0838.push-dominoes)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0839](https://leetcode.com/problems/similar-string-groups/)|[Similar String Groups](./Algorithms/0839.similar-string-groups)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0843](https://leetcode.com/problems/guess-the-word/)|[Guess the Word](./Algorithms/0843.guess-the-word)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0846](https://leetcode.com/problems/hand-of-straights/)|[Hand of Straights](./Algorithms/0846.hand-of-straights)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0847](https://leetcode.com/problems/shortest-path-visiting-all-nodes/)|[Shortest Path Visiting All Nodes](./Algorithms/0847.shortest-path-visiting-all-nodes)|48%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0849](https://leetcode.com/problems/maximize-distance-to-closest-person/)|[Maximize Distance to Closest Person](./Algorithms/0849.maximize-distance-to-closest-person)|41%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0850](https://leetcode.com/problems/rectangle-area-ii/)|[Rectangle Area II](./Algorithms/0850.rectangle-area-ii)|46%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0851](https://leetcode.com/problems/loud-and-rich/)|[Loud and Rich](./Algorithms/0851.loud-and-rich)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0852](https://leetcode.com/problems/peak-index-in-a-mountain-array/)|[Peak Index in a Mountain Array](./Algorithms/0852.peak-index-in-a-mountain-array)|70%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0854](https://leetcode.com/problems/k-similar-strings/)|[K-Similar Strings](./Algorithms/0854.k-similar-strings)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0857](https://leetcode.com/problems/minimum-cost-to-hire-k-workers/)|[Minimum Cost to Hire K Workers](./Algorithms/0857.minimum-cost-to-hire-k-workers)|48%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0862](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/)|[Shortest Subarray with Sum at Least K](./Algorithms/0862.shortest-subarray-with-sum-at-least-k)|22%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0863](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/)|[All Nodes Distance K in Binary Tree](./Algorithms/0863.all-nodes-distance-k-in-binary-tree)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0864](https://leetcode.com/problems/shortest-path-to-get-all-keys/)|[Shortest Path to Get All Keys](./Algorithms/0864.shortest-path-to-get-all-keys)|38%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0866](https://leetcode.com/problems/prime-palindrome/)|[Prime Palindrome](./Algorithms/0866.prime-palindrome)|21%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0879](https://leetcode.com/problems/profitable-schemes/)|[Profitable Schemes](./Algorithms/0879.profitable-schemes)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0895](https://leetcode.com/problems/maximum-frequency-stack/)|[Maximum Frequency Stack](./Algorithms/0895.maximum-frequency-stack)|58%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0896](https://leetcode.com/problems/monotonic-array/)|[Monotonic Array](./Algorithms/0896.monotonic-array)|56%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0897](https://leetcode.com/problems/increasing-order-search-tree/)|[Increasing Order Search Tree](./Algorithms/0897.increasing-order-search-tree)|66%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0898](https://leetcode.com/problems/bitwise-ors-of-subarrays/)|[Bitwise ORs of Subarrays](./Algorithms/0898.bitwise-ors-of-subarrays)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0901](https://leetcode.com/problems/online-stock-span/)|[Online Stock Span](./Algorithms/0901.online-stock-span)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0903](https://leetcode.com/problems/valid-permutations-for-di-sequence/)|[Valid Permutations for DI Sequence](./Algorithms/0903.valid-permutations-for-di-sequence)|46%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0904](https://leetcode.com/problems/fruit-into-baskets/)|[Fruit Into Baskets](./Algorithms/0904.fruit-into-baskets)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0907](https://leetcode.com/problems/sum-of-subarray-minimums/)|[Sum of Subarray Minimums](./Algorithms/0907.sum-of-subarray-minimums)|29%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0909](https://leetcode.com/problems/snakes-and-ladders/)|[Snakes and Ladders](./Algorithms/0909.snakes-and-ladders)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0910](https://leetcode.com/problems/smallest-range-ii/)|[Smallest Range II](./Algorithms/0910.smallest-range-ii)|24%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0911](https://leetcode.com/problems/online-election/)|[Online Election](./Algorithms/0911.online-election)|48%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0913](https://leetcode.com/problems/cat-and-mouse/)|[Cat and Mouse](./Algorithms/0913.cat-and-mouse)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0915](https://leetcode.com/problems/partition-array-into-disjoint-intervals/)|[Partition Array into Disjoint Intervals](./Algorithms/0915.partition-array-into-disjoint-intervals)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0918](https://leetcode.com/problems/maximum-sum-circular-subarray/)|[Maximum Sum Circular Subarray](./Algorithms/0918.maximum-sum-circular-subarray)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0919](https://leetcode.com/problems/complete-binary-tree-inserter/)|[Complete Binary Tree Inserter](./Algorithms/0919.complete-binary-tree-inserter)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0920](https://leetcode.com/problems/number-of-music-playlists/)|[Number of Music Playlists](./Algorithms/0920.number-of-music-playlists)|44%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0921](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/)|[Minimum Add to Make Parentheses Valid](./Algorithms/0921.minimum-add-to-make-parentheses-valid)|70%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0923](https://leetcode.com/problems/3sum-with-multiplicity/)|[3Sum With Multiplicity](./Algorithms/0923.3sum-with-multiplicity)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0932](https://leetcode.com/problems/beautiful-array/)|[Beautiful Array](./Algorithms/0932.beautiful-array)|54%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0936](https://leetcode.com/problems/stamping-the-sequence/)|[Stamping The Sequence](./Algorithms/0936.stamping-the-sequence)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0939](https://leetcode.com/problems/minimum-area-rectangle/)|[Minimum Area Rectangle](./Algorithms/0939.minimum-area-rectangle)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0940](https://leetcode.com/problems/distinct-subsequences-ii/)|[Distinct Subsequences II](./Algorithms/0940.distinct-subsequences-ii)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0943](https://leetcode.com/problems/find-the-shortest-superstring/)|[Find the Shortest Superstring](./Algorithms/0943.find-the-shortest-superstring)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0945](https://leetcode.com/problems/minimum-increment-to-make-array-unique/)|[Minimum Increment to Make Array Unique](./Algorithms/0945.minimum-increment-to-make-array-unique)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0947](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/)|[Most Stones Removed with Same Row or Column](./Algorithms/0947.most-stones-removed-with-same-row-or-column)|54%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0948](https://leetcode.com/problems/bag-of-tokens/)|[Bag of Tokens](./Algorithms/0948.bag-of-tokens)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0949](https://leetcode.com/problems/largest-time-for-given-digits/)|[Largest Time for Given Digits](./Algorithms/0949.largest-time-for-given-digits)|34%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0952](https://leetcode.com/problems/largest-component-size-by-common-factor/)|[Largest Component Size by Common Factor](./Algorithms/0952.largest-component-size-by-common-factor)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0955](https://leetcode.com/problems/delete-columns-to-make-sorted-ii/)|[Delete Columns to Make Sorted II](./Algorithms/0955.delete-columns-to-make-sorted-ii)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0956](https://leetcode.com/problems/tallest-billboard/)|[Tallest Billboard](./Algorithms/0956.tallest-billboard)|38%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0960](https://leetcode.com/problems/delete-columns-to-make-sorted-iii/)|[Delete Columns to Make Sorted III](./Algorithms/0960.delete-columns-to-make-sorted-iii)|52%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0962](https://leetcode.com/problems/maximum-width-ramp/)|[Maximum Width Ramp](./Algorithms/0962.maximum-width-ramp)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0964](https://leetcode.com/problems/least-operators-to-express-number/)|[Least Operators to Express Number](./Algorithms/0964.least-operators-to-express-number)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0971](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal/)|[Flip Binary Tree To Match Preorder Traversal](./Algorithms/0971.flip-binary-tree-to-match-preorder-traversal)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0972](https://leetcode.com/problems/equal-rational-numbers/)|[Equal Rational Numbers](./Algorithms/0972.equal-rational-numbers)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0974](https://leetcode.com/problems/subarray-sums-divisible-by-k/)|[Subarray Sums Divisible by K](./Algorithms/0974.subarray-sums-divisible-by-k)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0975](https://leetcode.com/problems/odd-even-jump/)|[Odd Even Jump](./Algorithms/0975.odd-even-jump)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0976](https://leetcode.com/problems/largest-perimeter-triangle/)|[Largest Perimeter Triangle](./Algorithms/0976.largest-perimeter-triangle)|57%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0978](https://leetcode.com/problems/longest-turbulent-subarray/)|[Longest Turbulent Subarray](./Algorithms/0978.longest-turbulent-subarray)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0979](https://leetcode.com/problems/distribute-coins-in-binary-tree/)|[Distribute Coins in Binary Tree](./Algorithms/0979.distribute-coins-in-binary-tree)|67%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0980](https://leetcode.com/problems/unique-paths-iii/)|[Unique Paths III](./Algorithms/0980.unique-paths-iii)|71%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0982](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero/)|[Triples with Bitwise AND Equal To Zero](./Algorithms/0982.triples-with-bitwise-and-equal-to-zero)|54%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0983](https://leetcode.com/problems/minimum-cost-for-tickets/)|[Minimum Cost For Tickets](./Algorithms/0983.minimum-cost-for-tickets)|57%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0986](https://leetcode.com/problems/interval-list-intersections/)|[Interval List Intersections](./Algorithms/0986.interval-list-intersections)|64%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0991](https://leetcode.com/problems/broken-calculator/)|[Broken Calculator](./Algorithms/0991.broken-calculator)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0992](https://leetcode.com/problems/subarrays-with-k-different-integers/)|[Subarrays with K Different Integers](./Algorithms/0992.subarrays-with-k-different-integers)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0996](https://leetcode.com/problems/number-of-squareful-arrays/)|[Number of Squareful Arrays](./Algorithms/0996.number-of-squareful-arrays)|47%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1000](https://leetcode.com/problems/minimum-cost-to-merge-stones/)|[Minimum Cost to Merge Stones](./Algorithms/1000.minimum-cost-to-merge-stones)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1001](https://leetcode.com/problems/grid-illumination/)|[Grid Illumination](./Algorithms/1001.grid-illumination)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1004](https://leetcode.com/problems/max-consecutive-ones-iii/)|[Max Consecutive Ones III](./Algorithms/1004.max-consecutive-ones-iii)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1009](https://leetcode.com/problems/complement-of-base-10-integer/)|[Complement of Base 10 Integer](./Algorithms/1009.complement-of-base-10-integer)|59%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1011](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/)|[Capacity To Ship Packages Within D Days](./Algorithms/1011.capacity-to-ship-packages-within-d-days)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1012](https://leetcode.com/problems/numbers-with-repeated-digits/)|[Numbers With Repeated Digits](./Algorithms/1012.numbers-with-repeated-digits)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1015](https://leetcode.com/problems/smallest-integer-divisible-by-k/)|[Smallest Integer Divisible by K](./Algorithms/1015.smallest-integer-divisible-by-k)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1019](https://leetcode.com/problems/next-greater-node-in-linked-list/)|[Next Greater Node In Linked List](./Algorithms/1019.next-greater-node-in-linked-list)|56%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1022](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/)|[Sum of Root To Leaf Binary Numbers](./Algorithms/1022.sum-of-root-to-leaf-binary-numbers)|61%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1024](https://leetcode.com/problems/video-stitching/)|[Video Stitching](./Algorithms/1024.video-stitching)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1025](https://leetcode.com/problems/divisor-game/)|[Divisor Game](./Algorithms/1025.divisor-game)|65%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1026](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor/)|[Maximum Difference Between Node and Ancestor](./Algorithms/1026.maximum-difference-between-node-and-ancestor)|61%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1027](https://leetcode.com/problems/longest-arithmetic-sequence/)|[Longest Arithmetic Sequence](./Algorithms/1027.longest-arithmetic-sequence)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1028](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal/)|[Recover a Tree From Preorder Traversal](./Algorithms/1028.recover-a-tree-from-preorder-traversal)|69%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1030](https://leetcode.com/problems/matrix-cells-in-distance-order/)|[Matrix Cells in Distance Order](./Algorithms/1030.matrix-cells-in-distance-order)|64%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1031](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays/)|[Maximum Sum of Two Non-Overlapping Subarrays](./Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1032](https://leetcode.com/problems/stream-of-characters/)|[Stream of Characters](./Algorithms/1032.stream-of-characters)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1035](https://leetcode.com/problems/uncrossed-lines/)|[Uncrossed Lines](./Algorithms/1035.uncrossed-lines)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1039](https://leetcode.com/problems/minimum-score-triangulation-of-polygon/)|[Minimum Score Triangulation of Polygon](./Algorithms/1039.minimum-score-triangulation-of-polygon)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1040](https://leetcode.com/problems/moving-stones-until-consecutive-ii/)|[Moving Stones Until Consecutive II](./Algorithms/1040.moving-stones-until-consecutive-ii)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1042](https://leetcode.com/problems/flower-planting-with-no-adjacent/)|[Flower Planting With No Adjacent](./Algorithms/1042.flower-planting-with-no-adjacent)|47%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1043](https://leetcode.com/problems/partition-array-for-maximum-sum/)|[Partition Array for Maximum Sum](./Algorithms/1043.partition-array-for-maximum-sum)|62%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1044](https://leetcode.com/problems/longest-duplicate-substring/)|[Longest Duplicate Substring](./Algorithms/1044.longest-duplicate-substring)|23%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1048](https://leetcode.com/problems/longest-string-chain/)|[Longest String Chain](./Algorithms/1048.longest-string-chain)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1049](https://leetcode.com/problems/last-stone-weight-ii/)|[Last Stone Weight II](./Algorithms/1049.last-stone-weight-ii)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1054](https://leetcode.com/problems/distant-barcodes/)|[Distant Barcodes](./Algorithms/1054.distant-barcodes)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1071](https://leetcode.com/problems/greatest-common-divisor-of-strings/)|[Greatest Common Divisor of Strings](./Algorithms/1071.greatest-common-divisor-of-strings)|53%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1072](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows/)|[Flip Columns For Maximum Number of Equal Rows](./Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows)|59%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1073](https://leetcode.com/problems/adding-two-negabinary-numbers/)|[Adding Two Negabinary Numbers](./Algorithms/1073.adding-two-negabinary-numbers)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1074](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/)|[Number of Submatrices That Sum to Target](./Algorithms/1074.number-of-submatrices-that-sum-to-target)|58%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1079](https://leetcode.com/problems/letter-tile-possibilities/)|[Letter Tile Possibilities](./Algorithms/1079.letter-tile-possibilities)|74%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1080](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths/)|[Insufficient Nodes in Root to Leaf Paths](./Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1089](https://leetcode.com/problems/duplicate-zeros/)|[Duplicate Zeros](./Algorithms/1089.duplicate-zeros)|58%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1092](https://leetcode.com/problems/shortest-common-supersequence/)|[Shortest Common Supersequence](./Algorithms/1092.shortest-common-supersequence)|49%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1105](https://leetcode.com/problems/filling-bookcase-shelves/)|[Filling Bookcase Shelves](./Algorithms/1105.filling-bookcase-shelves)|56%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1125](https://leetcode.com/problems/smallest-sufficient-team/)|[Smallest Sufficient Team](./Algorithms/1125.smallest-sufficient-team)|44%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1129](https://leetcode.com/problems/shortest-path-with-alternating-colors/)|[Shortest Path with Alternating Colors](./Algorithms/1129.shortest-path-with-alternating-colors)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1130](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values/)|[Minimum Cost Tree From Leaf Values](./Algorithms/1130.minimum-cost-tree-from-leaf-values)|62%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1131](https://leetcode.com/problems/maximum-of-absolute-value-expression/)|[Maximum of Absolute Value Expression](./Algorithms/1131.maximum-of-absolute-value-expression)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1137](https://leetcode.com/problems/n-th-tribonacci-number/)|[N-th Tribonacci Number](./Algorithms/1137.n-th-tribonacci-number)|57%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1138](https://leetcode.com/problems/alphabet-board-path/)|[Alphabet Board Path](./Algorithms/1138.alphabet-board-path)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1139](https://leetcode.com/problems/largest-1-bordered-square/)|[Largest 1-Bordered Square](./Algorithms/1139.largest-1-bordered-square)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1140](https://leetcode.com/problems/stone-game-ii/)|[Stone Game II](./Algorithms/1140.stone-game-ii)|60%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1145](https://leetcode.com/problems/binary-tree-coloring-game/)|[Binary Tree Coloring Game](./Algorithms/1145.binary-tree-coloring-game)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1146](https://leetcode.com/problems/snapshot-array/)|[Snapshot Array](./Algorithms/1146.snapshot-array)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1155](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/)|[Number of Dice Rolls With Target Sum](./Algorithms/1155.number-of-dice-rolls-with-target-sum)|48%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1157](https://leetcode.com/problems/online-majority-element-in-subarray/)|[Online Majority Element In Subarray](./Algorithms/1157.online-majority-element-in-subarray)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1163](https://leetcode.com/problems/last-substring-in-lexicographical-order/)|[Last Substring in Lexicographical Order](./Algorithms/1163.last-substring-in-lexicographical-order)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1172](https://leetcode.com/problems/dinner-plate-stacks/)|[Dinner Plate Stacks](./Algorithms/1172.dinner-plate-stacks)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1177](https://leetcode.com/problems/can-make-palindrome-from-substring/)|[Can Make Palindrome from Substring](./Algorithms/1177.can-make-palindrome-from-substring)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1178](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/)|[Number of Valid Words for Each Puzzle](./Algorithms/1178.number-of-valid-words-for-each-puzzle)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1186](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/)|[Maximum Subarray Sum with One Deletion](./Algorithms/1186.maximum-subarray-sum-with-one-deletion)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1190](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/)|[Reverse Substrings Between Each Pair of Parentheses](./Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses)|57%|Medium|[❤](https://leetcode.com/list/oussv5j)| + diff --git a/GoLand.png b/GoLand.png new file mode 100644 index 000000000..e940ca6d2 Binary files /dev/null and b/GoLand.png differ diff --git a/Helper/README.md b/Helper/README.md index 3c73ded9e..24a2908f5 100644 --- a/Helper/README.md +++ b/Helper/README.md @@ -6,8 +6,10 @@ 1. 在`LeetCode-in-Go`目录下,添加文本文件`config.toml`。 1. 把以下内容复制到`config.toml`中。 1. 把`config.toml`中的`test`分别修改为你的 leetcode `用户名`和`密码`。 +1. 去 leetcode 登录后,把网站 cookie 复制 (有洁癖者只要复制 LEETCODE_SESSION 就够了) 并替换 `config.toml`中的`Cookie`。 ```toml -Login="test" +Username="test" Password="test" +Cookie="LEETCODE_SESSION=XXXXXXXXX;" ``` \ No newline at end of file diff --git a/Helper/buildProblemDir.go b/Helper/buildProblemDir.go index eff4c48fd..514ced343 100644 --- a/Helper/buildProblemDir.go +++ b/Helper/buildProblemDir.go @@ -4,10 +4,9 @@ import ( "fmt" "log" "os" - "os/exec" + "runtime/debug" "strings" "syscall" - "time" "github.com/aQuaYi/GoKit" ) @@ -15,88 +14,78 @@ import ( func buildProblemDir(problemNum int) { log.Printf("~~ 开始生成第 %d 题的文件夹 ~~\n", problemNum) - // 需要创建答题文件夹 + // 获取 LeetCode 的记录文件 lc := newLeetCode() - // - makeProblemDir(lc.Problems, problemNum) - // - log.Printf("~~ 第 %d 题的文件夹,已经生成 ~~\n", problemNum) -} -func makeProblemDir(ps problems, problemNum int) { - var pb problem - var isFound bool - - // 根据题号,获取题目信息 - for _, p := range ps { - if p.ID == problemNum { - if p.HasNoGoOption { - log.Fatalln(`此题被标记为"不能使用 Go 语言解答"。请核查后,修改 unavailable.json 中的记录`) - } - pb = p - isFound = true - break - } + // 检查 problemNum 的合法性 + if problemNum >= len(lc.Problems) { + log.Panicf("%d 超出题目范围,请核查题号。", problemNum) } - - if !isFound { - log.Printf("没有发现第 %d 题,存在以下可能:1.此题不存在;2.此题需要付费。", problemNum) - return + if lc.Problems[problemNum].ID == 0 { + log.Panicf("%d 号题不存,请核查题号。", problemNum) + } + if lc.Problems[problemNum].IsPaid { + log.Panicf("%d 号题需要付费。如果已经订阅,请注释掉本代码。", problemNum) + } + if lc.Problems[problemNum].HasNoGoOption { + log.Panicf("%d 号题,没有提供 Go 解答选项。请核查后,修改 unavailable.json 中的记录。", problemNum) } - // 创建目录 - build(pb) + // 需要创建答题文件夹 + build(lc.Problems[problemNum]) + + log.Printf("~~ 第 %d 题的文件夹,已经生成 ~~\n", problemNum) } func build(p problem) { if GoKit.Exist(p.Dir()) { - log.Fatalf("第 %d 题的文件夹已经存在,请**移除** %s 文件夹后,再尝试。", p.ID, p.Dir()) + log.Panicf("第 %d 题的文件夹已经存在,请 **移除** %s 文件夹后,再尝试。", p.ID, p.Dir()) } + defer func() { + if err := recover(); err != nil { + debug.PrintStack() + log.Println(err) + log.Println("清理不必要的文件") + os.RemoveAll(p.Dir()) + } + }() + + // windows用户注释这两行 mask := syscall.Umask(0) defer syscall.Umask(mask) // 创建目录 err := os.Mkdir(p.Dir(), 0755) if err != nil { - log.Fatalf("无法创建目录,%s :%s", p.Dir(), err) + log.Panicf("无法创建目录,%s :%s", p.Dir(), err) } log.Printf("开始创建 %d %s 的文件夹...\n", p.ID, p.Title) - creatREADME(p) + content, fc := getGraphql(p) + if fc == "" { + log.Panicf("查无Go语言写法") + } + + // 利用 chrome 打开题目页面 + // go func() { + // cmd := exec.Command("google-chrome", p.link()) + // _, err = cmd.Output() + // if err != nil { + // panic(err.Error()) + // } + // }() - fc := getFunction(p.link()) + // fc := getFunction(p.link()) - fcName, para, ans := parseFunction(fc) + fcName, para, ans, _ := parseFunction(fc) creatGo(p, fc, ans) creatGoTest(p, fcName, para, ans) - // 利用 chrome 打开题目 submissions 页面 - go func() { - cmd := exec.Command("google-chrome", "https://leetcode.com/submissions/") - _, err := cmd.Output() - if err != nil { - panic(err.Error()) - } - }() - - log.Println("等待 10 秒,打开题目页面") - time.Sleep(10 * time.Second) - - // 利用 chrome 打开题目页面 - go func() { - cmd := exec.Command("google-chrome", p.link()) - _, err := cmd.Output() - if err != nil { - panic(err.Error()) - } - }() - - log.Println("正在打开题目页面") - time.Sleep(2 * time.Second) + creatREADME(p, content) log.Printf("%d.%s 的文件夹,创建完毕。\n", p.ID, p.Title) } @@ -110,21 +99,37 @@ var typeMap = map[string]string{ func creatGo(p problem, function, ansType string) { fileFormat := `package %s - +%s %s ` - content := fmt.Sprintf(fileFormat, p.packageName(), function) - returns := "\treturn nil\n}" - if v, ok := typeMap[ansType]; ok { - returns = fmt.Sprintf("\treturn %s\n}", v) + treeNodeDefine := "" + if strings.Contains(function, "*TreeNode") { + treeNodeDefine = ` +import "github.com/aQuaYi/LeetCode-in-Go/kit" + +// TreeNode is pre-defined... +// type TreeNode struct { +// Val int +// Left *TreeNode +// Right *TreeNode +// } +type TreeNode = kit.TreeNode + +` } - content = strings.Replace(content, "}", returns, -1) + content := fmt.Sprintf(fileFormat, p.packageName(), treeNodeDefine, function) + + if v, ok := typeMap[ansType]; ok { + content = strings.Replace(content, "nil", v, 1) + } filename := fmt.Sprintf("%s/%s.go", p.Dir(), p.TitleSlug) write(filename, content) + + vscodeOpen(filename) } func creatGoTest(p problem, fcName, para, ansType string) { @@ -134,23 +139,24 @@ func creatGoTest(p problem, fcName, para, ansType string) { }{ - + // 可以有多个 testcase }` + para = strings.Replace(para, ",", "\n", -1) + testCases := fmt.Sprintf(testCasesFormat, para, ansType) testFuncFormat := ` func Test_%s(t *testing.T) { - ast := assert.New(t) - + a := assert.New(t) + for _, tc := range tcs { - fmt.Printf("~~%s~~\n", tc) - ast.Equal(tc.ans, %s(%s), "输入:%s", tc) + a.Equal(tc.ans, %s(%s), "输入:%s", tc) } }` tcPara := getTcPara(para) - testFunc := fmt.Sprintf(testFuncFormat, fcName, `%v`, fcName, tcPara, `%v`) + testFunc := fmt.Sprintf(testFuncFormat, fcName, fcName, tcPara, `%v`) benchFuncFormat := ` func Benchmark_%s(b *testing.B) { @@ -165,7 +171,6 @@ func Benchmark_%s(b *testing.B) { fileFormat := `package %s import ( - "fmt" "testing" "github.com/stretchr/testify/assert" @@ -183,6 +188,8 @@ import ( write(filename, content) + vscodeOpen(filename) + } // 把 函数的参数 变成 tc 的参数 diff --git a/Helper/buildReadme.go b/Helper/buildReadme.go index 67c0ce4ca..f5c5344f3 100644 --- a/Helper/buildReadme.go +++ b/Helper/buildReadme.go @@ -1,9 +1,7 @@ package main import ( - "bufio" "bytes" - "fmt" "html/template" "io/ioutil" "log" @@ -14,8 +12,11 @@ func buildReadme() { log.Println("开始,重建 README 文档") lc := newLeetCode() + makeReadmeFile(lc) + makeMyFavoriteFile(lc) + log.Println("完成,重建 README 文档") } @@ -24,21 +25,18 @@ func makeReadmeFile(lc *leetcode) { os.Remove(file) var b bytes.Buffer - writer := bufio.NewWriter(&b) tmpl := template.Must(template.New("readme").Parse(readTMPL("template.markdown"))) - tmpl.Execute(writer, lc) + err := tmpl.Execute(&b, lc) + if err != nil { + log.Fatal(err) + } // 保存 README.md 文件 write(file, string(b.Bytes())) } -func getHead(lc *leetcode) string { - headFormat := string(read("README_HEAD.md")) - return fmt.Sprintf(headFormat, lc.Username, lc.Ranking, lc.Username) -} - func readTMPL(path string) string { file, err := os.Open(path) if err != nil { @@ -53,3 +51,20 @@ func readTMPL(path string) string { return string(data) } + +func makeMyFavoriteFile(lc *leetcode) { + file := "Favorite.md" + os.Remove(file) + + var b bytes.Buffer + + tmpl := template.Must(template.New("favorite").Parse(readTMPL("favorite.markdown"))) + + err := tmpl.Execute(&b, lc) + if err != nil { + log.Fatal(err) + } + + // 保存 README.md 文件 + write(file, string(b.Bytes())) +} diff --git a/Helper/cli.go b/Helper/cli.go index bbb75797a..8b482c7f1 100644 --- a/Helper/cli.go +++ b/Helper/cli.go @@ -29,7 +29,7 @@ func (c *CLI) printUsage() { fmt.Println(USAGE) } -func (c *CLI) validateArgs() { +func (c *CLI) checkArgs() { if len(os.Args) < 2 { c.printUsage() os.Exit(1) @@ -38,7 +38,7 @@ func (c *CLI) validateArgs() { // Run parses command line arguments and processes commands func (c *CLI) Run() { - c.validateArgs() + c.checkArgs() readmeCmd := flag.NewFlagSet("readme", flag.ExitOnError) diff --git a/Helper/config.go b/Helper/config.go index 9aec2b70b..b2c78f007 100644 --- a/Helper/config.go +++ b/Helper/config.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "log" "github.com/BurntSushi/toml" @@ -13,21 +14,36 @@ const ( type config struct { Username string Password string + Cookie string // 以下是电子邮件设置 - SMTP string - Port int - From string - To string - EmailPasswd string + SMTP string + Port int + From string + To string + EmailPassword string +} + +func (c config) String() string { + format := "Username: %s, Password: %s, SMTP: %s, Port: %d, From: %s, To: %s, EmailPassword: %s " + return fmt.Sprintf(format, + c.Username, + c.Password, + c.SMTP, + c.Port, + c.From, + c.To, + c.EmailPassword) } func getConfig() *config { cfg := new(config) if _, err := toml.DecodeFile(configTOML, &cfg); err != nil { - log.Fatalf(err.Error()) + log.Panicf(err.Error()) } + // log.Printf("get config: %s", cfg) + return cfg } diff --git a/Helper/dida.go b/Helper/dida.go index 81cfce80d..a13a286a4 100644 --- a/Helper/dida.go +++ b/Helper/dida.go @@ -7,7 +7,7 @@ import ( "os" "time" - gomail "gopkg.in/gomail.v2" + mail "gopkg.in/gomail.v2" ) const ( @@ -15,25 +15,29 @@ const ( ) func dida(prefix string, p problem) { - task := p.didaTask(prefix) - mailToDida(task) + // 不再往滴答清单中添加任务 + // task := p.didaTask(prefix) + // mailToDida(task) } func mailToDida(task string) { - cfg := getConfig() + task += " ^LeetCode " + task = delay(task) - if cfg.SMTP == "" || cfg.Port == 0 || cfg.EmailPasswd == "" || + cfg := getConfig() + if cfg.SMTP == "" || cfg.Port == 0 || cfg.EmailPassword == "" || cfg.From == "" || cfg.To == "" { - log.Println("没有配置 Email,无法发送任务") + log.Printf("%v, 没有配置 Email,无法发送任务", cfg) + saveLocal(task) + return } - m := gomail.NewMessage() + m := mail.NewMessage() m.SetHeader("From", cfg.From) m.SetHeader("To", cfg.To) - task = delay(task) m.SetHeader("Subject", task) m.SetBody("text/plain", fmt.Sprintf("添加日期 %s", time.Now())) - d := gomail.NewDialer(cfg.SMTP, cfg.Port, cfg.From, cfg.EmailPasswd) + d := mail.NewDialer(cfg.SMTP, cfg.Port, cfg.From, cfg.EmailPassword) if err := d.DialAndSend(m); err != nil { log.Println("无法发送任务到 滴答清单:", err) @@ -48,7 +52,7 @@ func saveLocal(task string) { ts, err := ioutil.ReadFile(didaTaskFile) if err != nil { if !os.IsNotExist(err) { - log.Fatalf("无法读取 %s:%s\n", didaTaskFile, err) + log.Panicf("无法读取 %s:%s\n", didaTaskFile, err) } f, _ := os.Create(didaTaskFile) f.Close() @@ -58,7 +62,7 @@ func saveLocal(task string) { err = ioutil.WriteFile(didaTaskFile, ts, 0755) if err != nil { - log.Fatalf("无法写入 %s: %s\n", didaTaskFile, err) + log.Panicf("无法写入 %s: %s\n", didaTaskFile, err) } log.Printf("新建任务已经写入 %s,请手动添加到滴答清单", didaTaskFile) @@ -72,10 +76,9 @@ var m = map[string]time.Duration{ func delay(task string) string { key := task[:3] - task += " ^LeetCode " if day, ok := m[key]; ok { task += time.Now().Add(time.Hour * 24 * day).Format("2006-01-02") - m[key]++ + m[key] += 2 } return task } diff --git a/Helper/leetcode-algorithms.go b/Helper/leetcode-algorithms.go index ad355f712..37cc27218 100644 --- a/Helper/leetcode-algorithms.go +++ b/Helper/leetcode-algorithms.go @@ -46,11 +46,12 @@ func getAlgorithms() *algorithms { res := new(algorithms) if err := json.Unmarshal(raw, res); err != nil { - log.Fatalf("无法把json转换成Category: %s\n", err.Error()) + log.Panicf("无法把json转换成Category: %s\n", err.Error()) } // 如果,没有登录的话,也能获取数据,但是用户名,就不是本人 if res.User != getConfig().Username { + log.Printf("res.User = %s\n", res.User) log.Fatal("没有获取到本人的数据") } diff --git a/Helper/leetcode-getGraphql.go b/Helper/leetcode-getGraphql.go new file mode 100644 index 000000000..1de75871a --- /dev/null +++ b/Helper/leetcode-getGraphql.go @@ -0,0 +1,75 @@ +package main + +import ( + "bytes" + "encoding/json" + "io/ioutil" + "log" + "net/http" +) + +type JsL4CodeSnippets []struct { + Lang string + Code string +} + +type JsL3Detail struct { + Content string + CodeSnippets JsL4CodeSnippets +} + +type JsL2Question struct { + Question JsL3Detail +} + +type JsL1Data struct { + Data JsL2Question +} + +func getGraphql(p problem) (string, string) { + // req := newReq() + + params := make(map[string]interface{}) + params["operationName"] = "questionData" + params["query"] = "query questionData($titleSlug: String!) { question(titleSlug: $titleSlug) { content codeSnippets { lang code } } }" + titleSlug := make(map[string]string) + titleSlug["titleSlug"] = p.TitleSlug + params["variables"] = titleSlug + + // Make this JSON + postJson, _ := json.Marshal(params) + + // http.POST expects an io.Reader, which a byte buffer does + postContent := bytes.NewBuffer(postJson) + + resp, err := http.Post("https://leetcode.com/graphql", "application/json", postContent) + if err != nil { + log.Fatal("getGraphql: POST Error: " + err.Error()) + } + + defer resp.Body.Close() + + if resp.StatusCode != 200 { + log.Fatal("抓题失败 code: " + resp.Status) + } + + respBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + log.Fatal("getGraphql: Read Error: " + err.Error()) + } + + //byte数组直接转成string,优化内存 + // str := (*string)(unsafe.Pointer(&respBytes)) + // fmt.Printf("%#v\n", *str) + + res := &JsL1Data{} + json.Unmarshal(respBytes, &res) + + code := "" + for _, qc := range res.Data.Question.CodeSnippets { + if qc.Lang == "Go" { + code = qc.Code + } + } + return res.Data.Question.Content, code +} diff --git a/Helper/leetcode-getRanking.go b/Helper/leetcode-getRanking.go index 02ae12f15..a5793bb62 100644 --- a/Helper/leetcode-getRanking.go +++ b/Helper/leetcode-getRanking.go @@ -42,7 +42,7 @@ func getRanking() int { r, err := strconv.Atoi(str) if err != nil { - log.Fatalf("无法把 %s 转换成数字Ranking", str) + log.Panicf("无法把 %s 转换成数字Ranking", str) } return r diff --git a/Helper/leetcode-new.go b/Helper/leetcode-new.go index b54ba9a6b..de988a667 100644 --- a/Helper/leetcode-new.go +++ b/Helper/leetcode-new.go @@ -50,13 +50,13 @@ func readUnavailable() map[int]bool { } if !GoKit.Exist(unavailableFile) { - log.Fatalf("%s 不存在,没有不能解答的题目", unavailableFile) + log.Panicf("%s 不存在,没有不能解答的题目", unavailableFile) } raw := read(unavailableFile) u := unavailable{} if err := json.Unmarshal(raw, &u); err != nil { - log.Fatalf("获取 %s 失败:%s", unavailableFile, err) + log.Panicf("获取 %s 失败:%s", unavailableFile, err) } res := make(map[int]bool, len(u.List)) diff --git a/Helper/leetcode.go b/Helper/leetcode.go index 32149ab12..fb7615a63 100644 --- a/Helper/leetcode.go +++ b/Helper/leetcode.go @@ -57,7 +57,7 @@ func readLeetCode() (*leetcode, error) { func (lc *leetcode) save() { if err := os.Remove(leetCodeJSON); err != nil { - log.Fatalf("删除 %s 失败,原因是:%s", leetCodeJSON, err) + log.Panicf("删除 %s 失败,原因是:%s", leetCodeJSON, err) } raw, err := json.MarshalIndent(lc, "", "\t") @@ -65,7 +65,7 @@ func (lc *leetcode) save() { log.Fatal("无法把Leetcode数据转换成[]bytes: ", err) } if err = ioutil.WriteFile(leetCodeJSON, raw, 0666); err != nil { - log.Fatal("无法把Marshal后的lc保存到文件: ", err) + log.Fatal("无法把 Marshal 后的 lc 保存到文件: ", err) } log.Println("最新的 LeetCode 记录已经保存。") return @@ -79,6 +79,7 @@ func (lc *leetcode) refresh() { log.Println("开始,刷新 LeetCode 数据") newLC := getLeetCode() + logDiff(lc, newLC) *lc = *newLC @@ -94,12 +95,13 @@ func logDiff(old, new *leetcode) { str += fmt.Sprintf(",%s了 %d 名", verb, delta) log.Println(str) - // 检查新旧都有的问题 lenOld, lenNew := len(old.Problems), len(new.Problems) hasNewFinished := false i := 0 - for i < lenOld { + + // 检查新旧都有的问题 + for i < lenOld && i < lenNew { o, n := old.Problems[i], new.Problems[i] // 检查是 n 是否是新 完成 if o.IsAccepted == false && n.IsAccepted == true { @@ -116,20 +118,28 @@ func logDiff(old, new *leetcode) { time.Sleep(time.Second) } + // 有时候,会在中间添加新题 + if o.Title == "" && n.Title != "" { + log.Printf("新题: %d - %s", new.Problems[i].ID, new.Problems[i].Title) + dida("do", n) + } + i++ } + log.Printf("已经检查完了 %d 题\n", i) + if !hasNewFinished { log.Println("~ 没有新完成习题 ~") } // 检查新添加的习题 for i < lenNew { - if new.Problems[i].isAvailble() { + if new.Problems[i].isAvailable() { log.Printf("新题: %d - %s", new.Problems[i].ID, new.Problems[i].Title) dida("do", new.Problems[i]) - i++ } + i++ } } @@ -141,6 +151,16 @@ func (lc *leetcode) AvailableTable() string { return lc.Problems.available().table() } +func (lc *leetcode) FavoriteTable() string { + return lc.Problems.favorite().table() +} + +func (lc *leetcode) FavoriteCount() int { + return len(lc.Problems.favorite()) +} + func (lc *leetcode) UnavailableList() string { - return lc.Problems.unavailable().list() + res := lc.Problems.unavailable().list() + // 为了 README.md 文档的美观,需要删除最后一个换行符号 + return res[:len(res)-1] } diff --git a/Helper/main.go b/Helper/main.go index fde3e25ad..9c9f363dd 100644 --- a/Helper/main.go +++ b/Helper/main.go @@ -6,7 +6,7 @@ import ( // 程序辅助设置 const ( - VERSION = "6.1.16" + VERSION = "7.0.8" ) func main() { diff --git a/Helper/problem.go b/Helper/problem.go index 7690d8b8c..36719621e 100644 --- a/Helper/problem.go +++ b/Helper/problem.go @@ -34,7 +34,7 @@ func newProblem(ps problemStatus) problem { return p } -func (p problem) isAvailble() bool { +func (p problem) isAvailable() bool { if p.ID == 0 || p.IsPaid || p.HasNoGoOption { return false } @@ -52,7 +52,7 @@ func (p problem) link() string { func (p problem) tableLine() string { // 题号 - res := fmt.Sprintf("|%d|", p.ID) + res := fmt.Sprintf("|[%04d](%s)|", p.ID, p.link()) // 标题 t := "" diff --git a/Helper/problemGoFile.go b/Helper/problemGoFile.go index ba73ea216..bae9b9832 100644 --- a/Helper/problemGoFile.go +++ b/Helper/problemGoFile.go @@ -1,14 +1,25 @@ package main import ( - "context" + "bufio" + "fmt" "log" + "os" "strings" - - "github.com/chromedp/chromedp" ) -func parseFunction(fc string) (fcName, para, ansType string) { +func parseFunction(fc string) (fcName, para, ansType, nfc string) { + log.Println("正在分解函数") + + defer func() { // 必须要先声明defer,否则不能捕获到panic异常 + if err := recover(); err != nil { + fcName = "myFunc" + para = "p int" + ansType = "int" + nfc = "func myFunc(p int) int {\n\nreturn nil\n}" + } + }() + funcIndex := strings.Index(fc, "func ") a := funcIndex + strings.Index(fc[funcIndex:], " ") b := funcIndex + strings.Index(fc[funcIndex:], "(") @@ -16,55 +27,25 @@ func parseFunction(fc string) (fcName, para, ansType string) { d := funcIndex + strings.Index(fc[funcIndex:], "{") fcName = fc[a+1 : b] - para = strings.Replace(fc[b+1:c], ",", "\n", -1) + para = fc[b+1 : c] ansType = strings.TrimSpace(fc[c+1 : d]) + nfc = fmt.Sprintf("func %s(%s) %s {\n\nreturn nil\n}", fcName, para, ansType) return } func getFunction(url string) string { + inputReader := bufio.NewReader(os.Stdin) var err error - - // create context - ctxt, cancel := context.WithCancel(context.Background()) - defer cancel() - - // create chrome instance - c, err := chromedp.New(ctxt, chromedp.WithLog(log.Printf)) - if err != nil { - log.Fatal("chromedp.New 出错:", err) + fc := "" + for !strings.HasPrefix(fc, "func ") { + fmt.Print("请输入 Go 函数:") + fc, err = inputReader.ReadString('\n') + if err != nil { + log.Panicf("读取 Go 函数失败:%s", err) + } } - // run task list - var function string - err = c.Run(ctxt, makeTasks(url, &function)) - if err != nil { - log.Fatal("c.Run 出错:", err) - } + return fc - // shutdown chrome - err = c.Shutdown(ctxt) - if err != nil { - log.Fatal("c.Shutdown 出错:", err) - } - - // wait for chrome to finish - err = c.Wait() - if err != nil { - log.Fatal("c.Wait 出错:", err) - } - - return function -} - -func makeTasks(url string, function *string) chromedp.Tasks { - textarea := `//textarea` - btn := `#question-detail-app > div > div:nth-child(3) > div > div > div.row.control-btn-bar > div > div > div > div > span.Select-arrow-zone` - goSel := `#react-select-2--option-9` - return chromedp.Tasks{ - chromedp.Navigate(url), - chromedp.Click(btn, chromedp.ByID), - chromedp.Click(goSel, chromedp.ByID), - chromedp.Text(textarea, function), - } } diff --git a/Helper/problemReadme.go b/Helper/problemReadme.go index 2b294d1b9..b8ae5f559 100644 --- a/Helper/problemReadme.go +++ b/Helper/problemReadme.go @@ -2,63 +2,132 @@ package main import ( "fmt" - "log" + "sort" "strings" - "github.com/PuerkitoBio/goquery" + "github.com/TruthHun/html2md" ) -func creatREADME(p problem) { +func creatREADME(p problem, s string) { fileFormat := `# [%d. %s](%s) -## 题目 - %s -## 解题思路 - -见程序注释 ` - questionDescription := getDescription(p.link()) + questionDescription := strings.TrimSpace(getDescription(p.link())) - content := fmt.Sprintf(fileFormat, p.ID, p.Title, p.link(), questionDescription) + content := fmt.Sprintf(fileFormat, p.ID, p.Title, p.link(), questionDescription) + s + "\n\n## 解题思路\n\n## 可能的變化" content = replaceCharacters(content) + content = html2md.Convert(content) + filename := fmt.Sprintf("%s/README.md", p.Dir()) write(filename, content) + vscodeOpen(filename) + } -func getDescription(url string) string { - doc, err := goquery.NewDocument(url) - if err != nil { - log.Fatal(err) +func replaceCharacters(s string) string { + changeMap := map[string]string{ + "&lt;": "<", + "&quot;": "\"", + "&nbsp;": " ", + "&#39;": "`", + """: "\"", + "<": "<", + ">": ">", + "≥": ">=", + " ": " ", + "&": "&", + "'": "'", + " \n": "\n", + " \n": "\n", + " \n": "\n", + "\n\n\n\n\n": "\n\n", + "\n\n\n\n": "\n\n", + "\n\n\n": "\n\n", } - var desc string - - doc.Find("meta[name=description]").Each(func(i int, selection *goquery.Selection) { - desc, _ = selection.Attr("content") - }) + olds := make([]string, 0, len(changeMap)) + for old := range changeMap { + olds = append(olds, old) + } - return desc -} + sort.Strings(olds) -func replaceCharacters(s string) string { - changeMap := map[string]string{ - """: "\"", - "<": "<", - ">": ">", - " ": "", - "'": "'", - "&": "&", - "\n\n\n": "\n\n", - " \n": "\n", + news := make([]string, 0, len(olds)) + for _, old := range olds { + news = append(news, changeMap[old]) } - for old, new := range changeMap { + + for i := len(olds) - 1; 0 <= i; i-- { + // 先替换长的,再替换短的 + old, new := olds[i], news[i] s = strings.Replace(s, old, new, -1) } + return s + } + +func getDescription(url string) string { + return "" +} + +// func getDescription(url string) string { +// var err error + +// // create context +// ctxt, cancel := context.WithCancel(context.Background()) +// defer cancel() + +// var options chromedp.Option +// options = chromedp.WithRunnerOptions( +// runner.Flag("headless", true), +// runner.Flag("no-sandbox", true), +// runner.Flag("disable-gpu", true), +// ) + +// log.Println("chromedp timeout:", chromedp.DefaultNewTargetTimeout) + +// // create chrome instance +// c, err := chromedp.New(ctxt, options) +// if err != nil { +// log.Fatal(err) +// } + +// // run task list +// var res string +// err = c.Run(ctxt, text(url, &res)) +// if err != nil { +// log.Fatal(err) +// } + +// // shutdown chrome +// err = c.Shutdown(ctxt) +// if err != nil { +// log.Fatal(err) +// } + +// // wait for chrome to finish +// err = c.Wait() +// if err != nil { +// log.Fatal(err) +// } + +// log.Println("Desc:", res) + +// return res +// } + +// func text(url string, res *string) chromedp.Tasks { +// sel := `div.content__eAC7` +// return chromedp.Tasks{ +// chromedp.Sleep(time.Second * 3), +// chromedp.Navigate(url), +// chromedp.Text(sel, res, chromedp.NodeVisible, chromedp.BySearch), +// } +// } diff --git a/Helper/problems.go b/Helper/problems.go index 82cce0792..b19fbd8d5 100644 --- a/Helper/problems.go +++ b/Helper/problems.go @@ -21,8 +21,22 @@ func (ps problems) accepted() problems { func (ps problems) available() problems { res := make([]problem, 0, len(ps)) - for _, p := range ps { - if p.isAvailble() { + size := len(ps) + for i := size - 1; i >= 0; i-- { + p := ps[i] + if p.isAvailable() { + res = append(res, p) + } + } + return res +} + +func (ps problems) favorite() problems { + res := make([]problem, 0, len(ps)) + size := len(ps) + for i := 0; i < size; i++ { + p := ps[i] + if p.IsFavor { res = append(res, p) } } diff --git a/Helper/record.go b/Helper/record.go index 22380778c..44cc4dd7d 100644 --- a/Helper/record.go +++ b/Helper/record.go @@ -22,13 +22,13 @@ func (r *record) progressTable() string { res += fmt.Sprintf("|**Total**|%d|", r.Easy.Total) res += fmt.Sprintf("%d|", r.Medium.Total) res += fmt.Sprintf("%d|", r.Hard.Total) - res += fmt.Sprintf("%d|\n", r.Total.Total) + res += fmt.Sprintf("%d|", r.Total.Total) return res } func (r *record) update(p problem) { - if !p.isAvailble() { + if !p.isAvailable() { return } switch p.Difficulty { diff --git a/Helper/signin.go b/Helper/signin.go index bd71f35e6..6ed97f200 100644 --- a/Helper/signin.go +++ b/Helper/signin.go @@ -3,7 +3,6 @@ package main import ( "log" "net/http" - "regexp" "github.com/mozillazg/request" ) @@ -24,7 +23,7 @@ func newReq() *request.Request { // 登录 leetcode // 返回的 req 带有 cookie func signin() *request.Request { - log.Println("正在登录中...") + // log.Println("正在登录中...") cfg := getConfig() // 对 req 赋值 @@ -32,49 +31,48 @@ func signin() *request.Request { // 配置request req.Headers = map[string]string{ + "Content-Type": "application/json", "Accept-Encoding": "", - "Referer": "https://leetcode.com/", + "cookie": cfg.Cookie, + "Referer": "https://leetcode.com/accounts/login/", + "origin": "https://leetcode.com", } // login - csrfToken, err := getCSRFToken(req) - if err != nil { - log.Fatal(err) - } - req.Data = map[string]string{ - "csrfmiddlewaretoken": csrfToken, - "login": cfg.Username, - "password": cfg.Password, - } - if err = login(req); err != nil { - log.Fatal(err) - } + // csrfToken := getCSRFToken(req) + + // log.Printf("csrfToken: %s", csrfToken) - log.Println("成功登录") + // req.Data = map[string]string{ + // "csrfmiddlewaretoken": csrfToken, + // "login": cfg.Username, + // "password": cfg.Password, + // "next": "problems", + // } + // if err := login(req); err != nil { + // log.Fatal(err) + // } + + // log.Println("成功登录") return req } -func getCSRFToken(req *request.Request) (string, error) { +func getCSRFToken(req *request.Request) string { resp, err := req.Get(loginPageURL) if err != nil { - return "", err - } - s, err := resp.Text() - if err != nil { - return "", err + log.Panicf("无法 Get 到 %s: %s", loginPageURL, err) } - reInput := regexp.MustCompile( - `]*?name=['"]csrfmiddlewaretoken['"'][^>]*>`, - ) - input := reInput.FindString(s) - reValue := regexp.MustCompile(`value=['"]([^'"]+)['"]`) - csrfToken := reValue.FindStringSubmatch(input) - if len(csrfToken) < 2 { - return "", err + cookies := resp.Cookies() + + for _, ck := range cookies { + if ck.Name == "csrftoken" { + return ck.Value + } } - return csrfToken[1], err + + panic("无法在 Cookies 中找到 csrftoken") } func login(req *request.Request) error { diff --git a/Helper/util.go b/Helper/util.go index 4b0b36a17..c55603e60 100644 --- a/Helper/util.go +++ b/Helper/util.go @@ -4,6 +4,7 @@ import ( "io/ioutil" "log" "os" + "os/exec" ) func max(a, b int) int { @@ -32,3 +33,12 @@ func write(path, content string) { log.Fatal(err) } } + +// 利用 VSCode 打开文件 +func vscodeOpen(filename string) { + cmd := exec.Command("code", "-r", filename) + _, err := cmd.Output() + if err != nil { + panic(err.Error()) + } +} diff --git a/Makefile b/Makefile index 626fff1b0..4570ec3af 100644 --- a/Makefile +++ b/Makefile @@ -5,4 +5,5 @@ run: git checkout master git merge develop git push - git checkout develop \ No newline at end of file + git checkout develop + google-chrome https://github.com/aQuaYi/LeetCode-in-Go#leetcode-%E7%9A%84-go-%E8%A7%A3%E7%AD%94 \ No newline at end of file diff --git a/README.md b/README.md index c15b9d0c7..4ae1b1098 100755 --- a/README.md +++ b/README.md @@ -1,621 +1,1013 @@ -# [LeetCode](https://leetcode.com) 的 Go 解答 +# [LeetCode](https://leetcode.com) 的 Go 解答 -[![LeetCode 排名](https://img.shields.io/badge/aQuaYi-1057-blue.svg)](https://leetcode.com/aQuaYi/) +[![LeetCode 排名](https://img.shields.io/badge/aQuaYi-646-blue.svg)](https://leetcode.com/aQuaYi/) [![codecov](https://codecov.io/gh/aQuaYi/LeetCode-in-Go/branch/master/graph/badge.svg)](https://codecov.io/gh/aQuaYi/LeetCode-in-Go) [![Build Status](https://www.travis-ci.org/aQuaYi/LeetCode-in-Go.svg?branch=master)](https://www.travis-ci.org/aQuaYi/LeetCode-in-Go) + [![Go](https://img.shields.io/badge/Go-1.13-blue.svg)](https://golang.google.cn) ## 进度 -> 统计规则:1.免费题,2.算法题,3.能用 Go 解答 +> 统计规则:1.免费题,2.算法题,3.能提交 Go 解答 | |Easy|Medium|Hard|Total| |:---:|:---:|:---:|:---:|:---:| -|**Accepted**|170|292|124|586| -|**Total**|173|299|129|601| - +|**Accepted**|265|456|187|908| +|**Total**|267|472|197|936| ## 题解 |题号|题目|通过率|难度|收藏| |:-:|:-|:-: | :-: | :-: | -|1|[Two Sum](./Algorithms/0001.two-sum)|38%|Easy|| -|2|[Add Two Numbers](./Algorithms/0002.add-two-numbers)|28%|Medium|| -|3|[Longest Substring Without Repeating Characters](./Algorithms/0003.longest-substring-without-repeating-characters)|24%|Medium|| -|4|[Median of Two Sorted Arrays](./Algorithms/0004.median-of-two-sorted-arrays)|23%|Hard|| -|5|[Longest Palindromic Substring](./Algorithms/0005.longest-palindromic-substring)|25%|Medium|| -|6|[ZigZag Conversion](./Algorithms/0006.zigzag-conversion)|27%|Medium|| -|7|[Reverse Integer](./Algorithms/0007.reverse-integer)|24%|Easy|| -|8|[String to Integer (atoi)](./Algorithms/0008.string-to-integer-atoi)|14%|Medium|| -|9|[Palindrome Number](./Algorithms/0009.palindrome-number)|36%|Easy|| -|10|[Regular Expression Matching](./Algorithms/0010.regular-expression-matching)|24%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|11|[Container With Most Water](./Algorithms/0011.container-with-most-water)|37%|Medium|| -|12|[Integer to Roman](./Algorithms/0012.integer-to-roman)|46%|Medium|| -|13|[Roman to Integer](./Algorithms/0013.roman-to-integer)|48%|Easy|| -|14|[Longest Common Prefix](./Algorithms/0014.longest-common-prefix)|31%|Easy|| -|15|[3Sum](./Algorithms/0015.3sum)|21%|Medium|| -|16|[3Sum Closest](./Algorithms/0016.3sum-closest)|31%|Medium|| -|17|[Letter Combinations of a Phone Number](./Algorithms/0017.letter-combinations-of-a-phone-number)|36%|Medium|| -|18|[4Sum](./Algorithms/0018.4sum)|27%|Medium|| -|19|[Remove Nth Node From End of List](./Algorithms/0019.remove-nth-node-from-end-of-list)|33%|Medium|| -|20|[Valid Parentheses](./Algorithms/0020.valid-parentheses)|34%|Easy|| -|21|[Merge Two Sorted Lists](./Algorithms/0021.merge-two-sorted-lists)|41%|Easy|| -|22|[Generate Parentheses](./Algorithms/0022.generate-parentheses)|48%|Medium|| -|23|[Merge k Sorted Lists](./Algorithms/0023.merge-k-sorted-lists)|28%|Hard|| -|24|[Swap Nodes in Pairs](./Algorithms/0024.swap-nodes-in-pairs)|39%|Medium|| -|25|[Reverse Nodes in k-Group](./Algorithms/0025.reverse-nodes-in-k-group)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|26|[Remove Duplicates from Sorted Array](./Algorithms/0026.remove-duplicates-from-sorted-array)|36%|Easy|| -|27|[Remove Element](./Algorithms/0027.remove-element)|41%|Easy|| -|28|[Implement strStr()](./Algorithms/0028.implement-strstr)|29%|Easy|| -|29|[Divide Two Integers](./Algorithms/0029.divide-two-integers)|15%|Medium|| -|30|[Substring with Concatenation of All Words](./Algorithms/0030.substring-with-concatenation-of-all-words)|22%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|31|[Next Permutation](./Algorithms/0031.next-permutation)|29%|Medium|| -|32|[Longest Valid Parentheses](./Algorithms/0032.longest-valid-parentheses)|23%|Hard|| -|33|[Search in Rotated Sorted Array](./Algorithms/0033.search-in-rotated-sorted-array)|31%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|34|[Search for a Range](./Algorithms/0034.search-for-a-range)|31%|Medium|| -|35|[Search Insert Position](./Algorithms/0035.search-insert-position)|40%|Easy|| -|36|[Valid Sudoku](./Algorithms/0036.valid-sudoku)|38%|Medium|| -|37|[Sudoku Solver](./Algorithms/0037.sudoku-solver)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|38|[Count and Say](./Algorithms/0038.count-and-say)|37%|Easy|| -|39|[Combination Sum](./Algorithms/0039.combination-sum)|41%|Medium|| -|40|[Combination Sum II](./Algorithms/0040.combination-sum-ii)|36%|Medium|| -|41|[First Missing Positive](./Algorithms/0041.first-missing-positive)|26%|Hard|| -|42|[Trapping Rain Water](./Algorithms/0042.trapping-rain-water)|37%|Hard|| -|43|[Multiply Strings](./Algorithms/0043.multiply-strings)|28%|Medium|| -|44|[Wildcard Matching](./Algorithms/0044.wildcard-matching)|21%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|45|[Jump Game II](./Algorithms/0045.jump-game-ii)|26%|Hard|| -|46|[Permutations](./Algorithms/0046.permutations)|47%|Medium|| -|47|[Permutations II](./Algorithms/0047.permutations-ii)|35%|Medium|| -|48|[Rotate Image](./Algorithms/0048.rotate-image)|42%|Medium|| -|49|[Group Anagrams](./Algorithms/0049.group-anagrams)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|50|[Pow(x, n)](./Algorithms/0050.powx-n)|26%|Medium|| -|51|[N-Queens](./Algorithms/0051.n-queens)|33%|Hard|| -|52|[N-Queens II](./Algorithms/0052.n-queens-ii)|47%|Hard|| -|53|[Maximum Subarray](./Algorithms/0053.maximum-subarray)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|54|[Spiral Matrix](./Algorithms/0054.spiral-matrix)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|55|[Jump Game](./Algorithms/0055.jump-game)|29%|Medium|| -|56|[Merge Intervals](./Algorithms/0056.merge-intervals)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|57|[Insert Interval](./Algorithms/0057.insert-interval)|29%|Hard|| -|58|[Length of Last Word](./Algorithms/0058.length-of-last-word)|32%|Easy|| -|59|[Spiral Matrix II](./Algorithms/0059.spiral-matrix-ii)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|60|[Permutation Sequence](./Algorithms/0060.permutation-sequence)|29%|Medium|| -|61|[Rotate List](./Algorithms/0061.rotate-list)|24%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|62|[Unique Paths](./Algorithms/0062.unique-paths)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|63|[Unique Paths II](./Algorithms/0063.unique-paths-ii)|32%|Medium|| -|64|[Minimum Path Sum](./Algorithms/0064.minimum-path-sum)|41%|Medium|| -|65|[Valid Number](./Algorithms/0065.valid-number)|12%|Hard|| -|66|[Plus One](./Algorithms/0066.plus-one)|39%|Easy|| -|67|[Add Binary](./Algorithms/0067.add-binary)|34%|Easy|| -|68|[Text Justification](./Algorithms/0068.text-justification)|20%|Hard|| -|69|[Sqrt(x)](./Algorithms/0069.sqrtx)|29%|Easy|| -|70|[Climbing Stairs](./Algorithms/0070.climbing-stairs)|41%|Easy|| -|71|[Simplify Path](./Algorithms/0071.simplify-path)|26%|Medium|| -|72|[Edit Distance](./Algorithms/0072.edit-distance)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|73|[Set Matrix Zeroes](./Algorithms/0073.set-matrix-zeroes)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|74|[Search a 2D Matrix](./Algorithms/0074.search-a-2d-matrix)|34%|Medium|| -|75|[Sort Colors](./Algorithms/0075.sort-colors)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|76|[Minimum Window Substring](./Algorithms/0076.minimum-window-substring)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|77|[Combinations](./Algorithms/0077.combinations)|41%|Medium|| -|78|[Subsets](./Algorithms/0078.subsets)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|79|[Word Search](./Algorithms/0079.word-search)|28%|Medium|| -|80|[Remove Duplicates from Sorted Array II](./Algorithms/0080.remove-duplicates-from-sorted-array-ii)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|81|[Search in Rotated Sorted Array II](./Algorithms/0081.search-in-rotated-sorted-array-ii)|32%|Medium|| -|82|[Remove Duplicates from Sorted List II](./Algorithms/0082.remove-duplicates-from-sorted-list-ii)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|83|[Remove Duplicates from Sorted List](./Algorithms/0083.remove-duplicates-from-sorted-list)|40%|Easy|| -|84|[Largest Rectangle in Histogram](./Algorithms/0084.largest-rectangle-in-histogram)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|85|[Maximal Rectangle](./Algorithms/0085.maximal-rectangle)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|86|[Partition List](./Algorithms/0086.partition-list)|33%|Medium|| -|87|[Scramble String](./Algorithms/0087.scramble-string)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|88|[Merge Sorted Array](./Algorithms/0088.merge-sorted-array)|32%|Easy|| -|89|[Gray Code](./Algorithms/0089.gray-code)|42%|Medium|| -|90|[Subsets II](./Algorithms/0090.subsets-ii)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|91|[Decode Ways](./Algorithms/0091.decode-ways)|20%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|92|[Reverse Linked List II](./Algorithms/0092.reverse-linked-list-ii)|31%|Medium|| -|93|[Restore IP Addresses](./Algorithms/0093.restore-ip-addresses)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|94|[Binary Tree Inorder Traversal](./Algorithms/0094.binary-tree-inorder-traversal)|50%|Medium|| -|95|[Unique Binary Search Trees II](./Algorithms/0095.unique-binary-search-trees-ii)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|96|[Unique Binary Search Trees](./Algorithms/0096.unique-binary-search-trees)|42%|Medium|| -|97|[Interleaving String](./Algorithms/0097.interleaving-string)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|98|[Validate Binary Search Tree](./Algorithms/0098.validate-binary-search-tree)|24%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|99|[Recover Binary Search Tree](./Algorithms/0099.recover-binary-search-tree)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|100|[Same Tree](./Algorithms/0100.same-tree)|47%|Easy|| -|101|[Symmetric Tree](./Algorithms/0101.symmetric-tree)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|102|[Binary Tree Level Order Traversal](./Algorithms/0102.binary-tree-level-order-traversal)|43%|Medium|| -|103|[Binary Tree Zigzag Level Order Traversal](./Algorithms/0103.binary-tree-zigzag-level-order-traversal)|37%|Medium|| -|104|[Maximum Depth of Binary Tree](./Algorithms/0104.maximum-depth-of-binary-tree)|55%|Easy|| -|105|[Construct Binary Tree from Preorder and Inorder Traversal](./Algorithms/0105.construct-binary-tree-from-preorder-and-inorder-traversal)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|106|[Construct Binary Tree from Inorder and Postorder Traversal](./Algorithms/0106.construct-binary-tree-from-inorder-and-postorder-traversal)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|107|[Binary Tree Level Order Traversal II](./Algorithms/0107.binary-tree-level-order-traversal-ii)|42%|Easy|| -|108|[Convert Sorted Array to Binary Search Tree](./Algorithms/0108.convert-sorted-array-to-binary-search-tree)|45%|Easy|| -|109|[Convert Sorted List to Binary Search Tree](./Algorithms/0109.convert-sorted-list-to-binary-search-tree)|36%|Medium|| -|110|[Balanced Binary Tree](./Algorithms/0110.balanced-binary-tree)|38%|Easy|| -|111|[Minimum Depth of Binary Tree](./Algorithms/0111.minimum-depth-of-binary-tree)|33%|Easy|| -|112|[Path Sum](./Algorithms/0112.path-sum)|35%|Easy|| -|113|[Path Sum II](./Algorithms/0113.path-sum-ii)|36%|Medium|| -|114|[Flatten Binary Tree to Linked List](./Algorithms/0114.flatten-binary-tree-to-linked-list)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|115|[Distinct Subsequences](./Algorithms/0115.distinct-subsequences)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|118|[Pascal's Triangle](./Algorithms/0118.pascals-triangle)|40%|Easy|| -|119|[Pascal's Triangle II](./Algorithms/0119.pascals-triangle-ii)|38%|Easy|| -|120|[Triangle](./Algorithms/0120.triangle)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|121|[Best Time to Buy and Sell Stock](./Algorithms/0121.best-time-to-buy-and-sell-stock)|43%|Easy|| -|122|[Best Time to Buy and Sell Stock II](./Algorithms/0122.best-time-to-buy-and-sell-stock-ii)|48%|Easy|| -|123|[Best Time to Buy and Sell Stock III](./Algorithms/0123.best-time-to-buy-and-sell-stock-iii)|30%|Hard|| -|124|[Binary Tree Maximum Path Sum](./Algorithms/0124.binary-tree-maximum-path-sum)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|125|[Valid Palindrome](./Algorithms/0125.valid-palindrome)|27%|Easy|| -|126|[Word Ladder II](./Algorithms/0126.word-ladder-ii)|15%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|127|[Word Ladder](./Algorithms/0127.word-ladder)|20%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|128|[Longest Consecutive Sequence](./Algorithms/0128.longest-consecutive-sequence)|38%|Hard|| -|129|[Sum Root to Leaf Numbers](./Algorithms/0129.sum-root-to-leaf-numbers)|38%|Medium|| -|130|[Surrounded Regions](./Algorithms/0130.surrounded-regions)|19%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|131|[Palindrome Partitioning](./Algorithms/0131.palindrome-partitioning)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|132|[Palindrome Partitioning II](./Algorithms/0132.palindrome-partitioning-ii)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|134|[Gas Station](./Algorithms/0134.gas-station)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|135|[Candy](./Algorithms/0135.candy)|25%|Hard|| -|136|[Single Number](./Algorithms/0136.single-number)|55%|Easy|| -|137|[Single Number II](./Algorithms/0137.single-number-ii)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|139|[Word Break](./Algorithms/0139.word-break)|31%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|140|[Word Break II](./Algorithms/0140.word-break-ii)|24%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|143|[Reorder List](./Algorithms/0143.reorder-list)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|144|[Binary Tree Preorder Traversal](./Algorithms/0144.binary-tree-preorder-traversal)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|145|[Binary Tree Postorder Traversal](./Algorithms/0145.binary-tree-postorder-traversal)|42%|Hard|| -|146|[LRU Cache](./Algorithms/0146.lru-cache)|20%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|147|[Insertion Sort List](./Algorithms/0147.insertion-sort-list)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|148|[Sort List](./Algorithms/0148.sort-list)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|149|[Max Points on a Line](./Algorithms/0149.max-points-on-a-line)|15%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|150|[Evaluate Reverse Polish Notation](./Algorithms/0150.evaluate-reverse-polish-notation)|28%|Medium|| -|152|[Maximum Product Subarray](./Algorithms/0152.maximum-product-subarray)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|153|[Find Minimum in Rotated Sorted Array](./Algorithms/0153.find-minimum-in-rotated-sorted-array)|41%|Medium|| -|154|[Find Minimum in Rotated Sorted Array II](./Algorithms/0154.find-minimum-in-rotated-sorted-array-ii)|37%|Hard|| -|155|[Min Stack](./Algorithms/0155.min-stack)|31%|Easy|| -|162|[Find Peak Element](./Algorithms/0162.find-peak-element)|39%|Medium|| -|164|[Maximum Gap](./Algorithms/0164.maximum-gap)|30%|Hard|| -|165|[Compare Version Numbers](./Algorithms/0165.compare-version-numbers)|20%|Medium|| -|166|[Fraction to Recurring Decimal](./Algorithms/0166.fraction-to-recurring-decimal)|18%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|167|[Two Sum II - Input array is sorted](./Algorithms/0167.two-sum-ii-input-array-is-sorted)|47%|Easy|| -|168|[Excel Sheet Column Title](./Algorithms/0168.excel-sheet-column-title)|27%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|169|[Majority Element](./Algorithms/0169.majority-element)|48%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|171|[Excel Sheet Column Number](./Algorithms/0171.excel-sheet-column-number)|48%|Easy|| -|172|[Factorial Trailing Zeroes](./Algorithms/0172.factorial-trailing-zeroes)|37%|Easy|| -|174|[Dungeon Game](./Algorithms/0174.dungeon-game)|24%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|179|[Largest Number](./Algorithms/0179.largest-number)|23%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|187|[Repeated DNA Sequences](./Algorithms/0187.repeated-dna-sequences)|33%|Medium|| -|188|[Best Time to Buy and Sell Stock IV](./Algorithms/0188.best-time-to-buy-and-sell-stock-iv)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|189|[Rotate Array](./Algorithms/0189.rotate-array)|25%|Easy|| -|198|[House Robber](./Algorithms/0198.house-robber)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|199|[Binary Tree Right Side View](./Algorithms/0199.binary-tree-right-side-view)|42%|Medium|| -|200|[Number of Islands](./Algorithms/0200.number-of-islands)|36%|Medium|| -|201|[Bitwise AND of Numbers Range](./Algorithms/0201.bitwise-and-of-numbers-range)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|202|[Happy Number](./Algorithms/0202.happy-number)|41%|Easy|| -|203|[Remove Linked List Elements](./Algorithms/0203.remove-linked-list-elements)|33%|Easy|| -|204|[Count Primes](./Algorithms/0204.count-primes)|26%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|205|[Isomorphic Strings](./Algorithms/0205.isomorphic-strings)|34%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|206|[Reverse Linked List](./Algorithms/0206.reverse-linked-list)|47%|Easy|| -|207|[Course Schedule](./Algorithms/0207.course-schedule)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|208|[Implement Trie (Prefix Tree)](./Algorithms/0208.implement-trie-prefix-tree)|31%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|209|[Minimum Size Subarray Sum](./Algorithms/0209.minimum-size-subarray-sum)|32%|Medium|| -|210|[Course Schedule II](./Algorithms/0210.course-schedule-ii)|30%|Medium|| -|211|[Add and Search Word - Data structure design](./Algorithms/0211.add-and-search-word-data-structure-design)|25%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|212|[Word Search II](./Algorithms/0212.word-search-ii)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|213|[House Robber II](./Algorithms/0213.house-robber-ii)|34%|Medium|| -|214|[Shortest Palindrome](./Algorithms/0214.shortest-palindrome)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|215|[Kth Largest Element in an Array](./Algorithms/0215.kth-largest-element-in-an-array)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|216|[Combination Sum III](./Algorithms/0216.combination-sum-iii)|47%|Medium|| -|217|[Contains Duplicate](./Algorithms/0217.contains-duplicate)|47%|Easy|| -|218|[The Skyline Problem](./Algorithms/0218.the-skyline-problem)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|219|[Contains Duplicate II](./Algorithms/0219.contains-duplicate-ii)|32%|Easy|| -|220|[Contains Duplicate III](./Algorithms/0220.contains-duplicate-iii)|18%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|221|[Maximal Square](./Algorithms/0221.maximal-square)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|223|[Rectangle Area](./Algorithms/0223.rectangle-area)|33%|Medium|| -|224|[Basic Calculator](./Algorithms/0224.basic-calculator)|28%|Hard|| -|225|[Implement Stack using Queues](./Algorithms/0225.implement-stack-using-queues)|34%|Easy|| -|226|[Invert Binary Tree](./Algorithms/0226.invert-binary-tree)|53%|Easy|| -|227|[Basic Calculator II](./Algorithms/0227.basic-calculator-ii)|30%|Medium|| -|228|[Summary Ranges](./Algorithms/0228.summary-ranges)|32%|Medium|| -|229|[Majority Element II](./Algorithms/0229.majority-element-ii)|29%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|230|[Kth Smallest Element in a BST](./Algorithms/0230.kth-smallest-element-in-a-bst)|45%|Medium|| -|231|[Power of Two](./Algorithms/0231.power-of-two)|40%|Easy|| -|232|[Implement Queue using Stacks](./Algorithms/0232.implement-queue-using-stacks)|38%|Easy|| -|233|[Number of Digit One](./Algorithms/0233.number-of-digit-one)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|234|[Palindrome Linked List](./Algorithms/0234.palindrome-linked-list)|33%|Easy|| -|238|[Product of Array Except Self](./Algorithms/0238.product-of-array-except-self)|50%|Medium|| -|239|[Sliding Window Maximum](./Algorithms/0239.sliding-window-maximum)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|240|[Search a 2D Matrix II](./Algorithms/0240.search-a-2d-matrix-ii)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|241|[Different Ways to Add Parentheses](./Algorithms/0241.different-ways-to-add-parentheses)|46%|Medium|| -|242|[Valid Anagram](./Algorithms/0242.valid-anagram)|47%|Easy|| -|257|[Binary Tree Paths](./Algorithms/0257.binary-tree-paths)|41%|Easy|| -|258|[Add Digits](./Algorithms/0258.add-digits)|51%|Easy|| -|260|[Single Number III](./Algorithms/0260.single-number-iii)|53%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|263|[Ugly Number](./Algorithms/0263.ugly-number)|39%|Easy|| -|264|[Ugly Number II](./Algorithms/0264.ugly-number-ii)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|268|[Missing Number](./Algorithms/0268.missing-number)|45%|Easy|| -|273|[Integer to English Words](./Algorithms/0273.integer-to-english-words)|22%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|274|[H-Index](./Algorithms/0274.h-index)|33%|Medium|| -|275|[H-Index II](./Algorithms/0275.h-index-ii)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|279|[Perfect Squares](./Algorithms/0279.perfect-squares)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|282|[Expression Add Operators](./Algorithms/0282.expression-add-operators)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|283|[Move Zeroes](./Algorithms/0283.move-zeroes)|51%|Easy|| -|287|[Find the Duplicate Number](./Algorithms/0287.find-the-duplicate-number)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|289|[Game of Life](./Algorithms/0289.game-of-life)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|290|[Word Pattern](./Algorithms/0290.word-pattern)|33%|Easy|| -|292|[Nim Game](./Algorithms/0292.nim-game)|55%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|295|[Find Median from Data Stream](./Algorithms/0295.find-median-from-data-stream)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|299|[Bulls and Cows](./Algorithms/0299.bulls-and-cows)|36%|Medium|| -|300|[Longest Increasing Subsequence](./Algorithms/0300.longest-increasing-subsequence)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|301|[Remove Invalid Parentheses](./Algorithms/0301.remove-invalid-parentheses)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|303|[Range Sum Query - Immutable](./Algorithms/0303.range-sum-query-immutable)|32%|Easy|| -|304|[Range Sum Query 2D - Immutable](./Algorithms/0304.range-sum-query-2d-immutable)|27%|Medium|| -|306|[Additive Number](./Algorithms/0306.additive-number)|27%|Medium|| -|307|[Range Sum Query - Mutable](./Algorithms/0307.range-sum-query-mutable)|22%|Medium|| -|309|[Best Time to Buy and Sell Stock with Cooldown](./Algorithms/0309.best-time-to-buy-and-sell-stock-with-cooldown)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|310|[Minimum Height Trees](./Algorithms/0310.minimum-height-trees)|28%|Medium|| -|312|[Burst Balloons](./Algorithms/0312.burst-balloons)|43%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|313|[Super Ugly Number](./Algorithms/0313.super-ugly-number)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|315|[Count of Smaller Numbers After Self](./Algorithms/0315.count-of-smaller-numbers-after-self)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|316|[Remove Duplicate Letters](./Algorithms/0316.remove-duplicate-letters)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|318|[Maximum Product of Word Lengths](./Algorithms/0318.maximum-product-of-word-lengths)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|319|[Bulb Switcher](./Algorithms/0319.bulb-switcher)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|321|[Create Maximum Number](./Algorithms/0321.create-maximum-number)|24%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|322|[Coin Change](./Algorithms/0322.coin-change)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|324|[Wiggle Sort II](./Algorithms/0324.wiggle-sort-ii)|26%|Medium|| -|326|[Power of Three](./Algorithms/0326.power-of-three)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|327|[Count of Range Sum](./Algorithms/0327.count-of-range-sum)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|328|[Odd Even Linked List](./Algorithms/0328.odd-even-linked-list)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|329|[Longest Increasing Path in a Matrix](./Algorithms/0329.longest-increasing-path-in-a-matrix)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|330|[Patching Array](./Algorithms/0330.patching-array)|32%|Hard|| -|331|[Verify Preorder Serialization of a Binary Tree](./Algorithms/0331.verify-preorder-serialization-of-a-binary-tree)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|332|[Reconstruct Itinerary](./Algorithms/0332.reconstruct-itinerary)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|334|[Increasing Triplet Subsequence](./Algorithms/0334.increasing-triplet-subsequence)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|335|[Self Crossing](./Algorithms/0335.self-crossing)|26%|Hard|| -|336|[Palindrome Pairs](./Algorithms/0336.palindrome-pairs)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|337|[House Robber III](./Algorithms/0337.house-robber-iii)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|338|[Counting Bits](./Algorithms/0338.counting-bits)|62%|Medium|| -|342|[Power of Four](./Algorithms/0342.power-of-four)|39%|Easy|| -|343|[Integer Break](./Algorithms/0343.integer-break)|46%|Medium|| -|344|[Reverse String](./Algorithms/0344.reverse-string)|60%|Easy|| -|345|[Reverse Vowels of a String](./Algorithms/0345.reverse-vowels-of-a-string)|39%|Easy|| -|347|[Top K Frequent Elements](./Algorithms/0347.top-k-frequent-elements)|49%|Medium|| -|349|[Intersection of Two Arrays](./Algorithms/0349.intersection-of-two-arrays)|48%|Easy|| -|350|[Intersection of Two Arrays II](./Algorithms/0350.intersection-of-two-arrays-ii)|44%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|352|[Data Stream as Disjoint Intervals](./Algorithms/0352.data-stream-as-disjoint-intervals)|41%|Hard|| -|354|[Russian Doll Envelopes](./Algorithms/0354.russian-doll-envelopes)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|355|[Design Twitter](./Algorithms/0355.design-twitter)|25%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|357|[Count Numbers with Unique Digits](./Algorithms/0357.count-numbers-with-unique-digits)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|363|[Max Sum of Rectangle No Larger Than K](./Algorithms/0363.max-sum-of-rectangle-no-larger-than-k)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|365|[Water and Jug Problem](./Algorithms/0365.water-and-jug-problem)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|367|[Valid Perfect Square](./Algorithms/0367.valid-perfect-square)|38%|Easy|| -|368|[Largest Divisible Subset](./Algorithms/0368.largest-divisible-subset)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|371|[Sum of Two Integers](./Algorithms/0371.sum-of-two-integers)|50%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|372|[Super Pow](./Algorithms/0372.super-pow)|34%|Medium|| -|373|[Find K Pairs with Smallest Sums](./Algorithms/0373.find-k-pairs-with-smallest-sums)|31%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|375|[Guess Number Higher or Lower II](./Algorithms/0375.guess-number-higher-or-lower-ii)|36%|Medium|| -|376|[Wiggle Subsequence](./Algorithms/0376.wiggle-subsequence)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|377|[Combination Sum IV](./Algorithms/0377.combination-sum-iv)|42%|Medium|| -|378|[Kth Smallest Element in a Sorted Matrix](./Algorithms/0378.kth-smallest-element-in-a-sorted-matrix)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|380|[Insert Delete GetRandom O(1)](./Algorithms/0380.insert-delete-getrandom-o1)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|381|[Insert Delete GetRandom O(1) - Duplicates allowed](./Algorithms/0381.insert-delete-getrandom-o1-duplicates-allowed)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|382|[Linked List Random Node](./Algorithms/0382.linked-list-random-node)|47%|Medium|| -|383|[Ransom Note](./Algorithms/0383.ransom-note)|47%|Easy|| -|384|[Shuffle an Array](./Algorithms/0384.shuffle-an-array)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|385|[Mini Parser](./Algorithms/0385.mini-parser)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|387|[First Unique Character in a String](./Algorithms/0387.first-unique-character-in-a-string)|47%|Easy|| -|388|[Longest Absolute File Path](./Algorithms/0388.longest-absolute-file-path)|37%|Medium|| -|389|[Find the Difference](./Algorithms/0389.find-the-difference)|51%|Easy|| -|390|[Elimination Game](./Algorithms/0390.elimination-game)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|391|[Perfect Rectangle](./Algorithms/0391.perfect-rectangle)|27%|Hard|| -|392|[Is Subsequence](./Algorithms/0392.is-subsequence)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|393|[UTF-8 Validation](./Algorithms/0393.utf-8-validation)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|394|[Decode String](./Algorithms/0394.decode-string)|42%|Medium|| -|395|[Longest Substring with At Least K Repeating Characters](./Algorithms/0395.longest-substring-with-at-least-k-repeating-characters)|35%|Medium|| -|396|[Rotate Function](./Algorithms/0396.rotate-function)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|397|[Integer Replacement](./Algorithms/0397.integer-replacement)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|398|[Random Pick Index](./Algorithms/0398.random-pick-index)|44%|Medium|| -|399|[Evaluate Division](./Algorithms/0399.evaluate-division)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|400|[Nth Digit](./Algorithms/0400.nth-digit)|30%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|401|[Binary Watch](./Algorithms/0401.binary-watch)|44%|Easy|| -|402|[Remove K Digits](./Algorithms/0402.remove-k-digits)|25%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|403|[Frog Jump](./Algorithms/0403.frog-jump)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|404|[Sum of Left Leaves](./Algorithms/0404.sum-of-left-leaves)|47%|Easy|| -|405|[Convert a Number to Hexadecimal](./Algorithms/0405.convert-a-number-to-hexadecimal)|41%|Easy|| -|406|[Queue Reconstruction by Height](./Algorithms/0406.queue-reconstruction-by-height)|56%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|407|[Trapping Rain Water II](./Algorithms/0407.trapping-rain-water-ii)|37%|Hard|| -|409|[Longest Palindrome](./Algorithms/0409.longest-palindrome)|46%|Easy|| -|410|[Split Array Largest Sum](./Algorithms/0410.split-array-largest-sum)|39%|Hard|| -|412|[Fizz Buzz](./Algorithms/0412.fizz-buzz)|57%|Easy|| -|413|[Arithmetic Slices](./Algorithms/0413.arithmetic-slices)|54%|Medium|| -|414|[Third Maximum Number](./Algorithms/0414.third-maximum-number)|28%|Easy|| -|415|[Add Strings](./Algorithms/0415.add-strings)|41%|Easy|| -|416|[Partition Equal Subset Sum](./Algorithms/0416.partition-equal-subset-sum)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|417|[Pacific Atlantic Water Flow](./Algorithms/0417.pacific-atlantic-water-flow)|34%|Medium|| -|419|[Battleships in a Board](./Algorithms/0419.battleships-in-a-board)|63%|Medium|| -|420|[Strong Password Checker](./Algorithms/0420.strong-password-checker)|19%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|421|[Maximum XOR of Two Numbers in an Array](./Algorithms/0421.maximum-xor-of-two-numbers-in-an-array)|48%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|423|[Reconstruct Original Digits from English](./Algorithms/0423.reconstruct-original-digits-from-english)|44%|Medium|| -|424|[Longest Repeating Character Replacement](./Algorithms/0424.longest-repeating-character-replacement)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|432|[All O`one Data Structure](./Algorithms/0432.all-oone-data-structure)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|434|[Number of Segments in a String](./Algorithms/0434.number-of-segments-in-a-string)|36%|Easy|| -|435|[Non-overlapping Intervals](./Algorithms/0435.non-overlapping-intervals)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|436|[Find Right Interval](./Algorithms/0436.find-right-interval)|41%|Medium|| -|437|[Path Sum III](./Algorithms/0437.path-sum-iii)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|438|[Find All Anagrams in a String](./Algorithms/0438.find-all-anagrams-in-a-string)|33%|Easy|| -|440|[K-th Smallest in Lexicographical Order](./Algorithms/0440.k-th-smallest-in-lexicographical-order)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|441|[Arranging Coins](./Algorithms/0441.arranging-coins)|36%|Easy|| -|442|[Find All Duplicates in an Array](./Algorithms/0442.find-all-duplicates-in-an-array)|57%|Medium|| -|443|[String Compression](./Algorithms/0443.string-compression)|35%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|445|[Add Two Numbers II](./Algorithms/0445.add-two-numbers-ii)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|446|[Arithmetic Slices II - Subsequence](./Algorithms/0446.arithmetic-slices-ii-subsequence)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|447|[Number of Boomerangs](./Algorithms/0447.number-of-boomerangs)|46%|Easy|| -|448|[Find All Numbers Disappeared in an Array](./Algorithms/0448.find-all-numbers-disappeared-in-an-array)|51%|Easy|| -|450|[Delete Node in a BST](./Algorithms/0450.delete-node-in-a-bst)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|451|[Sort Characters By Frequency](./Algorithms/0451.sort-characters-by-frequency)|52%|Medium|| -|452|[Minimum Number of Arrows to Burst Balloons](./Algorithms/0452.minimum-number-of-arrows-to-burst-balloons)|44%|Medium|| -|453|[Minimum Moves to Equal Array Elements](./Algorithms/0453.minimum-moves-to-equal-array-elements)|48%|Easy|| -|454|[4Sum II](./Algorithms/0454.4sum-ii)|47%|Medium|| -|455|[Assign Cookies](./Algorithms/0455.assign-cookies)|47%|Easy|| -|456|[132 Pattern](./Algorithms/0456.132-pattern)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|459|[Repeated Substring Pattern](./Algorithms/0459.repeated-substring-pattern)|38%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|460|[LFU Cache](./Algorithms/0460.lfu-cache)|25%|Hard|| -|461|[Hamming Distance](./Algorithms/0461.hamming-distance)|69%|Easy|| -|462|[Minimum Moves to Equal Array Elements II](./Algorithms/0462.minimum-moves-to-equal-array-elements-ii)|51%|Medium|| -|463|[Island Perimeter](./Algorithms/0463.island-perimeter)|58%|Easy|| -|464|[Can I Win](./Algorithms/0464.can-i-win)|25%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|466|[Count The Repetitions](./Algorithms/0466.count-the-repetitions)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|467|[Unique Substrings in Wraparound String](./Algorithms/0467.unique-substrings-in-wraparound-string)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|468|[Validate IP Address](./Algorithms/0468.validate-ip-address)|20%|Medium|| -|472|[Concatenated Words](./Algorithms/0472.concatenated-words)|31%|Hard|| -|473|[Matchsticks to Square](./Algorithms/0473.matchsticks-to-square)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|474|[Ones and Zeroes](./Algorithms/0474.ones-and-zeroes)|38%|Medium|| -|475|[Heaters](./Algorithms/0475.heaters)|29%|Easy|| -|476|[Number Complement](./Algorithms/0476.number-complement)|61%|Easy|| -|477|[Total Hamming Distance](./Algorithms/0477.total-hamming-distance)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|479|[Largest Palindrome Product](./Algorithms/0479.largest-palindrome-product)|25%|Easy|| -|480|[Sliding Window Median](./Algorithms/0480.sliding-window-median)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|481|[Magical String](./Algorithms/0481.magical-string)|45%|Medium|| -|482|[License Key Formatting](./Algorithms/0482.license-key-formatting)|39%|Easy|| -|483|[Smallest Good Base](./Algorithms/0483.smallest-good-base)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|485|[Max Consecutive Ones](./Algorithms/0485.max-consecutive-ones)|53%|Easy|| -|486|[Predict the Winner](./Algorithms/0486.predict-the-winner)|45%|Medium|| -|488|[Zuma Game](./Algorithms/0488.zuma-game)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|491|[Increasing Subsequences](./Algorithms/0491.increasing-subsequences)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|492|[Construct the Rectangle](./Algorithms/0492.construct-the-rectangle)|48%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|493|[Reverse Pairs](./Algorithms/0493.reverse-pairs)|20%|Hard|| -|494|[Target Sum](./Algorithms/0494.target-sum)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|495|[Teemo Attacking](./Algorithms/0495.teemo-attacking)|51%|Medium|| -|496|[Next Greater Element I](./Algorithms/0496.next-greater-element-i)|56%|Easy|| -|498|[Diagonal Traverse](./Algorithms/0498.diagonal-traverse)|45%|Medium|| -|500|[Keyboard Row](./Algorithms/0500.keyboard-row)|60%|Easy|| -|501|[Find Mode in Binary Search Tree](./Algorithms/0501.find-mode-in-binary-search-tree)|37%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|502|[IPO](./Algorithms/0502.ipo)|36%|Hard|| -|503|[Next Greater Element II](./Algorithms/0503.next-greater-element-ii)|48%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|504|[Base 7](./Algorithms/0504.base-7)|43%|Easy|| -|506|[Relative Ranks](./Algorithms/0506.relative-ranks)|47%|Easy|| -|507|[Perfect Number](./Algorithms/0507.perfect-number)|32%|Easy|| -|508|[Most Frequent Subtree Sum](./Algorithms/0508.most-frequent-subtree-sum)|52%|Medium|| -|513|[Find Bottom Left Tree Value](./Algorithms/0513.find-bottom-left-tree-value)|56%|Medium|| -|514|[Freedom Trail](./Algorithms/0514.freedom-trail)|39%|Hard|| -|515|[Find Largest Value in Each Tree Row](./Algorithms/0515.find-largest-value-in-each-tree-row)|55%|Medium|| -|516|[Longest Palindromic Subsequence](./Algorithms/0516.longest-palindromic-subsequence)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|517|[Super Washing Machines](./Algorithms/0517.super-washing-machines)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|520|[Detect Capital](./Algorithms/0520.detect-capital)|51%|Easy|| -|521|[Longest Uncommon Subsequence I](./Algorithms/0521.longest-uncommon-subsequence-i)|55%|Easy|| -|522|[Longest Uncommon Subsequence II](./Algorithms/0522.longest-uncommon-subsequence-ii)|32%|Medium|| -|523|[Continuous Subarray Sum](./Algorithms/0523.continuous-subarray-sum)|23%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|524|[Longest Word in Dictionary through Deleting](./Algorithms/0524.longest-word-in-dictionary-through-deleting)|43%|Medium|| -|525|[Contiguous Array](./Algorithms/0525.contiguous-array)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|526|[Beautiful Arrangement](./Algorithms/0526.beautiful-arrangement)|53%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|529|[Minesweeper](./Algorithms/0529.minesweeper)|49%|Medium|| -|530|[Minimum Absolute Difference in BST](./Algorithms/0530.minimum-absolute-difference-in-bst)|47%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|532|[K-diff Pairs in an Array](./Algorithms/0532.k-diff-pairs-in-an-array)|28%|Easy|| -|537|[Complex Number Multiplication](./Algorithms/0537.complex-number-multiplication)|63%|Medium|| -|538|[Convert BST to Greater Tree](./Algorithms/0538.convert-bst-to-greater-tree)|48%|Easy|| -|539|[Minimum Time Difference](./Algorithms/0539.minimum-time-difference)|46%|Medium|| -|540|[Single Element in a Sorted Array](./Algorithms/0540.single-element-in-a-sorted-array)|55%|Medium|| -|541|[Reverse String II](./Algorithms/0541.reverse-string-ii)|43%|Easy|| -|542|[01 Matrix](./Algorithms/0542.01-matrix)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|543|[Diameter of Binary Tree](./Algorithms/0543.diameter-of-binary-tree)|45%|Easy|| -|546|[Remove Boxes](./Algorithms/0546.remove-boxes)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|547|[Friend Circles](./Algorithms/0547.friend-circles)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|551|[Student Attendance Record I](./Algorithms/0551.student-attendance-record-i)|44%|Easy|| -|552|[Student Attendance Record II](./Algorithms/0552.student-attendance-record-ii)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|553|[Optimal Division](./Algorithms/0553.optimal-division)|55%|Medium|| -|554|[Brick Wall](./Algorithms/0554.brick-wall)|46%|Medium|| -|556|[Next Greater Element III](./Algorithms/0556.next-greater-element-iii)|28%|Medium|| -|557|[Reverse Words in a String III](./Algorithms/0557.reverse-words-in-a-string-iii)|60%|Easy|| -|560|[Subarray Sum Equals K](./Algorithms/0560.subarray-sum-equals-k)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|561|[Array Partition I](./Algorithms/0561.array-partition-i)|66%|Easy|| -|563|[Binary Tree Tilt](./Algorithms/0563.binary-tree-tilt)|47%|Easy|| -|564|[Find the Closest Palindrome](./Algorithms/0564.find-the-closest-palindrome)|17%|Hard|| -|565|[Array Nesting](./Algorithms/0565.array-nesting)|49%|Medium|| -|566|[Reshape the Matrix](./Algorithms/0566.reshape-the-matrix)|57%|Easy|| -|567|[Permutation in String](./Algorithms/0567.permutation-in-string)|36%|Medium|| -|572|[Subtree of Another Tree](./Algorithms/0572.subtree-of-another-tree)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|575|[Distribute Candies](./Algorithms/0575.distribute-candies)|58%|Easy|| -|576|[Out of Boundary Paths](./Algorithms/0576.out-of-boundary-paths)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|581|[Shortest Unsorted Continuous Subarray](./Algorithms/0581.shortest-unsorted-continuous-subarray)|29%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|583|[Delete Operation for Two Strings](./Algorithms/0583.delete-operation-for-two-strings)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|587|[Erect the Fence](./Algorithms/0587.erect-the-fence)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|591|[Tag Validator](./Algorithms/0591.tag-validator)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|592|[Fraction Addition and Subtraction](./Algorithms/0592.fraction-addition-and-subtraction)|46%|Medium|| -|593|[Valid Square](./Algorithms/0593.valid-square)|39%|Medium|| -|594|[Longest Harmonious Subsequence](./Algorithms/0594.longest-harmonious-subsequence)|41%|Easy|| -|598|[Range Addition II](./Algorithms/0598.range-addition-ii)|48%|Easy|| -|599|[Minimum Index Sum of Two Lists](./Algorithms/0599.minimum-index-sum-of-two-lists)|46%|Easy|| -|600|[Non-negative Integers without Consecutive Ones](./Algorithms/0600.non-negative-integers-without-consecutive-ones)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|605|[Can Place Flowers](./Algorithms/0605.can-place-flowers)|30%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|606|[Construct String from Binary Tree](./Algorithms/0606.construct-string-from-binary-tree)|49%|Easy|| -|609|[Find Duplicate File in System](./Algorithms/0609.find-duplicate-file-in-system)|52%|Medium|| -|611|[Valid Triangle Number](./Algorithms/0611.valid-triangle-number)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|617|[Merge Two Binary Trees](./Algorithms/0617.merge-two-binary-trees)|67%|Easy|| -|621|[Task Scheduler](./Algorithms/0621.task-scheduler)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|623|[Add One Row to Tree](./Algorithms/0623.add-one-row-to-tree)|46%|Medium|| -|628|[Maximum Product of Three Numbers](./Algorithms/0628.maximum-product-of-three-numbers)|44%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|629|[K Inverse Pairs Array](./Algorithms/0629.k-inverse-pairs-array)|27%|Hard|| -|630|[Course Schedule III](./Algorithms/0630.course-schedule-iii)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|632|[Smallest Range](./Algorithms/0632.smallest-range)|41%|Hard|| -|633|[Sum of Square Numbers](./Algorithms/0633.sum-of-square-numbers)|32%|Easy|| -|636|[Exclusive Time of Functions](./Algorithms/0636.exclusive-time-of-functions)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|637|[Average of Levels in Binary Tree](./Algorithms/0637.average-of-levels-in-binary-tree)|55%|Easy|| -|638|[Shopping Offers](./Algorithms/0638.shopping-offers)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|639|[Decode Ways II](./Algorithms/0639.decode-ways-ii)|24%|Hard|| -|640|[Solve the Equation](./Algorithms/0640.solve-the-equation)|38%|Medium|| -|643|[Maximum Average Subarray I](./Algorithms/0643.maximum-average-subarray-i)|37%|Easy|| -|645|[Set Mismatch](./Algorithms/0645.set-mismatch)|39%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|646|[Maximum Length of Pair Chain](./Algorithms/0646.maximum-length-of-pair-chain)|47%|Medium|| -|647|[Palindromic Substrings](./Algorithms/0647.palindromic-substrings)|54%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|648|[Replace Words](./Algorithms/0648.replace-words)|48%|Medium|| -|649|[Dota2 Senate](./Algorithms/0649.dota2-senate)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|650|[2 Keys Keyboard](./Algorithms/0650.2-keys-keyboard)|45%|Medium|| -|652|[Find Duplicate Subtrees](./Algorithms/0652.find-duplicate-subtrees)|37%|Medium|| -|653|[Two Sum IV - Input is a BST](./Algorithms/0653.two-sum-iv-input-is-a-bst)|50%|Easy|| -|654|[Maximum Binary Tree](./Algorithms/0654.maximum-binary-tree)|70%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|655|[Print Binary Tree](./Algorithms/0655.print-binary-tree)|49%|Medium|| -|657|[Judge Route Circle](./Algorithms/0657.judge-route-circle)|68%|Easy|| -|658|[Find K Closest Elements](./Algorithms/0658.find-k-closest-elements)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|659|[Split Array into Consecutive Subsequences](./Algorithms/0659.split-array-into-consecutive-subsequences)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|661|[Image Smoother](./Algorithms/0661.image-smoother)|46%|Easy|| -|662|[Maximum Width of Binary Tree](./Algorithms/0662.maximum-width-of-binary-tree)|38%|Medium|| -|664|[Strange Printer](./Algorithms/0664.strange-printer)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|665|[Non-decreasing Array](./Algorithms/0665.non-decreasing-array)|20%|Easy|| -|667|[Beautiful Arrangement II](./Algorithms/0667.beautiful-arrangement-ii)|51%|Medium|| -|668|[Kth Smallest Number in Multiplication Table](./Algorithms/0668.kth-smallest-number-in-multiplication-table)|40%|Hard|| -|669|[Trim a Binary Search Tree](./Algorithms/0669.trim-a-binary-search-tree)|58%|Easy|| -|670|[Maximum Swap](./Algorithms/0670.maximum-swap)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|671|[Second Minimum Node In a Binary Tree](./Algorithms/0671.second-minimum-node-in-a-binary-tree)|41%|Easy|| -|672|[Bulb Switcher II](./Algorithms/0672.bulb-switcher-ii)|49%|Medium|| -|673|[Number of Longest Increasing Subsequence](./Algorithms/0673.number-of-longest-increasing-subsequence)|31%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|674|[Longest Continuous Increasing Subsequence](./Algorithms/0674.longest-continuous-increasing-subsequence)|42%|Easy|| -|675|[Cut Off Trees for Golf Event](./Algorithms/0675.cut-off-trees-for-golf-event)|26%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|676|[Implement Magic Dictionary](./Algorithms/0676.implement-magic-dictionary)|49%|Medium|| -|677|[Map Sum Pairs](./Algorithms/0677.map-sum-pairs)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|678|[Valid Parenthesis String](./Algorithms/0678.valid-parenthesis-string)|29%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|679|[24 Game](./Algorithms/0679.24-game)|38%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|680|[Valid Palindrome II](./Algorithms/0680.valid-palindrome-ii)|32%|Easy|| -|682|[Baseball Game](./Algorithms/0682.baseball-game)|58%|Easy|| -|684|[Redundant Connection](./Algorithms/0684.redundant-connection)|44%|Medium|| -|685|[Redundant Connection II](./Algorithms/0685.redundant-connection-ii)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|686|[Repeated String Match](./Algorithms/0686.repeated-string-match)|31%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|687|[Longest Univalue Path](./Algorithms/0687.longest-univalue-path)|32%|Easy|| -|688|[Knight Probability in Chessboard](./Algorithms/0688.knight-probability-in-chessboard)|40%|Medium|| -|689|[Maximum Sum of 3 Non-Overlapping Subarrays](./Algorithms/0689.maximum-sum-of-3-non-overlapping-subarrays)|41%|Hard|| -|691|[Stickers to Spell Word](./Algorithms/0691.stickers-to-spell-word)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|692|[Top K Frequent Words](./Algorithms/0692.top-k-frequent-words)|41%|Medium|| -|693|[Binary Number with Alternating Bits](./Algorithms/0693.binary-number-with-alternating-bits)|55%|Easy|| -|695|[Max Area of Island](./Algorithms/0695.max-area-of-island)|51%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|696|[Count Binary Substrings](./Algorithms/0696.count-binary-substrings)|50%|Easy|| -|697|[Degree of an Array](./Algorithms/0697.degree-of-an-array)|46%|Easy|| -|698|[Partition to K Equal Sum Subsets](./Algorithms/0698.partition-to-k-equal-sum-subsets)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|699|[Falling Squares](./Algorithms/0699.falling-squares)|37%|Hard|| -|712|[Minimum ASCII Delete Sum for Two Strings](./Algorithms/0712.minimum-ascii-delete-sum-for-two-strings)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|713|[Subarray Product Less Than K](./Algorithms/0713.subarray-product-less-than-k)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|714|[Best Time to Buy and Sell Stock with Transaction Fee](./Algorithms/0714.best-time-to-buy-and-sell-stock-with-transaction-fee)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|715|[Range Module](./Algorithms/0715.range-module)|31%|Hard|| -|717|[1-bit and 2-bit Characters](./Algorithms/0717.1-bit-and-2-bit-characters)|49%|Easy|| -|718|[Maximum Length of Repeated Subarray](./Algorithms/0718.maximum-length-of-repeated-subarray)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|719|[Find K-th Smallest Pair Distance](./Algorithms/0719.find-k-th-smallest-pair-distance)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|720|[Longest Word in Dictionary](./Algorithms/0720.longest-word-in-dictionary)|41%|Easy|| -|721|[Accounts Merge](./Algorithms/0721.accounts-merge)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|722|[Remove Comments](./Algorithms/0722.remove-comments)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|724|[Find Pivot Index](./Algorithms/0724.find-pivot-index)|39%|Easy|| -|725|[Split Linked List in Parts](./Algorithms/0725.split-linked-list-in-parts)|46%|Medium|| -|726|[Number of Atoms](./Algorithms/0726.number-of-atoms)|43%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|728|[Self Dividing Numbers](./Algorithms/0728.self-dividing-numbers)|66%|Easy|| -|729|[My Calendar I](./Algorithms/0729.my-calendar-i)|42%|Medium|| -|730|[Count Different Palindromic Subsequences](./Algorithms/0730.count-different-palindromic-subsequences)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|731|[My Calendar II](./Algorithms/0731.my-calendar-ii)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|732|[My Calendar III](./Algorithms/0732.my-calendar-iii)|49%|Hard|| -|733|[Flood Fill](./Algorithms/0733.flood-fill)|47%|Easy|| -|735|[Asteroid Collision](./Algorithms/0735.asteroid-collision)|37%|Medium|| -|736|[Parse Lisp Expression](./Algorithms/0736.parse-lisp-expression)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|738|[Monotone Increasing Digits](./Algorithms/0738.monotone-increasing-digits)|41%|Medium|| -|739|[Daily Temperatures](./Algorithms/0739.daily-temperatures)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|740|[Delete and Earn](./Algorithms/0740.delete-and-earn)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|741|[Cherry Pickup](./Algorithms/0741.cherry-pickup)|24%|Hard|| -|743|[Network Delay Time](./Algorithms/0743.network-delay-time)|35%|Medium|| -|744|[Find Smallest Letter Greater Than Target](./Algorithms/0744.find-smallest-letter-greater-than-target)|43%|Easy|| -|745|[Prefix and Suffix Search](./Algorithms/0745.prefix-and-suffix-search)|25%|Hard|| -|746|[Min Cost Climbing Stairs](./Algorithms/0746.min-cost-climbing-stairs)|43%|Easy|| -|747|[Largest Number At Least Twice of Others](./Algorithms/0747.largest-number-at-least-twice-of-others)|41%|Easy|| -|748|[Shortest Completing Word](./Algorithms/0748.shortest-completing-word)|51%|Medium|| -|749|[Contain Virus](./Algorithms/0749.contain-virus)|40%|Hard|| -|752|[Open the Lock](./Algorithms/0752.open-the-lock)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|753|[Cracking the Safe](./Algorithms/0753.cracking-the-safe)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|754|[Reach a Number](./Algorithms/0754.reach-a-number)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|756|[Pyramid Transition Matrix](./Algorithms/0756.pyramid-transition-matrix)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|757|[Set Intersection Size At Least Two](./Algorithms/0757.set-intersection-size-at-least-two)|35%|Hard|| -|761|[Special Binary String](./Algorithms/0761.special-binary-string)|42%|Hard|| -|762|[Prime Number of Set Bits in Binary Representation](./Algorithms/0762.prime-number-of-set-bits-in-binary-representation)|55%|Easy|| -|763|[Partition Labels](./Algorithms/0763.partition-labels)|64%|Medium|| -|764|[Largest Plus Sign](./Algorithms/0764.largest-plus-sign)|38%|Medium|| -|765|[Couples Holding Hands](./Algorithms/0765.couples-holding-hands)|48%|Hard|| -|766|[Toeplitz Matrix](./Algorithms/0766.toeplitz-matrix)|57%|Easy|| -|767|[Reorganize String](./Algorithms/0767.reorganize-string)|36%|Medium|| -|768|[Max Chunks To Make Sorted II](./Algorithms/0768.max-chunks-to-make-sorted-ii)|43%|Hard|| -|769|[Max Chunks To Make Sorted](./Algorithms/0769.max-chunks-to-make-sorted)|48%|Medium|| -|770|[Basic Calculator IV](./Algorithms/0770.basic-calculator-iv)|42%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|771|[Jewels and Stones](./Algorithms/0771.jewels-and-stones)|81%|Easy|| -|773|[Sliding Puzzle](./Algorithms/0773.sliding-puzzle)|47%|Hard|| -|775|[Global and Local Inversions](./Algorithms/0775.global-and-local-inversions)|33%|Medium|| -|777|[Swap Adjacent in LR String](./Algorithms/0777.swap-adjacent-in-lr-string)|28%|Medium|| -|778|[Swim in Rising Water](./Algorithms/0778.swim-in-rising-water)|44%|Hard|| -|779|[K-th Symbol in Grammar](./Algorithms/0779.k-th-symbol-in-grammar)|36%|Medium|| -|780|[Reaching Points](./Algorithms/0780.reaching-points)|23%|Hard|| -|781|[Rabbits in Forest](./Algorithms/0781.rabbits-in-forest)|49%|Medium|| -|782|[Transform to Chessboard](./Algorithms/0782.transform-to-chessboard)|37%|Hard|| -|783|[Minimum Distance Between BST Nodes](./Algorithms/0783.minimum-distance-between-bst-nodes)|47%|Easy|| -|784|[Letter Case Permutation](./Algorithms/0784.letter-case-permutation)|52%|Easy|[❤](https://leetcode.com/list/oussv5j)| -|785|[Is Graph Bipartite?](./Algorithms/0785.is-graph-bipartite)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|786|[K-th Smallest Prime Fraction](./Algorithms/0786.k-th-smallest-prime-fraction)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|787|[Cheapest Flights Within K Stops](./Algorithms/0787.cheapest-flights-within-k-stops)|29%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|788|[Rotated Digits](./Algorithms/0788.rotated-digits)|50%|Easy|| -|789|[Escape The Ghosts](./Algorithms/0789.escape-the-ghosts)|50%|Medium|| -|790|[Domino and Tromino Tiling](./Algorithms/0790.domino-and-tromino-tiling)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|791|[Custom Sort String](./Algorithms/0791.custom-sort-string)|59%|Medium|| -|792|[Number of Matching Subsequences](./Algorithms/0792.number-of-matching-subsequences)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|793|[Preimage Size of Factorial Zeroes Function](./Algorithms/0793.preimage-size-of-factorial-zeroes-function)|42%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|794|[Valid Tic-Tac-Toe State](./Algorithms/0794.valid-tic-tac-toe-state)|27%|Medium|| -|795|[Number of Subarrays with Bounded Maximum](./Algorithms/0795.number-of-subarrays-with-bounded-maximum)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|796|[Rotate String](./Algorithms/0796.rotate-string)|51%|Easy|| -|797|[All Paths From Source to Target](./Algorithms/0797.all-paths-from-source-to-target)|67%|Medium|| -|798|[Smallest Rotation with Highest Score](./Algorithms/0798.smallest-rotation-with-highest-score)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|799|[Champagne Tower](./Algorithms/0799.champagne-tower)|29%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|801|[Minimum Swaps To Make Sequences Increasing](./Algorithms/0801.minimum-swaps-to-make-sequences-increasing)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|802|[Find Eventual Safe States](./Algorithms/0802.find-eventual-safe-states)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|803|[Bricks Falling When Hit](./Algorithms/0803.bricks-falling-when-hit)|22%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|804|[Unique Morse Code Words](./Algorithms/0804.unique-morse-code-words)|73%|Easy|| -|805|[Split Array With Same Average](./Algorithms/0805.split-array-with-same-average)|20%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|806|[Number of Lines To Write String](./Algorithms/0806.number-of-lines-to-write-string)|63%|Easy|| -|807|[Max Increase to Keep City Skyline](./Algorithms/0807.max-increase-to-keep-city-skyline)|81%|Medium|| -|808|[Soup Servings](./Algorithms/0808.soup-servings)|32%|Medium|| -|809|[Expressive Words](./Algorithms/0809.expressive-words)|36%|Medium|| -|810|[Chalkboard XOR Game](./Algorithms/0810.chalkboard-xor-game)|38%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|811|[Subdomain Visit Count](./Algorithms/0811.subdomain-visit-count)|63%|Easy|| -|812|[Largest Triangle Area](./Algorithms/0812.largest-triangle-area)|53%|Easy|| -|813|[Largest Sum of Averages](./Algorithms/0813.largest-sum-of-averages)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|814|[Binary Tree Pruning](./Algorithms/0814.binary-tree-pruning)|69%|Medium|| -|815|[Bus Routes](./Algorithms/0815.bus-routes)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|816|[Ambiguous Coordinates](./Algorithms/0816.ambiguous-coordinates)|41%|Medium|| -|817|[Linked List Components](./Algorithms/0817.linked-list-components)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|818|[Race Car](./Algorithms/0818.race-car)|26%|Hard|[❤](https://leetcode.com/list/oussv5j)| -|819|[Most Common Word](./Algorithms/0819.most-common-word)|49%|Easy|| -|820|[Short Encoding of Words](./Algorithms/0820.short-encoding-of-words)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|821|[Shortest Distance to a Character](./Algorithms/0821.shortest-distance-to-a-character)|62%|Easy|| -|822|[Card Flipping Game](./Algorithms/0822.card-flipping-game)|34%|Medium|| -|823|[Binary Trees With Factors](./Algorithms/0823.binary-trees-with-factors)|28%|Medium|| -|824|[Goat Latin](./Algorithms/0824.goat-latin)|56%|Easy|| -|825|[Friends Of Appropriate Ages](./Algorithms/0825.friends-of-appropriate-ages)|27%|Medium|| -|826|[Most Profit Assigning Work](./Algorithms/0826.most-profit-assigning-work)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|827| * Making A Large Island|41%|Hard|| -|828| * Unique Letter String|32%|Hard|| -|829|[Consecutive Numbers Sum](./Algorithms/0829.consecutive-numbers-sum)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| -|830|[Positions of Large Groups](./Algorithms/0830.positions-of-large-groups)|48%|Easy|| -|831| * Masking Personal Information|42%|Medium|| -|832| * Flipping an Image|72%|Easy|| -|833| * Find And Replace in String|36%|Medium|| -|834| * Sum of Distances in Tree|29%|Hard|| -|835| * Image Overlap|32%|Medium|| -|836| * Rectangle Overlap|38%|Easy|| -|837| * New 21 Game|24%|Medium|| -|838| * Push Dominoes|39%|Medium|| -|839| * Similar String Groups|35%|Hard|| -|840| * Magic Squares In Grid :new: |31%|Easy|| -|841| * Keys and Rooms :new: |60%|Medium|| -|842| * Split Array into Fibonacci Sequence :new: |31%|Medium|| -|843| * Guess the Word :new: |28%|Hard|| +|[1250](https://leetcode.com/problems/check-if-it-is-a-good-array/)| * Check If It Is a Good Array|46%|Hard|| +|[1249](https://leetcode.com/problems/minimum-remove-to-make-valid-parentheses/)| * Minimum Remove to Make Valid Parentheses|55%|Medium|| +|[1248](https://leetcode.com/problems/count-number-of-nice-subarrays/)| * Count Number of Nice Subarrays|50%|Medium|| +|[1247](https://leetcode.com/problems/minimum-swaps-to-make-strings-equal/)| * Minimum Swaps to Make Strings Equal|56%|Medium|| +|[1240](https://leetcode.com/problems/tiling-a-rectangle-with-the-fewest-squares/)| * Tiling a Rectangle with the Fewest Squares|48%|Hard|| +|[1239](https://leetcode.com/problems/maximum-length-of-a-concatenated-string-with-unique-characters/)| * Maximum Length of a Concatenated String with Unique Characters|40%|Medium|| +|[1238](https://leetcode.com/problems/circular-permutation-in-binary-representation/)| * Circular Permutation in Binary Representation|57%|Medium|| +|[1237](https://leetcode.com/problems/find-positive-integer-solution-for-a-given-equation/)| * Find Positive Integer Solution for a Given Equation|65%|Easy|| +|[1235](https://leetcode.com/problems/maximum-profit-in-job-scheduling/)| * Maximum Profit in Job Scheduling|44%|Hard|| +|[1234](https://leetcode.com/problems/replace-the-substring-for-balanced-string/)| * Replace the Substring for Balanced String|29%|Medium|| +|[1233](https://leetcode.com/problems/remove-sub-folders-from-the-filesystem/)| * Remove Sub-Folders from the Filesystem|53%|Medium|| +|[1232](https://leetcode.com/problems/check-if-it-is-a-straight-line/)| * Check If It Is a Straight Line|47%|Easy|| +|[1227](https://leetcode.com/problems/airplane-seat-assignment-probability/)| * Airplane Seat Assignment Probability|61%|Medium|| +|[1224](https://leetcode.com/problems/maximum-equal-frequency/)| * Maximum Equal Frequency|31%|Hard|| +|[1223](https://leetcode.com/problems/dice-roll-simulation/)| * Dice Roll Simulation|42%|Medium|| +|[1222](https://leetcode.com/problems/queens-that-can-attack-the-king/)| * Queens That Can Attack the King|68%|Medium|| +|[1221](https://leetcode.com/problems/split-a-string-in-balanced-strings/)|[Split a String in Balanced Strings](./Algorithms/1221.split-a-string-in-balanced-strings)|78%|Easy|| +|[1220](https://leetcode.com/problems/count-vowels-permutation/)| * Count Vowels Permutation|51%|Hard|| +|[1219](https://leetcode.com/problems/path-with-maximum-gold/)| * Path with Maximum Gold|61%|Medium|| +|[1218](https://leetcode.com/problems/longest-arithmetic-subsequence-of-given-difference/)| * Longest Arithmetic Subsequence of Given Difference|38%|Medium|| +|[1217](https://leetcode.com/problems/play-with-chips/)|[Play with Chips](./Algorithms/1217.play-with-chips)|63%|Easy|| +|[1210](https://leetcode.com/problems/minimum-moves-to-reach-target-with-rotations/)| * Minimum Moves to Reach Target with Rotations|43%|Hard|| +|[1209](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/)| * Remove All Adjacent Duplicates in String II|57%|Medium|| +|[1208](https://leetcode.com/problems/get-equal-substrings-within-budget/)| * Get Equal Substrings Within Budget|36%|Medium|| +|[1207](https://leetcode.com/problems/unique-number-of-occurrences/)|[Unique Number of Occurrences](./Algorithms/1207.unique-number-of-occurrences)|72%|Easy|| +|[1206](https://leetcode.com/problems/design-skiplist/)| * Design Skiplist|60%|Hard|| +|[1203](https://leetcode.com/problems/sort-items-by-groups-respecting-dependencies/)| * Sort Items by Groups Respecting Dependencies|45%|Hard|| +|[1202](https://leetcode.com/problems/smallest-string-with-swaps/)|[Smallest String With Swaps](./Algorithms/1202.smallest-string-with-swaps)|41%|Medium|| +|[1201](https://leetcode.com/problems/ugly-number-iii/)| * Ugly Number III|24%|Medium|| +|[1200](https://leetcode.com/problems/minimum-absolute-difference/)|[Minimum Absolute Difference](./Algorithms/1200.minimum-absolute-difference)|66%|Easy|| +|[1192](https://leetcode.com/problems/critical-connections-in-a-network/)| * Critical Connections in a Network|47%|Hard|| +|[1191](https://leetcode.com/problems/k-concatenation-maximum-sum/)| * K-Concatenation Maximum Sum|24%|Medium|| +|[1190](https://leetcode.com/problems/reverse-substrings-between-each-pair-of-parentheses/)|[Reverse Substrings Between Each Pair of Parentheses](./Algorithms/1190.reverse-substrings-between-each-pair-of-parentheses)|57%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1189](https://leetcode.com/problems/maximum-number-of-balloons/)|[Maximum Number of Balloons](./Algorithms/1189.maximum-number-of-balloons)|61%|Easy|| +|[1187](https://leetcode.com/problems/make-array-strictly-increasing/)| * Make Array Strictly Increasing|40%|Hard|| +|[1186](https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/)|[Maximum Subarray Sum with One Deletion](./Algorithms/1186.maximum-subarray-sum-with-one-deletion)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1185](https://leetcode.com/problems/day-of-the-week/)|[Day of the Week](./Algorithms/1185.day-of-the-week)|64%|Easy|| +|[1184](https://leetcode.com/problems/distance-between-bus-stops/)|[Distance Between Bus Stops](./Algorithms/1184.distance-between-bus-stops)|56%|Easy|| +|[1178](https://leetcode.com/problems/number-of-valid-words-for-each-puzzle/)|[Number of Valid Words for Each Puzzle](./Algorithms/1178.number-of-valid-words-for-each-puzzle)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1177](https://leetcode.com/problems/can-make-palindrome-from-substring/)|[Can Make Palindrome from Substring](./Algorithms/1177.can-make-palindrome-from-substring)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1175](https://leetcode.com/problems/prime-arrangements/)|[Prime Arrangements](./Algorithms/1175.prime-arrangements)|50%|Easy|| +|[1172](https://leetcode.com/problems/dinner-plate-stacks/)|[Dinner Plate Stacks](./Algorithms/1172.dinner-plate-stacks)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1171](https://leetcode.com/problems/remove-zero-sum-consecutive-nodes-from-linked-list/)|[Remove Zero Sum Consecutive Nodes from Linked List](./Algorithms/1171.remove-zero-sum-consecutive-nodes-from-linked-list)|41%|Medium|| +|[1170](https://leetcode.com/problems/compare-strings-by-frequency-of-the-smallest-character/)|[Compare Strings by Frequency of the Smallest Character](./Algorithms/1170.compare-strings-by-frequency-of-the-smallest-character)|58%|Easy|| +|[1169](https://leetcode.com/problems/invalid-transactions/)|[Invalid Transactions](./Algorithms/1169.invalid-transactions)|28%|Medium|| +|[1163](https://leetcode.com/problems/last-substring-in-lexicographical-order/)|[Last Substring in Lexicographical Order](./Algorithms/1163.last-substring-in-lexicographical-order)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1162](https://leetcode.com/problems/as-far-from-land-as-possible/)|[As Far from Land as Possible](./Algorithms/1162.as-far-from-land-as-possible)|40%|Medium|| +|[1161](https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/)|[Maximum Level Sum of a Binary Tree](./Algorithms/1161.maximum-level-sum-of-a-binary-tree)|70%|Medium|| +|[1160](https://leetcode.com/problems/find-words-that-can-be-formed-by-characters/)|[Find Words That Can Be Formed by Characters](./Algorithms/1160.find-words-that-can-be-formed-by-characters)|66%|Easy|| +|[1157](https://leetcode.com/problems/online-majority-element-in-subarray/)|[Online Majority Element In Subarray](./Algorithms/1157.online-majority-element-in-subarray)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1156](https://leetcode.com/problems/swap-for-longest-repeated-character-substring/)|[Swap For Longest Repeated Character Substring](./Algorithms/1156.swap-for-longest-repeated-character-substring)|46%|Medium|| +|[1155](https://leetcode.com/problems/number-of-dice-rolls-with-target-sum/)|[Number of Dice Rolls With Target Sum](./Algorithms/1155.number-of-dice-rolls-with-target-sum)|48%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1154](https://leetcode.com/problems/day-of-the-year/)|[Day of the Year](./Algorithms/1154.day-of-the-year)|48%|Easy|| +|[1147](https://leetcode.com/problems/longest-chunked-palindrome-decomposition/)|[Longest Chunked Palindrome Decomposition](./Algorithms/1147.longest-chunked-palindrome-decomposition)|58%|Hard|| +|[1146](https://leetcode.com/problems/snapshot-array/)|[Snapshot Array](./Algorithms/1146.snapshot-array)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1145](https://leetcode.com/problems/binary-tree-coloring-game/)|[Binary Tree Coloring Game](./Algorithms/1145.binary-tree-coloring-game)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1144](https://leetcode.com/problems/decrease-elements-to-make-array-zigzag/)|[Decrease Elements To Make Array Zigzag](./Algorithms/1144.decrease-elements-to-make-array-zigzag)|43%|Medium|| +|[1143](https://leetcode.com/problems/longest-common-subsequence/)|[Longest Common Subsequence](./Algorithms/1143.longest-common-subsequence)|57%|Medium|| +|[1140](https://leetcode.com/problems/stone-game-ii/)|[Stone Game II](./Algorithms/1140.stone-game-ii)|60%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1139](https://leetcode.com/problems/largest-1-bordered-square/)|[Largest 1-Bordered Square](./Algorithms/1139.largest-1-bordered-square)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1138](https://leetcode.com/problems/alphabet-board-path/)|[Alphabet Board Path](./Algorithms/1138.alphabet-board-path)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1137](https://leetcode.com/problems/n-th-tribonacci-number/)|[N-th Tribonacci Number](./Algorithms/1137.n-th-tribonacci-number)|57%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1131](https://leetcode.com/problems/maximum-of-absolute-value-expression/)|[Maximum of Absolute Value Expression](./Algorithms/1131.maximum-of-absolute-value-expression)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1130](https://leetcode.com/problems/minimum-cost-tree-from-leaf-values/)|[Minimum Cost Tree From Leaf Values](./Algorithms/1130.minimum-cost-tree-from-leaf-values)|62%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1129](https://leetcode.com/problems/shortest-path-with-alternating-colors/)|[Shortest Path with Alternating Colors](./Algorithms/1129.shortest-path-with-alternating-colors)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1128](https://leetcode.com/problems/number-of-equivalent-domino-pairs/)|[Number of Equivalent Domino Pairs](./Algorithms/1128.number-of-equivalent-domino-pairs)|46%|Easy|| +|[1125](https://leetcode.com/problems/smallest-sufficient-team/)|[Smallest Sufficient Team](./Algorithms/1125.smallest-sufficient-team)|44%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1124](https://leetcode.com/problems/longest-well-performing-interval/)|[Longest Well-Performing Interval](./Algorithms/1124.longest-well-performing-interval)|31%|Medium|| +|[1123](https://leetcode.com/problems/lowest-common-ancestor-of-deepest-leaves/)|[Lowest Common Ancestor of Deepest Leaves](./Algorithms/1123.lowest-common-ancestor-of-deepest-leaves)|64%|Medium|| +|[1122](https://leetcode.com/problems/relative-sort-array/)|[Relative Sort Array](./Algorithms/1122.relative-sort-array)|66%|Easy|| +|[1111](https://leetcode.com/problems/maximum-nesting-depth-of-two-valid-parentheses-strings/)|[Maximum Nesting Depth of Two Valid Parentheses Strings](./Algorithms/1111.maximum-nesting-depth-of-two-valid-parentheses-strings)|67%|Medium|| +|[1110](https://leetcode.com/problems/delete-nodes-and-return-forest/)|[Delete Nodes And Return Forest](./Algorithms/1110.delete-nodes-and-return-forest)|64%|Medium|| +|[1109](https://leetcode.com/problems/corporate-flight-bookings/)|[Corporate Flight Bookings](./Algorithms/1109.corporate-flight-bookings)|49%|Medium|| +|[1108](https://leetcode.com/problems/defanging-an-ip-address/)|[Defanging an IP Address](./Algorithms/1108.defanging-an-ip-address)|84%|Easy|| +|[1106](https://leetcode.com/problems/parsing-a-boolean-expression/)|[Parsing A Boolean Expression](./Algorithms/1106.parsing-a-boolean-expression)|57%|Hard|| +|[1105](https://leetcode.com/problems/filling-bookcase-shelves/)|[Filling Bookcase Shelves](./Algorithms/1105.filling-bookcase-shelves)|56%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1104](https://leetcode.com/problems/path-in-zigzag-labelled-binary-tree/)|[Path In Zigzag Labelled Binary Tree](./Algorithms/1104.path-in-zigzag-labelled-binary-tree)|70%|Medium|| +|[1103](https://leetcode.com/problems/distribute-candies-to-people/)|[Distribute Candies to People](./Algorithms/1103.distribute-candies-to-people)|59%|Easy|| +|[1096](https://leetcode.com/problems/brace-expansion-ii/)|[Brace Expansion II](./Algorithms/1096.brace-expansion-ii)|59%|Hard|| +|[1095](https://leetcode.com/problems/find-in-mountain-array/)|[Find in Mountain Array](./Algorithms/1095.find-in-mountain-array)|34%|Hard|| +|[1094](https://leetcode.com/problems/car-pooling/)|[Car Pooling](./Algorithms/1094.car-pooling)|57%|Medium|| +|[1093](https://leetcode.com/problems/statistics-from-a-large-sample/)|[Statistics from a Large Sample](./Algorithms/1093.statistics-from-a-large-sample)|44%|Medium|| +|[1092](https://leetcode.com/problems/shortest-common-supersequence/)|[Shortest Common Supersequence](./Algorithms/1092.shortest-common-supersequence)|49%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1091](https://leetcode.com/problems/shortest-path-in-binary-matrix/)|[Shortest Path in Binary Matrix](./Algorithms/1091.shortest-path-in-binary-matrix)|36%|Medium|| +|[1090](https://leetcode.com/problems/largest-values-from-labels/)|[Largest Values From Labels](./Algorithms/1090.largest-values-from-labels)|57%|Medium|| +|[1089](https://leetcode.com/problems/duplicate-zeros/)|[Duplicate Zeros](./Algorithms/1089.duplicate-zeros)|58%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1081](https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/)|[Smallest Subsequence of Distinct Characters](./Algorithms/1081.smallest-subsequence-of-distinct-characters)|44%|Medium|| +|[1080](https://leetcode.com/problems/insufficient-nodes-in-root-to-leaf-paths/)|[Insufficient Nodes in Root to Leaf Paths](./Algorithms/1080.insufficient-nodes-in-root-to-leaf-paths)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1079](https://leetcode.com/problems/letter-tile-possibilities/)|[Letter Tile Possibilities](./Algorithms/1079.letter-tile-possibilities)|74%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1078](https://leetcode.com/problems/occurrences-after-bigram/)|[Occurrences After Bigram](./Algorithms/1078.occurrences-after-bigram)|64%|Easy|| +|[1074](https://leetcode.com/problems/number-of-submatrices-that-sum-to-target/)|[Number of Submatrices That Sum to Target](./Algorithms/1074.number-of-submatrices-that-sum-to-target)|58%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1073](https://leetcode.com/problems/adding-two-negabinary-numbers/)|[Adding Two Negabinary Numbers](./Algorithms/1073.adding-two-negabinary-numbers)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1072](https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows/)|[Flip Columns For Maximum Number of Equal Rows](./Algorithms/1072.flip-columns-for-maximum-number-of-equal-rows)|59%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1071](https://leetcode.com/problems/greatest-common-divisor-of-strings/)|[Greatest Common Divisor of Strings](./Algorithms/1071.greatest-common-divisor-of-strings)|53%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1054](https://leetcode.com/problems/distant-barcodes/)|[Distant Barcodes](./Algorithms/1054.distant-barcodes)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1053](https://leetcode.com/problems/previous-permutation-with-one-swap/)|[Previous Permutation With One Swap](./Algorithms/1053.previous-permutation-with-one-swap)|46%|Medium|| +|[1052](https://leetcode.com/problems/grumpy-bookstore-owner/)|[Grumpy Bookstore Owner](./Algorithms/1052.grumpy-bookstore-owner)|53%|Medium|| +|[1051](https://leetcode.com/problems/height-checker/)|[Height Checker](./Algorithms/1051.height-checker)|68%|Easy|| +|[1049](https://leetcode.com/problems/last-stone-weight-ii/)|[Last Stone Weight II](./Algorithms/1049.last-stone-weight-ii)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1048](https://leetcode.com/problems/longest-string-chain/)|[Longest String Chain](./Algorithms/1048.longest-string-chain)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1047](https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string/)|[Remove All Adjacent Duplicates In String](./Algorithms/1047.remove-all-adjacent-duplicates-in-string)|65%|Easy|| +|[1046](https://leetcode.com/problems/last-stone-weight/)|[Last Stone Weight](./Algorithms/1046.last-stone-weight)|62%|Easy|| +|[1044](https://leetcode.com/problems/longest-duplicate-substring/)|[Longest Duplicate Substring](./Algorithms/1044.longest-duplicate-substring)|23%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1043](https://leetcode.com/problems/partition-array-for-maximum-sum/)|[Partition Array for Maximum Sum](./Algorithms/1043.partition-array-for-maximum-sum)|62%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1042](https://leetcode.com/problems/flower-planting-with-no-adjacent/)|[Flower Planting With No Adjacent](./Algorithms/1042.flower-planting-with-no-adjacent)|47%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1041](https://leetcode.com/problems/robot-bounded-in-circle/)|[Robot Bounded In Circle](./Algorithms/1041.robot-bounded-in-circle)|46%|Medium|| +|[1040](https://leetcode.com/problems/moving-stones-until-consecutive-ii/)|[Moving Stones Until Consecutive II](./Algorithms/1040.moving-stones-until-consecutive-ii)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1039](https://leetcode.com/problems/minimum-score-triangulation-of-polygon/)|[Minimum Score Triangulation of Polygon](./Algorithms/1039.minimum-score-triangulation-of-polygon)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1038](https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/)|[Binary Search Tree to Greater Sum Tree](./Algorithms/1038.binary-search-tree-to-greater-sum-tree)|77%|Medium|| +|[1037](https://leetcode.com/problems/valid-boomerang/)|[Valid Boomerang](./Algorithms/1037.valid-boomerang)|37%|Easy|| +|[1036](https://leetcode.com/problems/escape-a-large-maze/)|[Escape a Large Maze](./Algorithms/1036.escape-a-large-maze)|34%|Hard|| +|[1035](https://leetcode.com/problems/uncrossed-lines/)|[Uncrossed Lines](./Algorithms/1035.uncrossed-lines)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1034](https://leetcode.com/problems/coloring-a-border/)|[Coloring A Border](./Algorithms/1034.coloring-a-border)|43%|Medium|| +|[1033](https://leetcode.com/problems/moving-stones-until-consecutive/)|[Moving Stones Until Consecutive](./Algorithms/1033.moving-stones-until-consecutive)|38%|Easy|| +|[1032](https://leetcode.com/problems/stream-of-characters/)|[Stream of Characters](./Algorithms/1032.stream-of-characters)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1031](https://leetcode.com/problems/maximum-sum-of-two-non-overlapping-subarrays/)|[Maximum Sum of Two Non-Overlapping Subarrays](./Algorithms/1031.maximum-sum-of-two-non-overlapping-subarrays)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1030](https://leetcode.com/problems/matrix-cells-in-distance-order/)|[Matrix Cells in Distance Order](./Algorithms/1030.matrix-cells-in-distance-order)|64%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1029](https://leetcode.com/problems/two-city-scheduling/)|[Two City Scheduling](./Algorithms/1029.two-city-scheduling)|55%|Easy|| +|[1028](https://leetcode.com/problems/recover-a-tree-from-preorder-traversal/)|[Recover a Tree From Preorder Traversal](./Algorithms/1028.recover-a-tree-from-preorder-traversal)|69%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1027](https://leetcode.com/problems/longest-arithmetic-sequence/)|[Longest Arithmetic Sequence](./Algorithms/1027.longest-arithmetic-sequence)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1026](https://leetcode.com/problems/maximum-difference-between-node-and-ancestor/)|[Maximum Difference Between Node and Ancestor](./Algorithms/1026.maximum-difference-between-node-and-ancestor)|61%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1025](https://leetcode.com/problems/divisor-game/)|[Divisor Game](./Algorithms/1025.divisor-game)|65%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1024](https://leetcode.com/problems/video-stitching/)|[Video Stitching](./Algorithms/1024.video-stitching)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1023](https://leetcode.com/problems/camelcase-matching/)|[Camelcase Matching](./Algorithms/1023.camelcase-matching)|54%|Medium|| +|[1022](https://leetcode.com/problems/sum-of-root-to-leaf-binary-numbers/)|[Sum of Root To Leaf Binary Numbers](./Algorithms/1022.sum-of-root-to-leaf-binary-numbers)|61%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1021](https://leetcode.com/problems/remove-outermost-parentheses/)|[Remove Outermost Parentheses](./Algorithms/1021.remove-outermost-parentheses)|75%|Easy|| +|[1020](https://leetcode.com/problems/number-of-enclaves/)|[Number of Enclaves](./Algorithms/1020.number-of-enclaves)|54%|Medium|| +|[1019](https://leetcode.com/problems/next-greater-node-in-linked-list/)|[Next Greater Node In Linked List](./Algorithms/1019.next-greater-node-in-linked-list)|56%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1018](https://leetcode.com/problems/binary-prefix-divisible-by-5/)|[Binary Prefix Divisible By 5](./Algorithms/1018.binary-prefix-divisible-by-5)|46%|Easy|| +|[1017](https://leetcode.com/problems/convert-to-base-2/)|[Convert to Base -2](./Algorithms/1017.convert-to-base-2)|57%|Medium|| +|[1016](https://leetcode.com/problems/binary-string-with-substrings-representing-1-to-n/)|[Binary String With Substrings Representing 1 To N](./Algorithms/1016.binary-string-with-substrings-representing-1-to-n)|58%|Medium|| +|[1015](https://leetcode.com/problems/smallest-integer-divisible-by-k/)|[Smallest Integer Divisible by K](./Algorithms/1015.smallest-integer-divisible-by-k)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1014](https://leetcode.com/problems/best-sightseeing-pair/)|[Best Sightseeing Pair](./Algorithms/1014.best-sightseeing-pair)|51%|Medium|| +|[1013](https://leetcode.com/problems/partition-array-into-three-parts-with-equal-sum/)|[Partition Array Into Three Parts With Equal Sum](./Algorithms/1013.partition-array-into-three-parts-with-equal-sum)|56%|Easy|| +|[1012](https://leetcode.com/problems/numbers-with-repeated-digits/)|[Numbers With Repeated Digits](./Algorithms/1012.numbers-with-repeated-digits)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1011](https://leetcode.com/problems/capacity-to-ship-packages-within-d-days/)|[Capacity To Ship Packages Within D Days](./Algorithms/1011.capacity-to-ship-packages-within-d-days)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1010](https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/)|[Pairs of Songs With Total Durations Divisible by 60](./Algorithms/1010.pairs-of-songs-with-total-durations-divisible-by-60)|46%|Easy|| +|[1009](https://leetcode.com/problems/complement-of-base-10-integer/)|[Complement of Base 10 Integer](./Algorithms/1009.complement-of-base-10-integer)|59%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[1008](https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/)|[Construct Binary Search Tree from Preorder Traversal](./Algorithms/1008.construct-binary-search-tree-from-preorder-traversal)|73%|Medium|| +|[1007](https://leetcode.com/problems/minimum-domino-rotations-for-equal-row/)|[Minimum Domino Rotations For Equal Row](./Algorithms/1007.minimum-domino-rotations-for-equal-row)|51%|Medium|| +|[1006](https://leetcode.com/problems/clumsy-factorial/)|[Clumsy Factorial](./Algorithms/1006.clumsy-factorial)|53%|Medium|| +|[1005](https://leetcode.com/problems/maximize-sum-of-array-after-k-negations/)|[Maximize Sum Of Array After K Negations](./Algorithms/1005.maximize-sum-of-array-after-k-negations)|50%|Easy|| +|[1004](https://leetcode.com/problems/max-consecutive-ones-iii/)|[Max Consecutive Ones III](./Algorithms/1004.max-consecutive-ones-iii)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[1003](https://leetcode.com/problems/check-if-word-is-valid-after-substitutions/)|[Check If Word Is Valid After Substitutions](./Algorithms/1003.check-if-word-is-valid-after-substitutions)|53%|Medium|| +|[1002](https://leetcode.com/problems/find-common-characters/)|[Find Common Characters](./Algorithms/1002.find-common-characters)|65%|Easy|| +|[1001](https://leetcode.com/problems/grid-illumination/)|[Grid Illumination](./Algorithms/1001.grid-illumination)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[1000](https://leetcode.com/problems/minimum-cost-to-merge-stones/)|[Minimum Cost to Merge Stones](./Algorithms/1000.minimum-cost-to-merge-stones)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0999](https://leetcode.com/problems/available-captures-for-rook/)|[Available Captures for Rook](./Algorithms/0999.available-captures-for-rook)|65%|Easy|| +|[0998](https://leetcode.com/problems/maximum-binary-tree-ii/)|[Maximum Binary Tree II](./Algorithms/0998.maximum-binary-tree-ii)|61%|Medium|| +|[0997](https://leetcode.com/problems/find-the-town-judge/)|[Find the Town Judge](./Algorithms/0997.find-the-town-judge)|49%|Easy|| +|[0996](https://leetcode.com/problems/number-of-squareful-arrays/)|[Number of Squareful Arrays](./Algorithms/0996.number-of-squareful-arrays)|47%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0995](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/)|[Minimum Number of K Consecutive Bit Flips](./Algorithms/0995.minimum-number-of-k-consecutive-bit-flips)|46%|Hard|| +|[0994](https://leetcode.com/problems/rotting-oranges/)|[Rotting Oranges](./Algorithms/0994.rotting-oranges)|46%|Easy|| +|[0993](https://leetcode.com/problems/cousins-in-binary-tree/)|[Cousins in Binary Tree](./Algorithms/0993.cousins-in-binary-tree)|51%|Easy|| +|[0992](https://leetcode.com/problems/subarrays-with-k-different-integers/)|[Subarrays with K Different Integers](./Algorithms/0992.subarrays-with-k-different-integers)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0991](https://leetcode.com/problems/broken-calculator/)|[Broken Calculator](./Algorithms/0991.broken-calculator)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0990](https://leetcode.com/problems/satisfiability-of-equality-equations/)|[Satisfiability of Equality Equations](./Algorithms/0990.satisfiability-of-equality-equations)|41%|Medium|| +|[0989](https://leetcode.com/problems/add-to-array-form-of-integer/)|[Add to Array-Form of Integer](./Algorithms/0989.add-to-array-form-of-integer)|43%|Easy|| +|[0988](https://leetcode.com/problems/smallest-string-starting-from-leaf/)|[Smallest String Starting From Leaf](./Algorithms/0988.smallest-string-starting-from-leaf)|44%|Medium|| +|[0987](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree/)|[Vertical Order Traversal of a Binary Tree](./Algorithms/0987.vertical-order-traversal-of-a-binary-tree)|33%|Medium|| +|[0986](https://leetcode.com/problems/interval-list-intersections/)|[Interval List Intersections](./Algorithms/0986.interval-list-intersections)|64%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0985](https://leetcode.com/problems/sum-of-even-numbers-after-queries/)|[Sum of Even Numbers After Queries](./Algorithms/0985.sum-of-even-numbers-after-queries)|62%|Easy|| +|[0984](https://leetcode.com/problems/string-without-aaa-or-bbb/)|[String Without AAA or BBB](./Algorithms/0984.string-without-aaa-or-bbb)|34%|Medium|| +|[0983](https://leetcode.com/problems/minimum-cost-for-tickets/)|[Minimum Cost For Tickets](./Algorithms/0983.minimum-cost-for-tickets)|57%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0982](https://leetcode.com/problems/triples-with-bitwise-and-equal-to-zero/)|[Triples with Bitwise AND Equal To Zero](./Algorithms/0982.triples-with-bitwise-and-equal-to-zero)|54%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0981](https://leetcode.com/problems/time-based-key-value-store/)|[Time Based Key-Value Store](./Algorithms/0981.time-based-key-value-store)|51%|Medium|| +|[0980](https://leetcode.com/problems/unique-paths-iii/)|[Unique Paths III](./Algorithms/0980.unique-paths-iii)|71%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0979](https://leetcode.com/problems/distribute-coins-in-binary-tree/)|[Distribute Coins in Binary Tree](./Algorithms/0979.distribute-coins-in-binary-tree)|67%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0978](https://leetcode.com/problems/longest-turbulent-subarray/)|[Longest Turbulent Subarray](./Algorithms/0978.longest-turbulent-subarray)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0977](https://leetcode.com/problems/squares-of-a-sorted-array/)|[Squares of a Sorted Array](./Algorithms/0977.squares-of-a-sorted-array)|71%|Easy|| +|[0976](https://leetcode.com/problems/largest-perimeter-triangle/)|[Largest Perimeter Triangle](./Algorithms/0976.largest-perimeter-triangle)|57%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0975](https://leetcode.com/problems/odd-even-jump/)|[Odd Even Jump](./Algorithms/0975.odd-even-jump)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0974](https://leetcode.com/problems/subarray-sums-divisible-by-k/)|[Subarray Sums Divisible by K](./Algorithms/0974.subarray-sums-divisible-by-k)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0973](https://leetcode.com/problems/k-closest-points-to-origin/)|[K Closest Points to Origin](./Algorithms/0973.k-closest-points-to-origin)|61%|Medium|| +|[0972](https://leetcode.com/problems/equal-rational-numbers/)|[Equal Rational Numbers](./Algorithms/0972.equal-rational-numbers)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0971](https://leetcode.com/problems/flip-binary-tree-to-match-preorder-traversal/)|[Flip Binary Tree To Match Preorder Traversal](./Algorithms/0971.flip-binary-tree-to-match-preorder-traversal)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0970](https://leetcode.com/problems/powerful-integers/)|[Powerful Integers](./Algorithms/0970.powerful-integers)|39%|Easy|| +|[0969](https://leetcode.com/problems/pancake-sorting/)|[Pancake Sorting](./Algorithms/0969.pancake-sorting)|62%|Medium|| +|[0968](https://leetcode.com/problems/binary-tree-cameras/)|[Binary Tree Cameras](./Algorithms/0968.binary-tree-cameras)|36%|Hard|| +|[0967](https://leetcode.com/problems/numbers-with-same-consecutive-differences/)|[Numbers With Same Consecutive Differences](./Algorithms/0967.numbers-with-same-consecutive-differences)|38%|Medium|| +|[0966](https://leetcode.com/problems/vowel-spellchecker/)|[Vowel Spellchecker](./Algorithms/0966.vowel-spellchecker)|44%|Medium|| +|[0965](https://leetcode.com/problems/univalued-binary-tree/)|[Univalued Binary Tree](./Algorithms/0965.univalued-binary-tree)|66%|Easy|| +|[0964](https://leetcode.com/problems/least-operators-to-express-number/)|[Least Operators to Express Number](./Algorithms/0964.least-operators-to-express-number)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0963](https://leetcode.com/problems/minimum-area-rectangle-ii/)|[Minimum Area Rectangle II](./Algorithms/0963.minimum-area-rectangle-ii)|47%|Medium|| +|[0962](https://leetcode.com/problems/maximum-width-ramp/)|[Maximum Width Ramp](./Algorithms/0962.maximum-width-ramp)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0961](https://leetcode.com/problems/n-repeated-element-in-size-2n-array/)|[N-Repeated Element in Size 2N Array](./Algorithms/0961.n-repeated-element-in-size-2n-array)|72%|Easy|| +|[0960](https://leetcode.com/problems/delete-columns-to-make-sorted-iii/)|[Delete Columns to Make Sorted III](./Algorithms/0960.delete-columns-to-make-sorted-iii)|52%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0959](https://leetcode.com/problems/regions-cut-by-slashes/)|[Regions Cut By Slashes](./Algorithms/0959.regions-cut-by-slashes)|63%|Medium|| +|[0958](https://leetcode.com/problems/check-completeness-of-a-binary-tree/)|[Check Completeness of a Binary Tree](./Algorithms/0958.check-completeness-of-a-binary-tree)|50%|Medium|| +|[0957](https://leetcode.com/problems/prison-cells-after-n-days/)|[Prison Cells After N Days](./Algorithms/0957.prison-cells-after-n-days)|38%|Medium|| +|[0956](https://leetcode.com/problems/tallest-billboard/)|[Tallest Billboard](./Algorithms/0956.tallest-billboard)|38%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0955](https://leetcode.com/problems/delete-columns-to-make-sorted-ii/)|[Delete Columns to Make Sorted II](./Algorithms/0955.delete-columns-to-make-sorted-ii)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0954](https://leetcode.com/problems/array-of-doubled-pairs/)|[Array of Doubled Pairs](./Algorithms/0954.array-of-doubled-pairs)|35%|Medium|| +|[0953](https://leetcode.com/problems/verifying-an-alien-dictionary/)|[Verifying an Alien Dictionary](./Algorithms/0953.verifying-an-alien-dictionary)|55%|Easy|| +|[0952](https://leetcode.com/problems/largest-component-size-by-common-factor/)|[Largest Component Size by Common Factor](./Algorithms/0952.largest-component-size-by-common-factor)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0951](https://leetcode.com/problems/flip-equivalent-binary-trees/)|[Flip Equivalent Binary Trees](./Algorithms/0951.flip-equivalent-binary-trees)|65%|Medium|| +|[0950](https://leetcode.com/problems/reveal-cards-in-increasing-order/)|[Reveal Cards In Increasing Order](./Algorithms/0950.reveal-cards-in-increasing-order)|72%|Medium|| +|[0949](https://leetcode.com/problems/largest-time-for-given-digits/)|[Largest Time for Given Digits](./Algorithms/0949.largest-time-for-given-digits)|34%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0948](https://leetcode.com/problems/bag-of-tokens/)|[Bag of Tokens](./Algorithms/0948.bag-of-tokens)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0947](https://leetcode.com/problems/most-stones-removed-with-same-row-or-column/)|[Most Stones Removed with Same Row or Column](./Algorithms/0947.most-stones-removed-with-same-row-or-column)|54%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0946](https://leetcode.com/problems/validate-stack-sequences/)|[Validate Stack Sequences](./Algorithms/0946.validate-stack-sequences)|58%|Medium|| +|[0945](https://leetcode.com/problems/minimum-increment-to-make-array-unique/)|[Minimum Increment to Make Array Unique](./Algorithms/0945.minimum-increment-to-make-array-unique)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0944](https://leetcode.com/problems/delete-columns-to-make-sorted/)|[Delete Columns to Make Sorted](./Algorithms/0944.delete-columns-to-make-sorted)|69%|Easy|| +|[0943](https://leetcode.com/problems/find-the-shortest-superstring/)|[Find the Shortest Superstring](./Algorithms/0943.find-the-shortest-superstring)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0942](https://leetcode.com/problems/di-string-match/)|[DI String Match](./Algorithms/0942.di-string-match)|70%|Easy|| +|[0941](https://leetcode.com/problems/valid-mountain-array/)|[Valid Mountain Array](./Algorithms/0941.valid-mountain-array)|35%|Easy|| +|[0940](https://leetcode.com/problems/distinct-subsequences-ii/)|[Distinct Subsequences II](./Algorithms/0940.distinct-subsequences-ii)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0939](https://leetcode.com/problems/minimum-area-rectangle/)|[Minimum Area Rectangle](./Algorithms/0939.minimum-area-rectangle)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0938](https://leetcode.com/problems/range-sum-of-bst/)|[Range Sum of BST](./Algorithms/0938.range-sum-of-bst)|78%|Easy|| +|[0937](https://leetcode.com/problems/reorder-data-in-log-files/)|[Reorder Data in Log Files](./Algorithms/0937.reorder-data-in-log-files)|54%|Easy|| +|[0936](https://leetcode.com/problems/stamping-the-sequence/)|[Stamping The Sequence](./Algorithms/0936.stamping-the-sequence)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0935](https://leetcode.com/problems/knight-dialer/)|[Knight Dialer](./Algorithms/0935.knight-dialer)|42%|Medium|| +|[0934](https://leetcode.com/problems/shortest-bridge/)|[Shortest Bridge](./Algorithms/0934.shortest-bridge)|45%|Medium|| +|[0933](https://leetcode.com/problems/number-of-recent-calls/)|[Number of Recent Calls](./Algorithms/0933.number-of-recent-calls)|69%|Easy|| +|[0932](https://leetcode.com/problems/beautiful-array/)|[Beautiful Array](./Algorithms/0932.beautiful-array)|54%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0931](https://leetcode.com/problems/minimum-falling-path-sum/)|[Minimum Falling Path Sum](./Algorithms/0931.minimum-falling-path-sum)|59%|Medium|| +|[0930](https://leetcode.com/problems/binary-subarrays-with-sum/)|[Binary Subarrays With Sum](./Algorithms/0930.binary-subarrays-with-sum)|39%|Medium|| +|[0929](https://leetcode.com/problems/unique-email-addresses/)|[Unique Email Addresses](./Algorithms/0929.unique-email-addresses)|68%|Easy|| +|[0928](https://leetcode.com/problems/minimize-malware-spread-ii/)|[Minimize Malware Spread II](./Algorithms/0928.minimize-malware-spread-ii)|39%|Hard|| +|[0927](https://leetcode.com/problems/three-equal-parts/)|[Three Equal Parts](./Algorithms/0927.three-equal-parts)|31%|Hard|| +|[0926](https://leetcode.com/problems/flip-string-to-monotone-increasing/)|[Flip String to Monotone Increasing](./Algorithms/0926.flip-string-to-monotone-increasing)|51%|Medium|| +|[0925](https://leetcode.com/problems/long-pressed-name/)|[Long Pressed Name](./Algorithms/0925.long-pressed-name)|44%|Easy|| +|[0924](https://leetcode.com/problems/minimize-malware-spread/)|[Minimize Malware Spread](./Algorithms/0924.minimize-malware-spread)|40%|Hard|| +|[0923](https://leetcode.com/problems/3sum-with-multiplicity/)|[3Sum With Multiplicity](./Algorithms/0923.3sum-with-multiplicity)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0922](https://leetcode.com/problems/sort-array-by-parity-ii/)|[Sort Array By Parity II](./Algorithms/0922.sort-array-by-parity-ii)|67%|Easy|| +|[0921](https://leetcode.com/problems/minimum-add-to-make-parentheses-valid/)|[Minimum Add to Make Parentheses Valid](./Algorithms/0921.minimum-add-to-make-parentheses-valid)|70%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0920](https://leetcode.com/problems/number-of-music-playlists/)|[Number of Music Playlists](./Algorithms/0920.number-of-music-playlists)|44%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0919](https://leetcode.com/problems/complete-binary-tree-inserter/)|[Complete Binary Tree Inserter](./Algorithms/0919.complete-binary-tree-inserter)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0918](https://leetcode.com/problems/maximum-sum-circular-subarray/)|[Maximum Sum Circular Subarray](./Algorithms/0918.maximum-sum-circular-subarray)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0917](https://leetcode.com/problems/reverse-only-letters/)|[Reverse Only Letters](./Algorithms/0917.reverse-only-letters)|56%|Easy|| +|[0916](https://leetcode.com/problems/word-subsets/)|[Word Subsets](./Algorithms/0916.word-subsets)|45%|Medium|| +|[0915](https://leetcode.com/problems/partition-array-into-disjoint-intervals/)|[Partition Array into Disjoint Intervals](./Algorithms/0915.partition-array-into-disjoint-intervals)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0914](https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/)|[X of a Kind in a Deck of Cards](./Algorithms/0914.x-of-a-kind-in-a-deck-of-cards)|34%|Easy|| +|[0913](https://leetcode.com/problems/cat-and-mouse/)|[Cat and Mouse](./Algorithms/0913.cat-and-mouse)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0912](https://leetcode.com/problems/sort-an-array/)|[Sort an Array](./Algorithms/0912.sort-an-array)|62%|Medium|| +|[0911](https://leetcode.com/problems/online-election/)|[Online Election](./Algorithms/0911.online-election)|48%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0910](https://leetcode.com/problems/smallest-range-ii/)|[Smallest Range II](./Algorithms/0910.smallest-range-ii)|24%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0909](https://leetcode.com/problems/snakes-and-ladders/)|[Snakes and Ladders](./Algorithms/0909.snakes-and-ladders)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0908](https://leetcode.com/problems/smallest-range-i/)|[Smallest Range I](./Algorithms/0908.smallest-range-i)|64%|Easy|| +|[0907](https://leetcode.com/problems/sum-of-subarray-minimums/)|[Sum of Subarray Minimums](./Algorithms/0907.sum-of-subarray-minimums)|29%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0906](https://leetcode.com/problems/super-palindromes/)|[Super Palindromes](./Algorithms/0906.super-palindromes)|30%|Hard|| +|[0905](https://leetcode.com/problems/sort-array-by-parity/)|[Sort Array By Parity](./Algorithms/0905.sort-array-by-parity)|72%|Easy|| +|[0904](https://leetcode.com/problems/fruit-into-baskets/)|[Fruit Into Baskets](./Algorithms/0904.fruit-into-baskets)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0903](https://leetcode.com/problems/valid-permutations-for-di-sequence/)|[Valid Permutations for DI Sequence](./Algorithms/0903.valid-permutations-for-di-sequence)|46%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0902](https://leetcode.com/problems/numbers-at-most-n-given-digit-set/)|[Numbers At Most N Given Digit Set](./Algorithms/0902.numbers-at-most-n-given-digit-set)|29%|Hard|| +|[0901](https://leetcode.com/problems/online-stock-span/)|[Online Stock Span](./Algorithms/0901.online-stock-span)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0900](https://leetcode.com/problems/rle-iterator/)|[RLE Iterator](./Algorithms/0900.rle-iterator)|51%|Medium|| +|[0899](https://leetcode.com/problems/orderly-queue/)|[Orderly Queue](./Algorithms/0899.orderly-queue)|49%|Hard|| +|[0898](https://leetcode.com/problems/bitwise-ors-of-subarrays/)|[Bitwise ORs of Subarrays](./Algorithms/0898.bitwise-ors-of-subarrays)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0897](https://leetcode.com/problems/increasing-order-search-tree/)|[Increasing Order Search Tree](./Algorithms/0897.increasing-order-search-tree)|66%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0896](https://leetcode.com/problems/monotonic-array/)|[Monotonic Array](./Algorithms/0896.monotonic-array)|56%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0895](https://leetcode.com/problems/maximum-frequency-stack/)|[Maximum Frequency Stack](./Algorithms/0895.maximum-frequency-stack)|58%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0894](https://leetcode.com/problems/all-possible-full-binary-trees/)|[All Possible Full Binary Trees](./Algorithms/0894.all-possible-full-binary-trees)|72%|Medium|| +|[0893](https://leetcode.com/problems/groups-of-special-equivalent-strings/)|[Groups of Special-Equivalent Strings](./Algorithms/0893.groups-of-special-equivalent-strings)|63%|Easy|| +|[0892](https://leetcode.com/problems/surface-area-of-3d-shapes/)|[Surface Area of 3D Shapes](./Algorithms/0892.surface-area-of-3d-shapes)|57%|Easy|| +|[0891](https://leetcode.com/problems/sum-of-subsequence-widths/)|[Sum of Subsequence Widths](./Algorithms/0891.sum-of-subsequence-widths)|30%|Hard|| +|[0890](https://leetcode.com/problems/find-and-replace-pattern/)|[Find and Replace Pattern](./Algorithms/0890.find-and-replace-pattern)|72%|Medium|| +|[0889](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-postorder-traversal/)|[Construct Binary Tree from Preorder and Postorder Traversal](./Algorithms/0889.construct-binary-tree-from-preorder-and-postorder-traversal)|62%|Medium|| +|[0888](https://leetcode.com/problems/fair-candy-swap/)|[Fair Candy Swap](./Algorithms/0888.fair-candy-swap)|56%|Easy|| +|[0887](https://leetcode.com/problems/super-egg-drop/)|[Super Egg Drop](./Algorithms/0887.super-egg-drop)|25%|Hard|| +|[0886](https://leetcode.com/problems/possible-bipartition/)|[Possible Bipartition](./Algorithms/0886.possible-bipartition)|41%|Medium|| +|[0885](https://leetcode.com/problems/spiral-matrix-iii/)|[Spiral Matrix III](./Algorithms/0885.spiral-matrix-iii)|66%|Medium|| +|[0884](https://leetcode.com/problems/uncommon-words-from-two-sentences/)|[Uncommon Words from Two Sentences](./Algorithms/0884.uncommon-words-from-two-sentences)|61%|Easy|| +|[0883](https://leetcode.com/problems/projection-area-of-3d-shapes/)|[Projection Area of 3D Shapes](./Algorithms/0883.projection-area-of-3d-shapes)|66%|Easy|| +|[0882](https://leetcode.com/problems/reachable-nodes-in-subdivided-graph/)|[Reachable Nodes In Subdivided Graph](./Algorithms/0882.reachable-nodes-in-subdivided-graph)|39%|Hard|| +|[0881](https://leetcode.com/problems/boats-to-save-people/)|[Boats to Save People](./Algorithms/0881.boats-to-save-people)|44%|Medium|| +|[0880](https://leetcode.com/problems/decoded-string-at-index/)|[Decoded String at Index](./Algorithms/0880.decoded-string-at-index)|23%|Medium|| +|[0879](https://leetcode.com/problems/profitable-schemes/)|[Profitable Schemes](./Algorithms/0879.profitable-schemes)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0878](https://leetcode.com/problems/nth-magical-number/)|[Nth Magical Number](./Algorithms/0878.nth-magical-number)|26%|Hard|| +|[0877](https://leetcode.com/problems/stone-game/)|[Stone Game](./Algorithms/0877.stone-game)|62%|Medium|| +|[0876](https://leetcode.com/problems/middle-of-the-linked-list/)|[Middle of the Linked List](./Algorithms/0876.middle-of-the-linked-list)|65%|Easy|| +|[0875](https://leetcode.com/problems/koko-eating-bananas/)|[Koko Eating Bananas](./Algorithms/0875.koko-eating-bananas)|48%|Medium|| +|[0874](https://leetcode.com/problems/walking-robot-simulation/)|[Walking Robot Simulation](./Algorithms/0874.walking-robot-simulation)|33%|Easy|| +|[0873](https://leetcode.com/problems/length-of-longest-fibonacci-subsequence/)|[Length of Longest Fibonacci Subsequence](./Algorithms/0873.length-of-longest-fibonacci-subsequence)|47%|Medium|| +|[0872](https://leetcode.com/problems/leaf-similar-trees/)|[Leaf-Similar Trees](./Algorithms/0872.leaf-similar-trees)|64%|Easy|| +|[0871](https://leetcode.com/problems/minimum-number-of-refueling-stops/)|[Minimum Number of Refueling Stops](./Algorithms/0871.minimum-number-of-refueling-stops)|30%|Hard|| +|[0870](https://leetcode.com/problems/advantage-shuffle/)|[Advantage Shuffle](./Algorithms/0870.advantage-shuffle)|43%|Medium|| +|[0869](https://leetcode.com/problems/reordered-power-of-2/)|[Reordered Power of 2](./Algorithms/0869.reordered-power-of-2)|51%|Medium|| +|[0868](https://leetcode.com/problems/binary-gap/)|[Binary Gap](./Algorithms/0868.binary-gap)|59%|Easy|| +|[0867](https://leetcode.com/problems/transpose-matrix/)|[Transpose Matrix](./Algorithms/0867.transpose-matrix)|63%|Easy|| +|[0866](https://leetcode.com/problems/prime-palindrome/)|[Prime Palindrome](./Algorithms/0866.prime-palindrome)|21%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0865](https://leetcode.com/problems/smallest-subtree-with-all-the-deepest-nodes/)|[Smallest Subtree with all the Deepest Nodes](./Algorithms/0865.smallest-subtree-with-all-the-deepest-nodes)|58%|Medium|| +|[0864](https://leetcode.com/problems/shortest-path-to-get-all-keys/)|[Shortest Path to Get All Keys](./Algorithms/0864.shortest-path-to-get-all-keys)|38%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0863](https://leetcode.com/problems/all-nodes-distance-k-in-binary-tree/)|[All Nodes Distance K in Binary Tree](./Algorithms/0863.all-nodes-distance-k-in-binary-tree)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0862](https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/)|[Shortest Subarray with Sum at Least K](./Algorithms/0862.shortest-subarray-with-sum-at-least-k)|22%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0861](https://leetcode.com/problems/score-after-flipping-matrix/)|[Score After Flipping Matrix](./Algorithms/0861.score-after-flipping-matrix)|70%|Medium|| +|[0860](https://leetcode.com/problems/lemonade-change/)|[Lemonade Change](./Algorithms/0860.lemonade-change)|50%|Easy|| +|[0859](https://leetcode.com/problems/buddy-strings/)|[Buddy Strings](./Algorithms/0859.buddy-strings)|27%|Easy|| +|[0858](https://leetcode.com/problems/mirror-reflection/)|[Mirror Reflection](./Algorithms/0858.mirror-reflection)|52%|Medium|| +|[0857](https://leetcode.com/problems/minimum-cost-to-hire-k-workers/)|[Minimum Cost to Hire K Workers](./Algorithms/0857.minimum-cost-to-hire-k-workers)|48%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0856](https://leetcode.com/problems/score-of-parentheses/)|[Score of Parentheses](./Algorithms/0856.score-of-parentheses)|57%|Medium|| +|[0855](https://leetcode.com/problems/exam-room/)|[Exam Room](./Algorithms/0855.exam-room)|40%|Medium|| +|[0854](https://leetcode.com/problems/k-similar-strings/)|[K-Similar Strings](./Algorithms/0854.k-similar-strings)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0853](https://leetcode.com/problems/car-fleet/)|[Car Fleet](./Algorithms/0853.car-fleet)|41%|Medium|| +|[0852](https://leetcode.com/problems/peak-index-in-a-mountain-array/)|[Peak Index in a Mountain Array](./Algorithms/0852.peak-index-in-a-mountain-array)|70%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0851](https://leetcode.com/problems/loud-and-rich/)|[Loud and Rich](./Algorithms/0851.loud-and-rich)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0850](https://leetcode.com/problems/rectangle-area-ii/)|[Rectangle Area II](./Algorithms/0850.rectangle-area-ii)|46%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0849](https://leetcode.com/problems/maximize-distance-to-closest-person/)|[Maximize Distance to Closest Person](./Algorithms/0849.maximize-distance-to-closest-person)|41%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0848](https://leetcode.com/problems/shifting-letters/)|[Shifting Letters](./Algorithms/0848.shifting-letters)|42%|Medium|| +|[0847](https://leetcode.com/problems/shortest-path-visiting-all-nodes/)|[Shortest Path Visiting All Nodes](./Algorithms/0847.shortest-path-visiting-all-nodes)|48%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0846](https://leetcode.com/problems/hand-of-straights/)|[Hand of Straights](./Algorithms/0846.hand-of-straights)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0845](https://leetcode.com/problems/longest-mountain-in-array/)|[Longest Mountain in Array](./Algorithms/0845.longest-mountain-in-array)|35%|Medium|| +|[0844](https://leetcode.com/problems/backspace-string-compare/)|[Backspace String Compare](./Algorithms/0844.backspace-string-compare)|46%|Easy|| +|[0843](https://leetcode.com/problems/guess-the-word/)|[Guess the Word](./Algorithms/0843.guess-the-word)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0842](https://leetcode.com/problems/split-array-into-fibonacci-sequence/)|[Split Array into Fibonacci Sequence](./Algorithms/0842.split-array-into-fibonacci-sequence)|35%|Medium|| +|[0841](https://leetcode.com/problems/keys-and-rooms/)|[Keys and Rooms](./Algorithms/0841.keys-and-rooms)|61%|Medium|| +|[0840](https://leetcode.com/problems/magic-squares-in-grid/)|[Magic Squares In Grid](./Algorithms/0840.magic-squares-in-grid)|36%|Easy|| +|[0839](https://leetcode.com/problems/similar-string-groups/)|[Similar String Groups](./Algorithms/0839.similar-string-groups)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0838](https://leetcode.com/problems/push-dominoes/)|[Push Dominoes](./Algorithms/0838.push-dominoes)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0837](https://leetcode.com/problems/new-21-game/)|[New 21 Game](./Algorithms/0837.new-21-game)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0836](https://leetcode.com/problems/rectangle-overlap/)|[Rectangle Overlap](./Algorithms/0836.rectangle-overlap)|47%|Easy|| +|[0835](https://leetcode.com/problems/image-overlap/)|[Image Overlap](./Algorithms/0835.image-overlap)|54%|Medium|| +|[0834](https://leetcode.com/problems/sum-of-distances-in-tree/)|[Sum of Distances in Tree](./Algorithms/0834.sum-of-distances-in-tree)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0833](https://leetcode.com/problems/find-and-replace-in-string/)|[Find And Replace in String](./Algorithms/0833.find-and-replace-in-string)|48%|Medium|| +|[0832](https://leetcode.com/problems/flipping-an-image/)|[Flipping an Image](./Algorithms/0832.flipping-an-image)|73%|Easy|| +|[0831](https://leetcode.com/problems/masking-personal-information/)|[Masking Personal Information](./Algorithms/0831.masking-personal-information)|42%|Medium|| +|[0830](https://leetcode.com/problems/positions-of-large-groups/)|[Positions of Large Groups](./Algorithms/0830.positions-of-large-groups)|48%|Easy|| +|[0829](https://leetcode.com/problems/consecutive-numbers-sum/)|[Consecutive Numbers Sum](./Algorithms/0829.consecutive-numbers-sum)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0828](https://leetcode.com/problems/unique-letter-string/)|[Unique Letter String](./Algorithms/0828.unique-letter-string)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0827](https://leetcode.com/problems/making-a-large-island/)|[Making A Large Island](./Algorithms/0827.making-a-large-island)|44%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0826](https://leetcode.com/problems/most-profit-assigning-work/)|[Most Profit Assigning Work](./Algorithms/0826.most-profit-assigning-work)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0825](https://leetcode.com/problems/friends-of-appropriate-ages/)|[Friends Of Appropriate Ages](./Algorithms/0825.friends-of-appropriate-ages)|39%|Medium|| +|[0824](https://leetcode.com/problems/goat-latin/)|[Goat Latin](./Algorithms/0824.goat-latin)|59%|Easy|| +|[0823](https://leetcode.com/problems/binary-trees-with-factors/)|[Binary Trees With Factors](./Algorithms/0823.binary-trees-with-factors)|33%|Medium|| +|[0822](https://leetcode.com/problems/card-flipping-game/)|[Card Flipping Game](./Algorithms/0822.card-flipping-game)|41%|Medium|| +|[0821](https://leetcode.com/problems/shortest-distance-to-a-character/)|[Shortest Distance to a Character](./Algorithms/0821.shortest-distance-to-a-character)|64%|Easy|| +|[0820](https://leetcode.com/problems/short-encoding-of-words/)|[Short Encoding of Words](./Algorithms/0820.short-encoding-of-words)|48%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0819](https://leetcode.com/problems/most-common-word/)|[Most Common Word](./Algorithms/0819.most-common-word)|43%|Easy|| +|[0818](https://leetcode.com/problems/race-car/)|[Race Car](./Algorithms/0818.race-car)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0817](https://leetcode.com/problems/linked-list-components/)|[Linked List Components](./Algorithms/0817.linked-list-components)|55%|Medium|| +|[0816](https://leetcode.com/problems/ambiguous-coordinates/)|[Ambiguous Coordinates](./Algorithms/0816.ambiguous-coordinates)|45%|Medium|| +|[0815](https://leetcode.com/problems/bus-routes/)|[Bus Routes](./Algorithms/0815.bus-routes)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0814](https://leetcode.com/problems/binary-tree-pruning/)|[Binary Tree Pruning](./Algorithms/0814.binary-tree-pruning)|72%|Medium|| +|[0813](https://leetcode.com/problems/largest-sum-of-averages/)|[Largest Sum of Averages](./Algorithms/0813.largest-sum-of-averages)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0812](https://leetcode.com/problems/largest-triangle-area/)|[Largest Triangle Area](./Algorithms/0812.largest-triangle-area)|56%|Easy|| +|[0811](https://leetcode.com/problems/subdomain-visit-count/)|[Subdomain Visit Count](./Algorithms/0811.subdomain-visit-count)|66%|Easy|| +|[0810](https://leetcode.com/problems/chalkboard-xor-game/)|[Chalkboard XOR Game](./Algorithms/0810.chalkboard-xor-game)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0809](https://leetcode.com/problems/expressive-words/)|[Expressive Words](./Algorithms/0809.expressive-words)|45%|Medium|| +|[0808](https://leetcode.com/problems/soup-servings/)|[Soup Servings](./Algorithms/0808.soup-servings)|38%|Medium|| +|[0807](https://leetcode.com/problems/max-increase-to-keep-city-skyline/)|[Max Increase to Keep City Skyline](./Algorithms/0807.max-increase-to-keep-city-skyline)|82%|Medium|| +|[0806](https://leetcode.com/problems/number-of-lines-to-write-string/)|[Number of Lines To Write String](./Algorithms/0806.number-of-lines-to-write-string)|63%|Easy|| +|[0805](https://leetcode.com/problems/split-array-with-same-average/)|[Split Array With Same Average](./Algorithms/0805.split-array-with-same-average)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0804](https://leetcode.com/problems/unique-morse-code-words/)|[Unique Morse Code Words](./Algorithms/0804.unique-morse-code-words)|75%|Easy|| +|[0803](https://leetcode.com/problems/bricks-falling-when-hit/)|[Bricks Falling When Hit](./Algorithms/0803.bricks-falling-when-hit)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0802](https://leetcode.com/problems/find-eventual-safe-states/)|[Find Eventual Safe States](./Algorithms/0802.find-eventual-safe-states)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0801](https://leetcode.com/problems/minimum-swaps-to-make-sequences-increasing/)|[Minimum Swaps To Make Sequences Increasing](./Algorithms/0801.minimum-swaps-to-make-sequences-increasing)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0799](https://leetcode.com/problems/champagne-tower/)|[Champagne Tower](./Algorithms/0799.champagne-tower)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0798](https://leetcode.com/problems/smallest-rotation-with-highest-score/)|[Smallest Rotation with Highest Score](./Algorithms/0798.smallest-rotation-with-highest-score)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0797](https://leetcode.com/problems/all-paths-from-source-to-target/)|[All Paths From Source to Target](./Algorithms/0797.all-paths-from-source-to-target)|72%|Medium|| +|[0796](https://leetcode.com/problems/rotate-string/)|[Rotate String](./Algorithms/0796.rotate-string)|49%|Easy|| +|[0795](https://leetcode.com/problems/number-of-subarrays-with-bounded-maximum/)|[Number of Subarrays with Bounded Maximum](./Algorithms/0795.number-of-subarrays-with-bounded-maximum)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0794](https://leetcode.com/problems/valid-tic-tac-toe-state/)|[Valid Tic-Tac-Toe State](./Algorithms/0794.valid-tic-tac-toe-state)|31%|Medium|| +|[0793](https://leetcode.com/problems/preimage-size-of-factorial-zeroes-function/)|[Preimage Size of Factorial Zeroes Function](./Algorithms/0793.preimage-size-of-factorial-zeroes-function)|39%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0792](https://leetcode.com/problems/number-of-matching-subsequences/)|[Number of Matching Subsequences](./Algorithms/0792.number-of-matching-subsequences)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0791](https://leetcode.com/problems/custom-sort-string/)|[Custom Sort String](./Algorithms/0791.custom-sort-string)|63%|Medium|| +|[0790](https://leetcode.com/problems/domino-and-tromino-tiling/)|[Domino and Tromino Tiling](./Algorithms/0790.domino-and-tromino-tiling)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0789](https://leetcode.com/problems/escape-the-ghosts/)|[Escape The Ghosts](./Algorithms/0789.escape-the-ghosts)|56%|Medium|| +|[0788](https://leetcode.com/problems/rotated-digits/)|[Rotated Digits](./Algorithms/0788.rotated-digits)|55%|Easy|| +|[0787](https://leetcode.com/problems/cheapest-flights-within-k-stops/)|[Cheapest Flights Within K Stops](./Algorithms/0787.cheapest-flights-within-k-stops)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0786](https://leetcode.com/problems/k-th-smallest-prime-fraction/)|[K-th Smallest Prime Fraction](./Algorithms/0786.k-th-smallest-prime-fraction)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0785](https://leetcode.com/problems/is-graph-bipartite/)|[Is Graph Bipartite?](./Algorithms/0785.is-graph-bipartite)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0784](https://leetcode.com/problems/letter-case-permutation/)|[Letter Case Permutation](./Algorithms/0784.letter-case-permutation)|59%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0783](https://leetcode.com/problems/minimum-distance-between-bst-nodes/)|[Minimum Distance Between BST Nodes](./Algorithms/0783.minimum-distance-between-bst-nodes)|51%|Easy|| +|[0782](https://leetcode.com/problems/transform-to-chessboard/)|[Transform to Chessboard](./Algorithms/0782.transform-to-chessboard)|39%|Hard|| +|[0781](https://leetcode.com/problems/rabbits-in-forest/)|[Rabbits in Forest](./Algorithms/0781.rabbits-in-forest)|52%|Medium|| +|[0780](https://leetcode.com/problems/reaching-points/)|[Reaching Points](./Algorithms/0780.reaching-points)|28%|Hard|| +|[0779](https://leetcode.com/problems/k-th-symbol-in-grammar/)|[K-th Symbol in Grammar](./Algorithms/0779.k-th-symbol-in-grammar)|37%|Medium|| +|[0778](https://leetcode.com/problems/swim-in-rising-water/)|[Swim in Rising Water](./Algorithms/0778.swim-in-rising-water)|49%|Hard|| +|[0777](https://leetcode.com/problems/swap-adjacent-in-lr-string/)|[Swap Adjacent in LR String](./Algorithms/0777.swap-adjacent-in-lr-string)|34%|Medium|| +|[0775](https://leetcode.com/problems/global-and-local-inversions/)|[Global and Local Inversions](./Algorithms/0775.global-and-local-inversions)|40%|Medium|| +|[0773](https://leetcode.com/problems/sliding-puzzle/)|[Sliding Puzzle](./Algorithms/0773.sliding-puzzle)|55%|Hard|| +|[0771](https://leetcode.com/problems/jewels-and-stones/)|[Jewels and Stones](./Algorithms/0771.jewels-and-stones)|83%|Easy|| +|[0770](https://leetcode.com/problems/basic-calculator-iv/)|[Basic Calculator IV](./Algorithms/0770.basic-calculator-iv)|46%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0769](https://leetcode.com/problems/max-chunks-to-make-sorted/)|[Max Chunks To Make Sorted](./Algorithms/0769.max-chunks-to-make-sorted)|52%|Medium|| +|[0768](https://leetcode.com/problems/max-chunks-to-make-sorted-ii/)|[Max Chunks To Make Sorted II](./Algorithms/0768.max-chunks-to-make-sorted-ii)|46%|Hard|| +|[0767](https://leetcode.com/problems/reorganize-string/)|[Reorganize String](./Algorithms/0767.reorganize-string)|44%|Medium|| +|[0766](https://leetcode.com/problems/toeplitz-matrix/)|[Toeplitz Matrix](./Algorithms/0766.toeplitz-matrix)|62%|Easy|| +|[0765](https://leetcode.com/problems/couples-holding-hands/)|[Couples Holding Hands](./Algorithms/0765.couples-holding-hands)|52%|Hard|| +|[0764](https://leetcode.com/problems/largest-plus-sign/)|[Largest Plus Sign](./Algorithms/0764.largest-plus-sign)|44%|Medium|| +|[0763](https://leetcode.com/problems/partition-labels/)|[Partition Labels](./Algorithms/0763.partition-labels)|72%|Medium|| +|[0762](https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/)|[Prime Number of Set Bits in Binary Representation](./Algorithms/0762.prime-number-of-set-bits-in-binary-representation)|60%|Easy|| +|[0761](https://leetcode.com/problems/special-binary-string/)|[Special Binary String](./Algorithms/0761.special-binary-string)|53%|Hard|| +|[0757](https://leetcode.com/problems/set-intersection-size-at-least-two/)|[Set Intersection Size At Least Two](./Algorithms/0757.set-intersection-size-at-least-two)|37%|Hard|| +|[0756](https://leetcode.com/problems/pyramid-transition-matrix/)|[Pyramid Transition Matrix](./Algorithms/0756.pyramid-transition-matrix)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0754](https://leetcode.com/problems/reach-a-number/)|[Reach a Number](./Algorithms/0754.reach-a-number)|33%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0753](https://leetcode.com/problems/cracking-the-safe/)|[Cracking the Safe](./Algorithms/0753.cracking-the-safe)|48%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0752](https://leetcode.com/problems/open-the-lock/)|[Open the Lock](./Algorithms/0752.open-the-lock)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0749](https://leetcode.com/problems/contain-virus/)|[Contain Virus](./Algorithms/0749.contain-virus)|42%|Hard|| +|[0748](https://leetcode.com/problems/shortest-completing-word/)|[Shortest Completing Word](./Algorithms/0748.shortest-completing-word)|55%|Easy|| +|[0747](https://leetcode.com/problems/largest-number-at-least-twice-of-others/)|[Largest Number At Least Twice of Others](./Algorithms/0747.largest-number-at-least-twice-of-others)|40%|Easy|| +|[0746](https://leetcode.com/problems/min-cost-climbing-stairs/)|[Min Cost Climbing Stairs](./Algorithms/0746.min-cost-climbing-stairs)|48%|Easy|| +|[0745](https://leetcode.com/problems/prefix-and-suffix-search/)|[Prefix and Suffix Search](./Algorithms/0745.prefix-and-suffix-search)|32%|Hard|| +|[0744](https://leetcode.com/problems/find-smallest-letter-greater-than-target/)|[Find Smallest Letter Greater Than Target](./Algorithms/0744.find-smallest-letter-greater-than-target)|44%|Easy|| +|[0743](https://leetcode.com/problems/network-delay-time/)|[Network Delay Time](./Algorithms/0743.network-delay-time)|44%|Medium|| +|[0741](https://leetcode.com/problems/cherry-pickup/)|[Cherry Pickup](./Algorithms/0741.cherry-pickup)|31%|Hard|| +|[0740](https://leetcode.com/problems/delete-and-earn/)|[Delete and Earn](./Algorithms/0740.delete-and-earn)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0739](https://leetcode.com/problems/daily-temperatures/)|[Daily Temperatures](./Algorithms/0739.daily-temperatures)|61%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0738](https://leetcode.com/problems/monotone-increasing-digits/)|[Monotone Increasing Digits](./Algorithms/0738.monotone-increasing-digits)|42%|Medium|| +|[0736](https://leetcode.com/problems/parse-lisp-expression/)|[Parse Lisp Expression](./Algorithms/0736.parse-lisp-expression)|45%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0735](https://leetcode.com/problems/asteroid-collision/)|[Asteroid Collision](./Algorithms/0735.asteroid-collision)|39%|Medium|| +|[0733](https://leetcode.com/problems/flood-fill/)|[Flood Fill](./Algorithms/0733.flood-fill)|52%|Easy|| +|[0732](https://leetcode.com/problems/my-calendar-iii/)|[My Calendar III](./Algorithms/0732.my-calendar-iii)|57%|Hard|| +|[0731](https://leetcode.com/problems/my-calendar-ii/)|[My Calendar II](./Algorithms/0731.my-calendar-ii)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0730](https://leetcode.com/problems/count-different-palindromic-subsequences/)|[Count Different Palindromic Subsequences](./Algorithms/0730.count-different-palindromic-subsequences)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0729](https://leetcode.com/problems/my-calendar-i/)|[My Calendar I](./Algorithms/0729.my-calendar-i)|49%|Medium|| +|[0728](https://leetcode.com/problems/self-dividing-numbers/)|[Self Dividing Numbers](./Algorithms/0728.self-dividing-numbers)|71%|Easy|| +|[0726](https://leetcode.com/problems/number-of-atoms/)|[Number of Atoms](./Algorithms/0726.number-of-atoms)|46%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0725](https://leetcode.com/problems/split-linked-list-in-parts/)|[Split Linked List in Parts](./Algorithms/0725.split-linked-list-in-parts)|50%|Medium|| +|[0724](https://leetcode.com/problems/find-pivot-index/)|[Find Pivot Index](./Algorithms/0724.find-pivot-index)|42%|Easy|| +|[0722](https://leetcode.com/problems/remove-comments/)|[Remove Comments](./Algorithms/0722.remove-comments)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0721](https://leetcode.com/problems/accounts-merge/)|[Accounts Merge](./Algorithms/0721.accounts-merge)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0720](https://leetcode.com/problems/longest-word-in-dictionary/)|[Longest Word in Dictionary](./Algorithms/0720.longest-word-in-dictionary)|46%|Easy|| +|[0719](https://leetcode.com/problems/find-k-th-smallest-pair-distance/)|[Find K-th Smallest Pair Distance](./Algorithms/0719.find-k-th-smallest-pair-distance)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0718](https://leetcode.com/problems/maximum-length-of-repeated-subarray/)|[Maximum Length of Repeated Subarray](./Algorithms/0718.maximum-length-of-repeated-subarray)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0717](https://leetcode.com/problems/1-bit-and-2-bit-characters/)|[1-bit and 2-bit Characters](./Algorithms/0717.1-bit-and-2-bit-characters)|49%|Easy|| +|[0715](https://leetcode.com/problems/range-module/)|[Range Module](./Algorithms/0715.range-module)|36%|Hard|| +|[0714](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/)|[Best Time to Buy and Sell Stock with Transaction Fee](./Algorithms/0714.best-time-to-buy-and-sell-stock-with-transaction-fee)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0713](https://leetcode.com/problems/subarray-product-less-than-k/)|[Subarray Product Less Than K](./Algorithms/0713.subarray-product-less-than-k)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0712](https://leetcode.com/problems/minimum-ascii-delete-sum-for-two-strings/)|[Minimum ASCII Delete Sum for Two Strings](./Algorithms/0712.minimum-ascii-delete-sum-for-two-strings)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0710](https://leetcode.com/problems/random-pick-with-blacklist/)|[Random Pick with Blacklist](./Algorithms/0710.random-pick-with-blacklist)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0709](https://leetcode.com/problems/to-lower-case/)|[To Lower Case](./Algorithms/0709.to-lower-case)|77%|Easy|| +|[0707](https://leetcode.com/problems/design-linked-list/)|[Design Linked List](./Algorithms/0707.design-linked-list)|20%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0706](https://leetcode.com/problems/design-hashmap/)|[Design HashMap](./Algorithms/0706.design-hashmap)|57%|Easy|| +|[0705](https://leetcode.com/problems/design-hashset/)|[Design HashSet](./Algorithms/0705.design-hashset)|56%|Easy|| +|[0704](https://leetcode.com/problems/binary-search/)|[Binary Search](./Algorithms/0704.binary-search)|49%|Easy|| +|[0703](https://leetcode.com/problems/kth-largest-element-in-a-stream/)|[Kth Largest Element in a Stream](./Algorithms/0703.kth-largest-element-in-a-stream)|47%|Easy|| +|[0701](https://leetcode.com/problems/insert-into-a-binary-search-tree/)|[Insert into a Binary Search Tree](./Algorithms/0701.insert-into-a-binary-search-tree)|77%|Medium|| +|[0700](https://leetcode.com/problems/search-in-a-binary-search-tree/)|[Search in a Binary Search Tree](./Algorithms/0700.search-in-a-binary-search-tree)|69%|Easy|| +|[0699](https://leetcode.com/problems/falling-squares/)|[Falling Squares](./Algorithms/0699.falling-squares)|40%|Hard|| +|[0698](https://leetcode.com/problems/partition-to-k-equal-sum-subsets/)|[Partition to K Equal Sum Subsets](./Algorithms/0698.partition-to-k-equal-sum-subsets)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0697](https://leetcode.com/problems/degree-of-an-array/)|[Degree of an Array](./Algorithms/0697.degree-of-an-array)|51%|Easy|| +|[0696](https://leetcode.com/problems/count-binary-substrings/)|[Count Binary Substrings](./Algorithms/0696.count-binary-substrings)|54%|Easy|| +|[0695](https://leetcode.com/problems/max-area-of-island/)|[Max Area of Island](./Algorithms/0695.max-area-of-island)|59%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0693](https://leetcode.com/problems/binary-number-with-alternating-bits/)|[Binary Number with Alternating Bits](./Algorithms/0693.binary-number-with-alternating-bits)|58%|Easy|| +|[0692](https://leetcode.com/problems/top-k-frequent-words/)|[Top K Frequent Words](./Algorithms/0692.top-k-frequent-words)|47%|Medium|| +|[0691](https://leetcode.com/problems/stickers-to-spell-word/)|[Stickers to Spell Word](./Algorithms/0691.stickers-to-spell-word)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0689](https://leetcode.com/problems/maximum-sum-of-3-non-overlapping-subarrays/)|[Maximum Sum of 3 Non-Overlapping Subarrays](./Algorithms/0689.maximum-sum-of-3-non-overlapping-subarrays)|44%|Hard|| +|[0688](https://leetcode.com/problems/knight-probability-in-chessboard/)|[Knight Probability in Chessboard](./Algorithms/0688.knight-probability-in-chessboard)|46%|Medium|| +|[0687](https://leetcode.com/problems/longest-univalue-path/)|[Longest Univalue Path](./Algorithms/0687.longest-univalue-path)|34%|Easy|| +|[0686](https://leetcode.com/problems/repeated-string-match/)|[Repeated String Match](./Algorithms/0686.repeated-string-match)|31%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0685](https://leetcode.com/problems/redundant-connection-ii/)|[Redundant Connection II](./Algorithms/0685.redundant-connection-ii)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0684](https://leetcode.com/problems/redundant-connection/)|[Redundant Connection](./Algorithms/0684.redundant-connection)|54%|Medium|| +|[0682](https://leetcode.com/problems/baseball-game/)|[Baseball Game](./Algorithms/0682.baseball-game)|61%|Easy|| +|[0680](https://leetcode.com/problems/valid-palindrome-ii/)|[Valid Palindrome II](./Algorithms/0680.valid-palindrome-ii)|35%|Easy|| +|[0679](https://leetcode.com/problems/24-game/)|[24 Game](./Algorithms/0679.24-game)|44%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0678](https://leetcode.com/problems/valid-parenthesis-string/)|[Valid Parenthesis String](./Algorithms/0678.valid-parenthesis-string)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0677](https://leetcode.com/problems/map-sum-pairs/)|[Map Sum Pairs](./Algorithms/0677.map-sum-pairs)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0676](https://leetcode.com/problems/implement-magic-dictionary/)|[Implement Magic Dictionary](./Algorithms/0676.implement-magic-dictionary)|52%|Medium|| +|[0675](https://leetcode.com/problems/cut-off-trees-for-golf-event/)|[Cut Off Trees for Golf Event](./Algorithms/0675.cut-off-trees-for-golf-event)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0674](https://leetcode.com/problems/longest-continuous-increasing-subsequence/)|[Longest Continuous Increasing Subsequence](./Algorithms/0674.longest-continuous-increasing-subsequence)|44%|Easy|| +|[0673](https://leetcode.com/problems/number-of-longest-increasing-subsequence/)|[Number of Longest Increasing Subsequence](./Algorithms/0673.number-of-longest-increasing-subsequence)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0672](https://leetcode.com/problems/bulb-switcher-ii/)|[Bulb Switcher II](./Algorithms/0672.bulb-switcher-ii)|50%|Medium|| +|[0671](https://leetcode.com/problems/second-minimum-node-in-a-binary-tree/)|[Second Minimum Node In a Binary Tree](./Algorithms/0671.second-minimum-node-in-a-binary-tree)|43%|Easy|| +|[0670](https://leetcode.com/problems/maximum-swap/)|[Maximum Swap](./Algorithms/0670.maximum-swap)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0669](https://leetcode.com/problems/trim-a-binary-search-tree/)|[Trim a Binary Search Tree](./Algorithms/0669.trim-a-binary-search-tree)|61%|Easy|| +|[0668](https://leetcode.com/problems/kth-smallest-number-in-multiplication-table/)|[Kth Smallest Number in Multiplication Table](./Algorithms/0668.kth-smallest-number-in-multiplication-table)|43%|Hard|| +|[0667](https://leetcode.com/problems/beautiful-arrangement-ii/)|[Beautiful Arrangement II](./Algorithms/0667.beautiful-arrangement-ii)|52%|Medium|| +|[0665](https://leetcode.com/problems/non-decreasing-array/)|[Non-decreasing Array](./Algorithms/0665.non-decreasing-array)|19%|Easy|| +|[0664](https://leetcode.com/problems/strange-printer/)|[Strange Printer](./Algorithms/0664.strange-printer)|38%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0662](https://leetcode.com/problems/maximum-width-of-binary-tree/)|[Maximum Width of Binary Tree](./Algorithms/0662.maximum-width-of-binary-tree)|39%|Medium|| +|[0661](https://leetcode.com/problems/image-smoother/)|[Image Smoother](./Algorithms/0661.image-smoother)|49%|Easy|| +|[0659](https://leetcode.com/problems/split-array-into-consecutive-subsequences/)|[Split Array into Consecutive Subsequences](./Algorithms/0659.split-array-into-consecutive-subsequences)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0658](https://leetcode.com/problems/find-k-closest-elements/)|[Find K Closest Elements](./Algorithms/0658.find-k-closest-elements)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0657](https://leetcode.com/problems/robot-return-to-origin/)|[Robot Return to Origin](./Algorithms/0657.robot-return-to-origin)|72%|Easy|| +|[0655](https://leetcode.com/problems/print-binary-tree/)|[Print Binary Tree](./Algorithms/0655.print-binary-tree)|52%|Medium|| +|[0654](https://leetcode.com/problems/maximum-binary-tree/)|[Maximum Binary Tree](./Algorithms/0654.maximum-binary-tree)|77%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0653](https://leetcode.com/problems/two-sum-iv-input-is-a-bst/)|[Two Sum IV - Input is a BST](./Algorithms/0653.two-sum-iv-input-is-a-bst)|53%|Easy|| +|[0652](https://leetcode.com/problems/find-duplicate-subtrees/)|[Find Duplicate Subtrees](./Algorithms/0652.find-duplicate-subtrees)|47%|Medium|| +|[0650](https://leetcode.com/problems/2-keys-keyboard/)|[2 Keys Keyboard](./Algorithms/0650.2-keys-keyboard)|47%|Medium|| +|[0649](https://leetcode.com/problems/dota2-senate/)|[Dota2 Senate](./Algorithms/0649.dota2-senate)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0648](https://leetcode.com/problems/replace-words/)|[Replace Words](./Algorithms/0648.replace-words)|53%|Medium|| +|[0647](https://leetcode.com/problems/palindromic-substrings/)|[Palindromic Substrings](./Algorithms/0647.palindromic-substrings)|58%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0646](https://leetcode.com/problems/maximum-length-of-pair-chain/)|[Maximum Length of Pair Chain](./Algorithms/0646.maximum-length-of-pair-chain)|49%|Medium|| +|[0645](https://leetcode.com/problems/set-mismatch/)|[Set Mismatch](./Algorithms/0645.set-mismatch)|41%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0643](https://leetcode.com/problems/maximum-average-subarray-i/)|[Maximum Average Subarray I](./Algorithms/0643.maximum-average-subarray-i)|40%|Easy|| +|[0641](https://leetcode.com/problems/design-circular-deque/)|[Design Circular Deque](./Algorithms/0641.design-circular-deque)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0640](https://leetcode.com/problems/solve-the-equation/)|[Solve the Equation](./Algorithms/0640.solve-the-equation)|40%|Medium|| +|[0639](https://leetcode.com/problems/decode-ways-ii/)|[Decode Ways II](./Algorithms/0639.decode-ways-ii)|25%|Hard|| +|[0638](https://leetcode.com/problems/shopping-offers/)|[Shopping Offers](./Algorithms/0638.shopping-offers)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0637](https://leetcode.com/problems/average-of-levels-in-binary-tree/)|[Average of Levels in Binary Tree](./Algorithms/0637.average-of-levels-in-binary-tree)|60%|Easy|| +|[0636](https://leetcode.com/problems/exclusive-time-of-functions/)|[Exclusive Time of Functions](./Algorithms/0636.exclusive-time-of-functions)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0633](https://leetcode.com/problems/sum-of-square-numbers/)|[Sum of Square Numbers](./Algorithms/0633.sum-of-square-numbers)|32%|Easy|| +|[0632](https://leetcode.com/problems/smallest-range-covering-elements-from-k-lists/)|[Smallest Range Covering Elements from K Lists](./Algorithms/0632.smallest-range-covering-elements-from-k-lists)|49%|Hard|| +|[0630](https://leetcode.com/problems/course-schedule-iii/)|[Course Schedule III](./Algorithms/0630.course-schedule-iii)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0629](https://leetcode.com/problems/k-inverse-pairs-array/)|[K Inverse Pairs Array](./Algorithms/0629.k-inverse-pairs-array)|29%|Hard|| +|[0628](https://leetcode.com/problems/maximum-product-of-three-numbers/)|[Maximum Product of Three Numbers](./Algorithms/0628.maximum-product-of-three-numbers)|46%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0623](https://leetcode.com/problems/add-one-row-to-tree/)|[Add One Row to Tree](./Algorithms/0623.add-one-row-to-tree)|47%|Medium|| +|[0622](https://leetcode.com/problems/design-circular-queue/)|[Design Circular Queue](./Algorithms/0622.design-circular-queue)|41%|Medium|| +|[0621](https://leetcode.com/problems/task-scheduler/)|[Task Scheduler](./Algorithms/0621.task-scheduler)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0617](https://leetcode.com/problems/merge-two-binary-trees/)|[Merge Two Binary Trees](./Algorithms/0617.merge-two-binary-trees)|71%|Easy|| +|[0611](https://leetcode.com/problems/valid-triangle-number/)|[Valid Triangle Number](./Algorithms/0611.valid-triangle-number)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0609](https://leetcode.com/problems/find-duplicate-file-in-system/)|[Find Duplicate File in System](./Algorithms/0609.find-duplicate-file-in-system)|56%|Medium|| +|[0606](https://leetcode.com/problems/construct-string-from-binary-tree/)|[Construct String from Binary Tree](./Algorithms/0606.construct-string-from-binary-tree)|52%|Easy|| +|[0605](https://leetcode.com/problems/can-place-flowers/)|[Can Place Flowers](./Algorithms/0605.can-place-flowers)|31%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0600](https://leetcode.com/problems/non-negative-integers-without-consecutive-ones/)|[Non-negative Integers without Consecutive Ones](./Algorithms/0600.non-negative-integers-without-consecutive-ones)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0599](https://leetcode.com/problems/minimum-index-sum-of-two-lists/)|[Minimum Index Sum of Two Lists](./Algorithms/0599.minimum-index-sum-of-two-lists)|48%|Easy|| +|[0598](https://leetcode.com/problems/range-addition-ii/)|[Range Addition II](./Algorithms/0598.range-addition-ii)|49%|Easy|| +|[0594](https://leetcode.com/problems/longest-harmonious-subsequence/)|[Longest Harmonious Subsequence](./Algorithms/0594.longest-harmonious-subsequence)|44%|Easy|| +|[0593](https://leetcode.com/problems/valid-square/)|[Valid Square](./Algorithms/0593.valid-square)|41%|Medium|| +|[0592](https://leetcode.com/problems/fraction-addition-and-subtraction/)|[Fraction Addition and Subtraction](./Algorithms/0592.fraction-addition-and-subtraction)|47%|Medium|| +|[0591](https://leetcode.com/problems/tag-validator/)|[Tag Validator](./Algorithms/0591.tag-validator)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0587](https://leetcode.com/problems/erect-the-fence/)|[Erect the Fence](./Algorithms/0587.erect-the-fence)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0583](https://leetcode.com/problems/delete-operation-for-two-strings/)|[Delete Operation for Two Strings](./Algorithms/0583.delete-operation-for-two-strings)|46%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0581](https://leetcode.com/problems/shortest-unsorted-continuous-subarray/)|[Shortest Unsorted Continuous Subarray](./Algorithms/0581.shortest-unsorted-continuous-subarray)|30%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0576](https://leetcode.com/problems/out-of-boundary-paths/)|[Out of Boundary Paths](./Algorithms/0576.out-of-boundary-paths)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0575](https://leetcode.com/problems/distribute-candies/)|[Distribute Candies](./Algorithms/0575.distribute-candies)|60%|Easy|| +|[0572](https://leetcode.com/problems/subtree-of-another-tree/)|[Subtree of Another Tree](./Algorithms/0572.subtree-of-another-tree)|42%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0567](https://leetcode.com/problems/permutation-in-string/)|[Permutation in String](./Algorithms/0567.permutation-in-string)|39%|Medium|| +|[0566](https://leetcode.com/problems/reshape-the-matrix/)|[Reshape the Matrix](./Algorithms/0566.reshape-the-matrix)|59%|Easy|| +|[0565](https://leetcode.com/problems/array-nesting/)|[Array Nesting](./Algorithms/0565.array-nesting)|53%|Medium|| +|[0564](https://leetcode.com/problems/find-the-closest-palindrome/)|[Find the Closest Palindrome](./Algorithms/0564.find-the-closest-palindrome)|19%|Hard|| +|[0563](https://leetcode.com/problems/binary-tree-tilt/)|[Binary Tree Tilt](./Algorithms/0563.binary-tree-tilt)|47%|Easy|| +|[0561](https://leetcode.com/problems/array-partition-i/)|[Array Partition I](./Algorithms/0561.array-partition-i)|70%|Easy|| +|[0560](https://leetcode.com/problems/subarray-sum-equals-k/)|[Subarray Sum Equals K](./Algorithms/0560.subarray-sum-equals-k)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0557](https://leetcode.com/problems/reverse-words-in-a-string-iii/)|[Reverse Words in a String III](./Algorithms/0557.reverse-words-in-a-string-iii)|66%|Easy|| +|[0556](https://leetcode.com/problems/next-greater-element-iii/)|[Next Greater Element III](./Algorithms/0556.next-greater-element-iii)|30%|Medium|| +|[0554](https://leetcode.com/problems/brick-wall/)|[Brick Wall](./Algorithms/0554.brick-wall)|48%|Medium|| +|[0553](https://leetcode.com/problems/optimal-division/)|[Optimal Division](./Algorithms/0553.optimal-division)|55%|Medium|| +|[0552](https://leetcode.com/problems/student-attendance-record-ii/)|[Student Attendance Record II](./Algorithms/0552.student-attendance-record-ii)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0551](https://leetcode.com/problems/student-attendance-record-i/)|[Student Attendance Record I](./Algorithms/0551.student-attendance-record-i)|46%|Easy|| +|[0547](https://leetcode.com/problems/friend-circles/)|[Friend Circles](./Algorithms/0547.friend-circles)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0546](https://leetcode.com/problems/remove-boxes/)|[Remove Boxes](./Algorithms/0546.remove-boxes)|39%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0543](https://leetcode.com/problems/diameter-of-binary-tree/)|[Diameter of Binary Tree](./Algorithms/0543.diameter-of-binary-tree)|47%|Easy|| +|[0542](https://leetcode.com/problems/01-matrix/)|[01 Matrix](./Algorithms/0542.01-matrix)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0541](https://leetcode.com/problems/reverse-string-ii/)|[Reverse String II](./Algorithms/0541.reverse-string-ii)|46%|Easy|| +|[0540](https://leetcode.com/problems/single-element-in-a-sorted-array/)|[Single Element in a Sorted Array](./Algorithms/0540.single-element-in-a-sorted-array)|57%|Medium|| +|[0539](https://leetcode.com/problems/minimum-time-difference/)|[Minimum Time Difference](./Algorithms/0539.minimum-time-difference)|49%|Medium|| +|[0538](https://leetcode.com/problems/convert-bst-to-greater-tree/)|[Convert BST to Greater Tree](./Algorithms/0538.convert-bst-to-greater-tree)|52%|Easy|| +|[0537](https://leetcode.com/problems/complex-number-multiplication/)|[Complex Number Multiplication](./Algorithms/0537.complex-number-multiplication)|66%|Medium|| +|[0532](https://leetcode.com/problems/k-diff-pairs-in-an-array/)|[K-diff Pairs in an Array](./Algorithms/0532.k-diff-pairs-in-an-array)|30%|Easy|| +|[0530](https://leetcode.com/problems/minimum-absolute-difference-in-bst/)|[Minimum Absolute Difference in BST](./Algorithms/0530.minimum-absolute-difference-in-bst)|51%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0529](https://leetcode.com/problems/minesweeper/)|[Minesweeper](./Algorithms/0529.minesweeper)|55%|Medium|| +|[0528](https://leetcode.com/problems/random-pick-with-weight/)|[Random Pick with Weight](./Algorithms/0528.random-pick-with-weight)|43%|Medium|| +|[0526](https://leetcode.com/problems/beautiful-arrangement/)|[Beautiful Arrangement](./Algorithms/0526.beautiful-arrangement)|55%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0525](https://leetcode.com/problems/contiguous-array/)|[Contiguous Array](./Algorithms/0525.contiguous-array)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0524](https://leetcode.com/problems/longest-word-in-dictionary-through-deleting/)|[Longest Word in Dictionary through Deleting](./Algorithms/0524.longest-word-in-dictionary-through-deleting)|46%|Medium|| +|[0523](https://leetcode.com/problems/continuous-subarray-sum/)|[Continuous Subarray Sum](./Algorithms/0523.continuous-subarray-sum)|24%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0522](https://leetcode.com/problems/longest-uncommon-subsequence-ii/)|[Longest Uncommon Subsequence II](./Algorithms/0522.longest-uncommon-subsequence-ii)|33%|Medium|| +|[0521](https://leetcode.com/problems/longest-uncommon-subsequence-i/)|[Longest Uncommon Subsequence I](./Algorithms/0521.longest-uncommon-subsequence-i)|56%|Easy|| +|[0520](https://leetcode.com/problems/detect-capital/)|[Detect Capital](./Algorithms/0520.detect-capital)|52%|Easy|| +|[0519](https://leetcode.com/problems/random-flip-matrix/)|[Random Flip Matrix](./Algorithms/0519.random-flip-matrix)|34%|Medium|| +|[0518](https://leetcode.com/problems/coin-change-2/)|[Coin Change 2](./Algorithms/0518.coin-change-2)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0517](https://leetcode.com/problems/super-washing-machines/)|[Super Washing Machines](./Algorithms/0517.super-washing-machines)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0516](https://leetcode.com/problems/longest-palindromic-subsequence/)|[Longest Palindromic Subsequence](./Algorithms/0516.longest-palindromic-subsequence)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0515](https://leetcode.com/problems/find-largest-value-in-each-tree-row/)|[Find Largest Value in Each Tree Row](./Algorithms/0515.find-largest-value-in-each-tree-row)|58%|Medium|| +|[0514](https://leetcode.com/problems/freedom-trail/)|[Freedom Trail](./Algorithms/0514.freedom-trail)|41%|Hard|| +|[0513](https://leetcode.com/problems/find-bottom-left-tree-value/)|[Find Bottom Left Tree Value](./Algorithms/0513.find-bottom-left-tree-value)|59%|Medium|| +|[0509](https://leetcode.com/problems/fibonacci-number/)|[Fibonacci Number](./Algorithms/0509.fibonacci-number)|66%|Easy|| +|[0508](https://leetcode.com/problems/most-frequent-subtree-sum/)|[Most Frequent Subtree Sum](./Algorithms/0508.most-frequent-subtree-sum)|55%|Medium|| +|[0507](https://leetcode.com/problems/perfect-number/)|[Perfect Number](./Algorithms/0507.perfect-number)|35%|Easy|| +|[0506](https://leetcode.com/problems/relative-ranks/)|[Relative Ranks](./Algorithms/0506.relative-ranks)|49%|Easy|| +|[0504](https://leetcode.com/problems/base-7/)|[Base 7](./Algorithms/0504.base-7)|45%|Easy|| +|[0503](https://leetcode.com/problems/next-greater-element-ii/)|[Next Greater Element II](./Algorithms/0503.next-greater-element-ii)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0502](https://leetcode.com/problems/ipo/)|[IPO](./Algorithms/0502.ipo)|38%|Hard|| +|[0501](https://leetcode.com/problems/find-mode-in-binary-search-tree/)|[Find Mode in Binary Search Tree](./Algorithms/0501.find-mode-in-binary-search-tree)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0500](https://leetcode.com/problems/keyboard-row/)|[Keyboard Row](./Algorithms/0500.keyboard-row)|63%|Easy|| +|[0498](https://leetcode.com/problems/diagonal-traverse/)|[Diagonal Traverse](./Algorithms/0498.diagonal-traverse)|46%|Medium|| +|[0497](https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/)|[Random Point in Non-overlapping Rectangles](./Algorithms/0497.random-point-in-non-overlapping-rectangles)|36%|Medium|| +|[0496](https://leetcode.com/problems/next-greater-element-i/)|[Next Greater Element I](./Algorithms/0496.next-greater-element-i)|61%|Easy|| +|[0495](https://leetcode.com/problems/teemo-attacking/)|[Teemo Attacking](./Algorithms/0495.teemo-attacking)|52%|Medium|| +|[0494](https://leetcode.com/problems/target-sum/)|[Target Sum](./Algorithms/0494.target-sum)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0493](https://leetcode.com/problems/reverse-pairs/)|[Reverse Pairs](./Algorithms/0493.reverse-pairs)|23%|Hard|| +|[0492](https://leetcode.com/problems/construct-the-rectangle/)|[Construct the Rectangle](./Algorithms/0492.construct-the-rectangle)|48%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0491](https://leetcode.com/problems/increasing-subsequences/)|[Increasing Subsequences](./Algorithms/0491.increasing-subsequences)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0488](https://leetcode.com/problems/zuma-game/)|[Zuma Game](./Algorithms/0488.zuma-game)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0486](https://leetcode.com/problems/predict-the-winner/)|[Predict the Winner](./Algorithms/0486.predict-the-winner)|47%|Medium|| +|[0485](https://leetcode.com/problems/max-consecutive-ones/)|[Max Consecutive Ones](./Algorithms/0485.max-consecutive-ones)|55%|Easy|| +|[0483](https://leetcode.com/problems/smallest-good-base/)|[Smallest Good Base](./Algorithms/0483.smallest-good-base)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0482](https://leetcode.com/problems/license-key-formatting/)|[License Key Formatting](./Algorithms/0482.license-key-formatting)|41%|Easy|| +|[0481](https://leetcode.com/problems/magical-string/)|[Magical String](./Algorithms/0481.magical-string)|46%|Medium|| +|[0480](https://leetcode.com/problems/sliding-window-median/)|[Sliding Window Median](./Algorithms/0480.sliding-window-median)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0479](https://leetcode.com/problems/largest-palindrome-product/)|[Largest Palindrome Product](./Algorithms/0479.largest-palindrome-product)|27%|Hard|| +|[0478](https://leetcode.com/problems/generate-random-point-in-a-circle/)|[Generate Random Point in a Circle](./Algorithms/0478.generate-random-point-in-a-circle)|37%|Medium|| +|[0477](https://leetcode.com/problems/total-hamming-distance/)|[Total Hamming Distance](./Algorithms/0477.total-hamming-distance)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0476](https://leetcode.com/problems/number-complement/)|[Number Complement](./Algorithms/0476.number-complement)|62%|Easy|| +|[0475](https://leetcode.com/problems/heaters/)|[Heaters](./Algorithms/0475.heaters)|32%|Easy|| +|[0474](https://leetcode.com/problems/ones-and-zeroes/)|[Ones and Zeroes](./Algorithms/0474.ones-and-zeroes)|40%|Medium|| +|[0473](https://leetcode.com/problems/matchsticks-to-square/)|[Matchsticks to Square](./Algorithms/0473.matchsticks-to-square)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0472](https://leetcode.com/problems/concatenated-words/)|[Concatenated Words](./Algorithms/0472.concatenated-words)|37%|Hard|| +|[0470](https://leetcode.com/problems/implement-rand10-using-rand7/)|[Implement Rand10() Using Rand7()](./Algorithms/0470.implement-rand10-using-rand7)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0468](https://leetcode.com/problems/validate-ip-address/)|[Validate IP Address](./Algorithms/0468.validate-ip-address)|21%|Medium|| +|[0467](https://leetcode.com/problems/unique-substrings-in-wraparound-string/)|[Unique Substrings in Wraparound String](./Algorithms/0467.unique-substrings-in-wraparound-string)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0466](https://leetcode.com/problems/count-the-repetitions/)|[Count The Repetitions](./Algorithms/0466.count-the-repetitions)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0464](https://leetcode.com/problems/can-i-win/)|[Can I Win](./Algorithms/0464.can-i-win)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0463](https://leetcode.com/problems/island-perimeter/)|[Island Perimeter](./Algorithms/0463.island-perimeter)|62%|Easy|| +|[0462](https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/)|[Minimum Moves to Equal Array Elements II](./Algorithms/0462.minimum-moves-to-equal-array-elements-ii)|52%|Medium|| +|[0461](https://leetcode.com/problems/hamming-distance/)|[Hamming Distance](./Algorithms/0461.hamming-distance)|70%|Easy|| +|[0460](https://leetcode.com/problems/lfu-cache/)|[LFU Cache](./Algorithms/0460.lfu-cache)|30%|Hard|| +|[0459](https://leetcode.com/problems/repeated-substring-pattern/)|[Repeated Substring Pattern](./Algorithms/0459.repeated-substring-pattern)|40%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0458](https://leetcode.com/problems/poor-pigs/)|[Poor Pigs](./Algorithms/0458.poor-pigs)|46%|Hard|| +|[0457](https://leetcode.com/problems/circular-array-loop/)|[Circular Array Loop](./Algorithms/0457.circular-array-loop)|28%|Medium|| +|[0456](https://leetcode.com/problems/132-pattern/)|[132 Pattern](./Algorithms/0456.132-pattern)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0455](https://leetcode.com/problems/assign-cookies/)|[Assign Cookies](./Algorithms/0455.assign-cookies)|48%|Easy|| +|[0454](https://leetcode.com/problems/4sum-ii/)|[4Sum II](./Algorithms/0454.4sum-ii)|51%|Medium|| +|[0453](https://leetcode.com/problems/minimum-moves-to-equal-array-elements/)|[Minimum Moves to Equal Array Elements](./Algorithms/0453.minimum-moves-to-equal-array-elements)|49%|Easy|| +|[0452](https://leetcode.com/problems/minimum-number-of-arrows-to-burst-balloons/)|[Minimum Number of Arrows to Burst Balloons](./Algorithms/0452.minimum-number-of-arrows-to-burst-balloons)|47%|Medium|| +|[0451](https://leetcode.com/problems/sort-characters-by-frequency/)|[Sort Characters By Frequency](./Algorithms/0451.sort-characters-by-frequency)|57%|Medium|| +|[0450](https://leetcode.com/problems/delete-node-in-a-bst/)|[Delete Node in a BST](./Algorithms/0450.delete-node-in-a-bst)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0448](https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/)|[Find All Numbers Disappeared in an Array](./Algorithms/0448.find-all-numbers-disappeared-in-an-array)|54%|Easy|| +|[0447](https://leetcode.com/problems/number-of-boomerangs/)|[Number of Boomerangs](./Algorithms/0447.number-of-boomerangs)|50%|Easy|| +|[0446](https://leetcode.com/problems/arithmetic-slices-ii-subsequence/)|[Arithmetic Slices II - Subsequence](./Algorithms/0446.arithmetic-slices-ii-subsequence)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0445](https://leetcode.com/problems/add-two-numbers-ii/)|[Add Two Numbers II](./Algorithms/0445.add-two-numbers-ii)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0443](https://leetcode.com/problems/string-compression/)|[String Compression](./Algorithms/0443.string-compression)|38%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0442](https://leetcode.com/problems/find-all-duplicates-in-an-array/)|[Find All Duplicates in an Array](./Algorithms/0442.find-all-duplicates-in-an-array)|62%|Medium|| +|[0441](https://leetcode.com/problems/arranging-coins/)|[Arranging Coins](./Algorithms/0441.arranging-coins)|38%|Easy|| +|[0440](https://leetcode.com/problems/k-th-smallest-in-lexicographical-order/)|[K-th Smallest in Lexicographical Order](./Algorithms/0440.k-th-smallest-in-lexicographical-order)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0438](https://leetcode.com/problems/find-all-anagrams-in-a-string/)|[Find All Anagrams in a String](./Algorithms/0438.find-all-anagrams-in-a-string)|39%|Medium|| +|[0437](https://leetcode.com/problems/path-sum-iii/)|[Path Sum III](./Algorithms/0437.path-sum-iii)|44%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0436](https://leetcode.com/problems/find-right-interval/)|[Find Right Interval](./Algorithms/0436.find-right-interval)|43%|Medium|| +|[0435](https://leetcode.com/problems/non-overlapping-intervals/)|[Non-overlapping Intervals](./Algorithms/0435.non-overlapping-intervals)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0434](https://leetcode.com/problems/number-of-segments-in-a-string/)|[Number of Segments in a String](./Algorithms/0434.number-of-segments-in-a-string)|37%|Easy|| +|[0433](https://leetcode.com/problems/minimum-genetic-mutation/)|[Minimum Genetic Mutation](./Algorithms/0433.minimum-genetic-mutation)|39%|Medium|| +|[0432](https://leetcode.com/problems/all-oone-data-structure/)|[All O`one Data Structure](./Algorithms/0432.all-oone-data-structure)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0424](https://leetcode.com/problems/longest-repeating-character-replacement/)|[Longest Repeating Character Replacement](./Algorithms/0424.longest-repeating-character-replacement)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0423](https://leetcode.com/problems/reconstruct-original-digits-from-english/)|[Reconstruct Original Digits from English](./Algorithms/0423.reconstruct-original-digits-from-english)|46%|Medium|| +|[0421](https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/)|[Maximum XOR of Two Numbers in an Array](./Algorithms/0421.maximum-xor-of-two-numbers-in-an-array)|52%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0420](https://leetcode.com/problems/strong-password-checker/)|[Strong Password Checker](./Algorithms/0420.strong-password-checker)|16%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0419](https://leetcode.com/problems/battleships-in-a-board/)|[Battleships in a Board](./Algorithms/0419.battleships-in-a-board)|66%|Medium|| +|[0417](https://leetcode.com/problems/pacific-atlantic-water-flow/)|[Pacific Atlantic Water Flow](./Algorithms/0417.pacific-atlantic-water-flow)|38%|Medium|| +|[0416](https://leetcode.com/problems/partition-equal-subset-sum/)|[Partition Equal Subset Sum](./Algorithms/0416.partition-equal-subset-sum)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0415](https://leetcode.com/problems/add-strings/)|[Add Strings](./Algorithms/0415.add-strings)|45%|Easy|| +|[0414](https://leetcode.com/problems/third-maximum-number/)|[Third Maximum Number](./Algorithms/0414.third-maximum-number)|29%|Easy|| +|[0413](https://leetcode.com/problems/arithmetic-slices/)|[Arithmetic Slices](./Algorithms/0413.arithmetic-slices)|56%|Medium|| +|[0412](https://leetcode.com/problems/fizz-buzz/)|[Fizz Buzz](./Algorithms/0412.fizz-buzz)|60%|Easy|| +|[0410](https://leetcode.com/problems/split-array-largest-sum/)|[Split Array Largest Sum](./Algorithms/0410.split-array-largest-sum)|43%|Hard|| +|[0409](https://leetcode.com/problems/longest-palindrome/)|[Longest Palindrome](./Algorithms/0409.longest-palindrome)|48%|Easy|| +|[0407](https://leetcode.com/problems/trapping-rain-water-ii/)|[Trapping Rain Water II](./Algorithms/0407.trapping-rain-water-ii)|40%|Hard|| +|[0406](https://leetcode.com/problems/queue-reconstruction-by-height/)|[Queue Reconstruction by Height](./Algorithms/0406.queue-reconstruction-by-height)|61%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0405](https://leetcode.com/problems/convert-a-number-to-hexadecimal/)|[Convert a Number to Hexadecimal](./Algorithms/0405.convert-a-number-to-hexadecimal)|42%|Easy|| +|[0404](https://leetcode.com/problems/sum-of-left-leaves/)|[Sum of Left Leaves](./Algorithms/0404.sum-of-left-leaves)|49%|Easy|| +|[0403](https://leetcode.com/problems/frog-jump/)|[Frog Jump](./Algorithms/0403.frog-jump)|37%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0402](https://leetcode.com/problems/remove-k-digits/)|[Remove K Digits](./Algorithms/0402.remove-k-digits)|27%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0401](https://leetcode.com/problems/binary-watch/)|[Binary Watch](./Algorithms/0401.binary-watch)|45%|Easy|| +|[0400](https://leetcode.com/problems/nth-digit/)|[Nth Digit](./Algorithms/0400.nth-digit)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0399](https://leetcode.com/problems/evaluate-division/)|[Evaluate Division](./Algorithms/0399.evaluate-division)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0398](https://leetcode.com/problems/random-pick-index/)|[Random Pick Index](./Algorithms/0398.random-pick-index)|51%|Medium|| +|[0397](https://leetcode.com/problems/integer-replacement/)|[Integer Replacement](./Algorithms/0397.integer-replacement)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0396](https://leetcode.com/problems/rotate-function/)|[Rotate Function](./Algorithms/0396.rotate-function)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0395](https://leetcode.com/problems/longest-substring-with-at-least-k-repeating-characters/)|[Longest Substring with At Least K Repeating Characters](./Algorithms/0395.longest-substring-with-at-least-k-repeating-characters)|39%|Medium|| +|[0394](https://leetcode.com/problems/decode-string/)|[Decode String](./Algorithms/0394.decode-string)|47%|Medium|| +|[0393](https://leetcode.com/problems/utf-8-validation/)|[UTF-8 Validation](./Algorithms/0393.utf-8-validation)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0392](https://leetcode.com/problems/is-subsequence/)|[Is Subsequence](./Algorithms/0392.is-subsequence)|47%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0391](https://leetcode.com/problems/perfect-rectangle/)|[Perfect Rectangle](./Algorithms/0391.perfect-rectangle)|28%|Hard|| +|[0390](https://leetcode.com/problems/elimination-game/)|[Elimination Game](./Algorithms/0390.elimination-game)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0389](https://leetcode.com/problems/find-the-difference/)|[Find the Difference](./Algorithms/0389.find-the-difference)|53%|Easy|| +|[0388](https://leetcode.com/problems/longest-absolute-file-path/)|[Longest Absolute File Path](./Algorithms/0388.longest-absolute-file-path)|40%|Medium|| +|[0387](https://leetcode.com/problems/first-unique-character-in-a-string/)|[First Unique Character in a String](./Algorithms/0387.first-unique-character-in-a-string)|50%|Easy|| +|[0386](https://leetcode.com/problems/lexicographical-numbers/)|[Lexicographical Numbers](./Algorithms/0386.lexicographical-numbers)|48%|Medium|| +|[0385](https://leetcode.com/problems/mini-parser/)|[Mini Parser](./Algorithms/0385.mini-parser)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0384](https://leetcode.com/problems/shuffle-an-array/)|[Shuffle an Array](./Algorithms/0384.shuffle-an-array)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0383](https://leetcode.com/problems/ransom-note/)|[Ransom Note](./Algorithms/0383.ransom-note)|50%|Easy|| +|[0382](https://leetcode.com/problems/linked-list-random-node/)|[Linked List Random Node](./Algorithms/0382.linked-list-random-node)|50%|Medium|| +|[0381](https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/)|[Insert Delete GetRandom O(1) - Duplicates allowed](./Algorithms/0381.insert-delete-getrandom-o1-duplicates-allowed)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0380](https://leetcode.com/problems/insert-delete-getrandom-o1/)|[Insert Delete GetRandom O(1)](./Algorithms/0380.insert-delete-getrandom-o1)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0378](https://leetcode.com/problems/kth-smallest-element-in-a-sorted-matrix/)|[Kth Smallest Element in a Sorted Matrix](./Algorithms/0378.kth-smallest-element-in-a-sorted-matrix)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0377](https://leetcode.com/problems/combination-sum-iv/)|[Combination Sum IV](./Algorithms/0377.combination-sum-iv)|44%|Medium|| +|[0376](https://leetcode.com/problems/wiggle-subsequence/)|[Wiggle Subsequence](./Algorithms/0376.wiggle-subsequence)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0375](https://leetcode.com/problems/guess-number-higher-or-lower-ii/)|[Guess Number Higher or Lower II](./Algorithms/0375.guess-number-higher-or-lower-ii)|38%|Medium|| +|[0373](https://leetcode.com/problems/find-k-pairs-with-smallest-sums/)|[Find K Pairs with Smallest Sums](./Algorithms/0373.find-k-pairs-with-smallest-sums)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0372](https://leetcode.com/problems/super-pow/)|[Super Pow](./Algorithms/0372.super-pow)|36%|Medium|| +|[0371](https://leetcode.com/problems/sum-of-two-integers/)|[Sum of Two Integers](./Algorithms/0371.sum-of-two-integers)|50%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0368](https://leetcode.com/problems/largest-divisible-subset/)|[Largest Divisible Subset](./Algorithms/0368.largest-divisible-subset)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0367](https://leetcode.com/problems/valid-perfect-square/)|[Valid Perfect Square](./Algorithms/0367.valid-perfect-square)|40%|Easy|| +|[0365](https://leetcode.com/problems/water-and-jug-problem/)|[Water and Jug Problem](./Algorithms/0365.water-and-jug-problem)|29%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0363](https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k/)|[Max Sum of Rectangle No Larger Than K](./Algorithms/0363.max-sum-of-rectangle-no-larger-than-k)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0357](https://leetcode.com/problems/count-numbers-with-unique-digits/)|[Count Numbers with Unique Digits](./Algorithms/0357.count-numbers-with-unique-digits)|47%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0355](https://leetcode.com/problems/design-twitter/)|[Design Twitter](./Algorithms/0355.design-twitter)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0354](https://leetcode.com/problems/russian-doll-envelopes/)|[Russian Doll Envelopes](./Algorithms/0354.russian-doll-envelopes)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0352](https://leetcode.com/problems/data-stream-as-disjoint-intervals/)|[Data Stream as Disjoint Intervals](./Algorithms/0352.data-stream-as-disjoint-intervals)|44%|Hard|| +|[0350](https://leetcode.com/problems/intersection-of-two-arrays-ii/)|[Intersection of Two Arrays II](./Algorithms/0350.intersection-of-two-arrays-ii)|49%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0349](https://leetcode.com/problems/intersection-of-two-arrays/)|[Intersection of Two Arrays](./Algorithms/0349.intersection-of-two-arrays)|57%|Easy|| +|[0347](https://leetcode.com/problems/top-k-frequent-elements/)|[Top K Frequent Elements](./Algorithms/0347.top-k-frequent-elements)|57%|Medium|| +|[0345](https://leetcode.com/problems/reverse-vowels-of-a-string/)|[Reverse Vowels of a String](./Algorithms/0345.reverse-vowels-of-a-string)|42%|Easy|| +|[0344](https://leetcode.com/problems/reverse-string/)|[Reverse String](./Algorithms/0344.reverse-string)|64%|Easy|| +|[0343](https://leetcode.com/problems/integer-break/)|[Integer Break](./Algorithms/0343.integer-break)|48%|Medium|| +|[0342](https://leetcode.com/problems/power-of-four/)|[Power of Four](./Algorithms/0342.power-of-four)|40%|Easy|| +|[0338](https://leetcode.com/problems/counting-bits/)|[Counting Bits](./Algorithms/0338.counting-bits)|65%|Medium|| +|[0337](https://leetcode.com/problems/house-robber-iii/)|[House Robber III](./Algorithms/0337.house-robber-iii)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0336](https://leetcode.com/problems/palindrome-pairs/)|[Palindrome Pairs](./Algorithms/0336.palindrome-pairs)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0335](https://leetcode.com/problems/self-crossing/)|[Self Crossing](./Algorithms/0335.self-crossing)|27%|Hard|| +|[0334](https://leetcode.com/problems/increasing-triplet-subsequence/)|[Increasing Triplet Subsequence](./Algorithms/0334.increasing-triplet-subsequence)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0332](https://leetcode.com/problems/reconstruct-itinerary/)|[Reconstruct Itinerary](./Algorithms/0332.reconstruct-itinerary)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0331](https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/)|[Verify Preorder Serialization of a Binary Tree](./Algorithms/0331.verify-preorder-serialization-of-a-binary-tree)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0330](https://leetcode.com/problems/patching-array/)|[Patching Array](./Algorithms/0330.patching-array)|33%|Hard|| +|[0329](https://leetcode.com/problems/longest-increasing-path-in-a-matrix/)|[Longest Increasing Path in a Matrix](./Algorithms/0329.longest-increasing-path-in-a-matrix)|41%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0328](https://leetcode.com/problems/odd-even-linked-list/)|[Odd Even Linked List](./Algorithms/0328.odd-even-linked-list)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0327](https://leetcode.com/problems/count-of-range-sum/)|[Count of Range Sum](./Algorithms/0327.count-of-range-sum)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0326](https://leetcode.com/problems/power-of-three/)|[Power of Three](./Algorithms/0326.power-of-three)|41%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0324](https://leetcode.com/problems/wiggle-sort-ii/)|[Wiggle Sort II](./Algorithms/0324.wiggle-sort-ii)|28%|Medium|| +|[0322](https://leetcode.com/problems/coin-change/)|[Coin Change](./Algorithms/0322.coin-change)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0321](https://leetcode.com/problems/create-maximum-number/)|[Create Maximum Number](./Algorithms/0321.create-maximum-number)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0319](https://leetcode.com/problems/bulb-switcher/)|[Bulb Switcher](./Algorithms/0319.bulb-switcher)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0318](https://leetcode.com/problems/maximum-product-of-word-lengths/)|[Maximum Product of Word Lengths](./Algorithms/0318.maximum-product-of-word-lengths)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0316](https://leetcode.com/problems/remove-duplicate-letters/)|[Remove Duplicate Letters](./Algorithms/0316.remove-duplicate-letters)|33%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0315](https://leetcode.com/problems/count-of-smaller-numbers-after-self/)|[Count of Smaller Numbers After Self](./Algorithms/0315.count-of-smaller-numbers-after-self)|39%|Hard|| +|[0313](https://leetcode.com/problems/super-ugly-number/)|[Super Ugly Number](./Algorithms/0313.super-ugly-number)|42%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0312](https://leetcode.com/problems/burst-balloons/)|[Burst Balloons](./Algorithms/0312.burst-balloons)|48%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0310](https://leetcode.com/problems/minimum-height-trees/)|[Minimum Height Trees](./Algorithms/0310.minimum-height-trees)|31%|Medium|| +|[0309](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/)|[Best Time to Buy and Sell Stock with Cooldown](./Algorithms/0309.best-time-to-buy-and-sell-stock-with-cooldown)|45%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0307](https://leetcode.com/problems/range-sum-query-mutable/)|[Range Sum Query - Mutable](./Algorithms/0307.range-sum-query-mutable)|30%|Medium|| +|[0306](https://leetcode.com/problems/additive-number/)|[Additive Number](./Algorithms/0306.additive-number)|28%|Medium|| +|[0304](https://leetcode.com/problems/range-sum-query-2d-immutable/)|[Range Sum Query 2D - Immutable](./Algorithms/0304.range-sum-query-2d-immutable)|34%|Medium|| +|[0303](https://leetcode.com/problems/range-sum-query-immutable/)|[Range Sum Query - Immutable](./Algorithms/0303.range-sum-query-immutable)|40%|Easy|| +|[0301](https://leetcode.com/problems/remove-invalid-parentheses/)|[Remove Invalid Parentheses](./Algorithms/0301.remove-invalid-parentheses)|40%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0300](https://leetcode.com/problems/longest-increasing-subsequence/)|[Longest Increasing Subsequence](./Algorithms/0300.longest-increasing-subsequence)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0299](https://leetcode.com/problems/bulls-and-cows/)|[Bulls and Cows](./Algorithms/0299.bulls-and-cows)|40%|Easy|| +|[0295](https://leetcode.com/problems/find-median-from-data-stream/)|[Find Median from Data Stream](./Algorithms/0295.find-median-from-data-stream)|39%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0292](https://leetcode.com/problems/nim-game/)|[Nim Game](./Algorithms/0292.nim-game)|55%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0290](https://leetcode.com/problems/word-pattern/)|[Word Pattern](./Algorithms/0290.word-pattern)|35%|Easy|| +|[0289](https://leetcode.com/problems/game-of-life/)|[Game of Life](./Algorithms/0289.game-of-life)|49%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0287](https://leetcode.com/problems/find-the-duplicate-number/)|[Find the Duplicate Number](./Algorithms/0287.find-the-duplicate-number)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0283](https://leetcode.com/problems/move-zeroes/)|[Move Zeroes](./Algorithms/0283.move-zeroes)|55%|Easy|| +|[0282](https://leetcode.com/problems/expression-add-operators/)|[Expression Add Operators](./Algorithms/0282.expression-add-operators)|34%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0279](https://leetcode.com/problems/perfect-squares/)|[Perfect Squares](./Algorithms/0279.perfect-squares)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0275](https://leetcode.com/problems/h-index-ii/)|[H-Index II](./Algorithms/0275.h-index-ii)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0274](https://leetcode.com/problems/h-index/)|[H-Index](./Algorithms/0274.h-index)|34%|Medium|| +|[0273](https://leetcode.com/problems/integer-to-english-words/)|[Integer to English Words](./Algorithms/0273.integer-to-english-words)|25%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0268](https://leetcode.com/problems/missing-number/)|[Missing Number](./Algorithms/0268.missing-number)|49%|Easy|| +|[0264](https://leetcode.com/problems/ugly-number-ii/)|[Ugly Number II](./Algorithms/0264.ugly-number-ii)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0263](https://leetcode.com/problems/ugly-number/)|[Ugly Number](./Algorithms/0263.ugly-number)|41%|Easy|| +|[0260](https://leetcode.com/problems/single-number-iii/)|[Single Number III](./Algorithms/0260.single-number-iii)|58%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0258](https://leetcode.com/problems/add-digits/)|[Add Digits](./Algorithms/0258.add-digits)|55%|Easy|| +|[0257](https://leetcode.com/problems/binary-tree-paths/)|[Binary Tree Paths](./Algorithms/0257.binary-tree-paths)|47%|Easy|| +|[0242](https://leetcode.com/problems/valid-anagram/)|[Valid Anagram](./Algorithms/0242.valid-anagram)|54%|Easy|| +|[0241](https://leetcode.com/problems/different-ways-to-add-parentheses/)|[Different Ways to Add Parentheses](./Algorithms/0241.different-ways-to-add-parentheses)|52%|Medium|| +|[0240](https://leetcode.com/problems/search-a-2d-matrix-ii/)|[Search a 2D Matrix II](./Algorithms/0240.search-a-2d-matrix-ii)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0239](https://leetcode.com/problems/sliding-window-maximum/)|[Sliding Window Maximum](./Algorithms/0239.sliding-window-maximum)|39%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0238](https://leetcode.com/problems/product-of-array-except-self/)|[Product of Array Except Self](./Algorithms/0238.product-of-array-except-self)|57%|Medium|| +|[0237](https://leetcode.com/problems/delete-node-in-a-linked-list/)|[Delete Node in a Linked List](./Algorithms/0237.delete-node-in-a-linked-list)|56%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0236](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/)|[Lowest Common Ancestor of a Binary Tree](./Algorithms/0236.lowest-common-ancestor-of-a-binary-tree)|40%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0235](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/)|[Lowest Common Ancestor of a Binary Search Tree](./Algorithms/0235.lowest-common-ancestor-of-a-binary-search-tree)|46%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0234](https://leetcode.com/problems/palindrome-linked-list/)|[Palindrome Linked List](./Algorithms/0234.palindrome-linked-list)|37%|Easy|| +|[0233](https://leetcode.com/problems/number-of-digit-one/)|[Number of Digit One](./Algorithms/0233.number-of-digit-one)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0232](https://leetcode.com/problems/implement-queue-using-stacks/)|[Implement Queue using Stacks](./Algorithms/0232.implement-queue-using-stacks)|45%|Easy|| +|[0231](https://leetcode.com/problems/power-of-two/)|[Power of Two](./Algorithms/0231.power-of-two)|42%|Easy|| +|[0230](https://leetcode.com/problems/kth-smallest-element-in-a-bst/)|[Kth Smallest Element in a BST](./Algorithms/0230.kth-smallest-element-in-a-bst)|54%|Medium|| +|[0229](https://leetcode.com/problems/majority-element-ii/)|[Majority Element II](./Algorithms/0229.majority-element-ii)|33%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0228](https://leetcode.com/problems/summary-ranges/)|[Summary Ranges](./Algorithms/0228.summary-ranges)|37%|Medium|| +|[0227](https://leetcode.com/problems/basic-calculator-ii/)|[Basic Calculator II](./Algorithms/0227.basic-calculator-ii)|34%|Medium|| +|[0226](https://leetcode.com/problems/invert-binary-tree/)|[Invert Binary Tree](./Algorithms/0226.invert-binary-tree)|60%|Easy|| +|[0225](https://leetcode.com/problems/implement-stack-using-queues/)|[Implement Stack using Queues](./Algorithms/0225.implement-stack-using-queues)|41%|Easy|| +|[0224](https://leetcode.com/problems/basic-calculator/)|[Basic Calculator](./Algorithms/0224.basic-calculator)|34%|Hard|| +|[0223](https://leetcode.com/problems/rectangle-area/)|[Rectangle Area](./Algorithms/0223.rectangle-area)|36%|Medium|| +|[0222](https://leetcode.com/problems/count-complete-tree-nodes/)|[Count Complete Tree Nodes](./Algorithms/0222.count-complete-tree-nodes)|38%|Medium|| +|[0221](https://leetcode.com/problems/maximal-square/)|[Maximal Square](./Algorithms/0221.maximal-square)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0220](https://leetcode.com/problems/contains-duplicate-iii/)|[Contains Duplicate III](./Algorithms/0220.contains-duplicate-iii)|20%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0219](https://leetcode.com/problems/contains-duplicate-ii/)|[Contains Duplicate II](./Algorithms/0219.contains-duplicate-ii)|36%|Easy|| +|[0218](https://leetcode.com/problems/the-skyline-problem/)|[The Skyline Problem](./Algorithms/0218.the-skyline-problem)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0217](https://leetcode.com/problems/contains-duplicate/)|[Contains Duplicate](./Algorithms/0217.contains-duplicate)|53%|Easy|| +|[0216](https://leetcode.com/problems/combination-sum-iii/)|[Combination Sum III](./Algorithms/0216.combination-sum-iii)|53%|Medium|| +|[0215](https://leetcode.com/problems/kth-largest-element-in-an-array/)|[Kth Largest Element in an Array](./Algorithms/0215.kth-largest-element-in-an-array)|50%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0214](https://leetcode.com/problems/shortest-palindrome/)|[Shortest Palindrome](./Algorithms/0214.shortest-palindrome)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0213](https://leetcode.com/problems/house-robber-ii/)|[House Robber II](./Algorithms/0213.house-robber-ii)|35%|Medium|| +|[0212](https://leetcode.com/problems/word-search-ii/)|[Word Search II](./Algorithms/0212.word-search-ii)|30%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0211](https://leetcode.com/problems/add-and-search-word-data-structure-design/)|[Add and Search Word - Data structure design](./Algorithms/0211.add-and-search-word-data-structure-design)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0210](https://leetcode.com/problems/course-schedule-ii/)|[Course Schedule II](./Algorithms/0210.course-schedule-ii)|36%|Medium|| +|[0209](https://leetcode.com/problems/minimum-size-subarray-sum/)|[Minimum Size Subarray Sum](./Algorithms/0209.minimum-size-subarray-sum)|35%|Medium|| +|[0208](https://leetcode.com/problems/implement-trie-prefix-tree/)|[Implement Trie (Prefix Tree)](./Algorithms/0208.implement-trie-prefix-tree)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0207](https://leetcode.com/problems/course-schedule/)|[Course Schedule](./Algorithms/0207.course-schedule)|39%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0206](https://leetcode.com/problems/reverse-linked-list/)|[Reverse Linked List](./Algorithms/0206.reverse-linked-list)|57%|Easy|| +|[0205](https://leetcode.com/problems/isomorphic-strings/)|[Isomorphic Strings](./Algorithms/0205.isomorphic-strings)|38%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0204](https://leetcode.com/problems/count-primes/)|[Count Primes](./Algorithms/0204.count-primes)|30%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0203](https://leetcode.com/problems/remove-linked-list-elements/)|[Remove Linked List Elements](./Algorithms/0203.remove-linked-list-elements)|36%|Easy|| +|[0202](https://leetcode.com/problems/happy-number/)|[Happy Number](./Algorithms/0202.happy-number)|47%|Easy|| +|[0201](https://leetcode.com/problems/bitwise-and-of-numbers-range/)|[Bitwise AND of Numbers Range](./Algorithms/0201.bitwise-and-of-numbers-range)|36%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0200](https://leetcode.com/problems/number-of-islands/)|[Number of Islands](./Algorithms/0200.number-of-islands)|43%|Medium|| +|[0199](https://leetcode.com/problems/binary-tree-right-side-view/)|[Binary Tree Right Side View](./Algorithms/0199.binary-tree-right-side-view)|50%|Medium|| +|[0198](https://leetcode.com/problems/house-robber/)|[House Robber](./Algorithms/0198.house-robber)|41%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0191](https://leetcode.com/problems/number-of-1-bits/)|[Number of 1 Bits](./Algorithms/0191.number-of-1-bits)|45%|Easy|| +|[0190](https://leetcode.com/problems/reverse-bits/)|[Reverse Bits](./Algorithms/0190.reverse-bits)|33%|Easy|| +|[0189](https://leetcode.com/problems/rotate-array/)|[Rotate Array](./Algorithms/0189.rotate-array)|31%|Easy|| +|[0188](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/)|[Best Time to Buy and Sell Stock IV](./Algorithms/0188.best-time-to-buy-and-sell-stock-iv)|27%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0187](https://leetcode.com/problems/repeated-dna-sequences/)|[Repeated DNA Sequences](./Algorithms/0187.repeated-dna-sequences)|37%|Medium|| +|[0179](https://leetcode.com/problems/largest-number/)|[Largest Number](./Algorithms/0179.largest-number)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0174](https://leetcode.com/problems/dungeon-game/)|[Dungeon Game](./Algorithms/0174.dungeon-game)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0173](https://leetcode.com/problems/binary-search-tree-iterator/)|[Binary Search Tree Iterator](./Algorithms/0173.binary-search-tree-iterator)|51%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0172](https://leetcode.com/problems/factorial-trailing-zeroes/)|[Factorial Trailing Zeroes](./Algorithms/0172.factorial-trailing-zeroes)|37%|Easy|| +|[0171](https://leetcode.com/problems/excel-sheet-column-number/)|[Excel Sheet Column Number](./Algorithms/0171.excel-sheet-column-number)|52%|Easy|| +|[0169](https://leetcode.com/problems/majority-element/)|[Majority Element](./Algorithms/0169.majority-element)|54%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0168](https://leetcode.com/problems/excel-sheet-column-title/)|[Excel Sheet Column Title](./Algorithms/0168.excel-sheet-column-title)|29%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0167](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/)|[Two Sum II - Input array is sorted](./Algorithms/0167.two-sum-ii-input-array-is-sorted)|51%|Easy|| +|[0166](https://leetcode.com/problems/fraction-to-recurring-decimal/)|[Fraction to Recurring Decimal](./Algorithms/0166.fraction-to-recurring-decimal)|20%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0165](https://leetcode.com/problems/compare-version-numbers/)|[Compare Version Numbers](./Algorithms/0165.compare-version-numbers)|25%|Medium|| +|[0164](https://leetcode.com/problems/maximum-gap/)|[Maximum Gap](./Algorithms/0164.maximum-gap)|33%|Hard|| +|[0162](https://leetcode.com/problems/find-peak-element/)|[Find Peak Element](./Algorithms/0162.find-peak-element)|42%|Medium|| +|[0160](https://leetcode.com/problems/intersection-of-two-linked-lists/)|[Intersection of Two Linked Lists](./Algorithms/0160.intersection-of-two-linked-lists)|36%|Easy|| +|[0155](https://leetcode.com/problems/min-stack/)|[Min Stack](./Algorithms/0155.min-stack)|39%|Easy|| +|[0154](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/)|[Find Minimum in Rotated Sorted Array II](./Algorithms/0154.find-minimum-in-rotated-sorted-array-ii)|39%|Hard|| +|[0153](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/)|[Find Minimum in Rotated Sorted Array](./Algorithms/0153.find-minimum-in-rotated-sorted-array)|43%|Medium|| +|[0152](https://leetcode.com/problems/maximum-product-subarray/)|[Maximum Product Subarray](./Algorithms/0152.maximum-product-subarray)|30%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0150](https://leetcode.com/problems/evaluate-reverse-polish-notation/)|[Evaluate Reverse Polish Notation](./Algorithms/0150.evaluate-reverse-polish-notation)|33%|Medium|| +|[0149](https://leetcode.com/problems/max-points-on-a-line/)|[Max Points on a Line](./Algorithms/0149.max-points-on-a-line)|16%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0148](https://leetcode.com/problems/sort-list/)|[Sort List](./Algorithms/0148.sort-list)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0147](https://leetcode.com/problems/insertion-sort-list/)|[Insertion Sort List](./Algorithms/0147.insertion-sort-list)|38%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0146](https://leetcode.com/problems/lru-cache/)|[LRU Cache](./Algorithms/0146.lru-cache)|28%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0145](https://leetcode.com/problems/binary-tree-postorder-traversal/)|[Binary Tree Postorder Traversal](./Algorithms/0145.binary-tree-postorder-traversal)|50%|Hard|| +|[0144](https://leetcode.com/problems/binary-tree-preorder-traversal/)|[Binary Tree Preorder Traversal](./Algorithms/0144.binary-tree-preorder-traversal)|53%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0143](https://leetcode.com/problems/reorder-list/)|[Reorder List](./Algorithms/0143.reorder-list)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0142](https://leetcode.com/problems/linked-list-cycle-ii/)|[Linked List Cycle II](./Algorithms/0142.linked-list-cycle-ii)|34%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0141](https://leetcode.com/problems/linked-list-cycle/)|[Linked List Cycle](./Algorithms/0141.linked-list-cycle)|38%|Easy|| +|[0140](https://leetcode.com/problems/word-break-ii/)|[Word Break II](./Algorithms/0140.word-break-ii)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0139](https://leetcode.com/problems/word-break/)|[Word Break](./Algorithms/0139.word-break)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0137](https://leetcode.com/problems/single-number-ii/)|[Single Number II](./Algorithms/0137.single-number-ii)|47%|Medium|| +|[0136](https://leetcode.com/problems/single-number/)|[Single Number](./Algorithms/0136.single-number)|61%|Easy|| +|[0135](https://leetcode.com/problems/candy/)|[Candy](./Algorithms/0135.candy)|29%|Hard|| +|[0134](https://leetcode.com/problems/gas-station/)|[Gas Station](./Algorithms/0134.gas-station)|35%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0132](https://leetcode.com/problems/palindrome-partitioning-ii/)|[Palindrome Partitioning II](./Algorithms/0132.palindrome-partitioning-ii)|28%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0131](https://leetcode.com/problems/palindrome-partitioning/)|[Palindrome Partitioning](./Algorithms/0131.palindrome-partitioning)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0130](https://leetcode.com/problems/surrounded-regions/)|[Surrounded Regions](./Algorithms/0130.surrounded-regions)|24%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0129](https://leetcode.com/problems/sum-root-to-leaf-numbers/)|[Sum Root to Leaf Numbers](./Algorithms/0129.sum-root-to-leaf-numbers)|44%|Medium|| +|[0128](https://leetcode.com/problems/longest-consecutive-sequence/)|[Longest Consecutive Sequence](./Algorithms/0128.longest-consecutive-sequence)|43%|Hard|| +|[0127](https://leetcode.com/problems/word-ladder/)|[Word Ladder](./Algorithms/0127.word-ladder)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0126](https://leetcode.com/problems/word-ladder-ii/)|[Word Ladder II](./Algorithms/0126.word-ladder-ii)|19%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0125](https://leetcode.com/problems/valid-palindrome/)|[Valid Palindrome](./Algorithms/0125.valid-palindrome)|32%|Easy|| +|[0124](https://leetcode.com/problems/binary-tree-maximum-path-sum/)|[Binary Tree Maximum Path Sum](./Algorithms/0124.binary-tree-maximum-path-sum)|31%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0123](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/)|[Best Time to Buy and Sell Stock III](./Algorithms/0123.best-time-to-buy-and-sell-stock-iii)|35%|Hard|| +|[0122](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/)|[Best Time to Buy and Sell Stock II](./Algorithms/0122.best-time-to-buy-and-sell-stock-ii)|53%|Easy|| +|[0121](https://leetcode.com/problems/best-time-to-buy-and-sell-stock/)|[Best Time to Buy and Sell Stock](./Algorithms/0121.best-time-to-buy-and-sell-stock)|48%|Easy|| +|[0120](https://leetcode.com/problems/triangle/)|[Triangle](./Algorithms/0120.triangle)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0119](https://leetcode.com/problems/pascals-triangle-ii/)|[Pascal's Triangle II](./Algorithms/0119.pascals-triangle-ii)|45%|Easy|| +|[0118](https://leetcode.com/problems/pascals-triangle/)|[Pascal's Triangle](./Algorithms/0118.pascals-triangle)|48%|Easy|| +|[0115](https://leetcode.com/problems/distinct-subsequences/)|[Distinct Subsequences](./Algorithms/0115.distinct-subsequences)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0114](https://leetcode.com/problems/flatten-binary-tree-to-linked-list/)|[Flatten Binary Tree to Linked List](./Algorithms/0114.flatten-binary-tree-to-linked-list)|44%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0113](https://leetcode.com/problems/path-sum-ii/)|[Path Sum II](./Algorithms/0113.path-sum-ii)|42%|Medium|| +|[0112](https://leetcode.com/problems/path-sum/)|[Path Sum](./Algorithms/0112.path-sum)|39%|Easy|| +|[0111](https://leetcode.com/problems/minimum-depth-of-binary-tree/)|[Minimum Depth of Binary Tree](./Algorithms/0111.minimum-depth-of-binary-tree)|36%|Easy|| +|[0110](https://leetcode.com/problems/balanced-binary-tree/)|[Balanced Binary Tree](./Algorithms/0110.balanced-binary-tree)|42%|Easy|| +|[0109](https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/)|[Convert Sorted List to Binary Search Tree](./Algorithms/0109.convert-sorted-list-to-binary-search-tree)|43%|Medium|| +|[0108](https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/)|[Convert Sorted Array to Binary Search Tree](./Algorithms/0108.convert-sorted-array-to-binary-search-tree)|53%|Easy|| +|[0107](https://leetcode.com/problems/binary-tree-level-order-traversal-ii/)|[Binary Tree Level Order Traversal II](./Algorithms/0107.binary-tree-level-order-traversal-ii)|48%|Easy|| +|[0106](https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/)|[Construct Binary Tree from Inorder and Postorder Traversal](./Algorithms/0106.construct-binary-tree-from-inorder-and-postorder-traversal)|41%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0105](https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/)|[Construct Binary Tree from Preorder and Inorder Traversal](./Algorithms/0105.construct-binary-tree-from-preorder-and-inorder-traversal)|43%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0104](https://leetcode.com/problems/maximum-depth-of-binary-tree/)|[Maximum Depth of Binary Tree](./Algorithms/0104.maximum-depth-of-binary-tree)|62%|Easy|| +|[0103](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/)|[Binary Tree Zigzag Level Order Traversal](./Algorithms/0103.binary-tree-zigzag-level-order-traversal)|43%|Medium|| +|[0102](https://leetcode.com/problems/binary-tree-level-order-traversal/)|[Binary Tree Level Order Traversal](./Algorithms/0102.binary-tree-level-order-traversal)|50%|Medium|| +|[0101](https://leetcode.com/problems/symmetric-tree/)|[Symmetric Tree](./Algorithms/0101.symmetric-tree)|44%|Easy|[❤](https://leetcode.com/list/oussv5j)| +|[0100](https://leetcode.com/problems/same-tree/)|[Same Tree](./Algorithms/0100.same-tree)|51%|Easy|| +|[0099](https://leetcode.com/problems/recover-binary-search-tree/)|[Recover Binary Search Tree](./Algorithms/0099.recover-binary-search-tree)|36%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0098](https://leetcode.com/problems/validate-binary-search-tree/)|[Validate Binary Search Tree](./Algorithms/0098.validate-binary-search-tree)|26%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0097](https://leetcode.com/problems/interleaving-string/)|[Interleaving String](./Algorithms/0097.interleaving-string)|29%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0096](https://leetcode.com/problems/unique-binary-search-trees/)|[Unique Binary Search Trees](./Algorithms/0096.unique-binary-search-trees)|48%|Medium|| +|[0095](https://leetcode.com/problems/unique-binary-search-trees-ii/)|[Unique Binary Search Trees II](./Algorithms/0095.unique-binary-search-trees-ii)|37%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0094](https://leetcode.com/problems/binary-tree-inorder-traversal/)|[Binary Tree Inorder Traversal](./Algorithms/0094.binary-tree-inorder-traversal)|59%|Medium|| +|[0093](https://leetcode.com/problems/restore-ip-addresses/)|[Restore IP Addresses](./Algorithms/0093.restore-ip-addresses)|32%|Medium|[❤](https://leetcode.com/list/oussv5j)| +|[0092](https://leetcode.com/problems/reverse-linked-list-ii/)|[Reverse Linked List II](./Algorithms/0092.reverse-linked-list-ii)|36%|Medium|| +|[0091](https://leetcode.com/problems/decode-ways/)|[Decode Ways](./Algorithms/0091.decode-ways)|23%|Medium|| +|[0090](https://leetcode.com/problems/subsets-ii/)|[Subsets II](./Algorithms/0090.subsets-ii)|44%|Medium|| +|[0089](https://leetcode.com/problems/gray-code/)|[Gray Code](./Algorithms/0089.gray-code)|47%|Medium|| +|[0088](https://leetcode.com/problems/merge-sorted-array/)|[Merge Sorted Array](./Algorithms/0088.merge-sorted-array)|37%|Easy|| +|[0087](https://leetcode.com/problems/scramble-string/)|[Scramble String](./Algorithms/0087.scramble-string)|32%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0086](https://leetcode.com/problems/partition-list/)|[Partition List](./Algorithms/0086.partition-list)|38%|Medium|| +|[0085](https://leetcode.com/problems/maximal-rectangle/)|[Maximal Rectangle](./Algorithms/0085.maximal-rectangle)|35%|Hard|[❤](https://leetcode.com/list/oussv5j)| +|[0084](https://leetcode.com/problems/largest-rectangle-in-histogram/)|[Largest Rectangle in Histogram](./Algorithms/0084.largest-rectangle-in-histogram)|32%|Hard|| +|[0083](https://leetcode.com/problems/remove-duplicates-from-sorted-list/)|[Remove Duplicates from Sorted List](./Algorithms/0083.remove-duplicates-from-sorted-list)|43%|Easy|| +|[0082](https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/)|[Remove Duplicates from Sorted List II](./Algorithms/0082.remove-duplicates-from-sorted-list-ii)|34%|Medium|| +|[0081](https://leetcode.com/problems/search-in-rotated-sorted-array-ii/)|[Search in Rotated Sorted Array II](./Algorithms/0081.search-in-rotated-sorted-array-ii)|32%|Medium|| +|[0080](https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/)|[Remove Duplicates from Sorted Array II](./Algorithms/0080.remove-duplicates-from-sorted-array-ii)|41%|Medium|| +|[0079](https://leetcode.com/problems/word-search/)|[Word Search](./Algorithms/0079.word-search)|32%|Medium|| +|[0078](https://leetcode.com/problems/subsets/)|[Subsets](./Algorithms/0078.subsets)|56%|Medium|| +|[0077](https://leetcode.com/problems/combinations/)|[Combinations](./Algorithms/0077.combinations)|50%|Medium|| +|[0076](https://leetcode.com/problems/minimum-window-substring/)|[Minimum Window Substring](./Algorithms/0076.minimum-window-substring)|32%|Hard|| +|[0075](https://leetcode.com/problems/sort-colors/)|[Sort Colors](./Algorithms/0075.sort-colors)|43%|Medium|| +|[0074](https://leetcode.com/problems/search-a-2d-matrix/)|[Search a 2D Matrix](./Algorithms/0074.search-a-2d-matrix)|35%|Medium|| +|[0073](https://leetcode.com/problems/set-matrix-zeroes/)|[Set Matrix Zeroes](./Algorithms/0073.set-matrix-zeroes)|41%|Medium|| +|[0072](https://leetcode.com/problems/edit-distance/)|[Edit Distance](./Algorithms/0072.edit-distance)|40%|Hard|| +|[0071](https://leetcode.com/problems/simplify-path/)|[Simplify Path](./Algorithms/0071.simplify-path)|30%|Medium|| +|[0070](https://leetcode.com/problems/climbing-stairs/)|[Climbing Stairs](./Algorithms/0070.climbing-stairs)|45%|Easy|| +|[0069](https://leetcode.com/problems/sqrtx/)|[Sqrt(x)](./Algorithms/0069.sqrtx)|32%|Easy|| +|[0068](https://leetcode.com/problems/text-justification/)|[Text Justification](./Algorithms/0068.text-justification)|24%|Hard|| +|[0067](https://leetcode.com/problems/add-binary/)|[Add Binary](./Algorithms/0067.add-binary)|41%|Easy|| +|[0066](https://leetcode.com/problems/plus-one/)|[Plus One](./Algorithms/0066.plus-one)|41%|Easy|| +|[0065](https://leetcode.com/problems/valid-number/)|[Valid Number](./Algorithms/0065.valid-number)|14%|Hard|| +|[0064](https://leetcode.com/problems/minimum-path-sum/)|[Minimum Path Sum](./Algorithms/0064.minimum-path-sum)|49%|Medium|| +|[0063](https://leetcode.com/problems/unique-paths-ii/)|[Unique Paths II](./Algorithms/0063.unique-paths-ii)|33%|Medium|| +|[0062](https://leetcode.com/problems/unique-paths/)|[Unique Paths](./Algorithms/0062.unique-paths)|49%|Medium|| +|[0061](https://leetcode.com/problems/rotate-list/)|[Rotate List](./Algorithms/0061.rotate-list)|28%|Medium|| +|[0060](https://leetcode.com/problems/permutation-sequence/)|[Permutation Sequence](./Algorithms/0060.permutation-sequence)|34%|Medium|| +|[0059](https://leetcode.com/problems/spiral-matrix-ii/)|[Spiral Matrix II](./Algorithms/0059.spiral-matrix-ii)|49%|Medium|| +|[0058](https://leetcode.com/problems/length-of-last-word/)|[Length of Last Word](./Algorithms/0058.length-of-last-word)|32%|Easy|| +|[0057](https://leetcode.com/problems/insert-interval/)|[Insert Interval](./Algorithms/0057.insert-interval)|32%|Hard|| +|[0056](https://leetcode.com/problems/merge-intervals/)|[Merge Intervals](./Algorithms/0056.merge-intervals)|37%|Medium|| +|[0055](https://leetcode.com/problems/jump-game/)|[Jump Game](./Algorithms/0055.jump-game)|32%|Medium|| +|[0054](https://leetcode.com/problems/spiral-matrix/)|[Spiral Matrix](./Algorithms/0054.spiral-matrix)|31%|Medium|| +|[0053](https://leetcode.com/problems/maximum-subarray/)|[Maximum Subarray](./Algorithms/0053.maximum-subarray)|44%|Easy|| +|[0052](https://leetcode.com/problems/n-queens-ii/)|[N-Queens II](./Algorithms/0052.n-queens-ii)|54%|Hard|| +|[0051](https://leetcode.com/problems/n-queens/)|[N-Queens](./Algorithms/0051.n-queens)|42%|Hard|| +|[0050](https://leetcode.com/problems/powx-n/)|[Pow(x, n)](./Algorithms/0050.powx-n)|28%|Medium|| +|[0049](https://leetcode.com/problems/group-anagrams/)|[Group Anagrams](./Algorithms/0049.group-anagrams)|50%|Medium|| +|[0048](https://leetcode.com/problems/rotate-image/)|[Rotate Image](./Algorithms/0048.rotate-image)|51%|Medium|| +|[0047](https://leetcode.com/problems/permutations-ii/)|[Permutations II](./Algorithms/0047.permutations-ii)|42%|Medium|| +|[0046](https://leetcode.com/problems/permutations/)|[Permutations](./Algorithms/0046.permutations)|58%|Medium|| +|[0045](https://leetcode.com/problems/jump-game-ii/)|[Jump Game II](./Algorithms/0045.jump-game-ii)|29%|Hard|| +|[0044](https://leetcode.com/problems/wildcard-matching/)|[Wildcard Matching](./Algorithms/0044.wildcard-matching)|23%|Hard|| +|[0043](https://leetcode.com/problems/multiply-strings/)|[Multiply Strings](./Algorithms/0043.multiply-strings)|31%|Medium|| +|[0042](https://leetcode.com/problems/trapping-rain-water/)|[Trapping Rain Water](./Algorithms/0042.trapping-rain-water)|45%|Hard|| +|[0041](https://leetcode.com/problems/first-missing-positive/)|[First Missing Positive](./Algorithms/0041.first-missing-positive)|30%|Hard|| +|[0040](https://leetcode.com/problems/combination-sum-ii/)|[Combination Sum II](./Algorithms/0040.combination-sum-ii)|44%|Medium|| +|[0039](https://leetcode.com/problems/combination-sum/)|[Combination Sum](./Algorithms/0039.combination-sum)|51%|Medium|| +|[0038](https://leetcode.com/problems/count-and-say/)|[Count and Say](./Algorithms/0038.count-and-say)|42%|Easy|| +|[0037](https://leetcode.com/problems/sudoku-solver/)|[Sudoku Solver](./Algorithms/0037.sudoku-solver)|39%|Hard|| +|[0036](https://leetcode.com/problems/valid-sudoku/)|[Valid Sudoku](./Algorithms/0036.valid-sudoku)|45%|Medium|| +|[0035](https://leetcode.com/problems/search-insert-position/)|[Search Insert Position](./Algorithms/0035.search-insert-position)|41%|Easy|| +|[0034](https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/)|[Find First and Last Position of Element in Sorted Array](./Algorithms/0034.find-first-and-last-position-of-element-in-sorted-array)|34%|Medium|| +|[0033](https://leetcode.com/problems/search-in-rotated-sorted-array/)|[Search in Rotated Sorted Array](./Algorithms/0033.search-in-rotated-sorted-array)|33%|Medium|| +|[0032](https://leetcode.com/problems/longest-valid-parentheses/)|[Longest Valid Parentheses](./Algorithms/0032.longest-valid-parentheses)|26%|Hard|| +|[0031](https://leetcode.com/problems/next-permutation/)|[Next Permutation](./Algorithms/0031.next-permutation)|31%|Medium|| +|[0030](https://leetcode.com/problems/substring-with-concatenation-of-all-words/)|[Substring with Concatenation of All Words](./Algorithms/0030.substring-with-concatenation-of-all-words)|24%|Hard|| +|[0029](https://leetcode.com/problems/divide-two-integers/)|[Divide Two Integers](./Algorithms/0029.divide-two-integers)|16%|Medium|| +|[0028](https://leetcode.com/problems/implement-strstr/)|[Implement strStr()](./Algorithms/0028.implement-strstr)|33%|Easy|| +|[0027](https://leetcode.com/problems/remove-element/)|[Remove Element](./Algorithms/0027.remove-element)|45%|Easy|| +|[0026](https://leetcode.com/problems/remove-duplicates-from-sorted-array/)|[Remove Duplicates from Sorted Array](./Algorithms/0026.remove-duplicates-from-sorted-array)|42%|Easy|| +|[0025](https://leetcode.com/problems/reverse-nodes-in-k-group/)|[Reverse Nodes in k-Group](./Algorithms/0025.reverse-nodes-in-k-group)|38%|Hard|| +|[0024](https://leetcode.com/problems/swap-nodes-in-pairs/)|[Swap Nodes in Pairs](./Algorithms/0024.swap-nodes-in-pairs)|46%|Medium|| +|[0023](https://leetcode.com/problems/merge-k-sorted-lists/)|[Merge k Sorted Lists](./Algorithms/0023.merge-k-sorted-lists)|36%|Hard|| +|[0022](https://leetcode.com/problems/generate-parentheses/)|[Generate Parentheses](./Algorithms/0022.generate-parentheses)|57%|Medium|| +|[0021](https://leetcode.com/problems/merge-two-sorted-lists/)|[Merge Two Sorted Lists](./Algorithms/0021.merge-two-sorted-lists)|49%|Easy|| +|[0020](https://leetcode.com/problems/valid-parentheses/)|[Valid Parentheses](./Algorithms/0020.valid-parentheses)|37%|Easy|| +|[0019](https://leetcode.com/problems/remove-nth-node-from-end-of-list/)|[Remove Nth Node From End of List](./Algorithms/0019.remove-nth-node-from-end-of-list)|34%|Medium|| +|[0018](https://leetcode.com/problems/4sum/)|[4Sum](./Algorithms/0018.4sum)|31%|Medium|| +|[0017](https://leetcode.com/problems/letter-combinations-of-a-phone-number/)|[Letter Combinations of a Phone Number](./Algorithms/0017.letter-combinations-of-a-phone-number)|43%|Medium|| +|[0016](https://leetcode.com/problems/3sum-closest/)|[3Sum Closest](./Algorithms/0016.3sum-closest)|45%|Medium|| +|[0015](https://leetcode.com/problems/3sum/)|[3Sum](./Algorithms/0015.3sum)|25%|Medium|| +|[0014](https://leetcode.com/problems/longest-common-prefix/)|[Longest Common Prefix](./Algorithms/0014.longest-common-prefix)|34%|Easy|| +|[0013](https://leetcode.com/problems/roman-to-integer/)|[Roman to Integer](./Algorithms/0013.roman-to-integer)|53%|Easy|| +|[0012](https://leetcode.com/problems/integer-to-roman/)|[Integer to Roman](./Algorithms/0012.integer-to-roman)|52%|Medium|| +|[0011](https://leetcode.com/problems/container-with-most-water/)|[Container With Most Water](./Algorithms/0011.container-with-most-water)|47%|Medium|| +|[0010](https://leetcode.com/problems/regular-expression-matching/)|[Regular Expression Matching](./Algorithms/0010.regular-expression-matching)|25%|Hard|| +|[0009](https://leetcode.com/problems/palindrome-number/)|[Palindrome Number](./Algorithms/0009.palindrome-number)|45%|Easy|| +|[0008](https://leetcode.com/problems/string-to-integer-atoi/)|[String to Integer (atoi)](./Algorithms/0008.string-to-integer-atoi)|14%|Medium|| +|[0007](https://leetcode.com/problems/reverse-integer/)|[Reverse Integer](./Algorithms/0007.reverse-integer)|25%|Easy|| +|[0006](https://leetcode.com/problems/zigzag-conversion/)|[ZigZag Conversion](./Algorithms/0006.zigzag-conversion)|33%|Medium|| +|[0005](https://leetcode.com/problems/longest-palindromic-substring/)|[Longest Palindromic Substring](./Algorithms/0005.longest-palindromic-substring)|28%|Medium|| +|[0004](https://leetcode.com/problems/median-of-two-sorted-arrays/)|[Median of Two Sorted Arrays](./Algorithms/0004.median-of-two-sorted-arrays)|27%|Hard|| +|[0003](https://leetcode.com/problems/longest-substring-without-repeating-characters/)|[Longest Substring Without Repeating Characters](./Algorithms/0003.longest-substring-without-repeating-characters)|29%|Medium|| +|[0002](https://leetcode.com/problems/add-two-numbers/)|[Add Two Numbers](./Algorithms/0002.add-two-numbers)|32%|Medium|| +|[0001](https://leetcode.com/problems/two-sum/)|[Two Sum](./Algorithms/0001.two-sum)|44%|Easy|| + +以下免费的算法题,暂时不能提交 Go 解答 + +- [116.Populating Next Right Pointers in Each Node](https://leetcode.com/problems/populating-next-right-pointers-in-each-node/) +- [117.Populating Next Right Pointers in Each Node II](https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/) +- [133.Clone Graph](https://leetcode.com/problems/clone-graph/) +- [138.Copy List with Random Pointer](https://leetcode.com/problems/copy-list-with-random-pointer/) +- [151.Reverse Words in a String](https://leetcode.com/problems/reverse-words-in-a-string/) +- [278.First Bad Version](https://leetcode.com/problems/first-bad-version/) +- [284.Peeking Iterator](https://leetcode.com/problems/peeking-iterator/) +- [297.Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree/) +- [341.Flatten Nested List Iterator](https://leetcode.com/problems/flatten-nested-list-iterator/) +- [374.Guess Number Higher or Lower](https://leetcode.com/problems/guess-number-higher-or-lower/) +- [426.Convert Binary Search Tree to Sorted Doubly Linked List](https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/) +- [427.Construct Quad Tree](https://leetcode.com/problems/construct-quad-tree/) +- [429.N-ary Tree Level Order Traversal](https://leetcode.com/problems/n-ary-tree-level-order-traversal/) +- [430.Flatten a Multilevel Doubly Linked List](https://leetcode.com/problems/flatten-a-multilevel-doubly-linked-list/) +- [449.Serialize and Deserialize BST](https://leetcode.com/problems/serialize-and-deserialize-bst/) +- [535.Encode and Decode TinyURL](https://leetcode.com/problems/encode-and-decode-tinyurl/) +- [558.Quad Tree Intersection](https://leetcode.com/problems/quad-tree-intersection/) +- [559.Maximum Depth of N-ary Tree](https://leetcode.com/problems/maximum-depth-of-n-ary-tree/) +- [589.N-ary Tree Preorder Traversal](https://leetcode.com/problems/n-ary-tree-preorder-traversal/) +- [590.N-ary Tree Postorder Traversal](https://leetcode.com/problems/n-ary-tree-postorder-traversal/) +- [690.Employee Importance](https://leetcode.com/problems/employee-importance/) +- [708.Insert into a Cyclic Sorted List](https://leetcode.com/problems/insert-into-a-cyclic-sorted-list/) + +## helper + +[helper](./Helper) 会处理大部分琐碎的工作。 + +## notes + +[notes](./notes) 记录了我答题过程中,对知识点的总结。 + +## kit + +针对 LeetCode 中经常出现的以下数据结构,在 [kit](./kit) 中进行了定义,并添加了与 []int 相互转换的函数。利用 Go 1.9 添加的 [type alias](https://github.com/golang/proposal/blob/master/design/18130-type-alias.md) 功能,易于添加单元测试。 + +- [Heap](./kit/Heap.go) +- [Interval](./kit/Interval.go) +- [ListNode](./kit/ListNode.go) +- [NestedInteger](./kit/NestedInteger.go) +- [PriorityQueue](./kit/PriorityQueue.go) +- [Queue](./kit/Queue.go) +- [Stack](./kit/Stack.go) +- [TreeNode](./kit/TreeNode.go) +- [Master](./kit/master.go) + +## 致谢 + +感谢所有贡献者的辛苦付出 + + + +感谢 JetBrains + +[![GoLand](GoLand.png)]( https://www.jetbrains.com/?from=LeetCode-in-Go) diff --git a/README_HEAD.md b/README_HEAD.md deleted file mode 100644 index 181702aa6..000000000 --- a/README_HEAD.md +++ /dev/null @@ -1,5 +0,0 @@ -# [LeetCode](https://leetcode.com) 的 Go 解答 - -[![LeetCode 排名](https://img.shields.io/badge/%s-%d-blue.svg)](https://leetcode.com/%s/) -[![codecov](https://codecov.io/gh/aQuaYi/LeetCode-in-Go/branch/master/graph/badge.svg)](https://codecov.io/gh/aQuaYi/LeetCode-in-Go) -[![Build Status](https://www.travis-ci.org/aQuaYi/LeetCode-in-Go.svg?branch=master)](https://www.travis-ci.org/aQuaYi/LeetCode-in-Go) \ No newline at end of file diff --git a/README_TAIL.md b/README_TAIL.md deleted file mode 100644 index f18872390..000000000 --- a/README_TAIL.md +++ /dev/null @@ -1,33 +0,0 @@ -# 使用方法 - -```bash -$ go version -// 请确保版本号 >= 1.9 -$ go env -... -GOPATH="第一个GOPATH目录:..." -... -$ go get github.com/aQuaYi/LeetCode-in-Go -// 下载位置: 第一个GOPATH目录/src/github.com/aQuaYi/LeetCode-in-Go -``` - -## helper - -[helper](./helper) 会处理大部分琐碎的工作。 - -## notes - -[notes](./notes) 记录了我答题过程中,对知识点的总结。 - -## kit - -针对 LeetCode 中经常出现的以下数据结构,在 [kit](./kit) 中进行了定义,并添加了与 []int 相互转换的函数。利用 Go 1.9 新添加的 [type alias](https://github.com/golang/proposal/blob/master/design/18130-type-alias.md) 功能,易于添加单元测试。 - -- [Heap](./kit/Heap.go) -- [Interval](./kit/Interval.go) -- [ListNode](./kit/ListNode.go) -- [NestedInteger](./kit/NestedInteger.go) -- [PriorityQueue](./kit/PriorityQueue.go) -- [Queue](./kit/Queue.go) -- [Stack](./kit/Stack.go) -- [TreeNode](./kit/TreeNode.go) \ No newline at end of file diff --git a/favorite.markdown b/favorite.markdown new file mode 100755 index 000000000..166576ff0 --- /dev/null +++ b/favorite.markdown @@ -0,0 +1,3 @@ +# 我收藏的 {{.FavoriteCount}} 题 + +{{.FavoriteTable}} diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..3a671722c --- /dev/null +++ b/go.mod @@ -0,0 +1,13 @@ +module github.com/aQuaYi/LeetCode-in-Go + +go 1.13 + +require ( + github.com/BurntSushi/toml v0.3.1 + github.com/TruthHun/html2md v0.0.0-20200103021813-42640c281ac8 + github.com/aQuaYi/GoKit v0.0.0-20170805152833-88827a405d9b + github.com/bitly/go-simplejson v0.5.0 // indirect + github.com/mozillazg/request v0.8.0 + golang.org/x/net v0.0.0-20191124235446-72fef5d5e266 // indirect + gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df +) diff --git a/go.sum b/go.sum new file mode 100644 index 000000000..bdbfe20a1 --- /dev/null +++ b/go.sum @@ -0,0 +1,58 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= +github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM= +github.com/PuerkitoBio/goquery v1.5.0 h1:uGvmFXOA73IKluu/F84Xd1tt/z07GYm8X49XKHP7EJk= +github.com/PuerkitoBio/goquery v1.5.0/go.mod h1:qD2PgZ9lccMbQlc7eEOjaeRlFQON7xY8kdmcsrnKqMg= +github.com/TruthHun/html2md v0.0.0-20200103021813-42640c281ac8 h1:ehl5nICeqS2K/chBxq1GQNBxgrg4lAQlc4a34MoNoUM= +github.com/TruthHun/html2md v0.0.0-20200103021813-42640c281ac8/go.mod h1:krLpLGgGKK7lv2Ru8snV4DW1bPa3oPW/FVTL13E/Dws= +github.com/aQuaYi/GoKit v0.0.0-20170805152833-88827a405d9b h1:ETIKydTbnzwNUsIGDBiFl2EURPhMH3NnFHIDsnXc+o4= +github.com/aQuaYi/GoKit v0.0.0-20170805152833-88827a405d9b/go.mod h1:5MlpsreROJsVmgQHgk2nse+wA7lKTZWgu21Oat1JWcg= +github.com/andybalholm/cascadia v1.0.0 h1:hOCXnnZ5A+3eVDX8pvgl4kofXv2ELss0bKcqRySc45o= +github.com/andybalholm/cascadia v1.0.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/astaxie/beego v1.12.0 h1:MRhVoeeye5N+Flul5PoVfD9CslfdoH+xqC/xvSQ5u2Y= +github.com/astaxie/beego v1.12.0/go.mod h1:fysx+LZNZKnvh4GED/xND7jWtjCR6HzydR2Hh2Im57o= +github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ= +github.com/beego/x2j v0.0.0-20131220205130-a0352aadc542/go.mod h1:kSeGC/p1AbBiEp5kat81+DSQrZenVBZXklMLaELspWU= +github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= +github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= +github.com/bradfitz/gomemcache v0.0.0-20180710155616-bc664df96737/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60= +github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE= +github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= +github.com/couchbase/go-couchbase v0.0.0-20181122212707-3e9b6e1258bb/go.mod h1:TWI8EKQMs5u5jLKW/tsb9VwauIrMIxQG1r5fMsswK5U= +github.com/couchbase/gomemcached v0.0.0-20181122193126-5125a94a666c/go.mod h1:srVSlQLB8iXBVXHgnqemxUXqN6FCvClgCMPCsjBDR7c= +github.com/couchbase/goutils v0.0.0-20180530154633-e865a1461c8a/go.mod h1:BQwMFlJzDjFDG3DJUdU0KORxn88UlsOULuxLExMh3Hs= +github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY= +github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= +github.com/go-redis/redis v6.14.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= +github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mozillazg/request v0.8.0 h1:TbXeQUdBWr1J1df5Z+lQczDFzX9JD71kTCl7Zu/9rNM= +github.com/mozillazg/request v0.8.0/go.mod h1:weoQ/mVFNbWgRBtivCGF1tUT9lwneFesues+CleXMWc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo= +github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= +github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= +github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg= +github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= +github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= +github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= +github.com/wendal/errors v0.0.0-20130201093226-f66c77a7882b/go.mod h1:Q12BUT7DqIlHRmgv3RskH+UCM/4eqVMgI0EMmlSpAXc= +golang.org/x/crypto v0.0.0-20181127143415-eb0de9b17e85/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20191124235446-72fef5d5e266 h1:QuOiA7GCO0OSDzlNlFyOWOywDsjuzW8M2yvBfCqw+cY= +golang.org/x/net v0.0.0-20191124235446-72fef5d5e266/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE= +gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/kit/Heap.go b/kit/Heap.go index fa44e2183..995ecafd2 100644 --- a/kit/Heap.go +++ b/kit/Heap.go @@ -14,6 +14,7 @@ func (h intHeap) Less(i, j int) bool { func (h intHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } + func (h *intHeap) Push(x interface{}) { // Push 使用 *h,是因为 // Push 增加了 h 的长度 diff --git a/kit/ListNode.go b/kit/ListNode.go index 8b778e066..a908fbb7d 100644 --- a/kit/ListNode.go +++ b/kit/ListNode.go @@ -35,21 +35,44 @@ func List2Ints(head *ListNode) []int { // Ints2List convert []int to List func Ints2List(nums []int) *ListNode { - if len(nums) == 0 { - return nil - } - - res := &ListNode{ - Val: nums[0], + l := &ListNode{} + t := l + for _, v := range nums { + t.Next = &ListNode{Val: v} + t = t.Next } + return l.Next +} - temp := res - for i := 1; i < len(nums); i++ { - temp.Next = &ListNode{ - Val: nums[i], +// GetNodeWith returns the first node with val +func (l *ListNode) GetNodeWith(val int) *ListNode { + res := l + for res != nil { + if res.Val == val { + break } - temp = temp.Next + res = res.Next } - return res } + +// Ints2ListWithCycle returns a list whose tail point to pos-indexed node +// head's index is 0 +// if pos = -1, no cycle +func Ints2ListWithCycle(nums []int, pos int) *ListNode { + head := Ints2List(nums) + if pos == -1 { + return head + } + c := head + for pos > 0 { + c = c.Next + pos-- + } + tail := c + for tail.Next != nil { + tail = tail.Next + } + tail.Next = c + return head +} diff --git a/kit/ListNode_test.go b/kit/ListNode_test.go index ed2501edd..64cc2a020 100644 --- a/kit/ListNode_test.go +++ b/kit/ListNode_test.go @@ -34,8 +34,35 @@ func Test_s2l(t *testing.T) { i := 1 for ln != nil { ast.Equal(i, ln.Val, "对应的值不对") - ln = ln.Next i++ } } + +func Test_getNodeWith(t *testing.T) { + ast := assert.New(t) + // + ln := Ints2List([]int{1, 2, 3, 4, 5, 6, 7, 8, 9}) + val := 10 + node := &ListNode{ + Val: val, + } + tail := ln + for tail.Next != nil { + tail = tail.Next + } + tail.Next = node + expected := node + actual := ln.GetNodeWith(val) + ast.Equal(expected, actual) +} + +func Test_Ints2ListWithCycle(t *testing.T) { + ast := assert.New(t) + ints := []int{1, 2, 3} + l := Ints2ListWithCycle(ints, -1) + ast.Equal(ints, List2Ints(l)) + + l = Ints2ListWithCycle(ints, 1) + ast.Panics(func() { List2Ints(l) }) +} diff --git a/kit/TreeNode.go b/kit/TreeNode.go index bb3be150f..3e8c7bb99 100644 --- a/kit/TreeNode.go +++ b/kit/TreeNode.go @@ -11,7 +11,8 @@ type TreeNode struct { Right *TreeNode } -var null = -1 << 63 +// NULL 方便添加测试数据 +var NULL = -1 << 63 // Ints2TreeNode 利用 []int 生成 *TreeNode func Ints2TreeNode(ints []int) *TreeNode { @@ -28,30 +29,40 @@ func Ints2TreeNode(ints []int) *TreeNode { queue[0] = root i := 1 - for { + for i < n { node := queue[0] queue = queue[1:] - if i < n && ints[i] != null { + if i < n && ints[i] != NULL { node.Left = &TreeNode{Val: ints[i]} queue = append(queue, node.Left) } i++ - if i < n && ints[i] != null { + if i < n && ints[i] != NULL { node.Right = &TreeNode{Val: ints[i]} queue = append(queue, node.Right) } i++ - - if i >= n { - break - } } return root } +// GetTargetNode 返回 Val = target 的 TreeNode +// root 中一定有 node.Val = target +func GetTargetNode(root *TreeNode, target int) *TreeNode { + if root == nil || root.Val == target { + return root + } + + res := GetTargetNode(root.Left, target) + if res != nil { + return res + } + return GetTargetNode(root.Right, target) +} + func indexOf(val int, nums []int) int { for i, v := range nums { if v == val { @@ -178,3 +189,31 @@ func (tn *TreeNode) Equal(a *TreeNode) bool { return tn.Left.Equal(a.Left) && tn.Right.Equal(a.Right) } + +// Tree2ints 把 *TreeNode 按照行还原成 []int +func Tree2ints(tn *TreeNode) []int { + res := make([]int, 0, 1024) + + queue := []*TreeNode{tn} + + for len(queue) > 0 { + size := len(queue) + for i := 0; i < size; i++ { + nd := queue[i] + if nd == nil { + res = append(res, NULL) + } else { + res = append(res, nd.Val) + queue = append(queue, nd.Left, nd.Right) + } + } + queue = queue[size:] + } + + i := len(res) + for i > 0 && res[i-1] == NULL { + i-- + } + + return res[:i] +} diff --git a/kit/TreeNode_test.go b/kit/TreeNode_test.go index 3b3f0bea2..ab5d15a2d 100644 --- a/kit/TreeNode_test.go +++ b/kit/TreeNode_test.go @@ -1,6 +1,7 @@ package kit import ( + "reflect" "testing" "github.com/stretchr/testify/assert" @@ -97,7 +98,7 @@ func Test_TreeNode_Equal(t *testing.T) { { "不相等", args{Ints2TreeNode([]int{1, 2, 3, 4, 5})}, - args{Ints2TreeNode([]int{1, 2, 3, null, 5})}, + args{Ints2TreeNode([]int{1, 2, 3, NULL, 5})}, false, }, } @@ -110,3 +111,56 @@ func Test_TreeNode_Equal(t *testing.T) { }) } } + +func Test_GetTargetNode(t *testing.T) { + ints := []int{3, 5, 1, 6, 2, 0, 8, NULL, NULL, 7, 4} + root := Ints2TreeNode(ints) + + type args struct { + root *TreeNode + target int + } + tests := []struct { + name string + args args + want *TreeNode + }{ + + { + "找到 root.Right.Right", + args{ + root: root, + target: 8, + }, + root.Right.Right, + }, + + { + "找到 root.Left.Left", + args{ + root: root, + target: 6, + }, + root.Left.Left, + }, + + // + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := GetTargetNode(tt.args.root, tt.args.target); !reflect.DeepEqual(got, tt.want) { + t.Errorf("GetTargetNode() = %v, want %v", got, tt.want) + } + }) + } +} + +func Test_Tree2ints(t *testing.T) { + ast := assert.New(t) + + root := PreIn2Tree(preOrder, inOrder) + actual := LeetCodeOrder + expected := Tree2ints(root) + ast.Equal(expected, actual) +} diff --git a/kit/master.go b/kit/master.go new file mode 100644 index 000000000..b94c38197 --- /dev/null +++ b/kit/master.go @@ -0,0 +1,38 @@ +package kit + +// Master 是 LeetCode 的结构体 +type Master struct { + Secret string + WordList []string + IsInWords map[string]bool + Count int +} + +// Guess word +func (m *Master) Guess(word string) int { + m.Count-- + if !m.IsInWords[word] { + return -1 + } + return matches(m.Secret, word) +} + +// a,b 总是一样长的 +func matches(a, b string) int { + size := len(a) + res := 0 + for i := 0; i < size; i++ { + if a[i] == b[i] { + res++ + } + } + return res +} + +// Update 更新了 m.IsInWords +func (m *Master) Update() { + m.IsInWords = make(map[string]bool, len(m.WordList)) + for _, w := range m.WordList { + m.IsInWords[w] = true + } +} diff --git a/kit/master_test.go b/kit/master_test.go new file mode 100644 index 000000000..1d57c4597 --- /dev/null +++ b/kit/master_test.go @@ -0,0 +1,170 @@ +package kit + +import ( + "testing" +) + +func Test_matches(t *testing.T) { + type args struct { + a string + b string + } + tests := []struct { + name string + args args + want int + }{ + + { + "没有一个字母一样", + args{ + "aaaaaaa", + "bbbbbbb", + }, + 0, + }, + + { + "a 和 b 只有 1 个字母一样", + args{ + "aaaaaaa", + "bbbbbba", + }, + 1, + }, + + { + "a 和 b 只有 2 个字母一样", + args{ + "aaaaaaa", + "bbbbbaa", + }, + 2, + }, + + { + "a 和 b 只有 3 个字母一样", + args{ + "aaaaaaa", + "bbbbaaa", + }, + 3, + }, + + { + "a 和 b 只有 4 个字母一样", + args{ + "aaaaaaa", + "bbbaaaa", + }, + 4, + }, + + { + "a 和 b 只有 5 个字母一样", + args{ + "aaaaaaa", + "bbaaaaa", + }, + 5, + }, + + { + "a 和 b 只有 6 个字母一样", + args{ + "aaaaaaa", + "baaaaaa", + }, + 6, + }, + + { + "一样的 a 和 b", + args{ + "aaaaaaa", + "aaaaaaa", + }, + 7, + }, + + // 添加参数 + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := matches(tt.args.a, tt.args.b); got != tt.want { + t.Errorf("matches() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestMaster_Guess(t *testing.T) { + m := &Master{ + Secret: "acckzz", + WordList: []string{"acckzz", "ccbazz", "eiowzz", "abcczz"}, + Count: 5, + } + + m.Update() + + tests := []struct { + name string + m *Master + word string + want int + count int + }{ + + { + "猜中了", + m, + "acckzz", + 6, + 4, + }, + + { + "猜 word list 中的单词", + m, + "aaaaaa", + -1, + 3, + }, + + { + "猜中了 3 个字母", + m, + "ccbazz", + 3, + 2, + }, + + { + "猜中了 2 个字母", + m, + "eiowzz", + 2, + 1, + }, + + { + "猜中了 4 个字母", + m, + "abcczz", + 4, + 0, + }, + + // 添加参数 + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := tt.m.Guess(tt.word); got != tt.want { + t.Errorf("Master.Guess() = %v, want %v", got, tt.want) + } + if tt.m.Count != tt.count { + t.Errorf("tt.m.Count = %v, but tt.count = %v", tt.m.Count, tt.count) + } + }) + } +} diff --git a/leetcode.json b/leetcode.json index f7bc66b58..2d293697a 100644 --- a/leetcode.json +++ b/leetcode.json @@ -1,23 +1,23 @@ { "Username": "aQuaYi", - "Ranking": 1057, - "Updated": "2018-05-27T22:34:04.095802404+08:00", + "Ranking": 646, + "Updated": "2019-11-05T09:46:35.236486142+08:00", "Record": { "Easy": { - "Solved": 170, - "Total": 173 + "Solved": 265, + "Total": 267 }, "Medium": { - "Solved": 292, - "Total": 299 + "Solved": 456, + "Total": 472 }, "Hard": { - "Solved": 124, - "Total": 129 + "Solved": 187, + "Total": 197 }, "Total": { - "Solved": 586, - "Total": 601 + "Solved": 908, + "Total": 936 } }, "Problems": [ @@ -37,7 +37,7 @@ "ID": 1, "Title": "Two Sum", "TitleSlug": "two-sum", - "PassRate": "38%", + "PassRate": "44%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -49,7 +49,7 @@ "ID": 2, "Title": "Add Two Numbers", "TitleSlug": "add-two-numbers", - "PassRate": "28%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -61,7 +61,7 @@ "ID": 3, "Title": "Longest Substring Without Repeating Characters", "TitleSlug": "longest-substring-without-repeating-characters", - "PassRate": "24%", + "PassRate": "29%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -73,7 +73,7 @@ "ID": 4, "Title": "Median of Two Sorted Arrays", "TitleSlug": "median-of-two-sorted-arrays", - "PassRate": "23%", + "PassRate": "27%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -85,7 +85,7 @@ "ID": 5, "Title": "Longest Palindromic Substring", "TitleSlug": "longest-palindromic-substring", - "PassRate": "25%", + "PassRate": "28%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -97,7 +97,7 @@ "ID": 6, "Title": "ZigZag Conversion", "TitleSlug": "zigzag-conversion", - "PassRate": "27%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -109,7 +109,7 @@ "ID": 7, "Title": "Reverse Integer", "TitleSlug": "reverse-integer", - "PassRate": "24%", + "PassRate": "25%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -133,7 +133,7 @@ "ID": 9, "Title": "Palindrome Number", "TitleSlug": "palindrome-number", - "PassRate": "36%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -145,11 +145,11 @@ "ID": 10, "Title": "Regular Expression Matching", "TitleSlug": "regular-expression-matching", - "PassRate": "24%", + "PassRate": "25%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -157,7 +157,7 @@ "ID": 11, "Title": "Container With Most Water", "TitleSlug": "container-with-most-water", - "PassRate": "37%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -169,7 +169,7 @@ "ID": 12, "Title": "Integer to Roman", "TitleSlug": "integer-to-roman", - "PassRate": "46%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -181,7 +181,7 @@ "ID": 13, "Title": "Roman to Integer", "TitleSlug": "roman-to-integer", - "PassRate": "48%", + "PassRate": "53%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -193,7 +193,7 @@ "ID": 14, "Title": "Longest Common Prefix", "TitleSlug": "longest-common-prefix", - "PassRate": "31%", + "PassRate": "34%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -205,7 +205,7 @@ "ID": 15, "Title": "3Sum", "TitleSlug": "3sum", - "PassRate": "21%", + "PassRate": "25%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -217,7 +217,7 @@ "ID": 16, "Title": "3Sum Closest", "TitleSlug": "3sum-closest", - "PassRate": "31%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -229,7 +229,7 @@ "ID": 17, "Title": "Letter Combinations of a Phone Number", "TitleSlug": "letter-combinations-of-a-phone-number", - "PassRate": "36%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -241,7 +241,7 @@ "ID": 18, "Title": "4Sum", "TitleSlug": "4sum", - "PassRate": "27%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -253,7 +253,7 @@ "ID": 19, "Title": "Remove Nth Node From End of List", "TitleSlug": "remove-nth-node-from-end-of-list", - "PassRate": "33%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -265,7 +265,7 @@ "ID": 20, "Title": "Valid Parentheses", "TitleSlug": "valid-parentheses", - "PassRate": "34%", + "PassRate": "37%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -277,7 +277,7 @@ "ID": 21, "Title": "Merge Two Sorted Lists", "TitleSlug": "merge-two-sorted-lists", - "PassRate": "41%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -289,7 +289,7 @@ "ID": 22, "Title": "Generate Parentheses", "TitleSlug": "generate-parentheses", - "PassRate": "48%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -301,7 +301,7 @@ "ID": 23, "Title": "Merge k Sorted Lists", "TitleSlug": "merge-k-sorted-lists", - "PassRate": "28%", + "PassRate": "36%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -313,7 +313,7 @@ "ID": 24, "Title": "Swap Nodes in Pairs", "TitleSlug": "swap-nodes-in-pairs", - "PassRate": "39%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -325,11 +325,11 @@ "ID": 25, "Title": "Reverse Nodes in k-Group", "TitleSlug": "reverse-nodes-in-k-group", - "PassRate": "32%", + "PassRate": "38%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -337,7 +337,7 @@ "ID": 26, "Title": "Remove Duplicates from Sorted Array", "TitleSlug": "remove-duplicates-from-sorted-array", - "PassRate": "36%", + "PassRate": "42%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -349,7 +349,7 @@ "ID": 27, "Title": "Remove Element", "TitleSlug": "remove-element", - "PassRate": "41%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -361,7 +361,7 @@ "ID": 28, "Title": "Implement strStr()", "TitleSlug": "implement-strstr", - "PassRate": "29%", + "PassRate": "33%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -373,7 +373,7 @@ "ID": 29, "Title": "Divide Two Integers", "TitleSlug": "divide-two-integers", - "PassRate": "15%", + "PassRate": "16%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -385,11 +385,11 @@ "ID": 30, "Title": "Substring with Concatenation of All Words", "TitleSlug": "substring-with-concatenation-of-all-words", - "PassRate": "22%", + "PassRate": "24%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -397,7 +397,7 @@ "ID": 31, "Title": "Next Permutation", "TitleSlug": "next-permutation", - "PassRate": "29%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -409,7 +409,7 @@ "ID": 32, "Title": "Longest Valid Parentheses", "TitleSlug": "longest-valid-parentheses", - "PassRate": "23%", + "PassRate": "26%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -421,19 +421,19 @@ "ID": 33, "Title": "Search in Rotated Sorted Array", "TitleSlug": "search-in-rotated-sorted-array", - "PassRate": "31%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { "ID": 34, - "Title": "Search for a Range", - "TitleSlug": "search-for-a-range", - "PassRate": "31%", + "Title": "Find First and Last Position of Element in Sorted Array", + "TitleSlug": "find-first-and-last-position-of-element-in-sorted-array", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -445,7 +445,7 @@ "ID": 35, "Title": "Search Insert Position", "TitleSlug": "search-insert-position", - "PassRate": "40%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -457,7 +457,7 @@ "ID": 36, "Title": "Valid Sudoku", "TitleSlug": "valid-sudoku", - "PassRate": "38%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -469,11 +469,11 @@ "ID": 37, "Title": "Sudoku Solver", "TitleSlug": "sudoku-solver", - "PassRate": "32%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -481,7 +481,7 @@ "ID": 38, "Title": "Count and Say", "TitleSlug": "count-and-say", - "PassRate": "37%", + "PassRate": "42%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -493,7 +493,7 @@ "ID": 39, "Title": "Combination Sum", "TitleSlug": "combination-sum", - "PassRate": "41%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -505,7 +505,7 @@ "ID": 40, "Title": "Combination Sum II", "TitleSlug": "combination-sum-ii", - "PassRate": "36%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -517,7 +517,7 @@ "ID": 41, "Title": "First Missing Positive", "TitleSlug": "first-missing-positive", - "PassRate": "26%", + "PassRate": "30%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -529,7 +529,7 @@ "ID": 42, "Title": "Trapping Rain Water", "TitleSlug": "trapping-rain-water", - "PassRate": "37%", + "PassRate": "45%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -541,7 +541,7 @@ "ID": 43, "Title": "Multiply Strings", "TitleSlug": "multiply-strings", - "PassRate": "28%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -553,11 +553,11 @@ "ID": 44, "Title": "Wildcard Matching", "TitleSlug": "wildcard-matching", - "PassRate": "21%", + "PassRate": "23%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -565,7 +565,7 @@ "ID": 45, "Title": "Jump Game II", "TitleSlug": "jump-game-ii", - "PassRate": "26%", + "PassRate": "29%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -577,7 +577,7 @@ "ID": 46, "Title": "Permutations", "TitleSlug": "permutations", - "PassRate": "47%", + "PassRate": "58%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -589,7 +589,7 @@ "ID": 47, "Title": "Permutations II", "TitleSlug": "permutations-ii", - "PassRate": "35%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -601,7 +601,7 @@ "ID": 48, "Title": "Rotate Image", "TitleSlug": "rotate-image", - "PassRate": "42%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -613,11 +613,11 @@ "ID": 49, "Title": "Group Anagrams", "TitleSlug": "group-anagrams", - "PassRate": "39%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -625,7 +625,7 @@ "ID": 50, "Title": "Pow(x, n)", "TitleSlug": "powx-n", - "PassRate": "26%", + "PassRate": "28%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -637,7 +637,7 @@ "ID": 51, "Title": "N-Queens", "TitleSlug": "n-queens", - "PassRate": "33%", + "PassRate": "42%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -649,7 +649,7 @@ "ID": 52, "Title": "N-Queens II", "TitleSlug": "n-queens-ii", - "PassRate": "47%", + "PassRate": "54%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -661,11 +661,11 @@ "ID": 53, "Title": "Maximum Subarray", "TitleSlug": "maximum-subarray", - "PassRate": "40%", + "PassRate": "44%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -673,11 +673,11 @@ "ID": 54, "Title": "Spiral Matrix", "TitleSlug": "spiral-matrix", - "PassRate": "27%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -685,7 +685,7 @@ "ID": 55, "Title": "Jump Game", "TitleSlug": "jump-game", - "PassRate": "29%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -697,11 +697,11 @@ "ID": 56, "Title": "Merge Intervals", "TitleSlug": "merge-intervals", - "PassRate": "32%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -709,7 +709,7 @@ "ID": 57, "Title": "Insert Interval", "TitleSlug": "insert-interval", - "PassRate": "29%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -733,11 +733,11 @@ "ID": 59, "Title": "Spiral Matrix II", "TitleSlug": "spiral-matrix-ii", - "PassRate": "41%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -745,7 +745,7 @@ "ID": 60, "Title": "Permutation Sequence", "TitleSlug": "permutation-sequence", - "PassRate": "29%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -757,11 +757,11 @@ "ID": 61, "Title": "Rotate List", "TitleSlug": "rotate-list", - "PassRate": "24%", + "PassRate": "28%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -769,11 +769,11 @@ "ID": 62, "Title": "Unique Paths", "TitleSlug": "unique-paths", - "PassRate": "43%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -781,7 +781,7 @@ "ID": 63, "Title": "Unique Paths II", "TitleSlug": "unique-paths-ii", - "PassRate": "32%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -793,7 +793,7 @@ "ID": 64, "Title": "Minimum Path Sum", "TitleSlug": "minimum-path-sum", - "PassRate": "41%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -805,7 +805,7 @@ "ID": 65, "Title": "Valid Number", "TitleSlug": "valid-number", - "PassRate": "12%", + "PassRate": "14%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -817,7 +817,7 @@ "ID": 66, "Title": "Plus One", "TitleSlug": "plus-one", - "PassRate": "39%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -829,7 +829,7 @@ "ID": 67, "Title": "Add Binary", "TitleSlug": "add-binary", - "PassRate": "34%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -841,7 +841,7 @@ "ID": 68, "Title": "Text Justification", "TitleSlug": "text-justification", - "PassRate": "20%", + "PassRate": "24%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -853,7 +853,7 @@ "ID": 69, "Title": "Sqrt(x)", "TitleSlug": "sqrtx", - "PassRate": "29%", + "PassRate": "32%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -865,7 +865,7 @@ "ID": 70, "Title": "Climbing Stairs", "TitleSlug": "climbing-stairs", - "PassRate": "41%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -877,7 +877,7 @@ "ID": 71, "Title": "Simplify Path", "TitleSlug": "simplify-path", - "PassRate": "26%", + "PassRate": "30%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -889,11 +889,11 @@ "ID": 72, "Title": "Edit Distance", "TitleSlug": "edit-distance", - "PassRate": "32%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -901,11 +901,11 @@ "ID": 73, "Title": "Set Matrix Zeroes", "TitleSlug": "set-matrix-zeroes", - "PassRate": "36%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -913,7 +913,7 @@ "ID": 74, "Title": "Search a 2D Matrix", "TitleSlug": "search-a-2d-matrix", - "PassRate": "34%", + "PassRate": "35%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -925,11 +925,11 @@ "ID": 75, "Title": "Sort Colors", "TitleSlug": "sort-colors", - "PassRate": "39%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -937,11 +937,11 @@ "ID": 76, "Title": "Minimum Window Substring", "TitleSlug": "minimum-window-substring", - "PassRate": "27%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -949,7 +949,7 @@ "ID": 77, "Title": "Combinations", "TitleSlug": "combinations", - "PassRate": "41%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -961,11 +961,11 @@ "ID": 78, "Title": "Subsets", "TitleSlug": "subsets", - "PassRate": "45%", + "PassRate": "56%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -973,7 +973,7 @@ "ID": 79, "Title": "Word Search", "TitleSlug": "word-search", - "PassRate": "28%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -985,11 +985,11 @@ "ID": 80, "Title": "Remove Duplicates from Sorted Array II", "TitleSlug": "remove-duplicates-from-sorted-array-ii", - "PassRate": "37%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -1009,11 +1009,11 @@ "ID": 82, "Title": "Remove Duplicates from Sorted List II", "TitleSlug": "remove-duplicates-from-sorted-list-ii", - "PassRate": "30%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -1021,7 +1021,7 @@ "ID": 83, "Title": "Remove Duplicates from Sorted List", "TitleSlug": "remove-duplicates-from-sorted-list", - "PassRate": "40%", + "PassRate": "43%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1033,11 +1033,11 @@ "ID": 84, "Title": "Largest Rectangle in Histogram", "TitleSlug": "largest-rectangle-in-histogram", - "PassRate": "27%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -1045,7 +1045,7 @@ "ID": 85, "Title": "Maximal Rectangle", "TitleSlug": "maximal-rectangle", - "PassRate": "29%", + "PassRate": "35%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1057,7 +1057,7 @@ "ID": 86, "Title": "Partition List", "TitleSlug": "partition-list", - "PassRate": "33%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1069,7 +1069,7 @@ "ID": 87, "Title": "Scramble String", "TitleSlug": "scramble-string", - "PassRate": "29%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1081,7 +1081,7 @@ "ID": 88, "Title": "Merge Sorted Array", "TitleSlug": "merge-sorted-array", - "PassRate": "32%", + "PassRate": "37%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1093,7 +1093,7 @@ "ID": 89, "Title": "Gray Code", "TitleSlug": "gray-code", - "PassRate": "42%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1105,11 +1105,11 @@ "ID": 90, "Title": "Subsets II", "TitleSlug": "subsets-ii", - "PassRate": "38%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -1117,11 +1117,11 @@ "ID": 91, "Title": "Decode Ways", "TitleSlug": "decode-ways", - "PassRate": "20%", + "PassRate": "23%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -1129,7 +1129,7 @@ "ID": 92, "Title": "Reverse Linked List II", "TitleSlug": "reverse-linked-list-ii", - "PassRate": "31%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1141,7 +1141,7 @@ "ID": 93, "Title": "Restore IP Addresses", "TitleSlug": "restore-ip-addresses", - "PassRate": "28%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1153,7 +1153,7 @@ "ID": 94, "Title": "Binary Tree Inorder Traversal", "TitleSlug": "binary-tree-inorder-traversal", - "PassRate": "50%", + "PassRate": "59%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1165,7 +1165,7 @@ "ID": 95, "Title": "Unique Binary Search Trees II", "TitleSlug": "unique-binary-search-trees-ii", - "PassRate": "32%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1177,7 +1177,7 @@ "ID": 96, "Title": "Unique Binary Search Trees", "TitleSlug": "unique-binary-search-trees", - "PassRate": "42%", + "PassRate": "48%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1189,7 +1189,7 @@ "ID": 97, "Title": "Interleaving String", "TitleSlug": "interleaving-string", - "PassRate": "25%", + "PassRate": "29%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1201,7 +1201,7 @@ "ID": 98, "Title": "Validate Binary Search Tree", "TitleSlug": "validate-binary-search-tree", - "PassRate": "24%", + "PassRate": "26%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1213,7 +1213,7 @@ "ID": 99, "Title": "Recover Binary Search Tree", "TitleSlug": "recover-binary-search-tree", - "PassRate": "31%", + "PassRate": "36%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1225,7 +1225,7 @@ "ID": 100, "Title": "Same Tree", "TitleSlug": "same-tree", - "PassRate": "47%", + "PassRate": "51%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1237,7 +1237,7 @@ "ID": 101, "Title": "Symmetric Tree", "TitleSlug": "symmetric-tree", - "PassRate": "40%", + "PassRate": "44%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1249,7 +1249,7 @@ "ID": 102, "Title": "Binary Tree Level Order Traversal", "TitleSlug": "binary-tree-level-order-traversal", - "PassRate": "43%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1261,7 +1261,7 @@ "ID": 103, "Title": "Binary Tree Zigzag Level Order Traversal", "TitleSlug": "binary-tree-zigzag-level-order-traversal", - "PassRate": "37%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1273,7 +1273,7 @@ "ID": 104, "Title": "Maximum Depth of Binary Tree", "TitleSlug": "maximum-depth-of-binary-tree", - "PassRate": "55%", + "PassRate": "62%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1285,7 +1285,7 @@ "ID": 105, "Title": "Construct Binary Tree from Preorder and Inorder Traversal", "TitleSlug": "construct-binary-tree-from-preorder-and-inorder-traversal", - "PassRate": "34%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1297,7 +1297,7 @@ "ID": 106, "Title": "Construct Binary Tree from Inorder and Postorder Traversal", "TitleSlug": "construct-binary-tree-from-inorder-and-postorder-traversal", - "PassRate": "34%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1309,7 +1309,7 @@ "ID": 107, "Title": "Binary Tree Level Order Traversal II", "TitleSlug": "binary-tree-level-order-traversal-ii", - "PassRate": "42%", + "PassRate": "48%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1321,7 +1321,7 @@ "ID": 108, "Title": "Convert Sorted Array to Binary Search Tree", "TitleSlug": "convert-sorted-array-to-binary-search-tree", - "PassRate": "45%", + "PassRate": "53%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1333,7 +1333,7 @@ "ID": 109, "Title": "Convert Sorted List to Binary Search Tree", "TitleSlug": "convert-sorted-list-to-binary-search-tree", - "PassRate": "36%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1345,7 +1345,7 @@ "ID": 110, "Title": "Balanced Binary Tree", "TitleSlug": "balanced-binary-tree", - "PassRate": "38%", + "PassRate": "42%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1357,7 +1357,7 @@ "ID": 111, "Title": "Minimum Depth of Binary Tree", "TitleSlug": "minimum-depth-of-binary-tree", - "PassRate": "33%", + "PassRate": "36%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1369,7 +1369,7 @@ "ID": 112, "Title": "Path Sum", "TitleSlug": "path-sum", - "PassRate": "35%", + "PassRate": "39%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1381,7 +1381,7 @@ "ID": 113, "Title": "Path Sum II", "TitleSlug": "path-sum-ii", - "PassRate": "36%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1393,7 +1393,7 @@ "ID": 114, "Title": "Flatten Binary Tree to Linked List", "TitleSlug": "flatten-binary-tree-to-linked-list", - "PassRate": "37%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1405,7 +1405,7 @@ "ID": 115, "Title": "Distinct Subsequences", "TitleSlug": "distinct-subsequences", - "PassRate": "32%", + "PassRate": "36%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1417,7 +1417,7 @@ "ID": 116, "Title": "Populating Next Right Pointers in Each Node", "TitleSlug": "populating-next-right-pointers-in-each-node", - "PassRate": "36%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -1429,7 +1429,7 @@ "ID": 117, "Title": "Populating Next Right Pointers in Each Node II", "TitleSlug": "populating-next-right-pointers-in-each-node-ii", - "PassRate": "33%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -1441,7 +1441,7 @@ "ID": 118, "Title": "Pascal's Triangle", "TitleSlug": "pascals-triangle", - "PassRate": "40%", + "PassRate": "48%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1453,7 +1453,7 @@ "ID": 119, "Title": "Pascal's Triangle II", "TitleSlug": "pascals-triangle-ii", - "PassRate": "38%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1465,7 +1465,7 @@ "ID": 120, "Title": "Triangle", "TitleSlug": "triangle", - "PassRate": "35%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1477,7 +1477,7 @@ "ID": 121, "Title": "Best Time to Buy and Sell Stock", "TitleSlug": "best-time-to-buy-and-sell-stock", - "PassRate": "43%", + "PassRate": "48%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1489,7 +1489,7 @@ "ID": 122, "Title": "Best Time to Buy and Sell Stock II", "TitleSlug": "best-time-to-buy-and-sell-stock-ii", - "PassRate": "48%", + "PassRate": "53%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1501,7 +1501,7 @@ "ID": 123, "Title": "Best Time to Buy and Sell Stock III", "TitleSlug": "best-time-to-buy-and-sell-stock-iii", - "PassRate": "30%", + "PassRate": "35%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1513,7 +1513,7 @@ "ID": 124, "Title": "Binary Tree Maximum Path Sum", "TitleSlug": "binary-tree-maximum-path-sum", - "PassRate": "27%", + "PassRate": "31%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1525,7 +1525,7 @@ "ID": 125, "Title": "Valid Palindrome", "TitleSlug": "valid-palindrome", - "PassRate": "27%", + "PassRate": "32%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1537,7 +1537,7 @@ "ID": 126, "Title": "Word Ladder II", "TitleSlug": "word-ladder-ii", - "PassRate": "15%", + "PassRate": "19%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1549,7 +1549,7 @@ "ID": 127, "Title": "Word Ladder", "TitleSlug": "word-ladder", - "PassRate": "20%", + "PassRate": "26%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1561,7 +1561,7 @@ "ID": 128, "Title": "Longest Consecutive Sequence", "TitleSlug": "longest-consecutive-sequence", - "PassRate": "38%", + "PassRate": "43%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1573,7 +1573,7 @@ "ID": 129, "Title": "Sum Root to Leaf Numbers", "TitleSlug": "sum-root-to-leaf-numbers", - "PassRate": "38%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1585,7 +1585,7 @@ "ID": 130, "Title": "Surrounded Regions", "TitleSlug": "surrounded-regions", - "PassRate": "19%", + "PassRate": "24%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1597,7 +1597,7 @@ "ID": 131, "Title": "Palindrome Partitioning", "TitleSlug": "palindrome-partitioning", - "PassRate": "36%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1609,7 +1609,7 @@ "ID": 132, "Title": "Palindrome Partitioning II", "TitleSlug": "palindrome-partitioning-ii", - "PassRate": "25%", + "PassRate": "28%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1621,7 +1621,7 @@ "ID": 133, "Title": "Clone Graph", "TitleSlug": "clone-graph", - "PassRate": "25%", + "PassRate": "29%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -1633,7 +1633,7 @@ "ID": 134, "Title": "Gas Station", "TitleSlug": "gas-station", - "PassRate": "30%", + "PassRate": "35%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1645,7 +1645,7 @@ "ID": 135, "Title": "Candy", "TitleSlug": "candy", - "PassRate": "25%", + "PassRate": "29%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1657,7 +1657,7 @@ "ID": 136, "Title": "Single Number", "TitleSlug": "single-number", - "PassRate": "55%", + "PassRate": "61%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1669,11 +1669,11 @@ "ID": 137, "Title": "Single Number II", "TitleSlug": "single-number-ii", - "PassRate": "42%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -1681,7 +1681,7 @@ "ID": 138, "Title": "Copy List with Random Pointer", "TitleSlug": "copy-list-with-random-pointer", - "PassRate": "25%", + "PassRate": "30%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -1693,7 +1693,7 @@ "ID": 139, "Title": "Word Break", "TitleSlug": "word-break", - "PassRate": "31%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1705,7 +1705,7 @@ "ID": 140, "Title": "Word Break II", "TitleSlug": "word-break-ii", - "PassRate": "24%", + "PassRate": "28%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1717,31 +1717,31 @@ "ID": 141, "Title": "Linked List Cycle", "TitleSlug": "linked-list-cycle", - "PassRate": "35%", + "PassRate": "38%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 142, "Title": "Linked List Cycle II", "TitleSlug": "linked-list-cycle-ii", - "PassRate": "30%", + "PassRate": "34%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 143, "Title": "Reorder List", "TitleSlug": "reorder-list", - "PassRate": "27%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1753,7 +1753,7 @@ "ID": 144, "Title": "Binary Tree Preorder Traversal", "TitleSlug": "binary-tree-preorder-traversal", - "PassRate": "47%", + "PassRate": "53%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1765,7 +1765,7 @@ "ID": 145, "Title": "Binary Tree Postorder Traversal", "TitleSlug": "binary-tree-postorder-traversal", - "PassRate": "42%", + "PassRate": "50%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1777,8 +1777,8 @@ "ID": 146, "Title": "LRU Cache", "TitleSlug": "lru-cache", - "PassRate": "20%", - "Difficulty": "Hard", + "PassRate": "28%", + "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, "IsFavor": true, @@ -1789,7 +1789,7 @@ "ID": 147, "Title": "Insertion Sort List", "TitleSlug": "insertion-sort-list", - "PassRate": "34%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1801,7 +1801,7 @@ "ID": 148, "Title": "Sort List", "TitleSlug": "sort-list", - "PassRate": "30%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1813,7 +1813,7 @@ "ID": 149, "Title": "Max Points on a Line", "TitleSlug": "max-points-on-a-line", - "PassRate": "15%", + "PassRate": "16%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1825,7 +1825,7 @@ "ID": 150, "Title": "Evaluate Reverse Polish Notation", "TitleSlug": "evaluate-reverse-polish-notation", - "PassRate": "28%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1837,7 +1837,7 @@ "ID": 151, "Title": "Reverse Words in a String", "TitleSlug": "reverse-words-in-a-string", - "PassRate": "15%", + "PassRate": "18%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -1849,7 +1849,7 @@ "ID": 152, "Title": "Maximum Product Subarray", "TitleSlug": "maximum-product-subarray", - "PassRate": "26%", + "PassRate": "30%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1861,7 +1861,7 @@ "ID": 153, "Title": "Find Minimum in Rotated Sorted Array", "TitleSlug": "find-minimum-in-rotated-sorted-array", - "PassRate": "41%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1873,7 +1873,7 @@ "ID": 154, "Title": "Find Minimum in Rotated Sorted Array II", "TitleSlug": "find-minimum-in-rotated-sorted-array-ii", - "PassRate": "37%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -1885,7 +1885,7 @@ "ID": 155, "Title": "Min Stack", "TitleSlug": "min-stack", - "PassRate": "31%", + "PassRate": "39%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -1897,7 +1897,7 @@ "ID": 156, "Title": "Binary Tree Upside Down", "TitleSlug": "binary-tree-upside-down", - "PassRate": "46%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -1909,7 +1909,7 @@ "ID": 157, "Title": "Read N Characters Given Read4", "TitleSlug": "read-n-characters-given-read4", - "PassRate": "28%", + "PassRate": "31%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -1921,7 +1921,7 @@ "ID": 158, "Title": "Read N Characters Given Read4 II - Call multiple times", "TitleSlug": "read-n-characters-given-read4-ii-call-multiple-times", - "PassRate": "24%", + "PassRate": "28%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -1933,7 +1933,7 @@ "ID": 159, "Title": "Longest Substring with At Most Two Distinct Characters", "TitleSlug": "longest-substring-with-at-most-two-distinct-characters", - "PassRate": "43%", + "PassRate": "48%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -1945,19 +1945,19 @@ "ID": 160, "Title": "Intersection of Two Linked Lists", "TitleSlug": "intersection-of-two-linked-lists", - "PassRate": "30%", + "PassRate": "36%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 161, "Title": "One Edit Distance", "TitleSlug": "one-edit-distance", - "PassRate": "31%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -1969,7 +1969,7 @@ "ID": 162, "Title": "Find Peak Element", "TitleSlug": "find-peak-element", - "PassRate": "39%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -1993,7 +1993,7 @@ "ID": 164, "Title": "Maximum Gap", "TitleSlug": "maximum-gap", - "PassRate": "30%", + "PassRate": "33%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2005,7 +2005,7 @@ "ID": 165, "Title": "Compare Version Numbers", "TitleSlug": "compare-version-numbers", - "PassRate": "20%", + "PassRate": "25%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2017,7 +2017,7 @@ "ID": 166, "Title": "Fraction to Recurring Decimal", "TitleSlug": "fraction-to-recurring-decimal", - "PassRate": "18%", + "PassRate": "20%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2029,7 +2029,7 @@ "ID": 167, "Title": "Two Sum II - Input array is sorted", "TitleSlug": "two-sum-ii-input-array-is-sorted", - "PassRate": "47%", + "PassRate": "51%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2041,7 +2041,7 @@ "ID": 168, "Title": "Excel Sheet Column Title", "TitleSlug": "excel-sheet-column-title", - "PassRate": "27%", + "PassRate": "29%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2053,7 +2053,7 @@ "ID": 169, "Title": "Majority Element", "TitleSlug": "majority-element", - "PassRate": "48%", + "PassRate": "54%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2065,7 +2065,7 @@ "ID": 170, "Title": "Two Sum III - Data structure design", "TitleSlug": "two-sum-iii-data-structure-design", - "PassRate": "26%", + "PassRate": "31%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -2077,7 +2077,7 @@ "ID": 171, "Title": "Excel Sheet Column Number", "TitleSlug": "excel-sheet-column-number", - "PassRate": "48%", + "PassRate": "52%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2101,19 +2101,19 @@ "ID": 173, "Title": "Binary Search Tree Iterator", "TitleSlug": "binary-search-tree-iterator", - "PassRate": "43%", + "PassRate": "51%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 174, "Title": "Dungeon Game", "TitleSlug": "dungeon-game", - "PassRate": "24%", + "PassRate": "28%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2173,7 +2173,7 @@ "ID": 179, "Title": "Largest Number", "TitleSlug": "largest-number", - "PassRate": "23%", + "PassRate": "26%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2257,7 +2257,7 @@ "ID": 186, "Title": "Reverse Words in a String II", "TitleSlug": "reverse-words-in-a-string-ii", - "PassRate": "30%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -2269,7 +2269,7 @@ "ID": 187, "Title": "Repeated DNA Sequences", "TitleSlug": "repeated-dna-sequences", - "PassRate": "33%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2281,7 +2281,7 @@ "ID": 188, "Title": "Best Time to Buy and Sell Stock IV", "TitleSlug": "best-time-to-buy-and-sell-stock-iv", - "PassRate": "25%", + "PassRate": "27%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2293,7 +2293,7 @@ "ID": 189, "Title": "Rotate Array", "TitleSlug": "rotate-array", - "PassRate": "25%", + "PassRate": "31%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2305,25 +2305,25 @@ "ID": 190, "Title": "Reverse Bits", "TitleSlug": "reverse-bits", - "PassRate": "29%", + "PassRate": "33%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 191, "Title": "Number of 1 Bits", "TitleSlug": "number-of-1-bits", - "PassRate": "40%", + "PassRate": "45%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 0, @@ -2401,7 +2401,7 @@ "ID": 198, "Title": "House Robber", "TitleSlug": "house-robber", - "PassRate": "40%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2413,7 +2413,7 @@ "ID": 199, "Title": "Binary Tree Right Side View", "TitleSlug": "binary-tree-right-side-view", - "PassRate": "42%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2425,7 +2425,7 @@ "ID": 200, "Title": "Number of Islands", "TitleSlug": "number-of-islands", - "PassRate": "36%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2437,7 +2437,7 @@ "ID": 201, "Title": "Bitwise AND of Numbers Range", "TitleSlug": "bitwise-and-of-numbers-range", - "PassRate": "34%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2449,7 +2449,7 @@ "ID": 202, "Title": "Happy Number", "TitleSlug": "happy-number", - "PassRate": "41%", + "PassRate": "47%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2461,7 +2461,7 @@ "ID": 203, "Title": "Remove Linked List Elements", "TitleSlug": "remove-linked-list-elements", - "PassRate": "33%", + "PassRate": "36%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2473,7 +2473,7 @@ "ID": 204, "Title": "Count Primes", "TitleSlug": "count-primes", - "PassRate": "26%", + "PassRate": "30%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2485,7 +2485,7 @@ "ID": 205, "Title": "Isomorphic Strings", "TitleSlug": "isomorphic-strings", - "PassRate": "34%", + "PassRate": "38%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2497,7 +2497,7 @@ "ID": 206, "Title": "Reverse Linked List", "TitleSlug": "reverse-linked-list", - "PassRate": "47%", + "PassRate": "57%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2509,7 +2509,7 @@ "ID": 207, "Title": "Course Schedule", "TitleSlug": "course-schedule", - "PassRate": "33%", + "PassRate": "39%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2521,7 +2521,7 @@ "ID": 208, "Title": "Implement Trie (Prefix Tree)", "TitleSlug": "implement-trie-prefix-tree", - "PassRate": "31%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2533,7 +2533,7 @@ "ID": 209, "Title": "Minimum Size Subarray Sum", "TitleSlug": "minimum-size-subarray-sum", - "PassRate": "32%", + "PassRate": "35%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2545,7 +2545,7 @@ "ID": 210, "Title": "Course Schedule II", "TitleSlug": "course-schedule-ii", - "PassRate": "30%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2557,7 +2557,7 @@ "ID": 211, "Title": "Add and Search Word - Data structure design", "TitleSlug": "add-and-search-word-data-structure-design", - "PassRate": "25%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2569,7 +2569,7 @@ "ID": 212, "Title": "Word Search II", "TitleSlug": "word-search-ii", - "PassRate": "25%", + "PassRate": "30%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2581,7 +2581,7 @@ "ID": 213, "Title": "House Robber II", "TitleSlug": "house-robber-ii", - "PassRate": "34%", + "PassRate": "35%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2593,7 +2593,7 @@ "ID": 214, "Title": "Shortest Palindrome", "TitleSlug": "shortest-palindrome", - "PassRate": "25%", + "PassRate": "28%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2605,7 +2605,7 @@ "ID": 215, "Title": "Kth Largest Element in an Array", "TitleSlug": "kth-largest-element-in-an-array", - "PassRate": "41%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2617,7 +2617,7 @@ "ID": 216, "Title": "Combination Sum III", "TitleSlug": "combination-sum-iii", - "PassRate": "47%", + "PassRate": "53%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2629,7 +2629,7 @@ "ID": 217, "Title": "Contains Duplicate", "TitleSlug": "contains-duplicate", - "PassRate": "47%", + "PassRate": "53%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2641,7 +2641,7 @@ "ID": 218, "Title": "The Skyline Problem", "TitleSlug": "the-skyline-problem", - "PassRate": "29%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2653,7 +2653,7 @@ "ID": 219, "Title": "Contains Duplicate II", "TitleSlug": "contains-duplicate-ii", - "PassRate": "32%", + "PassRate": "36%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2665,7 +2665,7 @@ "ID": 220, "Title": "Contains Duplicate III", "TitleSlug": "contains-duplicate-iii", - "PassRate": "18%", + "PassRate": "20%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2677,7 +2677,7 @@ "ID": 221, "Title": "Maximal Square", "TitleSlug": "maximal-square", - "PassRate": "30%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2689,19 +2689,19 @@ "ID": 222, "Title": "Count Complete Tree Nodes", "TitleSlug": "count-complete-tree-nodes", - "PassRate": "27%", + "PassRate": "38%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 223, "Title": "Rectangle Area", "TitleSlug": "rectangle-area", - "PassRate": "33%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2713,7 +2713,7 @@ "ID": 224, "Title": "Basic Calculator", "TitleSlug": "basic-calculator", - "PassRate": "28%", + "PassRate": "34%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2725,7 +2725,7 @@ "ID": 225, "Title": "Implement Stack using Queues", "TitleSlug": "implement-stack-using-queues", - "PassRate": "34%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2737,7 +2737,7 @@ "ID": 226, "Title": "Invert Binary Tree", "TitleSlug": "invert-binary-tree", - "PassRate": "53%", + "PassRate": "60%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2749,7 +2749,7 @@ "ID": 227, "Title": "Basic Calculator II", "TitleSlug": "basic-calculator-ii", - "PassRate": "30%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2761,7 +2761,7 @@ "ID": 228, "Title": "Summary Ranges", "TitleSlug": "summary-ranges", - "PassRate": "32%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2773,7 +2773,7 @@ "ID": 229, "Title": "Majority Element II", "TitleSlug": "majority-element-ii", - "PassRate": "29%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2785,7 +2785,7 @@ "ID": 230, "Title": "Kth Smallest Element in a BST", "TitleSlug": "kth-smallest-element-in-a-bst", - "PassRate": "45%", + "PassRate": "54%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2797,7 +2797,7 @@ "ID": 231, "Title": "Power of Two", "TitleSlug": "power-of-two", - "PassRate": "40%", + "PassRate": "42%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2809,7 +2809,7 @@ "ID": 232, "Title": "Implement Queue using Stacks", "TitleSlug": "implement-queue-using-stacks", - "PassRate": "38%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2821,7 +2821,7 @@ "ID": 233, "Title": "Number of Digit One", "TitleSlug": "number-of-digit-one", - "PassRate": "29%", + "PassRate": "30%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2833,7 +2833,7 @@ "ID": 234, "Title": "Palindrome Linked List", "TitleSlug": "palindrome-linked-list", - "PassRate": "33%", + "PassRate": "37%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2845,43 +2845,43 @@ "ID": 235, "Title": "Lowest Common Ancestor of a Binary Search Tree", "TitleSlug": "lowest-common-ancestor-of-a-binary-search-tree", - "PassRate": "39%", + "PassRate": "46%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 236, "Title": "Lowest Common Ancestor of a Binary Tree", "TitleSlug": "lowest-common-ancestor-of-a-binary-tree", - "PassRate": "29%", + "PassRate": "40%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 237, "Title": "Delete Node in a Linked List", "TitleSlug": "delete-node-in-a-linked-list", - "PassRate": "47%", + "PassRate": "56%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 238, "Title": "Product of Array Except Self", "TitleSlug": "product-of-array-except-self", - "PassRate": "50%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2893,7 +2893,7 @@ "ID": 239, "Title": "Sliding Window Maximum", "TitleSlug": "sliding-window-maximum", - "PassRate": "34%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -2905,7 +2905,7 @@ "ID": 240, "Title": "Search a 2D Matrix II", "TitleSlug": "search-a-2d-matrix-ii", - "PassRate": "39%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2917,7 +2917,7 @@ "ID": 241, "Title": "Different Ways to Add Parentheses", "TitleSlug": "different-ways-to-add-parentheses", - "PassRate": "46%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -2929,7 +2929,7 @@ "ID": 242, "Title": "Valid Anagram", "TitleSlug": "valid-anagram", - "PassRate": "47%", + "PassRate": "54%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -2941,7 +2941,7 @@ "ID": 243, "Title": "Shortest Word Distance", "TitleSlug": "shortest-word-distance", - "PassRate": "53%", + "PassRate": "58%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -2953,7 +2953,7 @@ "ID": 244, "Title": "Shortest Word Distance II", "TitleSlug": "shortest-word-distance-ii", - "PassRate": "41%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -2965,7 +2965,7 @@ "ID": 245, "Title": "Shortest Word Distance III", "TitleSlug": "shortest-word-distance-iii", - "PassRate": "51%", + "PassRate": "54%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -2977,7 +2977,7 @@ "ID": 246, "Title": "Strobogrammatic Number", "TitleSlug": "strobogrammatic-number", - "PassRate": "40%", + "PassRate": "43%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -2989,7 +2989,7 @@ "ID": 247, "Title": "Strobogrammatic Number II", "TitleSlug": "strobogrammatic-number-ii", - "PassRate": "41%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3001,7 +3001,7 @@ "ID": 248, "Title": "Strobogrammatic Number III", "TitleSlug": "strobogrammatic-number-iii", - "PassRate": "32%", + "PassRate": "37%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3013,7 +3013,7 @@ "ID": 249, "Title": "Group Shifted Strings", "TitleSlug": "group-shifted-strings", - "PassRate": "44%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3025,7 +3025,7 @@ "ID": 250, "Title": "Count Univalue Subtrees", "TitleSlug": "count-univalue-subtrees", - "PassRate": "44%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3037,7 +3037,7 @@ "ID": 251, "Title": "Flatten 2D Vector", "TitleSlug": "flatten-2d-vector", - "PassRate": "41%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3049,7 +3049,7 @@ "ID": 252, "Title": "Meeting Rooms", "TitleSlug": "meeting-rooms", - "PassRate": "49%", + "PassRate": "53%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -3061,7 +3061,7 @@ "ID": 253, "Title": "Meeting Rooms II", "TitleSlug": "meeting-rooms-ii", - "PassRate": "39%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3073,7 +3073,7 @@ "ID": 254, "Title": "Factor Combinations", "TitleSlug": "factor-combinations", - "PassRate": "43%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3085,7 +3085,7 @@ "ID": 255, "Title": "Verify Preorder Sequence in Binary Search Tree", "TitleSlug": "verify-preorder-sequence-in-binary-search-tree", - "PassRate": "41%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3097,7 +3097,7 @@ "ID": 256, "Title": "Paint House", "TitleSlug": "paint-house", - "PassRate": "46%", + "PassRate": "50%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -3109,7 +3109,7 @@ "ID": 257, "Title": "Binary Tree Paths", "TitleSlug": "binary-tree-paths", - "PassRate": "41%", + "PassRate": "47%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -3121,7 +3121,7 @@ "ID": 258, "Title": "Add Digits", "TitleSlug": "add-digits", - "PassRate": "51%", + "PassRate": "55%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -3133,7 +3133,7 @@ "ID": 259, "Title": "3Sum Smaller", "TitleSlug": "3sum-smaller", - "PassRate": "42%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3145,7 +3145,7 @@ "ID": 260, "Title": "Single Number III", "TitleSlug": "single-number-iii", - "PassRate": "53%", + "PassRate": "58%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3157,7 +3157,7 @@ "ID": 261, "Title": "Graph Valid Tree", "TitleSlug": "graph-valid-tree", - "PassRate": "38%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3181,7 +3181,7 @@ "ID": 263, "Title": "Ugly Number", "TitleSlug": "ugly-number", - "PassRate": "39%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -3193,7 +3193,7 @@ "ID": 264, "Title": "Ugly Number II", "TitleSlug": "ugly-number-ii", - "PassRate": "33%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3205,7 +3205,7 @@ "ID": 265, "Title": "Paint House II", "TitleSlug": "paint-house-ii", - "PassRate": "38%", + "PassRate": "42%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3217,7 +3217,7 @@ "ID": 266, "Title": "Palindrome Permutation", "TitleSlug": "palindrome-permutation", - "PassRate": "58%", + "PassRate": "60%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -3229,7 +3229,7 @@ "ID": 267, "Title": "Palindrome Permutation II", "TitleSlug": "palindrome-permutation-ii", - "PassRate": "32%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3241,7 +3241,7 @@ "ID": 268, "Title": "Missing Number", "TitleSlug": "missing-number", - "PassRate": "45%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -3253,7 +3253,7 @@ "ID": 269, "Title": "Alien Dictionary", "TitleSlug": "alien-dictionary", - "PassRate": "26%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3265,7 +3265,7 @@ "ID": 270, "Title": "Closest Binary Search Tree Value", "TitleSlug": "closest-binary-search-tree-value", - "PassRate": "40%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -3277,7 +3277,7 @@ "ID": 271, "Title": "Encode and Decode Strings", "TitleSlug": "encode-and-decode-strings", - "PassRate": "25%", + "PassRate": "28%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3289,7 +3289,7 @@ "ID": 272, "Title": "Closest Binary Search Tree Value II", "TitleSlug": "closest-binary-search-tree-value-ii", - "PassRate": "40%", + "PassRate": "47%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3301,7 +3301,7 @@ "ID": 273, "Title": "Integer to English Words", "TitleSlug": "integer-to-english-words", - "PassRate": "22%", + "PassRate": "25%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3313,7 +3313,7 @@ "ID": 274, "Title": "H-Index", "TitleSlug": "h-index", - "PassRate": "33%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3325,7 +3325,7 @@ "ID": 275, "Title": "H-Index II", "TitleSlug": "h-index-ii", - "PassRate": "34%", + "PassRate": "35%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3337,7 +3337,7 @@ "ID": 276, "Title": "Paint Fence", "TitleSlug": "paint-fence", - "PassRate": "34%", + "PassRate": "37%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -3349,7 +3349,7 @@ "ID": 277, "Title": "Find the Celebrity", "TitleSlug": "find-the-celebrity", - "PassRate": "35%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3361,7 +3361,7 @@ "ID": 278, "Title": "First Bad Version", "TitleSlug": "first-bad-version", - "PassRate": "25%", + "PassRate": "31%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": false, @@ -3373,7 +3373,7 @@ "ID": 279, "Title": "Perfect Squares", "TitleSlug": "perfect-squares", - "PassRate": "37%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3385,7 +3385,7 @@ "ID": 280, "Title": "Wiggle Sort", "TitleSlug": "wiggle-sort", - "PassRate": "58%", + "PassRate": "61%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3397,7 +3397,7 @@ "ID": 281, "Title": "Zigzag Iterator", "TitleSlug": "zigzag-iterator", - "PassRate": "52%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3409,7 +3409,7 @@ "ID": 282, "Title": "Expression Add Operators", "TitleSlug": "expression-add-operators", - "PassRate": "30%", + "PassRate": "34%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3421,7 +3421,7 @@ "ID": 283, "Title": "Move Zeroes", "TitleSlug": "move-zeroes", - "PassRate": "51%", + "PassRate": "55%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -3433,7 +3433,7 @@ "ID": 284, "Title": "Peeking Iterator", "TitleSlug": "peeking-iterator", - "PassRate": "35%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -3445,7 +3445,7 @@ "ID": 285, "Title": "Inorder Successor in BST", "TitleSlug": "inorder-successor-in-bst", - "PassRate": "35%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3457,7 +3457,7 @@ "ID": 286, "Title": "Walls and Gates", "TitleSlug": "walls-and-gates", - "PassRate": "45%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3469,7 +3469,7 @@ "ID": 287, "Title": "Find the Duplicate Number", "TitleSlug": "find-the-duplicate-number", - "PassRate": "44%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3481,7 +3481,7 @@ "ID": 288, "Title": "Unique Word Abbreviation", "TitleSlug": "unique-word-abbreviation", - "PassRate": "18%", + "PassRate": "20%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3493,7 +3493,7 @@ "ID": 289, "Title": "Game of Life", "TitleSlug": "game-of-life", - "PassRate": "37%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3505,7 +3505,7 @@ "ID": 290, "Title": "Word Pattern", "TitleSlug": "word-pattern", - "PassRate": "33%", + "PassRate": "35%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -3517,7 +3517,7 @@ "ID": 291, "Title": "Word Pattern II", "TitleSlug": "word-pattern-ii", - "PassRate": "38%", + "PassRate": "42%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3541,7 +3541,7 @@ "ID": 293, "Title": "Flip Game", "TitleSlug": "flip-game", - "PassRate": "57%", + "PassRate": "59%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -3553,7 +3553,7 @@ "ID": 294, "Title": "Flip Game II", "TitleSlug": "flip-game-ii", - "PassRate": "47%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3565,7 +3565,7 @@ "ID": 295, "Title": "Find Median from Data Stream", "TitleSlug": "find-median-from-data-stream", - "PassRate": "30%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3577,7 +3577,7 @@ "ID": 296, "Title": "Best Meeting Point", "TitleSlug": "best-meeting-point", - "PassRate": "52%", + "PassRate": "56%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3589,7 +3589,7 @@ "ID": 297, "Title": "Serialize and Deserialize Binary Tree", "TitleSlug": "serialize-and-deserialize-binary-tree", - "PassRate": "35%", + "PassRate": "43%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": false, @@ -3601,7 +3601,7 @@ "ID": 298, "Title": "Binary Tree Longest Consecutive Sequence", "TitleSlug": "binary-tree-longest-consecutive-sequence", - "PassRate": "41%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3613,8 +3613,8 @@ "ID": 299, "Title": "Bulls and Cows", "TitleSlug": "bulls-and-cows", - "PassRate": "36%", - "Difficulty": "Medium", + "PassRate": "40%", + "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, "IsFavor": false, @@ -3625,7 +3625,7 @@ "ID": 300, "Title": "Longest Increasing Subsequence", "TitleSlug": "longest-increasing-subsequence", - "PassRate": "38%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3637,7 +3637,7 @@ "ID": 301, "Title": "Remove Invalid Parentheses", "TitleSlug": "remove-invalid-parentheses", - "PassRate": "35%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3649,7 +3649,7 @@ "ID": 302, "Title": "Smallest Rectangle Enclosing Black Pixels", "TitleSlug": "smallest-rectangle-enclosing-black-pixels", - "PassRate": "46%", + "PassRate": "50%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3661,7 +3661,7 @@ "ID": 303, "Title": "Range Sum Query - Immutable", "TitleSlug": "range-sum-query-immutable", - "PassRate": "32%", + "PassRate": "40%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -3673,7 +3673,7 @@ "ID": 304, "Title": "Range Sum Query 2D - Immutable", "TitleSlug": "range-sum-query-2d-immutable", - "PassRate": "27%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3685,7 +3685,7 @@ "ID": 305, "Title": "Number of Islands II", "TitleSlug": "number-of-islands-ii", - "PassRate": "39%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3697,7 +3697,7 @@ "ID": 306, "Title": "Additive Number", "TitleSlug": "additive-number", - "PassRate": "27%", + "PassRate": "28%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3709,7 +3709,7 @@ "ID": 307, "Title": "Range Sum Query - Mutable", "TitleSlug": "range-sum-query-mutable", - "PassRate": "22%", + "PassRate": "30%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3721,7 +3721,7 @@ "ID": 308, "Title": "Range Sum Query 2D - Mutable", "TitleSlug": "range-sum-query-2d-mutable", - "PassRate": "26%", + "PassRate": "33%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3733,7 +3733,7 @@ "ID": 309, "Title": "Best Time to Buy and Sell Stock with Cooldown", "TitleSlug": "best-time-to-buy-and-sell-stock-with-cooldown", - "PassRate": "42%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3745,7 +3745,7 @@ "ID": 310, "Title": "Minimum Height Trees", "TitleSlug": "minimum-height-trees", - "PassRate": "28%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3757,7 +3757,7 @@ "ID": 311, "Title": "Sparse Matrix Multiplication", "TitleSlug": "sparse-matrix-multiplication", - "PassRate": "52%", + "PassRate": "58%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3769,7 +3769,7 @@ "ID": 312, "Title": "Burst Balloons", "TitleSlug": "burst-balloons", - "PassRate": "43%", + "PassRate": "48%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3781,7 +3781,7 @@ "ID": 313, "Title": "Super Ugly Number", "TitleSlug": "super-ugly-number", - "PassRate": "38%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3793,7 +3793,7 @@ "ID": 314, "Title": "Binary Tree Vertical Order Traversal", "TitleSlug": "binary-tree-vertical-order-traversal", - "PassRate": "38%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3805,11 +3805,11 @@ "ID": 315, "Title": "Count of Smaller Numbers After Self", "TitleSlug": "count-of-smaller-numbers-after-self", - "PassRate": "35%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -3817,7 +3817,7 @@ "ID": 316, "Title": "Remove Duplicate Letters", "TitleSlug": "remove-duplicate-letters", - "PassRate": "30%", + "PassRate": "33%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3829,7 +3829,7 @@ "ID": 317, "Title": "Shortest Distance from All Buildings", "TitleSlug": "shortest-distance-from-all-buildings", - "PassRate": "34%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -3841,7 +3841,7 @@ "ID": 318, "Title": "Maximum Product of Word Lengths", "TitleSlug": "maximum-product-of-word-lengths", - "PassRate": "45%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3853,7 +3853,7 @@ "ID": 319, "Title": "Bulb Switcher", "TitleSlug": "bulb-switcher", - "PassRate": "42%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3865,7 +3865,7 @@ "ID": 320, "Title": "Generalized Abbreviation", "TitleSlug": "generalized-abbreviation", - "PassRate": "46%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3877,7 +3877,7 @@ "ID": 321, "Title": "Create Maximum Number", "TitleSlug": "create-maximum-number", - "PassRate": "24%", + "PassRate": "25%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3889,7 +3889,7 @@ "ID": 322, "Title": "Coin Change", "TitleSlug": "coin-change", - "PassRate": "26%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3901,7 +3901,7 @@ "ID": 323, "Title": "Number of Connected Components in an Undirected Graph", "TitleSlug": "number-of-connected-components-in-an-undirected-graph", - "PassRate": "49%", + "PassRate": "53%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3913,7 +3913,7 @@ "ID": 324, "Title": "Wiggle Sort II", "TitleSlug": "wiggle-sort-ii", - "PassRate": "26%", + "PassRate": "28%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3925,7 +3925,7 @@ "ID": 325, "Title": "Maximum Size Subarray Sum Equals k", "TitleSlug": "maximum-size-subarray-sum-equals-k", - "PassRate": "43%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -3937,7 +3937,7 @@ "ID": 326, "Title": "Power of Three", "TitleSlug": "power-of-three", - "PassRate": "40%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -3949,7 +3949,7 @@ "ID": 327, "Title": "Count of Range Sum", "TitleSlug": "count-of-range-sum", - "PassRate": "30%", + "PassRate": "33%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3961,7 +3961,7 @@ "ID": 328, "Title": "Odd Even Linked List", "TitleSlug": "odd-even-linked-list", - "PassRate": "44%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -3973,7 +3973,7 @@ "ID": 329, "Title": "Longest Increasing Path in a Matrix", "TitleSlug": "longest-increasing-path-in-a-matrix", - "PassRate": "37%", + "PassRate": "41%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3985,7 +3985,7 @@ "ID": 330, "Title": "Patching Array", "TitleSlug": "patching-array", - "PassRate": "32%", + "PassRate": "33%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -3997,7 +3997,7 @@ "ID": 331, "Title": "Verify Preorder Serialization of a Binary Tree", "TitleSlug": "verify-preorder-serialization-of-a-binary-tree", - "PassRate": "37%", + "PassRate": "39%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4009,7 +4009,7 @@ "ID": 332, "Title": "Reconstruct Itinerary", "TitleSlug": "reconstruct-itinerary", - "PassRate": "30%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4021,7 +4021,7 @@ "ID": 333, "Title": "Largest BST Subtree", "TitleSlug": "largest-bst-subtree", - "PassRate": "31%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4045,7 +4045,7 @@ "ID": 335, "Title": "Self Crossing", "TitleSlug": "self-crossing", - "PassRate": "26%", + "PassRate": "27%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4057,7 +4057,7 @@ "ID": 336, "Title": "Palindrome Pairs", "TitleSlug": "palindrome-pairs", - "PassRate": "27%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4069,7 +4069,7 @@ "ID": 337, "Title": "House Robber III", "TitleSlug": "house-robber-iii", - "PassRate": "44%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4081,7 +4081,7 @@ "ID": 338, "Title": "Counting Bits", "TitleSlug": "counting-bits", - "PassRate": "62%", + "PassRate": "65%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4093,7 +4093,7 @@ "ID": 339, "Title": "Nested List Weight Sum", "TitleSlug": "nested-list-weight-sum", - "PassRate": "63%", + "PassRate": "70%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -4105,7 +4105,7 @@ "ID": 340, "Title": "Longest Substring with At Most K Distinct Characters", "TitleSlug": "longest-substring-with-at-most-k-distinct-characters", - "PassRate": "38%", + "PassRate": "41%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -4117,7 +4117,7 @@ "ID": 341, "Title": "Flatten Nested List Iterator", "TitleSlug": "flatten-nested-list-iterator", - "PassRate": "43%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -4129,7 +4129,7 @@ "ID": 342, "Title": "Power of Four", "TitleSlug": "power-of-four", - "PassRate": "39%", + "PassRate": "40%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4141,7 +4141,7 @@ "ID": 343, "Title": "Integer Break", "TitleSlug": "integer-break", - "PassRate": "46%", + "PassRate": "48%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4153,7 +4153,7 @@ "ID": 344, "Title": "Reverse String", "TitleSlug": "reverse-string", - "PassRate": "60%", + "PassRate": "64%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4165,7 +4165,7 @@ "ID": 345, "Title": "Reverse Vowels of a String", "TitleSlug": "reverse-vowels-of-a-string", - "PassRate": "39%", + "PassRate": "42%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4177,7 +4177,7 @@ "ID": 346, "Title": "Moving Average from Data Stream", "TitleSlug": "moving-average-from-data-stream", - "PassRate": "60%", + "PassRate": "68%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -4189,7 +4189,7 @@ "ID": 347, "Title": "Top K Frequent Elements", "TitleSlug": "top-k-frequent-elements", - "PassRate": "49%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4201,7 +4201,7 @@ "ID": 348, "Title": "Design Tic-Tac-Toe", "TitleSlug": "design-tic-tac-toe", - "PassRate": "46%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4213,7 +4213,7 @@ "ID": 349, "Title": "Intersection of Two Arrays", "TitleSlug": "intersection-of-two-arrays", - "PassRate": "48%", + "PassRate": "57%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4225,7 +4225,7 @@ "ID": 350, "Title": "Intersection of Two Arrays II", "TitleSlug": "intersection-of-two-arrays-ii", - "PassRate": "44%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4237,7 +4237,7 @@ "ID": 351, "Title": "Android Unlock Patterns", "TitleSlug": "android-unlock-patterns", - "PassRate": "44%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4249,7 +4249,7 @@ "ID": 352, "Title": "Data Stream as Disjoint Intervals", "TitleSlug": "data-stream-as-disjoint-intervals", - "PassRate": "41%", + "PassRate": "44%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4261,7 +4261,7 @@ "ID": 353, "Title": "Design Snake Game", "TitleSlug": "design-snake-game", - "PassRate": "27%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4273,7 +4273,7 @@ "ID": 354, "Title": "Russian Doll Envelopes", "TitleSlug": "russian-doll-envelopes", - "PassRate": "32%", + "PassRate": "34%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4285,7 +4285,7 @@ "ID": 355, "Title": "Design Twitter", "TitleSlug": "design-twitter", - "PassRate": "25%", + "PassRate": "28%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4297,7 +4297,7 @@ "ID": 356, "Title": "Line Reflection", "TitleSlug": "line-reflection", - "PassRate": "30%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4309,7 +4309,7 @@ "ID": 357, "Title": "Count Numbers with Unique Digits", "TitleSlug": "count-numbers-with-unique-digits", - "PassRate": "46%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4321,7 +4321,7 @@ "ID": 358, "Title": "Rearrange String k Distance Apart", "TitleSlug": "rearrange-string-k-distance-apart", - "PassRate": "31%", + "PassRate": "33%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -4333,7 +4333,7 @@ "ID": 359, "Title": "Logger Rate Limiter", "TitleSlug": "logger-rate-limiter", - "PassRate": "61%", + "PassRate": "67%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -4345,7 +4345,7 @@ "ID": 360, "Title": "Sort Transformed Array", "TitleSlug": "sort-transformed-array", - "PassRate": "45%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4357,7 +4357,7 @@ "ID": 361, "Title": "Bomb Enemy", "TitleSlug": "bomb-enemy", - "PassRate": "40%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4369,7 +4369,7 @@ "ID": 362, "Title": "Design Hit Counter", "TitleSlug": "design-hit-counter", - "PassRate": "55%", + "PassRate": "60%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4381,7 +4381,7 @@ "ID": 363, "Title": "Max Sum of Rectangle No Larger Than K", "TitleSlug": "max-sum-of-rectangle-no-larger-than-k", - "PassRate": "33%", + "PassRate": "35%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4393,7 +4393,7 @@ "ID": 364, "Title": "Nested List Weight Sum II", "TitleSlug": "nested-list-weight-sum-ii", - "PassRate": "54%", + "PassRate": "59%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4405,7 +4405,7 @@ "ID": 365, "Title": "Water and Jug Problem", "TitleSlug": "water-and-jug-problem", - "PassRate": "28%", + "PassRate": "29%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4417,7 +4417,7 @@ "ID": 366, "Title": "Find Leaves of Binary Tree", "TitleSlug": "find-leaves-of-binary-tree", - "PassRate": "61%", + "PassRate": "68%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4429,7 +4429,7 @@ "ID": 367, "Title": "Valid Perfect Square", "TitleSlug": "valid-perfect-square", - "PassRate": "38%", + "PassRate": "40%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4441,7 +4441,7 @@ "ID": 368, "Title": "Largest Divisible Subset", "TitleSlug": "largest-divisible-subset", - "PassRate": "33%", + "PassRate": "35%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4453,7 +4453,7 @@ "ID": 369, "Title": "Plus One Linked List", "TitleSlug": "plus-one-linked-list", - "PassRate": "54%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4465,7 +4465,7 @@ "ID": 370, "Title": "Range Addition", "TitleSlug": "range-addition", - "PassRate": "57%", + "PassRate": "61%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4489,7 +4489,7 @@ "ID": 372, "Title": "Super Pow", "TitleSlug": "super-pow", - "PassRate": "34%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4501,7 +4501,7 @@ "ID": 373, "Title": "Find K Pairs with Smallest Sums", "TitleSlug": "find-k-pairs-with-smallest-sums", - "PassRate": "31%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4513,7 +4513,7 @@ "ID": 374, "Title": "Guess Number Higher or Lower", "TitleSlug": "guess-number-higher-or-lower", - "PassRate": "36%", + "PassRate": "40%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": false, @@ -4525,7 +4525,7 @@ "ID": 375, "Title": "Guess Number Higher or Lower II", "TitleSlug": "guess-number-higher-or-lower-ii", - "PassRate": "36%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4537,7 +4537,7 @@ "ID": 376, "Title": "Wiggle Subsequence", "TitleSlug": "wiggle-subsequence", - "PassRate": "36%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4549,7 +4549,7 @@ "ID": 377, "Title": "Combination Sum IV", "TitleSlug": "combination-sum-iv", - "PassRate": "42%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4561,7 +4561,7 @@ "ID": 378, "Title": "Kth Smallest Element in a Sorted Matrix", "TitleSlug": "kth-smallest-element-in-a-sorted-matrix", - "PassRate": "45%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4573,7 +4573,7 @@ "ID": 379, "Title": "Design Phone Directory", "TitleSlug": "design-phone-directory", - "PassRate": "36%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -4585,7 +4585,7 @@ "ID": 380, "Title": "Insert Delete GetRandom O(1)", "TitleSlug": "insert-delete-getrandom-o1", - "PassRate": "40%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4597,7 +4597,7 @@ "ID": 381, "Title": "Insert Delete GetRandom O(1) - Duplicates allowed", "TitleSlug": "insert-delete-getrandom-o1-duplicates-allowed", - "PassRate": "29%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4609,7 +4609,7 @@ "ID": 382, "Title": "Linked List Random Node", "TitleSlug": "linked-list-random-node", - "PassRate": "47%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4621,7 +4621,7 @@ "ID": 383, "Title": "Ransom Note", "TitleSlug": "ransom-note", - "PassRate": "47%", + "PassRate": "50%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4633,7 +4633,7 @@ "ID": 384, "Title": "Shuffle an Array", "TitleSlug": "shuffle-an-array", - "PassRate": "47%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4645,7 +4645,7 @@ "ID": 385, "Title": "Mini Parser", "TitleSlug": "mini-parser", - "PassRate": "30%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4657,19 +4657,19 @@ "ID": 386, "Title": "Lexicographical Numbers", "TitleSlug": "lexicographical-numbers", - "PassRate": "42%", + "PassRate": "48%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": true + "HasNoGoOption": false }, { "ID": 387, "Title": "First Unique Character in a String", "TitleSlug": "first-unique-character-in-a-string", - "PassRate": "47%", + "PassRate": "50%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4681,7 +4681,7 @@ "ID": 388, "Title": "Longest Absolute File Path", "TitleSlug": "longest-absolute-file-path", - "PassRate": "37%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4693,7 +4693,7 @@ "ID": 389, "Title": "Find the Difference", "TitleSlug": "find-the-difference", - "PassRate": "51%", + "PassRate": "53%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4705,7 +4705,7 @@ "ID": 390, "Title": "Elimination Game", "TitleSlug": "elimination-game", - "PassRate": "42%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4717,7 +4717,7 @@ "ID": 391, "Title": "Perfect Rectangle", "TitleSlug": "perfect-rectangle", - "PassRate": "27%", + "PassRate": "28%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4729,8 +4729,8 @@ "ID": 392, "Title": "Is Subsequence", "TitleSlug": "is-subsequence", - "PassRate": "44%", - "Difficulty": "Medium", + "PassRate": "47%", + "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, "IsFavor": true, @@ -4741,7 +4741,7 @@ "ID": 393, "Title": "UTF-8 Validation", "TitleSlug": "utf-8-validation", - "PassRate": "34%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4753,7 +4753,7 @@ "ID": 394, "Title": "Decode String", "TitleSlug": "decode-string", - "PassRate": "42%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4765,7 +4765,7 @@ "ID": 395, "Title": "Longest Substring with At Least K Repeating Characters", "TitleSlug": "longest-substring-with-at-least-k-repeating-characters", - "PassRate": "35%", + "PassRate": "39%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4777,7 +4777,7 @@ "ID": 396, "Title": "Rotate Function", "TitleSlug": "rotate-function", - "PassRate": "33%", + "PassRate": "35%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4789,7 +4789,7 @@ "ID": 397, "Title": "Integer Replacement", "TitleSlug": "integer-replacement", - "PassRate": "30%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4801,7 +4801,7 @@ "ID": 398, "Title": "Random Pick Index", "TitleSlug": "random-pick-index", - "PassRate": "44%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4813,7 +4813,7 @@ "ID": 399, "Title": "Evaluate Division", "TitleSlug": "evaluate-division", - "PassRate": "42%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4826,7 +4826,7 @@ "Title": "Nth Digit", "TitleSlug": "nth-digit", "PassRate": "30%", - "Difficulty": "Easy", + "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, "IsFavor": true, @@ -4837,7 +4837,7 @@ "ID": 401, "Title": "Binary Watch", "TitleSlug": "binary-watch", - "PassRate": "44%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4849,7 +4849,7 @@ "ID": 402, "Title": "Remove K Digits", "TitleSlug": "remove-k-digits", - "PassRate": "25%", + "PassRate": "27%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4861,7 +4861,7 @@ "ID": 403, "Title": "Frog Jump", "TitleSlug": "frog-jump", - "PassRate": "32%", + "PassRate": "37%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4873,7 +4873,7 @@ "ID": 404, "Title": "Sum of Left Leaves", "TitleSlug": "sum-of-left-leaves", - "PassRate": "47%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4885,7 +4885,7 @@ "ID": 405, "Title": "Convert a Number to Hexadecimal", "TitleSlug": "convert-a-number-to-hexadecimal", - "PassRate": "41%", + "PassRate": "42%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4897,7 +4897,7 @@ "ID": 406, "Title": "Queue Reconstruction by Height", "TitleSlug": "queue-reconstruction-by-height", - "PassRate": "56%", + "PassRate": "61%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4909,7 +4909,7 @@ "ID": 407, "Title": "Trapping Rain Water II", "TitleSlug": "trapping-rain-water-ii", - "PassRate": "37%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4921,7 +4921,7 @@ "ID": 408, "Title": "Valid Word Abbreviation", "TitleSlug": "valid-word-abbreviation", - "PassRate": "28%", + "PassRate": "29%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -4933,7 +4933,7 @@ "ID": 409, "Title": "Longest Palindrome", "TitleSlug": "longest-palindrome", - "PassRate": "46%", + "PassRate": "48%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4945,7 +4945,7 @@ "ID": 410, "Title": "Split Array Largest Sum", "TitleSlug": "split-array-largest-sum", - "PassRate": "39%", + "PassRate": "43%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -4957,7 +4957,7 @@ "ID": 411, "Title": "Minimum Unique Word Abbreviation", "TitleSlug": "minimum-unique-word-abbreviation", - "PassRate": "33%", + "PassRate": "35%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -4969,7 +4969,7 @@ "ID": 412, "Title": "Fizz Buzz", "TitleSlug": "fizz-buzz", - "PassRate": "57%", + "PassRate": "60%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -4981,7 +4981,7 @@ "ID": 413, "Title": "Arithmetic Slices", "TitleSlug": "arithmetic-slices", - "PassRate": "54%", + "PassRate": "56%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -4993,7 +4993,7 @@ "ID": 414, "Title": "Third Maximum Number", "TitleSlug": "third-maximum-number", - "PassRate": "28%", + "PassRate": "29%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5005,7 +5005,7 @@ "ID": 415, "Title": "Add Strings", "TitleSlug": "add-strings", - "PassRate": "41%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5017,7 +5017,7 @@ "ID": 416, "Title": "Partition Equal Subset Sum", "TitleSlug": "partition-equal-subset-sum", - "PassRate": "38%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5029,7 +5029,7 @@ "ID": 417, "Title": "Pacific Atlantic Water Flow", "TitleSlug": "pacific-atlantic-water-flow", - "PassRate": "34%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5041,7 +5041,7 @@ "ID": 418, "Title": "Sentence Screen Fitting", "TitleSlug": "sentence-screen-fitting", - "PassRate": "28%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -5053,7 +5053,7 @@ "ID": 419, "Title": "Battleships in a Board", "TitleSlug": "battleships-in-a-board", - "PassRate": "63%", + "PassRate": "66%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5065,7 +5065,7 @@ "ID": 420, "Title": "Strong Password Checker", "TitleSlug": "strong-password-checker", - "PassRate": "19%", + "PassRate": "16%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5077,7 +5077,7 @@ "ID": 421, "Title": "Maximum XOR of Two Numbers in an Array", "TitleSlug": "maximum-xor-of-two-numbers-in-an-array", - "PassRate": "48%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5101,7 +5101,7 @@ "ID": 423, "Title": "Reconstruct Original Digits from English", "TitleSlug": "reconstruct-original-digits-from-english", - "PassRate": "44%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5113,7 +5113,7 @@ "ID": 424, "Title": "Longest Repeating Character Replacement", "TitleSlug": "longest-repeating-character-replacement", - "PassRate": "42%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5125,7 +5125,7 @@ "ID": 425, "Title": "Word Squares", "TitleSlug": "word-squares", - "PassRate": "42%", + "PassRate": "45%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -5134,73 +5134,73 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 426, + "Title": "Convert Binary Search Tree to Sorted Doubly Linked List", + "TitleSlug": "convert-binary-search-tree-to-sorted-doubly-linked-list", + "PassRate": "55%", + "Difficulty": "Medium", "IsAccepted": false, - "IsPaid": false, + "IsPaid": true, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 427, + "Title": "Construct Quad Tree", + "TitleSlug": "construct-quad-tree", + "PassRate": "58%", + "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 428, + "Title": "Serialize and Deserialize N-ary Tree", + "TitleSlug": "serialize-and-deserialize-n-ary-tree", + "PassRate": "56%", + "Difficulty": "Hard", "IsAccepted": false, - "IsPaid": false, + "IsPaid": true, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 429, + "Title": "N-ary Tree Level Order Traversal", + "TitleSlug": "n-ary-tree-level-order-traversal", + "PassRate": "61%", + "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 430, + "Title": "Flatten a Multilevel Doubly Linked List", + "TitleSlug": "flatten-a-multilevel-doubly-linked-list", + "PassRate": "45%", + "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 431, + "Title": "Encode N-ary Tree to Binary Tree", + "TitleSlug": "encode-n-ary-tree-to-binary-tree", + "PassRate": "66%", + "Difficulty": "Hard", "IsAccepted": false, - "IsPaid": false, + "IsPaid": true, "IsFavor": false, "IsNew": false, "HasNoGoOption": false @@ -5209,7 +5209,7 @@ "ID": 432, "Title": "All O`one Data Structure", "TitleSlug": "all-oone-data-structure", - "PassRate": "27%", + "PassRate": "30%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5218,12 +5218,12 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 433, + "Title": "Minimum Genetic Mutation", + "TitleSlug": "minimum-genetic-mutation", + "PassRate": "39%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -5233,7 +5233,7 @@ "ID": 434, "Title": "Number of Segments in a String", "TitleSlug": "number-of-segments-in-a-string", - "PassRate": "36%", + "PassRate": "37%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5257,7 +5257,7 @@ "ID": 436, "Title": "Find Right Interval", "TitleSlug": "find-right-interval", - "PassRate": "41%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5269,7 +5269,7 @@ "ID": 437, "Title": "Path Sum III", "TitleSlug": "path-sum-iii", - "PassRate": "40%", + "PassRate": "44%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5281,8 +5281,8 @@ "ID": 438, "Title": "Find All Anagrams in a String", "TitleSlug": "find-all-anagrams-in-a-string", - "PassRate": "33%", - "Difficulty": "Easy", + "PassRate": "39%", + "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, "IsFavor": false, @@ -5293,7 +5293,7 @@ "ID": 439, "Title": "Ternary Expression Parser", "TitleSlug": "ternary-expression-parser", - "PassRate": "51%", + "PassRate": "54%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -5305,7 +5305,7 @@ "ID": 440, "Title": "K-th Smallest in Lexicographical Order", "TitleSlug": "k-th-smallest-in-lexicographical-order", - "PassRate": "25%", + "PassRate": "27%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5317,7 +5317,7 @@ "ID": 441, "Title": "Arranging Coins", "TitleSlug": "arranging-coins", - "PassRate": "36%", + "PassRate": "38%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5329,7 +5329,7 @@ "ID": 442, "Title": "Find All Duplicates in an Array", "TitleSlug": "find-all-duplicates-in-an-array", - "PassRate": "57%", + "PassRate": "62%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5341,7 +5341,7 @@ "ID": 443, "Title": "String Compression", "TitleSlug": "string-compression", - "PassRate": "35%", + "PassRate": "38%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5353,7 +5353,7 @@ "ID": 444, "Title": "Sequence Reconstruction", "TitleSlug": "sequence-reconstruction", - "PassRate": "19%", + "PassRate": "20%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -5365,7 +5365,7 @@ "ID": 445, "Title": "Add Two Numbers II", "TitleSlug": "add-two-numbers-ii", - "PassRate": "46%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5377,7 +5377,7 @@ "ID": 446, "Title": "Arithmetic Slices II - Subsequence", "TitleSlug": "arithmetic-slices-ii-subsequence", - "PassRate": "28%", + "PassRate": "31%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5389,7 +5389,7 @@ "ID": 447, "Title": "Number of Boomerangs", "TitleSlug": "number-of-boomerangs", - "PassRate": "46%", + "PassRate": "50%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5401,7 +5401,7 @@ "ID": 448, "Title": "Find All Numbers Disappeared in an Array", "TitleSlug": "find-all-numbers-disappeared-in-an-array", - "PassRate": "51%", + "PassRate": "54%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5413,7 +5413,7 @@ "ID": 449, "Title": "Serialize and Deserialize BST", "TitleSlug": "serialize-and-deserialize-bst", - "PassRate": "42%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -5425,7 +5425,7 @@ "ID": 450, "Title": "Delete Node in a BST", "TitleSlug": "delete-node-in-a-bst", - "PassRate": "37%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5437,7 +5437,7 @@ "ID": 451, "Title": "Sort Characters By Frequency", "TitleSlug": "sort-characters-by-frequency", - "PassRate": "52%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5449,7 +5449,7 @@ "ID": 452, "Title": "Minimum Number of Arrows to Burst Balloons", "TitleSlug": "minimum-number-of-arrows-to-burst-balloons", - "PassRate": "44%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5461,7 +5461,7 @@ "ID": 453, "Title": "Minimum Moves to Equal Array Elements", "TitleSlug": "minimum-moves-to-equal-array-elements", - "PassRate": "48%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5473,7 +5473,7 @@ "ID": 454, "Title": "4Sum II", "TitleSlug": "4sum-ii", - "PassRate": "47%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5485,7 +5485,7 @@ "ID": 455, "Title": "Assign Cookies", "TitleSlug": "assign-cookies", - "PassRate": "47%", + "PassRate": "48%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5506,24 +5506,24 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 457, + "Title": "Circular Array Loop", + "TitleSlug": "circular-array-loop", + "PassRate": "28%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 458, + "Title": "Poor Pigs", + "TitleSlug": "poor-pigs", + "PassRate": "46%", + "Difficulty": "Hard", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -5533,7 +5533,7 @@ "ID": 459, "Title": "Repeated Substring Pattern", "TitleSlug": "repeated-substring-pattern", - "PassRate": "38%", + "PassRate": "40%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5545,7 +5545,7 @@ "ID": 460, "Title": "LFU Cache", "TitleSlug": "lfu-cache", - "PassRate": "25%", + "PassRate": "30%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5557,7 +5557,7 @@ "ID": 461, "Title": "Hamming Distance", "TitleSlug": "hamming-distance", - "PassRate": "69%", + "PassRate": "70%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5569,7 +5569,7 @@ "ID": 462, "Title": "Minimum Moves to Equal Array Elements II", "TitleSlug": "minimum-moves-to-equal-array-elements-ii", - "PassRate": "51%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5581,7 +5581,7 @@ "ID": 463, "Title": "Island Perimeter", "TitleSlug": "island-perimeter", - "PassRate": "58%", + "PassRate": "62%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5593,7 +5593,7 @@ "ID": 464, "Title": "Can I Win", "TitleSlug": "can-i-win", - "PassRate": "25%", + "PassRate": "28%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5605,7 +5605,7 @@ "ID": 465, "Title": "Optimal Account Balancing", "TitleSlug": "optimal-account-balancing", - "PassRate": "39%", + "PassRate": "44%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -5629,7 +5629,7 @@ "ID": 467, "Title": "Unique Substrings in Wraparound String", "TitleSlug": "unique-substrings-in-wraparound-string", - "PassRate": "33%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5641,7 +5641,7 @@ "ID": 468, "Title": "Validate IP Address", "TitleSlug": "validate-ip-address", - "PassRate": "20%", + "PassRate": "21%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5653,7 +5653,7 @@ "ID": 469, "Title": "Convex Polygon", "TitleSlug": "convex-polygon", - "PassRate": "34%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -5662,14 +5662,14 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 470, + "Title": "Implement Rand10() Using Rand7()", + "TitleSlug": "implement-rand10-using-rand7", + "PassRate": "45%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -5677,7 +5677,7 @@ "ID": 471, "Title": "Encode String with Shortest Length", "TitleSlug": "encode-string-with-shortest-length", - "PassRate": "43%", + "PassRate": "45%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -5689,7 +5689,7 @@ "ID": 472, "Title": "Concatenated Words", "TitleSlug": "concatenated-words", - "PassRate": "31%", + "PassRate": "37%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5701,7 +5701,7 @@ "ID": 473, "Title": "Matchsticks to Square", "TitleSlug": "matchsticks-to-square", - "PassRate": "35%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5713,7 +5713,7 @@ "ID": 474, "Title": "Ones and Zeroes", "TitleSlug": "ones-and-zeroes", - "PassRate": "38%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5725,7 +5725,7 @@ "ID": 475, "Title": "Heaters", "TitleSlug": "heaters", - "PassRate": "29%", + "PassRate": "32%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5737,7 +5737,7 @@ "ID": 476, "Title": "Number Complement", "TitleSlug": "number-complement", - "PassRate": "61%", + "PassRate": "62%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5749,7 +5749,7 @@ "ID": 477, "Title": "Total Hamming Distance", "TitleSlug": "total-hamming-distance", - "PassRate": "47%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5758,12 +5758,12 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 478, + "Title": "Generate Random Point in a Circle", + "TitleSlug": "generate-random-point-in-a-circle", + "PassRate": "37%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -5773,8 +5773,8 @@ "ID": 479, "Title": "Largest Palindrome Product", "TitleSlug": "largest-palindrome-product", - "PassRate": "25%", - "Difficulty": "Easy", + "PassRate": "27%", + "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, "IsFavor": false, @@ -5785,7 +5785,7 @@ "ID": 480, "Title": "Sliding Window Median", "TitleSlug": "sliding-window-median", - "PassRate": "30%", + "PassRate": "34%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5797,7 +5797,7 @@ "ID": 481, "Title": "Magical String", "TitleSlug": "magical-string", - "PassRate": "45%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5809,7 +5809,7 @@ "ID": 482, "Title": "License Key Formatting", "TitleSlug": "license-key-formatting", - "PassRate": "39%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5821,7 +5821,7 @@ "ID": 483, "Title": "Smallest Good Base", "TitleSlug": "smallest-good-base", - "PassRate": "33%", + "PassRate": "34%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5833,7 +5833,7 @@ "ID": 484, "Title": "Find Permutation", "TitleSlug": "find-permutation", - "PassRate": "55%", + "PassRate": "58%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -5845,7 +5845,7 @@ "ID": 485, "Title": "Max Consecutive Ones", "TitleSlug": "max-consecutive-ones", - "PassRate": "53%", + "PassRate": "55%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5857,7 +5857,7 @@ "ID": 486, "Title": "Predict the Winner", "TitleSlug": "predict-the-winner", - "PassRate": "45%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5869,7 +5869,7 @@ "ID": 487, "Title": "Max Consecutive Ones II", "TitleSlug": "max-consecutive-ones-ii", - "PassRate": "45%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -5881,7 +5881,7 @@ "ID": 488, "Title": "Zuma Game", "TitleSlug": "zuma-game", - "PassRate": "37%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5890,13 +5890,13 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 489, + "Title": "Robot Room Cleaner", + "TitleSlug": "robot-room-cleaner", + "PassRate": "66%", + "Difficulty": "Hard", "IsAccepted": false, - "IsPaid": false, + "IsPaid": true, "IsFavor": false, "IsNew": false, "HasNoGoOption": false @@ -5905,7 +5905,7 @@ "ID": 490, "Title": "The Maze", "TitleSlug": "the-maze", - "PassRate": "43%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -5917,7 +5917,7 @@ "ID": 491, "Title": "Increasing Subsequences", "TitleSlug": "increasing-subsequences", - "PassRate": "38%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5941,7 +5941,7 @@ "ID": 493, "Title": "Reverse Pairs", "TitleSlug": "reverse-pairs", - "PassRate": "20%", + "PassRate": "23%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -5953,7 +5953,7 @@ "ID": 494, "Title": "Target Sum", "TitleSlug": "target-sum", - "PassRate": "43%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5965,7 +5965,7 @@ "ID": 495, "Title": "Teemo Attacking", "TitleSlug": "teemo-attacking", - "PassRate": "51%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -5977,7 +5977,7 @@ "ID": 496, "Title": "Next Greater Element I", "TitleSlug": "next-greater-element-i", - "PassRate": "56%", + "PassRate": "61%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -5986,12 +5986,12 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 497, + "Title": "Random Point in Non-overlapping Rectangles", + "TitleSlug": "random-point-in-non-overlapping-rectangles", + "PassRate": "36%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -6001,7 +6001,7 @@ "ID": 498, "Title": "Diagonal Traverse", "TitleSlug": "diagonal-traverse", - "PassRate": "45%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6013,7 +6013,7 @@ "ID": 499, "Title": "The Maze III", "TitleSlug": "the-maze-iii", - "PassRate": "33%", + "PassRate": "38%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -6025,7 +6025,7 @@ "ID": 500, "Title": "Keyboard Row", "TitleSlug": "keyboard-row", - "PassRate": "60%", + "PassRate": "63%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6037,7 +6037,7 @@ "ID": 501, "Title": "Find Mode in Binary Search Tree", "TitleSlug": "find-mode-in-binary-search-tree", - "PassRate": "37%", + "PassRate": "40%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6049,7 +6049,7 @@ "ID": 502, "Title": "IPO", "TitleSlug": "ipo", - "PassRate": "36%", + "PassRate": "38%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -6061,7 +6061,7 @@ "ID": 503, "Title": "Next Greater Element II", "TitleSlug": "next-greater-element-ii", - "PassRate": "48%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6073,7 +6073,7 @@ "ID": 504, "Title": "Base 7", "TitleSlug": "base-7", - "PassRate": "43%", + "PassRate": "45%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6085,7 +6085,7 @@ "ID": 505, "Title": "The Maze II", "TitleSlug": "the-maze-ii", - "PassRate": "38%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6097,7 +6097,7 @@ "ID": 506, "Title": "Relative Ranks", "TitleSlug": "relative-ranks", - "PassRate": "47%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6109,7 +6109,7 @@ "ID": 507, "Title": "Perfect Number", "TitleSlug": "perfect-number", - "PassRate": "32%", + "PassRate": "35%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6121,7 +6121,7 @@ "ID": 508, "Title": "Most Frequent Subtree Sum", "TitleSlug": "most-frequent-subtree-sum", - "PassRate": "52%", + "PassRate": "55%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6130,25 +6130,25 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 509, + "Title": "Fibonacci Number", + "TitleSlug": "fibonacci-number", + "PassRate": "66%", + "Difficulty": "Easy", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 510, + "Title": "Inorder Successor in BST II", + "TitleSlug": "inorder-successor-in-bst-ii", + "PassRate": "55%", + "Difficulty": "Medium", "IsAccepted": false, - "IsPaid": false, + "IsPaid": true, "IsFavor": false, "IsNew": false, "HasNoGoOption": false @@ -6181,7 +6181,7 @@ "ID": 513, "Title": "Find Bottom Left Tree Value", "TitleSlug": "find-bottom-left-tree-value", - "PassRate": "56%", + "PassRate": "59%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6193,7 +6193,7 @@ "ID": 514, "Title": "Freedom Trail", "TitleSlug": "freedom-trail", - "PassRate": "39%", + "PassRate": "41%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -6205,7 +6205,7 @@ "ID": 515, "Title": "Find Largest Value in Each Tree Row", "TitleSlug": "find-largest-value-in-each-tree-row", - "PassRate": "55%", + "PassRate": "58%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6217,7 +6217,7 @@ "ID": 516, "Title": "Longest Palindromic Subsequence", "TitleSlug": "longest-palindromic-subsequence", - "PassRate": "42%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6229,7 +6229,7 @@ "ID": 517, "Title": "Super Washing Machines", "TitleSlug": "super-washing-machines", - "PassRate": "36%", + "PassRate": "37%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -6238,24 +6238,24 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 518, + "Title": "Coin Change 2", + "TitleSlug": "coin-change-2", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 519, + "Title": "Random Flip Matrix", + "TitleSlug": "random-flip-matrix", + "PassRate": "34%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -6265,7 +6265,7 @@ "ID": 520, "Title": "Detect Capital", "TitleSlug": "detect-capital", - "PassRate": "51%", + "PassRate": "52%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6277,7 +6277,7 @@ "ID": 521, "Title": "Longest Uncommon Subsequence I ", "TitleSlug": "longest-uncommon-subsequence-i", - "PassRate": "55%", + "PassRate": "56%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6289,7 +6289,7 @@ "ID": 522, "Title": "Longest Uncommon Subsequence II", "TitleSlug": "longest-uncommon-subsequence-ii", - "PassRate": "32%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6301,7 +6301,7 @@ "ID": 523, "Title": "Continuous Subarray Sum", "TitleSlug": "continuous-subarray-sum", - "PassRate": "23%", + "PassRate": "24%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6313,7 +6313,7 @@ "ID": 524, "Title": "Longest Word in Dictionary through Deleting", "TitleSlug": "longest-word-in-dictionary-through-deleting", - "PassRate": "43%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6325,7 +6325,7 @@ "ID": 525, "Title": "Contiguous Array", "TitleSlug": "contiguous-array", - "PassRate": "41%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6337,7 +6337,7 @@ "ID": 526, "Title": "Beautiful Arrangement", "TitleSlug": "beautiful-arrangement", - "PassRate": "53%", + "PassRate": "55%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6349,7 +6349,7 @@ "ID": 527, "Title": "Word Abbreviation", "TitleSlug": "word-abbreviation", - "PassRate": "43%", + "PassRate": "51%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -6358,12 +6358,12 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 528, + "Title": "Random Pick with Weight", + "TitleSlug": "random-pick-with-weight", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -6373,7 +6373,7 @@ "ID": 529, "Title": "Minesweeper", "TitleSlug": "minesweeper", - "PassRate": "49%", + "PassRate": "55%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6385,7 +6385,7 @@ "ID": 530, "Title": "Minimum Absolute Difference in BST", "TitleSlug": "minimum-absolute-difference-in-bst", - "PassRate": "47%", + "PassRate": "51%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6397,7 +6397,7 @@ "ID": 531, "Title": "Lonely Pixel I", "TitleSlug": "lonely-pixel-i", - "PassRate": "56%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6409,7 +6409,7 @@ "ID": 532, "Title": "K-diff Pairs in an Array", "TitleSlug": "k-diff-pairs-in-an-array", - "PassRate": "28%", + "PassRate": "30%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6421,7 +6421,7 @@ "ID": 533, "Title": "Lonely Pixel II", "TitleSlug": "lonely-pixel-ii", - "PassRate": "45%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6445,7 +6445,7 @@ "ID": 535, "Title": "Encode and Decode TinyURL", "TitleSlug": "encode-and-decode-tinyurl", - "PassRate": "73%", + "PassRate": "78%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": false, @@ -6457,7 +6457,7 @@ "ID": 536, "Title": "Construct Binary Tree from String", "TitleSlug": "construct-binary-tree-from-string", - "PassRate": "42%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6469,7 +6469,7 @@ "ID": 537, "Title": "Complex Number Multiplication", "TitleSlug": "complex-number-multiplication", - "PassRate": "63%", + "PassRate": "66%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6481,7 +6481,7 @@ "ID": 538, "Title": "Convert BST to Greater Tree", "TitleSlug": "convert-bst-to-greater-tree", - "PassRate": "48%", + "PassRate": "52%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6493,7 +6493,7 @@ "ID": 539, "Title": "Minimum Time Difference", "TitleSlug": "minimum-time-difference", - "PassRate": "46%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6505,7 +6505,7 @@ "ID": 540, "Title": "Single Element in a Sorted Array", "TitleSlug": "single-element-in-a-sorted-array", - "PassRate": "55%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6517,7 +6517,7 @@ "ID": 541, "Title": "Reverse String II", "TitleSlug": "reverse-string-ii", - "PassRate": "43%", + "PassRate": "46%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6529,7 +6529,7 @@ "ID": 542, "Title": "01 Matrix", "TitleSlug": "01-matrix", - "PassRate": "33%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6541,7 +6541,7 @@ "ID": 543, "Title": "Diameter of Binary Tree", "TitleSlug": "diameter-of-binary-tree", - "PassRate": "45%", + "PassRate": "47%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6553,7 +6553,7 @@ "ID": 544, "Title": "Output Contest Matches", "TitleSlug": "output-contest-matches", - "PassRate": "71%", + "PassRate": "74%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6565,7 +6565,7 @@ "ID": 545, "Title": "Boundary of Binary Tree", "TitleSlug": "boundary-of-binary-tree", - "PassRate": "32%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6577,7 +6577,7 @@ "ID": 546, "Title": "Remove Boxes", "TitleSlug": "remove-boxes", - "PassRate": "35%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -6589,7 +6589,7 @@ "ID": 547, "Title": "Friend Circles", "TitleSlug": "friend-circles", - "PassRate": "49%", + "PassRate": "55%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6601,7 +6601,7 @@ "ID": 548, "Title": "Split Array with Equal Sum", "TitleSlug": "split-array-with-equal-sum", - "PassRate": "37%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6613,7 +6613,7 @@ "ID": 549, "Title": "Binary Tree Longest Consecutive Sequence II", "TitleSlug": "binary-tree-longest-consecutive-sequence-ii", - "PassRate": "42%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6637,7 +6637,7 @@ "ID": 551, "Title": "Student Attendance Record I", "TitleSlug": "student-attendance-record-i", - "PassRate": "44%", + "PassRate": "46%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6649,7 +6649,7 @@ "ID": 552, "Title": "Student Attendance Record II", "TitleSlug": "student-attendance-record-ii", - "PassRate": "31%", + "PassRate": "34%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -6673,7 +6673,7 @@ "ID": 554, "Title": "Brick Wall", "TitleSlug": "brick-wall", - "PassRate": "46%", + "PassRate": "48%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6685,7 +6685,7 @@ "ID": 555, "Title": "Split Concatenated Strings", "TitleSlug": "split-concatenated-strings", - "PassRate": "38%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6697,7 +6697,7 @@ "ID": 556, "Title": "Next Greater Element III", "TitleSlug": "next-greater-element-iii", - "PassRate": "28%", + "PassRate": "30%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6709,7 +6709,7 @@ "ID": 557, "Title": "Reverse Words in a String III", "TitleSlug": "reverse-words-in-a-string-iii", - "PassRate": "60%", + "PassRate": "66%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6718,34 +6718,34 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 558, + "Title": "Quad Tree Intersection", + "TitleSlug": "quad-tree-intersection", + "PassRate": "42%", + "Difficulty": "Easy", "IsAccepted": false, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 559, + "Title": "Maximum Depth of N-ary Tree", + "TitleSlug": "maximum-depth-of-n-ary-tree", + "PassRate": "66%", + "Difficulty": "Easy", "IsAccepted": false, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { "ID": 560, "Title": "Subarray Sum Equals K", "TitleSlug": "subarray-sum-equals-k", - "PassRate": "39%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6757,7 +6757,7 @@ "ID": 561, "Title": "Array Partition I", "TitleSlug": "array-partition-i", - "PassRate": "66%", + "PassRate": "70%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6769,7 +6769,7 @@ "ID": 562, "Title": "Longest Line of Consecutive One in Matrix", "TitleSlug": "longest-line-of-consecutive-one-in-matrix", - "PassRate": "41%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6793,7 +6793,7 @@ "ID": 564, "Title": "Find the Closest Palindrome", "TitleSlug": "find-the-closest-palindrome", - "PassRate": "17%", + "PassRate": "19%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -6805,7 +6805,7 @@ "ID": 565, "Title": "Array Nesting", "TitleSlug": "array-nesting", - "PassRate": "49%", + "PassRate": "53%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6817,7 +6817,7 @@ "ID": 566, "Title": "Reshape the Matrix", "TitleSlug": "reshape-the-matrix", - "PassRate": "57%", + "PassRate": "59%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6829,7 +6829,7 @@ "ID": 567, "Title": "Permutation in String", "TitleSlug": "permutation-in-string", - "PassRate": "36%", + "PassRate": "39%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6841,7 +6841,7 @@ "ID": 568, "Title": "Maximum Vacation Days", "TitleSlug": "maximum-vacation-days", - "PassRate": "36%", + "PassRate": "38%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -6889,7 +6889,7 @@ "ID": 572, "Title": "Subtree of Another Tree", "TitleSlug": "subtree-of-another-tree", - "PassRate": "40%", + "PassRate": "42%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6901,7 +6901,7 @@ "ID": 573, "Title": "Squirrel Simulation", "TitleSlug": "squirrel-simulation", - "PassRate": "52%", + "PassRate": "54%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -6925,7 +6925,7 @@ "ID": 575, "Title": "Distribute Candies", "TitleSlug": "distribute-candies", - "PassRate": "58%", + "PassRate": "60%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -6937,7 +6937,7 @@ "ID": 576, "Title": "Out of Boundary Paths", "TitleSlug": "out-of-boundary-paths", - "PassRate": "30%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -6997,7 +6997,7 @@ "ID": 581, "Title": "Shortest Unsorted Continuous Subarray", "TitleSlug": "shortest-unsorted-continuous-subarray", - "PassRate": "29%", + "PassRate": "30%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7009,7 +7009,7 @@ "ID": 582, "Title": "Kill Process", "TitleSlug": "kill-process", - "PassRate": "51%", + "PassRate": "57%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -7021,7 +7021,7 @@ "ID": 583, "Title": "Delete Operation for Two Strings", "TitleSlug": "delete-operation-for-two-strings", - "PassRate": "44%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7069,7 +7069,7 @@ "ID": 587, "Title": "Erect the Fence", "TitleSlug": "erect-the-fence", - "PassRate": "33%", + "PassRate": "34%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -7081,7 +7081,7 @@ "ID": 588, "Title": "Design In-Memory File System", "TitleSlug": "design-in-memory-file-system", - "PassRate": "35%", + "PassRate": "42%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -7090,34 +7090,34 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 589, + "Title": "N-ary Tree Preorder Traversal", + "TitleSlug": "n-ary-tree-preorder-traversal", + "PassRate": "69%", + "Difficulty": "Easy", "IsAccepted": false, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 590, + "Title": "N-ary Tree Postorder Traversal", + "TitleSlug": "n-ary-tree-postorder-traversal", + "PassRate": "69%", + "Difficulty": "Easy", "IsAccepted": false, "IsPaid": false, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { "ID": 591, "Title": "Tag Validator", "TitleSlug": "tag-validator", - "PassRate": "30%", + "PassRate": "33%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -7129,7 +7129,7 @@ "ID": 592, "Title": "Fraction Addition and Subtraction", "TitleSlug": "fraction-addition-and-subtraction", - "PassRate": "46%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7141,7 +7141,7 @@ "ID": 593, "Title": "Valid Square", "TitleSlug": "valid-square", - "PassRate": "39%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7153,7 +7153,7 @@ "ID": 594, "Title": "Longest Harmonious Subsequence", "TitleSlug": "longest-harmonious-subsequence", - "PassRate": "41%", + "PassRate": "44%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7201,7 +7201,7 @@ "ID": 598, "Title": "Range Addition II", "TitleSlug": "range-addition-ii", - "PassRate": "48%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7213,7 +7213,7 @@ "ID": 599, "Title": "Minimum Index Sum of Two Lists", "TitleSlug": "minimum-index-sum-of-two-lists", - "PassRate": "46%", + "PassRate": "48%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7225,7 +7225,7 @@ "ID": 600, "Title": "Non-negative Integers without Consecutive Ones", "TitleSlug": "non-negative-integers-without-consecutive-ones", - "PassRate": "31%", + "PassRate": "33%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -7273,7 +7273,7 @@ "ID": 604, "Title": "Design Compressed String Iterator", "TitleSlug": "design-compressed-string-iterator", - "PassRate": "33%", + "PassRate": "35%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -7285,7 +7285,7 @@ "ID": 605, "Title": "Can Place Flowers", "TitleSlug": "can-place-flowers", - "PassRate": "30%", + "PassRate": "31%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7297,7 +7297,7 @@ "ID": 606, "Title": "Construct String from Binary Tree", "TitleSlug": "construct-string-from-binary-tree", - "PassRate": "49%", + "PassRate": "52%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7333,7 +7333,7 @@ "ID": 609, "Title": "Find Duplicate File in System", "TitleSlug": "find-duplicate-file-in-system", - "PassRate": "52%", + "PassRate": "56%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7357,7 +7357,7 @@ "ID": 611, "Title": "Valid Triangle Number", "TitleSlug": "valid-triangle-number", - "PassRate": "41%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7417,7 +7417,7 @@ "ID": 616, "Title": "Add Bold Tag in String", "TitleSlug": "add-bold-tag-in-string", - "PassRate": "38%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -7429,7 +7429,7 @@ "ID": 617, "Title": "Merge Two Binary Trees", "TitleSlug": "merge-two-binary-trees", - "PassRate": "67%", + "PassRate": "71%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7477,7 +7477,7 @@ "ID": 621, "Title": "Task Scheduler", "TitleSlug": "task-scheduler", - "PassRate": "42%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7486,12 +7486,12 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 622, + "Title": "Design Circular Queue", + "TitleSlug": "design-circular-queue", + "PassRate": "41%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -7501,7 +7501,7 @@ "ID": 623, "Title": "Add One Row to Tree", "TitleSlug": "add-one-row-to-tree", - "PassRate": "46%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7513,7 +7513,7 @@ "ID": 624, "Title": "Maximum Distance in Arrays", "TitleSlug": "maximum-distance-in-arrays", - "PassRate": "35%", + "PassRate": "38%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -7525,7 +7525,7 @@ "ID": 625, "Title": "Minimum Factorization", "TitleSlug": "minimum-factorization", - "PassRate": "31%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -7561,7 +7561,7 @@ "ID": 628, "Title": "Maximum Product of Three Numbers", "TitleSlug": "maximum-product-of-three-numbers", - "PassRate": "44%", + "PassRate": "46%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7573,7 +7573,7 @@ "ID": 629, "Title": "K Inverse Pairs Array", "TitleSlug": "k-inverse-pairs-array", - "PassRate": "27%", + "PassRate": "29%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -7585,7 +7585,7 @@ "ID": 630, "Title": "Course Schedule III", "TitleSlug": "course-schedule-iii", - "PassRate": "29%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -7597,7 +7597,7 @@ "ID": 631, "Title": "Design Excel Sum Formula", "TitleSlug": "design-excel-sum-formula", - "PassRate": "27%", + "PassRate": "30%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -7607,9 +7607,9 @@ }, { "ID": 632, - "Title": "Smallest Range", - "TitleSlug": "smallest-range", - "PassRate": "41%", + "Title": "Smallest Range Covering Elements from K Lists", + "TitleSlug": "smallest-range-covering-elements-from-k-lists", + "PassRate": "49%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -7633,7 +7633,7 @@ "ID": 634, "Title": "Find the Derangement of An Array", "TitleSlug": "find-the-derangement-of-an-array", - "PassRate": "35%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -7645,7 +7645,7 @@ "ID": 635, "Title": "Design Log Storage System", "TitleSlug": "design-log-storage-system", - "PassRate": "49%", + "PassRate": "56%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -7657,7 +7657,7 @@ "ID": 636, "Title": "Exclusive Time of Functions", "TitleSlug": "exclusive-time-of-functions", - "PassRate": "44%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7669,7 +7669,7 @@ "ID": 637, "Title": "Average of Levels in Binary Tree", "TitleSlug": "average-of-levels-in-binary-tree", - "PassRate": "55%", + "PassRate": "60%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7681,7 +7681,7 @@ "ID": 638, "Title": "Shopping Offers", "TitleSlug": "shopping-offers", - "PassRate": "45%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7693,7 +7693,7 @@ "ID": 639, "Title": "Decode Ways II", "TitleSlug": "decode-ways-ii", - "PassRate": "24%", + "PassRate": "25%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -7705,7 +7705,7 @@ "ID": 640, "Title": "Solve the Equation", "TitleSlug": "solve-the-equation", - "PassRate": "38%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7714,14 +7714,14 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 641, + "Title": "Design Circular Deque", + "TitleSlug": "design-circular-deque", + "PassRate": "50%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -7729,7 +7729,7 @@ "ID": 642, "Title": "Design Search Autocomplete System", "TitleSlug": "design-search-autocomplete-system", - "PassRate": "30%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -7741,7 +7741,7 @@ "ID": 643, "Title": "Maximum Average Subarray I", "TitleSlug": "maximum-average-subarray-i", - "PassRate": "37%", + "PassRate": "40%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7753,7 +7753,7 @@ "ID": 644, "Title": "Maximum Average Subarray II", "TitleSlug": "maximum-average-subarray-ii", - "PassRate": "25%", + "PassRate": "29%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -7765,7 +7765,7 @@ "ID": 645, "Title": "Set Mismatch", "TitleSlug": "set-mismatch", - "PassRate": "39%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7777,7 +7777,7 @@ "ID": 646, "Title": "Maximum Length of Pair Chain", "TitleSlug": "maximum-length-of-pair-chain", - "PassRate": "47%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7789,7 +7789,7 @@ "ID": 647, "Title": "Palindromic Substrings", "TitleSlug": "palindromic-substrings", - "PassRate": "54%", + "PassRate": "58%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7801,7 +7801,7 @@ "ID": 648, "Title": "Replace Words", "TitleSlug": "replace-words", - "PassRate": "48%", + "PassRate": "53%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7813,7 +7813,7 @@ "ID": 649, "Title": "Dota2 Senate", "TitleSlug": "dota2-senate", - "PassRate": "36%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7825,7 +7825,7 @@ "ID": 650, "Title": "2 Keys Keyboard", "TitleSlug": "2-keys-keyboard", - "PassRate": "45%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7837,7 +7837,7 @@ "ID": 651, "Title": "4 Keys Keyboard", "TitleSlug": "4-keys-keyboard", - "PassRate": "49%", + "PassRate": "51%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -7849,7 +7849,7 @@ "ID": 652, "Title": "Find Duplicate Subtrees", "TitleSlug": "find-duplicate-subtrees", - "PassRate": "37%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7861,7 +7861,7 @@ "ID": 653, "Title": "Two Sum IV - Input is a BST", "TitleSlug": "two-sum-iv-input-is-a-bst", - "PassRate": "50%", + "PassRate": "53%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7873,7 +7873,7 @@ "ID": 654, "Title": "Maximum Binary Tree", "TitleSlug": "maximum-binary-tree", - "PassRate": "70%", + "PassRate": "77%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7885,7 +7885,7 @@ "ID": 655, "Title": "Print Binary Tree", "TitleSlug": "print-binary-tree", - "PassRate": "49%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7897,7 +7897,7 @@ "ID": 656, "Title": "Coin Path", "TitleSlug": "coin-path", - "PassRate": "25%", + "PassRate": "27%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -7907,9 +7907,9 @@ }, { "ID": 657, - "Title": "Judge Route Circle", - "TitleSlug": "judge-route-circle", - "PassRate": "68%", + "Title": "Robot Return to Origin", + "TitleSlug": "robot-return-to-origin", + "PassRate": "72%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7921,7 +7921,7 @@ "ID": 658, "Title": "Find K Closest Elements", "TitleSlug": "find-k-closest-elements", - "PassRate": "34%", + "PassRate": "39%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7933,7 +7933,7 @@ "ID": 659, "Title": "Split Array into Consecutive Subsequences", "TitleSlug": "split-array-into-consecutive-subsequences", - "PassRate": "36%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7945,7 +7945,7 @@ "ID": 660, "Title": "Remove 9", "TitleSlug": "remove-9", - "PassRate": "49%", + "PassRate": "52%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": true, @@ -7957,7 +7957,7 @@ "ID": 661, "Title": "Image Smoother", "TitleSlug": "image-smoother", - "PassRate": "46%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -7969,7 +7969,7 @@ "ID": 662, "Title": "Maximum Width of Binary Tree", "TitleSlug": "maximum-width-of-binary-tree", - "PassRate": "38%", + "PassRate": "39%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -7981,7 +7981,7 @@ "ID": 663, "Title": "Equal Tree Partition", "TitleSlug": "equal-tree-partition", - "PassRate": "36%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -7993,7 +7993,7 @@ "ID": 664, "Title": "Strange Printer", "TitleSlug": "strange-printer", - "PassRate": "34%", + "PassRate": "38%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8005,7 +8005,7 @@ "ID": 665, "Title": "Non-decreasing Array", "TitleSlug": "non-decreasing-array", - "PassRate": "20%", + "PassRate": "19%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8017,7 +8017,7 @@ "ID": 666, "Title": "Path Sum IV", "TitleSlug": "path-sum-iv", - "PassRate": "50%", + "PassRate": "53%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -8029,7 +8029,7 @@ "ID": 667, "Title": "Beautiful Arrangement II", "TitleSlug": "beautiful-arrangement-ii", - "PassRate": "51%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8041,7 +8041,7 @@ "ID": 668, "Title": "Kth Smallest Number in Multiplication Table", "TitleSlug": "kth-smallest-number-in-multiplication-table", - "PassRate": "40%", + "PassRate": "43%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8053,7 +8053,7 @@ "ID": 669, "Title": "Trim a Binary Search Tree", "TitleSlug": "trim-a-binary-search-tree", - "PassRate": "58%", + "PassRate": "61%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8065,7 +8065,7 @@ "ID": 670, "Title": "Maximum Swap", "TitleSlug": "maximum-swap", - "PassRate": "38%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8077,7 +8077,7 @@ "ID": 671, "Title": "Second Minimum Node In a Binary Tree", "TitleSlug": "second-minimum-node-in-a-binary-tree", - "PassRate": "41%", + "PassRate": "43%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8089,7 +8089,7 @@ "ID": 672, "Title": "Bulb Switcher II", "TitleSlug": "bulb-switcher-ii", - "PassRate": "49%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8101,7 +8101,7 @@ "ID": 673, "Title": "Number of Longest Increasing Subsequence", "TitleSlug": "number-of-longest-increasing-subsequence", - "PassRate": "31%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8113,7 +8113,7 @@ "ID": 674, "Title": "Longest Continuous Increasing Subsequence", "TitleSlug": "longest-continuous-increasing-subsequence", - "PassRate": "42%", + "PassRate": "44%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8125,7 +8125,7 @@ "ID": 675, "Title": "Cut Off Trees for Golf Event", "TitleSlug": "cut-off-trees-for-golf-event", - "PassRate": "26%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8137,7 +8137,7 @@ "ID": 676, "Title": "Implement Magic Dictionary", "TitleSlug": "implement-magic-dictionary", - "PassRate": "49%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8149,7 +8149,7 @@ "ID": 677, "Title": "Map Sum Pairs", "TitleSlug": "map-sum-pairs", - "PassRate": "51%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8161,7 +8161,7 @@ "ID": 678, "Title": "Valid Parenthesis String", "TitleSlug": "valid-parenthesis-string", - "PassRate": "29%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8173,7 +8173,7 @@ "ID": 679, "Title": "24 Game", "TitleSlug": "24-game", - "PassRate": "38%", + "PassRate": "44%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8185,7 +8185,7 @@ "ID": 680, "Title": "Valid Palindrome II", "TitleSlug": "valid-palindrome-ii", - "PassRate": "32%", + "PassRate": "35%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8197,7 +8197,7 @@ "ID": 681, "Title": "Next Closest Time", "TitleSlug": "next-closest-time", - "PassRate": "41%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -8209,7 +8209,7 @@ "ID": 682, "Title": "Baseball Game", "TitleSlug": "baseball-game", - "PassRate": "58%", + "PassRate": "61%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8221,7 +8221,7 @@ "ID": 683, "Title": "K Empty Slots", "TitleSlug": "k-empty-slots", - "PassRate": "33%", + "PassRate": "34%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -8233,7 +8233,7 @@ "ID": 684, "Title": "Redundant Connection", "TitleSlug": "redundant-connection", - "PassRate": "44%", + "PassRate": "54%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8245,7 +8245,7 @@ "ID": 685, "Title": "Redundant Connection II", "TitleSlug": "redundant-connection-ii", - "PassRate": "27%", + "PassRate": "31%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8269,7 +8269,7 @@ "ID": 687, "Title": "Longest Univalue Path", "TitleSlug": "longest-univalue-path", - "PassRate": "32%", + "PassRate": "34%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8281,7 +8281,7 @@ "ID": 688, "Title": "Knight Probability in Chessboard", "TitleSlug": "knight-probability-in-chessboard", - "PassRate": "40%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8293,7 +8293,7 @@ "ID": 689, "Title": "Maximum Sum of 3 Non-Overlapping Subarrays", "TitleSlug": "maximum-sum-of-3-non-overlapping-subarrays", - "PassRate": "41%", + "PassRate": "44%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8305,7 +8305,7 @@ "ID": 690, "Title": "Employee Importance", "TitleSlug": "employee-importance", - "PassRate": "51%", + "PassRate": "55%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": false, @@ -8317,7 +8317,7 @@ "ID": 691, "Title": "Stickers to Spell Word", "TitleSlug": "stickers-to-spell-word", - "PassRate": "34%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8329,7 +8329,7 @@ "ID": 692, "Title": "Top K Frequent Words", "TitleSlug": "top-k-frequent-words", - "PassRate": "41%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8341,7 +8341,7 @@ "ID": 693, "Title": "Binary Number with Alternating Bits", "TitleSlug": "binary-number-with-alternating-bits", - "PassRate": "55%", + "PassRate": "58%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8353,7 +8353,7 @@ "ID": 694, "Title": "Number of Distinct Islands", "TitleSlug": "number-of-distinct-islands", - "PassRate": "45%", + "PassRate": "53%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -8365,8 +8365,8 @@ "ID": 695, "Title": "Max Area of Island", "TitleSlug": "max-area-of-island", - "PassRate": "51%", - "Difficulty": "Easy", + "PassRate": "59%", + "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, "IsFavor": true, @@ -8377,7 +8377,7 @@ "ID": 696, "Title": "Count Binary Substrings", "TitleSlug": "count-binary-substrings", - "PassRate": "50%", + "PassRate": "54%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8389,7 +8389,7 @@ "ID": 697, "Title": "Degree of an Array", "TitleSlug": "degree-of-an-array", - "PassRate": "46%", + "PassRate": "51%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8401,7 +8401,7 @@ "ID": 698, "Title": "Partition to K Equal Sum Subsets", "TitleSlug": "partition-to-k-equal-sum-subsets", - "PassRate": "37%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8413,7 +8413,7 @@ "ID": 699, "Title": "Falling Squares", "TitleSlug": "falling-squares", - "PassRate": "37%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8422,134 +8422,134 @@ "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 700, + "Title": "Search in a Binary Search Tree", + "TitleSlug": "search-in-a-binary-search-tree", + "PassRate": "69%", + "Difficulty": "Easy", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 701, + "Title": "Insert into a Binary Search Tree", + "TitleSlug": "insert-into-a-binary-search-tree", + "PassRate": "77%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 702, + "Title": "Search in a Sorted Array of Unknown Size", + "TitleSlug": "search-in-a-sorted-array-of-unknown-size", + "PassRate": "62%", + "Difficulty": "Medium", "IsAccepted": false, - "IsPaid": false, + "IsPaid": true, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 703, + "Title": "Kth Largest Element in a Stream", + "TitleSlug": "kth-largest-element-in-a-stream", + "PassRate": "47%", + "Difficulty": "Easy", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 704, + "Title": "Binary Search", + "TitleSlug": "binary-search", + "PassRate": "49%", + "Difficulty": "Easy", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 705, + "Title": "Design HashSet", + "TitleSlug": "design-hashset", + "PassRate": "56%", + "Difficulty": "Easy", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 706, + "Title": "Design HashMap", + "TitleSlug": "design-hashmap", + "PassRate": "57%", + "Difficulty": "Easy", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 707, + "Title": "Design Linked List", + "TitleSlug": "design-linked-list", + "PassRate": "20%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", + "ID": 708, + "Title": "Insert into a Cyclic Sorted List", + "TitleSlug": "insert-into-a-cyclic-sorted-list", + "PassRate": "30%", + "Difficulty": "Medium", "IsAccepted": false, - "IsPaid": false, + "IsPaid": true, "IsFavor": false, "IsNew": false, - "HasNoGoOption": false + "HasNoGoOption": true }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 709, + "Title": "To Lower Case", + "TitleSlug": "to-lower-case", + "PassRate": "77%", + "Difficulty": "Easy", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, { - "ID": 0, - "Title": "", - "TitleSlug": "", - "PassRate": "", - "Difficulty": "", - "IsAccepted": false, + "ID": 710, + "Title": "Random Pick with Blacklist", + "TitleSlug": "random-pick-with-blacklist", + "PassRate": "32%", + "Difficulty": "Hard", + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -8557,7 +8557,7 @@ "ID": 711, "Title": "Number of Distinct Islands II", "TitleSlug": "number-of-distinct-islands-ii", - "PassRate": "41%", + "PassRate": "47%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -8569,7 +8569,7 @@ "ID": 712, "Title": "Minimum ASCII Delete Sum for Two Strings", "TitleSlug": "minimum-ascii-delete-sum-for-two-strings", - "PassRate": "51%", + "PassRate": "55%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8581,7 +8581,7 @@ "ID": 713, "Title": "Subarray Product Less Than K", "TitleSlug": "subarray-product-less-than-k", - "PassRate": "33%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8593,7 +8593,7 @@ "ID": 714, "Title": "Best Time to Buy and Sell Stock with Transaction Fee", "TitleSlug": "best-time-to-buy-and-sell-stock-with-transaction-fee", - "PassRate": "46%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8605,7 +8605,7 @@ "ID": 715, "Title": "Range Module", "TitleSlug": "range-module", - "PassRate": "31%", + "PassRate": "36%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8617,8 +8617,8 @@ "ID": 716, "Title": "Max Stack", "TitleSlug": "max-stack", - "PassRate": "36%", - "Difficulty": "Hard", + "PassRate": "41%", + "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, "IsFavor": false, @@ -8641,7 +8641,7 @@ "ID": 718, "Title": "Maximum Length of Repeated Subarray", "TitleSlug": "maximum-length-of-repeated-subarray", - "PassRate": "41%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8653,7 +8653,7 @@ "ID": 719, "Title": "Find K-th Smallest Pair Distance", "TitleSlug": "find-k-th-smallest-pair-distance", - "PassRate": "27%", + "PassRate": "30%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8665,7 +8665,7 @@ "ID": 720, "Title": "Longest Word in Dictionary", "TitleSlug": "longest-word-in-dictionary", - "PassRate": "41%", + "PassRate": "46%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8677,7 +8677,7 @@ "ID": 721, "Title": "Accounts Merge", "TitleSlug": "accounts-merge", - "PassRate": "33%", + "PassRate": "43%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8689,7 +8689,7 @@ "ID": 722, "Title": "Remove Comments", "TitleSlug": "remove-comments", - "PassRate": "28%", + "PassRate": "32%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8701,7 +8701,7 @@ "ID": 723, "Title": "Candy Crush", "TitleSlug": "candy-crush", - "PassRate": "55%", + "PassRate": "65%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -8713,7 +8713,7 @@ "ID": 724, "Title": "Find Pivot Index", "TitleSlug": "find-pivot-index", - "PassRate": "39%", + "PassRate": "42%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8725,7 +8725,7 @@ "ID": 725, "Title": "Split Linked List in Parts", "TitleSlug": "split-linked-list-in-parts", - "PassRate": "46%", + "PassRate": "50%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8737,7 +8737,7 @@ "ID": 726, "Title": "Number of Atoms", "TitleSlug": "number-of-atoms", - "PassRate": "43%", + "PassRate": "46%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8749,7 +8749,7 @@ "ID": 727, "Title": "Minimum Window Subsequence", "TitleSlug": "minimum-window-subsequence", - "PassRate": "30%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -8761,7 +8761,7 @@ "ID": 728, "Title": "Self Dividing Numbers", "TitleSlug": "self-dividing-numbers", - "PassRate": "66%", + "PassRate": "71%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8773,7 +8773,7 @@ "ID": 729, "Title": "My Calendar I", "TitleSlug": "my-calendar-i", - "PassRate": "42%", + "PassRate": "49%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8785,7 +8785,7 @@ "ID": 730, "Title": "Count Different Palindromic Subsequences", "TitleSlug": "count-different-palindromic-subsequences", - "PassRate": "34%", + "PassRate": "40%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8797,7 +8797,7 @@ "ID": 731, "Title": "My Calendar II", "TitleSlug": "my-calendar-ii", - "PassRate": "37%", + "PassRate": "46%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8809,7 +8809,7 @@ "ID": 732, "Title": "My Calendar III", "TitleSlug": "my-calendar-iii", - "PassRate": "49%", + "PassRate": "57%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8821,7 +8821,7 @@ "ID": 733, "Title": "Flood Fill", "TitleSlug": "flood-fill", - "PassRate": "47%", + "PassRate": "52%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8833,7 +8833,7 @@ "ID": 734, "Title": "Sentence Similarity", "TitleSlug": "sentence-similarity", - "PassRate": "38%", + "PassRate": "41%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -8845,7 +8845,7 @@ "ID": 735, "Title": "Asteroid Collision", "TitleSlug": "asteroid-collision", - "PassRate": "37%", + "PassRate": "39%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8857,7 +8857,7 @@ "ID": 736, "Title": "Parse Lisp Expression", "TitleSlug": "parse-lisp-expression", - "PassRate": "41%", + "PassRate": "45%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8869,7 +8869,7 @@ "ID": 737, "Title": "Sentence Similarity II", "TitleSlug": "sentence-similarity-ii", - "PassRate": "40%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -8881,7 +8881,7 @@ "ID": 738, "Title": "Monotone Increasing Digits", "TitleSlug": "monotone-increasing-digits", - "PassRate": "41%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8893,7 +8893,7 @@ "ID": 739, "Title": "Daily Temperatures", "TitleSlug": "daily-temperatures", - "PassRate": "52%", + "PassRate": "61%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8905,7 +8905,7 @@ "ID": 740, "Title": "Delete and Earn", "TitleSlug": "delete-and-earn", - "PassRate": "44%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8917,7 +8917,7 @@ "ID": 741, "Title": "Cherry Pickup", "TitleSlug": "cherry-pickup", - "PassRate": "24%", + "PassRate": "31%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8929,7 +8929,7 @@ "ID": 742, "Title": "Closest Leaf in a Binary Tree", "TitleSlug": "closest-leaf-in-a-binary-tree", - "PassRate": "34%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -8941,7 +8941,7 @@ "ID": 743, "Title": "Network Delay Time", "TitleSlug": "network-delay-time", - "PassRate": "35%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -8953,7 +8953,7 @@ "ID": 744, "Title": "Find Smallest Letter Greater Than Target", "TitleSlug": "find-smallest-letter-greater-than-target", - "PassRate": "43%", + "PassRate": "44%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8965,7 +8965,7 @@ "ID": 745, "Title": "Prefix and Suffix Search", "TitleSlug": "prefix-and-suffix-search", - "PassRate": "25%", + "PassRate": "32%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -8977,7 +8977,7 @@ "ID": 746, "Title": "Min Cost Climbing Stairs", "TitleSlug": "min-cost-climbing-stairs", - "PassRate": "43%", + "PassRate": "48%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -8989,7 +8989,7 @@ "ID": 747, "Title": "Largest Number At Least Twice of Others", "TitleSlug": "largest-number-at-least-twice-of-others", - "PassRate": "41%", + "PassRate": "40%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9001,8 +9001,8 @@ "ID": 748, "Title": "Shortest Completing Word", "TitleSlug": "shortest-completing-word", - "PassRate": "51%", - "Difficulty": "Medium", + "PassRate": "55%", + "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, "IsFavor": false, @@ -9013,7 +9013,7 @@ "ID": 749, "Title": "Contain Virus", "TitleSlug": "contain-virus", - "PassRate": "40%", + "PassRate": "42%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9025,7 +9025,7 @@ "ID": 750, "Title": "Number Of Corner Rectangles", "TitleSlug": "number-of-corner-rectangles", - "PassRate": "55%", + "PassRate": "65%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -9037,7 +9037,7 @@ "ID": 751, "Title": "IP to CIDR", "TitleSlug": "ip-to-cidr", - "PassRate": "53%", + "PassRate": "61%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -9049,7 +9049,7 @@ "ID": 752, "Title": "Open the Lock", "TitleSlug": "open-the-lock", - "PassRate": "39%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9061,7 +9061,7 @@ "ID": 753, "Title": "Cracking the Safe", "TitleSlug": "cracking-the-safe", - "PassRate": "40%", + "PassRate": "48%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9073,8 +9073,8 @@ "ID": 754, "Title": "Reach a Number", "TitleSlug": "reach-a-number", - "PassRate": "27%", - "Difficulty": "Medium", + "PassRate": "33%", + "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, "IsFavor": true, @@ -9085,7 +9085,7 @@ "ID": 755, "Title": "Pour Water", "TitleSlug": "pour-water", - "PassRate": "34%", + "PassRate": "42%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": true, @@ -9097,7 +9097,7 @@ "ID": 756, "Title": "Pyramid Transition Matrix", "TitleSlug": "pyramid-transition-matrix", - "PassRate": "46%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9109,7 +9109,7 @@ "ID": 757, "Title": "Set Intersection Size At Least Two", "TitleSlug": "set-intersection-size-at-least-two", - "PassRate": "35%", + "PassRate": "37%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9121,7 +9121,7 @@ "ID": 758, "Title": "Bold Words in String", "TitleSlug": "bold-words-in-string", - "PassRate": "38%", + "PassRate": "43%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -9133,7 +9133,7 @@ "ID": 759, "Title": "Employee Free Time", "TitleSlug": "employee-free-time", - "PassRate": "52%", + "PassRate": "63%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -9145,7 +9145,7 @@ "ID": 760, "Title": "Find Anagram Mappings", "TitleSlug": "find-anagram-mappings", - "PassRate": "76%", + "PassRate": "79%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": true, @@ -9157,7 +9157,7 @@ "ID": 761, "Title": "Special Binary String", "TitleSlug": "special-binary-string", - "PassRate": "42%", + "PassRate": "53%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9169,7 +9169,7 @@ "ID": 762, "Title": "Prime Number of Set Bits in Binary Representation", "TitleSlug": "prime-number-of-set-bits-in-binary-representation", - "PassRate": "55%", + "PassRate": "60%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9181,7 +9181,7 @@ "ID": 763, "Title": "Partition Labels", "TitleSlug": "partition-labels", - "PassRate": "64%", + "PassRate": "72%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9193,7 +9193,7 @@ "ID": 764, "Title": "Largest Plus Sign", "TitleSlug": "largest-plus-sign", - "PassRate": "38%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9205,7 +9205,7 @@ "ID": 765, "Title": "Couples Holding Hands", "TitleSlug": "couples-holding-hands", - "PassRate": "48%", + "PassRate": "52%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9217,7 +9217,7 @@ "ID": 766, "Title": "Toeplitz Matrix", "TitleSlug": "toeplitz-matrix", - "PassRate": "57%", + "PassRate": "62%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9229,7 +9229,7 @@ "ID": 767, "Title": "Reorganize String", "TitleSlug": "reorganize-string", - "PassRate": "36%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9241,7 +9241,7 @@ "ID": 768, "Title": "Max Chunks To Make Sorted II", "TitleSlug": "max-chunks-to-make-sorted-ii", - "PassRate": "43%", + "PassRate": "46%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9253,7 +9253,7 @@ "ID": 769, "Title": "Max Chunks To Make Sorted", "TitleSlug": "max-chunks-to-make-sorted", - "PassRate": "48%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9265,7 +9265,7 @@ "ID": 770, "Title": "Basic Calculator IV", "TitleSlug": "basic-calculator-iv", - "PassRate": "42%", + "PassRate": "46%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9277,7 +9277,7 @@ "ID": 771, "Title": "Jewels and Stones", "TitleSlug": "jewels-and-stones", - "PassRate": "81%", + "PassRate": "83%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9289,7 +9289,7 @@ "ID": 772, "Title": "Basic Calculator III", "TitleSlug": "basic-calculator-iii", - "PassRate": "39%", + "PassRate": "41%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -9301,7 +9301,7 @@ "ID": 773, "Title": "Sliding Puzzle", "TitleSlug": "sliding-puzzle", - "PassRate": "47%", + "PassRate": "55%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9313,7 +9313,7 @@ "ID": 774, "Title": "Minimize Max Distance to Gas Station", "TitleSlug": "minimize-max-distance-to-gas-station", - "PassRate": "31%", + "PassRate": "43%", "Difficulty": "Hard", "IsAccepted": false, "IsPaid": true, @@ -9325,7 +9325,7 @@ "ID": 775, "Title": "Global and Local Inversions", "TitleSlug": "global-and-local-inversions", - "PassRate": "33%", + "PassRate": "40%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9337,7 +9337,7 @@ "ID": 776, "Title": "Split BST", "TitleSlug": "split-bst", - "PassRate": "49%", + "PassRate": "53%", "Difficulty": "Medium", "IsAccepted": false, "IsPaid": true, @@ -9349,7 +9349,7 @@ "ID": 777, "Title": "Swap Adjacent in LR String", "TitleSlug": "swap-adjacent-in-lr-string", - "PassRate": "28%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9361,7 +9361,7 @@ "ID": 778, "Title": "Swim in Rising Water", "TitleSlug": "swim-in-rising-water", - "PassRate": "44%", + "PassRate": "49%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9373,7 +9373,7 @@ "ID": 779, "Title": "K-th Symbol in Grammar", "TitleSlug": "k-th-symbol-in-grammar", - "PassRate": "36%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9385,7 +9385,7 @@ "ID": 780, "Title": "Reaching Points", "TitleSlug": "reaching-points", - "PassRate": "23%", + "PassRate": "28%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9397,7 +9397,7 @@ "ID": 781, "Title": "Rabbits in Forest", "TitleSlug": "rabbits-in-forest", - "PassRate": "49%", + "PassRate": "52%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9409,7 +9409,7 @@ "ID": 782, "Title": "Transform to Chessboard", "TitleSlug": "transform-to-chessboard", - "PassRate": "37%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9421,7 +9421,7 @@ "ID": 783, "Title": "Minimum Distance Between BST Nodes", "TitleSlug": "minimum-distance-between-bst-nodes", - "PassRate": "47%", + "PassRate": "51%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9433,7 +9433,7 @@ "ID": 784, "Title": "Letter Case Permutation", "TitleSlug": "letter-case-permutation", - "PassRate": "52%", + "PassRate": "59%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9445,7 +9445,7 @@ "ID": 785, "Title": "Is Graph Bipartite?", "TitleSlug": "is-graph-bipartite", - "PassRate": "38%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9457,7 +9457,7 @@ "ID": 786, "Title": "K-th Smallest Prime Fraction", "TitleSlug": "k-th-smallest-prime-fraction", - "PassRate": "31%", + "PassRate": "41%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9469,7 +9469,7 @@ "ID": 787, "Title": "Cheapest Flights Within K Stops", "TitleSlug": "cheapest-flights-within-k-stops", - "PassRate": "29%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9481,7 +9481,7 @@ "ID": 788, "Title": "Rotated Digits", "TitleSlug": "rotated-digits", - "PassRate": "50%", + "PassRate": "55%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9493,7 +9493,7 @@ "ID": 789, "Title": "Escape The Ghosts", "TitleSlug": "escape-the-ghosts", - "PassRate": "50%", + "PassRate": "56%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9505,7 +9505,7 @@ "ID": 790, "Title": "Domino and Tromino Tiling", "TitleSlug": "domino-and-tromino-tiling", - "PassRate": "32%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9517,7 +9517,7 @@ "ID": 791, "Title": "Custom Sort String", "TitleSlug": "custom-sort-string", - "PassRate": "59%", + "PassRate": "63%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9529,7 +9529,7 @@ "ID": 792, "Title": "Number of Matching Subsequences", "TitleSlug": "number-of-matching-subsequences", - "PassRate": "36%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9541,7 +9541,7 @@ "ID": 793, "Title": "Preimage Size of Factorial Zeroes Function", "TitleSlug": "preimage-size-of-factorial-zeroes-function", - "PassRate": "42%", + "PassRate": "39%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9553,7 +9553,7 @@ "ID": 794, "Title": "Valid Tic-Tac-Toe State", "TitleSlug": "valid-tic-tac-toe-state", - "PassRate": "27%", + "PassRate": "31%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9565,7 +9565,7 @@ "ID": 795, "Title": "Number of Subarrays with Bounded Maximum", "TitleSlug": "number-of-subarrays-with-bounded-maximum", - "PassRate": "41%", + "PassRate": "44%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9577,7 +9577,7 @@ "ID": 796, "Title": "Rotate String", "TitleSlug": "rotate-string", - "PassRate": "51%", + "PassRate": "49%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9589,7 +9589,7 @@ "ID": 797, "Title": "All Paths From Source to Target", "TitleSlug": "all-paths-from-source-to-target", - "PassRate": "67%", + "PassRate": "72%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9601,7 +9601,7 @@ "ID": 798, "Title": "Smallest Rotation with Highest Score", "TitleSlug": "smallest-rotation-with-highest-score", - "PassRate": "32%", + "PassRate": "41%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9613,7 +9613,7 @@ "ID": 799, "Title": "Champagne Tower", "TitleSlug": "champagne-tower", - "PassRate": "29%", + "PassRate": "34%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9625,7 +9625,7 @@ "ID": 800, "Title": "Similar RGB Color", "TitleSlug": "similar-rgb-color", - "PassRate": "53%", + "PassRate": "60%", "Difficulty": "Easy", "IsAccepted": false, "IsPaid": true, @@ -9637,7 +9637,7 @@ "ID": 801, "Title": "Minimum Swaps To Make Sequences Increasing", "TitleSlug": "minimum-swaps-to-make-sequences-increasing", - "PassRate": "27%", + "PassRate": "36%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9649,7 +9649,7 @@ "ID": 802, "Title": "Find Eventual Safe States", "TitleSlug": "find-eventual-safe-states", - "PassRate": "37%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9661,7 +9661,7 @@ "ID": 803, "Title": "Bricks Falling When Hit", "TitleSlug": "bricks-falling-when-hit", - "PassRate": "22%", + "PassRate": "29%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9673,7 +9673,7 @@ "ID": 804, "Title": "Unique Morse Code Words", "TitleSlug": "unique-morse-code-words", - "PassRate": "73%", + "PassRate": "75%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9685,7 +9685,7 @@ "ID": 805, "Title": "Split Array With Same Average", "TitleSlug": "split-array-with-same-average", - "PassRate": "20%", + "PassRate": "25%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9709,7 +9709,7 @@ "ID": 807, "Title": "Max Increase to Keep City Skyline", "TitleSlug": "max-increase-to-keep-city-skyline", - "PassRate": "81%", + "PassRate": "82%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9721,7 +9721,7 @@ "ID": 808, "Title": "Soup Servings", "TitleSlug": "soup-servings", - "PassRate": "32%", + "PassRate": "38%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9733,7 +9733,7 @@ "ID": 809, "Title": "Expressive Words", "TitleSlug": "expressive-words", - "PassRate": "36%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9745,7 +9745,7 @@ "ID": 810, "Title": "Chalkboard XOR Game", "TitleSlug": "chalkboard-xor-game", - "PassRate": "38%", + "PassRate": "45%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9757,7 +9757,7 @@ "ID": 811, "Title": "Subdomain Visit Count", "TitleSlug": "subdomain-visit-count", - "PassRate": "63%", + "PassRate": "66%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9769,7 +9769,7 @@ "ID": 812, "Title": "Largest Triangle Area", "TitleSlug": "largest-triangle-area", - "PassRate": "53%", + "PassRate": "56%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9781,7 +9781,7 @@ "ID": 813, "Title": "Largest Sum of Averages", "TitleSlug": "largest-sum-of-averages", - "PassRate": "40%", + "PassRate": "47%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9793,7 +9793,7 @@ "ID": 814, "Title": "Binary Tree Pruning", "TitleSlug": "binary-tree-pruning", - "PassRate": "69%", + "PassRate": "72%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9805,7 +9805,7 @@ "ID": 815, "Title": "Bus Routes", "TitleSlug": "bus-routes", - "PassRate": "32%", + "PassRate": "41%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9817,7 +9817,7 @@ "ID": 816, "Title": "Ambiguous Coordinates", "TitleSlug": "ambiguous-coordinates", - "PassRate": "41%", + "PassRate": "45%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9829,11 +9829,11 @@ "ID": 817, "Title": "Linked List Components", "TitleSlug": "linked-list-components", - "PassRate": "50%", + "PassRate": "55%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, - "IsFavor": true, + "IsFavor": false, "IsNew": false, "HasNoGoOption": false }, @@ -9841,7 +9841,7 @@ "ID": 818, "Title": "Race Car", "TitleSlug": "race-car", - "PassRate": "26%", + "PassRate": "37%", "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, @@ -9853,7 +9853,7 @@ "ID": 819, "Title": "Most Common Word", "TitleSlug": "most-common-word", - "PassRate": "49%", + "PassRate": "43%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9865,7 +9865,7 @@ "ID": 820, "Title": "Short Encoding of Words", "TitleSlug": "short-encoding-of-words", - "PassRate": "40%", + "PassRate": "48%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9877,7 +9877,7 @@ "ID": 821, "Title": "Shortest Distance to a Character", "TitleSlug": "shortest-distance-to-a-character", - "PassRate": "62%", + "PassRate": "64%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9889,7 +9889,7 @@ "ID": 822, "Title": "Card Flipping Game", "TitleSlug": "card-flipping-game", - "PassRate": "34%", + "PassRate": "41%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9901,7 +9901,7 @@ "ID": 823, "Title": "Binary Trees With Factors", "TitleSlug": "binary-trees-with-factors", - "PassRate": "28%", + "PassRate": "33%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9913,7 +9913,7 @@ "ID": 824, "Title": "Goat Latin", "TitleSlug": "goat-latin", - "PassRate": "56%", + "PassRate": "59%", "Difficulty": "Easy", "IsAccepted": true, "IsPaid": false, @@ -9925,7 +9925,7 @@ "ID": 825, "Title": "Friends Of Appropriate Ages", "TitleSlug": "friends-of-appropriate-ages", - "PassRate": "27%", + "PassRate": "39%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9937,7 +9937,7 @@ "ID": 826, "Title": "Most Profit Assigning Work", "TitleSlug": "most-profit-assigning-work", - "PassRate": "32%", + "PassRate": "37%", "Difficulty": "Medium", "IsAccepted": true, "IsPaid": false, @@ -9949,11 +9949,11 @@ "ID": 827, "Title": "Making A Large Island", "TitleSlug": "making-a-large-island", - "PassRate": "41%", + "PassRate": "44%", "Difficulty": "Hard", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -9961,11 +9961,11 @@ "ID": 828, "Title": "Unique Letter String", "TitleSlug": "unique-letter-string", - "PassRate": "32%", + "PassRate": "41%", "Difficulty": "Hard", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -9973,8 +9973,8 @@ "ID": 829, "Title": "Consecutive Numbers Sum", "TitleSlug": "consecutive-numbers-sum", - "PassRate": "26%", - "Difficulty": "Medium", + "PassRate": "35%", + "Difficulty": "Hard", "IsAccepted": true, "IsPaid": false, "IsFavor": true, @@ -9999,7 +9999,7 @@ "TitleSlug": "masking-personal-information", "PassRate": "42%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -10009,9 +10009,9 @@ "ID": 832, "Title": "Flipping an Image", "TitleSlug": "flipping-an-image", - "PassRate": "72%", + "PassRate": "73%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -10021,9 +10021,9 @@ "ID": 833, "Title": "Find And Replace in String", "TitleSlug": "find-and-replace-in-string", - "PassRate": "36%", + "PassRate": "48%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -10033,11 +10033,11 @@ "ID": 834, "Title": "Sum of Distances in Tree", "TitleSlug": "sum-of-distances-in-tree", - "PassRate": "29%", + "PassRate": "41%", "Difficulty": "Hard", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -10045,9 +10045,9 @@ "ID": 835, "Title": "Image Overlap", "TitleSlug": "image-overlap", - "PassRate": "32%", + "PassRate": "54%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -10057,9 +10057,9 @@ "ID": 836, "Title": "Rectangle Overlap", "TitleSlug": "rectangle-overlap", - "PassRate": "38%", + "PassRate": "47%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, "IsNew": false, @@ -10069,11 +10069,11 @@ "ID": 837, "Title": "New 21 Game", "TitleSlug": "new-21-game", - "PassRate": "24%", + "PassRate": "32%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -10081,11 +10081,11 @@ "ID": 838, "Title": "Push Dominoes", "TitleSlug": "push-dominoes", - "PassRate": "39%", + "PassRate": "45%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -10093,11 +10093,11 @@ "ID": 839, "Title": "Similar String Groups", "TitleSlug": "similar-string-groups", - "PassRate": "35%", + "PassRate": "36%", "Difficulty": "Hard", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, - "IsFavor": false, + "IsFavor": true, "IsNew": false, "HasNoGoOption": false }, @@ -10105,48 +10105,4932 @@ "ID": 840, "Title": "Magic Squares In Grid", "TitleSlug": "magic-squares-in-grid", - "PassRate": "31%", + "PassRate": "36%", "Difficulty": "Easy", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, - "IsNew": true, + "IsNew": false, "HasNoGoOption": false }, { "ID": 841, "Title": "Keys and Rooms", "TitleSlug": "keys-and-rooms", - "PassRate": "60%", + "PassRate": "61%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, - "IsNew": true, + "IsNew": false, "HasNoGoOption": false }, { "ID": 842, "Title": "Split Array into Fibonacci Sequence", "TitleSlug": "split-array-into-fibonacci-sequence", - "PassRate": "31%", + "PassRate": "35%", "Difficulty": "Medium", - "IsAccepted": false, + "IsAccepted": true, "IsPaid": false, "IsFavor": false, - "IsNew": true, + "IsNew": false, "HasNoGoOption": false }, { "ID": 843, "Title": "Guess the Word", "TitleSlug": "guess-the-word", - "PassRate": "28%", + "PassRate": "45%", "Difficulty": "Hard", - "IsAccepted": false, + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 844, + "Title": "Backspace String Compare", + "TitleSlug": "backspace-string-compare", + "PassRate": "46%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 845, + "Title": "Longest Mountain in Array", + "TitleSlug": "longest-mountain-in-array", + "PassRate": "35%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 846, + "Title": "Hand of Straights", + "TitleSlug": "hand-of-straights", + "PassRate": "50%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 847, + "Title": "Shortest Path Visiting All Nodes", + "TitleSlug": "shortest-path-visiting-all-nodes", + "PassRate": "48%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 848, + "Title": "Shifting Letters", + "TitleSlug": "shifting-letters", + "PassRate": "42%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 849, + "Title": "Maximize Distance to Closest Person", + "TitleSlug": "maximize-distance-to-closest-person", + "PassRate": "41%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 850, + "Title": "Rectangle Area II", + "TitleSlug": "rectangle-area-ii", + "PassRate": "46%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 851, + "Title": "Loud and Rich", + "TitleSlug": "loud-and-rich", + "PassRate": "49%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 852, + "Title": "Peak Index in a Mountain Array", + "TitleSlug": "peak-index-in-a-mountain-array", + "PassRate": "70%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 853, + "Title": "Car Fleet", + "TitleSlug": "car-fleet", + "PassRate": "41%", + "Difficulty": "Medium", + "IsAccepted": true, "IsPaid": false, "IsFavor": false, - "IsNew": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 854, + "Title": "K-Similar Strings", + "TitleSlug": "k-similar-strings", + "PassRate": "35%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 855, + "Title": "Exam Room", + "TitleSlug": "exam-room", + "PassRate": "40%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 856, + "Title": "Score of Parentheses", + "TitleSlug": "score-of-parentheses", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 857, + "Title": "Minimum Cost to Hire K Workers", + "TitleSlug": "minimum-cost-to-hire-k-workers", + "PassRate": "48%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 858, + "Title": "Mirror Reflection", + "TitleSlug": "mirror-reflection", + "PassRate": "52%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 859, + "Title": "Buddy Strings", + "TitleSlug": "buddy-strings", + "PassRate": "27%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 860, + "Title": "Lemonade Change", + "TitleSlug": "lemonade-change", + "PassRate": "50%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 861, + "Title": "Score After Flipping Matrix", + "TitleSlug": "score-after-flipping-matrix", + "PassRate": "70%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 862, + "Title": "Shortest Subarray with Sum at Least K", + "TitleSlug": "shortest-subarray-with-sum-at-least-k", + "PassRate": "22%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 863, + "Title": "All Nodes Distance K in Binary Tree", + "TitleSlug": "all-nodes-distance-k-in-binary-tree", + "PassRate": "50%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 864, + "Title": "Shortest Path to Get All Keys", + "TitleSlug": "shortest-path-to-get-all-keys", + "PassRate": "38%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 865, + "Title": "Smallest Subtree with all the Deepest Nodes", + "TitleSlug": "smallest-subtree-with-all-the-deepest-nodes", + "PassRate": "58%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 866, + "Title": "Prime Palindrome", + "TitleSlug": "prime-palindrome", + "PassRate": "21%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 867, + "Title": "Transpose Matrix", + "TitleSlug": "transpose-matrix", + "PassRate": "63%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 868, + "Title": "Binary Gap", + "TitleSlug": "binary-gap", + "PassRate": "59%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 869, + "Title": "Reordered Power of 2", + "TitleSlug": "reordered-power-of-2", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 870, + "Title": "Advantage Shuffle", + "TitleSlug": "advantage-shuffle", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 871, + "Title": "Minimum Number of Refueling Stops", + "TitleSlug": "minimum-number-of-refueling-stops", + "PassRate": "30%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 872, + "Title": "Leaf-Similar Trees", + "TitleSlug": "leaf-similar-trees", + "PassRate": "64%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 873, + "Title": "Length of Longest Fibonacci Subsequence", + "TitleSlug": "length-of-longest-fibonacci-subsequence", + "PassRate": "47%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 874, + "Title": "Walking Robot Simulation", + "TitleSlug": "walking-robot-simulation", + "PassRate": "33%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 875, + "Title": "Koko Eating Bananas", + "TitleSlug": "koko-eating-bananas", + "PassRate": "48%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 876, + "Title": "Middle of the Linked List", + "TitleSlug": "middle-of-the-linked-list", + "PassRate": "65%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 877, + "Title": "Stone Game", + "TitleSlug": "stone-game", + "PassRate": "62%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 878, + "Title": "Nth Magical Number", + "TitleSlug": "nth-magical-number", + "PassRate": "26%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 879, + "Title": "Profitable Schemes", + "TitleSlug": "profitable-schemes", + "PassRate": "37%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 880, + "Title": "Decoded String at Index", + "TitleSlug": "decoded-string-at-index", + "PassRate": "23%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 881, + "Title": "Boats to Save People", + "TitleSlug": "boats-to-save-people", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 882, + "Title": "Reachable Nodes In Subdivided Graph", + "TitleSlug": "reachable-nodes-in-subdivided-graph", + "PassRate": "39%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 883, + "Title": "Projection Area of 3D Shapes", + "TitleSlug": "projection-area-of-3d-shapes", + "PassRate": "66%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 884, + "Title": "Uncommon Words from Two Sentences", + "TitleSlug": "uncommon-words-from-two-sentences", + "PassRate": "61%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 885, + "Title": "Spiral Matrix III", + "TitleSlug": "spiral-matrix-iii", + "PassRate": "66%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 886, + "Title": "Possible Bipartition", + "TitleSlug": "possible-bipartition", + "PassRate": "41%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 887, + "Title": "Super Egg Drop", + "TitleSlug": "super-egg-drop", + "PassRate": "25%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 888, + "Title": "Fair Candy Swap", + "TitleSlug": "fair-candy-swap", + "PassRate": "56%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 889, + "Title": "Construct Binary Tree from Preorder and Postorder Traversal", + "TitleSlug": "construct-binary-tree-from-preorder-and-postorder-traversal", + "PassRate": "62%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 890, + "Title": "Find and Replace Pattern", + "TitleSlug": "find-and-replace-pattern", + "PassRate": "72%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 891, + "Title": "Sum of Subsequence Widths", + "TitleSlug": "sum-of-subsequence-widths", + "PassRate": "30%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 892, + "Title": "Surface Area of 3D Shapes", + "TitleSlug": "surface-area-of-3d-shapes", + "PassRate": "57%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 893, + "Title": "Groups of Special-Equivalent Strings", + "TitleSlug": "groups-of-special-equivalent-strings", + "PassRate": "63%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 894, + "Title": "All Possible Full Binary Trees", + "TitleSlug": "all-possible-full-binary-trees", + "PassRate": "72%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 895, + "Title": "Maximum Frequency Stack", + "TitleSlug": "maximum-frequency-stack", + "PassRate": "58%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 896, + "Title": "Monotonic Array", + "TitleSlug": "monotonic-array", + "PassRate": "56%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 897, + "Title": "Increasing Order Search Tree", + "TitleSlug": "increasing-order-search-tree", + "PassRate": "66%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 898, + "Title": "Bitwise ORs of Subarrays", + "TitleSlug": "bitwise-ors-of-subarrays", + "PassRate": "35%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 899, + "Title": "Orderly Queue", + "TitleSlug": "orderly-queue", + "PassRate": "49%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 900, + "Title": "RLE Iterator", + "TitleSlug": "rle-iterator", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 901, + "Title": "Online Stock Span", + "TitleSlug": "online-stock-span", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 902, + "Title": "Numbers At Most N Given Digit Set", + "TitleSlug": "numbers-at-most-n-given-digit-set", + "PassRate": "29%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 903, + "Title": "Valid Permutations for DI Sequence", + "TitleSlug": "valid-permutations-for-di-sequence", + "PassRate": "46%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 904, + "Title": "Fruit Into Baskets", + "TitleSlug": "fruit-into-baskets", + "PassRate": "41%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 905, + "Title": "Sort Array By Parity", + "TitleSlug": "sort-array-by-parity", + "PassRate": "72%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 906, + "Title": "Super Palindromes", + "TitleSlug": "super-palindromes", + "PassRate": "30%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 907, + "Title": "Sum of Subarray Minimums", + "TitleSlug": "sum-of-subarray-minimums", + "PassRate": "29%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 908, + "Title": "Smallest Range I", + "TitleSlug": "smallest-range-i", + "PassRate": "64%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 909, + "Title": "Snakes and Ladders", + "TitleSlug": "snakes-and-ladders", + "PassRate": "36%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 910, + "Title": "Smallest Range II", + "TitleSlug": "smallest-range-ii", + "PassRate": "24%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 911, + "Title": "Online Election", + "TitleSlug": "online-election", + "PassRate": "48%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 912, + "Title": "Sort an Array", + "TitleSlug": "sort-an-array", + "PassRate": "62%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 913, + "Title": "Cat and Mouse", + "TitleSlug": "cat-and-mouse", + "PassRate": "29%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 914, + "Title": "X of a Kind in a Deck of Cards", + "TitleSlug": "x-of-a-kind-in-a-deck-of-cards", + "PassRate": "34%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 915, + "Title": "Partition Array into Disjoint Intervals", + "TitleSlug": "partition-array-into-disjoint-intervals", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 916, + "Title": "Word Subsets", + "TitleSlug": "word-subsets", + "PassRate": "45%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 917, + "Title": "Reverse Only Letters", + "TitleSlug": "reverse-only-letters", + "PassRate": "56%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 918, + "Title": "Maximum Sum Circular Subarray", + "TitleSlug": "maximum-sum-circular-subarray", + "PassRate": "33%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 919, + "Title": "Complete Binary Tree Inserter", + "TitleSlug": "complete-binary-tree-inserter", + "PassRate": "55%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 920, + "Title": "Number of Music Playlists", + "TitleSlug": "number-of-music-playlists", + "PassRate": "44%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 921, + "Title": "Minimum Add to Make Parentheses Valid", + "TitleSlug": "minimum-add-to-make-parentheses-valid", + "PassRate": "70%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 922, + "Title": "Sort Array By Parity II", + "TitleSlug": "sort-array-by-parity-ii", + "PassRate": "67%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 923, + "Title": "3Sum With Multiplicity", + "TitleSlug": "3sum-with-multiplicity", + "PassRate": "34%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 924, + "Title": "Minimize Malware Spread", + "TitleSlug": "minimize-malware-spread", + "PassRate": "40%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 925, + "Title": "Long Pressed Name", + "TitleSlug": "long-pressed-name", + "PassRate": "44%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 926, + "Title": "Flip String to Monotone Increasing", + "TitleSlug": "flip-string-to-monotone-increasing", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 927, + "Title": "Three Equal Parts", + "TitleSlug": "three-equal-parts", + "PassRate": "31%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 928, + "Title": "Minimize Malware Spread II", + "TitleSlug": "minimize-malware-spread-ii", + "PassRate": "39%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 929, + "Title": "Unique Email Addresses", + "TitleSlug": "unique-email-addresses", + "PassRate": "68%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 930, + "Title": "Binary Subarrays With Sum", + "TitleSlug": "binary-subarrays-with-sum", + "PassRate": "39%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 931, + "Title": "Minimum Falling Path Sum", + "TitleSlug": "minimum-falling-path-sum", + "PassRate": "59%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 932, + "Title": "Beautiful Array", + "TitleSlug": "beautiful-array", + "PassRate": "54%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 933, + "Title": "Number of Recent Calls", + "TitleSlug": "number-of-recent-calls", + "PassRate": "69%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 934, + "Title": "Shortest Bridge", + "TitleSlug": "shortest-bridge", + "PassRate": "45%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 935, + "Title": "Knight Dialer", + "TitleSlug": "knight-dialer", + "PassRate": "42%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 936, + "Title": "Stamping The Sequence", + "TitleSlug": "stamping-the-sequence", + "PassRate": "35%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 937, + "Title": "Reorder Data in Log Files", + "TitleSlug": "reorder-data-in-log-files", + "PassRate": "54%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 938, + "Title": "Range Sum of BST", + "TitleSlug": "range-sum-of-bst", + "PassRate": "78%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 939, + "Title": "Minimum Area Rectangle", + "TitleSlug": "minimum-area-rectangle", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 940, + "Title": "Distinct Subsequences II", + "TitleSlug": "distinct-subsequences-ii", + "PassRate": "40%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 941, + "Title": "Valid Mountain Array", + "TitleSlug": "valid-mountain-array", + "PassRate": "35%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 942, + "Title": "DI String Match", + "TitleSlug": "di-string-match", + "PassRate": "70%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 943, + "Title": "Find the Shortest Superstring", + "TitleSlug": "find-the-shortest-superstring", + "PassRate": "40%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 944, + "Title": "Delete Columns to Make Sorted", + "TitleSlug": "delete-columns-to-make-sorted", + "PassRate": "69%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 945, + "Title": "Minimum Increment to Make Array Unique", + "TitleSlug": "minimum-increment-to-make-array-unique", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 946, + "Title": "Validate Stack Sequences", + "TitleSlug": "validate-stack-sequences", + "PassRate": "58%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 947, + "Title": "Most Stones Removed with Same Row or Column", + "TitleSlug": "most-stones-removed-with-same-row-or-column", + "PassRate": "54%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 948, + "Title": "Bag of Tokens", + "TitleSlug": "bag-of-tokens", + "PassRate": "39%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 949, + "Title": "Largest Time for Given Digits", + "TitleSlug": "largest-time-for-given-digits", + "PassRate": "34%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 950, + "Title": "Reveal Cards In Increasing Order", + "TitleSlug": "reveal-cards-in-increasing-order", + "PassRate": "72%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 951, + "Title": "Flip Equivalent Binary Trees", + "TitleSlug": "flip-equivalent-binary-trees", + "PassRate": "65%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 952, + "Title": "Largest Component Size by Common Factor", + "TitleSlug": "largest-component-size-by-common-factor", + "PassRate": "27%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 953, + "Title": "Verifying an Alien Dictionary", + "TitleSlug": "verifying-an-alien-dictionary", + "PassRate": "55%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 954, + "Title": "Array of Doubled Pairs", + "TitleSlug": "array-of-doubled-pairs", + "PassRate": "35%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 955, + "Title": "Delete Columns to Make Sorted II", + "TitleSlug": "delete-columns-to-make-sorted-ii", + "PassRate": "32%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 956, + "Title": "Tallest Billboard", + "TitleSlug": "tallest-billboard", + "PassRate": "38%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 957, + "Title": "Prison Cells After N Days", + "TitleSlug": "prison-cells-after-n-days", + "PassRate": "38%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 958, + "Title": "Check Completeness of a Binary Tree", + "TitleSlug": "check-completeness-of-a-binary-tree", + "PassRate": "50%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 959, + "Title": "Regions Cut By Slashes", + "TitleSlug": "regions-cut-by-slashes", + "PassRate": "63%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 960, + "Title": "Delete Columns to Make Sorted III", + "TitleSlug": "delete-columns-to-make-sorted-iii", + "PassRate": "52%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 961, + "Title": "N-Repeated Element in Size 2N Array", + "TitleSlug": "n-repeated-element-in-size-2n-array", + "PassRate": "72%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 962, + "Title": "Maximum Width Ramp", + "TitleSlug": "maximum-width-ramp", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 963, + "Title": "Minimum Area Rectangle II", + "TitleSlug": "minimum-area-rectangle-ii", + "PassRate": "47%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 964, + "Title": "Least Operators to Express Number", + "TitleSlug": "least-operators-to-express-number", + "PassRate": "41%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 965, + "Title": "Univalued Binary Tree", + "TitleSlug": "univalued-binary-tree", + "PassRate": "66%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 966, + "Title": "Vowel Spellchecker", + "TitleSlug": "vowel-spellchecker", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 967, + "Title": "Numbers With Same Consecutive Differences", + "TitleSlug": "numbers-with-same-consecutive-differences", + "PassRate": "38%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 968, + "Title": "Binary Tree Cameras", + "TitleSlug": "binary-tree-cameras", + "PassRate": "36%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 969, + "Title": "Pancake Sorting", + "TitleSlug": "pancake-sorting", + "PassRate": "62%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 970, + "Title": "Powerful Integers", + "TitleSlug": "powerful-integers", + "PassRate": "39%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 971, + "Title": "Flip Binary Tree To Match Preorder Traversal", + "TitleSlug": "flip-binary-tree-to-match-preorder-traversal", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 972, + "Title": "Equal Rational Numbers", + "TitleSlug": "equal-rational-numbers", + "PassRate": "40%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 973, + "Title": "K Closest Points to Origin", + "TitleSlug": "k-closest-points-to-origin", + "PassRate": "61%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 974, + "Title": "Subarray Sums Divisible by K", + "TitleSlug": "subarray-sums-divisible-by-k", + "PassRate": "47%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 975, + "Title": "Odd Even Jump", + "TitleSlug": "odd-even-jump", + "PassRate": "45%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 976, + "Title": "Largest Perimeter Triangle", + "TitleSlug": "largest-perimeter-triangle", + "PassRate": "57%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 977, + "Title": "Squares of a Sorted Array", + "TitleSlug": "squares-of-a-sorted-array", + "PassRate": "71%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 978, + "Title": "Longest Turbulent Subarray", + "TitleSlug": "longest-turbulent-subarray", + "PassRate": "45%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 979, + "Title": "Distribute Coins in Binary Tree", + "TitleSlug": "distribute-coins-in-binary-tree", + "PassRate": "67%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 980, + "Title": "Unique Paths III", + "TitleSlug": "unique-paths-iii", + "PassRate": "71%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 981, + "Title": "Time Based Key-Value Store", + "TitleSlug": "time-based-key-value-store", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 982, + "Title": "Triples with Bitwise AND Equal To Zero", + "TitleSlug": "triples-with-bitwise-and-equal-to-zero", + "PassRate": "54%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 983, + "Title": "Minimum Cost For Tickets", + "TitleSlug": "minimum-cost-for-tickets", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 984, + "Title": "String Without AAA or BBB", + "TitleSlug": "string-without-aaa-or-bbb", + "PassRate": "34%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 985, + "Title": "Sum of Even Numbers After Queries", + "TitleSlug": "sum-of-even-numbers-after-queries", + "PassRate": "62%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 986, + "Title": "Interval List Intersections", + "TitleSlug": "interval-list-intersections", + "PassRate": "64%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 987, + "Title": "Vertical Order Traversal of a Binary Tree", + "TitleSlug": "vertical-order-traversal-of-a-binary-tree", + "PassRate": "33%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 988, + "Title": "Smallest String Starting From Leaf", + "TitleSlug": "smallest-string-starting-from-leaf", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 989, + "Title": "Add to Array-Form of Integer", + "TitleSlug": "add-to-array-form-of-integer", + "PassRate": "43%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 990, + "Title": "Satisfiability of Equality Equations", + "TitleSlug": "satisfiability-of-equality-equations", + "PassRate": "41%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 991, + "Title": "Broken Calculator", + "TitleSlug": "broken-calculator", + "PassRate": "42%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 992, + "Title": "Subarrays with K Different Integers", + "TitleSlug": "subarrays-with-k-different-integers", + "PassRate": "45%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 993, + "Title": "Cousins in Binary Tree", + "TitleSlug": "cousins-in-binary-tree", + "PassRate": "51%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 994, + "Title": "Rotting Oranges", + "TitleSlug": "rotting-oranges", + "PassRate": "46%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 995, + "Title": "Minimum Number of K Consecutive Bit Flips", + "TitleSlug": "minimum-number-of-k-consecutive-bit-flips", + "PassRate": "46%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 996, + "Title": "Number of Squareful Arrays", + "TitleSlug": "number-of-squareful-arrays", + "PassRate": "47%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 997, + "Title": "Find the Town Judge", + "TitleSlug": "find-the-town-judge", + "PassRate": "49%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 998, + "Title": "Maximum Binary Tree II", + "TitleSlug": "maximum-binary-tree-ii", + "PassRate": "61%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 999, + "Title": "Available Captures for Rook", + "TitleSlug": "available-captures-for-rook", + "PassRate": "65%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1000, + "Title": "Minimum Cost to Merge Stones", + "TitleSlug": "minimum-cost-to-merge-stones", + "PassRate": "36%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1001, + "Title": "Grid Illumination", + "TitleSlug": "grid-illumination", + "PassRate": "34%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1002, + "Title": "Find Common Characters", + "TitleSlug": "find-common-characters", + "PassRate": "65%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1003, + "Title": "Check If Word Is Valid After Substitutions", + "TitleSlug": "check-if-word-is-valid-after-substitutions", + "PassRate": "53%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1004, + "Title": "Max Consecutive Ones III", + "TitleSlug": "max-consecutive-ones-iii", + "PassRate": "55%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1005, + "Title": "Maximize Sum Of Array After K Negations", + "TitleSlug": "maximize-sum-of-array-after-k-negations", + "PassRate": "50%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1006, + "Title": "Clumsy Factorial", + "TitleSlug": "clumsy-factorial", + "PassRate": "53%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1007, + "Title": "Minimum Domino Rotations For Equal Row", + "TitleSlug": "minimum-domino-rotations-for-equal-row", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1008, + "Title": "Construct Binary Search Tree from Preorder Traversal", + "TitleSlug": "construct-binary-search-tree-from-preorder-traversal", + "PassRate": "73%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1009, + "Title": "Complement of Base 10 Integer", + "TitleSlug": "complement-of-base-10-integer", + "PassRate": "59%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1010, + "Title": "Pairs of Songs With Total Durations Divisible by 60", + "TitleSlug": "pairs-of-songs-with-total-durations-divisible-by-60", + "PassRate": "46%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1011, + "Title": "Capacity To Ship Packages Within D Days", + "TitleSlug": "capacity-to-ship-packages-within-d-days", + "PassRate": "55%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1012, + "Title": "Numbers With Repeated Digits", + "TitleSlug": "numbers-with-repeated-digits", + "PassRate": "35%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1013, + "Title": "Partition Array Into Three Parts With Equal Sum", + "TitleSlug": "partition-array-into-three-parts-with-equal-sum", + "PassRate": "56%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1014, + "Title": "Best Sightseeing Pair", + "TitleSlug": "best-sightseeing-pair", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1015, + "Title": "Smallest Integer Divisible by K", + "TitleSlug": "smallest-integer-divisible-by-k", + "PassRate": "30%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1016, + "Title": "Binary String With Substrings Representing 1 To N", + "TitleSlug": "binary-string-with-substrings-representing-1-to-n", + "PassRate": "58%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1017, + "Title": "Convert to Base -2", + "TitleSlug": "convert-to-base-2", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1018, + "Title": "Binary Prefix Divisible By 5", + "TitleSlug": "binary-prefix-divisible-by-5", + "PassRate": "46%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1019, + "Title": "Next Greater Node In Linked List", + "TitleSlug": "next-greater-node-in-linked-list", + "PassRate": "56%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1020, + "Title": "Number of Enclaves", + "TitleSlug": "number-of-enclaves", + "PassRate": "54%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1021, + "Title": "Remove Outermost Parentheses", + "TitleSlug": "remove-outermost-parentheses", + "PassRate": "75%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1022, + "Title": "Sum of Root To Leaf Binary Numbers", + "TitleSlug": "sum-of-root-to-leaf-binary-numbers", + "PassRate": "61%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1023, + "Title": "Camelcase Matching", + "TitleSlug": "camelcase-matching", + "PassRate": "54%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1024, + "Title": "Video Stitching", + "TitleSlug": "video-stitching", + "PassRate": "47%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1025, + "Title": "Divisor Game", + "TitleSlug": "divisor-game", + "PassRate": "65%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1026, + "Title": "Maximum Difference Between Node and Ancestor", + "TitleSlug": "maximum-difference-between-node-and-ancestor", + "PassRate": "61%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1027, + "Title": "Longest Arithmetic Sequence", + "TitleSlug": "longest-arithmetic-sequence", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1028, + "Title": "Recover a Tree From Preorder Traversal", + "TitleSlug": "recover-a-tree-from-preorder-traversal", + "PassRate": "69%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1029, + "Title": "Two City Scheduling", + "TitleSlug": "two-city-scheduling", + "PassRate": "55%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1030, + "Title": "Matrix Cells in Distance Order", + "TitleSlug": "matrix-cells-in-distance-order", + "PassRate": "64%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1031, + "Title": "Maximum Sum of Two Non-Overlapping Subarrays", + "TitleSlug": "maximum-sum-of-two-non-overlapping-subarrays", + "PassRate": "55%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1032, + "Title": "Stream of Characters", + "TitleSlug": "stream-of-characters", + "PassRate": "45%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1033, + "Title": "Moving Stones Until Consecutive", + "TitleSlug": "moving-stones-until-consecutive", + "PassRate": "38%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1034, + "Title": "Coloring A Border", + "TitleSlug": "coloring-a-border", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1035, + "Title": "Uncrossed Lines", + "TitleSlug": "uncrossed-lines", + "PassRate": "52%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1036, + "Title": "Escape a Large Maze", + "TitleSlug": "escape-a-large-maze", + "PassRate": "34%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1037, + "Title": "Valid Boomerang", + "TitleSlug": "valid-boomerang", + "PassRate": "37%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1038, + "Title": "Binary Search Tree to Greater Sum Tree", + "TitleSlug": "binary-search-tree-to-greater-sum-tree", + "PassRate": "77%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1039, + "Title": "Minimum Score Triangulation of Polygon", + "TitleSlug": "minimum-score-triangulation-of-polygon", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1040, + "Title": "Moving Stones Until Consecutive II", + "TitleSlug": "moving-stones-until-consecutive-ii", + "PassRate": "49%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1041, + "Title": "Robot Bounded In Circle", + "TitleSlug": "robot-bounded-in-circle", + "PassRate": "46%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1042, + "Title": "Flower Planting With No Adjacent", + "TitleSlug": "flower-planting-with-no-adjacent", + "PassRate": "47%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1043, + "Title": "Partition Array for Maximum Sum", + "TitleSlug": "partition-array-for-maximum-sum", + "PassRate": "62%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1044, + "Title": "Longest Duplicate Substring", + "TitleSlug": "longest-duplicate-substring", + "PassRate": "23%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1046, + "Title": "Last Stone Weight", + "TitleSlug": "last-stone-weight", + "PassRate": "62%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1047, + "Title": "Remove All Adjacent Duplicates In String", + "TitleSlug": "remove-all-adjacent-duplicates-in-string", + "PassRate": "65%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1048, + "Title": "Longest String Chain", + "TitleSlug": "longest-string-chain", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1049, + "Title": "Last Stone Weight II", + "TitleSlug": "last-stone-weight-ii", + "PassRate": "41%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1051, + "Title": "Height Checker", + "TitleSlug": "height-checker", + "PassRate": "68%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1052, + "Title": "Grumpy Bookstore Owner", + "TitleSlug": "grumpy-bookstore-owner", + "PassRate": "53%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1053, + "Title": "Previous Permutation With One Swap", + "TitleSlug": "previous-permutation-with-one-swap", + "PassRate": "46%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1054, + "Title": "Distant Barcodes", + "TitleSlug": "distant-barcodes", + "PassRate": "40%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1055, + "Title": "Shortest Way to Form String", + "TitleSlug": "shortest-way-to-form-string", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1056, + "Title": "Confusing Number", + "TitleSlug": "confusing-number", + "PassRate": "50%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1057, + "Title": "Campus Bikes", + "TitleSlug": "campus-bikes", + "PassRate": "58%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1058, + "Title": "Minimize Rounding Error to Meet Target", + "TitleSlug": "minimize-rounding-error-to-meet-target", + "PassRate": "40%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1059, + "Title": "All Paths from Source Lead to Destination", + "TitleSlug": "all-paths-from-source-lead-to-destination", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1060, + "Title": "Missing Element in Sorted Array", + "TitleSlug": "missing-element-in-sorted-array", + "PassRate": "53%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1061, + "Title": "Lexicographically Smallest Equivalent String", + "TitleSlug": "lexicographically-smallest-equivalent-string", + "PassRate": "62%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1062, + "Title": "Longest Repeating Substring", + "TitleSlug": "longest-repeating-substring", + "PassRate": "52%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1063, + "Title": "Number of Valid Subarrays", + "TitleSlug": "number-of-valid-subarrays", + "PassRate": "71%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1064, + "Title": "Fixed Point", + "TitleSlug": "fixed-point", + "PassRate": "71%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1065, + "Title": "Index Pairs of a String", + "TitleSlug": "index-pairs-of-a-string", + "PassRate": "57%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1066, + "Title": "Campus Bikes II", + "TitleSlug": "campus-bikes-ii", + "PassRate": "52%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1067, + "Title": "Digit Count in Range", + "TitleSlug": "digit-count-in-range", + "PassRate": "38%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1071, + "Title": "Greatest Common Divisor of Strings", + "TitleSlug": "greatest-common-divisor-of-strings", + "PassRate": "53%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1072, + "Title": "Flip Columns For Maximum Number of Equal Rows", + "TitleSlug": "flip-columns-for-maximum-number-of-equal-rows", + "PassRate": "59%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1073, + "Title": "Adding Two Negabinary Numbers", + "TitleSlug": "adding-two-negabinary-numbers", + "PassRate": "32%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1074, + "Title": "Number of Submatrices That Sum to Target", + "TitleSlug": "number-of-submatrices-that-sum-to-target", + "PassRate": "58%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1078, + "Title": "Occurrences After Bigram", + "TitleSlug": "occurrences-after-bigram", + "PassRate": "64%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1079, + "Title": "Letter Tile Possibilities", + "TitleSlug": "letter-tile-possibilities", + "PassRate": "74%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1080, + "Title": "Insufficient Nodes in Root to Leaf Paths", + "TitleSlug": "insufficient-nodes-in-root-to-leaf-paths", + "PassRate": "45%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1081, + "Title": "Smallest Subsequence of Distinct Characters", + "TitleSlug": "smallest-subsequence-of-distinct-characters", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1085, + "Title": "Sum of Digits in the Minimum Number", + "TitleSlug": "sum-of-digits-in-the-minimum-number", + "PassRate": "74%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1086, + "Title": "High Five", + "TitleSlug": "high-five", + "PassRate": "75%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1087, + "Title": "Brace Expansion", + "TitleSlug": "brace-expansion", + "PassRate": "60%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1088, + "Title": "Confusing Number II", + "TitleSlug": "confusing-number-ii", + "PassRate": "37%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1089, + "Title": "Duplicate Zeros", + "TitleSlug": "duplicate-zeros", + "PassRate": "58%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1090, + "Title": "Largest Values From Labels", + "TitleSlug": "largest-values-from-labels", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1091, + "Title": "Shortest Path in Binary Matrix", + "TitleSlug": "shortest-path-in-binary-matrix", + "PassRate": "36%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1092, + "Title": "Shortest Common Supersequence ", + "TitleSlug": "shortest-common-supersequence", + "PassRate": "49%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1093, + "Title": "Statistics from a Large Sample", + "TitleSlug": "statistics-from-a-large-sample", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1094, + "Title": "Car Pooling", + "TitleSlug": "car-pooling", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1095, + "Title": "Find in Mountain Array", + "TitleSlug": "find-in-mountain-array", + "PassRate": "34%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1096, + "Title": "Brace Expansion II", + "TitleSlug": "brace-expansion-ii", + "PassRate": "59%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1099, + "Title": "Two Sum Less Than K", + "TitleSlug": "two-sum-less-than-k", + "PassRate": "59%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1100, + "Title": "Find K-Length Substrings With No Repeated Characters", + "TitleSlug": "find-k-length-substrings-with-no-repeated-characters", + "PassRate": "71%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1101, + "Title": "The Earliest Moment When Everyone Become Friends", + "TitleSlug": "the-earliest-moment-when-everyone-become-friends", + "PassRate": "65%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1102, + "Title": "Path With Maximum Minimum Value", + "TitleSlug": "path-with-maximum-minimum-value", + "PassRate": "46%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1103, + "Title": "Distribute Candies to People", + "TitleSlug": "distribute-candies-to-people", + "PassRate": "59%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1104, + "Title": "Path In Zigzag Labelled Binary Tree", + "TitleSlug": "path-in-zigzag-labelled-binary-tree", + "PassRate": "70%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1105, + "Title": "Filling Bookcase Shelves", + "TitleSlug": "filling-bookcase-shelves", + "PassRate": "56%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1106, + "Title": "Parsing A Boolean Expression", + "TitleSlug": "parsing-a-boolean-expression", + "PassRate": "57%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1108, + "Title": "Defanging an IP Address", + "TitleSlug": "defanging-an-ip-address", + "PassRate": "84%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1109, + "Title": "Corporate Flight Bookings", + "TitleSlug": "corporate-flight-bookings", + "PassRate": "49%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1110, + "Title": "Delete Nodes And Return Forest", + "TitleSlug": "delete-nodes-and-return-forest", + "PassRate": "64%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1111, + "Title": "Maximum Nesting Depth of Two Valid Parentheses Strings", + "TitleSlug": "maximum-nesting-depth-of-two-valid-parentheses-strings", + "PassRate": "67%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1118, + "Title": "Number of Days in a Month", + "TitleSlug": "number-of-days-in-a-month", + "PassRate": "56%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1119, + "Title": "Remove Vowels from a String", + "TitleSlug": "remove-vowels-from-a-string", + "PassRate": "87%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1120, + "Title": "Maximum Average Subtree", + "TitleSlug": "maximum-average-subtree", + "PassRate": "61%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1121, + "Title": "Divide Array Into Increasing Sequences", + "TitleSlug": "divide-array-into-increasing-sequences", + "PassRate": "54%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1122, + "Title": "Relative Sort Array", + "TitleSlug": "relative-sort-array", + "PassRate": "66%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1123, + "Title": "Lowest Common Ancestor of Deepest Leaves", + "TitleSlug": "lowest-common-ancestor-of-deepest-leaves", + "PassRate": "64%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1124, + "Title": "Longest Well-Performing Interval", + "TitleSlug": "longest-well-performing-interval", + "PassRate": "31%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1125, + "Title": "Smallest Sufficient Team", + "TitleSlug": "smallest-sufficient-team", + "PassRate": "44%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1128, + "Title": "Number of Equivalent Domino Pairs", + "TitleSlug": "number-of-equivalent-domino-pairs", + "PassRate": "46%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1129, + "Title": "Shortest Path with Alternating Colors", + "TitleSlug": "shortest-path-with-alternating-colors", + "PassRate": "37%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1130, + "Title": "Minimum Cost Tree From Leaf Values", + "TitleSlug": "minimum-cost-tree-from-leaf-values", + "PassRate": "62%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1131, + "Title": "Maximum of Absolute Value Expression", + "TitleSlug": "maximum-of-absolute-value-expression", + "PassRate": "52%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1133, + "Title": "Largest Unique Number", + "TitleSlug": "largest-unique-number", + "PassRate": "67%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1134, + "Title": "Armstrong Number", + "TitleSlug": "armstrong-number", + "PassRate": "77%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1135, + "Title": "Connecting Cities With Minimum Cost", + "TitleSlug": "connecting-cities-with-minimum-cost", + "PassRate": "54%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1136, + "Title": "Parallel Courses", + "TitleSlug": "parallel-courses", + "PassRate": "59%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1137, + "Title": "N-th Tribonacci Number", + "TitleSlug": "n-th-tribonacci-number", + "PassRate": "57%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1138, + "Title": "Alphabet Board Path", + "TitleSlug": "alphabet-board-path", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1139, + "Title": "Largest 1-Bordered Square", + "TitleSlug": "largest-1-bordered-square", + "PassRate": "44%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1140, + "Title": "Stone Game II", + "TitleSlug": "stone-game-ii", + "PassRate": "60%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1143, + "Title": "Longest Common Subsequence", + "TitleSlug": "longest-common-subsequence", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1144, + "Title": "Decrease Elements To Make Array Zigzag", + "TitleSlug": "decrease-elements-to-make-array-zigzag", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1145, + "Title": "Binary Tree Coloring Game", + "TitleSlug": "binary-tree-coloring-game", + "PassRate": "49%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1146, + "Title": "Snapshot Array", + "TitleSlug": "snapshot-array", + "PassRate": "34%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1147, + "Title": "Longest Chunked Palindrome Decomposition", + "TitleSlug": "longest-chunked-palindrome-decomposition", + "PassRate": "58%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1150, + "Title": "Check If a Number Is Majority Element in a Sorted Array", + "TitleSlug": "check-if-a-number-is-majority-element-in-a-sorted-array", + "PassRate": "60%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1151, + "Title": "Minimum Swaps to Group All 1's Together", + "TitleSlug": "minimum-swaps-to-group-all-1s-together", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1152, + "Title": "Analyze User Website Visit Pattern", + "TitleSlug": "analyze-user-website-visit-pattern", + "PassRate": "39%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1153, + "Title": "String Transforms Into Another String", + "TitleSlug": "string-transforms-into-another-string", + "PassRate": "33%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1154, + "Title": "Day of the Year", + "TitleSlug": "day-of-the-year", + "PassRate": "48%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1155, + "Title": "Number of Dice Rolls With Target Sum", + "TitleSlug": "number-of-dice-rolls-with-target-sum", + "PassRate": "48%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1156, + "Title": "Swap For Longest Repeated Character Substring", + "TitleSlug": "swap-for-longest-repeated-character-substring", + "PassRate": "46%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1157, + "Title": "Online Majority Element In Subarray", + "TitleSlug": "online-majority-element-in-subarray", + "PassRate": "33%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1160, + "Title": "Find Words That Can Be Formed by Characters", + "TitleSlug": "find-words-that-can-be-formed-by-characters", + "PassRate": "66%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1161, + "Title": "Maximum Level Sum of a Binary Tree", + "TitleSlug": "maximum-level-sum-of-a-binary-tree", + "PassRate": "70%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1162, + "Title": "As Far from Land as Possible", + "TitleSlug": "as-far-from-land-as-possible", + "PassRate": "40%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1163, + "Title": "Last Substring in Lexicographical Order", + "TitleSlug": "last-substring-in-lexicographical-order", + "PassRate": "30%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1165, + "Title": "Single-Row Keyboard", + "TitleSlug": "single-row-keyboard", + "PassRate": "84%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1166, + "Title": "Design File System", + "TitleSlug": "design-file-system", + "PassRate": "58%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1167, + "Title": "Minimum Cost to Connect Sticks", + "TitleSlug": "minimum-cost-to-connect-sticks", + "PassRate": "61%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1168, + "Title": "Optimize Water Distribution in a Village", + "TitleSlug": "optimize-water-distribution-in-a-village", + "PassRate": "56%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1169, + "Title": "Invalid Transactions", + "TitleSlug": "invalid-transactions", + "PassRate": "28%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1170, + "Title": "Compare Strings by Frequency of the Smallest Character", + "TitleSlug": "compare-strings-by-frequency-of-the-smallest-character", + "PassRate": "58%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1171, + "Title": "Remove Zero Sum Consecutive Nodes from Linked List", + "TitleSlug": "remove-zero-sum-consecutive-nodes-from-linked-list", + "PassRate": "41%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1172, + "Title": "Dinner Plate Stacks", + "TitleSlug": "dinner-plate-stacks", + "PassRate": "40%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1175, + "Title": "Prime Arrangements", + "TitleSlug": "prime-arrangements", + "PassRate": "50%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1176, + "Title": "Diet Plan Performance", + "TitleSlug": "diet-plan-performance", + "PassRate": "49%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1177, + "Title": "Can Make Palindrome from Substring", + "TitleSlug": "can-make-palindrome-from-substring", + "PassRate": "32%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1178, + "Title": "Number of Valid Words for Each Puzzle", + "TitleSlug": "number-of-valid-words-for-each-puzzle", + "PassRate": "35%", + "Difficulty": "Hard", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1180, + "Title": "Count Substrings with Only One Distinct Letter", + "TitleSlug": "count-substrings-with-only-one-distinct-letter", + "PassRate": "76%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1181, + "Title": "Before and After Puzzle", + "TitleSlug": "before-and-after-puzzle", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1182, + "Title": "Shortest Distance to Target Color", + "TitleSlug": "shortest-distance-to-target-color", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1183, + "Title": "Maximum Number of Ones", + "TitleSlug": "maximum-number-of-ones", + "PassRate": "48%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1184, + "Title": "Distance Between Bus Stops", + "TitleSlug": "distance-between-bus-stops", + "PassRate": "56%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1185, + "Title": "Day of the Week", + "TitleSlug": "day-of-the-week", + "PassRate": "64%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1186, + "Title": "Maximum Subarray Sum with One Deletion", + "TitleSlug": "maximum-subarray-sum-with-one-deletion", + "PassRate": "33%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1187, + "Title": "Make Array Strictly Increasing", + "TitleSlug": "make-array-strictly-increasing", + "PassRate": "40%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1189, + "Title": "Maximum Number of Balloons", + "TitleSlug": "maximum-number-of-balloons", + "PassRate": "61%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1190, + "Title": "Reverse Substrings Between Each Pair of Parentheses", + "TitleSlug": "reverse-substrings-between-each-pair-of-parentheses", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": true, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1191, + "Title": "K-Concatenation Maximum Sum", + "TitleSlug": "k-concatenation-maximum-sum", + "PassRate": "24%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1192, + "Title": "Critical Connections in a Network", + "TitleSlug": "critical-connections-in-a-network", + "PassRate": "47%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1196, + "Title": "How Many Apples Can You Put into the Basket", + "TitleSlug": "how-many-apples-can-you-put-into-the-basket", + "PassRate": "69%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1197, + "Title": "Minimum Knight Moves", + "TitleSlug": "minimum-knight-moves", + "PassRate": "30%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1198, + "Title": "Find Smallest Common Element in All Rows", + "TitleSlug": "find-smallest-common-element-in-all-rows", + "PassRate": "73%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1199, + "Title": "Minimum Time to Build Blocks", + "TitleSlug": "minimum-time-to-build-blocks", + "PassRate": "33%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1200, + "Title": "Minimum Absolute Difference", + "TitleSlug": "minimum-absolute-difference", + "PassRate": "66%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1201, + "Title": "Ugly Number III", + "TitleSlug": "ugly-number-iii", + "PassRate": "24%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1202, + "Title": "Smallest String With Swaps", + "TitleSlug": "smallest-string-with-swaps", + "PassRate": "41%", + "Difficulty": "Medium", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1203, + "Title": "Sort Items by Groups Respecting Dependencies", + "TitleSlug": "sort-items-by-groups-respecting-dependencies", + "PassRate": "45%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1206, + "Title": "Design Skiplist", + "TitleSlug": "design-skiplist", + "PassRate": "60%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1207, + "Title": "Unique Number of Occurrences", + "TitleSlug": "unique-number-of-occurrences", + "PassRate": "72%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1208, + "Title": "Get Equal Substrings Within Budget", + "TitleSlug": "get-equal-substrings-within-budget", + "PassRate": "36%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1209, + "Title": "Remove All Adjacent Duplicates in String II", + "TitleSlug": "remove-all-adjacent-duplicates-in-string-ii", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1210, + "Title": "Minimum Moves to Reach Target with Rotations", + "TitleSlug": "minimum-moves-to-reach-target-with-rotations", + "PassRate": "43%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1213, + "Title": "Intersection of Three Sorted Arrays", + "TitleSlug": "intersection-of-three-sorted-arrays", + "PassRate": "77%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1214, + "Title": "Two Sum BSTs", + "TitleSlug": "two-sum-bsts", + "PassRate": "64%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1215, + "Title": "Stepping Numbers", + "TitleSlug": "stepping-numbers", + "PassRate": "36%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1216, + "Title": "Valid Palindrome III", + "TitleSlug": "valid-palindrome-iii", + "PassRate": "41%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1217, + "Title": "Play with Chips", + "TitleSlug": "play-with-chips", + "PassRate": "63%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1218, + "Title": "Longest Arithmetic Subsequence of Given Difference", + "TitleSlug": "longest-arithmetic-subsequence-of-given-difference", + "PassRate": "38%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1219, + "Title": "Path with Maximum Gold", + "TitleSlug": "path-with-maximum-gold", + "PassRate": "61%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1220, + "Title": "Count Vowels Permutation", + "TitleSlug": "count-vowels-permutation", + "PassRate": "51%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1221, + "Title": "Split a String in Balanced Strings", + "TitleSlug": "split-a-string-in-balanced-strings", + "PassRate": "78%", + "Difficulty": "Easy", + "IsAccepted": true, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1222, + "Title": "Queens That Can Attack the King", + "TitleSlug": "queens-that-can-attack-the-king", + "PassRate": "68%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1223, + "Title": "Dice Roll Simulation", + "TitleSlug": "dice-roll-simulation", + "PassRate": "42%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1224, + "Title": "Maximum Equal Frequency", + "TitleSlug": "maximum-equal-frequency", + "PassRate": "31%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1227, + "Title": "Airplane Seat Assignment Probability", + "TitleSlug": "airplane-seat-assignment-probability", + "PassRate": "61%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1228, + "Title": "Missing Number In Arithmetic Progression", + "TitleSlug": "missing-number-in-arithmetic-progression", + "PassRate": "52%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1229, + "Title": "Meeting Scheduler", + "TitleSlug": "meeting-scheduler", + "PassRate": "40%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1230, + "Title": "Toss Strange Coins", + "TitleSlug": "toss-strange-coins", + "PassRate": "43%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1231, + "Title": "Divide Chocolate", + "TitleSlug": "divide-chocolate", + "PassRate": "49%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1232, + "Title": "Check If It Is a Straight Line", + "TitleSlug": "check-if-it-is-a-straight-line", + "PassRate": "47%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1233, + "Title": "Remove Sub-Folders from the Filesystem", + "TitleSlug": "remove-sub-folders-from-the-filesystem", + "PassRate": "53%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1234, + "Title": "Replace the Substring for Balanced String", + "TitleSlug": "replace-the-substring-for-balanced-string", + "PassRate": "29%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1235, + "Title": "Maximum Profit in Job Scheduling", + "TitleSlug": "maximum-profit-in-job-scheduling", + "PassRate": "44%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1236, + "Title": "Web Crawler", + "TitleSlug": "web-crawler", + "PassRate": "63%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1237, + "Title": "Find Positive Integer Solution for a Given Equation", + "TitleSlug": "find-positive-integer-solution-for-a-given-equation", + "PassRate": "65%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1238, + "Title": "Circular Permutation in Binary Representation", + "TitleSlug": "circular-permutation-in-binary-representation", + "PassRate": "57%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1239, + "Title": "Maximum Length of a Concatenated String with Unique Characters", + "TitleSlug": "maximum-length-of-a-concatenated-string-with-unique-characters", + "PassRate": "40%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1240, + "Title": "Tiling a Rectangle with the Fewest Squares", + "TitleSlug": "tiling-a-rectangle-with-the-fewest-squares", + "PassRate": "48%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 0, + "Title": "", + "TitleSlug": "", + "PassRate": "", + "Difficulty": "", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1243, + "Title": "Array Transformation", + "TitleSlug": "array-transformation", + "PassRate": "51%", + "Difficulty": "Easy", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1244, + "Title": "Design A Leaderboard", + "TitleSlug": "design-a-leaderboard", + "PassRate": "51%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1245, + "Title": "Tree Diameter", + "TitleSlug": "tree-diameter", + "PassRate": "52%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1246, + "Title": "Palindrome Removal", + "TitleSlug": "palindrome-removal", + "PassRate": "41%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": true, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1247, + "Title": "Minimum Swaps to Make Strings Equal", + "TitleSlug": "minimum-swaps-to-make-strings-equal", + "PassRate": "56%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1248, + "Title": "Count Number of Nice Subarrays", + "TitleSlug": "count-number-of-nice-subarrays", + "PassRate": "50%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1249, + "Title": "Minimum Remove to Make Valid Parentheses", + "TitleSlug": "minimum-remove-to-make-valid-parentheses", + "PassRate": "55%", + "Difficulty": "Medium", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, + "HasNoGoOption": false + }, + { + "ID": 1250, + "Title": "Check If It Is a Good Array", + "TitleSlug": "check-if-it-is-a-good-array", + "PassRate": "46%", + "Difficulty": "Hard", + "IsAccepted": false, + "IsPaid": false, + "IsFavor": false, + "IsNew": false, "HasNoGoOption": false } ] diff --git a/routine/union-find/union-find.go b/routine/union-find/union-find.go new file mode 100644 index 000000000..6358430cf --- /dev/null +++ b/routine/union-find/union-find.go @@ -0,0 +1,28 @@ +package unionfind + +// leetcode 中需要 union 的集合都太小了,最普通的集合算法,就够用了 + +type unionFind struct { + parent []int +} + +func newUnionFind(size int) *unionFind { + parent := make([]int, size) + for i := range parent { + parent[i] = i + } + return &unionFind{ + parent: parent, + } +} + +func (u *unionFind) find(i int) int { + if u.parent[i] != i { + u.parent[i] = u.find(u.parent[i]) + } + return u.parent[i] +} + +func (u *unionFind) union(x, y int) { + u.parent[u.find(x)] = u.find(y) +} diff --git a/template.markdown b/template.markdown index 32147a3b2..e04a1c7e9 100755 --- a/template.markdown +++ b/template.markdown @@ -1,26 +1,26 @@ -# [LeetCode](https://leetcode.com) 的 Go 解答 {{/* 本文件是用来生成 README.md 的模板 */}} +# [LeetCode](https://leetcode.com) 的 Go 解答 {{- /* 本文件是用来生成 README.md 的模板 */}} [![LeetCode 排名](https://img.shields.io/badge/{{.Username}}-{{.Ranking}}-blue.svg)](https://leetcode.com/{{.Username}}/) [![codecov](https://codecov.io/gh/aQuaYi/LeetCode-in-Go/branch/master/graph/badge.svg)](https://codecov.io/gh/aQuaYi/LeetCode-in-Go) [![Build Status](https://www.travis-ci.org/aQuaYi/LeetCode-in-Go.svg?branch=master)](https://www.travis-ci.org/aQuaYi/LeetCode-in-Go) + [![Go](https://img.shields.io/badge/Go-1.13-blue.svg)](https://golang.google.cn) ## 进度 -> 统计规则:1.免费题,2.算法题,3.能用 Go 解答 +> 统计规则:1.免费题,2.算法题,3.能提交 Go 解答 {{.ProgressTable}} ## 题解 {{.AvailableTable}} - -以下免费的算法题,暂时不能使用 Go 解答 +以下免费的算法题,暂时不能提交 Go 解答 {{.UnavailableList}} ## helper -[helper](./helper) 会处理大部分琐碎的工作。 +[helper](./Helper) 会处理大部分琐碎的工作。 ## notes @@ -28,7 +28,7 @@ ## kit -针对 LeetCode 中经常出现的以下数据结构,在 [kit](./kit) 中进行了定义,并添加了与 []int 相互转换的函数。利用 Go 1.9 新添加的 [type alias](https://github.com/golang/proposal/blob/master/design/18130-type-alias.md) 功能,易于添加单元测试。 +针对 LeetCode 中经常出现的以下数据结构,在 [kit](./kit) 中进行了定义,并添加了与 []int 相互转换的函数。利用 Go 1.9 添加的 [type alias](https://github.com/golang/proposal/blob/master/design/18130-type-alias.md) 功能,易于添加单元测试。 - [Heap](./kit/Heap.go) - [Interval](./kit/Interval.go) @@ -38,3 +38,14 @@ - [Queue](./kit/Queue.go) - [Stack](./kit/Stack.go) - [TreeNode](./kit/TreeNode.go) +- [Master](./kit/master.go) + +## 致谢 + +感谢所有贡献者的辛苦付出 + + + +感谢 JetBrains + +[![GoLand](GoLand.png)]( https://www.jetbrains.com/?from=LeetCode-in-Go) diff --git a/test.sh b/test.sh index a2e5a9952..c279d1d95 100644 --- a/test.sh +++ b/test.sh @@ -3,7 +3,7 @@ set -e echo "" > coverage.txt -for d in $(go list ./... | grep -v vendor); do +for d in $(go list ./Algorithms/... | grep -v vendor); do echo $d go test -coverprofile=profile.out -covermode=atomic $d if [ -f profile.out ]; then diff --git a/unavailable.json b/unavailable.json index c8f3c4f4b..63fa65539 100644 --- a/unavailable.json +++ b/unavailable.json @@ -1 +1,26 @@ -{"List":[116,117,133,138,141,142,151,160,173,190,191,222,235,236,237,278,284,297,341,374,386,449,535,690]} \ No newline at end of file +{ + "List": [ + 116, + 117, + 133, + 138, + 151, + 278, + 284, + 297, + 341, + 374, + 426, + 427, + 429, + 430, + 449, + 535, + 558, + 559, + 589, + 590, + 690, + 708 + ] +} \ No newline at end of file