Created
July 17, 2017 11:54
-
-
Save akshanshjain95/76ccb6745ac38d21622719e74eef57c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.knoldus.kip.models | |
class Stack(stackWithList: List[Int]) { | |
def pop: Stack = { | |
if(stackWithList.isEmpty) { | |
throw new RuntimeException | |
} | |
new Stack(stackWithList.tail) | |
} | |
def push(x: Int): Stack = { | |
new Stack(x :: stackWithList) | |
} //returns the top after pushing the element on the stack | |
} | |
---------------- | |
package com.knoldus.kip.models | |
class Queue(queueWithList: List[Int]) { | |
def enqueue(x: Int): Queue = { | |
val newQueue = x :: queueWithList.reverse | |
new Queue(newQueue.reverse) | |
} | |
def dequeue: Queue = { | |
new Queue(queueWithList.tail) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def generateScorecards: Map[String, AnyRef] = {
}