Memory isn't O(TOTAL_LENGTH), but O(TOTAL_LENGTH * ALPHABET_SIZE)
Read more… (7 words)
Memory isn't O(TOTAL_LENGTH), but O(TOTAL_LENGTH * ALPHABET_SIZE)
Maybe people overthinked the problem because counting the numer of quadruples is different from "finding all the quadruples".