Skip to content

feat: adds amiyah jones' lesson12 & stack java files #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
8cc92d0
Create README.md
AmiyahJo Sep 24, 2024
50b1861
Delete lesson_00/amiyahjones/README.md
AmiyahJo Sep 24, 2024
27d57c0
Merge branch 'code-differently:main' into main
AmiyahJo Sep 25, 2024
fa3c700
Merge branch 'code-differently:main' into main
AmiyahJo Sep 26, 2024
7c2d053
Merge branch 'code-differently:main' into main
AmiyahJo Sep 26, 2024
faedd1b
Merge branch 'code-differently:main' into main
AmiyahJo Sep 26, 2024
19a4187
Merge branch 'code-differently:main' into main
AmiyahJo Sep 26, 2024
7711266
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
9a10c4c
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
3ea50c4
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
d7b772d
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
de46b67
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
b891561
Merge branch 'code-differently:main' into main
AmiyahJo Sep 28, 2024
7c9f2db
Merge branch 'code-differently:main' into main
AmiyahJo Sep 30, 2024
ff3ba35
Merge branch 'code-differently:main' into main
AmiyahJo Sep 30, 2024
457feea
Merge branch 'code-differently:main' into main
AmiyahJo Sep 30, 2024
5868f9d
Merge branch 'code-differently:main' into main
AmiyahJo Oct 1, 2024
28eacd4
Merge branch 'code-differently:main' into main
AmiyahJo Oct 1, 2024
bca4933
Merge branch 'code-differently:main' into main
AmiyahJo Oct 1, 2024
9ff0f9e
Merge branch 'code-differently:main' into main
AmiyahJo Oct 1, 2024
8d02849
Merge branch 'code-differently:main' into main
AmiyahJo Oct 2, 2024
6dd3a43
Merge branch 'code-differently:main' into main
AmiyahJo Oct 2, 2024
95f56a5
Merge branch 'code-differently:main' into main
AmiyahJo Oct 3, 2024
0f4dbac
Merge branch 'code-differently:main' into main
AmiyahJo Oct 4, 2024
a3b9984
Merge branch 'code-differently:main' into main
AmiyahJo Oct 4, 2024
54cd199
Merge branch 'code-differently:main' into main
AmiyahJo Oct 4, 2024
edbe7c0
Merge branch 'code-differently:main' into main
AmiyahJo Oct 4, 2024
7f0a084
Merge branch 'code-differently:main' into main
AmiyahJo Oct 7, 2024
a905b74
Merge branch 'code-differently:main' into main
AmiyahJo Oct 8, 2024
2d69531
Merge branch 'code-differently:main' into main
AmiyahJo Oct 8, 2024
df48fbd
Merge branch 'code-differently:main' into main
AmiyahJo Oct 8, 2024
c972d14
Merge branch 'code-differently:main' into main
AmiyahJo Oct 9, 2024
bc3907c
Merge branch 'code-differently:main' into main
AmiyahJo Oct 9, 2024
c3eabbb
Merge branch 'code-differently:main' into main
AmiyahJo Oct 9, 2024
9fff7d0
Merge branch 'code-differently:main' into main
AmiyahJo Oct 11, 2024
4c57926
Merge branch 'code-differently:main' into main
AmiyahJo Oct 11, 2024
8dd5d42
Merge branch 'code-differently:main' into main
AmiyahJo Oct 14, 2024
18f65ee
Merge branch 'code-differently:main' into main
AmiyahJo Oct 14, 2024
2dd1645
Merge branch 'code-differently:main' into main
AmiyahJo Oct 14, 2024
0de8601
Merge branch 'code-differently:main' into main
AmiyahJo Oct 14, 2024
85dd364
Merge branch 'code-differently:main' into main
AmiyahJo Oct 16, 2024
0afda26
Merge branch 'code-differently:main' into main
AmiyahJo Oct 16, 2024
f31e8d9
Merge branch 'code-differently:main' into main
AmiyahJo Oct 16, 2024
3e24069
Merge branch 'code-differently:main' into main
AmiyahJo Oct 17, 2024
8600f6c
Merge branch 'code-differently:main' into main
AmiyahJo Oct 17, 2024
563b076
Merge branch 'code-differently:main' into main
AmiyahJo Oct 18, 2024
b01a324
Merge branch 'code-differently:main' into main
AmiyahJo Oct 18, 2024
697a72d
Merge branch 'code-differently:main' into main
AmiyahJo Oct 21, 2024
92891f6
Merge branch 'code-differently:main' into main
AmiyahJo Oct 21, 2024
672ce73
feat: adds comments
Oct 21, 2024
c03667f
feat: adds code snippets
Oct 21, 2024
7e39738
feat: adds constraints
Oct 21, 2024
710b3c1
fix: variables "even" and "odd" turned to integers
Oct 21, 2024
c3c4b1d
Merge branch 'code-differently:main' into feature/lesson_12
AmiyahJo Oct 22, 2024
c0545ad
feat: adds if else statement on whether one of the teams win or if it…
Oct 22, 2024
1f4bdbd
Merge remote-tracking branch 'refs/remotes/origin/feature/lesson_12' …
Oct 22, 2024
eedad00
feat: adds code to solve the problem
Oct 22, 2024
7c6d0b1
fix: adding a point if one of the even or odd indexed node is higher
Oct 22, 2024
1fac40a
chore: remove constraints comments
Oct 22, 2024
59bfb07
chore: remove comments in lesson12.java file
Oct 22, 2024
a08470d
feat: adds code in ListNode push method and boolean isEmpty
Oct 22, 2024
7c37b67
feat: add implementation to stack pop and push
Oct 22, 2024
9a74b59
chore: spacing in peek method for Stack.java
Oct 22, 2024
77ecfc5
fix: replace stack.java 'top == null' to isEmpty() for if statements
Oct 22, 2024
4700bdb
fix: Code rewrite in stack.java and an exception reccomended by vscode
Oct 22, 2024
a2e4d65
fix: changed stack pop method
Oct 22, 2024
a75ae55
chore : remove comment
Oct 22, 2024
7ac1c12
fix: githubs recoomendation to avoid violations
Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@

public class Lesson12 {

/**
* Provide the solution to LeetCode 3062 here:
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
*/
public String gameResult(ListNode head) {
return null;

int oddPoints = 0;
int evenPoints = 0;

ListNode current = head;

while (current != null && current.next != null) {
if (current.val > current.next.val) {
evenPoints++;
} else if (current.val < current.next.val) {
oddPoints++;
}
current = current.next.next;
}

if (oddPoints > evenPoints) {
return "Odd";
} else if (evenPoints > oddPoints) {
return "Even";
} else {
return "Tie";
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.codedifferently.lesson12;

import java.util.EmptyStackException;

/** Implement the below Stack by providing code for the class methods. */
public class Stack {
private ListNode top;
Expand All @@ -9,18 +11,29 @@ public Stack() {
}

public void push(int value) {
// Your code here
ListNode newNode = new ListNode(value);
newNode.next = top;
top = newNode;
}

public int pop() {
return 0;
if (isEmpty()) {
throw new EmptyStackException();
} else {
int value = top.val;
top = top.next;
return value;
}
}

public int peek() {
return 0;
if (isEmpty()) {
throw new EmptyStackException();
}
return top.val;
}

public boolean isEmpty() {
return true;
return top == null;
}
}