diff options
author | crupest <crupest@outlook.com> | 2021-02-23 21:07:19 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-02-23 21:07:19 +0800 |
commit | 185ef9fcb0e59f13e9ee0ccb261693cdaddebab0 (patch) | |
tree | 3f19388b054fb2a12230706681dd62f077890c51 /works | |
parent | ca5a0f8dde5d8d9d7f877a790d05a270cc3224f9 (diff) | |
download | crupest-185ef9fcb0e59f13e9ee0ccb261693cdaddebab0.tar.gz crupest-185ef9fcb0e59f13e9ee0ccb261693cdaddebab0.tar.bz2 crupest-185ef9fcb0e59f13e9ee0ccb261693cdaddebab0.zip |
import(solutions): Move leetcode solutions to subdir.
Diffstat (limited to 'works')
-rw-r--r-- | works/solutions/leetcode/cpp/.gitignore (renamed from works/solutions/cpp/.gitignore) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/10.cpp (renamed from works/solutions/cpp/10.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/100.cpp (renamed from works/solutions/cpp/100.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/101.cpp (renamed from works/solutions/cpp/101.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1025.cpp (renamed from works/solutions/cpp/1025.cpp) | 16 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1051.cpp (renamed from works/solutions/cpp/1051.cpp) | 64 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1052.cpp (renamed from works/solutions/cpp/1052.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/11.cpp (renamed from works/solutions/cpp/11.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1144.cpp (renamed from works/solutions/cpp/1144.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/12.cpp (renamed from works/solutions/cpp/12.cpp) | 100 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/121.cpp (renamed from works/solutions/cpp/121.cpp) | 48 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1219.cpp (renamed from works/solutions/cpp/1219.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/122.cpp (renamed from works/solutions/cpp/122.cpp) | 56 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/123.cpp (renamed from works/solutions/cpp/123.cpp) | 68 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1286.cpp (renamed from works/solutions/cpp/1286.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/13.cpp (renamed from works/solutions/cpp/13.cpp) | 108 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1343.cpp (renamed from works/solutions/cpp/1343.cpp) | 80 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1347.cpp (renamed from works/solutions/cpp/1347.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1370.cpp (renamed from works/solutions/cpp/1370.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/14.cpp (renamed from works/solutions/cpp/14.cpp) | 70 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/147.cpp (renamed from works/solutions/cpp/147.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1470.cpp (renamed from works/solutions/cpp/1470.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/155-2.cpp (renamed from works/solutions/cpp/155-2.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/155.cpp (renamed from works/solutions/cpp/155.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/1609.cpp (renamed from works/solutions/cpp/1609.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/167.cpp (renamed from works/solutions/cpp/167.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/17.04.cpp (renamed from works/solutions/cpp/17.04.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/17.cpp (renamed from works/solutions/cpp/17.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/198.cpp (renamed from works/solutions/cpp/198.cpp) | 52 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/2.cpp (renamed from works/solutions/cpp/2.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/20.cpp (renamed from works/solutions/cpp/20.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/203.cpp (renamed from works/solutions/cpp/203.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/213.cpp (renamed from works/solutions/cpp/213.cpp) | 82 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/22.cpp (renamed from works/solutions/cpp/22.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/231.cpp (renamed from works/solutions/cpp/231.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/26.cpp (renamed from works/solutions/cpp/26.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/260-2.cpp (renamed from works/solutions/cpp/260-2.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/260.cpp (renamed from works/solutions/cpp/260.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/299.cpp (renamed from works/solutions/cpp/299.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/303.cpp (renamed from works/solutions/cpp/303.cpp) | 52 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/328.cpp (renamed from works/solutions/cpp/328.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/337.cpp (renamed from works/solutions/cpp/337.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/338.cpp (renamed from works/solutions/cpp/338.cpp) | 52 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/343.cpp (renamed from works/solutions/cpp/343.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/35.cpp (renamed from works/solutions/cpp/35.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/397.cpp (renamed from works/solutions/cpp/397.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/401.cpp (renamed from works/solutions/cpp/401.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/46.cpp (renamed from works/solutions/cpp/46.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/495.cpp (renamed from works/solutions/cpp/495.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/5.cpp (renamed from works/solutions/cpp/5.cpp) | 208 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/501.cpp (renamed from works/solutions/cpp/501.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/526.cpp (renamed from works/solutions/cpp/526.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/543.cpp (renamed from works/solutions/cpp/543.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/55.cpp (renamed from works/solutions/cpp/55.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/6.cpp (renamed from works/solutions/cpp/6.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/60.cpp (renamed from works/solutions/cpp/60.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/62.cpp (renamed from works/solutions/cpp/62.cpp) | 50 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/63.cpp (renamed from works/solutions/cpp/63.cpp) | 88 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/641.cpp (renamed from works/solutions/cpp/641.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/649.cpp (renamed from works/solutions/cpp/649.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/66.cpp (renamed from works/solutions/cpp/66.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/680.cpp (renamed from works/solutions/cpp/680.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/7.cpp (renamed from works/solutions/cpp/7.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/704.cpp (renamed from works/solutions/cpp/704.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/74.cpp (renamed from works/solutions/cpp/74.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/746.cpp (renamed from works/solutions/cpp/746.cpp) | 70 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/766-2.cpp (renamed from works/solutions/cpp/766-2.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/766.cpp (renamed from works/solutions/cpp/766.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/77.cpp (renamed from works/solutions/cpp/77.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/86.cpp (renamed from works/solutions/cpp/86.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/865.cpp (renamed from works/solutions/cpp/865.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/897.cpp (renamed from works/solutions/cpp/897.cpp) | 74 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/917.cpp (renamed from works/solutions/cpp/917.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/96.cpp (renamed from works/solutions/cpp/96.cpp) | 28 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/965.cpp (renamed from works/solutions/cpp/965.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/968.cpp (renamed from works/solutions/cpp/968.cpp) | 124 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/976.cpp (renamed from works/solutions/cpp/976.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/98.cpp (renamed from works/solutions/cpp/98.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/li-wu-de-zui-da-jie-zhi-lcof.cpp (renamed from works/solutions/cpp/li-wu-de-zui-da-jie-zhi-lcof.cpp) | 68 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/paths-with-sums-lcci.cpp (renamed from works/solutions/cpp/paths-with-sums-lcci.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/power-set-lcci.cpp (renamed from works/solutions/cpp/power-set-lcci.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/cpp/que-shi-de-shu-zi-lcof.cpp (renamed from works/solutions/cpp/que-shi-de-shu-zi-lcof.cpp) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/rust/.gitignore (renamed from works/solutions/rust/.gitignore) | 10 | ||||
-rw-r--r-- | works/solutions/leetcode/rust/Cargo.toml (renamed from works/solutions/rust/Cargo.toml) | 18 | ||||
-rw-r--r-- | works/solutions/leetcode/rust/src/add_two_numbers.rs (renamed from works/solutions/rust/src/add_two_numbers.rs) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/rust/src/find_median_sorted_arrays.rs (renamed from works/solutions/rust/src/find_median_sorted_arrays.rs) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/rust/src/length_of_longest_substring.rs (renamed from works/solutions/rust/src/length_of_longest_substring.rs) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/rust/src/lib.rs (renamed from works/solutions/rust/src/lib.rs) | 14 | ||||
-rw-r--r-- | works/solutions/leetcode/rust/src/longest_palindrome.rs (renamed from works/solutions/rust/src/longest_palindrome.rs) | 0 | ||||
-rw-r--r-- | works/solutions/leetcode/rust/src/two_sum.rs (renamed from works/solutions/rust/src/two_sum.rs) | 0 |
90 files changed, 800 insertions, 800 deletions
diff --git a/works/solutions/cpp/.gitignore b/works/solutions/leetcode/cpp/.gitignore index d1d85a8..d1d85a8 100644 --- a/works/solutions/cpp/.gitignore +++ b/works/solutions/leetcode/cpp/.gitignore diff --git a/works/solutions/cpp/10.cpp b/works/solutions/leetcode/cpp/10.cpp index fbb5586..fbb5586 100644 --- a/works/solutions/cpp/10.cpp +++ b/works/solutions/leetcode/cpp/10.cpp diff --git a/works/solutions/cpp/100.cpp b/works/solutions/leetcode/cpp/100.cpp index 28448d1..28448d1 100644 --- a/works/solutions/cpp/100.cpp +++ b/works/solutions/leetcode/cpp/100.cpp diff --git a/works/solutions/cpp/101.cpp b/works/solutions/leetcode/cpp/101.cpp index a1dad6f..a1dad6f 100644 --- a/works/solutions/cpp/101.cpp +++ b/works/solutions/leetcode/cpp/101.cpp diff --git a/works/solutions/cpp/1025.cpp b/works/solutions/leetcode/cpp/1025.cpp index 69d75d9..b26ae02 100644 --- a/works/solutions/cpp/1025.cpp +++ b/works/solutions/leetcode/cpp/1025.cpp @@ -1,8 +1,8 @@ -class Solution -{ -public: - bool divisorGame(int N) - { - return N % 2 == 0; - } -}; +class Solution
+{
+public:
+ bool divisorGame(int N)
+ {
+ return N % 2 == 0;
+ }
+};
diff --git a/works/solutions/cpp/1051.cpp b/works/solutions/leetcode/cpp/1051.cpp index e55d877..6ded6f5 100644 --- a/works/solutions/cpp/1051.cpp +++ b/works/solutions/leetcode/cpp/1051.cpp @@ -1,33 +1,33 @@ -#include <vector> - -using std::vector; - -class Solution -{ -public: - int heightChecker(vector<int> &heights) - { - vector<int> height_counter(101); - for (int height : heights) - { - height_counter[height]++; - } - - auto iter = heights.cbegin(); - - int result = 0; - - for (int height = 1; height <= 100; height++) - { - int height_count = height_counter[height]; - while (height_count > 0) - { - if (*iter++ != height) - result++; - --height_count; - } - } - - return result; - } +#include <vector>
+
+using std::vector;
+
+class Solution
+{
+public:
+ int heightChecker(vector<int> &heights)
+ {
+ vector<int> height_counter(101);
+ for (int height : heights)
+ {
+ height_counter[height]++;
+ }
+
+ auto iter = heights.cbegin();
+
+ int result = 0;
+
+ for (int height = 1; height <= 100; height++)
+ {
+ int height_count = height_counter[height];
+ while (height_count > 0)
+ {
+ if (*iter++ != height)
+ result++;
+ --height_count;
+ }
+ }
+
+ return result;
+ }
};
\ No newline at end of file diff --git a/works/solutions/cpp/1052.cpp b/works/solutions/leetcode/cpp/1052.cpp index 583e217..583e217 100644 --- a/works/solutions/cpp/1052.cpp +++ b/works/solutions/leetcode/cpp/1052.cpp diff --git a/works/solutions/cpp/11.cpp b/works/solutions/leetcode/cpp/11.cpp index 44a8fd9..44a8fd9 100644 --- a/works/solutions/cpp/11.cpp +++ b/works/solutions/leetcode/cpp/11.cpp diff --git a/works/solutions/cpp/1144.cpp b/works/solutions/leetcode/cpp/1144.cpp index e6bf83b..e6bf83b 100644 --- a/works/solutions/cpp/1144.cpp +++ b/works/solutions/leetcode/cpp/1144.cpp diff --git a/works/solutions/cpp/12.cpp b/works/solutions/leetcode/cpp/12.cpp index 68eb4b4..e334895 100644 --- a/works/solutions/cpp/12.cpp +++ b/works/solutions/leetcode/cpp/12.cpp @@ -1,51 +1,51 @@ -#include <string> - -using std::string; - -const char *roman_digits = "IVXLCDM"; - -class Solution -{ -public: - string intToRoman(int num) - { - string result; - - int current_digit_index = 0; - - while (num != 0) - { - const int digit = num % 10; - if (digit == 9) - { - result += roman_digits[current_digit_index + 2]; - result += roman_digits[current_digit_index]; - } - else if (digit <= 8 && digit >= 5) - { - for (int i = 0; i < digit - 5; i++) - { - result += roman_digits[current_digit_index]; - } - result += roman_digits[current_digit_index + 1]; - } - else if (digit == 4) - { - result += roman_digits[current_digit_index + 1]; - result += roman_digits[current_digit_index]; - } - else - { - for (int i = 0; i < digit; i++) - { - result += roman_digits[current_digit_index]; - } - } - - num /= 10; - current_digit_index += 2; - } - - return string(result.crbegin(), result.crend()); - } +#include <string>
+
+using std::string;
+
+const char *roman_digits = "IVXLCDM";
+
+class Solution
+{
+public:
+ string intToRoman(int num)
+ {
+ string result;
+
+ int current_digit_index = 0;
+
+ while (num != 0)
+ {
+ const int digit = num % 10;
+ if (digit == 9)
+ {
+ result += roman_digits[current_digit_index + 2];
+ result += roman_digits[current_digit_index];
+ }
+ else if (digit <= 8 && digit >= 5)
+ {
+ for (int i = 0; i < digit - 5; i++)
+ {
+ result += roman_digits[current_digit_index];
+ }
+ result += roman_digits[current_digit_index + 1];
+ }
+ else if (digit == 4)
+ {
+ result += roman_digits[current_digit_index + 1];
+ result += roman_digits[current_digit_index];
+ }
+ else
+ {
+ for (int i = 0; i < digit; i++)
+ {
+ result += roman_digits[current_digit_index];
+ }
+ }
+
+ num /= 10;
+ current_digit_index += 2;
+ }
+
+ return string(result.crbegin(), result.crend());
+ }
};
\ No newline at end of file diff --git a/works/solutions/cpp/121.cpp b/works/solutions/leetcode/cpp/121.cpp index cba465d..8561fa3 100644 --- a/works/solutions/cpp/121.cpp +++ b/works/solutions/leetcode/cpp/121.cpp @@ -1,24 +1,24 @@ -#include <vector> - -using std::vector; - -class Solution -{ -public: - int maxProfit(vector<int> &prices) - { - if (prices.size() <= 1) return 0; - - int result = 0; - int min = prices.front(); - for (int i = 1; i < prices.size(); i++) - { - if (prices[i] - min > result) - result = prices[i] - min; - if (prices[i] < min) - min = prices[i]; - } - - return result; - } -}; +#include <vector>
+
+using std::vector;
+
+class Solution
+{
+public:
+ int maxProfit(vector<int> &prices)
+ {
+ if (prices.size() <= 1) return 0;
+
+ int result = 0;
+ int min = prices.front();
+ for (int i = 1; i < prices.size(); i++)
+ {
+ if (prices[i] - min > result)
+ result = prices[i] - min;
+ if (prices[i] < min)
+ min = prices[i];
+ }
+
+ return result;
+ }
+};
diff --git a/works/solutions/cpp/1219.cpp b/works/solutions/leetcode/cpp/1219.cpp index 5f72206..5f72206 100644 --- a/works/solutions/cpp/1219.cpp +++ b/works/solutions/leetcode/cpp/1219.cpp diff --git a/works/solutions/cpp/122.cpp b/works/solutions/leetcode/cpp/122.cpp index d468a23..68cd278 100644 --- a/works/solutions/cpp/122.cpp +++ b/works/solutions/leetcode/cpp/122.cpp @@ -1,28 +1,28 @@ -#include <vector> - -using std::vector; - -class Solution -{ -public: - int maxProfit(vector<int> &prices) - { - if (prices.size() <= 1) - return 0; - - int day_count = prices.size(); - - vector<vector<int>> dp(day_count, std::vector<int>(2)); - - dp[0][0] = 0; - dp[0][1] = -prices[0]; - - for (int i = 1; i < day_count; i++) - { - dp[i][0] = std::max(dp[i - 1][0], dp[i - 1][1] + prices[i]); - dp[i][1] = std::max(dp[i - 1][1], dp[i - 1][0] - prices[i]); - } - - return dp[day_count - 1][0]; - } -}; +#include <vector>
+
+using std::vector;
+
+class Solution
+{
+public:
+ int maxProfit(vector<int> &prices)
+ {
+ if (prices.size() <= 1)
+ return 0;
+
+ int day_count = prices.size();
+
+ vector<vector<int>> dp(day_count, std::vector<int>(2));
+
+ dp[0][0] = 0;
+ dp[0][1] = -prices[0];
+
+ for (int i = 1; i < day_count; i++)
+ {
+ dp[i][0] = std::max(dp[i - 1][0], dp[i - 1][1] + prices[i]);
+ dp[i][1] = std::max(dp[i - 1][1], dp[i - 1][0] - prices[i]);
+ }
+
+ return dp[day_count - 1][0];
+ }
+};
diff --git a/works/solutions/cpp/123.cpp b/works/solutions/leetcode/cpp/123.cpp index f4feff2..ecf35c4 100644 --- a/works/solutions/cpp/123.cpp +++ b/works/solutions/leetcode/cpp/123.cpp @@ -1,34 +1,34 @@ -#include <vector> -#include <iostream> -using std::vector; - -#include <algorithm> - -class Solution -{ -public: - // 0 -> after buy for the first time - // 1 -> after sell for the first time - // 2 -> after buy for the second time - // 3 -> after sell for the second time - - int maxProfit(vector<int> &prices) - { - int day_count = prices.size(); - - int state_0 = -prices[0]; - int state_1 = 0; - int state_2 = -prices[0]; - int state_3 = 0; - - for (int day = 1; day < day_count; day++) - { - state_0 = std::max(state_0, -prices[day]); - state_1 = std::max(state_1, state_0 + prices[day]); - state_2 = std::max(state_2, state_1 - prices[day]); - state_3 = std::max(state_3, state_2 + prices[day]); - } - - return std::max({state_0, state_1, state_2, state_3}); - } -}; +#include <vector>
+#include <iostream>
+using std::vector;
+
+#include <algorithm>
+
+class Solution
+{
+public:
+ // 0 -> after buy for the first time
+ // 1 -> after sell for the first time
+ // 2 -> after buy for the second time
+ // 3 -> after sell for the second time
+
+ int maxProfit(vector<int> &prices)
+ {
+ int day_count = prices.size();
+
+ int state_0 = -prices[0];
+ int state_1 = 0;
+ int state_2 = -prices[0];
+ int state_3 = 0;
+
+ for (int day = 1; day < day_count; day++)
+ {
+ state_0 = std::max(state_0, -prices[day]);
+ state_1 = std::max(state_1, state_0 + prices[day]);
+ state_2 = std::max(state_2, state_1 - prices[day]);
+ state_3 = std::max(state_3, state_2 + prices[day]);
+ }
+
+ return std::max({state_0, state_1, state_2, state_3});
+ }
+};
diff --git a/works/solutions/cpp/1286.cpp b/works/solutions/leetcode/cpp/1286.cpp index 1ad0d4e..1ad0d4e 100644 --- a/works/solutions/cpp/1286.cpp +++ b/works/solutions/leetcode/cpp/1286.cpp diff --git a/works/solutions/cpp/13.cpp b/works/solutions/leetcode/cpp/13.cpp index 486c01b..9b7c5df 100644 --- a/works/solutions/cpp/13.cpp +++ b/works/solutions/leetcode/cpp/13.cpp @@ -1,54 +1,54 @@ -#include <string> - -using std::string; - -int romanDigitNumber(char romanDigit) -{ - switch (romanDigit) - { - case 'I': - return 1; - case 'V': - return 5; - case 'X': - return 10; - case 'L': - return 50; - case 'C': - return 100; - case 'D': - return 500; - case 'M': - return 1000; - }; - return 0; -} - -class Solution -{ -public: - int romanToInt(string s) - { - int result = 0; - - int count = s.size(); - - for (int i = 0; i < count; i++) - { - const char c = s[i]; - int num = romanDigitNumber(c); - if (i < count - 1) - { - const char next = s[i + 1]; - if ((c == 'I' && (next == 'V' || next == 'X')) || (c == 'X' && (next == 'L' || next == 'C')) || (c == 'C') && (next == 'D' || next == 'M')) - { - num = -num; - } - } - - result += num; - } - - return result; - } -}; +#include <string>
+
+using std::string;
+
+int romanDigitNumber(char romanDigit)
+{
+ switch (romanDigit)
+ {
+ case 'I':
+ return 1;
+ case 'V':
+ return 5;
+ case 'X':
+ return 10;
+ case 'L':
+ return 50;
+ case 'C':
+ return 100;
+ case 'D':
+ return 500;
+ case 'M':
+ return 1000;
+ };
+ return 0;
+}
+
+class Solution
+{
+public:
+ int romanToInt(string s)
+ {
+ int result = 0;
+
+ int count = s.size();
+
+ for (int i = 0; i < count; i++)
+ {
+ const char c = s[i];
+ int num = romanDigitNumber(c);
+ if (i < count - 1)
+ {
+ const char next = s[i + 1];
+ if ((c == 'I' && (next == 'V' || next == 'X')) || (c == 'X' && (next == 'L' || next == 'C')) || (c == 'C') && (next == 'D' || next == 'M'))
+ {
+ num = -num;
+ }
+ }
+
+ result += num;
+ }
+
+ return result;
+ }
+};
diff --git a/works/solutions/cpp/1343.cpp b/works/solutions/leetcode/cpp/1343.cpp index 24bb762..b300bc7 100644 --- a/works/solutions/cpp/1343.cpp +++ b/works/solutions/leetcode/cpp/1343.cpp @@ -1,40 +1,40 @@ -#include <vector> - -using std::vector; - -class Solution -{ -public: - int numOfSubarrays(vector<int> &arr, int k, int threshold) - { - const auto end = arr.cend(); - auto iter = arr.cbegin(); - auto last_iter = arr.cbegin(); - - double sum = 0; - - int result = 0; - - for (int i = 0; i < k; i++) - { - sum += *iter++; - } - - while (iter != end) - { - if (sum / k >= threshold) - { - result++; - } - sum -= *last_iter++; - sum += *iter++; - } - - if (sum / k >= threshold) - { - result++; - } - - return result; - } -}; +#include <vector>
+
+using std::vector;
+
+class Solution
+{
+public:
+ int numOfSubarrays(vector<int> &arr, int k, int threshold)
+ {
+ const auto end = arr.cend();
+ auto iter = arr.cbegin();
+ auto last_iter = arr.cbegin();
+
+ double sum = 0;
+
+ int result = 0;
+
+ for (int i = 0; i < k; i++)
+ {
+ sum += *iter++;
+ }
+
+ while (iter != end)
+ {
+ if (sum / k >= threshold)
+ {
+ result++;
+ }
+ sum -= *last_iter++;
+ sum += *iter++;
+ }
+
+ if (sum / k >= threshold)
+ {
+ result++;
+ }
+
+ return result;
+ }
+};
diff --git a/works/solutions/cpp/1347.cpp b/works/solutions/leetcode/cpp/1347.cpp index 154a6b5..154a6b5 100644 --- a/works/solutions/cpp/1347.cpp +++ b/works/solutions/leetcode/cpp/1347.cpp diff --git a/works/solutions/cpp/1370.cpp b/works/solutions/leetcode/cpp/1370.cpp index 9741d48..9741d48 100644 --- a/works/solutions/cpp/1370.cpp +++ b/works/solutions/leetcode/cpp/1370.cpp diff --git a/works/solutions/cpp/14.cpp b/works/solutions/leetcode/cpp/14.cpp index c1619b8..1d07a60 100644 --- a/works/solutions/cpp/14.cpp +++ b/works/solutions/leetcode/cpp/14.cpp @@ -1,35 +1,35 @@ -#include <string> -#include <vector> - -using std::string; -using std::vector; - -class Solution -{ -public: - string longestCommonPrefix(vector<string> &strs) - { - if (strs.empty()) - return ""; - - string result; - - const auto &first = strs.front(); - - for (int i = 0; i < first.size(); i++) - { - char c = first[i]; - - for (int j = 1; j < strs.size(); j++) - { - if (strs[j][i] != c) - goto r; - } - - result.push_back(c); - } - - r: - return result; - } -}; +#include <string>
+#include <vector>
+
+using std::string;
+using std::vector;
+
+class Solution
+{
+public:
+ string longestCommonPrefix(vector<string> &strs)
+ {
+ if (strs.empty())
+ return "";
+
+ string result;
+
+ const auto &first = strs.front();
+
+ for (int i = 0; i < first.size(); i++)
+ {
+ char c = first[i];
+
+ for (int j = 1; j < strs.size(); j++)
+ {
+ if (strs[j][i] != c)
+ goto r;
+ }
+
+ result.push_back(c);
+ }
+
+ r:
+ return result;
+ }
+};
diff --git a/works/solutions/cpp/147.cpp b/works/solutions/leetcode/cpp/147.cpp index c741290..c741290 100644 --- a/works/solutions/cpp/147.cpp +++ b/works/solutions/leetcode/cpp/147.cpp diff --git a/works/solutions/cpp/1470.cpp b/works/solutions/leetcode/cpp/1470.cpp index 8657dd6..8657dd6 100644 --- a/works/solutions/cpp/1470.cpp +++ b/works/solutions/leetcode/cpp/1470.cpp diff --git a/works/solutions/cpp/155-2.cpp b/works/solutions/leetcode/cpp/155-2.cpp index aa07eee..aa07eee 100644 --- a/works/solutions/cpp/155-2.cpp +++ b/works/solutions/leetcode/cpp/155-2.cpp diff --git a/works/solutions/cpp/155.cpp b/works/solutions/leetcode/cpp/155.cpp index 48550be..48550be 100644 --- a/works/solutions/cpp/155.cpp +++ b/works/solutions/leetcode/cpp/155.cpp diff --git a/works/solutions/cpp/1609.cpp b/works/solutions/leetcode/cpp/1609.cpp index e446c0f..e446c0f 100644 --- a/works/solutions/cpp/1609.cpp +++ b/works/solutions/leetcode/cpp/1609.cpp diff --git a/works/solutions/cpp/167.cpp b/works/solutions/leetcode/cpp/167.cpp index 05317b4..05317b4 100644 --- a/works/solutions/cpp/167.cpp +++ b/works/solutions/leetcode/cpp/167.cpp diff --git a/works/solutions/cpp/17.04.cpp b/works/solutions/leetcode/cpp/17.04.cpp index 07ac7ae..07ac7ae 100644 --- a/works/solutions/cpp/17.04.cpp +++ b/works/solutions/leetcode/cpp/17.04.cpp diff --git a/works/solutions/cpp/17.cpp b/works/solutions/leetcode/cpp/17.cpp index 74e33b4..74e33b4 100644 --- a/works/solutions/cpp/17.cpp +++ b/works/solutions/leetcode/cpp/17.cpp diff --git a/works/solutions/cpp/198.cpp b/works/solutions/leetcode/cpp/198.cpp index eee0929..4d9d4fc 100644 --- a/works/solutions/cpp/198.cpp +++ b/works/solutions/leetcode/cpp/198.cpp @@ -1,26 +1,26 @@ -#include <vector> - -using std::vector; - -class Solution -{ -public: - int rob(vector<int> &nums) - { - int count = nums.size(); - if (count == 0) - return 0; - - int not_rob_prev = 0; - int rob_prev = nums.front(); - - for (int i = 1; i < count; i++) - { - int not_rob_prev_cache = not_rob_prev; - not_rob_prev = std::max(not_rob_prev_cache, rob_prev); - rob_prev = std::max(not_rob_prev_cache + nums[i], not_rob_prev); - } - - return rob_prev; - } -}; +#include <vector>
+
+using std::vector;
+
+class Solution
+{
+public:
+ int rob(vector<int> &nums)
+ {
+ int count = nums.size();
+ if (count == 0)
+ return 0;
+
+ int not_rob_prev = 0;
+ int rob_prev = nums.front();
+
+ for (int i = 1; i < count; i++)
+ {
+ int not_rob_prev_cache = not_rob_prev;
+ not_rob_prev = std::max(not_rob_prev_cache, rob_prev);
+ rob_prev = std::max(not_rob_prev_cache + nums[i], not_rob_prev);
+ }
+
+ return rob_prev;
+ }
+};
diff --git a/works/solutions/cpp/2.cpp b/works/solutions/leetcode/cpp/2.cpp index cb954ae..cb954ae 100644 --- a/works/solutions/cpp/2.cpp +++ b/works/solutions/leetcode/cpp/2.cpp diff --git a/works/solutions/cpp/20.cpp b/works/solutions/leetcode/cpp/20.cpp index e994e96..e994e96 100644 --- a/works/solutions/cpp/20.cpp +++ b/works/solutions/leetcode/cpp/20.cpp diff --git a/works/solutions/cpp/203.cpp b/works/solutions/leetcode/cpp/203.cpp index 0f1bb55..0f1bb55 100644 --- a/works/solutions/cpp/203.cpp +++ b/works/solutions/leetcode/cpp/203.cpp diff --git a/works/solutions/cpp/213.cpp b/works/solutions/leetcode/cpp/213.cpp index 1414222..cd98f67 100644 --- a/works/solutions/cpp/213.cpp +++ b/works/solutions/leetcode/cpp/213.cpp @@ -1,41 +1,41 @@ -#include <vector> - -using std::vector; - -class Solution -{ -public: - int rob(vector<int> &nums) - { - int count = nums.size(); - if (count == 0) - return 0; - - if (count == 1) - return nums.front(); - - int not_rob_prev = 0; - int rob_prev = nums.front(); - int not_rob_prev_and_not_rob_first = 0; - int rob_prev_and_not_rob_first = 0; - - for (int i = 1; i < count - 1; i++) - { - int not_rob_prev_cache = not_rob_prev; - int not_rob_prev_and_not_rob_first_cache = not_rob_prev_and_not_rob_first; - not_rob_prev = std::max(not_rob_prev_cache, rob_prev); - rob_prev = std::max(not_rob_prev_cache + nums[i], not_rob_prev); - not_rob_prev_and_not_rob_first = std::max(not_rob_prev_and_not_rob_first_cache, rob_prev_and_not_rob_first); - rob_prev_and_not_rob_first = std::max(not_rob_prev_and_not_rob_first_cache + nums[i], not_rob_prev_and_not_rob_first); - } - - // last houst - { - int not_rob_prev_and_not_rob_first_cache = not_rob_prev_and_not_rob_first; - not_rob_prev_and_not_rob_first = std::max(not_rob_prev_and_not_rob_first_cache, rob_prev_and_not_rob_first); - rob_prev_and_not_rob_first = std::max(not_rob_prev_and_not_rob_first_cache + nums[count - 1], not_rob_prev_and_not_rob_first); - } - - return std::max(rob_prev, rob_prev_and_not_rob_first); - } -}; +#include <vector>
+
+using std::vector;
+
+class Solution
+{
+public:
+ int rob(vector<int> &nums)
+ {
+ int count = nums.size();
+ if (count == 0)
+ return 0;
+
+ if (count == 1)
+ return nums.front();
+
+ int not_rob_prev = 0;
+ int rob_prev = nums.front();
+ int not_rob_prev_and_not_rob_first = 0;
+ int rob_prev_and_not_rob_first = 0;
+
+ for (int i = 1; i < count - 1; i++)
+ {
+ int not_rob_prev_cache = not_rob_prev;
+ int not_rob_prev_and_not_rob_first_cache = not_rob_prev_and_not_rob_first;
+ not_rob_prev = std::max(not_rob_prev_cache, rob_prev);
+ rob_prev = std::max(not_rob_prev_cache + nums[i], not_rob_prev);
+ not_rob_prev_and_not_rob_first = std::max(not_rob_prev_and_not_rob_first_cache, rob_prev_and_not_rob_first);
+ rob_prev_and_not_rob_first = std::max(not_rob_prev_and_not_rob_first_cache + nums[i], not_rob_prev_and_not_rob_first);
+ }
+
+ // last houst
+ {
+ int not_rob_prev_and_not_rob_first_cache = not_rob_prev_and_not_rob_first;
+ not_rob_prev_and_not_rob_first = std::max(not_rob_prev_and_not_rob_first_cache, rob_prev_and_not_rob_first);
+ rob_prev_and_not_rob_first = std::max(not_rob_prev_and_not_rob_first_cache + nums[count - 1], not_rob_prev_and_not_rob_first);
+ }
+
+ return std::max(rob_prev, rob_prev_and_not_rob_first);
+ }
+};
diff --git a/works/solutions/cpp/22.cpp b/works/solutions/leetcode/cpp/22.cpp index e9467f1..e9467f1 100644 --- a/works/solutions/cpp/22.cpp +++ b/works/solutions/leetcode/cpp/22.cpp diff --git a/works/solutions/cpp/231.cpp b/works/solutions/leetcode/cpp/231.cpp index 8861e09..8861e09 100644 --- a/works/solutions/cpp/231.cpp +++ b/works/solutions/leetcode/cpp/231.cpp diff --git a/works/solutions/cpp/26.cpp b/works/solutions/leetcode/cpp/26.cpp index 3ee4aa7..3ee4aa7 100644 --- a/works/solutions/cpp/26.cpp +++ b/works/solutions/leetcode/cpp/26.cpp diff --git a/works/solutions/cpp/260-2.cpp b/works/solutions/leetcode/cpp/260-2.cpp index 336d9e1..336d9e1 100644 --- a/works/solutions/cpp/260-2.cpp +++ b/works/solutions/leetcode/cpp/260-2.cpp diff --git a/works/solutions/cpp/260.cpp b/works/solutions/leetcode/cpp/260.cpp index 5679d52..5679d52 100644 --- a/works/solutions/cpp/260.cpp +++ b/works/solutions/leetcode/cpp/260.cpp diff --git a/works/solutions/cpp/299.cpp b/works/solutions/leetcode/cpp/299.cpp index 21c09b6..21c09b6 100644 --- a/works/solutions/cpp/299.cpp +++ b/works/solutions/leetcode/cpp/299.cpp diff --git a/works/solutions/cpp/303.cpp b/works/solutions/leetcode/cpp/303.cpp index 74aea3c..06c4ad1 100644 --- a/works/solutions/cpp/303.cpp +++ b/works/solutions/leetcode/cpp/303.cpp @@ -1,26 +1,26 @@ -#include <vector> - -using std::vector; - -class NumArray -{ -private: - vector<int> prefix_sums; - -public: - NumArray(vector<int> &nums) - { - prefix_sums.push_back(0); - int sum = 0; - for (auto num : nums) - { - sum += num; - prefix_sums.push_back(sum); - } - } - - int sumRange(int i, int j) - { - return prefix_sums[j + 1] - prefix_sums[i]; - } -}; +#include <vector>
+
+using std::vector;
+
+class NumArray
+{
+private:
+ vector<int> prefix_sums;
+
+public:
+ NumArray(vector<int> &nums)
+ {
+ prefix_sums.push_back(0);
+ int sum = 0;
+ for (auto num : nums)
+ {
+ sum += num;
+ prefix_sums.push_back(sum);
+ }
+ }
+
+ int sumRange(int i, int j)
+ {
+ return prefix_sums[j + 1] - prefix_sums[i];
+ }
+};
diff --git a/works/solutions/cpp/328.cpp b/works/solutions/leetcode/cpp/328.cpp index de3ad0b..de3ad0b 100644 --- a/works/solutions/cpp/328.cpp +++ b/works/solutions/leetcode/cpp/328.cpp diff --git a/works/solutions/cpp/337.cpp b/works/solutions/leetcode/cpp/337.cpp index 655a4d0..655a4d0 100644 --- a/works/solutions/cpp/337.cpp +++ b/works/solutions/leetcode/cpp/337.cpp diff --git a/works/solutions/cpp/338.cpp b/works/solutions/leetcode/cpp/338.cpp index 3b32da4..1758234 100644 --- a/works/solutions/cpp/338.cpp +++ b/works/solutions/leetcode/cpp/338.cpp @@ -1,26 +1,26 @@ -#include <vector> - -using std::vector; - -class Solution -{ -public: - vector<int> countBits(int num) - { - vector<int> result(num + 1); - result[0] = 0; - for (int i = 1; i <= num; i++) - { - if (i % 2 == 1) - { - result[i] = result[i - 1] + 1; - } - else - { - result[i] = result[i / 2]; - } - } - - return result; - } -}; +#include <vector>
+
+using std::vector;
+
+class Solution
+{
+public:
+ vector<int> countBits(int num)
+ {
+ vector<int> result(num + 1);
+ result[0] = 0;
+ for (int i = 1; i <= num; i++)
+ {
+ if (i % 2 == 1)
+ {
+ result[i] = result[i - 1] + 1;
+ }
+ else
+ {
+ result[i] = result[i / 2];
+ }
+ }
+
+ return result;
+ }
+};
diff --git a/works/solutions/cpp/343.cpp b/works/solutions/leetcode/cpp/343.cpp index d31f7ce..d31f7ce 100644 --- a/works/solutions/cpp/343.cpp +++ b/works/solutions/leetcode/cpp/343.cpp diff --git a/works/solutions/cpp/35.cpp b/works/solutions/leetcode/cpp/35.cpp index 7da26c4..7da26c4 100644 --- a/works/solutions/cpp/35.cpp +++ b/works/solutions/leetcode/cpp/35.cpp diff --git a/works/solutions/cpp/397.cpp b/works/solutions/leetcode/cpp/397.cpp index bbb61ff..bbb61ff 100644 --- a/works/solutions/cpp/397.cpp +++ b/works/solutions/leetcode/cpp/397.cpp diff --git a/works/solutions/cpp/401.cpp b/works/solutions/leetcode/cpp/401.cpp index 71147f4..71147f4 100644 --- a/works/solutions/cpp/401.cpp +++ b/works/solutions/leetcode/cpp/401.cpp diff --git a/works/solutions/cpp/46.cpp b/works/solutions/leetcode/cpp/46.cpp index bfb3c83..bfb3c83 100644 --- a/works/solutions/cpp/46.cpp +++ b/works/solutions/leetcode/cpp/46.cpp diff --git a/works/solutions/cpp/495.cpp b/works/solutions/leetcode/cpp/495.cpp index c940b0b..c940b0b 100644 --- a/works/solutions/cpp/495.cpp +++ b/works/solutions/leetcode/cpp/495.cpp diff --git a/works/solutions/cpp/5.cpp b/works/solutions/leetcode/cpp/5.cpp index 8800321..6200c4c 100644 --- a/works/solutions/cpp/5.cpp +++ b/works/solutions/leetcode/cpp/5.cpp @@ -1,104 +1,104 @@ -#include <string> - -using std::string; - -class Solution -{ -public: - void longestWithCenter(const string &s, int length, int index, int *longest_start, int *longest_length_ptr) - { - int &longest_length = *longest_length_ptr; - - int palindrome_length_odd = index * 2 + 1 <= longest_length || (length - index - 1) * 2 + 1 <= longest_length ? 0 : 1; - int palindrome_length_even = (index + 1) * 2 <= longest_length || (length - index - 1) * 2 <= longest_length ? 0 : 1; - - while (palindrome_length_odd || palindrome_length_even) - { - if (palindrome_length_odd) - { - int start = index - palindrome_length_odd; - int end = index + palindrome_length_odd; - if (start < 0) - { - palindrome_length_odd = 0; - } - else if (end >= length) - { - palindrome_length_odd = 0; - } - else - { - if (s[start] == s[end]) - { - int current_length = end - start + 1; - if (current_length > longest_length) - { - *longest_start = start; - longest_length = current_length; - } - palindrome_length_odd++; - } - else - { - palindrome_length_odd = 0; - } - } - } - - if (palindrome_length_even) - { - int start = index - palindrome_length_even + 1; - int end = index + palindrome_length_even; - if (start < 0) - { - palindrome_length_even = 0; - } - else if (end >= length) - { - palindrome_length_even = 0; - } - else - { - if (s[start] == s[end]) - { - int current_length = end - start + 1; - if (current_length > longest_length) - { - *longest_start = start; - longest_length = current_length; - } - palindrome_length_even++; - } - else - { - palindrome_length_even = 0; - } - } - } - } - } - - string longestPalindrome(string s) - { - if (s.empty()) - return ""; - - int longest_start = 0; - int longest_length = 1; - int length = s.size(); - - for (int i = 0; i < length; i++) - { - longestWithCenter(s, length, i, &longest_start, &longest_length); - } - - return s.substr(longest_start, longest_length); - } -}; - -int main() -{ - Solution s{}; - s.longestPalindrome("bb"); - return 0; -} +#include <string>
+
+using std::string;
+
+class Solution
+{
+public:
+ void longestWithCenter(const string &s, int length, int index, int *longest_start, int *longest_length_ptr)
+ {
+ int &longest_length = *longest_length_ptr;
+
+ int palindrome_length_odd = index * 2 + 1 <= longest_length || (length - index - 1) * 2 + 1 <= longest_length ? 0 : 1;
+ int palindrome_length_even = (index + 1) * 2 <= longest_length || (length - index - 1) * 2 <= longest_length ? 0 : 1;
+
+ while (palindrome_length_odd || palindrome_length_even)
+ {
+ if (palindrome_length_odd)
+ {
+ int start = index - palindrome_length_odd;
+ int end = index + palindrome_length_odd;
+ if (start < 0)
+ {
+ palindrome_length_odd = 0;
+ }
+ else if (end >= length)
+ {
+ palindrome_length_odd = 0;
+ }
+ else
+ {
+ if (s[start] == s[end])
+ {
+ int current_length = end - start + 1;
+ if (current_length > longest_length)
+ {
+ *longest_start = start;
+ longest_length = current_length;
+ }
+ palindrome_length_odd++;
+ }
+ else
+ {
+ palindrome_length_odd = 0;
+ }
+ }
+ }
+
+ if (palindrome_length_even)
+ {
+ int start = index - palindrome_length_even + 1;
+ int end = index + palindrome_length_even;
+ if (start < 0)
+ {
+ palindrome_length_even = 0;
+ }
+ else if (end >= length)
+ {
+ palindrome_length_even = 0;
+ }
+ else
+ {
+ if (s[start] == s[end])
+ {
+ int current_length = end - start + 1;
+ if (current_length > longest_length)
+ {
+ *longest_start = start;
+ longest_length = current_length;
+ }
+ palindrome_length_even++;
+ }
+ else
+ {
+ palindrome_length_even = 0;
+ }
+ }
+ }
+ }
+ }
+
+ string longestPalindrome(string s)
+ {
+ if (s.empty())
+ return "";
+
+ int longest_start = 0;
+ int longest_length = 1;
+ int length = s.size();
+
+ for (int i = 0; i < length; i++)
+ {
+ longestWithCenter(s, length, i, &longest_start, &longest_length);
+ }
+
+ return s.substr(longest_start, longest_length);
+ }
+};
+
+int main()
+{
+ Solution s{};
+ s.longestPalindrome("bb");
+ return 0;
+}
diff --git a/works/solutions/cpp/501.cpp b/works/solutions/leetcode/cpp/501.cpp index 197ed10..197ed10 100644 --- a/works/solutions/cpp/501.cpp +++ b/works/solutions/leetcode/cpp/501.cpp diff --git a/works/solutions/cpp/526.cpp b/works/solutions/leetcode/cpp/526.cpp index 19f445f..19f445f 100644 --- a/works/solutions/cpp/526.cpp +++ b/works/solutions/leetcode/cpp/526.cpp diff --git a/works/solutions/cpp/543.cpp b/works/solutions/leetcode/cpp/543.cpp index f782521..f782521 100644 --- a/works/solutions/cpp/543.cpp +++ b/works/solutions/leetcode/cpp/543.cpp diff --git a/works/solutions/cpp/55.cpp b/works/solutions/leetcode/cpp/55.cpp index d2c2600..d2c2600 100644 --- a/works/solutions/cpp/55.cpp +++ b/works/solutions/leetcode/cpp/55.cpp diff --git a/works/solutions/cpp/6.cpp b/works/solutions/leetcode/cpp/6.cpp index f1d947c..f1d947c 100644 --- a/works/solutions/cpp/6.cpp +++ b/works/solutions/leetcode/cpp/6.cpp diff --git a/works/solutions/cpp/60.cpp b/works/solutions/leetcode/cpp/60.cpp index f090355..f090355 100644 --- a/works/solutions/cpp/60.cpp +++ b/works/solutions/leetcode/cpp/60.cpp diff --git a/works/solutions/cpp/62.cpp b/works/solutions/leetcode/cpp/62.cpp index 042b274..744a0d3 100644 --- a/works/solutions/cpp/62.cpp +++ b/works/solutions/leetcode/cpp/62.cpp @@ -1,25 +1,25 @@ -#include <utility> - -class Solution -{ -public: - // C(m + n - 2, m - 1) - int uniquePaths(int m, int n) - { - if (m < n) - std::swap(m, n); - - long long result = 1; - for (int i = m; i <= m + n - 2; i++) - { - result *= i; - } - - for (int i = 2; i <= n - 1; i++) - { - result /= i; - } - - return result; - } -}; +#include <utility>
+
+class Solution
+{
+public:
+ // C(m + n - 2, m - 1)
+ int uniquePaths(int m, int n)
+ {
+ if (m < n)
+ std::swap(m, n);
+
+ long long result = 1;
+ for (int i = m; i <= m + n - 2; i++)
+ {
+ result *= i;
+ }
+
+ for (int i = 2; i <= n - 1; i++)
+ {
+ result /= i;
+ }
+
+ return result;
+ }
+};
diff --git a/works/solutions/cpp/63.cpp b/works/solutions/leetcode/cpp/63.cpp index 8e01c44..ed07bdc 100644 --- a/works/solutions/cpp/63.cpp +++ b/works/solutions/leetcode/cpp/63.cpp @@ -1,44 +1,44 @@ -#include <vector> - -using std::vector; - -class Solution -{ -public: - int uniquePathsWithObstacles(vector<vector<int>> &obstacleGrid) - { - if (obstacleGrid[0][0]) - return 0; - obstacleGrid[0][0] = 1; - - int row = obstacleGrid.size(); - int col = obstacleGrid.front().size(); - - for (int i = 1; i < row; i++) - { - obstacleGrid[i][0] = obstacleGrid[i - 1][0] && !obstacleGrid[i][0] ? 1 : 0; - } - - for (int i = 1; i < col; i++) - { - obstacleGrid[0][i] = obstacleGrid[0][i - 1] && !obstacleGrid[0][i] ? 1 : 0; - } - - for (int r = 1; r < row; r++) - { - for (int c = 1; c < col; c++) - { - if (obstacleGrid[r][c]) - { - obstacleGrid[r][c] = 0; - } - else - { - obstacleGrid[r][c] = obstacleGrid[r - 1][c] + obstacleGrid[r][c - 1]; - } - } - } - - return obstacleGrid[row - 1][col - 1]; - } -}; +#include <vector>
+
+using std::vector;
+
+class Solution
+{
+public:
+ int uniquePathsWithObstacles(vector<vector<int>> &obstacleGrid)
+ {
+ if (obstacleGrid[0][0])
+ return 0;
+ obstacleGrid[0][0] = 1;
+
+ int row = obstacleGrid.size();
+ int col = obstacleGrid.front().size();
+
+ for (int i = 1; i < row; i++)
+ {
+ obstacleGrid[i][0] = obstacleGrid[i - 1][0] && !obstacleGrid[i][0] ? 1 : 0;
+ }
+
+ for (int i = 1; i < col; i++)
+ {
+ obstacleGrid[0][i] = obstacleGrid[0][i - 1] && !obstacleGrid[0][i] ? 1 : 0;
+ }
+
+ for (int r = 1; r < row; r++)
+ {
+ for (int c = 1; c < col; c++)
+ {
+ if (obstacleGrid[r][c])
+ {
+ obstacleGrid[r][c] = 0;
+ }
+ else
+ {
+ obstacleGrid[r][c] = obstacleGrid[r - 1][c] + obstacleGrid[r][c - 1];
+ }
+ }
+ }
+
+ return obstacleGrid[row - 1][col - 1];
+ }
+};
diff --git a/works/solutions/cpp/641.cpp b/works/solutions/leetcode/cpp/641.cpp index 0235797..0235797 100644 --- a/works/solutions/cpp/641.cpp +++ b/works/solutions/leetcode/cpp/641.cpp diff --git a/works/solutions/cpp/649.cpp b/works/solutions/leetcode/cpp/649.cpp index ab702d2..ab702d2 100644 --- a/works/solutions/cpp/649.cpp +++ b/works/solutions/leetcode/cpp/649.cpp diff --git a/works/solutions/cpp/66.cpp b/works/solutions/leetcode/cpp/66.cpp index 40ce008..40ce008 100644 --- a/works/solutions/cpp/66.cpp +++ b/works/solutions/leetcode/cpp/66.cpp diff --git a/works/solutions/cpp/680.cpp b/works/solutions/leetcode/cpp/680.cpp index 21d150f..21d150f 100644 --- a/works/solutions/cpp/680.cpp +++ b/works/solutions/leetcode/cpp/680.cpp diff --git a/works/solutions/cpp/7.cpp b/works/solutions/leetcode/cpp/7.cpp index a1a05c1..a1a05c1 100644 --- a/works/solutions/cpp/7.cpp +++ b/works/solutions/leetcode/cpp/7.cpp diff --git a/works/solutions/cpp/704.cpp b/works/solutions/leetcode/cpp/704.cpp index b56a01a..b56a01a 100644 --- a/works/solutions/cpp/704.cpp +++ b/works/solutions/leetcode/cpp/704.cpp diff --git a/works/solutions/cpp/74.cpp b/works/solutions/leetcode/cpp/74.cpp index 08560ef..08560ef 100644 --- a/works/solutions/cpp/74.cpp +++ b/works/solutions/leetcode/cpp/74.cpp diff --git a/works/solutions/cpp/746.cpp b/works/solutions/leetcode/cpp/746.cpp index aea1891..72ffd9f 100644 --- a/works/solutions/cpp/746.cpp +++ b/works/solutions/leetcode/cpp/746.cpp @@ -1,35 +1,35 @@ -#include <vector> - -using std::vector; - -#include <algorithm> - -class Solution -{ -public: - int minCostClimbingStairs(vector<int> &cost) - { - int count = cost.size(); - - // Total cost for index i means min cost of stepping through the number i stair, - // after which you are free to jump two or one stair. - // total_costs[i] is based on total_costs[i - 2] and total_costs[i - 1]. - // Note: - // This is not min cost to step above the number i stair, which has no simple dependency - // relationship because based on whether it steps through the last step there are two situation. - // However with the restriction of stepping through that last stair, there is a - // dependency relationship. And we can easily get the final result by comparing total_costs[count - 2] - // and total_costs[count - 1]. But not just use total_costs[count - 1]. - vector<int> total_costs(count); - - total_costs[0] = cost[0]; - total_costs[1] = cost[1]; - - for (int i = 2; i < count; i++) - { - total_costs[i] = std::min(total_costs[i - 2], total_costs[i - 1]) + cost[i]; - } - - return std::min(total_costs[count - 2], total_costs[count - 1]); - } -}; +#include <vector>
+
+using std::vector;
+
+#include <algorithm>
+
+class Solution
+{
+public:
+ int minCostClimbingStairs(vector<int> &cost)
+ {
+ int count = cost.size();
+
+ // Total cost for index i means min cost of stepping through the number i stair,
+ // after which you are free to jump two or one stair.
+ // total_costs[i] is based on total_costs[i - 2] and total_costs[i - 1].
+ // Note:
+ // This is not min cost to step above the number i stair, which has no simple dependency
+ // relationship because based on whether it steps through the last step there are two situation.
+ // However with the restriction of stepping through that last stair, there is a
+ // dependency relationship. And we can easily get the final result by comparing total_costs[count - 2]
+ // and total_costs[count - 1]. But not just use total_costs[count - 1].
+ vector<int> total_costs(count);
+
+ total_costs[0] = cost[0];
+ total_costs[1] = cost[1];
+
+ for (int i = 2; i < count; i++)
+ {
+ total_costs[i] = std::min(total_costs[i - 2], total_costs[i - 1]) + cost[i];
+ }
+
+ return std::min(total_costs[count - 2], total_costs[count - 1]);
+ }
+};
diff --git a/works/solutions/cpp/766-2.cpp b/works/solutions/leetcode/cpp/766-2.cpp index 79a0cc8..79a0cc8 100644 --- a/works/solutions/cpp/766-2.cpp +++ b/works/solutions/leetcode/cpp/766-2.cpp diff --git a/works/solutions/cpp/766.cpp b/works/solutions/leetcode/cpp/766.cpp index 3e8a015..3e8a015 100644 --- a/works/solutions/cpp/766.cpp +++ b/works/solutions/leetcode/cpp/766.cpp diff --git a/works/solutions/cpp/77.cpp b/works/solutions/leetcode/cpp/77.cpp index ec09198..ec09198 100644 --- a/works/solutions/cpp/77.cpp +++ b/works/solutions/leetcode/cpp/77.cpp diff --git a/works/solutions/cpp/86.cpp b/works/solutions/leetcode/cpp/86.cpp index 1f7568c..1f7568c 100644 --- a/works/solutions/cpp/86.cpp +++ b/works/solutions/leetcode/cpp/86.cpp diff --git a/works/solutions/cpp/865.cpp b/works/solutions/leetcode/cpp/865.cpp index 8981a02..8981a02 100644 --- a/works/solutions/cpp/865.cpp +++ b/works/solutions/leetcode/cpp/865.cpp diff --git a/works/solutions/cpp/897.cpp b/works/solutions/leetcode/cpp/897.cpp index 720847b..efc9741 100644 --- a/works/solutions/cpp/897.cpp +++ b/works/solutions/leetcode/cpp/897.cpp @@ -1,37 +1,37 @@ -/** - * Definition for a binary tree node. - * struct TreeNode { - * int val; - * TreeNode *left; - * TreeNode *right; - * TreeNode(int x) : val(x), left(NULL), right(NULL) {} - * }; - */ -class Solution { -public: - std::vector<TreeNode*> result; - - void InOrderTraverse(TreeNode* root) { - if (root->left != nullptr) - InOrderTraverse(root->left); - result.push_back(root); - if (root->right != nullptr) - InOrderTraverse(root->right); - } - - TreeNode* increasingBST(TreeNode* root) { - InOrderTraverse(root); - - const auto end = result.end(); - auto iter1 = result.begin(); - auto iter2 = result.begin() + 1; - for (; iter2 != end; ++iter1, ++iter2) { - const auto node = *iter1; - node->left = NULL; - node->right = *iter2; - } - (*iter1)->left = (*iter1)->right = NULL; - - return result.front(); - } -}; +/**
+ * Definition for a binary tree node.
+ * struct TreeNode {
+ * int val;
+ * TreeNode *left;
+ * TreeNode *right;
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
+ * };
+ */
+class Solution {
+public:
+ std::vector<TreeNode*> result;
+
+ void InOrderTraverse(TreeNode* root) {
+ if (root->left != nullptr)
+ InOrderTraverse(root->left);
+ result.push_back(root);
+ if (root->right != nullptr)
+ InOrderTraverse(root->right);
+ }
+
+ TreeNode* increasingBST(TreeNode* root) {
+ InOrderTraverse(root);
+
+ const auto end = result.end();
+ auto iter1 = result.begin();
+ auto iter2 = result.begin() + 1;
+ for (; iter2 != end; ++iter1, ++iter2) {
+ const auto node = *iter1;
+ node->left = NULL;
+ node->right = *iter2;
+ }
+ (*iter1)->left = (*iter1)->right = NULL;
+
+ return result.front();
+ }
+};
diff --git a/works/solutions/cpp/917.cpp b/works/solutions/leetcode/cpp/917.cpp index d01d795..d01d795 100644 --- a/works/solutions/cpp/917.cpp +++ b/works/solutions/leetcode/cpp/917.cpp diff --git a/works/solutions/cpp/96.cpp b/works/solutions/leetcode/cpp/96.cpp index a67a59a..3757baa 100644 --- a/works/solutions/cpp/96.cpp +++ b/works/solutions/leetcode/cpp/96.cpp @@ -1,14 +1,14 @@ -class Solution { -public: - // catalan number: - // f(n) = f(0) * f(n-1) + f(1) * f(n-2) + ... + f(n-1)*f(0) - // f(n) = 2(2n-1) * f(n-1) / (n+1) - // f(n) = C(2n, n) / (n+1) - int numTrees(int n) { - long long result = 1; - for (int i = 2; i <= n; i++) { - result = 2 * (2 * i - 1) * result / (i + 1); - } - return result; - } -}; +class Solution {
+public:
+ // catalan number:
+ // f(n) = f(0) * f(n-1) + f(1) * f(n-2) + ... + f(n-1)*f(0)
+ // f(n) = 2(2n-1) * f(n-1) / (n+1)
+ // f(n) = C(2n, n) / (n+1)
+ int numTrees(int n) {
+ long long result = 1;
+ for (int i = 2; i <= n; i++) {
+ result = 2 * (2 * i - 1) * result / (i + 1);
+ }
+ return result;
+ }
+};
diff --git a/works/solutions/cpp/965.cpp b/works/solutions/leetcode/cpp/965.cpp index fd2bff6..fd2bff6 100644 --- a/works/solutions/cpp/965.cpp +++ b/works/solutions/leetcode/cpp/965.cpp diff --git a/works/solutions/cpp/968.cpp b/works/solutions/leetcode/cpp/968.cpp index 4feecf6..c9e6b24 100644 --- a/works/solutions/cpp/968.cpp +++ b/works/solutions/leetcode/cpp/968.cpp @@ -1,63 +1,63 @@ -#include <cstddef> - -struct TreeNode -{ - int val; - TreeNode *left; - TreeNode *right; - TreeNode(int x) : val(x), left(NULL), right(NULL) {} -}; - -#include <algorithm> - -struct Result -{ - // root_camera >= root_monitored >= root_not_monitored - int root_camera; - int root_monitored; - int root_not_monitored; -}; - -class Solution -{ -public: - Result dfs(TreeNode *root) - { - if (root->left == nullptr && root->right == nullptr) - { - return Result{1, 1, 0}; - } - - if (root->left == nullptr || root->right == nullptr) - { - TreeNode *child_node = root->left == nullptr ? root->right : root->left; - Result child = dfs(child_node); - - int root_camera = 1 + child.root_not_monitored; - int root_monitored = std::min({child.root_camera, - root_camera}); - int root_not_monitored = std::min(child.root_monitored, root_monitored); - - return Result{ - root_camera, root_monitored, root_not_monitored}; - } - - Result left = dfs(root->left); - Result right = dfs(root->right); - - int root_camera = 1 + left.root_not_monitored + right.root_not_monitored; - int root_monitored = std::min({left.root_camera + right.root_monitored, - left.root_monitored + right.root_camera, - root_camera}); - int root_not_monitored = std::min({left.root_monitored + right.root_monitored, root_monitored}); - - return Result{ - root_camera, root_monitored, root_not_monitored}; - } - - int minCameraCover(TreeNode *root) - { - auto result = dfs(root); - return result.root_monitored; - } +#include <cstddef>
+
+struct TreeNode
+{
+ int val;
+ TreeNode *left;
+ TreeNode *right;
+ TreeNode(int x) : val(x), left(NULL), right(NULL) {}
+};
+
+#include <algorithm>
+
+struct Result
+{
+ // root_camera >= root_monitored >= root_not_monitored
+ int root_camera;
+ int root_monitored;
+ int root_not_monitored;
+};
+
+class Solution
+{
+public:
+ Result dfs(TreeNode *root)
+ {
+ if (root->left == nullptr && root->right == nullptr)
+ {
+ return Result{1, 1, 0};
+ }
+
+ if (root->left == nullptr || root->right == nullptr)
+ {
+ TreeNode *child_node = root->left == nullptr ? root->right : root->left;
+ Result child = dfs(child_node);
+
+ int root_camera = 1 + child.root_not_monitored;
+ int root_monitored = std::min({child.root_camera,
+ root_camera});
+ int root_not_monitored = std::min(child.root_monitored, root_monitored);
+
+ return Result{
+ root_camera, root_monitored, root_not_monitored};
+ }
+
+ Result left = dfs(root->left);
+ Result right = dfs(root->right);
+
+ int root_camera = 1 + left.root_not_monitored + right.root_not_monitored;
+ int root_monitored = std::min({left.root_camera + right.root_monitored,
+ left.root_monitored + right.root_camera,
+ root_camera});
+ int root_not_monitored = std::min({left.root_monitored + right.root_monitored, root_monitored});
+
+ return Result{
+ root_camera, root_monitored, root_not_monitored};
+ }
+
+ int minCameraCover(TreeNode *root)
+ {
+ auto result = dfs(root);
+ return result.root_monitored;
+ }
};
\ No newline at end of file diff --git a/works/solutions/cpp/976.cpp b/works/solutions/leetcode/cpp/976.cpp index e306047..e306047 100644 --- a/works/solutions/cpp/976.cpp +++ b/works/solutions/leetcode/cpp/976.cpp diff --git a/works/solutions/cpp/98.cpp b/works/solutions/leetcode/cpp/98.cpp index 73cefa0..73cefa0 100644 --- a/works/solutions/cpp/98.cpp +++ b/works/solutions/leetcode/cpp/98.cpp diff --git a/works/solutions/cpp/li-wu-de-zui-da-jie-zhi-lcof.cpp b/works/solutions/leetcode/cpp/li-wu-de-zui-da-jie-zhi-lcof.cpp index 9af13fd..dee81ec 100644 --- a/works/solutions/cpp/li-wu-de-zui-da-jie-zhi-lcof.cpp +++ b/works/solutions/leetcode/cpp/li-wu-de-zui-da-jie-zhi-lcof.cpp @@ -1,34 +1,34 @@ -#include <vector> - -using std::vector; - -#include <algorithm> - -class Solution -{ -public: - int maxValue(vector<vector<int>> &grid) - { - int row_count = grid.size(); - int col_count = grid.front().size(); - - for (int i = 1; i < row_count; i++) - { - grid[i][0] = grid[i - 1][0] + grid[i][0]; - } - - for (int j = 1; j < col_count; j++) - { - grid[0][j] = grid[0][j - 1] + grid[0][j]; - } - - for (int i = 1; i < row_count; i++) - { - for (int j = 1; j < col_count; j++) - { - grid[i][j] = std::max(grid[i - 1][j], grid[i][j - 1]) + grid[i][j]; - } - } - return grid[row_count - 1][col_count - 1]; - } -}; +#include <vector>
+
+using std::vector;
+
+#include <algorithm>
+
+class Solution
+{
+public:
+ int maxValue(vector<vector<int>> &grid)
+ {
+ int row_count = grid.size();
+ int col_count = grid.front().size();
+
+ for (int i = 1; i < row_count; i++)
+ {
+ grid[i][0] = grid[i - 1][0] + grid[i][0];
+ }
+
+ for (int j = 1; j < col_count; j++)
+ {
+ grid[0][j] = grid[0][j - 1] + grid[0][j];
+ }
+
+ for (int i = 1; i < row_count; i++)
+ {
+ for (int j = 1; j < col_count; j++)
+ {
+ grid[i][j] = std::max(grid[i - 1][j], grid[i][j - 1]) + grid[i][j];
+ }
+ }
+ return grid[row_count - 1][col_count - 1];
+ }
+};
diff --git a/works/solutions/cpp/paths-with-sums-lcci.cpp b/works/solutions/leetcode/cpp/paths-with-sums-lcci.cpp index 697182d..697182d 100644 --- a/works/solutions/cpp/paths-with-sums-lcci.cpp +++ b/works/solutions/leetcode/cpp/paths-with-sums-lcci.cpp diff --git a/works/solutions/cpp/power-set-lcci.cpp b/works/solutions/leetcode/cpp/power-set-lcci.cpp index f502e7c..f502e7c 100644 --- a/works/solutions/cpp/power-set-lcci.cpp +++ b/works/solutions/leetcode/cpp/power-set-lcci.cpp diff --git a/works/solutions/cpp/que-shi-de-shu-zi-lcof.cpp b/works/solutions/leetcode/cpp/que-shi-de-shu-zi-lcof.cpp index 1cb3e01..1cb3e01 100644 --- a/works/solutions/cpp/que-shi-de-shu-zi-lcof.cpp +++ b/works/solutions/leetcode/cpp/que-shi-de-shu-zi-lcof.cpp diff --git a/works/solutions/rust/.gitignore b/works/solutions/leetcode/rust/.gitignore index f03942d..8accfa8 100644 --- a/works/solutions/rust/.gitignore +++ b/works/solutions/leetcode/rust/.gitignore @@ -1,5 +1,5 @@ -/target -**/*.rs.bk -Cargo.lock - -.vscode +/target
+**/*.rs.bk
+Cargo.lock
+
+.vscode
diff --git a/works/solutions/rust/Cargo.toml b/works/solutions/leetcode/rust/Cargo.toml index 1073387..a87486e 100644 --- a/works/solutions/rust/Cargo.toml +++ b/works/solutions/leetcode/rust/Cargo.toml @@ -1,9 +1,9 @@ -[package] -name = "crupest-leetcode" -version = "0.1.0" -authors = ["杨宇千 <crupest@outlook.com>"] -edition = "2018" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] +[package]
+name = "crupest-leetcode"
+version = "0.1.0"
+authors = ["杨宇千 <crupest@outlook.com>"]
+edition = "2018"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/works/solutions/rust/src/add_two_numbers.rs b/works/solutions/leetcode/rust/src/add_two_numbers.rs index d2ca858..d2ca858 100644 --- a/works/solutions/rust/src/add_two_numbers.rs +++ b/works/solutions/leetcode/rust/src/add_two_numbers.rs diff --git a/works/solutions/rust/src/find_median_sorted_arrays.rs b/works/solutions/leetcode/rust/src/find_median_sorted_arrays.rs index bbc73f9..bbc73f9 100644 --- a/works/solutions/rust/src/find_median_sorted_arrays.rs +++ b/works/solutions/leetcode/rust/src/find_median_sorted_arrays.rs diff --git a/works/solutions/rust/src/length_of_longest_substring.rs b/works/solutions/leetcode/rust/src/length_of_longest_substring.rs index cbd5e14..cbd5e14 100644 --- a/works/solutions/rust/src/length_of_longest_substring.rs +++ b/works/solutions/leetcode/rust/src/length_of_longest_substring.rs diff --git a/works/solutions/rust/src/lib.rs b/works/solutions/leetcode/rust/src/lib.rs index b2f3416..fc2e8b4 100644 --- a/works/solutions/rust/src/lib.rs +++ b/works/solutions/leetcode/rust/src/lib.rs @@ -1,7 +1,7 @@ -pub mod two_sum; -pub mod add_two_numbers; -pub mod length_of_longest_substring; -pub mod find_median_sorted_arrays; -pub mod longest_palindrome; - -pub struct Solution; +pub mod two_sum;
+pub mod add_two_numbers;
+pub mod length_of_longest_substring;
+pub mod find_median_sorted_arrays;
+pub mod longest_palindrome;
+
+pub struct Solution;
diff --git a/works/solutions/rust/src/longest_palindrome.rs b/works/solutions/leetcode/rust/src/longest_palindrome.rs index 659ffe0..659ffe0 100644 --- a/works/solutions/rust/src/longest_palindrome.rs +++ b/works/solutions/leetcode/rust/src/longest_palindrome.rs diff --git a/works/solutions/rust/src/two_sum.rs b/works/solutions/leetcode/rust/src/two_sum.rs index 9f400aa..9f400aa 100644 --- a/works/solutions/rust/src/two_sum.rs +++ b/works/solutions/leetcode/rust/src/two_sum.rs |