Two Tasks
This commit is contained in:
67
.idea/.idea.Leetcode/.idea/workspace.xml
generated
67
.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>
|
||||||
@@ -72,6 +73,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>
|
||||||
@@ -82,6 +84,20 @@
|
|||||||
</component>
|
</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$/15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/encodings.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/indexLayout.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/projectSettingsUpdater.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/15. 3Sum/.idea/.idea.OldConsoleTemplate.dir/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/15. 3Sum/15. 3Sum.csproj" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/15. 3Sum/Program.cs" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/15. 3Sum/Solution.cs" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/encodings.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/indexLayout.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/projectSettingsUpdater.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/8. String to Integer (atoi)/8. String to Integer (atoi).csproj" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/8. String to Integer (atoi)/Program.cs" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/8. String to Integer (atoi)/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,20 +106,29 @@
|
|||||||
<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="HighlightingSettingsPerFile">
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/527a2dcd76ec41ecb0820c0926ad20f7a28600/75/a9f2af7b/Dictionary`2.cs" root0="SKIP_HIGHLIGHTING" />
|
||||||
|
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/527a2dcd76ec41ecb0820c0926ad20f7a28600/f4/54bf738e/ThrowHelper.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="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": {
|
||||||
|
"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",
|
"last_opened_file_path": "/home/nullptr/Projects/dotnet/Leetcode/15. 3Sum/15. 3Sum.csproj",
|
||||||
|
"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"
|
||||||
},
|
},
|
||||||
@@ -115,7 +140,7 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}]]></component>
|
}]]></component>
|
||||||
<component name="RunManager" selected=".NET Project.6. Zigzag Conversion">
|
<component name="RunManager" selected=".NET Project.15. 3Sum">
|
||||||
<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 +375,24 @@
|
|||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</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="" />
|
||||||
@@ -1448,6 +1491,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="" />
|
||||||
@@ -1530,6 +1591,7 @@
|
|||||||
<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" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
@@ -1538,6 +1600,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>
|
||||||
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>net7.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
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>
|
||||||
64
8. String to Integer (atoi)/.idea/.idea.OldConsoleTemplate.dir/.idea/workspace.xml
generated
Normal file
64
8. String to Integer (atoi)/.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>_8._String_to_Integer__atoi_.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="_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_.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>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
11
8. String to Integer (atoi)/Program.cs
Normal file
11
8. String to Integer (atoi)/Program.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace _8._String_to_Integer__atoi_;
|
||||||
|
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
static void Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.WriteLine(new Solution().MyAtoi(" "));
|
||||||
|
}
|
||||||
|
}
|
||||||
27
8. String to Integer (atoi)/Solution.cs
Normal file
27
8. String to Integer (atoi)/Solution.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System.Numerics;
|
||||||
|
|
||||||
|
namespace _8._String_to_Integer__atoi_;
|
||||||
|
|
||||||
|
public class Solution {
|
||||||
|
public int MyAtoi(string s)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(s))
|
||||||
|
return 0;
|
||||||
|
BigInteger res = 0;
|
||||||
|
int index = 0;
|
||||||
|
while (index<s.Length && s[index] == ' ')
|
||||||
|
index++;
|
||||||
|
bool negative = index<s.Length && s[index] == '-';
|
||||||
|
if (index<s.Length && "+-".Contains(s[index]))
|
||||||
|
index++;
|
||||||
|
while (index<s.Length && char.IsDigit(s[index]))
|
||||||
|
res = res * 10 + s[index++]-'0';
|
||||||
|
if (negative)
|
||||||
|
res *= -1;
|
||||||
|
if (res > int.MaxValue)
|
||||||
|
return int.MaxValue;
|
||||||
|
if (res < int.MinValue)
|
||||||
|
return int.MinValue;
|
||||||
|
return (int)res;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Leetcode.sln
12
Leetcode.sln
@@ -159,6 +159,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "4. Median of Two Sorted Arr
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "6. Zigzag Conversion", "6. Zigzag Conversion\6. Zigzag Conversion.csproj", "{4C15CB37-485C-4CD0-9BD4-D713CC744ECC}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "6. Zigzag Conversion", "6. Zigzag Conversion\6. Zigzag Conversion.csproj", "{4C15CB37-485C-4CD0-9BD4-D713CC744ECC}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "8. String to Integer (atoi)", "8. String to Integer (atoi)\8. String to Integer (atoi).csproj", "{D6AEC02C-3EF2-4BE8-9C13-7F511FC9F9E7}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "15. 3Sum", "15. 3Sum\15. 3Sum.csproj", "{4FAFB0B1-A240-44B9-8305-3CA7FED8AE3C}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -477,6 +481,14 @@ Global
|
|||||||
{4C15CB37-485C-4CD0-9BD4-D713CC744ECC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{4C15CB37-485C-4CD0-9BD4-D713CC744ECC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{4C15CB37-485C-4CD0-9BD4-D713CC744ECC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{4C15CB37-485C-4CD0-9BD4-D713CC744ECC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{4C15CB37-485C-4CD0-9BD4-D713CC744ECC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{4C15CB37-485C-4CD0-9BD4-D713CC744ECC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{D6AEC02C-3EF2-4BE8-9C13-7F511FC9F9E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{D6AEC02C-3EF2-4BE8-9C13-7F511FC9F9E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{D6AEC02C-3EF2-4BE8-9C13-7F511FC9F9E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{D6AEC02C-3EF2-4BE8-9C13-7F511FC9F9E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{4FAFB0B1-A240-44B9-8305-3CA7FED8AE3C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{4FAFB0B1-A240-44B9-8305-3CA7FED8AE3C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{4FAFB0B1-A240-44B9-8305-3CA7FED8AE3C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{4FAFB0B1-A240-44B9-8305-3CA7FED8AE3C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user