/top10

A selection of 10 problems solved in different programming languages

Primary LanguageC++

🔝🔟

Problems

  1. Rain Water
  2. Max Consecutive Ones (MCO)
  3. Longest Continuous Increasing Subsequence (LCIS)
  4. Maximum Subarray Sum (Kadanes)
  5. Sushi for Two (SF2)
  6. Maximum Gap
  7. Maximum Gap Count
  8. Three Consecutive Odds
  9. Skyline
  10. Ocean View

Algorithm & Combinators Required

Problem Algorithms Required Combinators Required
1 Rain Water reduce, map2, scan phi, under
2 MCO 1) reduce, scan
2) reduce, map, chunkBy
1) phi1
2) -
3 LCIS 1) reduce, scan, mapAdjacent
2) reduce, map, chunkBy
1) phi1
2) -
4 Kadanes reduce, scan phi1
5 SF2 reduce, mapAdjacent, map, chunkBy
reduce, mapAdjacent, indices
-
6 Max Gap sort, mapAdjacent, reduce -
7 Max Gap Count 1) sort, mapAdjacent, (RP* or map2, repeat) + reduce
2) sort, mapAdjacent, reduce
3) sort, foldl
1) sigma or s
2) -
3) -
8 TCO 1) slide, reduce
2) reduce, scan
3) reduce, map, chunkBy
1) -
2) phi1
3) -
9 Skyline 1) scan, unique -
10 OceanView 1) reverse, scan, unique_mask, indices
2) reverse, scan, progressive_index_count, map, indices
under?

* - Rank Polymorphism

Solutions

Language 1 2 3 4 5 6 7 8
BQN ⭐✔️ ⭐✔️ ✔️ ⭐✔️ ✔️ ⭐✔️ ⭐✔️ ✔️
Haskell ✔️ ✔️ ⭐✔️ ✔️ ⭐✔️ ✔️ ✔️ ✔️
APL ✔️ ✔️ ✔️ 🚫 ✔️ ✔️ ✔️ ⭐✔️
J ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
Clojure ✔️ ✔️ ✔️ ✔️ ✔️ ✔️ ✔️
C++ ✔️ ✔️ ✔️ ✔️ ✔️
Smalltalk ✔️
D ✔️

image