Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
\(O(f N)\) Two pointers method.
Stateless two pointer method
The stateless two pointer method assumes you can make up an \(O(1)\) Int -> Int -> Bool
predicate. Maybe cumulative sum comes with it.
Statefull two pointer method
Synopsis
- twoPointers :: Int -> (Int -> Int -> Bool) -> [(Int, Int)]
- twoPointersU :: Int -> (Int -> Int -> Bool) -> Vector (Int, Int)
- twoPtrM :: forall acc m v a. (Monad m, Vector v a) => acc -> (acc -> a -> m Bool) -> (acc -> a -> m acc) -> (acc -> a -> m acc) -> v a -> m [(Int, Int)]
- twoPtr :: Vector v a => acc -> (acc -> a -> Bool) -> (acc -> a -> acc) -> (acc -> a -> acc) -> v a -> [(Int, Int)]
Documentation
twoPointers :: Int -> (Int -> Int -> Bool) -> [(Int, Int)] #
\(O(f N)\) Stateless two pointer method over a range. Returns the longest non-null inclusive
ranges for each l
that satisfy the given check
.
twoPointersU :: Int -> (Int -> Int -> Bool) -> Vector (Int, Int) #
\(O(f N)\) Stateless two pointer method over a range. Returns the longest non-null inclusive
ranges for each l
that satisfy the given check
.