Mark As Completed Discussion

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?

Description

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?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Here's our guided, illustrated walk-through.

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.

Returning members can login to stop seeing this.