# 常見 Edge Case

<https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/learn/lecture/11172596#overview>

* 負數
* 有無空值
* input 值是否會重覆  eg. \["practice", "makes", "perfect", "coding", "makes"]
* 是否排序
* 有沒有負數
* 排序是小到大 (ascending order)，還是大到小 ( decreasing order)
* 是否會有兩個以上答案
* 會有 leading zero 嗎? ex 03, 04
* 字串有無大小寫之分 (case sensitive ?)
* input 是否在範圍內

## Array

```
['Bob', 'Ben', 'Tim', 'Jane', 'John']
```

* 有沒有空字串&#x20;

```javascript
items = ['Bob', 'Ben', '', '', 'John']
// 先篩掉
items.filter((item) => !!item);
```

```javascript
是不是只有一個
items = ['Bob']
 if (items.length === 1) {
    return items[0];
  }

是不是空陣列
items = []
if (!items || items.length === 0) {
    return "";
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hannahpun.gitbook.io/leetcode-note/tools/chang-jian-edge-case.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
