Skip to content

Commit

Permalink
Create 搜索技巧1.md
Browse files Browse the repository at this point in the history
dfs搜索技巧
  • Loading branch information
xxzuo committed May 23, 2022
1 parent dc83ac8 commit ef0e163
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions source/_posts/搜索技巧1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: 搜索技巧1
date: 2022-05-23 22:17:16
categories:
- Algorithm
tags:
- leetcode
---



# 利用数组确定搜索方向



我们可以新建方向数组,这样 dfs 里不用自己手写搜索方向

```java
int[] dx = new int[]{1, 0, -1, 0};
int[] dy = new int[]{0, 1, 0, -1};

for(int n = 0; n< 4; n++){
int nx = i + dx[n];
int ny = j + dy[n];
}

```

0 comments on commit ef0e163

Please sign in to comment.