Coding Test

最後編輯:2019-10-24 建立:2019-10-24 歷史紀錄

DKEN CGiven a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences.

 

Input: s = “kaiosinc”, wordDict = [“kaios”, “inc”]

Output: true

 

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

Output: false

 

  • class Test(object):
  • def __init__(self):
  • pass