File tree 2 files changed +25
-0
lines changed
src/main/java/com/fishercoder/solutions
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
8
8
9
9
| # | Title | Solutions | Video | Difficulty | Tag
10
10
|------|----------------|------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------|-------------
11
+ | 2582 |[Pass the Pillow](https://leetcode.com/problems/pass-the-pillow/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2582.java) | | Easy |
11
12
| 2566 |[Maximum Difference by Remapping a Digit](https://leetcode.com/problems/maximum-difference-by-remapping-a-digit/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2566.java) | | Easy |
12
13
| 2562 |[Find the Array Concatenation Value](https://leetcode.com/problems/find-the-array-concatenation-value/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2562.java) | | Easy |
13
14
| 2559 |[Count Vowel Strings in Ranges](https://leetcode.com/problems/count-vowel-strings-in-ranges/)| [Java](../master/src/main/java/com/fishercoder/solutions/_2559.java) | | Medium |
Original file line number Diff line number Diff line change
1
+ package com .fishercoder .solutions ;
2
+
3
+ public class _2582 {
4
+ public static class Solution1 {
5
+ public int passThePillow (int n , int time ) {
6
+ int person = 1 ;
7
+ boolean goLeft = true ;
8
+ while (time -- > 0 ) {
9
+ if (goLeft ) {
10
+ person ++;
11
+ } else {
12
+ person --;
13
+ }
14
+ if (time == 0 ) {
15
+ return person ;
16
+ }
17
+ if (person == n || person == 1 ) {
18
+ goLeft = !goLeft ;
19
+ }
20
+ }
21
+ return person ;
22
+ }
23
+ }
24
+ }
You can’t perform that action at this time.
0 commit comments