Skip to content

Commit c5fd3de

Browse files
committed
Add C# solutions
1 parent e9d1b36 commit c5fd3de

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Solutions in various programming languages are provided. Enjoy it.
2424
15. [Length of Last Word](https://github.com/AlgoStudyGroup/Leetcode/tree/master/September-LeetCoding-Challenge/15-Length-of-Last-Word)
2525
16. [Maximum XOR of Two Numbers in an Array](https://github.com/AlgoStudyGroup/Leetcode/tree/master/September-LeetCoding-Challenge/16-Maximum-XOR-of-Two-Numbers-in-an-Array)
2626
17. [Robot Bounded In Circle](https://github.com/AlgoStudyGroup/Leetcode/tree/master/September-LeetCoding-Challenge/17-Robot-Bounded-In-Circle)
27+
18. [Best Time to Buy and Sell Stock](https://github.com/AlgoStudyGroup/Leetcode/tree/master/September-LeetCoding-Challenge/18-Best-Time-to-Buy-and-Sell-Stock)
28+
19. [Sequential Digits](https://github.com/AlgoStudyGroup/Leetcode/tree/master/September-LeetCoding-Challenge/19-Sequential-Digits)
2729

2830
## August LeetCoding Challenge
2931
Click [here](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/) for problem descriptions.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class Solution {
2+
public int MaxProfit(int[] prices) {
3+
if(prices == null || prices.Length == 0) return 0;
4+
int min=prices[0],max=0;
5+
for (int i=1;i<prices.Length;i++){
6+
min=Math.Min(min,prices[i]);
7+
max=Math.Max(max,prices[i]-min);
8+
}
9+
return max;
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class Solution {
2+
public IList<int> SequentialDigits(int low, int high) {
3+
int[] allNums = {12,23,34,45,56,67,78,89,
4+
123,234,345,456,567,678,789,
5+
1234,2345,3456,4567,5678,6789,
6+
12345,23456,34567,45678,56789,
7+
123456,234567,345678,456789,
8+
1234567,2345678,3456789,
9+
12345678,23456789,
10+
123456789};
11+
var res = new List<int>();
12+
int n = allNums.Length;
13+
for (int i = 0; i < n; i++) {
14+
if (allNums[i] < low) continue;
15+
if (allNums[i] > high) break;
16+
res.Add(allNums[i]);
17+
}
18+
return res;
19+
}
20+
}

0 commit comments

Comments
 (0)