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
import akka.NotUsed | |
import akka.http.scaladsl.common.{EntityStreamingSupport, JsonEntityStreamingSupport} | |
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport | |
import akka.http.scaladsl.model.headers.Accept | |
import akka.http.scaladsl.model.{MediaRange, MediaTypes} | |
import akka.http.scaladsl.server.{Directives, Route} | |
import akka.http.scaladsl.testkit.ScalatestRouteTest | |
import akka.stream.scaladsl.Source | |
import org.scalatest.{Matchers, WordSpec, WordSpecLike} | |
import spray.json.DefaultJsonProtocol |
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 linkedlist | |
sealed trait AbstractCons[+A] { | |
def value: A | |
def next: AbstractCons[A] | |
} | |
/** |
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 searchpattern | |
import scala.annotation.tailrec | |
/** | |
* ZIndex String Pattern Search | |
* inspired from https://www.youtube.com/watch?v=CpZh4eF8QBw | |
* Created by Arun Sethia on 6/6/18. | |
*/ |
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 searchpattern | |
import scala.annotation.tailrec | |
/** | |
* KMP Pattern Matching | |
* inspired from https://www.youtube.com/watch?v=GTJr8OvyEVQ | |
* Created by Arun Sethia on 6/13/18. | |
*/ | |
object KMPAlgorithm extends App { |
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
import scala.annotation.tailrec | |
/** | |
* find given string has unique characters | |
* | |
* Created by Arun Sethia on 5/21/18. | |
*/ | |
trait UniqueCharacters { | |
//ASCII Characters 128 | |
def isUnique(input: String): Boolean = { |
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
import scala.annotation.tailrec | |
/** | |
* given two strings, write a method to decide if one is a permutation of the other. | |
* Created by Arun Sethia on 7/5/18. | |
*/ | |
trait AnagramString { | |
final val ASCII_CHAR_LEN: Int = 128 |
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
/** | |
* Write a method to replace all spaces in a string with '%20: | |
* You may assume that the string has sufficient space at the end to hold the additional characters | |
* Input: "hello world " | |
* Output: "hello%20world" | |
* Created by Arun Sethia on 7/5/18. | |
*/ | |
trait URLify { | |
/** |
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
import scala.annotation.tailrec | |
/** | |
* From given string input can we make Palindrome or not | |
* Input: Tact Coa | |
* Output: True | |
* (permutations: "taco cat". "atco cta". etc.) | |
* Created by Arun Sethia on 7/6/18. | |
*/ | |
trait PalindromePermutation { |
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
import org.scalatest.{Matchers, WordSpec} | |
import scala.annotation.tailrec | |
/** | |
* There are three types of edits that can be performed on strings: insert a character, remove a character, | |
* or replace a character. | |
* Given two strings, write a function to check if they are one edit (or zero edits) away. | |
* pale, pIe -> true | |
* pales, pale -> true |
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 arraystring | |
import org.scalatest.{Matchers, WordSpec} | |
import scala.annotation.tailrec | |
import scala.collection.mutable.StringBuilder | |
/** | |
* basic string compression using the counts of repeated characters. | |
* For example, the string aabcccccaaa would become a2b1c5a3. |
OlderNewer