---
# System prepended metadata

title: Weekly Contest 357
tags: [Weekly Contest]

---

###### tags: `Weekly Contest`
# Weekly Contest 357

## [2810. Faulty Keyboard](https://leetcode.com/problems/faulty-keyboard) (<font color=#00B8A3>Easy</font>)

限制 :

<ul>
<li><code>10<sup>4</sup></code></li>
</ul>

### Solution

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

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

程式碼:

```c++=
class Solution {
public:
    string finalString(string s) {
        string result = "";
        for(int i=0;i<s.size();i++)
        {
            if(s[i]=='i')
                reverse(result.begin(), result.end());
            else
                result += s[i];
        }
        return result;
    }
};
```

## [2811. Check if it is Possible to Split Array](https://leetcode.com/problems/check-if-it-is-possible-to-split-array) (<font color=#FFC011>Medium</font>)

限制 :

<ul>
<li><code>1 <= n == nums.length <= 100</code></li>
<li><code>1 <= nums[i] <= 100</code></li>
<li><code>1 <= m <= 200</code></li>
</ul>

### Solution
這題的重點在於拆解到最後其實是要找到一個兩兩相家會大於等於 m 的數字，如果有找到，則怎麼拆終究會拆到剩他們。
#### 時間複雜度: $O(n)$

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

程式碼:

```c++=
class Solution {

public:
    bool canSplitArray(vector<int>& nums, int m) {
        if (nums.size() <= 2)
            return true;
        for (int i = 0; i < nums.size() - 1; i++) {
            if (nums[i] + nums[i + 1] >= m) {
                return true;
            }
        }
        return false;
    }
};
```

## [2812. Find the Safest Path in a Grid](https://leetcode.com/problems/find-the-safest-path-in-a-grid)(<font color=#FFC011>Medium</font>)

限制 :

<ul>
<li><code>10<sup>4</sup></code></li>
</ul>
### Solution

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

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

程式碼:

```c++=
```

## [2813. Maximum Elegance of a K-Length Subsequence](https://leetcode.com/problems/maximum-elegance-of-a-k-length-subsequence)(<font color=#FF375F>Hard</font>)

限制 :

<ul>
<li><code>10<sup>4</sup></code></li>
</ul>
### Solution

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

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

程式碼:

```c++=
```
