Skip to content

Commit

Permalink
Day54: Stack
Browse files Browse the repository at this point in the history
  • Loading branch information
uttu-316 committed Dec 13, 2022
1 parent 71b909d commit 4fb9c65
Show file tree
Hide file tree
Showing 3 changed files with 232 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dsa/Day53/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,4 @@ delete arr[5]
arr.pop()
arr.shift()
arr.splice()
console.log(arr)
console.log(arr)
112 changes: 112 additions & 0 deletions dsa/Day54/stack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
//Stack has 3 operations
//push: adds value on the top
//pop : removes value from the top
//peek: return the top element of stack

//Stack Overflow
//Stack Undeflow

class Stack{
constructor(size){
this.data = [];
this.size=size;
}
push(value){
if(this.data.length<this.size){
this.data.push(value);
return this.data.length;
}
console.log('Stack Overflow')
return -1;
}
pop(){
if(this.isEmpty()){
console.log("Stack Underflow")
return -1;
}
return this.data.pop();
}
peek(){
const length = this.data.length;
if(this.isEmpty()){
console.log("Stack is Empty")
return -1;
}
return this.data[length-1];
}
isEmpty(){
return this.data.length===0;
}
}

const stack = new Stack()
stack.push(3)
stack.push(4)
stack.push(5)
stack.push(6)
stack.pop()
stack.push(10)
stack.push(12)
stack.pop()
stack.push(13)



console.log(stack.peek())


const stack2 = new Stack()
stack2.push('Rajat')
stack2.push('Smita')
stack2.push('Sree')
stack2.pop()
stack2.push('Ajay')
stack2.push('Rajeev')
stack2.push('Aniket')
stack2.pop()
stack2.push('Rahul')
stack2.push('Varsha')
stack2.pop()
stack2.pop()

console.log(stack2.peek())









const stack3 = new Stack(4)


stack.push('Apple')
stack.push('Banana')
stack.push('Stawberry')
stack.push('Guava')
stack.push('Cherry')

console.log(stack.peek())


//reverse an array using stack

const array = [1,2,3,4,5];

const newStack = new Stack(array.length);



for(let i=0;i<array.length;i++){
newStack.push(array[i])
}

//traversing on stack
let arr = [];
while(!newStack.isEmpty()){
const popedValue = newStack.pop();
arr.push(popedValue)
}
console.log(arr)
119 changes: 119 additions & 0 deletions javascript/Day51/Tinder/slick/slick.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/* Slider */
.slick-slider
{
position: relative;

display: block;
box-sizing: border-box;

-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;

-webkit-touch-callout: none;
-khtml-user-select: none;
-ms-touch-action: pan-y;
touch-action: pan-y;
-webkit-tap-highlight-color: transparent;
}

.slick-list
{
position: relative;

display: block;
overflow: hidden;

margin: 0;
padding: 0;
}
.slick-list:focus
{
outline: none;
}
.slick-list.dragging
{
cursor: pointer;
cursor: hand;
}

.slick-slider .slick-track,
.slick-slider .slick-list
{
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-o-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}

.slick-track
{
position: relative;
top: 0;
left: 0;

display: block;
margin-left: auto;
margin-right: auto;
}
.slick-track:before,
.slick-track:after
{
display: table;

content: '';
}
.slick-track:after
{
clear: both;
}
.slick-loading .slick-track
{
visibility: hidden;
}

.slick-slide
{
display: none;
float: left;

height: 100%;
min-height: 1px;
}
[dir='rtl'] .slick-slide
{
float: right;
}
.slick-slide img
{
display: block;
}
.slick-slide.slick-loading img
{
display: none;
}
.slick-slide.dragging img
{
pointer-events: none;
}
.slick-initialized .slick-slide
{
display: block;
}
.slick-loading .slick-slide
{
visibility: hidden;
}
.slick-vertical .slick-slide
{
display: block;

height: auto;

border: 1px solid transparent;
}
.slick-arrow.slick-hidden {
display: none;
}

0 comments on commit 4fb9c65

Please sign in to comment.