Coding

Break a string into space-separated words using a dictionary.

Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.

Input: s = "catsandog", wordDict = ["cats", "dog", "sand", "and", "cat"]

Output: FALSE

Explanation: There is no valid segmentation. "cats" and "and" leaves "og", which is not in the dictionary.

Was asked at

Practice this question with AI

First session is free - no credit card required.

Go Premium

More interviews, more skills, more success.

No answers yet

Be the first to share your approach to this question

Practice More Questions