Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfa49da0

Browse files
authored
Improved tasks 12, 13, 14
1 parent2cc5663 commitfa49da0

File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
lines changed

‎LeetCodeNet/G0001_0100/S0012_integer_to_roman/Solution.cs‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ namespace LeetCodeNet.G0001_0100.S0012_integer_to_roman {
33
// #Medium #String #Hash_Table #Math #Top_Interview_150_Array/String #Big_O_Time_O(1)_Space_O(1)
44
// #2025_06_20_Time_2_ms_(87.59%)_Space_45.13_MB_(98.99%)
55

6-
publicclassSolution
7-
{
8-
publicstringIntToRoman(intnum)
9-
{
6+
publicclassSolution{
7+
publicstringIntToRoman(intnum){
108
varsb=newSystem.Text.StringBuilder();
119
intm=1000;
1210
intc=100;
@@ -19,11 +17,9 @@ public string IntToRoman(int num)
1917
returnsb.ToString();
2018
}
2119

22-
privateintNumerals(System.Text.StringBuildersb,intnum,intone,charcTen,charcFive,charcOne)
23-
{
20+
privateintNumerals(System.Text.StringBuildersb,intnum,intone,charcTen,charcFive,charcOne){
2421
intdiv=num/one;
25-
switch(div)
26-
{
22+
switch(div){
2723
case9:
2824
sb.Append(cOne);
2925
sb.Append(cTen);

‎LeetCodeNet/G0001_0100/S0013_roman_to_integer/Solution.cs‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@ namespace LeetCodeNet.G0001_0100.S0013_roman_to_integer {
33
// #Easy #Top_Interview_Questions #String #Hash_Table #Math #Top_Interview_150_Array/String
44
// #Big_O_Time_O(n)_Space_O(1) #2025_06_20_Time_1_ms_(99.81%)_Space_49.42_MB_(80.66%)
55

6-
publicclassSolution
7-
{
8-
publicintRomanToInt(strings)
9-
{
6+
publicclassSolution{
7+
publicintRomanToInt(strings){
108
intx=0;
119
chary;
12-
for(inti=0;i<s.Length;i++)
13-
{
10+
for(inti=0;i<s.Length;i++){
1411
y=s[i];
15-
switch(y)
16-
{
12+
switch(y){
1713
case'I':
1814
x=GetX(s,x,i,1,'V','X');
1915
break;
@@ -42,8 +38,7 @@ public int RomanToInt(string s)
4238
returnx;
4339
}
4440

45-
privateintGetX(strings,intx,inti,inti2,charv,charx2)
46-
{
41+
privateintGetX(strings,intx,inti,inti2,charv,charx2){
4742
if(i+1==s.Length)
4843
{
4944
x+=i2;

‎LeetCodeNet/G0001_0100/S0014_longest_common_prefix/Solution.cs‎

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,25 @@ namespace LeetCodeNet.G0001_0100.S0014_longest_common_prefix {
44
// #Top_Interview_150_Array/String #Big_O_Time_O(n*m)_Space_O(m)
55
// #2025_06_20_Time_0_ms_(100.00%)_Space_42.70_MB_(97.50%)
66

7-
publicclassSolution
8-
{
9-
publicstringLongestCommonPrefix(string[]strs)
10-
{
11-
if(strs.Length<1)
12-
{
7+
publicclassSolution{
8+
publicstringLongestCommonPrefix(string[]strs){
9+
if(strs.Length<1){
1310
return"";
1411
}
15-
if(strs.Length==1)
16-
{
12+
if(strs.Length==1){
1713
returnstrs[0];
1814
}
1915
stringtemp=strs[0];
2016
inti=1;
2117
stringcur;
22-
while(!string.IsNullOrEmpty(temp)&&i<strs.Length)
23-
{
24-
if(temp.Length>strs[i].Length)
25-
{
18+
while(!string.IsNullOrEmpty(temp)&&i<strs.Length){
19+
if(temp.Length>strs[i].Length){
2620
temp=temp.Substring(0,strs[i].Length);
2721
}
2822
cur=strs[i].Substring(0,temp.Length);
29-
if(!cur.Equals(temp))
30-
{
23+
if(!cur.Equals(temp)){
3124
temp=temp.Substring(0,temp.Length-1);
32-
}
33-
else
34-
{
25+
}else{
3526
i++;
3627
}
3728
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp