Update almost-sorted-interval

Can remove count of sets with length 1 from for loop as the value is always N and N is known. Use previous version if N is unknown.