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// trueAssuming 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
ASCIIcharacters (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?
xxxxxxxxxx36
var assert = require('assert');​function stringBreakdown(str, dictArr) { return true;}​const str = 'applecomputer';const dictArr = ['apple', 'computer'];stringBreakdown(str, dictArr);// true​try { assert.equal( stringBreakdown('crazyrichasians', ['crazy', 'rich', 'asians']), true );​ console.log( 'PASSED: ' + "Expect <code>stringBreakdown('crazyrichasians', ['crazy', 'rich', 'asians'])</code> to return <code>true</code>" );} catch (err) { console.log(err);}​try { assert.equal(stringBreakdown('lockcombination', ['lock', 'combo']), false);​ console.log(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.

