Hands of Straights (LeetCode) Arrange the card Tried this leetcode question Hands of Straights. https://leetcode.com/problems/hand-of-straights/
Description is 
Alice has a hand of cards, given as an array of integers.

Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecutive cards.

Return true if and only if she can.

Example 1.
Input: hand = [1,2,3,6,2,3,4,7,8], W = 3
Output: true
Explanation: Alice's hand can be rearranged as [1,2,3],[2,3,4],[6,7,8].

Example 2
Input: hand = [1,2,3,4,5], W = 4
Output: false
Explanation: Alice's hand can't be rearranged into groups of 4.


My attempt to solve it using Haskell is here. Can someone review it. The code returns the correct values for most of the test cases that I have tried.

import Data.List

{-
solve 3 [1,1,2,2,2,3,3,3,4]
True

solve 3 [1,1,2,2,2,3,3,3]
False

solve 4 [1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4]
True
-}

solve::Int -&gt; [Int] -&gt; Bool
solve v xss = helper v $ group $ sort xss

helper::Int -&gt;[[Int]] -&gt; Bool
helper v [] = True
helper v xss = let (a, b) = splitAt v xss 
    in case verify a  &amp;&amp; ((length a) `mod` v == 0)  of
        True -&gt; helper v $ (removeHead a []) ++ b
        False -&gt; False

verify::[[Int]] -&gt; Bool
verify [] = True
verify (x:[]) = True
verify (x:y:zx) 
    | head y == succ (head x) = verify $ y:zx
    | otherwise = False

removeHead::[[Int]] -&gt; [[Int]]-&gt; [[Int]]
removeHead [] acc = acc
removeHead (x:xss) acc = case null (tail x) of
    True -&gt; removeHead xss acc
    False -&gt; removeHead xss (acc ++ [tail x])
Lines like False -&gt; False indicate that there is a better way.

helper :: Int -&gt; [[Int]] -&gt; Bool
helper v [] = True
helper v xss = let (a, b) = splitAt v xss 
  in verify a &amp;&amp; length a `mod` v == 0 -- length a &lt;= v, so why not just length a == v?
  &amp;&amp; helper v (removeHead a [] ++ b)

removeHead :: [[Int]] -&gt; [[Int]] -&gt; [[Int]]
removeHead [] acc = acc
removeHead (x:xss) acc = removeHead xss
  $ acc ++ [tail x | not $ null $ tail x]


Left folds like removeHead can often be turned into right folds:

removeHead :: [[Int]] -&gt; [[Int]]
removeHead [] = []
removeHead (x:xss) = [tail x | not $ null $ tail x] ++ removeHead xss


removeHead needs no explicit recursion. Data.List.NonEmpty lets us avoid partial functions (and giving verify a name :) ).

import Data.List.NonEmpty

solve :: Int -&gt; [Int] -&gt; Bool
solve v = helper v . NE.group . sort

helper :: Int -&gt; [NE.NonEmpty Int] -&gt; Bool
helper v [] = True
helper v xss =
  let (a, b) = splitAt v xss
      (straight, a') = unzip $ map NE.uncons a
  in all (==1) (zipWith subtract straight (tail straight))
  &amp;&amp; length a == v
  &amp;&amp; helper v (catMaybes a' ++ b)