Two Tasks

This commit is contained in:
nullptroma
2023-04-06 22:17:31 +03:00
parent 1f7d9dad1b
commit 75d2db5b75
16 changed files with 373 additions and 2 deletions

View 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>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View 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>

View 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">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;SolutionBuilderGeneralOptionsPage&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</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>

View File

@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
</Project>

View 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(" "));
}
}

View 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;
}
}