File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12 Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1+ Subproject commit 7b3bd25441ace95f23357f28344eec7110953645
Original file line number Diff line number Diff line change @@ -7,6 +7,44 @@ public class Lesson12 {
77 * https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
88 */
99 public String gameResult (ListNode head ) {
10- return null ;
10+
11+ //team values
12+ int oddValue = 0 ;
13+ int evenValue = 0 ;
14+
15+ //iterate through listNode
16+ //grabbed items
17+ //accessed value
18+
19+ while (head != null && head .next != null ) {
20+ int val1 = head .val ; //at head node, accessing value. head val is even
21+ int val2 = head .next .val ; // at next node, accessing value. next val is odd
22+
23+ //compare values
24+ if (val1 > val2 ) {
25+ evenValue += 1 ;
26+ } else if (val1 < val2 ) {
27+ oddValue += 1 ;
28+ }
29+ // go to next value
30+
31+ }
32+
33+
34+
35+
36+
37+
38+
39+ // loop through lstNode
40+
41+ // grab lstNode values
42+ //compare them
43+ //return even or odd depending on which value is higher
44+
45+
46+
47+
1148 }
49+
1250}
You can’t perform that action at this time.
0 commit comments