Skip to content
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

feat: adds amiyah jones' lesson 12 & stack typescript files #409

Closed
wants to merge 73 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 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
17fdee5
Merge branch 'code-differently:main' into main
AmiyahJo Oct 22, 2024
90a4c55
feat: adds lesson12.ts snippets
Oct 22, 2024
07989fb
Merge branch 'code-differently:main' into feature/lesson12_extra
AmiyahJo Oct 23, 2024
b0c63c4
feat: adds listnode
Oct 23, 2024
2be3bd2
feat: typescript versoin of creating a ListNode
Oct 23, 2024
39db8a2
chore: adjust listnode comment
Oct 23, 2024
4a4e6fa
feat: adjusts .java code to typescript language
Oct 23, 2024
14d00d6
fix: joined lesson12.ts oddPoints and evenPoints together
Oct 23, 2024
e566771
fix: commented out lesson12.ts while loop
Oct 23, 2024
d598b70
feat: adds while loop using my current pointer
Oct 23, 2024
992be27
feat: adds java implementation for reference
Oct 23, 2024
4f9e138
feat: adds typescript version of code for stack.ts
Oct 23, 2024
7ca9a49
vhore: remove .java implementation comments of stack.ts
Oct 23, 2024
394abcf
fix: final adjustments with peek() return undefined to null
Oct 23, 2024
47f79a3
chore: remove lesson12.ts comments
Oct 23, 2024
3e66149
fix: used singlequotes for lesson12.ts strings
Oct 23, 2024
d9eaced
fix: removed 'this.top!' for githubs non-null assertion
Oct 23, 2024
d511f07
fix: adjustments to this.top.val and boolean in stack.ts
Oct 23, 2024
d6af86e
fix: alter this.top in stack.ts
Oct 23, 2024
295e936
fix: alter this.top text
Oct 23, 2024
6175f1b
fix: peek() method in stack.ts
Oct 23, 2024
9937d62
fix: peek() method in stack.ts if statement
Oct 23, 2024
c69fb10
Merge branch 'code-differently:main' into feature/lesson12_extra
AmiyahJo Oct 23, 2024
f692d0a
Merge branch 'code-differently:main' into feature/lesson12_extra
AmiyahJo Oct 24, 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
25 changes: 20 additions & 5 deletions lesson_12/structs_ts/src/lesson12.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import { ListNode } from './list_node.js';

export 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 gameResult(head: ListNode | null): string {
return '';
let [oddPoints, evenPoints] = [0,0];
let 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 ? current.next.next || null : null;
AmiyahJo marked this conversation as resolved.
Show resolved Hide resolved
}

if (oddPoints > evenPoints) {
return 'Odd';
} else if (evenPoints > oddPoints) {
return 'Even';
} else {
return 'Tie';
}
}
}
19 changes: 15 additions & 4 deletions lesson_12/structs_ts/src/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,29 @@ export class Stack {
}

push(value: number): void {
throw new Error('Not implemented');
const newNode = new ListNode(value)
newNode.next = this.top;
this.top = newNode;
}

pop(): number | undefined {
throw new Error('Not implemented');
if (this.isEmpty()) {
return undefined;
}

const value = this.top?.val;
this.top = this.top?.next;
AmiyahJo marked this conversation as resolved.
Show resolved Hide resolved
return value;
}

peek(): number | null {
throw new Error('Not implemented');
if (this.top === undefined) {
throw new Error('Stack is empty');
}
return this.top.val;
}

isEmpty(): boolean {
throw new Error('Not implemented');
return this.top === undefined;
}
}