Class Solution
java.lang.Object
g2701_2800.s2788_split_strings_by_separator.Solution
2788 - Split Strings by Separator.<p>Easy</p>
<p>Given an array of strings <code>words</code> and a character <code>separator</code>, <strong>split</strong> each string in <code>words</code> by <code>separator</code>.</p>
<p>Return <em>an array of strings containing the new strings formed after the splits, <strong>excluding empty strings</strong>.</em></p>
<p><strong>Notes</strong></p>
<ul>
<li><code>separator</code> is used to determine where the split should occur, but it is not included as part of the resulting strings.</li>
<li>A split may result in more than two strings.</li>
<li>The resulting strings must maintain the same order as they were initially given.</li>
</ul>
<p><strong>Example 1:</strong></p>
<p><strong>Input:</strong> words = [“one.two.three”,“four.five”,“six”], separator = “.”</p>
<p><strong>Output:</strong> [“one”,“two”,“three”,“four”,“five”,“six”]</p>
<p><strong>Explanation:</strong></p>
<p>In this example we split as follows: “one.two.three” splits into</p>
<p>“one”, “two”, “three” “four.five” splits into</p>
<p>“four”, “five” “six” splits into “six”</p>
<p>Hence, the resulting array is [“one”,“two”,“three”,“four”,“five”,“six”].</p>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> words = [“$easy$”,“$problem$”], separator = “$”</p>
<p><strong>Output:</strong> [“easy”,“problem”]</p>
<p><strong>Explanation:</strong></p>
<p>In this example we split as follows:</p>
<p>“$easy$” splits into “easy” (excluding empty strings)</p>
<p>“$problem$” splits into “problem” (excluding empty strings)</p>
<p>Hence, the resulting array is [“easy”,“problem”].</p>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> words = [“|||”], separator = “|”</p>
<p><strong>Output:</strong> []</p>
<p><strong>Explanation:</strong></p>
<p>In this example the resulting split of “|||” will contain only empty strings, so we return an empty array [].</p>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>1 <= words.length <= 100</code></li>
<li><code>1 <= words[i].length <= 20</code></li>
<li>characters in <code>words[i]</code> are either lowercase English letters or characters from the string <code>".,|$#@"</code> (excluding the quotes)</li>
<li><code>separator</code> is a character from the string <code>".,|$#@"</code> (excluding the quotes)</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
splitWordsBySeparator
-