0
Php-string / break word
I give you a string and a dictionary of words, return true if the string can be split into words to be found in the dictionary, else return false. Example: Dictionary is {i, love, indian, food, spicy}. So, if I pass a string ilovespicy or indianfoodspicy, what would be the outcome? Example: Dictionary is {wicket, bats, man, keeper}. So, if I pass a string wicketkeeper or batswicket, what would be the outcome?
4 Respuestas
0
I don't have much experience with php. But what I would try is
#1 Pick a word from the dictionary
#2 Compare it with the similar length of the string
#3 if that's true
cut the rest of the string
and compare it with rest of the library
if match found or not go to step 5
#4 if false go to step 1
#5 print whether the result is true or false.
+ 1
i find this question on Quora and i try to solve this que. i used explode and split fun but could not figure out correctly
0
Why don't you try using regular expressions?
[ /.*my.*/, /.*dictionary.*/ ]
for each regexp I'm the array
check if the string matches the pattern
if so, return true
0
noname I was thinking about them. But it would be too easy if you use regexp.😂😂lol. I think the challenge isn't meant to test regexp use.😊