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

Commit69eba98

Browse files
authored
Merge pull requestneetcode-gh#1077 from agnihotriketan/patch-24
Create 1094-Car-Pooling.cs
2 parentsd3e1a55 +5a58722 commit69eba98

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

‎csharp/1094-Car-Pooling.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
publicclassSolution{
2+
publicboolCarPooling(int[][]trips,intcapacity){
3+
vardictionary=newSortedDictionary<int,int>();
4+
5+
foreach(vartripintrips)
6+
{
7+
if(!dictionary.ContainsKey(trip[1]))dictionary[trip[1]]=0;
8+
if(!dictionary.ContainsKey(trip[2]))dictionary[trip[2]]=0;
9+
dictionary[trip[1]]+=trip[0];dictionary[trip[2]]-=trip[0];
10+
}
11+
intcurrentPassennger=0;
12+
foreach(varkeyvalindictionary)
13+
{
14+
currentPassennger+=keyval.Value;
15+
if(currentPassennger>capacity)returnfalse;
16+
}
17+
returntrue;
18+
}
19+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp