Pathikrit Bhowmick

Results 72 issues of Pathikrit Bhowmick

``` scala /** * Two pointer algorithm * O(2*n) * See: * http://codeforces.com/contest/676/problem/C * http://codeforces.com/contest/580/problem/B * * @param n maximum right bound * @param f given an interval returns if...

See [Codeforces #816B](http://codeforces.com/contest/816/problem/B)

```scala // O(n^3) version def countPalindromes3(s: String): Int = (1 to s.length).flatMap(s.sliding).count(t => t.reverse == t) ``` ```scala // O(n^2) version def countPalindromes2(s: String): Int = { def countBetween(left: Int,...

``` // return Map of prime to count def primeFactors(n: Int): Map[Int, Int] ```

``` scala import scala.collection.mutable class Counter[A](allowNegativeCount: Boolean) extends mutable.Map[A, Int] { private[this] val counter = mutable.Map.empty[A, Int] withDefaultValue 0 def +=(key: A): this.type = this += (key -> 1) override...

``` scala import scala.collection.mutable /** * Container to hold helpful "[pimps](http://www.artima.com/weblogs/viewpost.jsp?thread=179766)" * @see https://github.com/stacycurl/pimpathon/issues/120 * @see https://github.com/cvogt/scala-extensions */ trait Pimps { implicit class StringInterpolations(sc: StringContext) { /** * Helper to...

https://jvns.ca/blog/2022/04/12/a-list-of-new-ish--command-line-tools/?utm_source=pocket_mylist

See: https://github.com/tonsky/AnyBar Then we can install this from homebrew?