Meta Interview Question

Find if a word can be constructed from the dictionary

Interview Answers

Anonymous

Nov 9, 2018

Non optimally, but laid out all possible solutions + complexities.

1

Anonymous

Nov 11, 2018

public boolean wordBreak(String s, List wordDict) { Set dict = new HashSet(wordDict); boolean[] f = new boolean[s.length() + 1]; f[0] = true; for(int i=1; i <= s.length(); i++){ for(int j=0; j < i; j++){ if(f[j] && dict.contains(s.substring(j, i))){ f[i] = true; break; } } } return f[s.length()]; }

Anonymous

Dec 8, 2018

LeetCode Problem 139. Word Break