Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9db165d

Browse files
add 3248
1 parentb61d906 commit9db165d

File tree

2 files changed

+24
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+24
-0
lines changed

‎paginated_contents/algorithms/4th_thousand/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
3+
| 3248|[Snake in Matrix](https://leetcode.com/problems/snake-in-matrix/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3248.java)|| Easy|
34
| 3243|[Shortest Distance After Road Addition Queries I](https://leetcode.com/problems/shortest-distance-after-road-addition-queries-i/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3243.java)|| Medium|
45
| 3242|[Design Neighbor Sum Service](https://leetcode.com/problems/design-neighbor-sum-service/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3242.java)|| Easy|
56
| 3241|[Time Taken to Mark All Nodes](https://leetcode.com/problems/time-taken-to-mark-all-nodes/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3241.java)|| Hard|
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
packagecom.fishercoder.solutions.fourththousand;
2+
3+
importjava.util.List;
4+
5+
publicclass_3248 {
6+
publicstaticclassSolution1 {
7+
publicintfinalPositionOfSnake(intn,List<String>commands) {
8+
int[]pos =newint[2];
9+
for (Stringcommand :commands) {
10+
if (command.equals("RIGHT")) {
11+
pos[1]++;
12+
}elseif (command.equals("DOWN")) {
13+
pos[0]++;
14+
}elseif (command.equals("UP")) {
15+
pos[0]--;
16+
}elseif (command.equals("LEFT")) {
17+
pos[1]--;
18+
}
19+
}
20+
returnpos[0] *n +pos[1];
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp