-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
42 lines (38 loc) · 1.37 KB
/
Main.java
File metadata and controls
42 lines (38 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.surenderthakran.codes.segmentstringintodictionarywords;
/**
* Given an input string and a list of words, determnine if the whole input string can be used to
* create sub-strings which are all words from the list.
*
* <p>ex: For input string "ilikedogs" and strings list {"i", "like", "liked", "dogs"}, the input
* string can be divided into words "i", "like" and "dogs" which are all part of the input list of
* words.
*
* <p>Assumptions:
*
* <ul>
* <li>The input and words are composed of only lowercase english alphabet.
* </ul>
*/
class Main {
public static void main(String[] args) {
boolean assertsEnabled = false;
assert assertsEnabled = true;
if (assertsEnabled) {
assert new Solution()
.canInputBeSegmentedInDictionaryWords(
"ilikedogs", new String[] {"i", "like", "liked", "dogs"})
== true;
assert new Solution()
.canInputBeSegmentedInDictionaryWords(
"ilikedogs", new String[] {"i", "liked", "dogs"})
== false;
assert new Solution()
.canInputBeSegmentedInDictionaryWords(
"sachintendulkar", new String[] {"sachin", "ramesh", "tendulkar"})
== true;
System.out.println("All Assertions Succeeded!");
} else {
System.out.println("Asserions not enabled! Results not verified!");
}
}
}