Can a string be split into a sequence of dictionary words? Think splitting hashtags ("machinelearning" → "machine learning") or segmenting text in languages without spaces.
Implement can_break(s, words) and segment(s, words), which returns one valid segmentation as a list, preferring the split whose first word is longest, then recursively the same rule. Return None if there isn't one. Words can be reused.