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
sealed case class BrandSafetyFeatureStatus(override val value: Long) extends FlaggedEnum[BrandSafetyFeatureStatus] | |
object BrandSafetyFeatureStatus extends enumeratum.Enum[BrandSafetyFeatureStatus] { | |
object Inclusion extends BrandSafetyFeatureStatus(1L << 0) | |
object Exclusion extends BrandSafetyFeatureStatus(1L << 1) | |
object Exception extends BrandSafetyFeatureStatus(1L << 2) | |
override def values: IndexedSeq[BrandSafetyFeatureStatus] = findValues | |
} |
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
// https://leetcode.com/problems/n-queens-ii/ | |
object Solution extends App { | |
def totalNQueens(N: Int): Int = { | |
type Board = Array[Array[Boolean]] | |
def putQueen(board: Board, row: Int, col: Int): Unit = board(row)(col) = true | |
def removeQueen(board: Board, row: Int, col: Int): Unit = board(row)(col) = false | |
def isValid(board: Board, row: Int, col: Int): Boolean = { | |
val checkCol = (0 until row).forall(currRow => board(currRow)(col) == false ) | |
val checkLeftDiagonal = ((row to 0 by -1) zip (col to 0 by -1)).forall { case (currRow, currCol) => board(currRow)(currCol) == false } | |
val checkRightDiagonal = ((row to 0 by -1) zip (col until N)).forall { case (currRow, currCol) => board(currRow)(currCol) == false } |
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
// https://leetcode.com/problems/binary-tree-right-side-view/ | |
class TreeNode(_value: Int = 0, _left: TreeNode = null, _right: TreeNode = null) { | |
var value: Int = _value | |
var left: TreeNode = _left | |
var right: TreeNode = _right | |
} | |
object Solution { | |
def rightSideView(root: TreeNode): List[Int] = { |
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
// https://leetcode.com/problems/validate-binary-search-tree/ | |
class TreeNode(_value: Int = 0, _left: TreeNode = null, _right: TreeNode = null) { | |
var value: Int = _value | |
var left: TreeNode = _left | |
var right: TreeNode = _right | |
} | |
object Solution { | |
def isValidBST(root: TreeNode): 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
val HadoopVersion = "2.5.2" | |
val hadoop = Seq( | |
"org.apache.hadoop" % "hadoop-client" % HadoopVersion exclude("org.slf4j", "*") | |
) | |
val parquet4s = Seq( | |
"com.github.mjakubowski84" %% "parquet4s-core" % "1.7.0" exclude("org.slf4j", "*") | |
) |
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.concurrent.duration._ | |
import scala.concurrent.{Await, Future} | |
import scala.concurrent.duration.FiniteDuration | |
import scala.util.control.NonFatal | |
import scala.concurrent.ExecutionContext.Implicits.global | |
def foo(): Future[Unit] = if(Math.random() >= 1/3) Future.failed(new RuntimeException("")) else Future.successful(()) | |
def retry[T](retries: Int, delay: FiniteDuration)(fn: => Future[T]): Future[T] = { | |
fn recoverWith { |
![welcome.gif](https://gist.github.com/ZviMints/21c598c659081f9c0866e29a00bc2468/raw/05205bd01a980bfaaf4b81b8e5264d9fc127f73f/welcome.gif)