1

PROBLEM OF THE DAY : 20/02/2024 | Word Break

 6 months ago
source link: https://www.geeksforgeeks.org/videos/problem-of-the-day-20022024-word-break/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

PROBLEM OF THE DAY : 20/02/2024

February 22, 2024 |130 Views
PROBLEM OF THE DAY : 20/02/2024 | Word Break
Problem of the Day, String, Data Structure and Algorithm
 Save  Share   Like
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Yash Dwivedi. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Strings but also build up problem-solving skills.

In this problem, we are given a string A and a dictionary of n words B, to find out if A can be segmented into a space-separated sequence of dictionary words. Return 1 if it is possible to break A into a sequence of dictionary words, else return 0.

Note: From the dictionary B each word can be taken any number of times and in any order.

Example :

Input:
n = 6
B = { "i", "like", "sam", "sung", "samsung", "mobile"}
A = "ilike"
Output:
1

Explanation:
The string can be segmented as "i like".

Give the problem a try before going through the video. All the best!!!
Problem Link: https://www.geeksforgeeks.org/problems/word-break1352/1

Read More

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK