File tree Expand file tree Collapse file tree 3 files changed +19
-21
lines changed Expand file tree Collapse file tree 3 files changed +19
-21
lines changed Original file line number Diff line number Diff line change 3
3
namespace LeetcodeCShaprDotNetCore {
4
4
class Program {
5
5
static void Main ( string [ ] args ) {
6
+
7
+
6
8
}
7
9
}
8
10
}
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Text ;
4
+
5
+
4
6
namespace LeetcodeCShaprDotNetCore {
5
7
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 ] ) ;
20
18
}
21
- left ++ ;
22
- right -- ;
23
19
}
20
+ result . Add ( list ) ;
24
21
}
25
- return true ;
22
+ return result ;
26
23
}
27
24
}
28
- }
29
-
30
- // 12321 1234
25
+ }
Original file line number Diff line number Diff line change 3
3
I will use this repository to make notes for leetcode solutions and classify the problems by different topics.
4
4
5
5
## Solved Problem List
6
- Total solved: 68
6
+ Total solved: 69
7
7
8
8
### top-interview-questions
9
9
@@ -12,6 +12,7 @@ ID | Difficulty | Tags | Solution
12
12
14 | Easy | String | [ Longest Common Prefix] ( https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/14.%20Longest%20Common%20Prefix.cs )
13
13
38 | Easy | String | [ Count and Say] ( https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/38.%20Count%20and%20Say.cs )
14
14
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 )
15
16
155 | Easy | Stack, Design | [ Min Stack] ( https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/155.%20Min%20Stack.cs )
16
17
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 )
17
18
169 | Easy | Dictionary | [ Majority Element] ( https://github.com/kflili/LeetcodeCShaprDotNetCore/blob/master/Algorithms%20Basics/top-interview-questions/169.%20Majority%20Element.cs )
You can’t perform that action at this time.
0 commit comments