Good morning! Here's our prompt for today.
We're given a string and need to see if it can be broken down into words from a dictionary array. For example:
JAVASCRIPT
1const str = "applecomputer";
2const dictArr = ["apple", "computer"];
3stringBreakdown(str, dictArr);
4// true
Assuming that there are no repeats in the dictionary array, can you write a method that will return true
if the string can be broken down into words from the array, or false
if not?

Constraints
- Length of the string <=
1000
- The string is made up of
ASCII
characters (all or some of it) - Expected time complexity :
O(n^2)
- Expected space complexity :
O(n)
Try to solve this here or in Interactive Mode.
How do I practice this challenge?
xxxxxxxxxx
46
​
import static org.junit.Assert.*;
​
import java.util.*;
import java.util.HashMap;
import org.junit.*;
import org.junit.runner.*;
import org.junit.runner.notification.*;
​
public class MainTest {
​
public static boolean stringBreakdown(String dictionary[], String str[]) {
// fill in
return true;
}
​
// tests
​
public void testOne() {
String dictionary[] = {
"get",
"a",
"all",
"with",
"friends",
"algo",
"daily",
"inter",
};
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment
Here's how we would solve this problem...
How do I use this guide?
Access all course materials today
The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.