## Hypercube's LeetCode Weekly Contest 50

- Rank:
**183**/ 2713 - Score: 25 / 25
- Finish Time: 01:55:22

### Valid Palindrome II

Given a non-empty string `s`

, you may delete **at most** one character. Judge whether you can make it a palindrome.

**Example 1**:

```
Input: "aba"
Output: True
```

**Example 2:**

```
Input: "abca"
Output: True
Explanation: You could delete the character 'c'.
```

**Note:**

- The string will only contain lowercase characters a-z. The maximum length of the string is 50000.

**Accepted**in 00:16:42 with 2 wrong submissions

### Map Sum Pairs

Implement a MapSum class with `insert`

, and `sum`

methods.

For the method `insert`

, you’ll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key already existed, then the original key-value pair will be overridden to the new one.

For the method `sum`

, you’ll be given a string representing the prefix, and you need to return the sum of all the pairs’ value whose key starts with the prefix.

**Example 1:**

```
Input: insert("apple", 3), Output: Null
Input: sum("ap"), Output: 3
Input: insert("app", 2), Output: Null
Input: sum("ap"), Output: 5
```

**Accepted**in 00:19:25

### Valid Parenthesis String

Given a string containing only three types of characters: ‘(‘, ‘)’ and ‘*’, write a function to check whether this string is valid. We define the validity of a string by these rules:

- Any left parenthesis
`'('`

must have a corresponding right parenthesis`')'`

. - Any right parenthesis
`')'`

must have a corresponding left parenthesis`'('`

. - Left parenthesis
`'('`

must go before the corresponding right parenthesis`')'`

. `'*'`

could be treated as a single right parenthesis`')'`

or a single left parenthesis`'('`

or an empty string.- An empty string is also valid.

**Example 1:**

```
Input: "()"
Output: True
```

**Example 2:**

```
Input: "(*)"
Output: True
```

**Example 3:**

```
Input: "(*))"
Output: True
```

**Note:**

- The string size will be in the range [1, 100].

**Accepted**in 00:24:33

### 24 Game

You have 4 cards each containing a number from 1 to 9. You need to judge whether they could operated through `*`

, `/`

, `+`

, `-`

, `(`

, `)`

to get the value of 24.

**Example 1:**

```
Input: [4, 1, 8, 7]
Output: True
Explanation: (8-4) * (7-1) = 24
```

**Example 2:**

```
Input: [1, 2, 1, 2]
Output: False
```

**Note:**

- The division operator
`/`

represents real division, not integer division. For example, 4 / (1 - 2/3) = 12. - Every operation done is between two numbers. In particular, we cannot use
`-`

as a unary operator. For example, with`[1, 1, 1, 1]`

as input, the expression`-1 - 1 - 1 - 1`

is not allowed. - You cannot concatenate numbers together. For example, if the input is
`[1, 2, 1, 2]`

, we cannot write this as 12 + 12.

**Accepted**in 01:15:22 with 6 wrong submissions