Compare commits
10 Commits
1f7d9dad1b
...
5014a24cc8
| Author | SHA1 | Date | |
|---|---|---|---|
| 5014a24cc8 | |||
|
|
9b3c8c3fef | ||
|
|
c47d2185b5 | ||
|
|
bfb8311fe7 | ||
|
|
d15aa071c8 | ||
|
|
9d50f345d1 | ||
|
|
1e43adf29e | ||
|
|
66ea6b80f4 | ||
|
|
8b40248caf | ||
|
|
75d2db5b75 |
203
.idea/.idea.Leetcode/.idea/workspace.xml
generated
203
.idea/.idea.Leetcode/.idea/workspace.xml
generated
@@ -15,6 +15,7 @@
|
|||||||
<projectFile>144. Binary Tree Preorder Traversal/144. Binary Tree Preorder Traversal.csproj</projectFile>
|
<projectFile>144. Binary Tree Preorder Traversal/144. Binary Tree Preorder Traversal.csproj</projectFile>
|
||||||
<projectFile>145. Binary Tree Postorder Traversal/145. Binary Tree Postorder Traversal.csproj</projectFile>
|
<projectFile>145. Binary Tree Postorder Traversal/145. Binary Tree Postorder Traversal.csproj</projectFile>
|
||||||
<projectFile>1480. Running Sum of 1d Array/1480. Running Sum of 1d Array.csproj</projectFile>
|
<projectFile>1480. Running Sum of 1d Array/1480. Running Sum of 1d Array.csproj</projectFile>
|
||||||
|
<projectFile>15. 3Sum/15. 3Sum.csproj</projectFile>
|
||||||
<projectFile>167. Two Sum II - Input Array Is Sorted/167. Two Sum II - Input Array Is Sorted.csproj</projectFile>
|
<projectFile>167. Two Sum II - Input Array Is Sorted/167. Two Sum II - Input Array Is Sorted.csproj</projectFile>
|
||||||
<projectFile>189. Rotate Array/189. Rotate Array.csproj</projectFile>
|
<projectFile>189. Rotate Array/189. Rotate Array.csproj</projectFile>
|
||||||
<projectFile>19. Remove Nth Node From End of List/19. Remove Nth Node From End of List.csproj</projectFile>
|
<projectFile>19. Remove Nth Node From End of List/19. Remove Nth Node From End of List.csproj</projectFile>
|
||||||
@@ -29,6 +30,7 @@
|
|||||||
<projectFile>206. Reverse Linked List/206. Reverse Linked List.csproj</projectFile>
|
<projectFile>206. Reverse Linked List/206. Reverse Linked List.csproj</projectFile>
|
||||||
<projectFile>21. Merge Two Sorted Lists/21. Merge Two Sorted Lists.csproj</projectFile>
|
<projectFile>21. Merge Two Sorted Lists/21. Merge Two Sorted Lists.csproj</projectFile>
|
||||||
<projectFile>217. Contains Duplicate/217. Contains Duplicate.csproj</projectFile>
|
<projectFile>217. Contains Duplicate/217. Contains Duplicate.csproj</projectFile>
|
||||||
|
<projectFile>225. Implement Stack using Queues/225. Implement Stack using Queues.csproj</projectFile>
|
||||||
<projectFile>226. Invert Binary Tree/226. Invert Binary Tree.csproj</projectFile>
|
<projectFile>226. Invert Binary Tree/226. Invert Binary Tree.csproj</projectFile>
|
||||||
<projectFile>231. Power of Two/231. Power of Two.csproj</projectFile>
|
<projectFile>231. Power of Two/231. Power of Two.csproj</projectFile>
|
||||||
<projectFile>232. Implement Queue using Stacks/232. Implement Queue using Stacks.csproj</projectFile>
|
<projectFile>232. Implement Queue using Stacks/232. Implement Queue using Stacks.csproj</projectFile>
|
||||||
@@ -40,6 +42,7 @@
|
|||||||
<projectFile>299. Bulls and Cows/299. Bulls and Cows.csproj</projectFile>
|
<projectFile>299. Bulls and Cows/299. Bulls and Cows.csproj</projectFile>
|
||||||
<projectFile>3. Longest Substring Without Repeating Characters/3. Longest Substring Without Repeating Characters.csproj</projectFile>
|
<projectFile>3. Longest Substring Without Repeating Characters/3. Longest Substring Without Repeating Characters.csproj</projectFile>
|
||||||
<projectFile>344. Reverse String/344. Reverse String.csproj</projectFile>
|
<projectFile>344. Reverse String/344. Reverse String.csproj</projectFile>
|
||||||
|
<projectFile>347. Top K Frequent Elements/347. Top K Frequent Elements.csproj</projectFile>
|
||||||
<projectFile>35. Search Insert Position/35. Search Insert Position.csproj</projectFile>
|
<projectFile>35. Search Insert Position/35. Search Insert Position.csproj</projectFile>
|
||||||
<projectFile>350. Intersection of Two Arrays II/350. Intersection of Two Arrays II.csproj</projectFile>
|
<projectFile>350. Intersection of Two Arrays II/350. Intersection of Two Arrays II.csproj</projectFile>
|
||||||
<projectFile>36. Valid Sudoku/36. Valid Sudoku.csproj</projectFile>
|
<projectFile>36. Valid Sudoku/36. Valid Sudoku.csproj</projectFile>
|
||||||
@@ -50,6 +53,7 @@
|
|||||||
<projectFile>409. Longest Palindrome/409. Longest Palindrome.csproj</projectFile>
|
<projectFile>409. Longest Palindrome/409. Longest Palindrome.csproj</projectFile>
|
||||||
<projectFile>424. Longest Repeating Character Replacement/424. Longest Repeating Character Replacement.csproj</projectFile>
|
<projectFile>424. Longest Repeating Character Replacement/424. Longest Repeating Character Replacement.csproj</projectFile>
|
||||||
<projectFile>438. Find All Anagrams in a String/438. Find All Anagrams in a String.csproj</projectFile>
|
<projectFile>438. Find All Anagrams in a String/438. Find All Anagrams in a String.csproj</projectFile>
|
||||||
|
<projectFile>451. Sort Characters By Frequency/451. Sort Characters By Frequency.csproj</projectFile>
|
||||||
<projectFile>46. Permutations/46. Permutations.csproj</projectFile>
|
<projectFile>46. Permutations/46. Permutations.csproj</projectFile>
|
||||||
<projectFile>509. Fibonacci Number/509. Fibonacci Number.csproj</projectFile>
|
<projectFile>509. Fibonacci Number/509. Fibonacci Number.csproj</projectFile>
|
||||||
<projectFile>53. Maximum Subarray/53. Maximum Subarray.csproj</projectFile>
|
<projectFile>53. Maximum Subarray/53. Maximum Subarray.csproj</projectFile>
|
||||||
@@ -72,6 +76,7 @@
|
|||||||
<projectFile>746. Min Cost Climbing Stairs/746. Min Cost Climbing Stairs.csproj</projectFile>
|
<projectFile>746. Min Cost Climbing Stairs/746. Min Cost Climbing Stairs.csproj</projectFile>
|
||||||
<projectFile>77. Combinations/77. Combinations.csproj</projectFile>
|
<projectFile>77. Combinations/77. Combinations.csproj</projectFile>
|
||||||
<projectFile>784. Letter Case Permutation/784. Letter Case Permutation.csproj</projectFile>
|
<projectFile>784. Letter Case Permutation/784. Letter Case Permutation.csproj</projectFile>
|
||||||
|
<projectFile>8. String to Integer (atoi)/8. String to Integer (atoi).csproj</projectFile>
|
||||||
<projectFile>83. Remove Duplicates from Sorted List/83. Remove Duplicates from Sorted List.csproj</projectFile>
|
<projectFile>83. Remove Duplicates from Sorted List/83. Remove Duplicates from Sorted List.csproj</projectFile>
|
||||||
<projectFile>876. Middle of the Linked List/876. Middle of the Linked List.csproj</projectFile>
|
<projectFile>876. Middle of the Linked List/876. Middle of the Linked List.csproj</projectFile>
|
||||||
<projectFile>88. Merge Sorted Array/88. Merge Sorted Array.csproj</projectFile>
|
<projectFile>88. Merge Sorted Array/88. Merge Sorted Array.csproj</projectFile>
|
||||||
@@ -80,8 +85,14 @@
|
|||||||
<projectFile>98. Validate Binary Search Tree/98. Validate Binary Search Tree.csproj</projectFile>
|
<projectFile>98. Validate Binary Search Tree/98. Validate Binary Search Tree.csproj</projectFile>
|
||||||
<projectFile>994. Rotting Oranges/994. Rotting Oranges.csproj</projectFile>
|
<projectFile>994. Rotting Oranges/994. Rotting Oranges.csproj</projectFile>
|
||||||
</component>
|
</component>
|
||||||
|
<component name="AutoImportSettings">
|
||||||
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="11f2de1c-1ee5-4aa4-91e6-11975ebd421f" name="Changes" comment="">
|
<list default="true" id="11f2de1c-1ee5-4aa4-91e6-11975ebd421f" name="Changes" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/347. Top K Frequent Elements/347. Top K Frequent Elements.csproj" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/347. Top K Frequent Elements/Program.cs" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/347. Top K Frequent Elements/Solution.cs" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Leetcode/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Leetcode/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.Leetcode/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Leetcode/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/Leetcode.sln" beforeDir="false" afterPath="$PROJECT_DIR$/Leetcode.sln" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/Leetcode.sln" beforeDir="false" afterPath="$PROJECT_DIR$/Leetcode.sln" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
@@ -90,32 +101,61 @@
|
|||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="HighlightingSettingsPerFile">
|
||||||
|
<setting file="file://$PROJECT_DIR$/14. Longest Common Prefix/Program.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/14. Longest Common Prefix/Solution.cs" root0="FORCE_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/225. Implement Stack using Queues/MyStack.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/225. Implement Stack using Queues/Program.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/232. Implement Queue using Stacks/MyQueue.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$PROJECT_DIR$/232. Implement Queue using Stacks/Program.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
</component>
|
||||||
<component name="MarkdownSettingsMigration">
|
<component name="MarkdownSettingsMigration">
|
||||||
<option name="stateVersion" value="1" />
|
<option name="stateVersion" value="1" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="ProjectColorInfo">{
|
||||||
|
"associatedIndex": 3
|
||||||
|
}</component>
|
||||||
<component name="ProjectId" id="2MbItycivFzycjT9hquXZe9USRT" />
|
<component name="ProjectId" id="2MbItycivFzycjT9hquXZe9USRT" />
|
||||||
|
<component name="ProjectLevelVcsManager">
|
||||||
|
<ConfirmationsSetting value="2" id="Add" />
|
||||||
|
</component>
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
|
".NET Project.14. Longest Common Prefix.executor": "Run",
|
||||||
|
".NET Project.150. Evaluate Reverse Polish Notation.executor": "Run",
|
||||||
|
".NET Project.347. Top K Frequent Elements.executor": "Run",
|
||||||
|
".NET Project.451. Sort Characters By Frequency.executor": "Run",
|
||||||
|
".NET Project.9. Palindrome Number.executor": "Run",
|
||||||
|
"ASKED_ADD_EXTERNAL_FILES": "true",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"WebServerToolWindowFactoryState": "false",
|
"WebServerToolWindowFactoryState": "false",
|
||||||
"last_opened_file_path": "/home/nullptr/Projects/dotNET/Leetcode/6. Zigzag Conversion/6. Zigzag Conversion.csproj",
|
"git-widget-placeholder": "main",
|
||||||
|
"last_opened_file_path": "/home/nullptr/Projects/dotnet/Leetcode/15. 3Sum/15. 3Sum.csproj",
|
||||||
|
"node.js.detected.package.eslint": "true",
|
||||||
|
"node.js.detected.package.tslint": "true",
|
||||||
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "SolutionBuilderGeneralOptionsPage",
|
"settings.editor.selected.configurable": "SolutionBuilderGeneralOptionsPage",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"rider.external.source.directories": [
|
"rider.external.source.directories": [
|
||||||
"/home/nullptr/.config/JetBrains/Rider2022.3/resharper-host/DecompilerCache",
|
"/home/nullptr/.config/JetBrains/Rider2023.3/resharper-host/DecompilerCache",
|
||||||
"/home/nullptr/.config/JetBrains/Rider2022.3/resharper-host/SourcesCache",
|
"/home/nullptr/.config/JetBrains/Rider2023.3/resharper-host/SourcesCache",
|
||||||
"/home/nullptr/.local/share/Symbols/src"
|
"/home/nullptr/.local/share/Symbols/src"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}]]></component>
|
||||||
<component name="RunManager" selected=".NET Project.6. Zigzag Conversion">
|
<component name="RunManager" selected=".NET Project.347. Top K Frequent Elements">
|
||||||
<configuration name="101. Symmetric Tree" type="DotNetProject" factoryName=".NET Project">
|
<configuration name="101. Symmetric Tree" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="" />
|
<option name="EXE_PATH" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
@@ -350,6 +390,60 @@
|
|||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="14. Longest Common Prefix" type="DotNetProject" factoryName=".NET Project" temporary="true">
|
||||||
|
<option name="EXE_PATH" value="$PROJECT_DIR$/14. Longest Common Prefix/bin/Debug/net8.0/14. Longest Common Prefix" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/14. Longest Common Prefix/bin/Debug/net8.0" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/14. Longest Common Prefix/14. Longest Common Prefix.csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="net8.0" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
<configuration name="150. Evaluate Reverse Polish Notation" type="DotNetProject" factoryName=".NET Project" temporary="true">
|
||||||
|
<option name="EXE_PATH" value="$PROJECT_DIR$/150. Evaluate Reverse Polish Notation/bin/Debug/net8.0/150. Evaluate Reverse Polish Notation" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/150. Evaluate Reverse Polish Notation/bin/Debug/net8.0" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/150. Evaluate Reverse Polish Notation/150. Evaluate Reverse Polish Notation.csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="net8.0" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
<configuration name="15. 3Sum" type="DotNetProject" factoryName=".NET Project">
|
||||||
|
<option name="EXE_PATH" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/15. 3Sum/15. 3Sum.csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
<configuration name="167. Two Sum II - Input Array Is Sorted" type="DotNetProject" factoryName=".NET Project">
|
<configuration name="167. Two Sum II - Input Array Is Sorted" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="" />
|
<option name="EXE_PATH" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
@@ -602,6 +696,24 @@
|
|||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="225. Implement Stack using Queues" type="DotNetProject" factoryName=".NET Project">
|
||||||
|
<option name="EXE_PATH" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/225. Implement Stack using Queues/225. Implement Stack using Queues.csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
<configuration name="226. Invert Binary Tree" type="DotNetProject" factoryName=".NET Project">
|
<configuration name="226. Invert Binary Tree" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="" />
|
<option name="EXE_PATH" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
@@ -800,6 +912,24 @@
|
|||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="347. Top K Frequent Elements" type="DotNetProject" factoryName=".NET Project">
|
||||||
|
<option name="EXE_PATH" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/347. Top K Frequent Elements/347. Top K Frequent Elements.csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
<configuration name="350. Intersection of Two Arrays II" type="DotNetProject" factoryName=".NET Project">
|
<configuration name="350. Intersection of Two Arrays II" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="" />
|
<option name="EXE_PATH" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
@@ -980,6 +1110,24 @@
|
|||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="451. Sort Characters By Frequency" type="DotNetProject" factoryName=".NET Project">
|
||||||
|
<option name="EXE_PATH" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/451. Sort Characters By Frequency/451. Sort Characters By Frequency.csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
<configuration name="46. Permutations" type="DotNetProject" factoryName=".NET Project">
|
<configuration name="46. Permutations" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="" />
|
<option name="EXE_PATH" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
@@ -1448,6 +1596,24 @@
|
|||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="8. String to Integer (atoi)" type="DotNetProject" factoryName=".NET Project">
|
||||||
|
<option name="EXE_PATH" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/8. String to Integer (atoi)/8. String to Integer (atoi).csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
<configuration name="94. Binary Tree Inorder Traversal" type="DotNetProject" factoryName=".NET Project">
|
<configuration name="94. Binary Tree Inorder Traversal" type="DotNetProject" factoryName=".NET Project">
|
||||||
<option name="EXE_PATH" value="" />
|
<option name="EXE_PATH" value="" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
@@ -1520,6 +1686,31 @@
|
|||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
<configuration name="9. Palindrome Number" type="DotNetProject" factoryName=".NET Project" temporary="true">
|
||||||
|
<option name="EXE_PATH" value="$PROJECT_DIR$/9. Palindrome Number/bin/Debug/net8.0/9. Palindrome Number" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/9. Palindrome Number/bin/Debug/net8.0" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/9. Palindrome Number/9. Palindrome Number.csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="net8.0" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue=".NET Project.9. Palindrome Number" />
|
||||||
|
<item itemvalue=".NET Project.150. Evaluate Reverse Polish Notation" />
|
||||||
|
<item itemvalue=".NET Project.14. Longest Common Prefix" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
</component>
|
</component>
|
||||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
<component name="TaskManager">
|
<component name="TaskManager">
|
||||||
@@ -1530,6 +1721,9 @@
|
|||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1678030074860</updated>
|
<updated>1678030074860</updated>
|
||||||
<workItem from="1678030078340" duration="114000" />
|
<workItem from="1678030078340" duration="114000" />
|
||||||
|
<workItem from="1680804946367" duration="3697000" />
|
||||||
|
<workItem from="1706644472303" duration="7903000" />
|
||||||
|
<workItem from="1707331420927" duration="3074000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@@ -1538,6 +1732,7 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="UnityUnitTestConfiguration" currentTestLauncher="NUnit" />
|
<component name="UnityUnitTestConfiguration" currentTestLauncher="NUnit" />
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
|
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||||
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_1._Two_Sum</RootNamespace>
|
<RootNamespace>_1._Two_Sum</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_101._Symmetric_Tree</RootNamespace>
|
<RootNamespace>_101._Symmetric_Tree</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_102._Binary_Tree_Level_Order_Traversal</RootNamespace>
|
<RootNamespace>_102._Binary_Tree_Level_Order_Traversal</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_104._Maximum_Depth_of_Binary_Tree</RootNamespace>
|
<RootNamespace>_104._Maximum_Depth_of_Binary_Tree</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_112._Path_Sum</RootNamespace>
|
<RootNamespace>_112._Path_Sum</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_116._Populating_Next_Right_Pointers_in_Each_Node</RootNamespace>
|
<RootNamespace>_116._Populating_Next_Right_Pointers_in_Each_Node</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_118._Pascal_s_Triangle</RootNamespace>
|
<RootNamespace>_118._Pascal_s_Triangle</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_121._Best_Time_to_Buy_and_Sell_Stock</RootNamespace>
|
<RootNamespace>_121._Best_Time_to_Buy_and_Sell_Stock</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_136._Single_Number</RootNamespace>
|
<RootNamespace>_136._Single_Number</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
11
14. Longest Common Prefix/14. Longest Common Prefix.csproj
Normal file
11
14. Longest Common Prefix/14. Longest Common Prefix.csproj
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<RootNamespace>_14._Longest_Common_Prefix</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
6
14. Longest Common Prefix/Program.cs
Normal file
6
14. Longest Common Prefix/Program.cs
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
|
||||||
|
using _14._Longest_Common_Prefix;
|
||||||
|
|
||||||
|
string[] strs = ["flower", "flow", "flight"];
|
||||||
|
Console.WriteLine(new Solution().LongestCommonPrefix(strs));
|
||||||
32
14. Longest Common Prefix/Solution.cs
Normal file
32
14. Longest Common Prefix/Solution.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace _14._Longest_Common_Prefix;
|
||||||
|
|
||||||
|
public class Solution
|
||||||
|
{
|
||||||
|
public string LongestCommonPrefix(string[] strs)
|
||||||
|
{
|
||||||
|
if (strs.Length == 1)
|
||||||
|
return strs[0];
|
||||||
|
StringBuilder sb = new StringBuilder(256);
|
||||||
|
int maxLen = strs.Select(s => s.Length).Min();
|
||||||
|
for (int i = 0; i < maxLen; i++)
|
||||||
|
{
|
||||||
|
char letter;
|
||||||
|
if ((letter = strs[0][i]) != strs[1][i])
|
||||||
|
break;
|
||||||
|
for (int j = 2; j < strs.Length; j++)
|
||||||
|
{
|
||||||
|
if (letter != strs[j][i])
|
||||||
|
{
|
||||||
|
maxLen = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(maxLen != -1)
|
||||||
|
sb.Append(letter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_141._Linked_List_Cycle</RootNamespace>
|
<RootNamespace>_141._Linked_List_Cycle</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_142._Linked_List_Cycle_II</RootNamespace>
|
<RootNamespace>_142._Linked_List_Cycle_II</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_144._Binary_Tree_Preorder_Traversal</RootNamespace>
|
<RootNamespace>_144._Binary_Tree_Preorder_Traversal</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_145._Binary_Tree_Postorder_Traversal</RootNamespace>
|
<RootNamespace>_145._Binary_Tree_Postorder_Traversal</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_1480._Running_Sum_of_1d_Array</RootNamespace>
|
<RootNamespace>_1480._Running_Sum_of_1d_Array</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
4
15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/encodings.xml
generated
Normal file
4
15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
8
15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/indexLayout.xml
generated
Normal file
8
15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/projectSettingsUpdater.xml
generated
Normal file
6
15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/projectSettingsUpdater.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RiderProjectSettingsUpdater">
|
||||||
|
<option name="vcsConfiguration" value="2" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
64
15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/workspace.xml
generated
Normal file
64
15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AutoGeneratedRunConfigurationManager">
|
||||||
|
<projectFile>_15._3Sum.csproj</projectFile>
|
||||||
|
</component>
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="82866301-1c54-48b2-9c86-912478ff5746" name="Changes" comment="" />
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectId" id="2NSm8ypYphrjURy5OrzoEQDZIRZ" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent">{
|
||||||
|
"keyToString": {
|
||||||
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"WebServerToolWindowFactoryState": "false",
|
||||||
|
"settings.editor.selected.configurable": "SolutionBuilderGeneralOptionsPage",
|
||||||
|
"vue.rearranger.settings.migration": "true"
|
||||||
|
}
|
||||||
|
}</component>
|
||||||
|
<component name="RunManager">
|
||||||
|
<configuration name="_15._3Sum" type="DotNetProject" factoryName=".NET Project">
|
||||||
|
<option name="EXE_PATH" value="" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="USE_MONO" value="0" />
|
||||||
|
<option name="RUNTIME_ARGUMENTS" value="" />
|
||||||
|
<option name="PROJECT_PATH" value="$PROJECT_DIR$/_15._3Sum.csproj" />
|
||||||
|
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
|
||||||
|
<option name="PROJECT_KIND" value="DotNetCore" />
|
||||||
|
<option name="PROJECT_TFM" value="" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Build" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="82866301-1c54-48b2-9c86-912478ff5746" name="Changes" comment="" />
|
||||||
|
<created>1679665701935</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1679665701935</updated>
|
||||||
|
<workItem from="1679665703808" duration="5000" />
|
||||||
|
<workItem from="1680292231454" duration="4000" />
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="UnityUnitTestConfiguration" currentTestLauncher="NUnit" />
|
||||||
|
<component name="VcsManagerConfiguration">
|
||||||
|
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
15. 3Sum/15. 3Sum.csproj
Normal file
8
15. 3Sum/15. 3Sum.csproj
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
15
15. 3Sum/Program.cs
Normal file
15
15. 3Sum/Program.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace _15._3Sum;
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var res = new Solution().ThreeSum(new int[]{-3,0,-5,2,-4,-2,1,-2,-1,3,1,3,1,3,-3,-5,1});
|
||||||
|
foreach (var list in res)
|
||||||
|
{
|
||||||
|
Console.WriteLine(String.Join(" ", list));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
15. 3Sum/Solution.cs
Normal file
63
15. 3Sum/Solution.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace _15._3Sum;
|
||||||
|
|
||||||
|
public class Solution {
|
||||||
|
|
||||||
|
class SequenceComparer<T>:IEqualityComparer<IEnumerable<T>>
|
||||||
|
{
|
||||||
|
public bool Equals(IEnumerable<T> seq1,IEnumerable<T> seq2)
|
||||||
|
{
|
||||||
|
return seq1.SequenceEqual(seq2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode(IEnumerable<T> seq)
|
||||||
|
{
|
||||||
|
int hash = 1234567;
|
||||||
|
foreach(T elem in seq)
|
||||||
|
hash = unchecked(hash * 37 + elem.GetHashCode());
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IList<IList<int>> ThreeSum(int[] nums)
|
||||||
|
{
|
||||||
|
Dictionary<int, int> dict = new Dictionary<int, int>();
|
||||||
|
foreach (var num in nums)
|
||||||
|
{
|
||||||
|
if (dict.ContainsKey(num))
|
||||||
|
dict[num]++;
|
||||||
|
else
|
||||||
|
dict.Add(num, 1);
|
||||||
|
}
|
||||||
|
HashSet<IList<int>> answer = new HashSet<IList<int>>(new SequenceComparer<int>());
|
||||||
|
int[] keys = dict.Keys.ToArray();
|
||||||
|
for (int i = 0; i < keys.Length; i++)
|
||||||
|
{
|
||||||
|
int countI = dict[keys[i]]-1;
|
||||||
|
for (int j = i; j < keys.Length; j++)
|
||||||
|
{
|
||||||
|
int countJ = j == i ? (countI-1) : (dict[keys[j]]-1);
|
||||||
|
int v1 = keys[i];
|
||||||
|
int v2 = keys[j];
|
||||||
|
int v3 = -(v1+v2);
|
||||||
|
if (v3 == v1)
|
||||||
|
countI--;
|
||||||
|
if (v3 == v2)
|
||||||
|
countJ--;
|
||||||
|
bool can = dict.ContainsKey(v3);
|
||||||
|
if (can && countI >= 0 && countJ >= 0)
|
||||||
|
{
|
||||||
|
var list = new List<int>() { v1, v2, v3 };
|
||||||
|
list.Sort();
|
||||||
|
answer.Add(list);
|
||||||
|
}
|
||||||
|
countI = dict[keys[i]]-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return answer.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<RootNamespace>_150._Evaluate_Reverse_Polish_Notation</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
11
150. Evaluate Reverse Polish Notation/Program.cs
Normal file
11
150. Evaluate Reverse Polish Notation/Program.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
|
||||||
|
using _150._Evaluate_Reverse_Polish_Notation;
|
||||||
|
|
||||||
|
string[] arr = ["10", "1", "1", "2", "+", "+", "+"];
|
||||||
|
var sol = new Solution();
|
||||||
|
int n = 100000;
|
||||||
|
while(n-- > 0)
|
||||||
|
Console.WriteLine(sol.EvalRPN(["10", "1", "1", "2", "+", "+", "+"]));
|
||||||
|
|
||||||
|
|
||||||
31
150. Evaluate Reverse Polish Notation/Solution.cs
Normal file
31
150. Evaluate Reverse Polish Notation/Solution.cs
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
namespace _150._Evaluate_Reverse_Polish_Notation;
|
||||||
|
|
||||||
|
public class Solution
|
||||||
|
{
|
||||||
|
public int EvalRPN(string[] tokens)
|
||||||
|
{
|
||||||
|
var stack = new Stack<int>(tokens.Length);
|
||||||
|
foreach (var token in tokens)
|
||||||
|
{
|
||||||
|
if (int.TryParse(token, out var number))
|
||||||
|
stack.Push(number);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int right = stack.Pop();
|
||||||
|
int left = stack.Pop();
|
||||||
|
char op = token[0];
|
||||||
|
stack.Push(Calc(op, left, right));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stack.Pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int Calc(char op, int left, int right) => op switch
|
||||||
|
{
|
||||||
|
'+' => left + right,
|
||||||
|
'-' => left - right,
|
||||||
|
'*' => left * right,
|
||||||
|
'/' => left / right,
|
||||||
|
_ => throw new ArgumentOutOfRangeException()
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_167._Two_Sum_II___Input_Array_Is_Sorted</RootNamespace>
|
<RootNamespace>_167._Two_Sum_II___Input_Array_Is_Sorted</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_189._Rotate_Array</RootNamespace>
|
<RootNamespace>_189._Rotate_Array</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_19._Remove_Nth_Node_From_End_of_List</RootNamespace>
|
<RootNamespace>_19._Remove_Nth_Node_From_End_of_List</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_190._Reverse_Bits</RootNamespace>
|
<RootNamespace>_190._Reverse_Bits</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_191._Number_of_1_Bits</RootNamespace>
|
<RootNamespace>_191._Number_of_1_Bits</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_198._House_Robber</RootNamespace>
|
<RootNamespace>_198._House_Robber</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_2._Add_Two_Numbers</RootNamespace>
|
<RootNamespace>_2._Add_Two_Numbers</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_20._Valid_Parentheses</RootNamespace>
|
<RootNamespace>_20._Valid_Parentheses</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_200._Number_of_Islands</RootNamespace>
|
<RootNamespace>_200._Number_of_Islands</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_203._Remove_Linked_List_Elements</RootNamespace>
|
<RootNamespace>_203._Remove_Linked_List_Elements</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_205._Isomorphic_Strings</RootNamespace>
|
<RootNamespace>_205._Isomorphic_Strings</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_206._Reverse_Linked_List</RootNamespace>
|
<RootNamespace>_206._Reverse_Linked_List</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_21._Merge_Two_Sorted_Lists</RootNamespace>
|
<RootNamespace>_21._Merge_Two_Sorted_Lists</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_217._Contains_Duplicate</RootNamespace>
|
<RootNamespace>_217._Contains_Duplicate</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<RootNamespace>_225._Implement_Stack_using_Queues</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
50
225. Implement Stack using Queues/MyStack.cs
Normal file
50
225. Implement Stack using Queues/MyStack.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
namespace _225._Implement_Stack_using_Queues;
|
||||||
|
|
||||||
|
public class MyStack
|
||||||
|
{
|
||||||
|
private Queue<int> _queue = new Queue<int>(256);
|
||||||
|
private int? _lastNum = null;
|
||||||
|
|
||||||
|
public MyStack()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Push(int x)
|
||||||
|
{
|
||||||
|
if (_lastNum == null)
|
||||||
|
{
|
||||||
|
_lastNum = x;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = _queue.Count;
|
||||||
|
_queue.Enqueue(_lastNum.Value);
|
||||||
|
_lastNum = x;
|
||||||
|
while (count-- > 0)
|
||||||
|
_queue.Enqueue(_queue.Dequeue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Pop()
|
||||||
|
{
|
||||||
|
if (_lastNum != null)
|
||||||
|
{
|
||||||
|
int res = _lastNum.Value;
|
||||||
|
_lastNum = null;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return _queue.Dequeue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Top()
|
||||||
|
{
|
||||||
|
if (_lastNum != null)
|
||||||
|
return _lastNum.Value;
|
||||||
|
return _queue.Peek();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Empty()
|
||||||
|
{
|
||||||
|
return _lastNum == null && _queue.Count == 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
225. Implement Stack using Queues/Program.cs
Normal file
3
225. Implement Stack using Queues/Program.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
// See https://aka.ms/new-console-template for more information
|
||||||
|
|
||||||
|
Console.WriteLine("Hello, World!");
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_226._Invert_Binary_Tree</RootNamespace>
|
<RootNamespace>_226._Invert_Binary_Tree</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_231._Power_of_Two</RootNamespace>
|
<RootNamespace>_231._Power_of_Two</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_232._Implement_Queue_using_Stacks</RootNamespace>
|
<RootNamespace>_232._Implement_Queue_using_Stacks</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,18 +2,19 @@
|
|||||||
|
|
||||||
public class MyQueue
|
public class MyQueue
|
||||||
{
|
{
|
||||||
private Stack<int> _sInput = new Stack<int>();
|
private Stack<int> _sInput = new Stack<int>(256);
|
||||||
private Stack<int> _sOutput = new Stack<int>();
|
private Stack<int> _sOutput = new Stack<int>(256);
|
||||||
|
|
||||||
public void Push(int x)
|
public void Push(int x)
|
||||||
{
|
{
|
||||||
while (_sOutput.TryPop(out int res))
|
|
||||||
_sInput.Push(res);
|
|
||||||
_sInput.Push(x);
|
_sInput.Push(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Pop()
|
public int Pop()
|
||||||
{
|
{
|
||||||
|
if (_sOutput.Count > 0)
|
||||||
|
return _sOutput.Pop();
|
||||||
|
|
||||||
while (_sInput.TryPop(out int res))
|
while (_sInput.TryPop(out int res))
|
||||||
_sOutput.Push(res);
|
_sOutput.Push(res);
|
||||||
return _sOutput.Pop();
|
return _sOutput.Pop();
|
||||||
@@ -21,6 +22,9 @@ public class MyQueue
|
|||||||
|
|
||||||
public int Peek()
|
public int Peek()
|
||||||
{
|
{
|
||||||
|
if (_sOutput.Count > 0)
|
||||||
|
return _sOutput.Peek();
|
||||||
|
|
||||||
while (_sInput.TryPop(out int res))
|
while (_sInput.TryPop(out int res))
|
||||||
_sOutput.Push(res);
|
_sOutput.Push(res);
|
||||||
return _sOutput.Peek();
|
return _sOutput.Peek();
|
||||||
@@ -28,8 +32,6 @@ public class MyQueue
|
|||||||
|
|
||||||
public bool Empty()
|
public bool Empty()
|
||||||
{
|
{
|
||||||
while (_sInput.TryPop(out int res))
|
return _sOutput.Count == 0 && _sInput.Count == 0;
|
||||||
_sOutput.Push(res);
|
|
||||||
return _sOutput.Count == 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ internal class Program
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Hello, World!");
|
int x = 5;
|
||||||
|
MyQueue obj = new MyQueue();
|
||||||
|
obj.Push(x);
|
||||||
|
int param_2 = obj.Pop();
|
||||||
|
int param_3 = obj.Peek();
|
||||||
|
bool param_4 = obj.Empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_235._Lowest_Common_Ancestor_of_a_Binary_Search_Tree</RootNamespace>
|
<RootNamespace>_235._Lowest_Common_Ancestor_of_a_Binary_Search_Tree</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_240._Search_a_2D_Matrix_II</RootNamespace>
|
<RootNamespace>_240._Search_a_2D_Matrix_II</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_242._Valid_Anagram</RootNamespace>
|
<RootNamespace>_242._Valid_Anagram</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_278._First_Bad_Version</RootNamespace>
|
<RootNamespace>_278._First_Bad_Version</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_283._Move_Zeroes</RootNamespace>
|
<RootNamespace>_283._Move_Zeroes</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_299._Bulls_and_Cows</RootNamespace>
|
<RootNamespace>_299._Bulls_and_Cows</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_3._Longest_Substring_Without_Repeating_Characters</RootNamespace>
|
<RootNamespace>_3._Longest_Substring_Without_Repeating_Characters</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_344._Reverse_String</RootNamespace>
|
<RootNamespace>_344._Reverse_String</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<RootNamespace>_347._Top_K_Frequent_Elements</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
4
347. Top K Frequent Elements/Program.cs
Normal file
4
347. Top K Frequent Elements/Program.cs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
using _347._Top_K_Frequent_Elements;
|
||||||
|
|
||||||
|
var sol = new Solution();
|
||||||
|
Console.WriteLine(string.Join(", ", sol.TopKFrequent([1,1,1,2,2,3], 2)));
|
||||||
13
347. Top K Frequent Elements/Solution.cs
Normal file
13
347. Top K Frequent Elements/Solution.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace _347._Top_K_Frequent_Elements;
|
||||||
|
|
||||||
|
public class Solution
|
||||||
|
{
|
||||||
|
public int[] TopKFrequent(int[] nums, int k)
|
||||||
|
{
|
||||||
|
var dictionary = new Dictionary<int, int>();
|
||||||
|
foreach (var num in nums)
|
||||||
|
if (!dictionary.TryAdd(num, 1))
|
||||||
|
dictionary[num]++;
|
||||||
|
return dictionary.OrderByDescending(kp=>kp.Value).Take(k).Select(kp=>kp.Key).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_35._Search_Insert_Position</RootNamespace>
|
<RootNamespace>_35._Search_Insert_Position</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_350._Intersection_of_Two_Arrays_II</RootNamespace>
|
<RootNamespace>_350._Intersection_of_Two_Arrays_II</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_36._Valid_Sudoku</RootNamespace>
|
<RootNamespace>_36._Valid_Sudoku</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_383._Ransom_Note</RootNamespace>
|
<RootNamespace>_383._Ransom_Note</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_387._First_Unique_Character_in_a_String</RootNamespace>
|
<RootNamespace>_387._First_Unique_Character_in_a_String</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_392._Is_Subsequence</RootNamespace>
|
<RootNamespace>_392._Is_Subsequence</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_4._Median_of_Two_Sorted_Arrays</RootNamespace>
|
<RootNamespace>_4._Median_of_Two_Sorted_Arrays</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_409._Longest_Palindrome</RootNamespace>
|
<RootNamespace>_409._Longest_Palindrome</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_424._Longest_Repeating_Character_Replacement</RootNamespace>
|
<RootNamespace>_424._Longest_Repeating_Character_Replacement</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_438._Find_All_Anagrams_in_a_String</RootNamespace>
|
<RootNamespace>_438._Find_All_Anagrams_in_a_String</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<RootNamespace>_451._Sort_Characters_By_Frequency</RootNamespace>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
26
451. Sort Characters By Frequency/Fast/FastSolution.cs
Normal file
26
451. Sort Characters By Frequency/Fast/FastSolution.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace _451._Sort_Characters_By_Frequency.Fast;
|
||||||
|
|
||||||
|
public class Solution
|
||||||
|
{
|
||||||
|
private static int Comparer((char, int) el1, (char, int) el2)
|
||||||
|
{
|
||||||
|
return el2.Item2.CompareTo(el1.Item2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string FrequencySort(string s)
|
||||||
|
{
|
||||||
|
var count = new (char, int)[128];
|
||||||
|
for (var ch = (char)0; ch < count.Length; ch++)
|
||||||
|
count[ch].Item1 = ch;
|
||||||
|
foreach (var c in s)
|
||||||
|
count[c].Item2++;
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
Array.Sort(count, Comparer);
|
||||||
|
for (var ch = (char)0; ch < count.Length; ch++)
|
||||||
|
while (count[ch].Item2-- > 0)
|
||||||
|
sb.Append(count[ch].Item1);
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
4
451. Sort Characters By Frequency/Program.cs
Normal file
4
451. Sort Characters By Frequency/Program.cs
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
using _451._Sort_Characters_By_Frequency;
|
||||||
|
|
||||||
|
var sol = new _451._Sort_Characters_By_Frequency.Fast.Solution();
|
||||||
|
Console.WriteLine(sol.FrequencySort("gbngjaaaaaaaafsdgnjk;fdsnjkg;fds"));
|
||||||
16
451. Sort Characters By Frequency/Solution.cs
Normal file
16
451. Sort Characters By Frequency/Solution.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
namespace _451._Sort_Characters_By_Frequency;
|
||||||
|
|
||||||
|
public class Solution
|
||||||
|
{
|
||||||
|
public string FrequencySort(string s)
|
||||||
|
{
|
||||||
|
Dictionary<char, int> dictionary = [];
|
||||||
|
foreach (var c in s.Where(c => !dictionary.TryAdd(c, 1)))
|
||||||
|
dictionary[c]++;
|
||||||
|
|
||||||
|
var list = dictionary.ToList();
|
||||||
|
return String.Join("",
|
||||||
|
list.OrderByDescending(element => element.Value)
|
||||||
|
.Select(element => new string(element.Key, element.Value)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_46._Permutations</RootNamespace>
|
<RootNamespace>_46._Permutations</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_509._Fibonacci_Number</RootNamespace>
|
<RootNamespace>_509._Fibonacci_Number</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_53._Maximum_Subarray</RootNamespace>
|
<RootNamespace>_53._Maximum_Subarray</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_542._01_Matrix</RootNamespace>
|
<RootNamespace>_542._01_Matrix</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_557._Reverse_Words_in_a_String_III</RootNamespace>
|
<RootNamespace>_557._Reverse_Words_in_a_String_III</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_566._Reshape_the_Matrix</RootNamespace>
|
<RootNamespace>_566._Reshape_the_Matrix</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_567._Permutation_in_String</RootNamespace>
|
<RootNamespace>_567._Permutation_in_String</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_589._N_ary_Tree_Preorder_Traversal</RootNamespace>
|
<RootNamespace>_589._N_ary_Tree_Preorder_Traversal</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_6._Zigzag_Conversion</RootNamespace>
|
<RootNamespace>_6._Zigzag_Conversion</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_617._Merge_Two_Binary_Trees</RootNamespace>
|
<RootNamespace>_617._Merge_Two_Binary_Trees</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_62._Unique_Paths</RootNamespace>
|
<RootNamespace>_62._Unique_Paths</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_695._Max_Area_of_Island</RootNamespace>
|
<RootNamespace>_695._Max_Area_of_Island</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_70._Climbing_Stairs</RootNamespace>
|
<RootNamespace>_70._Climbing_Stairs</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_700._Search_in_a_Binary_Search_Tree</RootNamespace>
|
<RootNamespace>_700._Search_in_a_Binary_Search_Tree</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_701._Insert_into_a_Binary_Search_Tree</RootNamespace>
|
<RootNamespace>_701._Insert_into_a_Binary_Search_Tree</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_704._Binary_Search</RootNamespace>
|
<RootNamespace>_704._Binary_Search</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_724._Find_Pivot_Index</RootNamespace>
|
<RootNamespace>_724._Find_Pivot_Index</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_733._Flood_Fill</RootNamespace>
|
<RootNamespace>_733._Flood_Fill</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_74._Search_a_2D_Matrix</RootNamespace>
|
<RootNamespace>_74._Search_a_2D_Matrix</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_746._Min_Cost_Climbing_Stairs</RootNamespace>
|
<RootNamespace>_746._Min_Cost_Climbing_Stairs</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_77._Combinations</RootNamespace>
|
<RootNamespace>_77._Combinations</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<RootNamespace>_784._Letter_Case_Permutation</RootNamespace>
|
<RootNamespace>_784._Letter_Case_Permutation</RootNamespace>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|||||||
4
8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/encodings.xml
generated
Normal file
4
8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||||
|
</project>
|
||||||
8
8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/indexLayout.xml
generated
Normal file
8
8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="UserContentModel">
|
||||||
|
<attachedFolders />
|
||||||
|
<explicitIncludes />
|
||||||
|
<explicitExcludes />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/projectSettingsUpdater.xml
generated
Normal file
6
8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/projectSettingsUpdater.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RiderProjectSettingsUpdater">
|
||||||
|
<option name="vcsConfiguration" value="2" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user