Update peek() method to read from tail.

Peeking at the element should be done from the tail rather than the head.
This commit is contained in:
psquared-dev 2023-04-04 05:31:23 +05:30 committed by GitHub
parent bbbfd32a45
commit 9742eee388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -26,7 +26,7 @@ export default class Stack {
} }
// Just read the value from the start of linked list without deleting it. // Just read the value from the start of linked list without deleting it.
return this.linkedList.head.value; return this.linkedList.tail.value;
} }
/** /**