Skip to content

Commit 0f42fd1

Browse files
committed
Improved tasks 12, 13, 14
1 parent a89a3f9 commit 0f42fd1

File tree

3 files changed

+17
-35
lines changed

3 files changed

+17
-35
lines changed

LeetCodeNet/G0001_0100/S0012_integer_to_roman/readme.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ Given an integer, convert it to a roman numeral.
6767
## Solution
6868

6969
```csharp
70-
public class Solution
71-
{
72-
public string IntToRoman(int num)
73-
{
70+
public class Solution {
71+
public string IntToRoman(int num) {
7472
var sb = new System.Text.StringBuilder();
7573
int m = 1000;
7674
int c = 100;
@@ -83,11 +81,9 @@ public class Solution
8381
return sb.ToString();
8482
}
8583

86-
private int Numerals(System.Text.StringBuilder sb, int num, int one, char cTen, char cFive, char cOne)
87-
{
84+
private int Numerals(System.Text.StringBuilder sb, int num, int one, char cTen, char cFive, char cOne) {
8885
int div = num / one;
89-
switch (div)
90-
{
86+
switch (div) {
9187
case 9:
9288
sb.Append(cOne);
9389
sb.Append(cTen);

LeetCodeNet/G0001_0100/S0013_roman_to_integer/readme.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,13 @@ Given a roman numeral, convert it to an integer.
6969
## Solution
7070

7171
```csharp
72-
public class Solution
73-
{
74-
public int RomanToInt(string s)
75-
{
72+
public class Solution {
73+
public int RomanToInt(string s) {
7674
int x = 0;
7775
char y;
78-
for (int i = 0; i < s.Length; i++)
79-
{
76+
for (int i = 0; i < s.Length; i++) {
8077
y = s[i];
81-
switch (y)
82-
{
78+
switch (y) {
8379
case 'I':
8480
x = GetX(s, x, i, 1, 'V', 'X');
8581
break;
@@ -108,8 +104,7 @@ public class Solution
108104
return x;
109105
}
110106

111-
private int GetX(string s, int x, int i, int i2, char v, char x2)
112-
{
107+
private int GetX(string s, int x, int i, int i2, char v, char x2) {
113108
if (i + 1 == s.Length)
114109
{
115110
x += i2;

LeetCodeNet/G0001_0100/S0014_longest_common_prefix/readme.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,34 +32,25 @@ If there is no common prefix, return an empty string `""`.
3232
## Solution
3333

3434
```csharp
35-
public class Solution
36-
{
37-
public string LongestCommonPrefix(string[] strs)
38-
{
39-
if (strs.Length < 1)
40-
{
35+
public class Solution {
36+
public string LongestCommonPrefix(string[] strs) {
37+
if (strs.Length < 1) {
4138
return "";
4239
}
43-
if (strs.Length == 1)
44-
{
40+
if (strs.Length == 1) {
4541
return strs[0];
4642
}
4743
string temp = strs[0];
4844
int i = 1;
4945
string cur;
50-
while (!string.IsNullOrEmpty(temp) && i < strs.Length)
51-
{
52-
if (temp.Length > strs[i].Length)
53-
{
46+
while (!string.IsNullOrEmpty(temp) && i < strs.Length) {
47+
if (temp.Length > strs[i].Length) {
5448
temp = temp.Substring(0, strs[i].Length);
5549
}
5650
cur = strs[i].Substring(0, temp.Length);
57-
if (!cur.Equals(temp))
58-
{
51+
if (!cur.Equals(temp)) {
5952
temp = temp.Substring(0, temp.Length - 1);
60-
}
61-
else
62-
{
53+
} else {
6354
i++;
6455
}
6556
}

0 commit comments

Comments
 (0)