diff --git a/README.md b/README.md index 6a3591f2..39e672f9 100644 --- a/README.md +++ b/README.md @@ -2512,15 +2512,6 @@ All the solutions here are crafted with love and their performance beats 99% of Easy - - - 1170 - - - Compare Strings by Frequency of the Smallest Character - - Easy - 1175 @@ -8857,6 +8848,15 @@ All the solutions here are crafted with love and their performance beats 99% of Medium + + + 1170 + + + Compare Strings by Frequency of the Smallest Character + + Medium + 1171 diff --git a/rustgym/desc/leetcode/d0/52.md b/rustgym/desc/leetcode/d0/52.md new file mode 100644 index 00000000..21a438d3 --- /dev/null +++ b/rustgym/desc/leetcode/d0/52.md @@ -0,0 +1,25 @@ +

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.

+ +

Given an integer n, return the number of distinct solutions to the n-queens puzzle.

+ +

 

+

Example 1:

+ +
Input: n = 4
+Output: 2
+Explanation: There are two distinct solutions to the 4-queens puzzle as shown.
+
+ +

Example 2:

+ +
Input: n = 1
+Output: 1
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/53.md b/rustgym/desc/leetcode/d0/53.md new file mode 100644 index 00000000..bd30b747 --- /dev/null +++ b/rustgym/desc/leetcode/d0/53.md @@ -0,0 +1,44 @@ +

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.

+ +

 

+

Example 1:

+ +
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
+Output: 6
+Explanation: [4,-1,2,1] has the largest sum = 6.
+
+ +

Example 2:

+ +
Input: nums = [1]
+Output: 1
+
+ +

Example 3:

+ +
Input: nums = [0]
+Output: 0
+
+ +

Example 4:

+ +
Input: nums = [-1]
+Output: -1
+
+ +

Example 5:

+ +
Input: nums = [-100000]
+Output: -100000
+
+ +

 

+

Constraints:

+ + + +

 

+Follow up: If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle.
diff --git a/rustgym/desc/leetcode/d0/54.md b/rustgym/desc/leetcode/d0/54.md new file mode 100644 index 00000000..c0665eb3 --- /dev/null +++ b/rustgym/desc/leetcode/d0/54.md @@ -0,0 +1,25 @@ +

Given an m x n matrix, return all elements of the matrix in spiral order.

+ +

 

+

Example 1:

+ +
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]]
+Output: [1,2,3,6,9,8,7,4,5]
+
+ +

Example 2:

+ +
Input: matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
+Output: [1,2,3,4,8,12,11,10,9,5,6,7]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/55.md b/rustgym/desc/leetcode/d0/55.md new file mode 100644 index 00000000..41455938 --- /dev/null +++ b/rustgym/desc/leetcode/d0/55.md @@ -0,0 +1,29 @@ +

Given an array of non-negative integers nums, you are initially positioned at the first index of the array.

+ +

Each element in the array represents your maximum jump length at that position.

+ +

Determine if you are able to reach the last index.

+ +

 

+

Example 1:

+ +
Input: nums = [2,3,1,1,4]
+Output: true
+Explanation: Jump 1 step from index 0 to 1, then 3 steps to the last index.
+
+ +

Example 2:

+ +
Input: nums = [3,2,1,0,4]
+Output: false
+Explanation: You will always arrive at index 3 no matter what. Its maximum jump length is 0, which makes it impossible to reach the last index.
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/56.md b/rustgym/desc/leetcode/d0/56.md new file mode 100644 index 00000000..8ae81ef3 --- /dev/null +++ b/rustgym/desc/leetcode/d0/56.md @@ -0,0 +1,26 @@ +

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.

+ +

 

+

Example 1:

+ +
Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
+Output: [[1,6],[8,10],[15,18]]
+Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
+
+ +

Example 2:

+ +
Input: intervals = [[1,4],[4,5]]
+Output: [[1,5]]
+Explanation: Intervals [1,4] and [4,5] are considered overlapping.
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/57.md b/rustgym/desc/leetcode/d0/57.md new file mode 100644 index 00000000..6e023f71 --- /dev/null +++ b/rustgym/desc/leetcode/d0/57.md @@ -0,0 +1,47 @@ +

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).

+ +

You may assume that the intervals were initially sorted according to their start times.

+ +

 

+

Example 1:

+ +
Input: intervals = [[1,3],[6,9]], newInterval = [2,5]
+Output: [[1,5],[6,9]]
+
+ +

Example 2:

+ +
Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8]
+Output: [[1,2],[3,10],[12,16]]
+Explanation: Because the new interval [4,8] overlaps with [3,5],[6,7],[8,10].
+ +

Example 3:

+ +
Input: intervals = [], newInterval = [5,7]
+Output: [[5,7]]
+
+ +

Example 4:

+ +
Input: intervals = [[1,5]], newInterval = [2,3]
+Output: [[1,5]]
+
+ +

Example 5:

+ +
Input: intervals = [[1,5]], newInterval = [2,7]
+Output: [[1,7]]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/58.md b/rustgym/desc/leetcode/d0/58.md new file mode 100644 index 00000000..eee3d994 --- /dev/null +++ b/rustgym/desc/leetcode/d0/58.md @@ -0,0 +1,20 @@ +

Given a string s consists of some words separated by spaces, return the length of the last word in the string. If the last word does not exist, return 0.

+ +

A word is a maximal substring consisting of non-space characters only.

+ +

 

+

Example 1:

+
Input: s = "Hello World"
+Output: 5
+

Example 2:

+
Input: s = " "
+Output: 0
+
+

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/59.md b/rustgym/desc/leetcode/d0/59.md new file mode 100644 index 00000000..7e1def26 --- /dev/null +++ b/rustgym/desc/leetcode/d0/59.md @@ -0,0 +1,22 @@ +

Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.

+ +

 

+

Example 1:

+ +
Input: n = 3
+Output: [[1,2,3],[8,9,4],[7,6,5]]
+
+ +

Example 2:

+ +
Input: n = 1
+Output: [[1]]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/60.md b/rustgym/desc/leetcode/d0/60.md new file mode 100644 index 00000000..058d3c11 --- /dev/null +++ b/rustgym/desc/leetcode/d0/60.md @@ -0,0 +1,34 @@ +

The set [1, 2, 3, ..., n] contains a total of n! unique permutations.

+ +

By listing and labeling all of the permutations in order, we get the following sequence for n = 3:

+ +
    +
  1. "123"
  2. +
  3. "132"
  4. +
  5. "213"
  6. +
  7. "231"
  8. +
  9. "312"
  10. +
  11. "321"
  12. +
+ +

Given n and k, return the kth permutation sequence.

+ +

 

+

Example 1:

+
Input: n = 3, k = 3
+Output: "213"
+

Example 2:

+
Input: n = 4, k = 9
+Output: "2314"
+

Example 3:

+
Input: n = 3, k = 1
+Output: "123"
+
+

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/61.md b/rustgym/desc/leetcode/d0/61.md new file mode 100644 index 00000000..bbdef5a4 --- /dev/null +++ b/rustgym/desc/leetcode/d0/61.md @@ -0,0 +1,24 @@ +

Given the head of a linked list, rotate the list to the right by k places.

+ +

 

+

Example 1:

+ +
Input: head = [1,2,3,4,5], k = 2
+Output: [4,5,1,2,3]
+
+ +

Example 2:

+ +
Input: head = [0,1,2], k = 4
+Output: [2,0,1]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/62.md b/rustgym/desc/leetcode/d0/62.md new file mode 100644 index 00000000..2f039faf --- /dev/null +++ b/rustgym/desc/leetcode/d0/62.md @@ -0,0 +1,44 @@ +

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

+ +

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).

+ +

How many possible unique paths are there?

+ +

 

+

Example 1:

+ +
Input: m = 3, n = 7
+Output: 28
+
+ +

Example 2:

+ +
Input: m = 3, n = 2
+Output: 3
+Explanation:
+From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:
+1. Right -> Down -> Down
+2. Down -> Down -> Right
+3. Down -> Right -> Down
+
+ +

Example 3:

+ +
Input: m = 7, n = 3
+Output: 28
+
+ +

Example 4:

+ +
Input: m = 3, n = 3
+Output: 6
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/63.md b/rustgym/desc/leetcode/d0/63.md new file mode 100644 index 00000000..b8fa2ac6 --- /dev/null +++ b/rustgym/desc/leetcode/d0/63.md @@ -0,0 +1,35 @@ +

A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).

+ +

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).

+ +

Now consider if some obstacles are added to the grids. How many unique paths would there be?

+ +

An obstacle and space is marked as 1 and 0 respectively in the grid.

+ +

 

+

Example 1:

+ +
Input: obstacleGrid = [[0,0,0],[0,1,0],[0,0,0]]
+Output: 2
+Explanation: There is one obstacle in the middle of the 3x3 grid above.
+There are two ways to reach the bottom-right corner:
+1. Right -> Right -> Down -> Down
+2. Down -> Down -> Right -> Right
+
+ +

Example 2:

+ +
Input: obstacleGrid = [[0,1],[0,0]]
+Output: 1
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/64.md b/rustgym/desc/leetcode/d0/64.md new file mode 100644 index 00000000..2f1456ed --- /dev/null +++ b/rustgym/desc/leetcode/d0/64.md @@ -0,0 +1,28 @@ +

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.

+ +

Note: You can only move either down or right at any point in time.

+ +

 

+

Example 1:

+ +
Input: grid = [[1,3,1],[1,5,1],[4,2,1]]
+Output: 7
+Explanation: Because the path 1 → 3 → 1 → 1 → 1 minimizes the sum.
+
+ +

Example 2:

+ +
Input: grid = [[1,2,3],[4,5,6]]
+Output: 12
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/66.md b/rustgym/desc/leetcode/d0/66.md new file mode 100644 index 00000000..c376d48c --- /dev/null +++ b/rustgym/desc/leetcode/d0/66.md @@ -0,0 +1,35 @@ +

Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer.

+ +

The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit.

+ +

You may assume the integer does not contain any leading zero, except the number 0 itself.

+ +

 

+

Example 1:

+ +
Input: digits = [1,2,3]
+Output: [1,2,4]
+Explanation: The array represents the integer 123.
+
+ +

Example 2:

+ +
Input: digits = [4,3,2,1]
+Output: [4,3,2,2]
+Explanation: The array represents the integer 4321.
+
+ +

Example 3:

+ +
Input: digits = [0]
+Output: [1]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/67.md b/rustgym/desc/leetcode/d0/67.md new file mode 100644 index 00000000..ba70c56c --- /dev/null +++ b/rustgym/desc/leetcode/d0/67.md @@ -0,0 +1,19 @@ +

Given two binary strings a and b, return their sum as a binary string.

+ +

 

+

Example 1:

+
Input: a = "11", b = "1"
+Output: "100"
+

Example 2:

+
Input: a = "1010", b = "1011"
+Output: "10101"
+
+

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/69.md b/rustgym/desc/leetcode/d0/69.md new file mode 100644 index 00000000..fee84537 --- /dev/null +++ b/rustgym/desc/leetcode/d0/69.md @@ -0,0 +1,24 @@ +

Given a non-negative integer x, compute and return the square root of x.

+ +

Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.

+ +

 

+

Example 1:

+ +
Input: x = 4
+Output: 2
+
+ +

Example 2:

+ +
Input: x = 8
+Output: 2
+Explanation: The square root of 8 is 2.82842..., and since the decimal part is truncated, 2 is returned.
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/70.md b/rustgym/desc/leetcode/d0/70.md new file mode 100644 index 00000000..4a04078b --- /dev/null +++ b/rustgym/desc/leetcode/d0/70.md @@ -0,0 +1,31 @@ +

You are climbing a staircase. It takes n steps to reach the top.

+ +

Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?

+ +

 

+

Example 1:

+ +
Input: n = 2
+Output: 2
+Explanation: There are two ways to climb to the top.
+1. 1 step + 1 step
+2. 2 steps
+
+ +

Example 2:

+ +
Input: n = 3
+Output: 3
+Explanation: There are three ways to climb to the top.
+1. 1 step + 1 step + 1 step
+2. 1 step + 2 steps
+3. 2 steps + 1 step
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/71.md b/rustgym/desc/leetcode/d0/71.md new file mode 100644 index 00000000..a42a3c91 --- /dev/null +++ b/rustgym/desc/leetcode/d0/71.md @@ -0,0 +1,43 @@ +

Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path.

+ +

In a UNIX-style file system, a period '.' refers to the current directory. Furthermore, a double period '..' moves the directory up a level.

+ +

Note that the returned canonical path must always begin with a slash '/', and there must be only a single slash '/' between two directory names. The last directory name (if it exists) must not end with a trailing '/'. Also, the canonical path must be the shortest string representing the absolute path.

+ +

 

+

Example 1:

+ +
Input: path = "/home/"
+Output: "/home"
+Explanation: Note that there is no trailing slash after the last directory name.
+
+ +

Example 2:

+ +
Input: path = "/../"
+Output: "/"
+Explanation: Going one level up from the root directory is a no-op, as the root level is the highest level you can go.
+
+ +

Example 3:

+ +
Input: path = "/home//foo/"
+Output: "/home/foo"
+Explanation: In the canonical path, multiple consecutive slashes are replaced by a single one.
+
+ +

Example 4:

+ +
Input: path = "/a/./b/../../c/"
+Output: "/c"
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/73.md b/rustgym/desc/leetcode/d0/73.md new file mode 100644 index 00000000..81471e1d --- /dev/null +++ b/rustgym/desc/leetcode/d0/73.md @@ -0,0 +1,33 @@ +

Given an m x n matrix. If an element is 0, set its entire row and column to 0. Do it in-place.

+ +

Follow up:

+ + + +

 

+

Example 1:

+ +
Input: matrix = [[1,1,1],[1,0,1],[1,1,1]]
+Output: [[1,0,1],[0,0,0],[1,0,1]]
+
+ +

Example 2:

+ +
Input: matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
+Output: [[0,0,0,0],[0,4,5,0],[0,3,1,0]]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/74.md b/rustgym/desc/leetcode/d0/74.md new file mode 100644 index 00000000..7c2bae1f --- /dev/null +++ b/rustgym/desc/leetcode/d0/74.md @@ -0,0 +1,30 @@ +

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:

+ + + +

 

+

Example 1:

+ +
Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 3
+Output: true
+
+ +

Example 2:

+ +
Input: matrix = [[1,3,5,7],[10,11,16,20],[23,30,34,60]], target = 13
+Output: false
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/75.md b/rustgym/desc/leetcode/d0/75.md new file mode 100644 index 00000000..40c851e7 --- /dev/null +++ b/rustgym/desc/leetcode/d0/75.md @@ -0,0 +1,35 @@ +

Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.

+ +

We will use the integers 0, 1, and 2 to represent the color red, white, and blue, respectively.

+ +

 

+

Example 1:

+
Input: nums = [2,0,2,1,1,0]
+Output: [0,0,1,1,2,2]
+

Example 2:

+
Input: nums = [2,0,1]
+Output: [0,1,2]
+

Example 3:

+
Input: nums = [0]
+Output: [0]
+

Example 4:

+
Input: nums = [1]
+Output: [1]
+
+

 

+

Constraints:

+ + + +

 

+

Follow up:

+ + +
diff --git a/rustgym/desc/leetcode/d0/77.md b/rustgym/desc/leetcode/d0/77.md new file mode 100644 index 00000000..e0efa93c --- /dev/null +++ b/rustgym/desc/leetcode/d0/77.md @@ -0,0 +1,33 @@ +

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.

+ +

You may return the answer in any order.

+ +

 

+

Example 1:

+ +
Input: n = 4, k = 2
+Output:
+[
+  [2,4],
+  [3,4],
+  [2,3],
+  [1,2],
+  [1,3],
+  [1,4],
+]
+
+ +

Example 2:

+ +
Input: n = 1, k = 1
+Output: [[1]]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/78.md b/rustgym/desc/leetcode/d0/78.md new file mode 100644 index 00000000..a7740867 --- /dev/null +++ b/rustgym/desc/leetcode/d0/78.md @@ -0,0 +1,26 @@ +

Given an integer array nums of unique elements, return all possible subsets (the power set).

+ +

The solution set must not contain duplicate subsets. Return the solution in any order.

+ +

 

+

Example 1:

+ +
Input: nums = [1,2,3]
+Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
+
+ +

Example 2:

+ +
Input: nums = [0]
+Output: [[],[0]]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/79.md b/rustgym/desc/leetcode/d0/79.md new file mode 100644 index 00000000..270669c9 --- /dev/null +++ b/rustgym/desc/leetcode/d0/79.md @@ -0,0 +1,34 @@ +

Given an m x n board and a word, find if the word exists in the grid.

+ +

The word can be constructed from letters of sequentially adjacent cells, where "adjacent" cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.

+ +

 

+

Example 1:

+ +
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"
+Output: true
+
+ +

Example 2:

+ +
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE"
+Output: true
+
+ +

Example 3:

+ +
Input: board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCB"
+Output: false
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/80.md b/rustgym/desc/leetcode/d0/80.md new file mode 100644 index 00000000..38072e80 --- /dev/null +++ b/rustgym/desc/leetcode/d0/80.md @@ -0,0 +1,46 @@ +

Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length.

+ +

Do not allocate extra space for another array; you must do this by modifying the input array in-place with O(1) extra memory.

+ +

Clarification:

+ +

Confused why the returned value is an integer, but your answer is an array?

+ +

Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller.

+ +

Internally you can think of this:

+ +
// nums is passed in by reference. (i.e., without making a copy)
+int len = removeDuplicates(nums);
+
+// any modification to nums in your function would be known by the caller.
+// using the length returned by your function, it prints the first len elements.
+for (int i = 0; i < len; i++) {
+    print(nums[i]);
+}
+
+ +

 

+

Example 1:

+ +
Input: nums = [1,1,1,2,2,3]
+Output: 5, nums = [1,1,2,2,3]
+Explanation: Your function should return length = 5, with the first five elements of nums being 1, 1, 2, 2 and 3 respectively. It doesn't matter what you leave beyond the returned length.
+
+ +

Example 2:

+ +
Input: nums = [0,0,1,1,1,1,2,3,3]
+Output: 7, nums = [0,0,1,1,2,3,3]
+Explanation: Your function should return length = 7, with the first seven elements of nums being modified to 0, 0, 1, 1, 2, 3 and 3 respectively. It doesn't matter what values are set beyond the returned length.
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/81.md b/rustgym/desc/leetcode/d0/81.md new file mode 100644 index 00000000..23b17df1 --- /dev/null +++ b/rustgym/desc/leetcode/d0/81.md @@ -0,0 +1,26 @@ +

You are given an integer array nums sorted in ascending order (not necessarily distinct values), and an integer target.

+ +

Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,4,4,5,6,6,7] might become [4,5,6,6,7,0,1,2,4,4]).

+ +

If target is found in the array return its index, otherwise, return -1.

+ +

 

+

Example 1:

+
Input: nums = [2,5,6,0,0,1,2], target = 0
+Output: true
+

Example 2:

+
Input: nums = [2,5,6,0,0,1,2], target = 3
+Output: false
+
+

 

+

Constraints:

+ + + +

 

+Follow up: This problem is the same as Search in Rotated Sorted Array, where nums may contain duplicates. Would this affect the run-time complexity? How and why?
diff --git a/rustgym/desc/leetcode/d0/82.md b/rustgym/desc/leetcode/d0/82.md new file mode 100644 index 00000000..cd56b076 --- /dev/null +++ b/rustgym/desc/leetcode/d0/82.md @@ -0,0 +1,24 @@ +

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.

+ +

 

+

Example 1:

+ +
Input: head = [1,2,3,3,4,4,5]
+Output: [1,2,5]
+
+ +

Example 2:

+ +
Input: head = [1,1,1,2,3]
+Output: [2,3]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/83.md b/rustgym/desc/leetcode/d0/83.md new file mode 100644 index 00000000..4310eceb --- /dev/null +++ b/rustgym/desc/leetcode/d0/83.md @@ -0,0 +1,24 @@ +

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.

+ +

 

+

Example 1:

+ +
Input: head = [1,1,2]
+Output: [1,2]
+
+ +

Example 2:

+ +
Input: head = [1,1,2,3,3]
+Output: [1,2,3]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/86.md b/rustgym/desc/leetcode/d0/86.md new file mode 100644 index 00000000..92a6d4ad --- /dev/null +++ b/rustgym/desc/leetcode/d0/86.md @@ -0,0 +1,26 @@ +

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.

+ +

You should preserve the original relative order of the nodes in each of the two partitions.

+ +

 

+

Example 1:

+ +
Input: head = [1,4,3,2,5,2], x = 3
+Output: [1,2,2,4,3,5]
+
+ +

Example 2:

+ +
Input: head = [2,1], x = 2
+Output: [1,2]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/87.md b/rustgym/desc/leetcode/d0/87.md new file mode 100644 index 00000000..a92ea785 --- /dev/null +++ b/rustgym/desc/leetcode/d0/87.md @@ -0,0 +1,52 @@ +

We can scramble a string s to get a string t using the following algorithm:

+ +
    +
  1. If the length of the string is 1, stop.
  2. +
  3. If the length of the string is > 1, do the following: +
      +
    • Split the string into two non-empty substrings at a random index, i.e., if the string is s, divide it to x and y where s = x + y.
    • +
    • Randomly decide to swap the two substrings or to keep them in the same order. i.e., after this step, s may become s = x + y or s = y + x.
    • +
    • Apply step 1 recursively on each of the two substrings x and y.
    • +
    +
  4. +
+ +

Given two strings s1 and s2 of the same length, return true if s2 is a scrambled string of s1, otherwise, return false.

+ +

 

+

Example 1:

+ +
Input: s1 = "great", s2 = "rgeat"
+Output: true
+Explanation: One possible scenario applied on s1 is:
+"great" --> "gr/eat" // divide at random index.
+"gr/eat" --> "gr/eat" // random decision is not to swap the two substrings and keep them in order.
+"gr/eat" --> "g/r / e/at" // apply the same algorithm recursively on both substrings. divide at ranom index each of them.
+"g/r / e/at" --> "r/g / e/at" // random decision was to swap the first substring and to keep the second substring in the same order.
+"r/g / e/at" --> "r/g / e/ a/t" // again apply the algorithm recursively, divide "at" to "a/t".
+"r/g / e/ a/t" --> "r/g / e/ a/t" // random decision is to keep both substrings in the same order.
+The algorithm stops now and the result string is "rgeat" which is s2.
+As there is one possible scenario that led s1 to be scrambled to s2, we return true.
+
+ +

Example 2:

+ +
Input: s1 = "abcde", s2 = "caebd"
+Output: false
+
+ +

Example 3:

+ +
Input: s1 = "a", s2 = "a"
+Output: true
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/88.md b/rustgym/desc/leetcode/d0/88.md new file mode 100644 index 00000000..e54824c3 --- /dev/null +++ b/rustgym/desc/leetcode/d0/88.md @@ -0,0 +1,23 @@ +

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.

+ +

The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has a size equal to m + n such that it has enough space to hold additional elements from nums2.

+ +

 

+

Example 1:

+
Input: nums1 = [1,2,3,0,0,0], m = 3, nums2 = [2,5,6], n = 3
+Output: [1,2,2,3,5,6]
+

Example 2:

+
Input: nums1 = [1], m = 1, nums2 = [], n = 0
+Output: [1]
+
+

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/89.md b/rustgym/desc/leetcode/d0/89.md new file mode 100644 index 00000000..90d88631 --- /dev/null +++ b/rustgym/desc/leetcode/d0/89.md @@ -0,0 +1,36 @@ +

The gray code is a binary numeral system where two successive values differ in only one bit.

+ +

Given an integer n representing the total number of bits in the code, return any sequence of gray code.

+ +

A gray code sequence must begin with 0.

+ +

 

+

Example 1:

+ +
Input: n = 2
+Output: [0,1,3,2]
+Explanation:
+00 - 0
+01 - 1
+11 - 3
+10 - 2
+[0,2,3,1] is also a valid gray code sequence.
+00 - 0
+10 - 2
+11 - 3
+01 - 1
+
+ +

Example 2:

+ +
Input: n = 1
+Output: [0,1]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/90.md b/rustgym/desc/leetcode/d0/90.md new file mode 100644 index 00000000..862d8b7e --- /dev/null +++ b/rustgym/desc/leetcode/d0/90.md @@ -0,0 +1,20 @@ +

Given an integer array nums that may contain duplicates, return all possible subsets (the power set).

+ +

The solution set must not contain duplicate subsets. Return the solution in any order.

+ +

 

+

Example 1:

+
Input: nums = [1,2,2]
+Output: [[],[1],[1,2],[1,2,2],[2],[2,2]]
+

Example 2:

+
Input: nums = [0]
+Output: [[],[0]]
+
+

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/92.md b/rustgym/desc/leetcode/d0/92.md new file mode 100644 index 00000000..2a68f102 --- /dev/null +++ b/rustgym/desc/leetcode/d0/92.md @@ -0,0 +1,10 @@ +

Reverse a linked list from position m to n. Do it in one-pass.

+ +

Note: 1 ≤ mn ≤ length of list.

+ +

Example:

+ +
Input: 1->2->3->4->5->NULL, m = 2, n = 4
+Output: 1->4->3->2->5->NULL
+
+
diff --git a/rustgym/desc/leetcode/d0/93.md b/rustgym/desc/leetcode/d0/93.md new file mode 100644 index 00000000..84fd5d57 --- /dev/null +++ b/rustgym/desc/leetcode/d0/93.md @@ -0,0 +1,29 @@ +

Given a string s containing only digits, return all possible valid IP addresses that can be obtained from s. You can return them in any order.

+ +

A valid IP address consists of exactly four integers, each integer is between 0 and 255, separated by single dots and cannot have leading zeros. For example, "0.1.2.201" and "192.168.1.1" are valid IP addresses and "0.011.255.245", "192.168.1.312" and "192.168@1.1" are invalid IP addresses. 

+ +

 

+

Example 1:

+
Input: s = "25525511135"
+Output: ["255.255.11.135","255.255.111.35"]
+

Example 2:

+
Input: s = "0000"
+Output: ["0.0.0.0"]
+

Example 3:

+
Input: s = "1111"
+Output: ["1.1.1.1"]
+

Example 4:

+
Input: s = "010010"
+Output: ["0.10.0.10","0.100.1.0"]
+

Example 5:

+
Input: s = "101023"
+Output: ["1.0.10.23","1.0.102.3","10.1.0.23","10.10.2.3","101.0.2.3"]
+
+

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/94.md b/rustgym/desc/leetcode/d0/94.md new file mode 100644 index 00000000..35b0be1c --- /dev/null +++ b/rustgym/desc/leetcode/d0/94.md @@ -0,0 +1,49 @@ +

Given the root of a binary tree, return the inorder traversal of its nodes' values.

+ +

 

+

Example 1:

+ +
Input: root = [1,null,2,3]
+Output: [1,3,2]
+
+ +

Example 2:

+ +
Input: root = []
+Output: []
+
+ +

Example 3:

+ +
Input: root = [1]
+Output: [1]
+
+ +

Example 4:

+ +
Input: root = [1,2]
+Output: [2,1]
+
+ +

Example 5:

+ +
Input: root = [1,null,2]
+Output: [1,2]
+
+ +

 

+

Constraints:

+ + + +

 

+ +

Follow up:

+ +

Recursive solution is trivial, could you do it iteratively?

+ +

 

+
diff --git a/rustgym/desc/leetcode/d0/95.md b/rustgym/desc/leetcode/d0/95.md new file mode 100644 index 00000000..f0a1225c --- /dev/null +++ b/rustgym/desc/leetcode/d0/95.md @@ -0,0 +1,22 @@ +

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.

+ +

 

+

Example 1:

+ +
Input: n = 3
+Output: [[1,null,2,null,3],[1,null,3,2],[2,1,3],[3,1,null,null,2],[3,2,null,1]]
+
+ +

Example 2:

+ +
Input: n = 1
+Output: [[1]]
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/96.md b/rustgym/desc/leetcode/d0/96.md new file mode 100644 index 00000000..06aec5f4 --- /dev/null +++ b/rustgym/desc/leetcode/d0/96.md @@ -0,0 +1,22 @@ +

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.

+ +

 

+

Example 1:

+ +
Input: n = 3
+Output: 5
+
+ +

Example 2:

+ +
Input: n = 1
+Output: 1
+
+ +

 

+

Constraints:

+ + +
diff --git a/rustgym/desc/leetcode/d0/98.md b/rustgym/desc/leetcode/d0/98.md new file mode 100644 index 00000000..bfdb7c5c --- /dev/null +++ b/rustgym/desc/leetcode/d0/98.md @@ -0,0 +1,32 @@ +

Given the root of a binary tree, determine if it is a valid binary search tree (BST).

+ +

A valid BST is defined as follows:

+ + + +

 

+

Example 1:

+ +
Input: root = [2,1,3]
+Output: true
+
+ +

Example 2:

+ +
Input: root = [5,1,4,null,null,3,6]
+Output: false
+Explanation: The root node's value is 5 but its right child's value is 4.
+
+ +

 

+

Constraints:

+ + +
diff --git a/server/templates/home.j2 b/server/templates/home.j2 index 96b1489d..7ad70d2d 100644 --- a/server/templates/home.j2 +++ b/server/templates/home.j2 @@ -61,13 +61,9 @@ {% block footer %}
-
+

+ 2021 RUST GYM +

-
-
-

- 2021 RUST GYM -

-
{% endblock %}