---
# System prepended metadata

title: Weekly Contest 355
tags: [Weekly Contest]

---

###### tags: `Weekly Contest`
# Weekly Contest 355

## [2788. Split Strings by Separator](https://leetcode.com/problems/split-strings-by-separator/)(<font color=#00B8A3>Easy</font>)

限制 :

<ul>
<li><code>1 <= words.length <= 100</code></li>
<li><code>1 <= words[i].length <= 20</code></li>
<li><code>characters in words[i] are either lowercase English letters or characters from the string ".,|$#@" (excluding the quotes)
</code></li>
<li><code>separator is a character from the string ".,|$#@" (excluding the quotes)</code></li>
</ul>

### Solution
這題我的解法是很基礎的寫法，如果有更好的解法可以跟我說。
#### 時間複雜度: $O(n^2)$

#### 空間複雜度: $O(n)$

程式碼:

```c++=
class Solution {
public:
    vector<string> splitWordsBySeparator(vector<string>& words, char separator) {
        vector<string>results;
        for(int words_index=0; words_index<words.size(); words_index++)
        {
            string str = "", word = words[words_index];
            int preindex = 0, postindex = 0;
            for(int i=0;i<word.size();i++)
            {
                if(word[i]==separator)
                {
                    str.assign(word.begin()+preindex, word.begin()+postindex);
                    if(str.size())
                    {
                        results.push_back(str);
                    }
                    preindex = i+1;
                }
                postindex++;
            }
            if(postindex != preindex || postindex == 0)
            {
                str.assign(word.begin()+preindex, word.begin()+int(word.size()));
                if(str.size())
                {
                    results.push_back(str);
                }
            }
        }
        return results;
    }
};
```

## [2789. Largest Element in an Array after Merge Operations](https://leetcode.com/problems/largest-element-in-an-array-after-merge-operations/)(<font color=#FFC011>Medium</font>)

限制 :

<ul>
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
<li><code>1 <= nums[i] <= 10<sup>6</sup></code></li>
</ul>

### Solution

#### 時間複雜度: $O()$

#### 空間複雜度: $O()$

程式碼:

```c++=
```

## [2790. Maximum Number of Groups With Increasing Length](https://leetcode.com/problems/maximum-number-of-groups-with-increasing-length/)(<font color=#FF375F>Hard</font>)

限制 :

<ul>
<li><code>1 <= usageLimits.length <= 10<sup>5</sup></code></li>
<li><code>1 <= usageLimits[i] <= 10<sup>9</sup></code></li>
</ul>

### Solution

#### 時間複雜度: $O()$

#### 空間複雜度: $O()$

程式碼:

```c++=
```

## [2791. Count Paths That Can Form a Palindrome in a Tree](https://leetcode.com/problems/count-paths-that-can-form-a-palindrome-in-a-tree/)(<font color=#FF375F>Hard</font>)

限制 :

<ul>
<li><code>n == parent.length == s.length</code></li>
<li><code>1 <= n <= 10<sup>5</sup></code></li>
<li><code>0 <= parent[i] <= n - 1 for all i >= 1</code></li>
<li><code>parent[0] == -1</code></li>
<li><code>parent represents a valid tree.</code></li>
<li><code>s consists of only lowercase English letters.</code></li>
</ul>

### Solution

#### 時間複雜度: $O()$

#### 空間複雜度: $O()$

程式碼:

```c++=
```
