Content-Length: 467988 | pFad | http://github.com/LeetCode-in-Net/LeetCode-in-Net/commit/#start-of-content

6886E29F Improved tasks 12, 13, 14 · LeetCode-in-Net/LeetCode-in-Net@fa49da0 · GitHub
Skip to content

Commit fa49da0

Browse files
authored
Improved tasks 12, 13, 14
1 parent 2cc5663 commit fa49da0

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-
public class Solution
7-
{
8-
public string IntToRoman(int num)
9-
{
6+
public class Solution {
7+
public string IntToRoman(int num) {
108
var sb = new System.Text.StringBuilder();
119
int m = 1000;
1210
int c = 100;
@@ -19,11 +17,9 @@ public string IntToRoman(int num)
1917
return sb.ToString();
2018
}
2119

22-
private int Numerals(System.Text.StringBuilder sb, int num, int one, char cTen, char cFive, char cOne)
23-
{
20+
private int Numerals(System.Text.StringBuilder sb, int num, int one, char cTen, char cFive, char cOne) {
2421
int div = num / one;
25-
switch (div)
26-
{
22+
switch (div) {
2723
case 9:
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-
public class Solution
7-
{
8-
public int RomanToInt(string s)
9-
{
6+
public class Solution {
7+
public int RomanToInt(string s) {
108
int x = 0;
119
char y;
12-
for (int i = 0; i < s.Length; i++)
13-
{
10+
for (int i = 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
return x;
4339
}
4440

45-
private int GetX(string s, int x, int i, int i2, char v, char x2)
46-
{
41+
private int GetX(string s, int x, int i, int i2, char v, char x2) {
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-
public class Solution
8-
{
9-
public string LongestCommonPrefix(string[] strs)
10-
{
11-
if (strs.Length < 1)
12-
{
7+
public class Solution {
8+
public string LongestCommonPrefix(string[] strs) {
9+
if (strs.Length < 1) {
1310
return "";
1411
}
15-
if (strs.Length == 1)
16-
{
12+
if (strs.Length == 1) {
1713
return strs[0];
1814
}
1915
string temp = strs[0];
2016
int i = 1;
2117
string cur;
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/LeetCode-in-Net/LeetCode-in-Net/commit/#start-of-content

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy