├── templates └── style.css ├── README.md └── Qdata ├── 3 └── 3.txt ├── 4 └── 4.txt ├── 6 └── 6.txt ├── 8 └── 8.txt ├── 22 └── 22.txt ├── 24 └── 24.txt ├── 28 └── 28.txt ├── 49 └── 49.txt ├── 59 └── 59.txt ├── 60 └── 60.txt ├── 62 └── 62.txt ├── 72 └── 72.txt ├── 81 └── 81.txt ├── 82 └── 82.txt ├── 88 └── 88.txt ├── 108 └── 108.txt ├── 123 └── 123.txt ├── 132 └── 132.txt ├── 133 └── 133.txt ├── 135 └── 135.txt ├── 145 └── 145.txt ├── 180 └── 180.txt ├── 186 └── 186.txt ├── 191 └── 191.txt ├── 202 └── 202.txt ├── 209 └── 209.txt ├── 228 └── 228.txt ├── 237 └── 237.txt ├── 251 └── 251.txt ├── 252 └── 252.txt ├── 254 └── 254.txt ├── 259 └── 259.txt ├── 271 └── 271.txt ├── 292 └── 292.txt ├── 304 └── 304.txt ├── 305 └── 305.txt ├── 307 └── 307.txt ├── 313 └── 313.txt ├── 315 └── 315.txt ├── 317 └── 317.txt ├── 325 └── 325.txt ├── 326 └── 326.txt ├── 333 └── 333.txt ├── 336 └── 336.txt ├── 344 └── 344.txt ├── 354 └── 354.txt ├── 358 └── 358.txt ├── 369 └── 369.txt ├── 374 └── 374.txt ├── 375 └── 375.txt ├── 381 └── 381.txt ├── 382 └── 382.txt ├── 386 └── 386.txt ├── 388 └── 388.txt ├── 390 └── 390.txt ├── 391 └── 391.txt ├── 394 └── 394.txt ├── 395 └── 395.txt ├── 401 └── 401.txt ├── 405 └── 405.txt ├── 410 └── 410.txt ├── 413 └── 413.txt ├── 423 └── 423.txt ├── 436 └── 436.txt ├── 440 └── 440.txt ├── 445 └── 445.txt ├── 446 └── 446.txt ├── 450 └── 450.txt ├── 454 └── 454.txt ├── 466 └── 466.txt ├── 484 └── 484.txt ├── 486 └── 486.txt ├── 498 └── 498.txt ├── 511 └── 511.txt ├── 515 └── 515.txt ├── 517 └── 517.txt ├── 528 └── 528.txt ├── 532 └── 532.txt ├── 533 └── 533.txt ├── 536 └── 536.txt ├── 539 └── 539.txt ├── 560 └── 560.txt ├── 561 └── 561.txt ├── 567 └── 567.txt ├── 572 └── 572.txt ├── 573 └── 573.txt ├── 577 └── 577.txt ├── 578 └── 578.txt ├── 589 └── 589.txt ├── 597 └── 597.txt ├── 603 └── 603.txt ├── 609 └── 609.txt ├── 613 └── 613.txt ├── 619 └── 619.txt ├── 627 └── 627.txt ├── 640 └── 640.txt ├── 645 └── 645.txt ├── 648 └── 648.txt ├── 653 └── 653.txt ├── 655 └── 655.txt ├── 656 └── 656.txt ├── 669 └── 669.txt ├── 684 └── 684.txt ├── 685 └── 685.txt ├── 692 └── 692.txt ├── 698 └── 698.txt ├── 703 └── 703.txt ├── 704 └── 704.txt ├── 710 └── 710.txt ├── 713 └── 713.txt ├── 715 └── 715.txt ├── 722 └── 722.txt ├── 737 └── 737.txt ├── 738 └── 738.txt ├── 748 └── 748.txt ├── 749 └── 749.txt ├── 759 └── 759.txt ├── 764 └── 764.txt ├── 765 └── 765.txt ├── 767 └── 767.txt ├── 779 └── 779.txt ├── 781 └── 781.txt ├── 799 └── 799.txt ├── 805 └── 805.txt ├── 806 └── 806.txt ├── 844 └── 844.txt ├── 857 └── 857.txt ├── 863 └── 863.txt ├── 864 └── 864.txt ├── 865 └── 865.txt ├── 871 └── 871.txt ├── 873 └── 873.txt ├── 875 └── 875.txt ├── 891 └── 891.txt ├── 901 └── 901.txt ├── 904 └── 904.txt ├── 910 └── 910.txt ├── 935 └── 935.txt ├── 941 └── 941.txt ├── 945 └── 945.txt ├── 952 └── 952.txt ├── 954 └── 954.txt ├── 964 └── 964.txt ├── 980 └── 980.txt ├── 981 └── 981.txt ├── 983 └── 983.txt ├── 989 └── 989.txt ├── 991 └── 991.txt ├── 995 └── 995.txt ├── 998 └── 998.txt ├── 1001 └── 1001.txt ├── 1002 └── 1002.txt ├── 1005 └── 1005.txt ├── 1013 └── 1013.txt ├── 1016 └── 1016.txt ├── 1018 └── 1018.txt ├── 1021 └── 1021.txt ├── 1055 └── 1055.txt ├── 1056 └── 1056.txt ├── 1059 └── 1059.txt ├── 1074 └── 1074.txt ├── 1082 └── 1082.txt ├── 1083 └── 1083.txt ├── 1087 └── 1087.txt ├── 1088 └── 1088.txt ├── 1092 └── 1092.txt ├── 1093 └── 1093.txt ├── 1099 └── 1099.txt ├── 1112 └── 1112.txt ├── 1116 └── 1116.txt ├── 1120 └── 1120.txt ├── 1121 └── 1121.txt ├── 1136 └── 1136.txt ├── 1137 └── 1137.txt ├── 1157 └── 1157.txt ├── 1174 └── 1174.txt ├── 1176 └── 1176.txt ├── 1185 └── 1185.txt ├── 1187 └── 1187.txt ├── 1188 └── 1188.txt ├── 1194 └── 1194.txt ├── 1195 └── 1195.txt ├── 1196 └── 1196.txt ├── 1203 └── 1203.txt ├── 1206 └── 1206.txt ├── 1214 └── 1214.txt ├── 1215 └── 1215.txt ├── 1221 └── 1221.txt ├── 1222 └── 1222.txt ├── 1223 └── 1223.txt ├── 1234 └── 1234.txt ├── 1243 └── 1243.txt ├── 1259 └── 1259.txt ├── 1264 └── 1264.txt ├── 1274 └── 1274.txt ├── 1281 └── 1281.txt ├── 1291 └── 1291.txt ├── 1292 └── 1292.txt ├── 1294 └── 1294.txt ├── 1295 └── 1295.txt ├── 1307 └── 1307.txt ├── 1309 └── 1309.txt ├── 1314 └── 1314.txt ├── 1316 └── 1316.txt ├── 1318 └── 1318.txt ├── 1329 └── 1329.txt ├── 1336 └── 1336.txt ├── 1338 └── 1338.txt ├── 1347 └── 1347.txt ├── 1352 └── 1352.txt ├── 1357 └── 1357.txt ├── 1368 └── 1368.txt ├── 1386 └── 1386.txt ├── 1394 └── 1394.txt ├── 1411 └── 1411.txt ├── 1413 └── 1413.txt ├── 1417 └── 1417.txt ├── 1419 └── 1419.txt ├── 1423 └── 1423.txt ├── 1430 └── 1430.txt ├── 1438 └── 1438.txt ├── 1440 └── 1440.txt ├── 1441 └── 1441.txt ├── 1443 └── 1443.txt ├── 1466 └── 1466.txt ├── 1470 └── 1470.txt ├── 1471 └── 1471.txt ├── 1472 └── 1472.txt ├── 1478 └── 1478.txt ├── 1483 └── 1483.txt ├── 1484 └── 1484.txt ├── 1489 └── 1489.txt ├── 1491 └── 1491.txt ├── 1492 └── 1492.txt ├── 1499 └── 1499.txt ├── 1507 └── 1507.txt ├── 1510 └── 1510.txt ├── 1524 └── 1524.txt ├── 1525 └── 1525.txt ├── 1535 └── 1535.txt ├── 1538 └── 1538.txt ├── 1542 └── 1542.txt ├── 1544 └── 1544.txt ├── 1554 └── 1554.txt ├── 1556 └── 1556.txt ├── 1570 └── 1570.txt ├── 1579 └── 1579.txt ├── 1580 └── 1580.txt ├── 1590 └── 1590.txt ├── 1592 └── 1592.txt ├── 1593 └── 1593.txt ├── 1596 └── 1596.txt ├── 1599 └── 1599.txt ├── 1639 └── 1639.txt ├── 1653 └── 1653.txt ├── 1658 └── 1658.txt ├── 1661 └── 1661.txt ├── 1668 └── 1668.txt ├── 1684 └── 1684.txt ├── 1689 └── 1689.txt ├── 1692 └── 1692.txt ├── 1693 └── 1693.txt ├── 1714 └── 1714.txt ├── 1716 └── 1716.txt ├── 1732 └── 1732.txt ├── 1743 └── 1743.txt ├── 1744 └── 1744.txt ├── 1748 └── 1748.txt ├── 1752 └── 1752.txt ├── 1765 └── 1765.txt ├── 1770 └── 1770.txt ├── 1773 └── 1773.txt ├── 1783 └── 1783.txt ├── 1806 └── 1806.txt ├── 1820 └── 1820.txt ├── 1825 └── 1825.txt ├── 1831 └── 1831.txt ├── 1840 └── 1840.txt ├── 1841 └── 1841.txt ├── 1849 └── 1849.txt ├── 1858 └── 1858.txt ├── 1862 └── 1862.txt ├── 1865 └── 1865.txt ├── 1888 └── 1888.txt ├── 1890 └── 1890.txt ├── 1901 └── 1901.txt ├── 1933 └── 1933.txt ├── 1941 └── 1941.txt ├── 1954 └── 1954.txt ├── 1960 └── 1960.txt ├── 1992 └── 1992.txt ├── 1995 └── 1995.txt ├── 1999 └── 1999.txt ├── 2003 └── 2003.txt ├── 2004 └── 2004.txt ├── 2015 └── 2015.txt ├── 2018 └── 2018.txt ├── 2029 └── 2029.txt ├── 2030 └── 2030.txt ├── 2037 └── 2037.txt ├── 2050 └── 2050.txt ├── 2056 └── 2056.txt ├── 2068 └── 2068.txt ├── 2072 └── 2072.txt ├── 2074 └── 2074.txt ├── 2077 └── 2077.txt ├── 2085 └── 2085.txt ├── 2088 └── 2088.txt ├── 2109 └── 2109.txt ├── 2117 └── 2117.txt ├── 2124 └── 2124.txt ├── 2130 └── 2130.txt ├── 2143 └── 2143.txt ├── 2152 └── 2152.txt ├── 2158 └── 2158.txt ├── 2163 └── 2163.txt ├── 2168 └── 2168.txt ├── 2177 └── 2177.txt ├── 2178 └── 2178.txt ├── 2179 └── 2179.txt ├── 2181 └── 2181.txt ├── 2182 └── 2182.txt ├── 2188 └── 2188.txt ├── 2192 └── 2192.txt ├── 2194 └── 2194.txt ├── 2196 └── 2196.txt ├── 2200 └── 2200.txt ├── 2203 └── 2203.txt ├── 2213 └── 2213.txt ├── 2225 └── 2225.txt └── 2226 └── 2226.txt /templates/style.css: -------------------------------------------------------------------------------- 1 | .form { 2 | display: flex; 3 | flex-direction: column; 4 | justify-content: center; 5 | align-items: center; 6 | } 7 | 8 | body{ 9 | background-color: blue; 10 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AlgoSleuth 2 | A Flask-based platform utilizing Selenium and TF-IDF to index 2,000+ LeetCode problems, achieving 98% query accuracy and enhancing search efficiency by 40% through intelligent, automated data retrieval. 3 | -------------------------------------------------------------------------------- /Qdata/1074/1074.txt: -------------------------------------------------------------------------------- 1 | Given an integer num, return a string of its base 7 representation. 2 |   3 | Example 1: 4 | Input: num = 100 5 | Output: "202" 6 | Example 2: 7 | Input: num = -7 8 | Output: "-10" 9 | 10 |   11 | Constraints: 12 | 13 | -107 <= num <= 107 14 | 15 | -------------------------------------------------------------------------------- /Qdata/1765/1765.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, add a dot (".") as the thousands separator and return it in string format. 2 |   3 | Example 1: 4 | Input: n = 987 5 | Output: "987" 6 | 7 | Example 2: 8 | Input: n = 1234 9 | Output: "1.234" 10 | 11 |   12 | Constraints: 13 | 14 | 0 <= n <= 231 - 1 15 | 16 | -------------------------------------------------------------------------------- /Qdata/209/209.txt: -------------------------------------------------------------------------------- 1 | Given two integers a and b, return the sum of the two integers without using the operators + and -. 2 |   3 | Example 1: 4 | Input: a = 1, b = 2 5 | Output: 3 6 | Example 2: 7 | Input: a = 2, b = 3 8 | Output: 5 9 | 10 |   11 | Constraints: 12 | 13 | -1000 <= a, b <= 1000 14 | 15 | -------------------------------------------------------------------------------- /Qdata/1596/1596.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. 2 |   3 | Example 1: 4 | Input: n = 13 5 | Output: 6 6 | 7 | Example 2: 8 | Input: n = 0 9 | Output: 0 10 | 11 |   12 | Constraints: 13 | 14 | 0 <= n <= 109 15 | 16 | -------------------------------------------------------------------------------- /Qdata/191/191.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order. 2 |   3 | Example 1: 4 | 5 | Input: n = 3 6 | Output: [[1,2,3],[8,9,4],[7,6,5]] 7 | 8 | Example 2: 9 | Input: n = 1 10 | Output: [[1]] 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= n <= 20 16 | 17 | -------------------------------------------------------------------------------- /Qdata/8/8.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n. 2 |   3 | Example 1: 4 | 5 | Input: n = 3 6 | Output: 5 7 | 8 | Example 2: 9 | Input: n = 1 10 | Output: 1 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= n <= 19 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1188/1188.txt: -------------------------------------------------------------------------------- 1 | Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c. 2 |   3 | Example 1: 4 | Input: c = 5 5 | Output: true 6 | Explanation: 1 * 1 + 2 * 2 = 5 7 | 8 | Example 2: 9 | Input: c = 3 10 | Output: false 11 | 12 |   13 | Constraints: 14 | 15 | 0 <= c <= 231 - 1 16 | 17 | -------------------------------------------------------------------------------- /Qdata/2109/2109.txt: -------------------------------------------------------------------------------- 1 | Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. 2 |   3 | Example 1: 4 | Input: n = 3 5 | Output: ["((()))","(()())","(())()","()(())","()()()"] 6 | Example 2: 7 | Input: n = 1 8 | Output: ["()"] 9 | 10 |   11 | Constraints: 12 | 13 | 1 <= n <= 8 14 | 15 | -------------------------------------------------------------------------------- /Qdata/799/799.txt: -------------------------------------------------------------------------------- 1 | Given a text file file.txt, transpose its content. 2 | You may assume that each row has the same number of columns, and each field is separated by the ' ' character. 3 | Example: 4 | If file.txt has the following content: 5 | name age 6 | alice 21 7 | ryan 30 8 | 9 | Output the following: 10 | name alice ryan 11 | age 21 30 12 | 13 | -------------------------------------------------------------------------------- /Qdata/561/561.txt: -------------------------------------------------------------------------------- 1 | Given a string s, return the longest palindromic substring in s. 2 |   3 | Example 1: 4 | Input: s = "babad" 5 | Output: "bab" 6 | Explanation: "aba" is also a valid answer. 7 | 8 | Example 2: 9 | Input: s = "cbbd" 10 | Output: "bb" 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= s.length <= 1000 16 | s consist of only digits and English letters. 17 | 18 | -------------------------------------------------------------------------------- /Qdata/1194/1194.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order. 2 | You must write an algorithm that runs in O(n) time and uses O(1) extra space.  3 |   4 | Example 1: 5 | Input: n = 13 6 | Output: [1,10,11,12,13,2,3,4,5,6,7,8,9] 7 | Example 2: 8 | Input: n = 2 9 | Output: [1,2] 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= n <= 5 * 104 15 | 16 | -------------------------------------------------------------------------------- /Qdata/1593/1593.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n. 2 |   3 | Example 1: 4 | Input: n = 2 5 | Output: 91 6 | Explanation: The answer should be the total numbers in the range of 0 ≤ x < 100, excluding 11,22,33,44,55,66,77,88,99 7 | 8 | Example 2: 9 | Input: n = 0 10 | Output: 1 11 | 12 |   13 | Constraints: 14 | 15 | 0 <= n <= 8 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1714/1714.txt: -------------------------------------------------------------------------------- 1 | Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer. 2 |   3 | Example 1: 4 | Input: arr = [1,2,2,6,6,6,6,7,10] 5 | Output: 6 6 | 7 | Example 2: 8 | Input: arr = [1,1] 9 | Output: 1 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= arr.length <= 104 15 | 0 <= arr[i] <= 105 16 | 17 | -------------------------------------------------------------------------------- /Qdata/2200/2200.txt: -------------------------------------------------------------------------------- 1 | Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer. 2 |   3 | Example 1: 4 | Input: arr = [1,2,2,6,6,6,6,7,10] 5 | Output: 6 6 | 7 | Example 2: 8 | Input: arr = [1,1] 9 | Output: 1 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= arr.length <= 104 15 | 0 <= arr[i] <= 105 16 | 17 | -------------------------------------------------------------------------------- /Qdata/251/251.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the leftmost value in the last row of the tree. 2 |   3 | Example 1: 4 | 5 | Input: root = [2,1,3] 6 | Output: 1 7 | 8 | Example 2: 9 | 10 | Input: root = [1,2,3,4,null,5,6,null,null,7] 11 | Output: 7 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is in the range [1, 104]. 17 | -231 <= Node.val <= 231 - 1 18 | 19 | -------------------------------------------------------------------------------- /Qdata/904/904.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, find three numbers whose product is maximum and return the maximum product. 2 |   3 | Example 1: 4 | Input: nums = [1,2,3] 5 | Output: 6 6 | Example 2: 7 | Input: nums = [1,2,3,4] 8 | Output: 24 9 | Example 3: 10 | Input: nums = [-1,-2,-3] 11 | Output: -6 12 | 13 |   14 | Constraints: 15 | 16 | 3 <= nums.length <= 104 17 | -1000 <= nums[i] <= 1000 18 | 19 | -------------------------------------------------------------------------------- /Qdata/2068/2068.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the number of prime numbers that are strictly less than n. 2 |   3 | Example 1: 4 | Input: n = 10 5 | Output: 4 6 | Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. 7 | 8 | Example 2: 9 | Input: n = 0 10 | Output: 0 11 | 12 | Example 3: 13 | Input: n = 1 14 | Output: 0 15 | 16 |   17 | Constraints: 18 | 19 | 0 <= n <= 5 * 106 20 | 21 | -------------------------------------------------------------------------------- /Qdata/271/271.txt: -------------------------------------------------------------------------------- 1 | Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. 2 |   3 | Example 1: 4 | Input: s = "aab" 5 | Output: [["a","a","b"],["aa","b"]] 6 | Example 2: 7 | Input: s = "a" 8 | Output: [["a"]] 9 | 10 |   11 | Constraints: 12 | 13 | 1 <= s.length <= 16 14 | s contains only lowercase English letters. 15 | 16 | -------------------------------------------------------------------------------- /Qdata/2003/2003.txt: -------------------------------------------------------------------------------- 1 | Given a valid (IPv4) IP address, return a defanged version of that IP address. 2 | A defanged IP address replaces every period "." with "[.]". 3 |   4 | Example 1: 5 | Input: address = "1.1.1.1" 6 | Output: "1[.]1[.]1[.]1" 7 | Example 2: 8 | Input: address = "255.100.50.0" 9 | Output: "255[.]100[.]50[.]0" 10 | 11 |   12 | Constraints: 13 | 14 | The given address is a valid IPv4 address. 15 | -------------------------------------------------------------------------------- /Qdata/910/910.txt: -------------------------------------------------------------------------------- 1 | Given an integer numRows, return the first numRows of Pascal's triangle. 2 | In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: 3 | 4 |   5 | Example 1: 6 | Input: numRows = 5 7 | Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] 8 | Example 2: 9 | Input: numRows = 1 10 | Output: [[1]] 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= numRows <= 30 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1056/1056.txt: -------------------------------------------------------------------------------- 1 | Given the head of a linked list, rotate the list to the right by k places. 2 |   3 | Example 1: 4 | 5 | Input: head = [1,2,3,4,5], k = 2 6 | Output: [4,5,1,2,3] 7 | 8 | Example 2: 9 | 10 | Input: head = [0,1,2], k = 4 11 | Output: [2,0,1] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the list is in the range [0, 500]. 17 | -100 <= Node.val <= 100 18 | 0 <= k <= 2 * 109 19 | 20 | -------------------------------------------------------------------------------- /Qdata/2030/2030.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the largest palindromic integer that can be represented as the product of two n-digits integers. Since the answer can be very large, return it modulo 1337. 2 |   3 | Example 1: 4 | Input: n = 2 5 | Output: 987 6 | Explanation: 99 x 91 = 9009, 9009 % 1337 = 987 7 | 8 | Example 2: 9 | Input: n = 1 10 | Output: 9 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= n <= 8 16 | 17 | -------------------------------------------------------------------------------- /Qdata/2188/2188.txt: -------------------------------------------------------------------------------- 1 | Given an integer numRows, return the first numRows of Pascal's triangle. 2 | In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: 3 | 4 |   5 | Example 1: 6 | Input: numRows = 5 7 | Output: [[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]] 8 | Example 2: 9 | Input: numRows = 1 10 | Output: [[1]] 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= numRows <= 30 16 | 17 | -------------------------------------------------------------------------------- /Qdata/703/703.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). 2 |   3 | Example 1: 4 | 5 | Input: root = [1,3,2,5,3,null,9] 6 | Output: [1,3,9] 7 | 8 | Example 2: 9 | Input: root = [1,2,3] 10 | Output: [1,3] 11 | 12 |   13 | Constraints: 14 | 15 | The number of nodes in the tree will be in the range [0, 104]. 16 | -231 <= Node.val <= 231 - 1 17 | 18 | -------------------------------------------------------------------------------- /Qdata/1329/1329.txt: -------------------------------------------------------------------------------- 1 | Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. 2 | Return any possible rearrangement of s or return "" if not possible. 3 |   4 | Example 1: 5 | Input: s = "aab" 6 | Output: "aba" 7 | Example 2: 8 | Input: s = "aaab" 9 | Output: "" 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= s.length <= 500 15 | s consists of lowercase English letters. 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1841/1841.txt: -------------------------------------------------------------------------------- 1 | You are given an integer n. We reorder the digits in any order (including the original order) such that the leading digit is not zero. 2 | Return true if and only if we can do this so that the resulting number is a power of two. 3 |   4 | Example 1: 5 | Input: n = 1 6 | Output: true 7 | 8 | Example 2: 9 | Input: n = 10 10 | Output: false 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= n <= 109 16 | 17 | -------------------------------------------------------------------------------- /Qdata/382/382.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return all root-to-leaf paths in any order. 2 | A leaf is a node with no children. 3 |   4 | Example 1: 5 | 6 | Input: root = [1,2,3,null,5] 7 | Output: ["1->2->5","1->3"] 8 | 9 | Example 2: 10 | Input: root = [1] 11 | Output: ["1"] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is in the range [1, 100]. 17 | -100 <= Node.val <= 100 18 | 19 | -------------------------------------------------------------------------------- /Qdata/135/135.txt: -------------------------------------------------------------------------------- 1 | Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. 2 |   3 | Example 1: 4 | Input: s = "leetcode" 5 | Output: 0 6 | Example 2: 7 | Input: s = "loveleetcode" 8 | Output: 2 9 | Example 3: 10 | Input: s = "aabb" 11 | Output: -1 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= s.length <= 105 17 | s consists of only lowercase English letters. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1116/1116.txt: -------------------------------------------------------------------------------- 1 | Given two integers n and k, return the kth lexicographically smallest integer in the range [1, n]. 2 |   3 | Example 1: 4 | Input: n = 13, k = 2 5 | Output: 10 6 | Explanation: The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9], so the second smallest number is 10. 7 | 8 | Example 2: 9 | Input: n = 1, k = 1 10 | Output: 1 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= k <= n <= 109 16 | 17 | -------------------------------------------------------------------------------- /Qdata/145/145.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return any array containing n unique integers such that they add up to 0. 2 |   3 | Example 1: 4 | Input: n = 5 5 | Output: [-7,-1,1,3,4] 6 | Explanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4]. 7 | 8 | Example 2: 9 | Input: n = 3 10 | Output: [-1,0,1] 11 | 12 | Example 3: 13 | Input: n = 1 14 | Output: [0] 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= n <= 1000 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1525/1525.txt: -------------------------------------------------------------------------------- 1 | Given two binary strings a and b, return their sum as a binary string. 2 |   3 | Example 1: 4 | Input: a = "11", b = "1" 5 | Output: "100" 6 | Example 2: 7 | Input: a = "1010", b = "1011" 8 | Output: "10101" 9 | 10 |   11 | Constraints: 12 | 13 | 1 <= a.length, b.length <= 104 14 | a and b consist only of '0' or '1' characters. 15 | Each string does not contain leading zeros except for the zero itself. 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1820/1820.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return all the structurally unique BST's (binary search trees), which has exactly n nodes of unique values from 1 to n. Return the answer in any order. 2 |   3 | Example 1: 4 | 5 | Input: n = 3 6 | Output: [[1,null,2,null,3],[1,null,3,2],[2,1,3],[3,1,null,null,2],[3,2,null,1]] 7 | 8 | Example 2: 9 | Input: n = 1 10 | Output: [[1]] 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= n <= 8 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1890/1890.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the nth digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]. 2 |   3 | Example 1: 4 | Input: n = 3 5 | Output: 3 6 | 7 | Example 2: 8 | Input: n = 11 9 | Output: 0 10 | Explanation: The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10. 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= n <= 231 - 1 16 | 17 | -------------------------------------------------------------------------------- /Qdata/333/333.txt: -------------------------------------------------------------------------------- 1 | You are given an integer num. You can swap two digits at most once to get the maximum valued number. 2 | Return the maximum valued number you can get. 3 |   4 | Example 1: 5 | Input: num = 2736 6 | Output: 7236 7 | Explanation: Swap the number 2 and the number 7. 8 | 9 | Example 2: 10 | Input: num = 9973 11 | Output: 9973 12 | Explanation: No swap. 13 | 14 |   15 | Constraints: 16 | 17 | 0 <= num <= 108 18 | 19 | -------------------------------------------------------------------------------- /Qdata/603/603.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the sum of values of its deepest leaves. 2 |   3 | Example 1: 4 | 5 | Input: root = [1,2,3,4,5,null,6,7,null,null,null,null,8] 6 | Output: 15 7 | 8 | Example 2: 9 | Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5] 10 | Output: 19 11 | 12 |   13 | Constraints: 14 | 15 | The number of nodes in the tree is in the range [1, 104]. 16 | 1 <= Node.val <= 100 17 | 18 | -------------------------------------------------------------------------------- /Qdata/764/764.txt: -------------------------------------------------------------------------------- 1 | Given a string s, return the string after replacing every uppercase letter with the same lowercase letter. 2 |   3 | Example 1: 4 | Input: s = "Hello" 5 | Output: "hello" 6 | 7 | Example 2: 8 | Input: s = "here" 9 | Output: "here" 10 | 11 | Example 3: 12 | Input: s = "LOVELY" 13 | Output: "lovely" 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= s.length <= 100 19 | s consists of printable ASCII characters. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1264/1264.txt: -------------------------------------------------------------------------------- 1 | Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive). 2 |   3 | Example 1: 4 | Input: low = 3, high = 7 5 | Output: 3 6 | Explanation: The odd numbers between 3 and 7 are [3,5,7]. 7 | Example 2: 8 | Input: low = 8, high = 10 9 | Output: 1 10 | Explanation: The odd numbers between 8 and 10 are [9]. 11 |   12 | Constraints: 13 | 14 | 0 <= low <= high <= 10^9 15 | -------------------------------------------------------------------------------- /Qdata/82/82.txt: -------------------------------------------------------------------------------- 1 | A positive integer is magical if it is divisible by either a or b. 2 | Given the three integers n, a, and b, return the nth magical number. Since the answer may be very large, return it modulo 109 + 7. 3 |   4 | Example 1: 5 | Input: n = 1, a = 2, b = 3 6 | Output: 2 7 | 8 | Example 2: 9 | Input: n = 4, a = 2, b = 3 10 | Output: 6 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= n <= 109 16 | 2 <= a, b <= 4 * 104 17 | 18 | -------------------------------------------------------------------------------- /Qdata/980/980.txt: -------------------------------------------------------------------------------- 1 | Given a list of 24-hour clock time points in "HH:MM" format, return the minimum minutes difference between any two time-points in the list. 2 |   3 | Example 1: 4 | Input: timePoints = ["23:59","00:00"] 5 | Output: 1 6 | Example 2: 7 | Input: timePoints = ["00:00","23:59","00:00"] 8 | Output: 0 9 | 10 |   11 | Constraints: 12 | 13 | 2 <= timePoints.length <= 2 * 104 14 | timePoints[i] is in the format "HH:MM". 15 | 16 | -------------------------------------------------------------------------------- /Qdata/1234/1234.txt: -------------------------------------------------------------------------------- 1 | Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive. 2 |   3 | Example 1: 4 | Input: left = 5, right = 7 5 | Output: 4 6 | 7 | Example 2: 8 | Input: left = 0, right = 0 9 | Output: 0 10 | 11 | Example 3: 12 | Input: left = 1, right = 2147483647 13 | Output: 0 14 | 15 |   16 | Constraints: 17 | 18 | 0 <= left <= right <= 231 - 1 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1693/1693.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers. 2 | Return the maximum product you can get. 3 |   4 | Example 1: 5 | Input: n = 2 6 | Output: 1 7 | Explanation: 2 = 1 + 1, 1 × 1 = 1. 8 | 9 | Example 2: 10 | Input: n = 10 11 | Output: 36 12 | Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36. 13 | 14 |   15 | Constraints: 16 | 17 | 2 <= n <= 58 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1840/1840.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n. 2 |   3 | Example 1: 4 | Input: nums = [3,10,5,25,2,8] 5 | Output: 28 6 | Explanation: The maximum result is 5 XOR 25 = 28. 7 | 8 | Example 2: 9 | Input: nums = [14,70,53,83,49,91,36,80,92,51,66,70] 10 | Output: 127 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= nums.length <= 2 * 105 16 | 0 <= nums[i] <= 231 - 1 17 | 18 | -------------------------------------------------------------------------------- /Qdata/498/498.txt: -------------------------------------------------------------------------------- 1 | Given two integers num1 and num2, return the sum of the two integers. 2 |   3 | Example 1: 4 | Input: num1 = 12, num2 = 5 5 | Output: 17 6 | Explanation: num1 is 12, num2 is 5, and their sum is 12 + 5 = 17, so 17 is returned. 7 | 8 | Example 2: 9 | Input: num1 = -10, num2 = 4 10 | Output: -6 11 | Explanation: num1 + num2 = -6, so -6 is returned. 12 | 13 |   14 | Constraints: 15 | 16 | -100 <= num1, num2 <= 100 17 | 18 | -------------------------------------------------------------------------------- /Qdata/722/722.txt: -------------------------------------------------------------------------------- 1 | Given the head of a singly linked list, return true if it is a palindrome or false otherwise. 2 |   3 | Example 1: 4 | 5 | Input: head = [1,2,2,1] 6 | Output: true 7 | 8 | Example 2: 9 | 10 | Input: head = [1,2] 11 | Output: false 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the list is in the range [1, 105]. 17 | 0 <= Node.val <= 9 18 | 19 |   20 | Follow up: Could you do it in O(n) time and O(1) space? -------------------------------------------------------------------------------- /Qdata/1825/1825.txt: -------------------------------------------------------------------------------- 1 | Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order. 2 |   3 | Example 1: 4 | Input: nums = [1,1,2] 5 | Output: 6 | [[1,1,2], 7 | [1,2,1], 8 | [2,1,1]] 9 | 10 | Example 2: 11 | Input: nums = [1,2,3] 12 | Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 8 18 | -10 <= nums[i] <= 10 19 | 20 | -------------------------------------------------------------------------------- /Qdata/2177/2177.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, invert the tree, and return its root. 2 |   3 | Example 1: 4 | 5 | Input: root = [4,2,7,1,3,6,9] 6 | Output: [4,7,2,9,6,3,1] 7 | 8 | Example 2: 9 | 10 | Input: root = [2,1,3] 11 | Output: [2,3,1] 12 | 13 | Example 3: 14 | Input: root = [] 15 | Output: [] 16 | 17 |   18 | Constraints: 19 | 20 | The number of nodes in the tree is in the range [0, 100]. 21 | -100 <= Node.val <= 100 22 | 23 | -------------------------------------------------------------------------------- /Qdata/952/952.txt: -------------------------------------------------------------------------------- 1 | Given a binary tree, determine if it is height-balanced. 2 |   3 | Example 1: 4 | 5 | Input: root = [3,9,20,null,null,15,7] 6 | Output: true 7 | 8 | Example 2: 9 | 10 | Input: root = [1,2,2,3,3,null,null,4,4] 11 | Output: false 12 | 13 | Example 3: 14 | Input: root = [] 15 | Output: true 16 | 17 |   18 | Constraints: 19 | 20 | The number of nodes in the tree is in the range [0, 5000]. 21 | -104 <= Node.val <= 104 22 | 23 | -------------------------------------------------------------------------------- /Qdata/1185/1185.txt: -------------------------------------------------------------------------------- 1 | You are given a string s. You can convert s to a palindrome by adding characters in front of it. 2 | Return the shortest palindrome you can find by performing this transformation. 3 |   4 | Example 1: 5 | Input: s = "aacecaaa" 6 | Output: "aaacecaaa" 7 | Example 2: 8 | Input: s = "abcd" 9 | Output: "dcbabcd" 10 | 11 |   12 | Constraints: 13 | 14 | 0 <= s.length <= 5 * 104 15 | s consists of lowercase English letters only. 16 | 17 | -------------------------------------------------------------------------------- /Qdata/748/748.txt: -------------------------------------------------------------------------------- 1 | Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order. 2 |   3 | Example 1: 4 | 5 | Input: mat = [[1,2,3],[4,5,6],[7,8,9]] 6 | Output: [1,2,4,7,5,3,6,8,9] 7 | 8 | Example 2: 9 | Input: mat = [[1,2],[3,4]] 10 | Output: [1,2,3,4] 11 | 12 |   13 | Constraints: 14 | 15 | m == mat.length 16 | n == mat[i].length 17 | 1 <= m, n <= 104 18 | 1 <= m * n <= 104 19 | -105 <= mat[i][j] <= 105 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1092/1092.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. 2 |   3 | Example 1: 4 | Input: nums = [1,2,3,1] 5 | Output: true 6 | Example 2: 7 | Input: nums = [1,2,3,4] 8 | Output: false 9 | Example 3: 10 | Input: nums = [1,1,1,3,3,4,3,2,4,2] 11 | Output: true 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums.length <= 105 17 | -109 <= nums[i] <= 109 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1136/1136.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n. 2 |   3 | Example 1: 4 | Input: n = 5 5 | Output: 10 6 | Explanation: The smallest multiple of both 5 and 2 is 10. 7 | 8 | Example 2: 9 | Input: n = 6 10 | Output: 6 11 | Explanation: The smallest multiple of both 6 and 2 is 6. Note that a number is a multiple of itself. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= n <= 150 17 | 18 | -------------------------------------------------------------------------------- /Qdata/1294/1294.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums that may contain duplicates, return all possible subsets (the power set). 2 | The solution set must not contain duplicate subsets. Return the solution in any order. 3 |   4 | Example 1: 5 | Input: nums = [1,2,2] 6 | Output: [[],[1],[1,2],[1,2,2],[2],[2,2]] 7 | Example 2: 8 | Input: nums = [0] 9 | Output: [[],[0]] 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= nums.length <= 10 15 | -10 <= nums[i] <= 10 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1338/1338.txt: -------------------------------------------------------------------------------- 1 | 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. 2 |   3 | Example 1: 4 | Input: grid = [[1,1,1],[1,0,1],[1,1,1]] 5 | Output: 9 6 | 7 | Example 2: 8 | Input: grid = [[1,1,0,0]] 9 | Output: 1 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= grid.length <= 100 15 | 1 <= grid[0].length <= 100 16 | grid[i][j] is 0 or 1 17 | -------------------------------------------------------------------------------- /Qdata/2163/2163.txt: -------------------------------------------------------------------------------- 1 | Given a string s, reverse only all the vowels in the string and return it. 2 | The vowels are 'a', 'e', 'i', 'o', and 'u', and they can appear in both lower and upper cases, more than once. 3 |   4 | Example 1: 5 | Input: s = "hello" 6 | Output: "holle" 7 | Example 2: 8 | Input: s = "leetcode" 9 | Output: "leotcede" 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= s.length <= 3 * 105 15 | s consist of printable ASCII characters. 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1243/1243.txt: -------------------------------------------------------------------------------- 1 | Given a list of non-negative integers nums, arrange them such that they form the largest number and return it. 2 | Since the result may be very large, so you need to return a string instead of an integer. 3 |   4 | Example 1: 5 | Input: nums = [10,2] 6 | Output: "210" 7 | 8 | Example 2: 9 | Input: nums = [3,30,34,5,9] 10 | Output: "9534330" 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= nums.length <= 100 16 | 0 <= nums[i] <= 109 17 | 18 | -------------------------------------------------------------------------------- /Qdata/1592/1592.txt: -------------------------------------------------------------------------------- 1 | Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order. 2 |   3 | Example 1: 4 | Input: s = "owoztneoer" 5 | Output: "012" 6 | Example 2: 7 | Input: s = "fviefuro" 8 | Output: "45" 9 | 10 |   11 | Constraints: 12 | 13 | 1 <= s.length <= 105 14 | s[i] is one of the characters ["e","g","f","i","h","o","n","s","r","u","t","w","v","x","z"]. 15 | s is guaranteed to be valid. 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1806/1806.txt: -------------------------------------------------------------------------------- 1 | Write a program to count the number of days between two dates. 2 | The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples. 3 |   4 | Example 1: 5 | Input: date1 = "2019-06-29", date2 = "2019-06-30" 6 | Output: 1 7 | Example 2: 8 | Input: date1 = "2020-01-15", date2 = "2019-12-31" 9 | Output: 15 10 | 11 |   12 | Constraints: 13 | 14 | The given dates are valid dates between the years 1971 and 2100. 15 | 16 | -------------------------------------------------------------------------------- /Qdata/536/536.txt: -------------------------------------------------------------------------------- 1 | Given a binary string s ​​​​​without leading zeros, return true​​​ if s contains at most one contiguous segment of ones. Otherwise, return false. 2 |   3 | Example 1: 4 | Input: s = "1001" 5 | Output: false 6 | Explanation: The ones do not form a contiguous segment. 7 | 8 | Example 2: 9 | Input: s = "110" 10 | Output: true 11 |   12 | Constraints: 13 | 14 | 1 <= s.length <= 100 15 | s[i]​​​​ is either '0' or '1'. 16 | s[0] is '1'. 17 | 18 | -------------------------------------------------------------------------------- /Qdata/765/765.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. 2 | A subarray is a contiguous non-empty sequence of elements within an array. 3 |   4 | Example 1: 5 | Input: nums = [1,1,1], k = 2 6 | Output: 2 7 | Example 2: 8 | Input: nums = [1,2,3], k = 3 9 | Output: 2 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= nums.length <= 2 * 104 15 | -1000 <= nums[i] <= 1000 16 | -107 <= k <= 107 17 | 18 | -------------------------------------------------------------------------------- /Qdata/1018/1018.txt: -------------------------------------------------------------------------------- 1 | Given an m x n matrix, return all elements of the matrix in spiral order. 2 |   3 | Example 1: 4 | 5 | Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] 6 | Output: [1,2,3,6,9,8,7,4,5] 7 | 8 | Example 2: 9 | 10 | Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]] 11 | Output: [1,2,3,4,8,12,11,10,9,5,6,7] 12 | 13 |   14 | Constraints: 15 | 16 | m == matrix.length 17 | n == matrix[i].length 18 | 1 <= m, n <= 10 19 | -100 <= matrix[i][j] <= 100 20 | 21 | -------------------------------------------------------------------------------- /Qdata/901/901.txt: -------------------------------------------------------------------------------- 1 | Given a binary array nums, return the maximum number of consecutive 1's in the array. 2 |   3 | Example 1: 4 | Input: nums = [1,1,0,1,1,1] 5 | Output: 3 6 | Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3. 7 | 8 | Example 2: 9 | Input: nums = [1,0,1,1,0,1] 10 | Output: 2 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= nums.length <= 105 16 | nums[i] is either 0 or 1. 17 | 18 | -------------------------------------------------------------------------------- /Qdata/1093/1093.txt: -------------------------------------------------------------------------------- 1 | Convert a non-negative integer num to its English words representation. 2 |   3 | Example 1: 4 | Input: num = 123 5 | Output: "One Hundred Twenty Three" 6 | 7 | Example 2: 8 | Input: num = 12345 9 | Output: "Twelve Thousand Three Hundred Forty Five" 10 | 11 | Example 3: 12 | Input: num = 1234567 13 | Output: "One Million Two Hundred Thirty Four Thousand Five Hundred Sixty Seven" 14 | 15 |   16 | Constraints: 17 | 18 | 0 <= num <= 231 - 1 19 | 20 | -------------------------------------------------------------------------------- /Qdata/317/317.txt: -------------------------------------------------------------------------------- 1 | An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y. 2 | Given an integer n, return the largest number that is less than or equal to n with monotone increasing digits. 3 |   4 | Example 1: 5 | Input: n = 10 6 | Output: 9 7 | 8 | Example 2: 9 | Input: n = 1234 10 | Output: 1234 11 | 12 | Example 3: 13 | Input: n = 332 14 | Output: 299 15 | 16 |   17 | Constraints: 18 | 19 | 0 <= n <= 109 20 | 21 | -------------------------------------------------------------------------------- /Qdata/440/440.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return true if it is a power of four. Otherwise, return false. 2 | An integer n is a power of four, if there exists an integer x such that n == 4x. 3 |   4 | Example 1: 5 | Input: n = 16 6 | Output: true 7 | Example 2: 8 | Input: n = 5 9 | Output: false 10 | Example 3: 11 | Input: n = 1 12 | Output: true 13 | 14 |   15 | Constraints: 16 | 17 | -231 <= n <= 231 - 1 18 | 19 |   20 | Follow up: Could you solve it without loops/recursion? -------------------------------------------------------------------------------- /Qdata/450/450.txt: -------------------------------------------------------------------------------- 1 | Given a string s, return true if the s can be palindrome after deleting at most one character from it. 2 |   3 | Example 1: 4 | Input: s = "aba" 5 | Output: true 6 | 7 | Example 2: 8 | Input: s = "abca" 9 | Output: true 10 | Explanation: You could delete the character 'c'. 11 | 12 | Example 3: 13 | Input: s = "abc" 14 | Output: false 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= s.length <= 105 20 | s consists of lowercase English letters. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1259/1259.txt: -------------------------------------------------------------------------------- 1 | Given a string s, return the last substring of s in lexicographical order. 2 |   3 | Example 1: 4 | Input: s = "abab" 5 | Output: "bab" 6 | Explanation: The substrings are ["a", "ab", "aba", "abab", "b", "ba", "bab"]. The lexicographically maximum substring is "bab". 7 | 8 | Example 2: 9 | Input: s = "leetcode" 10 | Output: "tcode" 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= s.length <= 4 * 105 16 | s contains only lowercase English letters. 17 | 18 | -------------------------------------------------------------------------------- /Qdata/2015/2015.txt: -------------------------------------------------------------------------------- 1 | Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order. 2 |   3 | Example 1: 4 | 5 | Input: root1 = [2,1,4], root2 = [1,0,3] 6 | Output: [0,1,1,2,3,4] 7 | 8 | Example 2: 9 | 10 | Input: root1 = [1,null,8], root2 = [8,1] 11 | Output: [1,1,8,8] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in each tree is in the range [0, 5000]. 17 | -105 <= Node.val <= 105 18 | 19 | -------------------------------------------------------------------------------- /Qdata/2050/2050.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers. 2 |   3 | Example 1: 4 | Input: n = 5 5 | Output: 2 6 | Explanation: 5 = 2 + 3 7 | 8 | Example 2: 9 | Input: n = 9 10 | Output: 3 11 | Explanation: 9 = 4 + 5 = 2 + 3 + 4 12 | 13 | Example 3: 14 | Input: n = 15 15 | Output: 4 16 | Explanation: 15 = 8 + 7 = 4 + 5 + 6 = 1 + 2 + 3 + 4 + 5 17 | 18 |   19 | Constraints: 20 | 21 | 1 <= n <= 109 22 | 23 | -------------------------------------------------------------------------------- /Qdata/577/577.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false. 2 | An integer m is a divisor of n if there exists an integer k such that n = k * m. 3 |   4 | Example 1: 5 | Input: n = 2 6 | Output: false 7 | Explantion: 2 has only two divisors: 1 and 2. 8 | 9 | Example 2: 10 | Input: n = 4 11 | Output: true 12 | Explantion: 4 has three divisors: 1, 2, and 4. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= n <= 104 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1203/1203.txt: -------------------------------------------------------------------------------- 1 | A binary tree is uni-valued if every node in the tree has the same value. 2 | Given the root of a binary tree, return true if the given tree is uni-valued, or false otherwise. 3 |   4 | Example 1: 5 | 6 | Input: root = [1,1,1,1,1,null,1] 7 | Output: true 8 | 9 | Example 2: 10 | 11 | Input: root = [2,2,2,5,2] 12 | Output: false 13 | 14 |   15 | Constraints: 16 | 17 | The number of nodes in the tree is in the range [1, 100]. 18 | 0 <= Node.val < 100 19 | 20 | -------------------------------------------------------------------------------- /Qdata/388/388.txt: -------------------------------------------------------------------------------- 1 | The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other. 2 | Given an integer n, return the number of distinct solutions to the n-queens puzzle. 3 |   4 | Example 1: 5 | 6 | Input: n = 4 7 | Output: 2 8 | Explanation: There are two distinct solutions to the 4-queens puzzle as shown. 9 | 10 | Example 2: 11 | Input: n = 1 12 | Output: 1 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= n <= 9 18 | 19 | -------------------------------------------------------------------------------- /Qdata/517/517.txt: -------------------------------------------------------------------------------- 1 | Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. 2 |   3 | Example 1: 4 | Input: nums = [3,2,3] 5 | Output: [3] 6 | 7 | Example 2: 8 | Input: nums = [1] 9 | Output: [1] 10 | 11 | Example 3: 12 | Input: nums = [1,2] 13 | Output: [1,2] 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= nums.length <= 5 * 104 19 | -109 <= nums[i] <= 109 20 | 21 |   22 | Follow up: Could you solve the problem in linear time and in O(1) space? 23 | -------------------------------------------------------------------------------- /Qdata/1316/1316.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements. You may return the answer in any order. 2 |   3 | Example 1: 4 | Input: nums = [4,6,7,7] 5 | Output: [[4,6],[4,6,7],[4,6,7,7],[4,7],[4,7,7],[6,7],[6,7,7],[7,7]] 6 | 7 | Example 2: 8 | Input: nums = [4,4,3,2,1] 9 | Output: [[4,4]] 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= nums.length <= 15 15 | -100 <= nums[i] <= 100 16 | 17 | -------------------------------------------------------------------------------- /Qdata/304/304.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return its maximum depth. 2 | A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. 3 |   4 | Example 1: 5 | 6 | Input: root = [3,9,20,null,null,15,7] 7 | Output: 3 8 | 9 | Example 2: 10 | Input: root = [1,null,2] 11 | Output: 2 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is in the range [0, 104]. 17 | -100 <= Node.val <= 100 18 | 19 | -------------------------------------------------------------------------------- /Qdata/597/597.txt: -------------------------------------------------------------------------------- 1 | An integer has sequential digits if and only if each digit in the number is one more than the previous digit. 2 | Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits. 3 |   4 | Example 1: 5 | Input: low = 100, high = 300 6 | Output: [123,234] 7 | Example 2: 8 | Input: low = 1000, high = 13000 9 | Output: [1234,2345,3456,4567,5678,6789,12345] 10 | 11 |   12 | Constraints: 13 | 14 | 10 <= low <= high <= 10^9 15 | 16 | -------------------------------------------------------------------------------- /Qdata/1599/1599.txt: -------------------------------------------------------------------------------- 1 | Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false. 2 |   3 | Example 1: 4 | Input: arr = [2,6,4,1] 5 | Output: false 6 | Explanation: There are no three consecutive odds. 7 | 8 | Example 2: 9 | Input: arr = [1,2,34,3,4,5,7,23,12] 10 | Output: true 11 | Explanation: [5,7,23] are three consecutive odds. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= arr.length <= 1000 17 | 1 <= arr[i] <= 1000 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1770/1770.txt: -------------------------------------------------------------------------------- 1 | Given two positive integers a and b, return the number of common factors of a and b. 2 | An integer x is a common factor of a and b if x divides both a and b. 3 |   4 | Example 1: 5 | Input: a = 12, b = 6 6 | Output: 4 7 | Explanation: The common factors of 12 and 6 are 1, 2, 3, 6. 8 | 9 | Example 2: 10 | Input: a = 25, b = 30 11 | Output: 2 12 | Explanation: The common factors of 25 and 30 are 1, 5. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= a, b <= 1000 18 | 19 | -------------------------------------------------------------------------------- /Qdata/738/738.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). 2 |   3 | Example 1: 4 | 5 | Input: root = [1,2,2,3,4,4,3] 6 | Output: true 7 | 8 | Example 2: 9 | 10 | Input: root = [1,2,2,null,3,null,3] 11 | Output: false 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is in the range [1, 1000]. 17 | -100 <= Node.val <= 100 18 | 19 |   20 | Follow up: Could you solve it both recursively and iteratively? -------------------------------------------------------------------------------- /Qdata/891/891.txt: -------------------------------------------------------------------------------- 1 | Write a function that reverses a string. The input string is given as an array of characters s. 2 | You must do this by modifying the input array in-place with O(1) extra memory. 3 |   4 | Example 1: 5 | Input: s = ["h","e","l","l","o"] 6 | Output: ["o","l","l","e","h"] 7 | Example 2: 8 | Input: s = ["H","a","n","n","a","h"] 9 | Output: ["h","a","n","n","a","H"] 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= s.length <= 105 15 | s[i] is a printable ascii character. 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1544/1544.txt: -------------------------------------------------------------------------------- 1 | Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once. 2 |   3 | Example 1: 4 | Input: s = "bcabc" 5 | Output: "abc" 6 | 7 | Example 2: 8 | Input: s = "cbacdcbc" 9 | Output: "acdb" 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= s.length <= 1000 15 | s consists of lowercase English letters. 16 | 17 |   18 | Note: This question is the same as 316: https://leetcode.com/problems/remove-duplicate-letters/ -------------------------------------------------------------------------------- /Qdata/1661/1661.txt: -------------------------------------------------------------------------------- 1 | The Tribonacci sequence Tn is defined as follows:  2 | T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0. 3 | Given n, return the value of Tn. 4 |   5 | Example 1: 6 | Input: n = 4 7 | Output: 4 8 | Explanation: 9 | T_3 = 0 + 1 + 1 = 2 10 | T_4 = 1 + 1 + 2 = 4 11 | 12 | Example 2: 13 | Input: n = 25 14 | Output: 1389537 15 | 16 |   17 | Constraints: 18 | 19 | 0 <= n <= 37 20 | The answer is guaranteed to fit within a 32-bit integer, ie. answer <= 2^31 - 1. 21 | -------------------------------------------------------------------------------- /Qdata/381/381.txt: -------------------------------------------------------------------------------- 1 | Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle. 2 |   3 | Example 1: 4 | 5 | Input: n = 2, m = 3 6 | Output: 3 7 | Explanation: 3 squares are necessary to cover the rectangle. 8 | 2 (squares of 1x1) 9 | 1 (square of 2x2) 10 | Example 2: 11 | 12 | Input: n = 5, m = 8 13 | Output: 5 14 | 15 | Example 3: 16 | 17 | Input: n = 11, m = 13 18 | Output: 6 19 | 20 |   21 | Constraints: 22 | 23 | 1 <= n, m <= 13 24 | 25 | -------------------------------------------------------------------------------- /Qdata/180/180.txt: -------------------------------------------------------------------------------- 1 | A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2. 2 | Given an integer n, return the number of square triples such that 1 <= a, b, c <= n. 3 |   4 | Example 1: 5 | Input: n = 5 6 | Output: 2 7 | Explanation: The square triples are (3,4,5) and (4,3,5). 8 | 9 | Example 2: 10 | Input: n = 10 11 | Output: 4 12 | Explanation: The square triples are (3,4,5), (4,3,5), (6,8,10), and (8,6,10). 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= n <= 250 18 | 19 | -------------------------------------------------------------------------------- /Qdata/572/572.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums and an integer k, return the kth largest element in the array. 2 | Note that it is the kth largest element in the sorted order, not the kth distinct element. 3 | You must solve it in O(n) time complexity. 4 |   5 | Example 1: 6 | Input: nums = [3,2,1,5,6,4], k = 2 7 | Output: 5 8 | Example 2: 9 | Input: nums = [3,2,3,1,2,4,5,5,6], k = 4 10 | Output: 4 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= k <= nums.length <= 105 16 | -104 <= nums[i] <= 104 17 | 18 | -------------------------------------------------------------------------------- /Qdata/609/609.txt: -------------------------------------------------------------------------------- 1 | Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. 2 |   3 | Example 1: 4 | 5 | Input: head = [1,1,2] 6 | Output: [1,2] 7 | 8 | Example 2: 9 | 10 | Input: head = [1,1,2,3,3] 11 | Output: [1,2,3] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the list is in the range [0, 300]. 17 | -100 <= Node.val <= 100 18 | The list is guaranteed to be sorted in ascending order. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1309/1309.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums of unique elements, return all possible subsets (the power set). 2 | The solution set must not contain duplicate subsets. Return the solution in any order. 3 |   4 | Example 1: 5 | Input: nums = [1,2,3] 6 | Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] 7 | 8 | Example 2: 9 | Input: nums = [0] 10 | Output: [[],[0]] 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= nums.length <= 10 16 | -10 <= nums[i] <= 10 17 | All the numbers of nums are unique. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1430/1430.txt: -------------------------------------------------------------------------------- 1 | Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. 2 |   3 | Example 1: 4 | Input: num = 38 5 | Output: 2 6 | Explanation: The process is 7 | 38 --> 3 + 8 --> 11 8 | 11 --> 1 + 1 --> 2 9 | Since 2 has only one digit, return it. 10 | 11 | Example 2: 12 | Input: num = 0 13 | Output: 0 14 | 15 |   16 | Constraints: 17 | 18 | 0 <= num <= 231 - 1 19 | 20 |   21 | Follow up: Could you do it without any loop/recursion in O(1) runtime? 22 | -------------------------------------------------------------------------------- /Qdata/325/325.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). 2 |   3 | Example 1: 4 | 5 | Input: root = [3,9,20,null,null,15,7] 6 | Output: [[3],[9,20],[15,7]] 7 | 8 | Example 2: 9 | Input: root = [1] 10 | Output: [[1]] 11 | 12 | Example 3: 13 | Input: root = [] 14 | Output: [] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the tree is in the range [0, 2000]. 20 | -1000 <= Node.val <= 1000 21 | 22 | -------------------------------------------------------------------------------- /Qdata/454/454.txt: -------------------------------------------------------------------------------- 1 | Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. 2 |   3 | Example 1: 4 | Input: nums = [1,2,3] 5 | Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]] 6 | Example 2: 7 | Input: nums = [0,1] 8 | Output: [[0,1],[1,0]] 9 | Example 3: 10 | Input: nums = [1] 11 | Output: [[1]] 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums.length <= 6 17 | -10 <= nums[i] <= 10 18 | All the integers of nums are unique. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/59/59.txt: -------------------------------------------------------------------------------- 1 | Given an array points where points[i] = [xi, yi] represents a point on the X-Y plane, return true if these points are a boomerang. 2 | A boomerang is a set of three points that are all distinct and not in a straight line. 3 |   4 | Example 1: 5 | Input: points = [[1,1],[2,3],[3,2]] 6 | Output: true 7 | Example 2: 8 | Input: points = [[1,1],[2,2],[3,3]] 9 | Output: false 10 | 11 |   12 | Constraints: 13 | 14 | points.length == 3 15 | points[i].length == 2 16 | 0 <= xi, yi <= 100 17 | 18 | -------------------------------------------------------------------------------- /Qdata/6/6.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the inorder traversal of its nodes' values. 2 |   3 | Example 1: 4 | 5 | Input: root = [1,null,2,3] 6 | Output: [1,3,2] 7 | 8 | Example 2: 9 | Input: root = [] 10 | Output: [] 11 | 12 | Example 3: 13 | Input: root = [1] 14 | Output: [1] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the tree is in the range [0, 100]. 20 | -100 <= Node.val <= 100 21 | 22 |   23 | Follow up: Recursive solution is trivial, could you do it iteratively? -------------------------------------------------------------------------------- /Qdata/1087/1087.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers. 2 | Return any array that satisfies this condition. 3 |   4 | Example 1: 5 | Input: nums = [3,1,2,4] 6 | Output: [2,4,3,1] 7 | Explanation: The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepted. 8 | 9 | Example 2: 10 | Input: nums = [0] 11 | Output: [0] 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums.length <= 5000 17 | 0 <= nums[i] <= 5000 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1413/1413.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. 2 |   3 | Example 1: 4 | Input: nums = [2,2,3,4] 5 | Output: 3 6 | Explanation: Valid combinations are: 7 | 2,3,4 (using the first 2) 8 | 2,3,4 (using the second 2) 9 | 2,2,3 10 | 11 | Example 2: 12 | Input: nums = [4,2,3,4] 13 | Output: 4 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= nums.length <= 1000 19 | 0 <= nums[i] <= 1000 20 | 21 | -------------------------------------------------------------------------------- /Qdata/22/22.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the preorder traversal of its nodes' values. 2 |   3 | Example 1: 4 | 5 | Input: root = [1,null,2,3] 6 | Output: [1,2,3] 7 | 8 | Example 2: 9 | Input: root = [] 10 | Output: [] 11 | 12 | Example 3: 13 | Input: root = [1] 14 | Output: [1] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the tree is in the range [0, 100]. 20 | -100 <= Node.val <= 100 21 | 22 |   23 | Follow up: Recursive solution is trivial, could you do it iteratively? 24 | -------------------------------------------------------------------------------- /Qdata/374/374.txt: -------------------------------------------------------------------------------- 1 | Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array. 2 |   3 | Example 1: 4 | Input: a = 2, b = [3] 5 | Output: 8 6 | 7 | Example 2: 8 | Input: a = 2, b = [1,0] 9 | Output: 1024 10 | 11 | Example 3: 12 | Input: a = 1, b = [4,3,3,8,5,2] 13 | Output: 1 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= a <= 231 - 1 19 | 1 <= b.length <= 2000 20 | 0 <= b[i] <= 9 21 | b does not contain leading zeros. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/410/410.txt: -------------------------------------------------------------------------------- 1 | Given a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s, or false otherwise. 2 | A substring is a contiguous sequence of characters within a string. 3 |   4 | Example 1: 5 | Input: s = "0110", n = 3 6 | Output: true 7 | Example 2: 8 | Input: s = "0110", n = 4 9 | Output: false 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= s.length <= 1000 15 | s[i] is either '0' or '1'. 16 | 1 <= n <= 109 17 | 18 | -------------------------------------------------------------------------------- /Qdata/567/567.txt: -------------------------------------------------------------------------------- 1 | In a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i]. 2 | Rearrange the barcodes so that no two adjacent barcodes are equal. You may return any answer, and it is guaranteed an answer exists. 3 |   4 | Example 1: 5 | Input: barcodes = [1,1,1,2,2,2] 6 | Output: [2,1,2,1,2,1] 7 | Example 2: 8 | Input: barcodes = [1,1,1,1,2,2,3,3] 9 | Output: [1,3,1,3,1,2,1,2] 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= barcodes.length <= 10000 15 | 1 <= barcodes[i] <= 10000 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1336/1336.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the postorder traversal of its nodes' values. 2 |   3 | Example 1: 4 | 5 | Input: root = [1,null,2,3] 6 | Output: [3,2,1] 7 | 8 | Example 2: 9 | Input: root = [] 10 | Output: [] 11 | 12 | Example 3: 13 | Input: root = [1] 14 | Output: [1] 15 | 16 |   17 | Constraints: 18 | 19 | The number of the nodes in the tree is in the range [0, 100]. 20 | -100 <= Node.val <= 100 21 | 22 |   23 | Follow up: Recursive solution is trivial, could you do it iteratively? -------------------------------------------------------------------------------- /Qdata/24/24.txt: -------------------------------------------------------------------------------- 1 | Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order. 2 |   3 | Example 1: 4 | Input: nums1 = [1,2,2,1], nums2 = [2,2] 5 | Output: [2] 6 | 7 | Example 2: 8 | Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] 9 | Output: [9,4] 10 | Explanation: [4,9] is also accepted. 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= nums1.length, nums2.length <= 1000 16 | 0 <= nums1[i], nums2[i] <= 1000 17 | 18 | -------------------------------------------------------------------------------- /Qdata/560/560.txt: -------------------------------------------------------------------------------- 1 | Given a text file file.txt, print just the 10th line of the file. 2 | Example: 3 | Assume that file.txt has the following content: 4 | Line 1 5 | Line 2 6 | Line 3 7 | Line 4 8 | Line 5 9 | Line 6 10 | Line 7 11 | Line 8 12 | Line 9 13 | Line 10 14 | 15 | Your script should output the tenth line, which is: 16 | Line 10 17 | 18 | Note: 19 | 1. If the file contains less than 10 lines, what should you output? 20 | 2. There's at least three different solutions. Try to explore all possibilities. 21 | -------------------------------------------------------------------------------- /Qdata/60/60.txt: -------------------------------------------------------------------------------- 1 | Given two arrays of integers with equal lengths, return the maximum value of: 2 | |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j| 3 | where the maximum is taken over all 0 <= i, j < arr1.length. 4 |   5 | Example 1: 6 | Input: arr1 = [1,2,3,4], arr2 = [-1,4,5,6] 7 | Output: 13 8 | 9 | Example 2: 10 | Input: arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4] 11 | Output: 20 12 | 13 |   14 | Constraints: 15 | 16 | 2 <= arr1.length == arr2.length <= 40000 17 | -10^6 <= arr1[i], arr2[i] <= 10^6 18 | 19 | -------------------------------------------------------------------------------- /Qdata/779/779.txt: -------------------------------------------------------------------------------- 1 | Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line. 2 |   3 | Example 1: 4 | 5 | Input: points = [[1,1],[2,2],[3,3]] 6 | Output: 3 7 | 8 | Example 2: 9 | 10 | Input: points = [[1,1],[3,2],[5,3],[4,1],[2,3],[1,4]] 11 | Output: 4 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= points.length <= 300 17 | points[i].length == 2 18 | -104 <= xi, yi <= 104 19 | All the points are unique. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1088/1088.txt: -------------------------------------------------------------------------------- 1 | Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet. 2 | For example: 3 | A -> 1 4 | B -> 2 5 | C -> 3 6 | ... 7 | Z -> 26 8 | AA -> 27 9 | AB -> 28 10 | ... 11 | 12 |   13 | Example 1: 14 | Input: columnNumber = 1 15 | Output: "A" 16 | 17 | Example 2: 18 | Input: columnNumber = 28 19 | Output: "AB" 20 | 21 | Example 3: 22 | Input: columnNumber = 701 23 | Output: "ZY" 24 | 25 |   26 | Constraints: 27 | 28 | 1 <= columnNumber <= 231 - 1 29 | 30 | -------------------------------------------------------------------------------- /Qdata/1471/1471.txt: -------------------------------------------------------------------------------- 1 | Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates). You may return the answer in any order. 2 |   3 | Example 1: 4 | Input: words = ["bella","label","roller"] 5 | Output: ["e","l","l"] 6 | Example 2: 7 | Input: words = ["cool","lock","cook"] 8 | Output: ["c","o"] 9 | 10 |   11 | Constraints: 12 | 13 | 1 <= words.length <= 100 14 | 1 <= words[i].length <= 100 15 | words[i] consists of lowercase English letters. 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1478/1478.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. 2 |   3 | Example 1: 4 | 5 | Input: root = [1,2,3,null,5,null,4] 6 | Output: [1,3,4] 7 | 8 | Example 2: 9 | Input: root = [1,null,3] 10 | Output: [1,3] 11 | 12 | Example 3: 13 | Input: root = [] 14 | Output: [] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the tree is in the range [0, 100]. 20 | -100 <= Node.val <= 100 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1941/1941.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive integer exists, return -1. 2 | Note that the returned integer should fit in 32-bit integer, if there is a valid answer but it does not fit in 32-bit integer, return -1. 3 |   4 | Example 1: 5 | Input: n = 12 6 | Output: 21 7 | Example 2: 8 | Input: n = 21 9 | Output: -1 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= n <= 231 - 1 15 | 16 | -------------------------------------------------------------------------------- /Qdata/2158/2158.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. 2 | Note that you must do this in-place without making a copy of the array. 3 |   4 | Example 1: 5 | Input: nums = [0,1,0,3,12] 6 | Output: [1,3,12,0,0] 7 | Example 2: 8 | Input: nums = [0] 9 | Output: [0] 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= nums.length <= 104 15 | -231 <= nums[i] <= 231 - 1 16 | 17 |   18 | Follow up: Could you minimize the total number of operations done? -------------------------------------------------------------------------------- /Qdata/863/863.txt: -------------------------------------------------------------------------------- 1 | You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. 2 | Return the single element that appears only once. 3 | Your solution must run in O(log n) time and O(1) space. 4 |   5 | Example 1: 6 | Input: nums = [1,1,2,3,3,4,4,8,8] 7 | Output: 2 8 | Example 2: 9 | Input: nums = [3,3,7,7,10,11,11] 10 | Output: 10 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= nums.length <= 105 16 | 0 <= nums[i] <= 105 17 | 18 | -------------------------------------------------------------------------------- /Qdata/88/88.txt: -------------------------------------------------------------------------------- 1 | Implement pow(x, n), which calculates x raised to the power n (i.e., xn). 2 |   3 | Example 1: 4 | Input: x = 2.00000, n = 10 5 | Output: 1024.00000 6 | 7 | Example 2: 8 | Input: x = 2.10000, n = 3 9 | Output: 9.26100 10 | 11 | Example 3: 12 | Input: x = 2.00000, n = -2 13 | Output: 0.25000 14 | Explanation: 2-2 = 1/22 = 1/4 = 0.25 15 | 16 |   17 | Constraints: 18 | 19 | -100.0 < x < 100.0 20 | -231 <= n <= 231-1 21 | n is an integer. 22 | Either x is not zero or n > 0. 23 | -104 <= xn <= 104 24 | 25 | -------------------------------------------------------------------------------- /Qdata/1215/1215.txt: -------------------------------------------------------------------------------- 1 | An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. 2 | Given an integer n, return the nth ugly number. 3 |   4 | Example 1: 5 | Input: n = 10 6 | Output: 12 7 | Explanation: [1, 2, 3, 4, 5, 6, 8, 9, 10, 12] is the sequence of the first 10 ugly numbers. 8 | 9 | Example 2: 10 | Input: n = 1 11 | Output: 1 12 | Explanation: 1 has no prime factors, therefore all of its prime factors are limited to 2, 3, and 5. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= n <= 1690 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1492/1492.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k. 2 |   3 | Example 1: 4 | Input: nums = [1,2,3,1], k = 3 5 | Output: true 6 | 7 | Example 2: 8 | Input: nums = [1,0,1,1], k = 1 9 | Output: true 10 | 11 | Example 3: 12 | Input: nums = [1,2,3,1,2,3], k = 2 13 | Output: false 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= nums.length <= 105 19 | -109 <= nums[i] <= 109 20 | 0 <= k <= 105 21 | 22 | -------------------------------------------------------------------------------- /Qdata/2179/2179.txt: -------------------------------------------------------------------------------- 1 | Implement pow(x, n), which calculates x raised to the power n (i.e., xn). 2 |   3 | Example 1: 4 | Input: x = 2.00000, n = 10 5 | Output: 1024.00000 6 | 7 | Example 2: 8 | Input: x = 2.10000, n = 3 9 | Output: 9.26100 10 | 11 | Example 3: 12 | Input: x = 2.00000, n = -2 13 | Output: 0.25000 14 | Explanation: 2-2 = 1/22 = 1/4 = 0.25 15 | 16 |   17 | Constraints: 18 | 19 | -100.0 < x < 100.0 20 | -231 <= n <= 231-1 21 | n is an integer. 22 | Either x is not zero or n > 0. 23 | -104 <= xn <= 104 24 | 25 | -------------------------------------------------------------------------------- /Qdata/2182/2182.txt: -------------------------------------------------------------------------------- 1 | Implement pow(x, n), which calculates x raised to the power n (i.e., xn). 2 |   3 | Example 1: 4 | Input: x = 2.00000, n = 10 5 | Output: 1024.00000 6 | 7 | Example 2: 8 | Input: x = 2.10000, n = 3 9 | Output: 9.26100 10 | 11 | Example 3: 12 | Input: x = 2.00000, n = -2 13 | Output: 0.25000 14 | Explanation: 2-2 = 1/22 = 1/4 = 0.25 15 | 16 |   17 | Constraints: 18 | 19 | -100.0 < x < 100.0 20 | -231 <= n <= 231-1 21 | n is an integer. 22 | Either x is not zero or n > 0. 23 | -104 <= xn <= 104 24 | 25 | -------------------------------------------------------------------------------- /Qdata/2226/2226.txt: -------------------------------------------------------------------------------- 1 | Implement pow(x, n), which calculates x raised to the power n (i.e., xn). 2 |   3 | Example 1: 4 | Input: x = 2.00000, n = 10 5 | Output: 1024.00000 6 | 7 | Example 2: 8 | Input: x = 2.10000, n = 3 9 | Output: 9.26100 10 | 11 | Example 3: 12 | Input: x = 2.00000, n = -2 13 | Output: 0.25000 14 | Explanation: 2-2 = 1/22 = 1/4 = 0.25 15 | 16 |   17 | Constraints: 18 | 19 | -100.0 < x < 100.0 20 | -231 <= n <= 231-1 21 | n is an integer. 22 | Either x is not zero or n > 0. 23 | -104 <= xn <= 104 24 | 25 | -------------------------------------------------------------------------------- /Qdata/713/713.txt: -------------------------------------------------------------------------------- 1 | Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times. The occurrences may overlap. 2 | Return any duplicated substring that has the longest possible length. If s does not have a duplicated substring, the answer is "". 3 |   4 | Example 1: 5 | Input: s = "banana" 6 | Output: "ana" 7 | Example 2: 8 | Input: s = "abcd" 9 | Output: "" 10 | 11 |   12 | Constraints: 13 | 14 | 2 <= s.length <= 3 * 104 15 | s consists of lowercase English letters. 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1295/1295.txt: -------------------------------------------------------------------------------- 1 | Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. 2 | You must write an algorithm that runs in O(n) time. 3 |   4 | Example 1: 5 | Input: nums = [100,4,200,1,3,2] 6 | Output: 4 7 | Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. 8 | 9 | Example 2: 10 | Input: nums = [0,3,7,2,5,8,4,6,0,1] 11 | Output: 9 12 | 13 |   14 | Constraints: 15 | 16 | 0 <= nums.length <= 105 17 | -109 <= nums[i] <= 109 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1524/1524.txt: -------------------------------------------------------------------------------- 1 | Given a binary tree, find its minimum depth. 2 | The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 3 | Note: A leaf is a node with no children. 4 |   5 | Example 1: 6 | 7 | Input: root = [3,9,20,null,null,15,7] 8 | Output: 2 9 | 10 | Example 2: 11 | Input: root = [2,null,3,null,4,null,5,null,6] 12 | Output: 5 13 | 14 |   15 | Constraints: 16 | 17 | The number of nodes in the tree is in the range [0, 105]. 18 | -1000 <= Node.val <= 1000 19 | 20 | -------------------------------------------------------------------------------- /Qdata/2143/2143.txt: -------------------------------------------------------------------------------- 1 | Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. 2 | Assume the environment does not allow you to store 64-bit integers (signed or unsigned). 3 |   4 | Example 1: 5 | Input: x = 123 6 | Output: 321 7 | 8 | Example 2: 9 | Input: x = -123 10 | Output: -321 11 | 12 | Example 3: 13 | Input: x = 120 14 | Output: 21 15 | 16 |   17 | Constraints: 18 | 19 | -231 <= x <= 231 - 1 20 | 21 | -------------------------------------------------------------------------------- /Qdata/2178/2178.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return a binary string representing its representation in base -2. 2 | Note that the returned string should not have leading zeros unless the string is "0". 3 |   4 | Example 1: 5 | Input: n = 2 6 | Output: "110" 7 | Explantion: (-2)2 + (-2)1 = 2 8 | 9 | Example 2: 10 | Input: n = 3 11 | Output: "111" 12 | Explantion: (-2)2 + (-2)1 + (-2)0 = 3 13 | 14 | Example 3: 15 | Input: n = 4 16 | Output: "100" 17 | Explantion: (-2)2 = 4 18 | 19 |   20 | Constraints: 21 | 22 | 0 <= n <= 109 23 | 24 | -------------------------------------------------------------------------------- /Qdata/2181/2181.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return a binary string representing its representation in base -2. 2 | Note that the returned string should not have leading zeros unless the string is "0". 3 |   4 | Example 1: 5 | Input: n = 2 6 | Output: "110" 7 | Explantion: (-2)2 + (-2)1 = 2 8 | 9 | Example 2: 10 | Input: n = 3 11 | Output: "111" 12 | Explantion: (-2)2 + (-2)1 + (-2)0 = 3 13 | 14 | Example 3: 15 | Input: n = 4 16 | Output: "100" 17 | Explantion: (-2)2 = 4 18 | 19 |   20 | Constraints: 21 | 22 | 0 <= n <= 109 23 | 24 | -------------------------------------------------------------------------------- /Qdata/2225/2225.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return a binary string representing its representation in base -2. 2 | Note that the returned string should not have leading zeros unless the string is "0". 3 |   4 | Example 1: 5 | Input: n = 2 6 | Output: "110" 7 | Explantion: (-2)2 + (-2)1 = 2 8 | 9 | Example 2: 10 | Input: n = 3 11 | Output: "111" 12 | Explantion: (-2)2 + (-2)1 + (-2)0 = 3 13 | 14 | Example 3: 15 | Input: n = 4 16 | Output: "100" 17 | Explantion: (-2)2 = 4 18 | 19 |   20 | Constraints: 21 | 22 | 0 <= n <= 109 23 | 24 | -------------------------------------------------------------------------------- /Qdata/395/395.txt: -------------------------------------------------------------------------------- 1 | Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string. 2 | Return a list of all possible strings we could create. Return the output in any order. 3 |   4 | Example 1: 5 | Input: s = "a1b2" 6 | Output: ["a1b2","a1B2","A1b2","A1B2"] 7 | 8 | Example 2: 9 | Input: s = "3z4" 10 | Output: ["3z4","3Z4"] 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= s.length <= 12 16 | s consists of lowercase English letters, uppercase English letters, and digits. 17 | 18 | -------------------------------------------------------------------------------- /Qdata/405/405.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return true if it is a power of two. Otherwise, return false. 2 | An integer n is a power of two, if there exists an integer x such that n == 2x. 3 |   4 | Example 1: 5 | Input: n = 1 6 | Output: true 7 | Explanation: 20 = 1 8 | 9 | Example 2: 10 | Input: n = 16 11 | Output: true 12 | Explanation: 24 = 16 13 | 14 | Example 3: 15 | Input: n = 3 16 | Output: false 17 | 18 |   19 | Constraints: 20 | 21 | -231 <= n <= 231 - 1 22 | 23 |   24 | Follow up: Could you solve it without loops/recursion? -------------------------------------------------------------------------------- /Qdata/62/62.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return a binary string representing its representation in base -2. 2 | Note that the returned string should not have leading zeros unless the string is "0". 3 |   4 | Example 1: 5 | Input: n = 2 6 | Output: "110" 7 | Explantion: (-2)2 + (-2)1 = 2 8 | 9 | Example 2: 10 | Input: n = 3 11 | Output: "111" 12 | Explantion: (-2)2 + (-2)1 + (-2)0 = 3 13 | 14 | Example 3: 15 | Input: n = 4 16 | Output: "100" 17 | Explantion: (-2)2 = 4 18 | 19 |   20 | Constraints: 21 | 22 | 0 <= n <= 109 23 | 24 | -------------------------------------------------------------------------------- /Qdata/698/698.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false. 2 | An integer y is a power of three if there exists an integer x such that y == 3x. 3 |   4 | Example 1: 5 | Input: n = 12 6 | Output: true 7 | Explanation: 12 = 31 + 32 8 | 9 | Example 2: 10 | Input: n = 91 11 | Output: true 12 | Explanation: 91 = 30 + 32 + 34 13 | 14 | Example 3: 15 | Input: n = 21 16 | Output: false 17 | 18 |   19 | Constraints: 20 | 21 | 1 <= n <= 107 22 | 23 | -------------------------------------------------------------------------------- /Qdata/954/954.txt: -------------------------------------------------------------------------------- 1 | Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand. 2 | Answers within 10-5 of the actual value will be accepted as correct. 3 |   4 | Example 1: 5 | 6 | Input: hour = 12, minutes = 30 7 | Output: 165 8 | 9 | Example 2: 10 | 11 | Input: hour = 3, minutes = 30 12 | Output: 75 13 | 14 | Example 3: 15 | 16 | Input: hour = 3, minutes = 15 17 | Output: 7.5 18 | 19 |   20 | Constraints: 21 | 22 | 1 <= hour <= 12 23 | 0 <= minutes <= 59 24 | 25 | -------------------------------------------------------------------------------- /Qdata/1021/1021.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from left to right, level by level from leaf to root). 2 |   3 | Example 1: 4 | 5 | Input: root = [3,9,20,null,null,15,7] 6 | Output: [[15,7],[9,20],[3]] 7 | 8 | Example 2: 9 | Input: root = [1] 10 | Output: [[1]] 11 | 12 | Example 3: 13 | Input: root = [] 14 | Output: [] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the tree is in the range [0, 2000]. 20 | -1000 <= Node.val <= 1000 21 | 22 | -------------------------------------------------------------------------------- /Qdata/578/578.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the least number of perfect square numbers that sum to n. 2 | A perfect square is an integer that is the square of an integer; in other words, it is the product of some integer with itself. For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not. 3 |   4 | Example 1: 5 | Input: n = 12 6 | Output: 3 7 | Explanation: 12 = 4 + 4 + 4. 8 | 9 | Example 2: 10 | Input: n = 13 11 | Output: 2 12 | Explanation: 13 = 4 + 9. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= n <= 104 18 | 19 | -------------------------------------------------------------------------------- /Qdata/108/108.txt: -------------------------------------------------------------------------------- 1 | Given an array nums of size n, return the majority element. 2 | The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. 3 |   4 | Example 1: 5 | Input: nums = [3,2,3] 6 | Output: 3 7 | Example 2: 8 | Input: nums = [2,2,1,1,1,2,2] 9 | Output: 2 10 | 11 |   12 | Constraints: 13 | 14 | n == nums.length 15 | 1 <= n <= 5 * 104 16 | -109 <= nums[i] <= 109 17 | 18 |   19 | Follow-up: Could you solve the problem in linear time and in O(1) space? -------------------------------------------------------------------------------- /Qdata/1176/1176.txt: -------------------------------------------------------------------------------- 1 | Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.) 2 |   3 | Example 1: 4 | 5 | Input: head = [1,2,3,4] 6 | Output: [2,1,4,3] 7 | 8 | Example 2: 9 | Input: head = [] 10 | Output: [] 11 | 12 | Example 3: 13 | Input: head = [1] 14 | Output: [1] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the list is in the range [0, 100]. 20 | 0 <= Node.val <= 100 21 | 22 | -------------------------------------------------------------------------------- /Qdata/292/292.txt: -------------------------------------------------------------------------------- 1 | Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images. 2 |   3 | Example 1: 4 | 5 | Input: nums = [[1,2,3],[4,5,6],[7,8,9]] 6 | Output: [1,4,2,7,5,3,8,6,9] 7 | 8 | Example 2: 9 | 10 | Input: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]] 11 | Output: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16] 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums.length <= 105 17 | 1 <= nums[i].length <= 105 18 | 1 <= sum(nums[i].length) <= 105 19 | 1 <= nums[i][j] <= 105 20 | 21 | -------------------------------------------------------------------------------- /Qdata/528/528.txt: -------------------------------------------------------------------------------- 1 | You are given two strings s and t. 2 | String t is generated by random shuffling string s and then add one more letter at a random position. 3 | Return the letter that was added to t. 4 |   5 | Example 1: 6 | Input: s = "abcd", t = "abcde" 7 | Output: "e" 8 | Explanation: 'e' is the letter that was added. 9 | 10 | Example 2: 11 | Input: s = "", t = "y" 12 | Output: "y" 13 | 14 |   15 | Constraints: 16 | 17 | 0 <= s.length <= 1000 18 | t.length == s.length + 1 19 | s and t consist of lowercase English letters. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/945/945.txt: -------------------------------------------------------------------------------- 1 | Given the head of a linked list, remove the nth node from the end of the list and return its head. 2 |   3 | Example 1: 4 | 5 | Input: head = [1,2,3,4,5], n = 2 6 | Output: [1,2,3,5] 7 | 8 | Example 2: 9 | Input: head = [1], n = 1 10 | Output: [] 11 | 12 | Example 3: 13 | Input: head = [1,2], n = 1 14 | Output: [1] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the list is sz. 20 | 1 <= sz <= 30 21 | 0 <= Node.val <= 100 22 | 1 <= n <= sz 23 | 24 |   25 | Follow up: Could you do this in one pass? 26 | -------------------------------------------------------------------------------- /Qdata/1137/1137.txt: -------------------------------------------------------------------------------- 1 | Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year. 2 |   3 | Example 1: 4 | Input: date = "2019-01-09" 5 | Output: 9 6 | Explanation: Given date is the 9th day of the year in 2019. 7 | 8 | Example 2: 9 | Input: date = "2019-02-10" 10 | Output: 41 11 | 12 |   13 | Constraints: 14 | 15 | date.length == 10 16 | date[4] == date[7] == '-', and all other date[i]'s are digits 17 | date represents a calendar date between Jan 1st, 1900 and Dec 31th, 2019. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1470/1470.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the number of trailing zeroes in n!. 2 | Note that n! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1. 3 |   4 | Example 1: 5 | Input: n = 3 6 | Output: 0 7 | Explanation: 3! = 6, no trailing zero. 8 | 9 | Example 2: 10 | Input: n = 5 11 | Output: 1 12 | Explanation: 5! = 120, one trailing zero. 13 | 14 | Example 3: 15 | Input: n = 0 16 | Output: 0 17 | 18 |   19 | Constraints: 20 | 21 | 0 <= n <= 104 22 | 23 |   24 | Follow up: Could you write a solution that works in logarithmic time complexity? 25 | -------------------------------------------------------------------------------- /Qdata/1491/1491.txt: -------------------------------------------------------------------------------- 1 | Given the head of a singly linked list where elements are sorted in ascending order, convert it to a height-balanced binary search tree. 2 |   3 | Example 1: 4 | 5 | Input: head = [-10,-3,0,5,9] 6 | Output: [0,-3,9,-10,null,5] 7 | Explanation: One possible answer is [0,-3,9,-10,null,5], which represents the shown height balanced BST. 8 | 9 | Example 2: 10 | Input: head = [] 11 | Output: [] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in head is in the range [0, 2 * 104]. 17 | -105 <= Node.val <= 105 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1538/1538.txt: -------------------------------------------------------------------------------- 1 | Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. 2 |   3 | Example 1: 4 | Input: nums = [0,1] 5 | Output: 2 6 | Explanation: [0, 1] is the longest contiguous subarray with an equal number of 0 and 1. 7 | 8 | Example 2: 9 | Input: nums = [0,1,0] 10 | Output: 2 11 | Explanation: [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums.length <= 105 17 | nums[i] is either 0 or 1. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1954/1954.txt: -------------------------------------------------------------------------------- 1 | Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head. 2 |   3 | Example 1: 4 | 5 | Input: head = [1,2,6,3,4,5,6], val = 6 6 | Output: [1,2,3,4,5] 7 | 8 | Example 2: 9 | Input: head = [], val = 1 10 | Output: [] 11 | 12 | Example 3: 13 | Input: head = [7,7,7,7], val = 7 14 | Output: [] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the list is in the range [0, 104]. 20 | 1 <= Node.val <= 50 21 | 0 <= val <= 50 22 | 23 | -------------------------------------------------------------------------------- /Qdata/259/259.txt: -------------------------------------------------------------------------------- 1 | Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well. 2 |   3 | Example 1: 4 | 5 | Input: head = [1,2,3,3,4,4,5] 6 | Output: [1,2,5] 7 | 8 | Example 2: 9 | 10 | Input: head = [1,1,1,2,3] 11 | Output: [2,3] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the list is in the range [0, 300]. 17 | -100 <= Node.val <= 100 18 | The list is guaranteed to be sorted in ascending order. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/486/486.txt: -------------------------------------------------------------------------------- 1 | Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise. 2 | In other words, return true if one of s1's permutations is the substring of s2. 3 |   4 | Example 1: 5 | Input: s1 = "ab", s2 = "eidbaooo" 6 | Output: true 7 | Explanation: s2 contains one permutation of s1 ("ba"). 8 | 9 | Example 2: 10 | Input: s1 = "ab", s2 = "eidboaoo" 11 | Output: false 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= s1.length, s2.length <= 104 17 | s1 and s2 consist of lowercase English letters. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/983/983.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values. 2 |   3 | Example 1: 4 | Input: n = 5 5 | Output: true 6 | Explanation: The binary representation of 5 is: 101 7 | 8 | Example 2: 9 | Input: n = 7 10 | Output: false 11 | Explanation: The binary representation of 7 is: 111. 12 | Example 3: 13 | Input: n = 11 14 | Output: false 15 | Explanation: The binary representation of 11 is: 1011. 16 |   17 | Constraints: 18 | 19 | 1 <= n <= 231 - 1 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1083/1083.txt: -------------------------------------------------------------------------------- 1 | An array nums of length n is beautiful if: 2 | 3 | nums is a permutation of the integers in the range [1, n]. 4 | For every 0 <= i < j < n, there is no index k with i < k < j where 2 * nums[k] == nums[i] + nums[j]. 5 | 6 | Given the integer n, return any beautiful array nums of length n. There will be at least one valid answer for the given n. 7 |   8 | Example 1: 9 | Input: n = 4 10 | Output: [2,1,4,3] 11 | Example 2: 12 | Input: n = 5 13 | Output: [3,1,2,5,4] 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= n <= 1000 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1888/1888.txt: -------------------------------------------------------------------------------- 1 | Given an array arr of integers, check if there exist two indices i and j such that : 2 | 3 | i != j 4 | 0 <= i, j < arr.length 5 | arr[i] == 2 * arr[j] 6 | 7 |   8 | Example 1: 9 | Input: arr = [10,2,5,3] 10 | Output: true 11 | Explanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j] 12 | 13 | Example 2: 14 | Input: arr = [3,1,7,11] 15 | Output: false 16 | Explanation: There is no i and j that satisfy the conditions. 17 | 18 |   19 | Constraints: 20 | 21 | 2 <= arr.length <= 500 22 | -103 <= arr[i] <= 103 23 | 24 | -------------------------------------------------------------------------------- /Qdata/656/656.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no such subarray, return -1. 2 | A subarray is a contiguous part of an array. 3 |   4 | Example 1: 5 | Input: nums = [1], k = 1 6 | Output: 1 7 | Example 2: 8 | Input: nums = [1,2], k = 4 9 | Output: -1 10 | Example 3: 11 | Input: nums = [2,-1,2], k = 3 12 | Output: 3 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 105 18 | -105 <= nums[i] <= 105 19 | 1 <= k <= 109 20 | 21 | -------------------------------------------------------------------------------- /Qdata/72/72.txt: -------------------------------------------------------------------------------- 1 | The Hamming distance between two integers is the number of positions at which the corresponding bits are different. 2 | Given two integers x and y, return the Hamming distance between them. 3 |   4 | Example 1: 5 | Input: x = 1, y = 4 6 | Output: 2 7 | Explanation: 8 | 1 (0 0 0 1) 9 | 4 (0 1 0 0) 10 | ↑ ↑ 11 | The above arrows point to positions where the corresponding bits are different. 12 | 13 | Example 2: 14 | Input: x = 3, y = 1 15 | Output: 1 16 | 17 |   18 | Constraints: 19 | 20 | 0 <= x, y <= 231 - 1 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1347/1347.txt: -------------------------------------------------------------------------------- 1 | Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. 2 | In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: 3 | 4 |   5 | Example 1: 6 | Input: rowIndex = 3 7 | Output: [1,3,3,1] 8 | Example 2: 9 | Input: rowIndex = 0 10 | Output: [1] 11 | Example 3: 12 | Input: rowIndex = 1 13 | Output: [1,1] 14 | 15 |   16 | Constraints: 17 | 18 | 0 <= rowIndex <= 33 19 | 20 |   21 | Follow up: Could you optimize your algorithm to use only O(rowIndex) extra space? 22 | -------------------------------------------------------------------------------- /Qdata/1419/1419.txt: -------------------------------------------------------------------------------- 1 | Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums. 2 |   3 | Example 1: 4 | Input: nums = [4,3,2,7,8,2,3,1] 5 | Output: [5,6] 6 | Example 2: 7 | Input: nums = [1,1] 8 | Output: [2] 9 | 10 |   11 | Constraints: 12 | 13 | n == nums.length 14 | 1 <= n <= 105 15 | 1 <= nums[i] <= n 16 | 17 |   18 | Follow up: Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space. 19 | -------------------------------------------------------------------------------- /Qdata/1689/1689.txt: -------------------------------------------------------------------------------- 1 | Given an integer number n, return the difference between the product of its digits and the sum of its digits. 2 |   3 | Example 1: 4 | Input: n = 234 5 | Output: 15 6 | Explanation: 7 | Product of digits = 2 * 3 * 4 = 24 8 | Sum of digits = 2 + 3 + 4 = 9 9 | Result = 24 - 9 = 15 10 | 11 | Example 2: 12 | Input: n = 4421 13 | Output: 21 14 | Explanation: 15 | Product of digits = 4 * 4 * 2 * 1 = 32 16 | Sum of digits = 4 + 4 + 2 + 1 = 11 17 | Result = 32 - 11 = 21 18 | 19 |   20 | Constraints: 21 | 22 | 1 <= n <= 10^5 23 | 24 | -------------------------------------------------------------------------------- /Qdata/1933/1933.txt: -------------------------------------------------------------------------------- 1 | Write a function to find the longest common prefix string amongst an array of strings. 2 | If there is no common prefix, return an empty string "". 3 |   4 | Example 1: 5 | Input: strs = ["flower","flow","flight"] 6 | Output: "fl" 7 | 8 | Example 2: 9 | Input: strs = ["dog","racecar","car"] 10 | Output: "" 11 | Explanation: There is no common prefix among the input strings. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= strs.length <= 200 17 | 0 <= strs[i].length <= 200 18 | strs[i] consists of only lowercase English letters. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/2085/2085.txt: -------------------------------------------------------------------------------- 1 | Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring. 2 |   3 | Example 1: 4 | Input: s = "(()" 5 | Output: 2 6 | Explanation: The longest valid parentheses substring is "()". 7 | 8 | Example 2: 9 | Input: s = ")()())" 10 | Output: 4 11 | Explanation: The longest valid parentheses substring is "()()". 12 | 13 | Example 3: 14 | Input: s = "" 15 | Output: 0 16 | 17 |   18 | Constraints: 19 | 20 | 0 <= s.length <= 3 * 104 21 | s[i] is '(', or ')'. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/2168/2168.txt: -------------------------------------------------------------------------------- 1 | You are given the head of a linked list, and an integer k. 2 | Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed). 3 |   4 | Example 1: 5 | 6 | Input: head = [1,2,3,4,5], k = 2 7 | Output: [1,4,3,2,5] 8 | 9 | Example 2: 10 | Input: head = [7,9,6,6,7,8,3,0,9,5], k = 5 11 | Output: [7,9,6,6,8,7,3,0,9,5] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the list is n. 17 | 1 <= k <= n <= 105 18 | 0 <= Node.val <= 100 19 | 20 | -------------------------------------------------------------------------------- /Qdata/2194/2194.txt: -------------------------------------------------------------------------------- 1 | Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. 2 | In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: 3 | 4 |   5 | Example 1: 6 | Input: rowIndex = 3 7 | Output: [1,3,3,1] 8 | Example 2: 9 | Input: rowIndex = 0 10 | Output: [1] 11 | Example 3: 12 | Input: rowIndex = 1 13 | Output: [1,1] 14 | 15 |   16 | Constraints: 17 | 18 | 0 <= rowIndex <= 33 19 | 20 |   21 | Follow up: Could you optimize your algorithm to use only O(rowIndex) extra space? 22 | -------------------------------------------------------------------------------- /Qdata/653/653.txt: -------------------------------------------------------------------------------- 1 | Given the root of a Binary Search Tree (BST), return the minimum difference between the values of any two different nodes in the tree. 2 |   3 | Example 1: 4 | 5 | Input: root = [4,2,6,1,3] 6 | Output: 1 7 | 8 | Example 2: 9 | 10 | Input: root = [1,0,48,null,null,12,49] 11 | Output: 1 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is in the range [2, 100]. 17 | 0 <= Node.val <= 105 18 | 19 |   20 | Note: This question is the same as 530: https://leetcode.com/problems/minimum-absolute-difference-in-bst/ 21 | -------------------------------------------------------------------------------- /Qdata/669/669.txt: -------------------------------------------------------------------------------- 1 | Given a string s, partition s such that every substring of the partition is a palindrome. 2 | Return the minimum cuts needed for a palindrome partitioning of s. 3 |   4 | Example 1: 5 | Input: s = "aab" 6 | Output: 1 7 | Explanation: The palindrome partitioning ["aa","b"] could be produced using 1 cut. 8 | 9 | Example 2: 10 | Input: s = "a" 11 | Output: 0 12 | 13 | Example 3: 14 | Input: s = "ab" 15 | Output: 1 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= s.length <= 2000 21 | s consists of lowercase English letters only. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/684/684.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the zigzag level order traversal of its nodes' values. (i.e., from left to right, then right to left for the next level and alternate between). 2 |   3 | Example 1: 4 | 5 | Input: root = [3,9,20,null,null,15,7] 6 | Output: [[3],[20,9],[15,7]] 7 | 8 | Example 2: 9 | Input: root = [1] 10 | Output: [[1]] 11 | 12 | Example 3: 13 | Input: root = [] 14 | Output: [] 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the tree is in the range [0, 2000]. 20 | -100 <= Node.val <= 100 21 | 22 | -------------------------------------------------------------------------------- /Qdata/873/873.txt: -------------------------------------------------------------------------------- 1 | A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. A divisor of an integer x is an integer that can divide x evenly. 2 | Given an integer n, return true if n is a perfect number, otherwise return false. 3 |   4 | Example 1: 5 | Input: num = 28 6 | Output: true 7 | Explanation: 28 = 1 + 2 + 4 + 7 + 14 8 | 1, 2, 4, 7, and 14 are all divisors of 28. 9 | 10 | Example 2: 11 | Input: num = 7 12 | Output: false 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= num <= 108 18 | 19 | -------------------------------------------------------------------------------- /Qdata/935/935.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements. 2 | 3 | 4 |   5 | Example 1: 6 | Input: arr = [5,5,4], k = 1 7 | Output: 1 8 | Explanation: Remove the single 4, only 5 is left. 9 | 10 | Example 2: 11 | Input: arr = [4,3,1,1,3,3,2], k = 3 12 | Output: 2 13 | Explanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left. 14 |   15 | Constraints: 16 | 17 | 1 <= arr.length <= 10^5 18 | 1 <= arr[i] <= 10^9 19 | 0 <= k <= arr.length 20 | -------------------------------------------------------------------------------- /Qdata/981/981.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or false otherwise. 2 |   3 | Example 1: 4 | Input: nums = [1,5,11,5] 5 | Output: true 6 | Explanation: The array can be partitioned as [1, 5, 5] and [11]. 7 | 8 | Example 2: 9 | Input: nums = [1,2,3,5] 10 | Output: false 11 | Explanation: The array cannot be partitioned into equal sum subsets. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums.length <= 200 17 | 1 <= nums[i] <= 100 18 | 19 | -------------------------------------------------------------------------------- /Qdata/484/484.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the sum of all left leaves. 2 | A leaf is a node with no children. A left leaf is a leaf that is the left child of another node. 3 |   4 | Example 1: 5 | 6 | Input: root = [3,9,20,null,null,15,7] 7 | Output: 24 8 | Explanation: There are two left leaves in the binary tree, with values 9 and 15 respectively. 9 | 10 | Example 2: 11 | Input: root = [1] 12 | Output: 0 13 | 14 |   15 | Constraints: 16 | 17 | The number of nodes in the tree is in the range [1, 1000]. 18 | -1000 <= Node.val <= 1000 19 | 20 | -------------------------------------------------------------------------------- /Qdata/781/781.txt: -------------------------------------------------------------------------------- 1 | Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2. 2 | Return the two integers in any order. 3 |   4 | Example 1: 5 | Input: num = 8 6 | Output: [3,3] 7 | Explanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3 is chosen. 8 | 9 | Example 2: 10 | Input: num = 123 11 | Output: [5,25] 12 | 13 | Example 3: 14 | Input: num = 999 15 | Output: [40,25] 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= num <= 10^9 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1743/1743.txt: -------------------------------------------------------------------------------- 1 | Given the root of a Binary Search Tree (BST), return the minimum absolute difference between the values of any two different nodes in the tree. 2 |   3 | Example 1: 4 | 5 | Input: root = [4,2,6,1,3] 6 | Output: 1 7 | 8 | Example 2: 9 | 10 | Input: root = [1,0,48,null,null,12,49] 11 | Output: 1 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is in the range [2, 104]. 17 | 0 <= Node.val <= 105 18 | 19 |   20 | Note: This question is the same as 783: https://leetcode.com/problems/minimum-distance-between-bst-nodes/ 21 | -------------------------------------------------------------------------------- /Qdata/2029/2029.txt: -------------------------------------------------------------------------------- 1 | Given the head of a singly linked list, reverse the list, and return the reversed list. 2 |   3 | Example 1: 4 | 5 | Input: head = [1,2,3,4,5] 6 | Output: [5,4,3,2,1] 7 | 8 | Example 2: 9 | 10 | Input: head = [1,2] 11 | Output: [2,1] 12 | 13 | Example 3: 14 | Input: head = [] 15 | Output: [] 16 | 17 |   18 | Constraints: 19 | 20 | The number of nodes in the list is the range [0, 5000]. 21 | -5000 <= Node.val <= 5000 22 | 23 |   24 | Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 25 | -------------------------------------------------------------------------------- /Qdata/1112/1112.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary search tree and an integer k, return true if there exist two elements in the BST such that their sum is equal to k, or false otherwise. 2 |   3 | Example 1: 4 | 5 | Input: root = [5,3,6,2,4,null,7], k = 9 6 | Output: true 7 | 8 | Example 2: 9 | 10 | Input: root = [5,3,6,2,4,null,7], k = 28 11 | Output: false 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is in the range [1, 104]. 17 | -104 <= Node.val <= 104 18 | root is guaranteed to be a valid binary search tree. 19 | -105 <= k <= 105 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1417/1417.txt: -------------------------------------------------------------------------------- 1 | Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. 2 | You should preserve the original relative order of the nodes in each of the two partitions. 3 |   4 | Example 1: 5 | 6 | Input: head = [1,4,3,2,5,2], x = 3 7 | Output: [1,2,2,4,3,5] 8 | 9 | Example 2: 10 | Input: head = [2,1], x = 2 11 | Output: [1,2] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the list is in the range [0, 200]. 17 | -100 <= Node.val <= 100 18 | -200 <= x <= 200 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1441/1441.txt: -------------------------------------------------------------------------------- 1 | Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. 2 | The distance between two adjacent cells is 1. 3 |   4 | Example 1: 5 | 6 | Input: mat = [[0,0,0],[0,1,0],[0,0,0]] 7 | Output: [[0,0,0],[0,1,0],[0,0,0]] 8 | 9 | Example 2: 10 | 11 | Input: mat = [[0,0,0],[0,1,0],[1,1,1]] 12 | Output: [[0,0,0],[0,1,0],[1,2,1]] 13 | 14 |   15 | Constraints: 16 | 17 | m == mat.length 18 | n == mat[i].length 19 | 1 <= m, n <= 104 20 | 1 <= m * n <= 104 21 | mat[i][j] is either 0 or 1. 22 | There is at least one 0 in mat. 23 | 24 | -------------------------------------------------------------------------------- /Qdata/2192/2192.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary search tree and an integer k, return true if there exist two elements in the BST such that their sum is equal to k, or false otherwise. 2 |   3 | Example 1: 4 | 5 | Input: root = [5,3,6,2,4,null,7], k = 9 6 | Output: true 7 | 8 | Example 2: 9 | 10 | Input: root = [5,3,6,2,4,null,7], k = 28 11 | Output: false 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is in the range [1, 104]. 17 | -104 <= Node.val <= 104 18 | root is guaranteed to be a valid binary search tree. 19 | -105 <= k <= 105 20 | 21 | -------------------------------------------------------------------------------- /Qdata/375/375.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers nums, return the number of good pairs. 2 | A pair (i, j) is called good if nums[i] == nums[j] and i < j. 3 |   4 | Example 1: 5 | Input: nums = [1,2,3,1,1,3] 6 | Output: 4 7 | Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed. 8 | 9 | Example 2: 10 | Input: nums = [1,1,1,1] 11 | Output: 6 12 | Explanation: Each pair in the array are good. 13 | 14 | Example 3: 15 | Input: nums = [1,2,3] 16 | Output: 0 17 | 18 |   19 | Constraints: 20 | 21 | 1 <= nums.length <= 100 22 | 1 <= nums[i] <= 100 23 | 24 | -------------------------------------------------------------------------------- /Qdata/844/844.txt: -------------------------------------------------------------------------------- 1 | Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays. 2 |   3 | Example 1: 4 | Input: nums1 = [1,2,3,2,1], nums2 = [3,2,1,4,7] 5 | Output: 3 6 | Explanation: The repeated subarray with maximum length is [3,2,1]. 7 | 8 | Example 2: 9 | Input: nums1 = [0,0,0,0,0], nums2 = [0,0,0,0,0] 10 | Output: 5 11 | Explanation: The repeated subarray with maximum length is [0,0,0,0,0]. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums1.length, nums2.length <= 1000 17 | 0 <= nums1[i], nums2[i] <= 100 18 | 19 | -------------------------------------------------------------------------------- /Qdata/991/991.txt: -------------------------------------------------------------------------------- 1 | Given the head of a linked list, return the list after sorting it in ascending order. 2 |   3 | Example 1: 4 | 5 | Input: head = [4,2,1,3] 6 | Output: [1,2,3,4] 7 | 8 | Example 2: 9 | 10 | Input: head = [-1,5,3,4,0] 11 | Output: [-1,0,3,4,5] 12 | 13 | Example 3: 14 | Input: head = [] 15 | Output: [] 16 | 17 |   18 | Constraints: 19 | 20 | The number of nodes in the list is in the range [0, 5 * 104]. 21 | -105 <= Node.val <= 105 22 | 23 |   24 | Follow up: Can you sort the linked list in O(n logn) time and O(1) memory (i.e. constant space)? 25 | -------------------------------------------------------------------------------- /Qdata/1668/1668.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise. 2 |   3 | Example 1: 4 | Input: arr = [1,2,2,1,1,3] 5 | Output: true 6 | Explanation: The value 1 has 3 occurrences, 2 has 2 and 3 has 1. No two values have the same number of occurrences. 7 | Example 2: 8 | Input: arr = [1,2] 9 | Output: false 10 | 11 | Example 3: 12 | Input: arr = [-3,0,1,-3,1,1,1,-3,10,0] 13 | Output: true 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= arr.length <= 1000 19 | -1000 <= arr[i] <= 1000 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1157/1157.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit. 2 |   3 | Example 1: 4 | Input: n = 20 5 | Output: 1 6 | Explanation: The only positive number (<= 20) with at least 1 repeated digit is 11. 7 | 8 | Example 2: 9 | Input: n = 100 10 | Output: 10 11 | Explanation: The positive numbers (<= 100) with atleast 1 repeated digit are 11, 22, 33, 44, 55, 66, 77, 88, 99, and 100. 12 | 13 | Example 3: 14 | Input: n = 1000 15 | Output: 262 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= n <= 109 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1579/1579.txt: -------------------------------------------------------------------------------- 1 | Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results. 2 |   3 | Example 1: 4 | Input: s = "bcabc" 5 | Output: "abc" 6 | 7 | Example 2: 8 | Input: s = "cbacdcbc" 9 | Output: "acdb" 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= s.length <= 104 15 | s consists of lowercase English letters. 16 | 17 |   18 | Note: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/ 19 | -------------------------------------------------------------------------------- /Qdata/1992/1992.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal. 2 |   3 | Example 1: 4 | Input: nums = [4,3,2,3,5,2,1], k = 4 5 | Output: true 6 | Explanation: It is possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with equal sums. 7 | 8 | Example 2: 9 | Input: nums = [1,2,3,4], k = 3 10 | Output: false 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= k <= nums.length <= 16 16 | 1 <= nums[i] <= 104 17 | The frequency of each element is in the range [1, 4]. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/589/589.txt: -------------------------------------------------------------------------------- 1 | Given a 2D integer array matrix, return the transpose of matrix. 2 | The transpose of a matrix is the matrix flipped over its main diagonal, switching the matrix's row and column indices. 3 | 4 |   5 | Example 1: 6 | Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] 7 | Output: [[1,4,7],[2,5,8],[3,6,9]] 8 | 9 | Example 2: 10 | Input: matrix = [[1,2,3],[4,5,6]] 11 | Output: [[1,4],[2,5],[3,6]] 12 | 13 |   14 | Constraints: 15 | 16 | m == matrix.length 17 | n == matrix[i].length 18 | 1 <= m, n <= 1000 19 | 1 <= m * n <= 105 20 | -109 <= matrix[i][j] <= 109 21 | 22 | -------------------------------------------------------------------------------- /Qdata/749/749.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer millis, write an asynchronous function that sleeps for millis milliseconds. It can resolve any value. 2 |   3 | Example 1: 4 | Input: millis = 100 5 | Output: 100 6 | Explanation: It should return a promise that resolves after 100ms. 7 | let t = Date.now(); 8 | sleep(100).then(() => { 9 | console.log(Date.now() - t); // 100 10 | }); 11 | 12 | Example 2: 13 | Input: millis = 200 14 | Output: 200 15 | Explanation: It should return a promise that resolves after 200ms. 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= millis <= 1000 21 | 22 | -------------------------------------------------------------------------------- /Qdata/989/989.txt: -------------------------------------------------------------------------------- 1 | The set [1, 2, 3, ..., n] contains a total of n! unique permutations. 2 | By listing and labeling all of the permutations in order, we get the following sequence for n = 3: 3 | 4 | "123" 5 | "132" 6 | "213" 7 | "231" 8 | "312" 9 | "321" 10 | 11 | Given n and k, return the kth permutation sequence. 12 |   13 | Example 1: 14 | Input: n = 3, k = 3 15 | Output: "213" 16 | Example 2: 17 | Input: n = 4, k = 9 18 | Output: "2314" 19 | Example 3: 20 | Input: n = 3, k = 1 21 | Output: "123" 22 | 23 |   24 | Constraints: 25 | 26 | 1 <= n <= 9 27 | 1 <= k <= n! 28 | 29 | -------------------------------------------------------------------------------- /Qdata/1274/1274.txt: -------------------------------------------------------------------------------- 1 | Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. 2 |   3 | Example 1: 4 | 5 | Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] 6 | Output: 4 7 | 8 | Example 2: 9 | 10 | Input: matrix = [["0","1"],["1","0"]] 11 | Output: 1 12 | 13 | Example 3: 14 | Input: matrix = [["0"]] 15 | Output: 0 16 | 17 |   18 | Constraints: 19 | 20 | m == matrix.length 21 | n == matrix[i].length 22 | 1 <= m, n <= 300 23 | matrix[i][j] is '0' or '1'. 24 | 25 | -------------------------------------------------------------------------------- /Qdata/1732/1732.txt: -------------------------------------------------------------------------------- 1 | Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k. 2 | After converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10. 3 |   4 | Example 1: 5 | Input: n = 34, k = 6 6 | Output: 9 7 | Explanation: 34 (base 10) expressed in base 6 is 54. 5 + 4 = 9. 8 | 9 | Example 2: 10 | Input: n = 10, k = 10 11 | Output: 1 12 | Explanation: n is already in base 10. 1 + 0 = 1. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= n <= 100 18 | 2 <= k <= 10 19 | 20 | -------------------------------------------------------------------------------- /Qdata/401/401.txt: -------------------------------------------------------------------------------- 1 | You are climbing a staircase. It takes n steps to reach the top. 2 | Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? 3 |   4 | Example 1: 5 | Input: n = 2 6 | Output: 2 7 | Explanation: There are two ways to climb to the top. 8 | 1. 1 step + 1 step 9 | 2. 2 steps 10 | 11 | Example 2: 12 | Input: n = 3 13 | Output: 3 14 | Explanation: There are three ways to climb to the top. 15 | 1. 1 step + 1 step + 1 step 16 | 2. 1 step + 2 steps 17 | 3. 2 steps + 1 step 18 | 19 |   20 | Constraints: 21 | 22 | 1 <= n <= 45 23 | 24 | -------------------------------------------------------------------------------- /Qdata/1314/1314.txt: -------------------------------------------------------------------------------- 1 | Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s. 2 | A shift on s consists of moving the leftmost character of s to the rightmost position. 3 | 4 | For example, if s = "abcde", then it will be "bcdea" after one shift. 5 | 6 |   7 | Example 1: 8 | Input: s = "abcde", goal = "cdeab" 9 | Output: true 10 | Example 2: 11 | Input: s = "abcde", goal = "abced" 12 | Output: false 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= s.length, goal.length <= 100 18 | s and goal consist of lowercase English letters. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1368/1368.txt: -------------------------------------------------------------------------------- 1 | Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal. 2 | A subarray is a contiguous part of the array. 3 |   4 | Example 1: 5 | Input: nums = [1,0,1,0,1], goal = 2 6 | Output: 4 7 | Explanation: The 4 subarrays are bolded and underlined below: 8 | [1,0,1,0,1] 9 | [1,0,1,0,1] 10 | [1,0,1,0,1] 11 | [1,0,1,0,1] 12 | 13 | Example 2: 14 | Input: nums = [0,0,0,0,0], goal = 0 15 | Output: 15 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= nums.length <= 3 * 104 21 | nums[i] is either 0 or 1. 22 | 0 <= goal <= nums.length 23 | -------------------------------------------------------------------------------- /Qdata/1438/1438.txt: -------------------------------------------------------------------------------- 1 | Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid. 2 |   3 | Example 1: 4 | Input: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]] 5 | Output: 8 6 | Explanation: There are 8 negatives number in the matrix. 7 | 8 | Example 2: 9 | Input: grid = [[3,2],[1,0]] 10 | Output: 0 11 | 12 |   13 | Constraints: 14 | 15 | m == grid.length 16 | n == grid[i].length 17 | 1 <= m, n <= 100 18 | -100 <= grid[i][j] <= 100 19 | 20 |   21 | Follow up: Could you find an O(n + m) solution? -------------------------------------------------------------------------------- /Qdata/1865/1865.txt: -------------------------------------------------------------------------------- 1 | Given two integers a and b, return any string s such that: 2 | 3 | s has length a + b and contains exactly a 'a' letters, and exactly b 'b' letters, 4 | The substring 'aaa' does not occur in s, and 5 | The substring 'bbb' does not occur in s. 6 | 7 |   8 | Example 1: 9 | Input: a = 1, b = 2 10 | Output: "abb" 11 | Explanation: "abb", "bab" and "bba" are all correct answers. 12 | 13 | Example 2: 14 | Input: a = 4, b = 1 15 | Output: "aabaa" 16 | 17 |   18 | Constraints: 19 | 20 | 0 <= a, b <= 100 21 | It is guaranteed such an s exists for the given a and b. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/2077/2077.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram. 2 |   3 | Example 1: 4 | 5 | Input: heights = [2,1,5,6,2,3] 6 | Output: 10 7 | Explanation: The above is a histogram where width of each bar is 1. 8 | The largest rectangle is shown in the red area, which has an area = 10 units. 9 | 10 | Example 2: 11 | 12 | Input: heights = [2,4] 13 | Output: 4 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= heights.length <= 105 19 | 0 <= heights[i] <= 104 20 | 21 | -------------------------------------------------------------------------------- /Qdata/307/307.txt: -------------------------------------------------------------------------------- 1 | Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. 2 | You can use each character in text at most once. Return the maximum number of instances that can be formed. 3 |   4 | Example 1: 5 | 6 | Input: text = "nlaebolko" 7 | Output: 1 8 | 9 | Example 2: 10 | 11 | Input: text = "loonbalxballpoon" 12 | Output: 2 13 | 14 | Example 3: 15 | Input: text = "leetcode" 16 | Output: 0 17 | 18 |   19 | Constraints: 20 | 21 | 1 <= text.length <= 104 22 | text consists of lower case English letters only. 23 | 24 | -------------------------------------------------------------------------------- /Qdata/386/386.txt: -------------------------------------------------------------------------------- 1 | The power of the string is the maximum length of a non-empty substring that contains only one unique character. 2 | Given a string s, return the power of s. 3 |   4 | Example 1: 5 | Input: s = "leetcode" 6 | Output: 2 7 | Explanation: The substring "ee" is of length 2 with the character 'e' only. 8 | 9 | Example 2: 10 | Input: s = "abbcccddddeeeeedcba" 11 | Output: 5 12 | Explanation: The substring "eeeee" is of length 5 with the character 'e' only. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= s.length <= 500 18 | s consists of only lowercase English letters. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/413/413.txt: -------------------------------------------------------------------------------- 1 | Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. 2 |   3 | Example 1: 4 | Input: s = "abab" 5 | Output: true 6 | Explanation: It is the substring "ab" twice. 7 | 8 | Example 2: 9 | Input: s = "aba" 10 | Output: false 11 | 12 | Example 3: 13 | Input: s = "abcabcabcabc" 14 | Output: true 15 | Explanation: It is the substring "abc" four times or the substring "abcabc" twice. 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= s.length <= 104 21 | s consists of lowercase English letters. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/49/49.txt: -------------------------------------------------------------------------------- 1 | Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. 2 |   3 | Example 1: 4 | Input: s = "Let's take LeetCode contest" 5 | Output: "s'teL ekat edoCteeL tsetnoc" 6 | Example 2: 7 | Input: s = "God Ding" 8 | Output: "doG gniD" 9 | 10 |   11 | Constraints: 12 | 13 | 1 <= s.length <= 5 * 104 14 | s contains printable ASCII characters. 15 | s does not contain any leading or trailing spaces. 16 | There is at least one word in s. 17 | All the words in s are separated by a single space. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/767/767.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer num represented as a string, return the integer num without trailing zeros as a string. 2 |   3 | Example 1: 4 | Input: num = "51230100" 5 | Output: "512301" 6 | Explanation: Integer "51230100" has 2 trailing zeros, we remove them and return integer "512301". 7 | 8 | Example 2: 9 | Input: num = "123" 10 | Output: "123" 11 | Explanation: Integer "123" has no trailing zeros, we return integer "123". 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= num.length <= 1000 17 | num consists of only digits. 18 | num doesn't have any leading zeros. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1059/1059.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary search 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 one right child. 2 |   3 | Example 1: 4 | 5 | Input: root = [5,3,6,2,4,null,8,1,null,null,null,7,9] 6 | Output: [1,null,2,null,3,null,4,null,5,null,6,null,7,null,8,null,9] 7 | 8 | Example 2: 9 | 10 | Input: root = [5,1,7] 11 | Output: [1,null,5,null,7] 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the given tree will be in the range [1, 100]. 17 | 0 <= Node.val <= 1000 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1281/1281.txt: -------------------------------------------------------------------------------- 1 | An array is squareful if the sum of every pair of adjacent elements is a perfect square. 2 | Given an integer array nums, return the number of permutations of nums that are squareful. 3 | Two permutations perm1 and perm2 are different if there is some index i such that perm1[i] != perm2[i]. 4 |   5 | Example 1: 6 | Input: nums = [1,17,8] 7 | Output: 2 8 | Explanation: [1,8,17] and [17,8,1] are the valid permutations. 9 | 10 | Example 2: 11 | Input: nums = [2,2,2] 12 | Output: 1 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 12 18 | 0 <= nums[i] <= 109 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1535/1535.txt: -------------------------------------------------------------------------------- 1 | Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right, and return the reversed list. 2 |   3 | Example 1: 4 | 5 | Input: head = [1,2,3,4,5], left = 2, right = 4 6 | Output: [1,4,3,2,5] 7 | 8 | Example 2: 9 | Input: head = [5], left = 1, right = 1 10 | Output: [5] 11 | 12 |   13 | Constraints: 14 | 15 | The number of nodes in the list is n. 16 | 1 <= n <= 500 17 | -500 <= Node.val <= 500 18 | 1 <= left <= right <= n 19 | 20 |   21 | Follow up: Could you do it in one pass? -------------------------------------------------------------------------------- /Qdata/1684/1684.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums where the elements are sorted in ascending order, convert it to a height-balanced binary search tree. 2 |   3 | Example 1: 4 | 5 | Input: nums = [-10,-3,0,5,9] 6 | Output: [0,-3,9,-10,null,5] 7 | Explanation: [0,-10,5,null,-3,null,9] is also accepted: 8 | 9 | 10 | Example 2: 11 | 12 | Input: nums = [1,3] 13 | Output: [3,1] 14 | Explanation: [1,null,3] and [3,1] are both height-balanced BSTs. 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= nums.length <= 104 20 | -104 <= nums[i] <= 104 21 | nums is sorted in a strictly increasing order. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/1692/1692.txt: -------------------------------------------------------------------------------- 1 | Write a function argumentsLength that returns the count of arguments passed to it. 2 |   3 | Example 1: 4 | Input: argsArr = [5] 5 | Output: 1 6 | Explanation: 7 | argumentsLength(5); // 1 8 | 9 | One value was passed to the function so it should return 1. 10 | 11 | Example 2: 12 | Input: argsArr = [{}, null, "3"] 13 | Output: 3 14 | Explanation: 15 | argumentsLength({}, null, "3"); // 3 16 | 17 | Three values were passed to the function so it should return 3. 18 | 19 |   20 | Constraints: 21 | 22 | argsArr is a valid JSON array 23 | 0 <= argsArr.length <= 100 24 | 25 | -------------------------------------------------------------------------------- /Qdata/1999/1999.txt: -------------------------------------------------------------------------------- 1 | Write code that enhances all arrays such that you can call the array.last() method on any array and it will return the last element. If there are no elements in the array, it should return -1. 2 | You may assume the array is the output of JSON.parse. 3 |   4 | Example 1: 5 | Input: nums = [null, {}, 3] 6 | Output: 3 7 | Explanation: Calling nums.last() should return the last element: 3. 8 | 9 | Example 2: 10 | Input: nums = [] 11 | Output: -1 12 | Explanation: Because there are no elements, return -1. 13 | 14 |   15 | Constraints: 16 | 17 | 0 <= arr.length <= 1000 18 | 19 | -------------------------------------------------------------------------------- /Qdata/202/202.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the most frequent subtree sum. If there is a tie, return all the values with the highest frequency in any order. 2 | The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (including the node itself). 3 |   4 | Example 1: 5 | 6 | Input: root = [5,2,-3] 7 | Output: [2,-3,4] 8 | 9 | Example 2: 10 | 11 | Input: root = [5,2,-5] 12 | Output: [2] 13 | 14 |   15 | Constraints: 16 | 17 | The number of nodes in the tree is in the range [1, 104]. 18 | -105 <= Node.val <= 105 19 | 20 | -------------------------------------------------------------------------------- /Qdata/539/539.txt: -------------------------------------------------------------------------------- 1 | Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string). 2 |   3 | Example 1: 4 | Input: text = "abcabcabc" 5 | Output: 3 6 | Explanation: The 3 substrings are "abcabc", "bcabca" and "cabcab". 7 | 8 | Example 2: 9 | Input: text = "leetcodeleetcode" 10 | Output: 2 11 | Explanation: The 2 substrings are "ee" and "leetcodeleetcode". 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= text.length <= 2000 17 | text has only lowercase English letters. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1196/1196.txt: -------------------------------------------------------------------------------- 1 | Given an integer num, return three consecutive integers (as a sorted array) that sum to num. If num cannot be expressed as the sum of three consecutive integers, return an empty array. 2 |   3 | Example 1: 4 | Input: num = 33 5 | Output: [10,11,12] 6 | Explanation: 33 can be expressed as 10 + 11 + 12 = 33. 7 | 10, 11, 12 are 3 consecutive integers, so we return [10, 11, 12]. 8 | 9 | Example 2: 10 | Input: num = 4 11 | Output: [] 12 | Explanation: There is no way to express 4 as the sum of 3 consecutive integers. 13 | 14 |   15 | Constraints: 16 | 17 | 0 <= num <= 1015 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1423/1423.txt: -------------------------------------------------------------------------------- 1 | Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false. 2 |   3 | Example 1: 4 | 5 | Input: nums = [1,0,0,0,1,0,0,1], k = 2 6 | Output: true 7 | Explanation: Each of the 1s are at least 2 places away from each other. 8 | 9 | Example 2: 10 | 11 | Input: nums = [1,0,0,1,0,1], k = 2 12 | Output: false 13 | Explanation: The second 1 and third 1 are only one apart from each other. 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= nums.length <= 105 19 | 0 <= k <= nums.length 20 | nums[i] is 0 or 1 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1499/1499.txt: -------------------------------------------------------------------------------- 1 | Given an integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement method is used. 2 | All the letters in the answer string should be lowercase characters, and there should not be any leading zeros in the answer except for the zero itself. 3 | Note: You are not allowed to use any built-in library method to directly solve this problem. 4 |   5 | Example 1: 6 | Input: num = 26 7 | Output: "1a" 8 | Example 2: 9 | Input: num = -1 10 | Output: "ffffffff" 11 | 12 |   13 | Constraints: 14 | 15 | -231 <= num <= 231 - 1 16 | 17 | -------------------------------------------------------------------------------- /Qdata/1580/1580.txt: -------------------------------------------------------------------------------- 1 | You are given the root of a binary search tree (BST) and an integer val. 2 | Find the node in the BST that the node's value equals val and return the subtree rooted with that node. If such a node does not exist, return null. 3 |   4 | Example 1: 5 | 6 | Input: root = [4,2,7,1,3], val = 2 7 | Output: [2,1,3] 8 | 9 | Example 2: 10 | 11 | Input: root = [4,2,7,1,3], val = 5 12 | Output: [] 13 | 14 |   15 | Constraints: 16 | 17 | The number of nodes in the tree is in the range [1, 5000]. 18 | 1 <= Node.val <= 107 19 | root is a binary search tree. 20 | 1 <= val <= 107 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1901/1901.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer n, you can apply one of the following operations: 2 | 3 | If n is even, replace n with n / 2. 4 | If n is odd, replace n with either n + 1 or n - 1. 5 | 6 | Return the minimum number of operations needed for n to become 1. 7 |   8 | Example 1: 9 | Input: n = 8 10 | Output: 3 11 | Explanation: 8 -> 4 -> 2 -> 1 12 | 13 | Example 2: 14 | Input: n = 7 15 | Output: 4 16 | Explanation: 7 -> 8 -> 4 -> 2 -> 1 17 | or 7 -> 6 -> 3 -> 2 -> 1 18 | 19 | Example 3: 20 | Input: n = 4 21 | Output: 2 22 | 23 |   24 | Constraints: 25 | 26 | 1 <= n <= 231 - 1 27 | 28 | -------------------------------------------------------------------------------- /Qdata/2152/2152.txt: -------------------------------------------------------------------------------- 1 | Given a string s, return the number of palindromic substrings in it. 2 | A string is a palindrome when it reads the same backward as forward. 3 | A substring is a contiguous sequence of characters within the string. 4 |   5 | Example 1: 6 | Input: s = "abc" 7 | Output: 3 8 | Explanation: Three palindromic strings: "a", "b", "c". 9 | 10 | Example 2: 11 | Input: s = "aaa" 12 | Output: 6 13 | Explanation: Six palindromic strings: "a", "a", "a", "aa", "aa", "aaa". 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= s.length <= 1000 19 | s consists of lowercase English letters. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/2196/2196.txt: -------------------------------------------------------------------------------- 1 | Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false. 2 |   3 | Example 1: 4 | 5 | Input: nums = [1,0,0,0,1,0,0,1], k = 2 6 | Output: true 7 | Explanation: Each of the 1s are at least 2 places away from each other. 8 | 9 | Example 2: 10 | 11 | Input: nums = [1,0,0,1,0,1], k = 2 12 | Output: false 13 | Explanation: The second 1 and third 1 are only one apart from each other. 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= nums.length <= 105 19 | 0 <= k <= nums.length 20 | nums[i] is 0 or 1 21 | 22 | -------------------------------------------------------------------------------- /Qdata/394/394.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it. 2 | You must implement a solution with a linear runtime complexity and use only constant extra space. 3 |   4 | Example 1: 5 | Input: nums = [2,2,3,2] 6 | Output: 3 7 | Example 2: 8 | Input: nums = [0,1,0,1,0,1,99] 9 | Output: 99 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= nums.length <= 3 * 104 15 | -231 <= nums[i] <= 231 - 1 16 | Each element in nums appears exactly three times except for one element which appears once. 17 | 18 | -------------------------------------------------------------------------------- /Qdata/737/737.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k. 2 | A subarray is a contiguous part of an array. 3 |   4 | Example 1: 5 | Input: nums = [4,5,0,-2,-3,1], k = 5 6 | Output: 7 7 | Explanation: There are 7 subarrays with a sum divisible by k = 5: 8 | [4, 5, 0, -2, -3, 1], [5], [5, 0], [5, 0, -2, -3], [0], [0, -2, -3], [-2, -3] 9 | 10 | Example 2: 11 | Input: nums = [5], k = 9 12 | Output: 0 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 3 * 104 18 | -104 <= nums[i] <= 104 19 | 2 <= k <= 104 20 | 21 | -------------------------------------------------------------------------------- /Qdata/995/995.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr. Since the answer may be large, return the answer modulo 109 + 7. 2 |   3 | Example 1: 4 | Input: arr = [3,1,2,4] 5 | Output: 17 6 | Explanation: 7 | Subarrays are [3], [1], [2], [4], [3,1], [1,2], [2,4], [3,1,2], [1,2,4], [3,1,2,4]. 8 | Minimums are 3, 1, 2, 4, 1, 1, 2, 1, 1, 1. 9 | Sum is 17. 10 | 11 | Example 2: 12 | Input: arr = [11,81,94,43,3] 13 | Output: 444 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= arr.length <= 3 * 104 19 | 1 <= arr[i] <= 3 * 104 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1121/1121.txt: -------------------------------------------------------------------------------- 1 | Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. 2 | In one step, you can delete exactly one character in either string. 3 |   4 | Example 1: 5 | Input: word1 = "sea", word2 = "eat" 6 | Output: 2 7 | Explanation: You need one step to make "sea" to "ea" and another step to make "eat" to "ea". 8 | 9 | Example 2: 10 | Input: word1 = "leetcode", word2 = "etco" 11 | Output: 4 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= word1.length, word2.length <= 500 17 | word1 and word2 consist of only lowercase English letters. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1223/1223.txt: -------------------------------------------------------------------------------- 1 | An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5. 2 | Given an integer n, return true if n is an ugly number. 3 |   4 | Example 1: 5 | Input: n = 6 6 | Output: true 7 | Explanation: 6 = 2 × 3 8 | 9 | Example 2: 10 | Input: n = 1 11 | Output: true 12 | Explanation: 1 has no prime factors, therefore all of its prime factors are limited to 2, 3, and 5. 13 | 14 | Example 3: 15 | Input: n = 14 16 | Output: false 17 | Explanation: 14 is not ugly since it includes the prime factor 7. 18 | 19 |   20 | Constraints: 21 | 22 | -231 <= n <= 231 - 1 23 | 24 | -------------------------------------------------------------------------------- /Qdata/133/133.txt: -------------------------------------------------------------------------------- 1 | Nearly everyone has used the Multiplication Table. The multiplication table of size m x n is an integer matrix mat where mat[i][j] == i * j (1-indexed). 2 | Given three integers m, n, and k, return the kth smallest element in the m x n multiplication table. 3 |   4 | Example 1: 5 | 6 | Input: m = 3, n = 3, k = 5 7 | Output: 3 8 | Explanation: The 5th smallest number is 3. 9 | 10 | Example 2: 11 | 12 | Input: m = 2, n = 3, k = 6 13 | Output: 6 14 | Explanation: The 6th smallest number is 6. 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= m, n <= 3 * 104 20 | 1 <= k <= m * n 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1472/1472.txt: -------------------------------------------------------------------------------- 1 | Given a string s, return the number of segments in the string. 2 | A segment is defined to be a contiguous sequence of non-space characters. 3 |   4 | Example 1: 5 | Input: s = "Hello, my name is John" 6 | Output: 5 7 | Explanation: The five segments are ["Hello,", "my", "name", "is", "John"] 8 | 9 | Example 2: 10 | Input: s = "Hello" 11 | Output: 1 12 | 13 |   14 | Constraints: 15 | 16 | 0 <= s.length <= 300 17 | s consists of lowercase and uppercase English letters, digits, or one of the following characters "!@#$%^&*()_+-=',.:". 18 | The only space character in s is ' '. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/336/336.txt: -------------------------------------------------------------------------------- 1 | Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path. 2 | Note: You can only move either down or right at any point in time. 3 |   4 | Example 1: 5 | 6 | Input: grid = [[1,3,1],[1,5,1],[4,2,1]] 7 | Output: 7 8 | Explanation: Because the path 1 → 3 → 1 → 1 → 1 minimizes the sum. 9 | 10 | Example 2: 11 | Input: grid = [[1,2,3],[4,5,6]] 12 | Output: 12 13 | 14 |   15 | Constraints: 16 | 17 | m == grid.length 18 | n == grid[i].length 19 | 1 <= m, n <= 200 20 | 0 <= grid[i][j] <= 200 21 | 22 | -------------------------------------------------------------------------------- /Qdata/391/391.txt: -------------------------------------------------------------------------------- 1 | Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. 2 | You must implement a solution with a linear runtime complexity and use only constant extra space. 3 |   4 | Example 1: 5 | Input: nums = [2,2,1] 6 | Output: 1 7 | Example 2: 8 | Input: nums = [4,1,2,1,2] 9 | Output: 4 10 | Example 3: 11 | Input: nums = [1] 12 | Output: 1 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 3 * 104 18 | -3 * 104 <= nums[i] <= 3 * 104 19 | Each element in the array appears twice except for one element which appears only once. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1174/1174.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return true if it is a power of three. Otherwise, return false. 2 | An integer n is a power of three, if there exists an integer x such that n == 3x. 3 |   4 | Example 1: 5 | Input: n = 27 6 | Output: true 7 | Explanation: 27 = 33 8 | 9 | Example 2: 10 | Input: n = 0 11 | Output: false 12 | Explanation: There is no x where 3x = 0. 13 | 14 | Example 3: 15 | Input: n = -1 16 | Output: false 17 | Explanation: There is no x where 3x = (-1). 18 | 19 |   20 | Constraints: 21 | 22 | -231 <= n <= 231 - 1 23 | 24 |   25 | Follow up: Could you solve it without loops/recursion? -------------------------------------------------------------------------------- /Qdata/1489/1489.txt: -------------------------------------------------------------------------------- 1 | Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. 2 |   3 | Example 1: 4 | 5 | Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] 6 | Output: 6 7 | Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. In this case, 6 units of rain water (blue section) are being trapped. 8 | 9 | Example 2: 10 | Input: height = [4,2,0,3,2,5] 11 | Output: 9 12 | 13 |   14 | Constraints: 15 | 16 | n == height.length 17 | 1 <= n <= 2 * 104 18 | 0 <= height[i] <= 105 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1653/1653.txt: -------------------------------------------------------------------------------- 1 | You have n  tiles, where each tile has one letter tiles[i] printed on it. 2 | Return the number of possible non-empty sequences of letters you can make using the letters printed on those tiles. 3 |   4 | Example 1: 5 | Input: tiles = "AAB" 6 | Output: 8 7 | Explanation: The possible sequences are "A", "B", "AA", "AB", "BA", "AAB", "ABA", "BAA". 8 | 9 | Example 2: 10 | Input: tiles = "AAABBC" 11 | Output: 188 12 | 13 | Example 3: 14 | Input: tiles = "V" 15 | Output: 1 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= tiles.length <= 7 21 | tiles consists of uppercase English letters. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/186/186.txt: -------------------------------------------------------------------------------- 1 | Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. 2 | Note: You must not use any built-in BigInteger library or convert the inputs to integer directly. 3 |   4 | Example 1: 5 | Input: num1 = "2", num2 = "3" 6 | Output: "6" 7 | Example 2: 8 | Input: num1 = "123", num2 = "456" 9 | Output: "56088" 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= num1.length, num2.length <= 200 15 | num1 and num2 consist of digits only. 16 | Both num1 and num2 do not contain any leading zero, except the number 0 itself. 17 | 18 | -------------------------------------------------------------------------------- /Qdata/2213/2213.txt: -------------------------------------------------------------------------------- 1 | Given the head of a singly linked list, return the middle node of the linked list. 2 | If there are two middle nodes, return the second middle node. 3 |   4 | Example 1: 5 | 6 | Input: head = [1,2,3,4,5] 7 | Output: [3,4,5] 8 | Explanation: The middle node of the list is node 3. 9 | 10 | Example 2: 11 | 12 | Input: head = [1,2,3,4,5,6] 13 | Output: [4,5,6] 14 | Explanation: Since the list has two middle nodes with values 3 and 4, we return the second one. 15 | 16 |   17 | Constraints: 18 | 19 | The number of nodes in the list is in the range [1, 100]. 20 | 1 <= Node.val <= 100 21 | 22 | -------------------------------------------------------------------------------- /Qdata/3/3.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. 2 |   3 | Example 1: 4 | Input: nums = [1,1,1,2,2,3], k = 2 5 | Output: [1,2] 6 | Example 2: 7 | Input: nums = [1], k = 1 8 | Output: [1] 9 | 10 |   11 | Constraints: 12 | 13 | 1 <= nums.length <= 105 14 | -104 <= nums[i] <= 104 15 | k is in the range [1, the number of unique elements in the array]. 16 | It is guaranteed that the answer is unique. 17 | 18 |   19 | Follow up: Your algorithm's time complexity must be better than O(n log n), where n is the array's size. 20 | -------------------------------------------------------------------------------- /Qdata/645/645.txt: -------------------------------------------------------------------------------- 1 | You have n coins and you want to build a staircase with these coins. The staircase consists of k rows where the ith row has exactly i coins. The last row of the staircase may be incomplete. 2 | Given the integer n, return the number of complete rows of the staircase you will build. 3 |   4 | Example 1: 5 | 6 | Input: n = 5 7 | Output: 2 8 | Explanation: Because the 3rd row is incomplete, we return 2. 9 | 10 | Example 2: 11 | 12 | Input: n = 8 13 | Output: 3 14 | Explanation: Because the 4th row is incomplete, we return 3. 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= n <= 231 - 1 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1744/1744.txt: -------------------------------------------------------------------------------- 1 | Given the roots of two binary trees p and q, write a function to check if they are the same or not. 2 | Two binary trees are considered the same if they are structurally identical, and the nodes have the same value. 3 |   4 | Example 1: 5 | 6 | Input: p = [1,2,3], q = [1,2,3] 7 | Output: true 8 | 9 | Example 2: 10 | 11 | Input: p = [1,2], q = [1,null,2] 12 | Output: false 13 | 14 | Example 3: 15 | 16 | Input: p = [1,2,1], q = [1,1,2] 17 | Output: false 18 | 19 |   20 | Constraints: 21 | 22 | The number of nodes in both trees is in the range [0, 100]. 23 | -104 <= Node.val <= 104 24 | 25 | -------------------------------------------------------------------------------- /Qdata/423/423.txt: -------------------------------------------------------------------------------- 1 | You are given two integer arrays nums1 and nums2 both of the same length. The advantage of nums1 with respect to nums2 is the number of indices i for which nums1[i] > nums2[i]. 2 | Return any permutation of nums1 that maximizes its advantage with respect to nums2. 3 |   4 | Example 1: 5 | Input: nums1 = [2,7,11,15], nums2 = [1,10,4,11] 6 | Output: [2,11,7,15] 7 | Example 2: 8 | Input: nums1 = [12,24,8,32], nums2 = [13,25,32,11] 9 | Output: [24,32,8,12] 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= nums1.length <= 105 15 | nums2.length == nums1.length 16 | 0 <= nums1[i], nums2[i] <= 109 17 | 18 | -------------------------------------------------------------------------------- /Qdata/573/573.txt: -------------------------------------------------------------------------------- 1 | You are given an array of points in the X-Y plane points where points[i] = [xi, yi]. 2 | Return the minimum area of a rectangle formed from these points, with sides parallel to the X and Y axes. If there is not any such rectangle, return 0. 3 |   4 | Example 1: 5 | 6 | Input: points = [[1,1],[1,3],[3,1],[3,3],[2,2]] 7 | Output: 4 8 | 9 | Example 2: 10 | 11 | Input: points = [[1,1],[1,3],[3,1],[3,3],[4,1],[4,3]] 12 | Output: 2 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= points.length <= 500 18 | points[i].length == 2 19 | 0 <= xi, yi <= 4 * 104 20 | All the given points are unique. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1443/1443.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return the length of the longest strictly increasing subsequence. 2 |   3 | Example 1: 4 | Input: nums = [10,9,2,5,3,7,101,18] 5 | Output: 4 6 | Explanation: The longest increasing subsequence is [2,3,7,101], therefore the length is 4. 7 | 8 | Example 2: 9 | Input: nums = [0,1,0,3,2,3] 10 | Output: 4 11 | 12 | Example 3: 13 | Input: nums = [7,7,7,7,7,7,7] 14 | Output: 1 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= nums.length <= 2500 20 | -104 <= nums[i] <= 104 21 | 22 |   23 | Follow up: Can you come up with an algorithm that runs in O(n log(n)) time complexity? 24 | -------------------------------------------------------------------------------- /Qdata/692/692.txt: -------------------------------------------------------------------------------- 1 | Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false otherwise. 2 |   3 | Example 1: 4 | Input: arr = [3,1,3,6] 5 | Output: false 6 | 7 | Example 2: 8 | Input: arr = [2,1,2,6] 9 | Output: false 10 | 11 | Example 3: 12 | Input: arr = [4,-2,2,-4] 13 | Output: true 14 | Explanation: We can take two groups, [-2,-4] and [2,4] to form [-2,-4,2,4] or [2,4,-2,-4]. 15 | 16 |   17 | Constraints: 18 | 19 | 2 <= arr.length <= 3 * 104 20 | arr.length is even. 21 | -105 <= arr[i] <= 105 22 | 23 | -------------------------------------------------------------------------------- /Qdata/81/81.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return the number of longest increasing subsequences. 2 | Notice that the sequence has to be strictly increasing. 3 |   4 | Example 1: 5 | Input: nums = [1,3,5,4,7] 6 | Output: 2 7 | Explanation: The two longest increasing subsequences are [1, 3, 4, 7] and [1, 3, 5, 7]. 8 | 9 | Example 2: 10 | Input: nums = [2,2,2,2,2] 11 | Output: 5 12 | Explanation: The length of the longest increasing subsequence is 1, and there are 5 increasing subsequences of length 1, so output 5. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 2000 18 | -106 <= nums[i] <= 106 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1483/1483.txt: -------------------------------------------------------------------------------- 1 | You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane. 2 |   3 |   4 | Example 1: 5 | 6 | Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]] 7 | Output: true 8 | 9 | Example 2: 10 | 11 | Input: coordinates = [[1,1],[2,2],[3,4],[4,5],[5,6],[7,7]] 12 | Output: false 13 | 14 |   15 | Constraints: 16 | 17 | 2 <= coordinates.length <= 1000 18 | coordinates[i].length == 2 19 | -10^4 <= coordinates[i][0], coordinates[i][1] <= 10^4 20 | coordinates contains no duplicate point. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1554/1554.txt: -------------------------------------------------------------------------------- 1 | You are given an integer n. 2 | Each number from 1 to n is grouped according to the sum of its digits. 3 | Return the number of groups that have the largest size. 4 |   5 | Example 1: 6 | Input: n = 13 7 | Output: 4 8 | Explanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13: 9 | [1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9]. 10 | There are 4 groups with largest size. 11 | 12 | Example 2: 13 | Input: n = 2 14 | Output: 2 15 | Explanation: There are 2 groups [1], [2] of size 1. 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= n <= 104 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1639/1639.txt: -------------------------------------------------------------------------------- 1 | Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn]. 2 | Return the array in the form [x1,y1,x2,y2,...,xn,yn]. 3 |   4 | Example 1: 5 | Input: nums = [2,5,1,3,4,7], n = 3 6 | Output: [2,3,5,4,1,7] 7 | Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7]. 8 | 9 | Example 2: 10 | Input: nums = [1,2,3,4,4,3,2,1], n = 4 11 | Output: [1,4,2,3,3,2,4,1] 12 | 13 | Example 3: 14 | Input: nums = [1,1,2,2], n = 2 15 | Output: [1,2,1,2] 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= n <= 500 21 | nums.length == 2n 22 | 1 <= nums[i] <= 10^3 23 | -------------------------------------------------------------------------------- /Qdata/1773/1773.txt: -------------------------------------------------------------------------------- 1 | You are given the head of a singly linked-list. The list can be represented as: 2 | L0 → L1 → … → Ln - 1 → Ln 3 | 4 | Reorder the list to be on the following form: 5 | L0 → Ln → L1 → Ln - 1 → L2 → Ln - 2 → … 6 | 7 | You may not modify the values in the list's nodes. Only nodes themselves may be changed. 8 |   9 | Example 1: 10 | 11 | Input: head = [1,2,3,4] 12 | Output: [1,4,2,3] 13 | 14 | Example 2: 15 | 16 | Input: head = [1,2,3,4,5] 17 | Output: [1,5,2,4,3] 18 | 19 |   20 | Constraints: 21 | 22 | The number of nodes in the list is in the range [1, 5 * 104]. 23 | 1 <= Node.val <= 1000 24 | 25 | -------------------------------------------------------------------------------- /Qdata/2018/2018.txt: -------------------------------------------------------------------------------- 1 | The beauty of a string is the difference in frequencies between the most frequent and least frequent characters. 2 | 3 | For example, the beauty of "abaacc" is 3 - 1 = 2. 4 | 5 | Given a string s, return the sum of beauty of all of its substrings. 6 |   7 | Example 1: 8 | Input: s = "aabcb" 9 | Output: 5 10 | Explanation: The substrings with non-zero beauty are ["aab","aabc","aabcb","abcb","bcb"], each with beauty equal to 1. 11 | Example 2: 12 | Input: s = "aabcbaa" 13 | Output: 17 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= s.length <= 500 19 | s consists of only lowercase English letters. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/627/627.txt: -------------------------------------------------------------------------------- 1 | A pangram is a sentence where every letter of the English alphabet appears at least once. 2 | Given a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise. 3 |   4 | Example 1: 5 | Input: sentence = "thequickbrownfoxjumpsoverthelazydog" 6 | Output: true 7 | Explanation: sentence contains at least one of every letter of the English alphabet. 8 | 9 | Example 2: 10 | Input: sentence = "leetcode" 11 | Output: false 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= sentence.length <= 1000 17 | sentence consists of lowercase English letters. 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1307/1307.txt: -------------------------------------------------------------------------------- 1 | Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string. 2 | If there are fewer than k characters left, reverse all of them. If there are less than 2k but greater than or equal to k characters, then reverse the first k characters and leave the other as original. 3 |   4 | Example 1: 5 | Input: s = "abcdefg", k = 2 6 | Output: "bacdfeg" 7 | Example 2: 8 | Input: s = "abcd", k = 2 9 | Output: "bacd" 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= s.length <= 104 15 | s consists of only lowercase English letters. 16 | 1 <= k <= 104 17 | 18 | -------------------------------------------------------------------------------- /Qdata/2056/2056.txt: -------------------------------------------------------------------------------- 1 | You are given an integer array nums consisting of n elements, and an integer k. 2 | Find a contiguous subarray whose length is equal to k that has the maximum average value and return this value. Any answer with a calculation error less than 10-5 will be accepted. 3 |   4 | Example 1: 5 | Input: nums = [1,12,-5,-6,50,3], k = 4 6 | Output: 12.75000 7 | Explanation: Maximum average is (12 - 5 - 6 + 50) / 4 = 51 / 4 = 12.75 8 | 9 | Example 2: 10 | Input: nums = [5], k = 1 11 | Output: 5.00000 12 | 13 |   14 | Constraints: 15 | 16 | n == nums.length 17 | 1 <= k <= n <= 105 18 | -104 <= nums[i] <= 104 19 | 20 | -------------------------------------------------------------------------------- /Qdata/305/305.txt: -------------------------------------------------------------------------------- 1 | Given a string s, find the longest palindromic subsequence's length in s. 2 | A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements. 3 |   4 | Example 1: 5 | Input: s = "bbbab" 6 | Output: 4 7 | Explanation: One possible longest palindromic subsequence is "bbbb". 8 | 9 | Example 2: 10 | Input: s = "cbbd" 11 | Output: 2 12 | Explanation: One possible longest palindromic subsequence is "bb". 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= s.length <= 1000 18 | s consists only of lowercase English letters. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/759/759.txt: -------------------------------------------------------------------------------- 1 | Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. 2 | Each letter in magazine can only be used once in ransomNote. 3 |   4 | Example 1: 5 | Input: ransomNote = "a", magazine = "b" 6 | Output: false 7 | Example 2: 8 | Input: ransomNote = "aa", magazine = "ab" 9 | Output: false 10 | Example 3: 11 | Input: ransomNote = "aa", magazine = "aab" 12 | Output: true 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= ransomNote.length, magazine.length <= 105 18 | ransomNote and magazine consist of lowercase English letters. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1082/1082.txt: -------------------------------------------------------------------------------- 1 | Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.​​​​​ 2 | A string is said to be palindrome if it the same string when reversed. 3 |   4 | Example 1: 5 | Input: s = "abcbdd" 6 | Output: true 7 | Explanation: "abcbdd" = "a" + "bcb" + "dd", and all three substrings are palindromes. 8 | 9 | Example 2: 10 | Input: s = "bcbddxy" 11 | Output: false 12 | Explanation: s cannot be split into 3 palindromes. 13 | 14 |   15 | Constraints: 16 | 17 | 3 <= s.length <= 2000 18 | s​​​​​​ consists only of lowercase English letters. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1831/1831.txt: -------------------------------------------------------------------------------- 1 | Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n]. 2 | You may return the answer in any order. 3 |   4 | Example 1: 5 | Input: n = 4, k = 2 6 | Output: [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]] 7 | Explanation: There are 4 choose 2 = 6 total combinations. 8 | Note that combinations are unordered, i.e., [1,2] and [2,1] are considered to be the same combination. 9 | 10 | Example 2: 11 | Input: n = 1, k = 1 12 | Output: [[1]] 13 | Explanation: There is 1 choose 1 = 1 total combination. 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= n <= 20 19 | 1 <= k <= n 20 | 21 | -------------------------------------------------------------------------------- /Qdata/252/252.txt: -------------------------------------------------------------------------------- 1 | Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array. The result should also be sorted in ascending order. 2 | An integer a is closer to x than an integer b if: 3 | 4 | |a - x| < |b - x|, or 5 | |a - x| == |b - x| and a < b 6 | 7 |   8 | Example 1: 9 | Input: arr = [1,2,3,4,5], k = 4, x = 3 10 | Output: [1,2,3,4] 11 | Example 2: 12 | Input: arr = [1,2,3,4,5], k = 4, x = -1 13 | Output: [1,2,3,4] 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= k <= arr.length 19 | 1 <= arr.length <= 104 20 | arr is sorted in ascending order. 21 | -104 <= arr[i], x <= 104 22 | 23 | -------------------------------------------------------------------------------- /Qdata/511/511.txt: -------------------------------------------------------------------------------- 1 | Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for: 2 | 3 | i - k <= r <= i + k, 4 | j - k <= c <= j + k, and 5 | (r, c) is a valid position in the matrix. 6 | 7 |   8 | Example 1: 9 | Input: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 1 10 | Output: [[12,21,16],[27,45,33],[24,39,28]] 11 | 12 | Example 2: 13 | Input: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 2 14 | Output: [[45,45,45],[45,45,45],[45,45,45]] 15 | 16 |   17 | Constraints: 18 | 19 | m == mat.length 20 | n == mat[i].length 21 | 1 <= m, n, k <= 100 22 | 1 <= mat[i][j] <= 100 23 | 24 | -------------------------------------------------------------------------------- /Qdata/515/515.txt: -------------------------------------------------------------------------------- 1 | Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). 2 | Return the running sum of nums. 3 |   4 | Example 1: 5 | Input: nums = [1,2,3,4] 6 | Output: [1,3,6,10] 7 | Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4]. 8 | Example 2: 9 | Input: nums = [1,1,1,1,1] 10 | Output: [1,2,3,4,5] 11 | Explanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1]. 12 | Example 3: 13 | Input: nums = [3,1,2,10,1] 14 | Output: [3,4,6,16,17] 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= nums.length <= 1000 20 | -10^6 <= nums[i] <= 10^6 21 | -------------------------------------------------------------------------------- /Qdata/1002/1002.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0. 2 |   3 | Example 1: 4 | Input: nums = [21,4,7] 5 | Output: 32 6 | Explanation: 7 | 21 has 4 divisors: 1, 3, 7, 21 8 | 4 has 3 divisors: 1, 2, 4 9 | 7 has 2 divisors: 1, 7 10 | The answer is the sum of divisors of 21 only. 11 | 12 | Example 2: 13 | Input: nums = [21,21] 14 | Output: 64 15 | 16 | Example 3: 17 | Input: nums = [1,2,3,4,5] 18 | Output: 0 19 | 20 |   21 | Constraints: 22 | 23 | 1 <= nums.length <= 104 24 | 1 <= nums[i] <= 105 25 | 26 | -------------------------------------------------------------------------------- /Qdata/1206/1206.txt: -------------------------------------------------------------------------------- 1 | For two strings s and t, we say "t divides s" if and only if s = t + ... + t (i.e., t is concatenated with itself one or more times). 2 | Given two strings str1 and str2, return the largest string x such that x divides both str1 and str2. 3 |   4 | Example 1: 5 | Input: str1 = "ABCABC", str2 = "ABC" 6 | Output: "ABC" 7 | 8 | Example 2: 9 | Input: str1 = "ABABAB", str2 = "ABAB" 10 | Output: "AB" 11 | 12 | Example 3: 13 | Input: str1 = "LEET", str2 = "CODE" 14 | Output: "" 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= str1.length, str2.length <= 1000 20 | str1 and str2 consist of English uppercase letters. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1292/1292.txt: -------------------------------------------------------------------------------- 1 | Given a text file file.txt that contains a list of phone numbers (one per line), write a one-liner bash script to print all valid phone numbers. 2 | You may assume that a valid phone number must appear in one of the following two formats: (xxx) xxx-xxxx or xxx-xxx-xxxx. (x means a digit) 3 | You may also assume each line in the text file must not contain leading or trailing white spaces. 4 | Example: 5 | Assume that file.txt has the following content: 6 | 987-123-4567 7 | 123 456 7890 8 | (123) 456-7890 9 | 10 | Your script should output the following valid phone numbers: 11 | 987-123-4567 12 | (123) 456-7890 13 | 14 | -------------------------------------------------------------------------------- /Qdata/1542/1542.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears once or twice, return an array of all the integers that appears twice. 2 | You must write an algorithm that runs in O(n) time and uses only constant extra space. 3 |   4 | Example 1: 5 | Input: nums = [4,3,2,7,8,2,3,1] 6 | Output: [2,3] 7 | Example 2: 8 | Input: nums = [1,1,2] 9 | Output: [1] 10 | Example 3: 11 | Input: nums = [1] 12 | Output: [] 13 | 14 |   15 | Constraints: 16 | 17 | n == nums.length 18 | 1 <= n <= 105 19 | 1 <= nums[i] <= n 20 | Each element in nums appears once or twice. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1849/1849.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3].... 2 | You may assume the input array always has a valid answer. 3 |   4 | Example 1: 5 | Input: nums = [1,5,1,1,6,4] 6 | Output: [1,6,1,5,1,4] 7 | Explanation: [1,4,1,5,1,6] is also accepted. 8 | 9 | Example 2: 10 | Input: nums = [1,3,2,2,3,1] 11 | Output: [2,3,1,3,1,2] 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums.length <= 5 * 104 17 | 0 <= nums[i] <= 5000 18 | It is guaranteed that there will be an answer for the given input nums. 19 | 20 |   21 | Follow Up: Can you do it in O(n) time and/or in-place with O(1) extra space? -------------------------------------------------------------------------------- /Qdata/2072/2072.txt: -------------------------------------------------------------------------------- 1 | Given a set of distinct positive integers nums, return the largest subset answer such that every pair (answer[i], answer[j]) of elements in this subset satisfies: 2 | 3 | answer[i] % answer[j] == 0, or 4 | answer[j] % answer[i] == 0 5 | 6 | If there are multiple solutions, return any of them. 7 |   8 | Example 1: 9 | Input: nums = [1,2,3] 10 | Output: [1,2] 11 | Explanation: [1,3] is also accepted. 12 | 13 | Example 2: 14 | Input: nums = [1,2,4,8] 15 | Output: [1,2,4,8] 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= nums.length <= 1000 21 | 1 <= nums[i] <= 2 * 109 22 | All the integers in nums are unique. 23 | 24 | -------------------------------------------------------------------------------- /Qdata/805/805.txt: -------------------------------------------------------------------------------- 1 | A self-dividing number is a number that is divisible by every digit it contains. 2 | 3 | For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. 4 | 5 | A self-dividing number is not allowed to contain the digit zero. 6 | Given two integers left and right, return a list of all the self-dividing numbers in the range [left, right]. 7 |   8 | Example 1: 9 | Input: left = 1, right = 22 10 | Output: [1,2,3,4,5,6,7,8,9,11,12,15,22] 11 | Example 2: 12 | Input: left = 47, right = 85 13 | Output: [48,55,66,77] 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= left <= right <= 104 19 | 20 | -------------------------------------------------------------------------------- /Qdata/865/865.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary search tree, and an integer k, return the kth smallest value (1-indexed) of all the values of the nodes in the tree. 2 |   3 | Example 1: 4 | 5 | Input: root = [3,1,4,null,2], k = 1 6 | Output: 1 7 | 8 | Example 2: 9 | 10 | Input: root = [5,3,6,2,4,null,null,1], k = 3 11 | Output: 3 12 | 13 |   14 | Constraints: 15 | 16 | The number of nodes in the tree is n. 17 | 1 <= k <= n <= 104 18 | 0 <= Node.val <= 104 19 | 20 |   21 | Follow up: If the BST is modified often (i.e., we can do insert and delete operations) and you need to find the kth smallest frequently, how would you optimize? 22 | -------------------------------------------------------------------------------- /Qdata/1440/1440.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even. 2 | The digit sum of a positive integer is the sum of all its digits. 3 |   4 | Example 1: 5 | Input: num = 4 6 | Output: 2 7 | Explanation: 8 | The only integers less than or equal to 4 whose digit sums are even are 2 and 4. 9 | 10 | Example 2: 11 | Input: num = 30 12 | Output: 14 13 | Explanation: 14 | The 14 integers less than or equal to 30 whose digit sums are even are 15 | 2, 4, 6, 8, 11, 13, 15, 17, 19, 20, 22, 24, 26, and 28. 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= num <= 1000 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1752/1752.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, find a subarray that has the largest product, and return the product. 2 | The test cases are generated so that the answer will fit in a 32-bit integer. 3 |   4 | Example 1: 5 | Input: nums = [2,3,-2,4] 6 | Output: 6 7 | Explanation: [2,3] has the largest product 6. 8 | 9 | Example 2: 10 | Input: nums = [-2,0,-1] 11 | Output: 0 12 | Explanation: The result cannot be 2, because [-2,-1] is not a subarray. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 2 * 104 18 | -10 <= nums[i] <= 10 19 | The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1858/1858.txt: -------------------------------------------------------------------------------- 1 | We define the usage of capitals in a word to be right when one of the following cases holds: 2 | 3 | All letters in this word are capitals, like "USA". 4 | All letters in this word are not capitals, like "leetcode". 5 | Only the first letter in this word is capital, like "Google". 6 | 7 | Given a string word, return true if the usage of capitals in it is right. 8 |   9 | Example 1: 10 | Input: word = "USA" 11 | Output: true 12 | Example 2: 13 | Input: word = "FlaG" 14 | Output: false 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= word.length <= 100 20 | word consists of lowercase and uppercase English letters. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1960/1960.txt: -------------------------------------------------------------------------------- 1 | In an infinite binary tree where every node has two children, the nodes are labelled in row order. 2 | In the odd numbered rows (ie., the first, third, fifth,...), the labelling is left to right, while in the even numbered rows (second, fourth, sixth,...), the labelling is right to left. 3 | 4 | Given the label of a node in this tree, return the labels in the path from the root of the tree to the node with that label. 5 |   6 | Example 1: 7 | Input: label = 14 8 | Output: [1,3,4,14] 9 | 10 | Example 2: 11 | Input: label = 26 12 | Output: [1,2,6,10,26] 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= label <= 10^6 18 | 19 | -------------------------------------------------------------------------------- /Qdata/2130/2130.txt: -------------------------------------------------------------------------------- 1 | Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: 2 | 3 | 0 <= a, b, c, d < n 4 | a, b, c, and d are distinct. 5 | nums[a] + nums[b] + nums[c] + nums[d] == target 6 | 7 | You may return the answer in any order. 8 |   9 | Example 1: 10 | Input: nums = [1,0,-1,0,-2,2], target = 0 11 | Output: [[-2,-1,1,2],[-2,0,0,2],[-1,0,0,1]] 12 | 13 | Example 2: 14 | Input: nums = [2,2,2,2,2], target = 8 15 | Output: [[2,2,2,2]] 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= nums.length <= 200 21 | -109 <= nums[i] <= 109 22 | -109 <= target <= 109 23 | 24 | -------------------------------------------------------------------------------- /Qdata/710/710.txt: -------------------------------------------------------------------------------- 1 | Given two integers n and k, return an array of all the integers of length n where the difference between every two consecutive digits is k. You may return the answer in any order. 2 | Note that the integers should not have leading zeros. Integers as 02 and 043 are not allowed. 3 |   4 | Example 1: 5 | Input: n = 3, k = 7 6 | Output: [181,292,707,818,929] 7 | Explanation: Note that 070 is not a valid number, because it has leading zeroes. 8 | 9 | Example 2: 10 | Input: n = 2, k = 1 11 | Output: [10,12,21,23,32,34,43,45,54,56,65,67,76,78,87,89,98] 12 | 13 |   14 | Constraints: 15 | 16 | 2 <= n <= 9 17 | 0 <= k <= 9 18 | 19 | -------------------------------------------------------------------------------- /Qdata/857/857.txt: -------------------------------------------------------------------------------- 1 | Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k. 2 |   3 | Example 1: 4 | Input: s = "aaabb", k = 3 5 | Output: 3 6 | Explanation: The longest substring is "aaa", as 'a' is repeated 3 times. 7 | 8 | Example 2: 9 | Input: s = "ababbc", k = 2 10 | Output: 5 11 | Explanation: The longest substring is "ababb", as 'a' is repeated 2 times and 'b' is repeated 3 times. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= s.length <= 104 17 | s consists of only lowercase English letters. 18 | 1 <= k <= 105 19 | 20 | -------------------------------------------------------------------------------- /Qdata/2004/2004.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. 2 | In one move, you can increment n - 1 elements of the array by 1. 3 |   4 | Example 1: 5 | Input: nums = [1,2,3] 6 | Output: 3 7 | Explanation: Only three moves are needed (remember each move increments two elements): 8 | [1,2,3] => [2,3,3] => [3,4,3] => [4,4,4] 9 | 10 | Example 2: 11 | Input: nums = [1,1,1] 12 | Output: 0 13 | 14 |   15 | Constraints: 16 | 17 | n == nums.length 18 | 1 <= nums.length <= 105 19 | -109 <= nums[i] <= 109 20 | The answer is guaranteed to fit in a 32-bit integer. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/445/445.txt: -------------------------------------------------------------------------------- 1 | Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make ( a OR b == c ). (bitwise OR operation). 2 | Flip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation. 3 |   4 | Example 1: 5 | 6 | Input: a = 2, b = 6, c = 5 7 | Output: 3 8 | Explanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c) 9 | Example 2: 10 | Input: a = 4, b = 2, c = 7 11 | Output: 1 12 | 13 | Example 3: 14 | Input: a = 1, b = 2, c = 3 15 | Output: 0 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= a <= 10^9 21 | 1 <= b <= 10^9 22 | 1 <= c <= 10^9 23 | -------------------------------------------------------------------------------- /Qdata/640/640.txt: -------------------------------------------------------------------------------- 1 | Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) 2 | (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.) 3 | Since the answer may be large, return the answer modulo 10^9 + 7. 4 |   5 | Example 1: 6 | Input: n = 5 7 | Output: 12 8 | 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. 9 | 10 | Example 2: 11 | Input: n = 100 12 | Output: 682289015 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= n <= 100 18 | 19 | -------------------------------------------------------------------------------- /Qdata/864/864.txt: -------------------------------------------------------------------------------- 1 | Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. 2 |   3 | Example 1: 4 | 5 | Input: matrix = [["1","0","1","0","0"],["1","0","1","1","1"],["1","1","1","1","1"],["1","0","0","1","0"]] 6 | Output: 6 7 | Explanation: The maximal rectangle is shown in the above picture. 8 | 9 | Example 2: 10 | Input: matrix = [["0"]] 11 | Output: 0 12 | 13 | Example 3: 14 | Input: matrix = [["1"]] 15 | Output: 1 16 | 17 |   18 | Constraints: 19 | 20 | rows == matrix.length 21 | cols == matrix[i].length 22 | 1 <= row, cols <= 200 23 | matrix[i][j] is '0' or '1'. 24 | 25 | -------------------------------------------------------------------------------- /Qdata/964/964.txt: -------------------------------------------------------------------------------- 1 | Given two strings s and t, return true if t is an anagram of s, and false otherwise. 2 | An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. 3 |   4 | Example 1: 5 | Input: s = "anagram", t = "nagaram" 6 | Output: true 7 | Example 2: 8 | Input: s = "rat", t = "car" 9 | Output: false 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= s.length, t.length <= 5 * 104 15 | s and t consist of lowercase English letters. 16 | 17 |   18 | Follow up: What if the inputs contain Unicode characters? How would you adapt your solution to such a case? 19 | -------------------------------------------------------------------------------- /Qdata/1016/1016.txt: -------------------------------------------------------------------------------- 1 | An array is monotonic if it is either monotone increasing or monotone decreasing. 2 | An array nums is monotone increasing if for all i <= j, nums[i] <= nums[j]. An array nums is monotone decreasing if for all i <= j, nums[i] >= nums[j]. 3 | Given an integer array nums, return true if the given array is monotonic, or false otherwise. 4 |   5 | Example 1: 6 | Input: nums = [1,2,2,3] 7 | Output: true 8 | 9 | Example 2: 10 | Input: nums = [6,5,4,4] 11 | Output: true 12 | 13 | Example 3: 14 | Input: nums = [1,3,2] 15 | Output: false 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= nums.length <= 105 21 | -105 <= nums[i] <= 105 22 | 23 | -------------------------------------------------------------------------------- /Qdata/1195/1195.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer num, return true if num is a perfect square or false otherwise. 2 | A perfect square is an integer that is the square of an integer. In other words, it is the product of some integer with itself. 3 | You must not use any built-in library function, such as sqrt. 4 |   5 | Example 1: 6 | Input: num = 16 7 | Output: true 8 | Explanation: We return true because 4 * 4 = 16 and 4 is an integer. 9 | 10 | Example 2: 11 | Input: num = 14 12 | Output: false 13 | Explanation: We return false because 3.742 * 3.742 = 14 and 3.742 is not an integer. 14 | 15 |   16 | Constraints: 17 | 18 | 1 <= num <= 231 - 1 19 | 20 | -------------------------------------------------------------------------------- /Qdata/123/123.txt: -------------------------------------------------------------------------------- 1 | Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number. 2 | For example: 3 | A -> 1 4 | B -> 2 5 | C -> 3 6 | ... 7 | Z -> 26 8 | AA -> 27 9 | AB -> 28 10 | ... 11 | 12 |   13 | Example 1: 14 | Input: columnTitle = "A" 15 | Output: 1 16 | 17 | Example 2: 18 | Input: columnTitle = "AB" 19 | Output: 28 20 | 21 | Example 3: 22 | Input: columnTitle = "ZY" 23 | Output: 701 24 | 25 |   26 | Constraints: 27 | 28 | 1 <= columnTitle.length <= 7 29 | columnTitle consists only of uppercase English letters. 30 | columnTitle is in the range ["A", "FXSHRXW"]. 31 | 32 | -------------------------------------------------------------------------------- /Qdata/1411/1411.txt: -------------------------------------------------------------------------------- 1 | Given an integer n represented as a string, return the smallest good base of n. 2 | We call k >= 2 a good base of n, if all digits of n base k are 1's. 3 |   4 | Example 1: 5 | Input: n = "13" 6 | Output: "3" 7 | Explanation: 13 base 3 is 111. 8 | 9 | Example 2: 10 | Input: n = "4681" 11 | Output: "8" 12 | Explanation: 4681 base 8 is 11111. 13 | 14 | Example 3: 15 | Input: n = "1000000000000000000" 16 | Output: "999999999999999999" 17 | Explanation: 1000000000000000000 base 999999999999999999 is 11. 18 | 19 |   20 | Constraints: 21 | 22 | n is an integer in the range [3, 1018]. 23 | n does not contain any leading zeros. 24 | 25 | -------------------------------------------------------------------------------- /Qdata/344/344.txt: -------------------------------------------------------------------------------- 1 | Given an array of points on the X-Y plane points where points[i] = [xi, yi], return the area of the largest triangle that can be formed by any three different points. Answers within 10-5 of the actual answer will be accepted. 2 |   3 | Example 1: 4 | 5 | Input: points = [[0,0],[0,1],[1,0],[0,2],[2,0]] 6 | Output: 2.00000 7 | Explanation: The five points are shown in the above figure. The red triangle is the largest. 8 | 9 | Example 2: 10 | Input: points = [[1,0],[0,0],[0,1]] 11 | Output: 0.50000 12 | 13 |   14 | Constraints: 15 | 16 | 3 <= points.length <= 50 17 | -50 <= xi, yi <= 50 18 | All the given points are unique. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1570/1570.txt: -------------------------------------------------------------------------------- 1 | Given a balanced parentheses string s, return the score of the string. 2 | The score of a balanced parentheses string is based on the following rule: 3 | 4 | "()" has score 1. 5 | AB has score A + B, where A and B are balanced parentheses strings. 6 | (A) has score 2 * A, where A is a balanced parentheses string. 7 | 8 |   9 | Example 1: 10 | Input: s = "()" 11 | Output: 1 12 | 13 | Example 2: 14 | Input: s = "(())" 15 | Output: 2 16 | 17 | Example 3: 18 | Input: s = "()()" 19 | Output: 2 20 | 21 |   22 | Constraints: 23 | 24 | 2 <= s.length <= 50 25 | s consists of only '(' and ')'. 26 | s is a balanced parentheses string. 27 | 28 | -------------------------------------------------------------------------------- /Qdata/436/436.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. You can return the answer in any order. 2 |   3 | Example 1: 4 | Input: n = 2 5 | Output: ["1/2"] 6 | Explanation: "1/2" is the only unique fraction with a denominator less-than-or-equal-to 2. 7 | 8 | Example 2: 9 | Input: n = 3 10 | Output: ["1/2","1/3","2/3"] 11 | 12 | Example 3: 13 | Input: n = 4 14 | Output: ["1/2","1/3","1/4","2/3","3/4"] 15 | Explanation: "2/4" is not a simplified fraction because it can be simplified to "1/2". 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= n <= 100 21 | 22 | -------------------------------------------------------------------------------- /Qdata/704/704.txt: -------------------------------------------------------------------------------- 1 | Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. 2 | Return the decimal value of the number in the linked list. 3 | The most significant bit is at the head of the linked list. 4 |   5 | Example 1: 6 | 7 | Input: head = [1,0,1] 8 | Output: 5 9 | Explanation: (101) in base 2 = (5) in base 10 10 | 11 | Example 2: 12 | Input: head = [0] 13 | Output: 0 14 | 15 |   16 | Constraints: 17 | 18 | The Linked List is not empty. 19 | Number of nodes will not exceed 30. 20 | Each node's value is either 0 or 1. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/941/941.txt: -------------------------------------------------------------------------------- 1 | You are given an integer array nums with the following properties: 2 | 3 | nums.length == 2 * n. 4 | nums contains n + 1 unique elements. 5 | Exactly one element of nums is repeated n times. 6 | 7 | Return the element that is repeated n times. 8 |   9 | Example 1: 10 | Input: nums = [1,2,3,3] 11 | Output: 3 12 | Example 2: 13 | Input: nums = [2,1,2,5,3,2] 14 | Output: 2 15 | Example 3: 16 | Input: nums = [5,1,5,2,5,3,5,4] 17 | Output: 5 18 | 19 |   20 | Constraints: 21 | 22 | 2 <= n <= 5000 23 | nums.length == 2 * n 24 | 0 <= nums[i] <= 104 25 | nums contains n + 1 unique elements and one of them is repeated exactly n times. 26 | 27 | -------------------------------------------------------------------------------- /Qdata/1222/1222.txt: -------------------------------------------------------------------------------- 1 | Given an integer num, return the number of digits in num that divide num. 2 | An integer val divides nums if nums % val == 0. 3 |   4 | Example 1: 5 | Input: num = 7 6 | Output: 1 7 | Explanation: 7 divides itself, hence the answer is 1. 8 | 9 | Example 2: 10 | Input: num = 121 11 | Output: 2 12 | Explanation: 121 is divisible by 1, but not 2. Since 1 occurs twice as a digit, we return 2. 13 | 14 | Example 3: 15 | Input: num = 1248 16 | Output: 4 17 | Explanation: 1248 is divisible by all of its digits, hence the answer is 4. 18 | 19 |   20 | Constraints: 21 | 22 | 1 <= num <= 109 23 | num does not contain 0 as one of its digits. 24 | 25 | -------------------------------------------------------------------------------- /Qdata/1510/1510.txt: -------------------------------------------------------------------------------- 1 | You are given an integer n and an integer start. 2 | Define an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length. 3 | Return the bitwise XOR of all elements of nums. 4 |   5 | Example 1: 6 | Input: n = 5, start = 0 7 | Output: 8 8 | Explanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8. 9 | Where "^" corresponds to bitwise XOR operator. 10 | 11 | Example 2: 12 | Input: n = 4, start = 3 13 | Output: 8 14 | Explanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8. 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= n <= 1000 20 | 0 <= start <= 1000 21 | n == nums.length 22 | 23 | -------------------------------------------------------------------------------- /Qdata/1658/1658.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers arr, return true if and only if it is a valid mountain array. 2 | Recall that arr is a mountain array if and only if: 3 | 4 | arr.length >= 3 5 | There exists some i with 0 < i < arr.length - 1 such that: 6 | 7 | arr[0] < arr[1] < ... < arr[i - 1] < arr[i] 8 | arr[i] > arr[i + 1] > ... > arr[arr.length - 1] 9 | 10 | 11 | 12 | 13 |   14 | Example 1: 15 | Input: arr = [2,1] 16 | Output: false 17 | Example 2: 18 | Input: arr = [3,5,5] 19 | Output: false 20 | Example 3: 21 | Input: arr = [0,3,2,1] 22 | Output: true 23 | 24 |   25 | Constraints: 26 | 27 | 1 <= arr.length <= 104 28 | 0 <= arr[i] <= 104 29 | 30 | -------------------------------------------------------------------------------- /Qdata/1783/1783.txt: -------------------------------------------------------------------------------- 1 | Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. 2 | You must not use any built-in exponent function or operator. 3 | 4 | For example, do not use pow(x, 0.5) in c++ or x ** 0.5 in python. 5 | 6 |   7 | Example 1: 8 | Input: x = 4 9 | Output: 2 10 | Explanation: The square root of 4 is 2, so we return 2. 11 | 12 | Example 2: 13 | Input: x = 8 14 | Output: 2 15 | Explanation: The square root of 8 is 2.82842..., and since we round it down to the nearest integer, 2 is returned. 16 | 17 |   18 | Constraints: 19 | 20 | 0 <= x <= 231 - 1 21 | 22 | -------------------------------------------------------------------------------- /Qdata/2203/2203.txt: -------------------------------------------------------------------------------- 1 | Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well. 2 | You must not use any built-in exponent function or operator. 3 | 4 | For example, do not use pow(x, 0.5) in c++ or x ** 0.5 in python. 5 | 6 |   7 | Example 1: 8 | Input: x = 4 9 | Output: 2 10 | Explanation: The square root of 4 is 2, so we return 2. 11 | 12 | Example 2: 13 | Input: x = 8 14 | Output: 2 15 | Explanation: The square root of 8 is 2.82842..., and since we round it down to the nearest integer, 2 is returned. 16 | 17 |   18 | Constraints: 19 | 20 | 0 <= x <= 231 - 1 21 | 22 | -------------------------------------------------------------------------------- /Qdata/228/228.txt: -------------------------------------------------------------------------------- 1 | Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome. If there is a tie, return the smaller one. 2 | The closest is defined as the absolute difference minimized between two integers. 3 |   4 | Example 1: 5 | Input: n = "123" 6 | Output: "121" 7 | 8 | Example 2: 9 | Input: n = "1" 10 | Output: "0" 11 | Explanation: 0 and 2 are the closest palindromes but we return the smallest which is 0. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= n.length <= 18 17 | n consists of only digits. 18 | n does not have leading zeros. 19 | n is representing an integer in the range [1, 1018 - 1]. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/655/655.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it. 2 | Return the number of nice sub-arrays. 3 |   4 | Example 1: 5 | Input: nums = [1,1,2,1,1], k = 3 6 | Output: 2 7 | Explanation: The only sub-arrays with 3 odd numbers are [1,1,2,1] and [1,2,1,1]. 8 | 9 | Example 2: 10 | Input: nums = [2,4,6], k = 1 11 | Output: 0 12 | Explanation: There is no odd numbers in the array. 13 | 14 | Example 3: 15 | Input: nums = [2,2,2,1,2,2,1,2,2,2], k = 2 16 | Output: 16 17 | 18 |   19 | Constraints: 20 | 21 | 1 <= nums.length <= 50000 22 | 1 <= nums[i] <= 10^5 23 | 1 <= k <= nums.length 24 | -------------------------------------------------------------------------------- /Qdata/998/998.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value. 2 | If target is not found in the array, return [-1, -1]. 3 | You must write an algorithm with O(log n) runtime complexity. 4 |   5 | Example 1: 6 | Input: nums = [5,7,7,8,8,10], target = 8 7 | Output: [3,4] 8 | Example 2: 9 | Input: nums = [5,7,7,8,8,10], target = 6 10 | Output: [-1,-1] 11 | Example 3: 12 | Input: nums = [], target = 0 13 | Output: [-1,-1] 14 | 15 |   16 | Constraints: 17 | 18 | 0 <= nums.length <= 105 19 | -109 <= nums[i] <= 109 20 | nums is a non-decreasing array. 21 | -109 <= target <= 109 22 | 23 | -------------------------------------------------------------------------------- /Qdata/132/132.txt: -------------------------------------------------------------------------------- 1 | A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: 2 | 3 | s[i] == 'I' if perm[i] < perm[i + 1], and 4 | s[i] == 'D' if perm[i] > perm[i + 1]. 5 | 6 | Given a string s, reconstruct the permutation perm and return it. If there are multiple valid permutations perm, return any of them. 7 |   8 | Example 1: 9 | Input: s = "IDID" 10 | Output: [0,4,1,3,2] 11 | Example 2: 12 | Input: s = "III" 13 | Output: [0,1,2,3] 14 | Example 3: 15 | Input: s = "DDI" 16 | Output: [3,2,0,1] 17 | 18 |   19 | Constraints: 20 | 21 | 1 <= s.length <= 105 22 | s[i] is either 'I' or 'D'. 23 | 24 | -------------------------------------------------------------------------------- /Qdata/1386/1386.txt: -------------------------------------------------------------------------------- 1 | Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist. 2 | An alphanumeric string is a string consisting of lowercase English letters and digits. 3 |   4 | Example 1: 5 | Input: s = "dfa12321afd" 6 | Output: 2 7 | Explanation: The digits that appear in s are [1, 2, 3]. The second largest digit is 2. 8 | 9 | Example 2: 10 | Input: s = "abc1111" 11 | Output: -1 12 | Explanation: The digits that appear in s are [1]. There is no second largest digit. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= s.length <= 500 18 | s consists of only lowercase English letters and/or digits. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1507/1507.txt: -------------------------------------------------------------------------------- 1 | Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino can be rotated to be equal to another domino. 2 | Return the number of pairs (i, j) for which 0 <= i < j < dominoes.length, and dominoes[i] is equivalent to dominoes[j]. 3 |   4 | Example 1: 5 | Input: dominoes = [[1,2],[2,1],[3,4],[5,6]] 6 | Output: 1 7 | 8 | Example 2: 9 | Input: dominoes = [[1,2],[1,2],[1,1],[1,2],[2,2]] 10 | Output: 3 11 | 12 |   13 | Constraints: 14 | 15 | 1 <= dominoes.length <= 4 * 104 16 | dominoes[i].length == 2 17 | 1 <= dominoes[i][j] <= 9 18 | 19 | -------------------------------------------------------------------------------- /Qdata/1590/1590.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return a string array answer (1-indexed) where: 2 | 3 | answer[i] == "FizzBuzz" if i is divisible by 3 and 5. 4 | answer[i] == "Fizz" if i is divisible by 3. 5 | answer[i] == "Buzz" if i is divisible by 5. 6 | answer[i] == i (as a string) if none of the above conditions are true. 7 | 8 |   9 | Example 1: 10 | Input: n = 3 11 | Output: ["1","2","Fizz"] 12 | Example 2: 13 | Input: n = 5 14 | Output: ["1","2","Fizz","4","Buzz"] 15 | Example 3: 16 | Input: n = 15 17 | Output: ["1","2","Fizz","4","Buzz","Fizz","7","8","Fizz","Buzz","11","Fizz","13","14","FizzBuzz"] 18 | 19 |   20 | Constraints: 21 | 22 | 1 <= n <= 104 23 | 24 | -------------------------------------------------------------------------------- /Qdata/1748/1748.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the average value of the nodes on each level in the form of an array. Answers within 10-5 of the actual answer will be accepted. 2 |   3 | Example 1: 4 | 5 | Input: root = [3,9,20,null,null,15,7] 6 | Output: [3.00000,14.50000,11.00000] 7 | Explanation: The average value of nodes on level 0 is 3, on level 1 is 14.5, and on level 2 is 11. 8 | Hence return [3, 14.5, 11]. 9 | 10 | Example 2: 11 | 12 | Input: root = [3,9,20,15,7] 13 | Output: [3.00000,14.50000,11.00000] 14 | 15 |   16 | Constraints: 17 | 18 | The number of nodes in the tree is in the range [1, 104]. 19 | -231 <= Node.val <= 231 - 1 20 | 21 | -------------------------------------------------------------------------------- /Qdata/313/313.txt: -------------------------------------------------------------------------------- 1 | Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. 2 | A mapping of digits to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. 3 | 4 |   5 | Example 1: 6 | Input: digits = "23" 7 | Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"] 8 | 9 | Example 2: 10 | Input: digits = "" 11 | Output: [] 12 | 13 | Example 3: 14 | Input: digits = "2" 15 | Output: ["a","b","c"] 16 | 17 |   18 | Constraints: 19 | 20 | 0 <= digits.length <= 4 21 | digits[i] is a digit in the range ['2', '9']. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/326/326.txt: -------------------------------------------------------------------------------- 1 | Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empty string. 2 | Since the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer must not contain unnecessary leading zeros. 3 |   4 | Example 1: 5 | Input: digits = [8,1,9] 6 | Output: "981" 7 | 8 | Example 2: 9 | Input: digits = [8,6,7,1,0] 10 | Output: "8760" 11 | 12 | Example 3: 13 | Input: digits = [1] 14 | Output: "" 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= digits.length <= 104 20 | 0 <= digits[i] <= 9 21 | 22 | -------------------------------------------------------------------------------- /Qdata/358/358.txt: -------------------------------------------------------------------------------- 1 | Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 2 |   3 | Example 1: 4 | Input: haystack = "sadbutsad", needle = "sad" 5 | Output: 0 6 | Explanation: "sad" occurs at index 0 and 6. 7 | The first occurrence is at index 0, so we return 0. 8 | 9 | Example 2: 10 | Input: haystack = "leetcode", needle = "leeto" 11 | Output: -1 12 | Explanation: "leeto" did not occur in "leetcode", so we return -1. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= haystack.length, needle.length <= 104 18 | haystack and needle consist of only lowercase English characters. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/532/532.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3. 2 | Note that the average of n elements is the sum of the n elements divided by n and rounded down to the nearest integer. 3 |   4 | Example 1: 5 | Input: nums = [1,3,6,10,12,15] 6 | Output: 9 7 | Explanation: 6 and 12 are even numbers that are divisible by 3. (6 + 12) / 2 = 9. 8 | 9 | Example 2: 10 | Input: nums = [1,2,4,7,10] 11 | Output: 0 12 | Explanation: There is no single number that satisfies the requirement, so return 0. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 1000 18 | 1 <= nums[i] <= 1000 19 | 20 | -------------------------------------------------------------------------------- /Qdata/613/613.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead. 2 |   3 | Example 1: 4 | Input: temperatures = [73,74,75,71,69,72,76,73] 5 | Output: [1,1,4,2,1,1,0,0] 6 | Example 2: 7 | Input: temperatures = [30,40,50,60] 8 | Output: [1,1,1,0] 9 | Example 3: 10 | Input: temperatures = [30,60,90] 11 | Output: [1,1,0] 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= temperatures.length <= 105 17 | 30 <= temperatures[i] <= 100 18 | 19 | -------------------------------------------------------------------------------- /Qdata/715/715.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k. 2 |   3 | Example 1: 4 | Input: nums = [10,5,2,6], k = 100 5 | Output: 8 6 | Explanation: The 8 subarrays that have product less than 100 are: 7 | [10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6] 8 | Note that [10, 5, 2] is not included as the product of 100 is not strictly less than k. 9 | 10 | Example 2: 11 | Input: nums = [1,2,3], k = 0 12 | Output: 0 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 3 * 104 18 | 1 <= nums[i] <= 1000 19 | 0 <= k <= 106 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1001/1001.txt: -------------------------------------------------------------------------------- 1 | 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, 2 | F(0) = 0, F(1) = 1 3 | F(n) = F(n - 1) + F(n - 2), for n > 1. 4 | 5 | Given n, calculate F(n). 6 |   7 | Example 1: 8 | Input: n = 2 9 | Output: 1 10 | Explanation: F(2) = F(1) + F(0) = 1 + 0 = 1. 11 | 12 | Example 2: 13 | Input: n = 3 14 | Output: 2 15 | Explanation: F(3) = F(2) + F(1) = 1 + 1 = 2. 16 | 17 | Example 3: 18 | Input: n = 4 19 | Output: 3 20 | Explanation: F(4) = F(3) + F(2) = 2 + 1 = 3. 21 | 22 |   23 | Constraints: 24 | 25 | 0 <= n <= 30 26 | 27 | -------------------------------------------------------------------------------- /Qdata/1005/1005.txt: -------------------------------------------------------------------------------- 1 | Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. 2 | An input string is valid if: 3 | 4 | Open brackets must be closed by the same type of brackets. 5 | Open brackets must be closed in the correct order. 6 | Every close bracket has a corresponding open bracket of the same type. 7 | 8 |   9 | Example 1: 10 | Input: s = "()" 11 | Output: true 12 | 13 | Example 2: 14 | Input: s = "()[]{}" 15 | Output: true 16 | 17 | Example 3: 18 | Input: s = "(]" 19 | Output: false 20 | 21 |   22 | Constraints: 23 | 24 | 1 <= s.length <= 104 25 | s consists of parentheses only '()[]{}'. 26 | 27 | -------------------------------------------------------------------------------- /Qdata/1214/1214.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the length of the diameter of the tree. 2 | The diameter of a binary tree is the length of the longest path between any two nodes in a tree. This path may or may not pass through the root. 3 | The length of a path between two nodes is represented by the number of edges between them. 4 |   5 | Example 1: 6 | 7 | Input: root = [1,2,3,4,5] 8 | Output: 3 9 | Explanation: 3 is the length of the path [4,2,1,3] or [5,2,1,3]. 10 | 11 | Example 2: 12 | Input: root = [1,2] 13 | Output: 1 14 | 15 |   16 | Constraints: 17 | 18 | The number of nodes in the tree is in the range [1, 104]. 19 | -100 <= Node.val <= 100 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1221/1221.txt: -------------------------------------------------------------------------------- 1 | Given a positive integer n, return the number of the integers in the range [0, n] whose binary representations do not contain consecutive ones. 2 |   3 | Example 1: 4 | Input: n = 5 5 | Output: 5 6 | Explanation: 7 | Here are the non-negative integers <= 5 with their corresponding binary representations: 8 | 0 : 0 9 | 1 : 1 10 | 2 : 10 11 | 3 : 11 12 | 4 : 100 13 | 5 : 101 14 | Among them, only integer 3 disobeys the rule (two consecutive ones) and the other 5 satisfy the rule. 15 | 16 | Example 2: 17 | Input: n = 1 18 | Output: 2 19 | 20 | Example 3: 21 | Input: n = 2 22 | Output: 3 23 | 24 |   25 | Constraints: 26 | 27 | 1 <= n <= 109 28 | 29 | -------------------------------------------------------------------------------- /Qdata/2037/2037.txt: -------------------------------------------------------------------------------- 1 | Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. 2 | The overall run time complexity should be O(log (m+n)). 3 |   4 | Example 1: 5 | Input: nums1 = [1,3], nums2 = [2] 6 | Output: 2.00000 7 | Explanation: merged array = [1,2,3] and median is 2. 8 | 9 | Example 2: 10 | Input: nums1 = [1,2], nums2 = [3,4] 11 | Output: 2.50000 12 | Explanation: merged array = [1,2,3,4] and median is (2 + 3) / 2 = 2.5. 13 | 14 |   15 | Constraints: 16 | 17 | nums1.length == m 18 | nums2.length == n 19 | 0 <= m <= 1000 20 | 0 <= n <= 1000 21 | 1 <= m + n <= 2000 22 | -106 <= nums1[i], nums2[i] <= 106 23 | 24 | -------------------------------------------------------------------------------- /Qdata/2074/2074.txt: -------------------------------------------------------------------------------- 1 | Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. 2 | You must write an algorithm with O(log n) runtime complexity. 3 |   4 | Example 1: 5 | Input: nums = [1,3,5,6], target = 5 6 | Output: 2 7 | 8 | Example 2: 9 | Input: nums = [1,3,5,6], target = 2 10 | Output: 1 11 | 12 | Example 3: 13 | Input: nums = [1,3,5,6], target = 7 14 | Output: 4 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= nums.length <= 104 20 | -104 <= nums[i] <= 104 21 | nums contains distinct values sorted in ascending order. 22 | -104 <= target <= 104 23 | 24 | -------------------------------------------------------------------------------- /Qdata/254/254.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0. 2 | A grandparent of a node is the parent of its parent if it exists. 3 |   4 | Example 1: 5 | 6 | Input: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5] 7 | Output: 18 8 | Explanation: The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents. 9 | 10 | Example 2: 11 | 12 | Input: root = [1] 13 | Output: 0 14 | 15 |   16 | Constraints: 17 | 18 | The number of nodes in the tree is in the range [1, 104]. 19 | 1 <= Node.val <= 100 20 | 21 | -------------------------------------------------------------------------------- /Qdata/315/315.txt: -------------------------------------------------------------------------------- 1 | You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1. 2 | You are allowed to select any subarray of the given array and reverse it. You can perform this operation only once. 3 | Find maximum possible value of the final array. 4 |   5 | Example 1: 6 | Input: nums = [2,3,1,5,4] 7 | Output: 10 8 | Explanation: By reversing the subarray [3,1,5] the array becomes [2,5,1,3,4] whose value is 10. 9 | 10 | Example 2: 11 | Input: nums = [2,4,9,24,2,1,10] 12 | Output: 68 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 3 * 104 18 | -105 <= nums[i] <= 105 19 | 20 | -------------------------------------------------------------------------------- /Qdata/4/4.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array contains less than two elements, return 0. 2 | You must write an algorithm that runs in linear time and uses linear extra space. 3 |   4 | Example 1: 5 | Input: nums = [3,6,9,1] 6 | Output: 3 7 | Explanation: The sorted form of the array is [1,3,6,9], either (3,6) or (6,9) has the maximum difference 3. 8 | 9 | Example 2: 10 | Input: nums = [10] 11 | Output: 0 12 | Explanation: The array contains less than 2 elements, therefore return 0. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= nums.length <= 105 18 | 0 <= nums[i] <= 109 19 | 20 | -------------------------------------------------------------------------------- /Qdata/685/685.txt: -------------------------------------------------------------------------------- 1 | Given an unsorted integer array nums, return the smallest missing positive integer. 2 | You must implement an algorithm that runs in O(n) time and uses constant extra space. 3 |   4 | Example 1: 5 | Input: nums = [1,2,0] 6 | Output: 3 7 | Explanation: The numbers in the range [1,2] are all in the array. 8 | 9 | Example 2: 10 | Input: nums = [3,4,-1,1] 11 | Output: 2 12 | Explanation: 1 is in the array but 2 is missing. 13 | 14 | Example 3: 15 | Input: nums = [7,8,9,11,12] 16 | Output: 1 17 | Explanation: The smallest positive integer 1 is missing. 18 | 19 |   20 | Constraints: 21 | 22 | 1 <= nums.length <= 105 23 | -231 <= nums[i] <= 231 - 1 24 | 25 | -------------------------------------------------------------------------------- /Qdata/875/875.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary tree, return all duplicate subtrees. 2 | For each kind of duplicate subtrees, you only need to return the root node of any one of them. 3 | Two trees are duplicate if they have the same structure with the same node values. 4 |   5 | Example 1: 6 | 7 | Input: root = [1,2,3,4,null,2,4,null,null,4] 8 | Output: [[2,4],[4]] 9 | 10 | Example 2: 11 | 12 | Input: root = [2,1,1] 13 | Output: [[1]] 14 | 15 | Example 3: 16 | 17 | Input: root = [2,2,2,3,null,3,null] 18 | Output: [[2,3],[3]] 19 | 20 |   21 | Constraints: 22 | 23 | The number of the nodes in the tree will be in the range [1, 5000] 24 | -200 <= Node.val <= 200 25 | 26 | -------------------------------------------------------------------------------- /Qdata/1291/1291.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return the maximum possible sum of elements of the array such that it is divisible by three. 2 |   3 | Example 1: 4 | Input: nums = [3,6,5,1,8] 5 | Output: 18 6 | Explanation: Pick numbers 3, 6, 1 and 8 their sum is 18 (maximum sum divisible by 3). 7 | Example 2: 8 | Input: nums = [4] 9 | Output: 0 10 | Explanation: Since 4 is not divisible by 3, do not pick any number. 11 | 12 | Example 3: 13 | Input: nums = [1,2,3,4,4] 14 | Output: 12 15 | Explanation: Pick numbers 1, 3, 4 and 4 their sum is 12 (maximum sum divisible by 3). 16 | 17 |   18 | Constraints: 19 | 20 | 1 <= nums.length <= 4 * 104 21 | 1 <= nums[i] <= 104 22 | 23 | -------------------------------------------------------------------------------- /Qdata/1357/1357.txt: -------------------------------------------------------------------------------- 1 | Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element. 2 | We define an array is non-decreasing if nums[i] <= nums[i + 1] holds for every i (0-based) such that (0 <= i <= n - 2). 3 |   4 | Example 1: 5 | Input: nums = [4,2,3] 6 | Output: true 7 | Explanation: You could modify the first 4 to 1 to get a non-decreasing array. 8 | 9 | Example 2: 10 | Input: nums = [4,2,1] 11 | Output: false 12 | Explanation: You cannot get a non-decreasing array by modifying at most one element. 13 | 14 |   15 | Constraints: 16 | 17 | n == nums.length 18 | 1 <= n <= 104 19 | -105 <= nums[i] <= 105 20 | 21 | -------------------------------------------------------------------------------- /Qdata/648/648.txt: -------------------------------------------------------------------------------- 1 | You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise). 2 | You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation. 3 |   4 | Example 1: 5 | 6 | Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] 7 | Output: [[7,4,1],[8,5,2],[9,6,3]] 8 | 9 | Example 2: 10 | 11 | Input: matrix = [[5,1,9,11],[2,4,8,10],[13,3,6,7],[15,14,12,16]] 12 | Output: [[15,13,2,5],[14,3,4,1],[12,6,8,9],[16,7,10,11]] 13 | 14 |   15 | Constraints: 16 | 17 | n == matrix.length == matrix[i].length 18 | 1 <= n <= 20 19 | -1000 <= matrix[i][j] <= 1000 20 | 21 | -------------------------------------------------------------------------------- /Qdata/806/806.txt: -------------------------------------------------------------------------------- 1 | Given an array of strings strs, group the anagrams together. You can return the answer in any order. 2 | An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. 3 |   4 | Example 1: 5 | Input: strs = ["eat","tea","tan","ate","nat","bat"] 6 | Output: [["bat"],["nat","tan"],["ate","eat","tea"]] 7 | Example 2: 8 | Input: strs = [""] 9 | Output: [[""]] 10 | Example 3: 11 | Input: strs = ["a"] 12 | Output: [["a"]] 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= strs.length <= 104 18 | 0 <= strs[i].length <= 100 19 | strs[i] consists of lowercase English letters. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1120/1120.txt: -------------------------------------------------------------------------------- 1 | Given an array of integers arr. 2 | We want to select three indices i, j and k where (0 <= i < j <= k < arr.length). 3 | Let's define a and b as follows: 4 | 5 | a = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1] 6 | b = arr[j] ^ arr[j + 1] ^ ... ^ arr[k] 7 | 8 | Note that ^ denotes the bitwise-xor operation. 9 | Return the number of triplets (i, j and k) Where a == b. 10 |   11 | Example 1: 12 | Input: arr = [2,3,1,6,7] 13 | Output: 4 14 | Explanation: The triplets are (0,1,2), (0,2,2), (2,3,4) and (2,4,4) 15 | 16 | Example 2: 17 | Input: arr = [1,1,1,1,1] 18 | Output: 10 19 | 20 |   21 | Constraints: 22 | 23 | 1 <= arr.length <= 300 24 | 1 <= arr[i] <= 108 25 | 26 | -------------------------------------------------------------------------------- /Qdata/1394/1394.txt: -------------------------------------------------------------------------------- 1 | Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. 2 | Letters are case sensitive, for example, "Aa" is not considered a palindrome here. 3 |   4 | Example 1: 5 | Input: s = "abccccdd" 6 | Output: 7 7 | Explanation: One longest palindrome that can be built is "dccaccd", whose length is 7. 8 | 9 | Example 2: 10 | Input: s = "a" 11 | Output: 1 12 | Explanation: The longest palindrome that can be built is "a", whose length is 1. 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= s.length <= 2000 18 | s consists of lowercase and/or uppercase English letters only. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/354/354.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. 2 | In one move, you can increment or decrement an element of the array by 1. 3 | Test cases are designed so that the answer will fit in a 32-bit integer. 4 |   5 | Example 1: 6 | Input: nums = [1,2,3] 7 | Output: 2 8 | Explanation: 9 | Only two moves are needed (remember each move increments or decrements one element): 10 | [1,2,3] => [2,2,3] => [2,2,2] 11 | 12 | Example 2: 13 | Input: nums = [1,10,2,9] 14 | Output: 16 15 | 16 |   17 | Constraints: 18 | 19 | n == nums.length 20 | 1 <= nums.length <= 105 21 | -109 <= nums[i] <= 109 22 | 23 | -------------------------------------------------------------------------------- /Qdata/466/466.txt: -------------------------------------------------------------------------------- 1 | Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0. 2 | Each element of the answer is the root node of one possible tree. You may return the final list of trees in any order. 3 | A full binary tree is a binary tree where each node has exactly 0 or 2 children. 4 |   5 | Example 1: 6 | 7 | Input: n = 7 8 | 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]] 9 | 10 | Example 2: 11 | Input: n = 3 12 | Output: [[0,0,0]] 13 | 14 |   15 | Constraints: 16 | 17 | 1 <= n <= 20 18 | 19 | -------------------------------------------------------------------------------- /Qdata/619/619.txt: -------------------------------------------------------------------------------- 1 | You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels. 2 | Letters are case sensitive, so "a" is considered a different type of stone from "A". 3 |   4 | Example 1: 5 | Input: jewels = "aA", stones = "aAAbbbb" 6 | Output: 3 7 | Example 2: 8 | Input: jewels = "z", stones = "ZZ" 9 | Output: 0 10 | 11 |   12 | Constraints: 13 | 14 | 1 <= jewels.length, stones.length <= 50 15 | jewels and stones consist of only English letters. 16 | All the characters of jewels are unique. 17 | 18 | -------------------------------------------------------------------------------- /Qdata/1055/1055.txt: -------------------------------------------------------------------------------- 1 | Given a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid. 2 | Return a list of unique strings that are valid with the minimum number of removals. You may return the answer in any order. 3 |   4 | Example 1: 5 | Input: s = "()())()" 6 | Output: ["(())()","()()()"] 7 | 8 | Example 2: 9 | Input: s = "(a)())()" 10 | Output: ["(a())()","(a)()()"] 11 | 12 | Example 3: 13 | Input: s = ")(" 14 | Output: [""] 15 | 16 |   17 | Constraints: 18 | 19 | 1 <= s.length <= 25 20 | s consists of lowercase English letters and parentheses '(' and ')'. 21 | There will be at most 20 parentheses in s. 22 | 23 | -------------------------------------------------------------------------------- /Qdata/1099/1099.txt: -------------------------------------------------------------------------------- 1 | Given a binary string s, return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 109 + 7. 2 |   3 | Example 1: 4 | Input: s = "0110111" 5 | Output: 9 6 | Explanation: There are 9 substring in total with only 1's characters. 7 | "1" -> 5 times. 8 | "11" -> 3 times. 9 | "111" -> 1 time. 10 | Example 2: 11 | Input: s = "101" 12 | Output: 2 13 | Explanation: Substring "1" is shown 2 times in s. 14 | 15 | Example 3: 16 | Input: s = "111111" 17 | Output: 21 18 | Explanation: Each substring contains only 1's characters. 19 | 20 |   21 | Constraints: 22 | 23 | 1 <= s.length <= 105 24 | s[i] is either '0' or '1'. 25 | 26 | -------------------------------------------------------------------------------- /Qdata/1352/1352.txt: -------------------------------------------------------------------------------- 1 | Given a non-negative integer num, return true if num can be expressed as the sum of any non-negative integer and its reverse, or false otherwise. 2 |   3 | Example 1: 4 | Input: num = 443 5 | Output: true 6 | Explanation: 172 + 271 = 443 so we return true. 7 | 8 | Example 2: 9 | Input: num = 63 10 | Output: false 11 | Explanation: 63 cannot be expressed as the sum of a non-negative integer and its reverse so we return false. 12 | 13 | Example 3: 14 | Input: num = 181 15 | Output: true 16 | Explanation: 140 + 041 = 181 so we return true. Note that when a number is reversed, there may be leading zeros. 17 | 18 |   19 | Constraints: 20 | 21 | 0 <= num <= 105 22 | 23 | -------------------------------------------------------------------------------- /Qdata/2088/2088.txt: -------------------------------------------------------------------------------- 1 | Given a date, return the corresponding day of the week for that date. 2 | The input is given as three integers representing the day, month and year respectively. 3 | Return the answer as one of the following values {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}. 4 |   5 | Example 1: 6 | Input: day = 31, month = 8, year = 2019 7 | Output: "Saturday" 8 | 9 | Example 2: 10 | Input: day = 18, month = 7, year = 1999 11 | Output: "Sunday" 12 | 13 | Example 3: 14 | Input: day = 15, month = 8, year = 1993 15 | Output: "Sunday" 16 | 17 |   18 | Constraints: 19 | 20 | The given dates are valid dates between the years 1971 and 2100. 21 | 22 | -------------------------------------------------------------------------------- /Qdata/2124/2124.txt: -------------------------------------------------------------------------------- 1 | Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input. 2 |   3 | Example 1: 4 | Input: intervals = [[1,3],[2,6],[8,10],[15,18]] 5 | Output: [[1,6],[8,10],[15,18]] 6 | Explanation: Since intervals [1,3] and [2,6] overlap, merge them into [1,6]. 7 | 8 | Example 2: 9 | Input: intervals = [[1,4],[4,5]] 10 | Output: [[1,5]] 11 | Explanation: Intervals [1,4] and [4,5] are considered overlapping. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= intervals.length <= 104 17 | intervals[i].length == 2 18 | 0 <= starti <= endi <= 104 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1187/1187.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target. 2 | Return the sum of the three integers. 3 | You may assume that each input would have exactly one solution. 4 |   5 | Example 1: 6 | Input: nums = [-1,2,1,-4], target = 1 7 | Output: 2 8 | Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). 9 | 10 | Example 2: 11 | Input: nums = [0,0,0], target = 1 12 | Output: 0 13 | Explanation: The sum that is closest to the target is 0. (0 + 0 + 0 = 0). 14 | 15 |   16 | Constraints: 17 | 18 | 3 <= nums.length <= 500 19 | -1000 <= nums[i] <= 1000 20 | -104 <= target <= 104 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1318/1318.txt: -------------------------------------------------------------------------------- 1 | Given a string s, reverse the string according to the following rules: 2 | 3 | All the characters that are not English letters remain in the same position. 4 | All the English letters (lowercase or uppercase) should be reversed. 5 | 6 | Return s after reversing it. 7 |   8 | Example 1: 9 | Input: s = "ab-cd" 10 | Output: "dc-ba" 11 | Example 2: 12 | Input: s = "a-bC-dEf-ghIj" 13 | Output: "j-Ih-gfE-dCba" 14 | Example 3: 15 | Input: s = "Test1ng-Leet=code-Q!" 16 | Output: "Qedo1ct-eeLg=ntse-T!" 17 | 18 |   19 | Constraints: 20 | 21 | 1 <= s.length <= 100 22 | s consists of characters with ASCII values in the range [33, 122]. 23 | s does not contain '\"' or '\\'. 24 | 25 | -------------------------------------------------------------------------------- /Qdata/1466/1466.txt: -------------------------------------------------------------------------------- 1 | Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square. 2 |   3 | Example 1: 4 | 5 | Input: mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4 6 | Output: 2 7 | Explanation: The maximum side length of square with sum less than 4 is 2 as shown. 8 | 9 | Example 2: 10 | Input: mat = [[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]], threshold = 1 11 | Output: 0 12 | 13 |   14 | Constraints: 15 | 16 | m == mat.length 17 | n == mat[i].length 18 | 1 <= m, n <= 300 19 | 0 <= mat[i][j] <= 104 20 | 0 <= threshold <= 105 21 | 22 | -------------------------------------------------------------------------------- /Qdata/1484/1484.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i]. 2 |   3 | Example 1: 4 | Input: nums = [5,2,6,1] 5 | Output: [2,1,1,0] 6 | Explanation: 7 | To the right of 5 there are 2 smaller elements (2 and 1). 8 | To the right of 2 there is only 1 smaller element (1). 9 | To the right of 6 there is 1 smaller element (1). 10 | To the right of 1 there is 0 smaller element. 11 | 12 | Example 2: 13 | Input: nums = [-1] 14 | Output: [0] 15 | 16 | Example 3: 17 | Input: nums = [-1,-1] 18 | Output: [0,0] 19 | 20 |   21 | Constraints: 22 | 23 | 1 <= nums.length <= 105 24 | -104 <= nums[i] <= 104 25 | 26 | -------------------------------------------------------------------------------- /Qdata/237/237.txt: -------------------------------------------------------------------------------- 1 | You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array. 2 | Return the sum of all the unique elements of nums. 3 |   4 | Example 1: 5 | Input: nums = [1,2,3,2] 6 | Output: 4 7 | Explanation: The unique elements are [1,3], and the sum is 4. 8 | 9 | Example 2: 10 | Input: nums = [1,1,1,1,1] 11 | Output: 0 12 | Explanation: There are no unique elements, and the sum is 0. 13 | 14 | Example 3: 15 | Input: nums = [1,2,3,4,5] 16 | Output: 15 17 | Explanation: The unique elements are [1,2,3,4,5], and the sum is 15. 18 | 19 |   20 | Constraints: 21 | 22 | 1 <= nums.length <= 100 23 | 1 <= nums[i] <= 100 24 | 25 | -------------------------------------------------------------------------------- /Qdata/390/390.txt: -------------------------------------------------------------------------------- 1 | Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in that subarray is in the range [left, right]. 2 | The test cases are generated so that the answer will fit in a 32-bit integer. 3 |   4 | Example 1: 5 | Input: nums = [2,1,4,3], left = 2, right = 3 6 | Output: 3 7 | Explanation: There are three subarrays that meet the requirements: [2], [2, 1], [3]. 8 | 9 | Example 2: 10 | Input: nums = [2,9,2,5,6], left = 2, right = 8 11 | Output: 7 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums.length <= 105 17 | 0 <= nums[i] <= 109 18 | 0 <= left <= right <= 109 19 | 20 | -------------------------------------------------------------------------------- /Qdata/446/446.txt: -------------------------------------------------------------------------------- 1 | Given a string s, find the length of the longest substring without repeating characters. 2 |   3 | Example 1: 4 | Input: s = "abcabcbb" 5 | Output: 3 6 | Explanation: The answer is "abc", with the length of 3. 7 | 8 | Example 2: 9 | Input: s = "bbbbb" 10 | Output: 1 11 | Explanation: The answer is "b", with the length of 1. 12 | 13 | Example 3: 14 | Input: s = "pwwkew" 15 | Output: 3 16 | Explanation: The answer is "wke", with the length of 3. 17 | Notice that the answer must be a substring, "pwke" is a subsequence and not a substring. 18 | 19 |   20 | Constraints: 21 | 22 | 0 <= s.length <= 5 * 104 23 | s consists of English letters, digits, symbols and spaces. 24 | 25 | -------------------------------------------------------------------------------- /Qdata/871/871.txt: -------------------------------------------------------------------------------- 1 | Given an n-ary tree, return the level order traversal of its nodes' values. 2 | Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples). 3 |   4 | Example 1: 5 | 6 | Input: root = [1,null,3,2,4,null,5,6] 7 | Output: [[1],[3,2,4],[5,6]] 8 | 9 | Example 2: 10 | 11 | Input: root = [1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13,null,null,14] 12 | Output: [[1],[2,3,4,5],[6,7,8,9,10],[11,12,13],[14]] 13 | 14 |   15 | Constraints: 16 | 17 | The height of the n-ary tree is less than or equal to 1000 18 | The total number of nodes is between [0, 104] 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1556/1556.txt: -------------------------------------------------------------------------------- 1 | Given two arrays of unique digits nums1 and nums2, return the smallest number that contains at least one digit from each array. 2 |   3 | Example 1: 4 | Input: nums1 = [4,1,3], nums2 = [5,7] 5 | Output: 15 6 | Explanation: The number 15 contains the digit 1 from nums1 and the digit 5 from nums2. It can be proven that 15 is the smallest number we can have. 7 | 8 | Example 2: 9 | Input: nums1 = [3,5,2,6], nums2 = [3,1,7] 10 | Output: 3 11 | Explanation: The number 3 contains the digit 3 which exists in both arrays. 12 | 13 |   14 | Constraints: 15 | 16 | 1 <= nums1.length, nums2.length <= 9 17 | 1 <= nums1[i], nums2[i] <= 9 18 | All digits in each array are unique. 19 | 20 | -------------------------------------------------------------------------------- /Qdata/1716/1716.txt: -------------------------------------------------------------------------------- 1 | Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them. 2 | A binary search tree is balanced if the depth of the two subtrees of every node never differs by more than 1. 3 |   4 | Example 1: 5 | 6 | Input: root = [1,null,2,null,3,null,4,null,null] 7 | Output: [2,1,3,null,null,null,4] 8 | Explanation: This is not the only correct answer, [3,1,4,null,2] is also correct. 9 | 10 | Example 2: 11 | 12 | Input: root = [2,1,3] 13 | Output: [2,1,3] 14 | 15 |   16 | Constraints: 17 | 18 | The number of nodes in the tree is in the range [1, 104]. 19 | 1 <= Node.val <= 105 20 | 21 | -------------------------------------------------------------------------------- /Qdata/1862/1862.txt: -------------------------------------------------------------------------------- 1 | Given an integer x, return true if x is a palindrome, and false otherwise. 2 |   3 | Example 1: 4 | Input: x = 121 5 | Output: true 6 | Explanation: 121 reads as 121 from left to right and from right to left. 7 | 8 | Example 2: 9 | Input: x = -121 10 | Output: false 11 | Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. 12 | 13 | Example 3: 14 | Input: x = 10 15 | Output: false 16 | Explanation: Reads 01 from right to left. Therefore it is not a palindrome. 17 | 18 |   19 | Constraints: 20 | 21 | -231 <= x <= 231 - 1 22 | 23 |   24 | Follow up: Could you solve it without converting the integer to a string? -------------------------------------------------------------------------------- /Qdata/1995/1995.txt: -------------------------------------------------------------------------------- 1 | You are given the heads of two sorted linked lists list1 and list2. 2 | Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. 3 | Return the head of the merged linked list. 4 |   5 | Example 1: 6 | 7 | Input: list1 = [1,2,4], list2 = [1,3,4] 8 | Output: [1,1,2,3,4,4] 9 | 10 | Example 2: 11 | Input: list1 = [], list2 = [] 12 | Output: [] 13 | 14 | Example 3: 15 | Input: list1 = [], list2 = [0] 16 | Output: [0] 17 | 18 |   19 | Constraints: 20 | 21 | The number of nodes in both lists is in the range [0, 50]. 22 | -100 <= Node.val <= 100 23 | Both list1 and list2 are sorted in non-decreasing order. 24 | 25 | -------------------------------------------------------------------------------- /Qdata/2117/2117.txt: -------------------------------------------------------------------------------- 1 | Write a function createHelloWorld. It should return a new function that always returns "Hello World". 2 |   3 | Example 1: 4 | Input: args = [] 5 | Output: "Hello World" 6 | Explanation: 7 | const f = createHelloWorld(); 8 | f(); // "Hello World" 9 | 10 | The function returned by createHelloWorld should always return "Hello World". 11 | 12 | Example 2: 13 | Input: args = [{},null,42] 14 | Output: "Hello World" 15 | Explanation: 16 | const f = createHelloWorld(); 17 | f({}, null, 42); // "Hello World" 18 | 19 | Any arguments could be passed to the function but it should still always return "Hello World". 20 | 21 |   22 | Constraints: 23 | 24 | 0 <= args.length <= 10 25 | 26 | -------------------------------------------------------------------------------- /Qdata/1013/1013.txt: -------------------------------------------------------------------------------- 1 | Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent. 2 |   3 | Example 1: 4 | Input: s = "foobar", letter = "o" 5 | Output: 33 6 | Explanation: 7 | The percentage of characters in s that equal the letter 'o' is 2 / 6 * 100% = 33% when rounded down, so we return 33. 8 | 9 | Example 2: 10 | Input: s = "jjjj", letter = "k" 11 | Output: 0 12 | Explanation: 13 | The percentage of characters in s that equal the letter 'k' is 0%, so we return 0. 14 |   15 | Constraints: 16 | 17 | 1 <= s.length <= 100 18 | s consists of lowercase English letters. 19 | letter is a lowercase English letter. 20 | 21 | -------------------------------------------------------------------------------- /Qdata/28/28.txt: -------------------------------------------------------------------------------- 1 | A ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j]. The width of such a ramp is j - i. 2 | Given an integer array nums, return the maximum width of a ramp in nums. If there is no ramp in nums, return 0. 3 |   4 | Example 1: 5 | Input: nums = [6,0,8,2,1,5] 6 | Output: 4 7 | Explanation: The maximum width ramp is achieved at (i, j) = (1, 5): nums[1] = 0 and nums[5] = 5. 8 | 9 | Example 2: 10 | Input: nums = [9,8,1,0,1,9,4,0,4,1] 11 | Output: 7 12 | Explanation: The maximum width ramp is achieved at (i, j) = (2, 9): nums[2] = 1 and nums[9] = 1. 13 | 14 |   15 | Constraints: 16 | 17 | 2 <= nums.length <= 5 * 104 18 | 0 <= nums[i] <= 5 * 104 19 | 20 | -------------------------------------------------------------------------------- /Qdata/369/369.txt: -------------------------------------------------------------------------------- 1 | You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got duplicated to another number in the set, which results in repetition of one number and loss of another number. 2 | You are given an integer array nums representing the data status of this set after the error. 3 | Find the number that occurs twice and the number that is missing and return them in the form of an array. 4 |   5 | Example 1: 6 | Input: nums = [1,2,2,4] 7 | Output: [2,3] 8 | Example 2: 9 | Input: nums = [1,1] 10 | Output: [1,2] 11 | 12 |   13 | Constraints: 14 | 15 | 2 <= nums.length <= 104 16 | 1 <= nums[i] <= 104 17 | 18 | -------------------------------------------------------------------------------- /Qdata/533/533.txt: -------------------------------------------------------------------------------- 1 | You are given a positive integer n. Each digit of n has a sign according to the following rules: 2 | 3 | The most significant digit is assigned a positive sign. 4 | Each other digit has an opposite sign to its adjacent digits. 5 | 6 | Return the sum of all digits with their corresponding sign. 7 |   8 | Example 1: 9 | Input: n = 521 10 | Output: 4 11 | Explanation: (+5) + (-2) + (+1) = 4. 12 | 13 | Example 2: 14 | Input: n = 111 15 | Output: 1 16 | Explanation: (+1) + (-1) + (+1) = 1. 17 | 18 | Example 3: 19 | Input: n = 886996 20 | Output: 0 21 | Explanation: (+8) + (-8) + (+6) + (-9) + (+9) + (-6) = 0. 22 | 23 |   24 | Constraints: 25 | 26 | 1 <= n <= 109 27 | 28 |   29 | 30 | --------------------------------------------------------------------------------