Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Strings are lethal for me!! Please help!!

Правка en2, от LZD_DeViL0902, 2020-07-24 15:25:56

Okay, so I again came up with a similar String question and I don't know how to approach these questions(Optimally), I will be thankful for the explanations if any..

Question Given a sentence string with no spaces in between, find the minimum number of spaces that can be there in the string so that all the generated words are present in a given dictionary. Example:

string: abcdef no.of words in dictionary: 5 dictionary: a bc def ab abc

Answer: 1 Explanation : By inserting 1 space as shown — 'abc def' we get 2 words abc and def which are valid words in the language Note: You could also split it as 'a bc def' But this would not be the case with minimum number of spaces.

I will be Thankful to the helping responses.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en4 Английский LZD_DeViL0902 2020-07-24 15:27:29 6 Tiny change: 'Answer: 1 \nExplanat' -> 'Answer: 1 ,,,,,,\nExplanat'
en3 Английский LZD_DeViL0902 2020-07-24 15:27:00 13
en2 Английский LZD_DeViL0902 2020-07-24 15:25:56 4 Tiny change: 'lly), I with be thankf' -> 'lly), I will be thankf'
en1 Английский LZD_DeViL0902 2020-07-24 15:25:29 794 Initial revision (published)