Skip to content

Commit c5fcd3a

Browse files
author
Li Li
committed
add 118 to notes
1 parent 1f38f3d commit c5fcd3a

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

LeetcodeCShaprDotNetCore/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace LeetcodeCShaprDotNetCore {
44
class Program {
55
static void Main(string[] args) {
6+
7+
68
}
79
}
810
}

LeetcodeCShaprDotNetCore/Solution.cs

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Text;
4+
5+
46
namespace LeetcodeCShaprDotNetCore {
57
public class Solution {
6-
public bool IsPalindrome(string s) {
7-
if (s.Length == 0) return true;
8-
int left = 0, right = s.Length - 1;
9-
char leftChar, rightChar;
10-
while (left <= right) {
11-
leftChar = s[left];
12-
rightChar = s[right];
13-
if (!char.IsLetterOrDigit(leftChar)){
14-
left++;
15-
} else if (!char.IsLetterOrDigit(rightChar)) {
16-
right--;
17-
} else {
18-
if (char.ToLower(leftChar) != char.ToLower(rightChar)) {
19-
return false;
8+
public IList<IList<int>> Generate(int numRows) {
9+
IList<IList<int>> result = new List<IList<int>>();
10+
for (int row = 0; row < numRows; row++) {
11+
IList<int> list = new List<int>();
12+
for (int i = 0; i < row + 1; i++) {
13+
if (i == 0 || i == row) {
14+
list.Add(1);
15+
} else {
16+
var preList = result[row - 1];
17+
list.Add(preList[i - 1] + preList[i]);
2018
}
21-
left++;
22-
right--;
2319
}
20+
result.Add(list);
2421
}
25-
return true;
22+
return result;
2623
}
2724
}
28-
}
29-
30-
// 12321 1234
25+
}

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
I will use this repository to make notes for leetcode solutions and classify the problems by different topics.
44

55
## Solved Problem List
6-
Total solved: 68
6+
Total solved: 69
77

88
### top-interview-questions
99

@@ -12,6 +12,7 @@ ID | Difficulty | Tags | Solution
1212
14 | Easy | String | [Longest Common Prefix](https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/14.%20Longest%20Common%20Prefix.cs)
1313
38 | Easy | String | [Count and Say](https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/38.%20Count%20and%20Say.cs)
1414
53 | Easy | Dynamic Programming, Divide and Conquer | [Maximum Subarray](https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/53.%20Maximum%20Subarray.cs)
15+
118 | Easy | Array, Math | [Pascal's Triangle](https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/118.%20Pascal's%20Triangle.cs)
1516
155 | Easy | Stack, Design | [Min Stack](https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/155.%20Min%20Stack.cs)
1617
160 | Easy | LinkedList | [Intersection of Two Linked Lists](https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/160.%20Intersection%20of%20Two%20Linked%20Lists.cs)
1718
169 | Easy | Dictionary | [Majority Element](https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/169.%20Majority%20Element.cs)

0 commit comments

Comments
 (0)