File tree Expand file tree Collapse file tree 3 files changed +21
-2
lines changed
solution/2300-2399/2335.Minimum Amount of Time to Fill Cups Expand file tree Collapse file tree 3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,13 @@ func fillCups(amount []int) int {
138
138
### ** TypeScript**
139
139
140
140
``` ts
141
-
141
+ function fillCups(amount : number []): number {
142
+ amount .sort ((a , b ) => a - b );
143
+ let [a, b, c] = amount ;
144
+ let diff = (a + b ) - c ;
145
+ if (diff <= 0 ) return c ;
146
+ else return Math .floor ((diff + 1 ) / 2 ) + c ;
147
+ };
142
148
```
143
149
144
150
### ** ...**
Original file line number Diff line number Diff line change @@ -127,7 +127,13 @@ func fillCups(amount []int) int {
127
127
### ** TypeScript**
128
128
129
129
``` ts
130
-
130
+ function fillCups(amount : number []): number {
131
+ amount .sort ((a , b ) => a - b );
132
+ let [a, b, c] = amount ;
133
+ let diff = (a + b ) - c ;
134
+ if (diff <= 0 ) return c ;
135
+ else return Math .floor ((diff + 1 ) / 2 ) + c ;
136
+ };
131
137
```
132
138
133
139
### ** ...**
Original file line number Diff line number Diff line change
1
+ function fillCups ( amount : number [ ] ) : number {
2
+ amount . sort ( ( a , b ) => a - b ) ;
3
+ let [ a , b , c ] = amount ;
4
+ let diff = ( a + b ) - c ;
5
+ if ( diff <= 0 ) return c ;
6
+ else return Math . floor ( ( diff + 1 ) / 2 ) + c ;
7
+ } ;
You can’t perform that action at this time.
0 commit comments