# 数组中的双指针

### 求N数之和为target的子数组

#### 解题思路

#### 题型

通常用于求N数组成的子数组，且满足和/乘积为target的子数组，或者子数组的个数等这些题型。解题时使用双指针，一个指向最左边，一个指向最右边，然后根据判断条件不断移动左指针或者右指针，直到到达结束条件。

#### 注意点

**但是需要注意的是数组必须是排序好的，如果没有排序则需要先排序。**

#### 去重

### 滑动窗口

#### 题型

通常用于求满足条件的**连续数组**，例如**乘积小于 K 的子数组。**

#### 注意点

注意数组中的数字是否都是正数，例如求子数组之和为k时，数组必须都是正整数，否则使用滑动窗口将毫无意义。

### 前缀和


---

# 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://1425816423.gitbook.io/suan-fa-xiao-ce/shu-zu/shu-zu-zhong-de-shuang-zhi-zhen.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.
