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

Pre Course 1 Completed #2000

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
54 changes: 0 additions & 54 deletions Exercise_1.cpp

This file was deleted.

46 changes: 0 additions & 46 deletions Exercise_1.java

This file was deleted.

80 changes: 49 additions & 31 deletions Exercise_1.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
// Time Complexity : push, pop, peek, isEmpty O(1)
// Space Complexity : O(1) since we not creating any data structure in user facing functions.
// Did this code successfully run on Leetcode : No
// Any problem you faced while coding this : NO

class Stack {
//Please read sample.java file before starting.
//Kindly include Time and Space complexity at top of each file
constructor() {
//Initialize your constructor
this.MAX = 1000;
this.top = -1;
this.a = new Array(this.MAX);
// Please read sample.java file before starting.
// Kindly include Time and Space complexity at top of each file
constructor() {
//Initialize your constructor
this.MAX = 10;
this.top = -1; // Index of top element
this.a = new Array(this.MAX);
}

isEmpty() {
//Write your code here
return this.top === -1;
}

push(x) {
this.top += 1;
this.a[this.top] = x;
}

pop() {
//If empty return 0 and print " Stack Underflow"
if (this.isEmpty()) {
return 0;
}
function isEmpty() {
//Write your code here
}
function push(x) {
//Check for stack Overflow
//Write your code here
}
function pop() {
//If empty return 0 and print " Stack Underflow"
//Write your code here
}
function peek() {
//Write your code here
let value = this.a[this.top];
this.a[this.top] = null;
this.top -= 1;
return value;
}

peek() {
//Write your code here
if (this.isEmpty()) {
return -1;
}
this.a[this.top];
}
}
let s = new Stack();
s.push(10);
s.push(20);
s.push(30);
console.log(s.pop() + " Popped from stack");

test("Scenario #1:", () => {
let obj = new Stack();
obj.push(10);
obj.push(20);
obj.push(30);

expect(obj.pop()).toStrictEqual(30);
});
24 changes: 0 additions & 24 deletions Exercise_1.py

This file was deleted.

52 changes: 0 additions & 52 deletions Exercise_2.cpp

This file was deleted.

52 changes: 0 additions & 52 deletions Exercise_2.java

This file was deleted.

Loading