Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit21832b1

Browse files
authored
Merge pull request#286 from hellomrsun/master
Add C# solutions
2 parentse9d1b36 +b83f1c2 commit21832b1

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

‎README.md‎

Lines changed: 2 additions & 0 deletions
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.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
publicclassSolution{
2+
publicintMaxProfit(int[]prices){
3+
if(prices==null||prices.Length==0)return0;
4+
intmin=prices[0],max=0;
5+
for(inti=1;i<prices.Length;i++){
6+
min=Math.Min(min,prices[i]);
7+
max=Math.Max(max,prices[i]-min);
8+
}
9+
returnmax;
10+
}
11+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
publicclassSolution{
2+
publicIList<int>SequentialDigits(intlow,inthigh){
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+
varres=newList<int>();
12+
intn=allNums.Length;
13+
for(inti=0;i<n;i++){
14+
if(allNums[i]<low)continue;
15+
if(allNums[i]>high)break;
16+
res.Add(allNums[i]);
17+
}
18+
returnres;
19+
}
20+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
publicclassSolution{
2+
publicintCanCompleteCircuit(int[]gas,int[]cost){
3+
intsumGas=0,sumCost=0,tank=0,pos=0;
4+
5+
for(inti=0;i<gas.Length;i++){
6+
sumGas+=gas[i];
7+
sumCost+=cost[i];
8+
tank+=gas[i]-cost[i];
9+
if(tank<0){
10+
pos=i+1;
11+
tank=0;
12+
}
13+
}
14+
15+
if(sumGas>=sumCost){
16+
returnpos;
17+
}
18+
19+
return-1;
20+
}
21+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp