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

Commit0e8724f

Browse files
add 1848
1 parent88dd14a commit0e8724f

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
11+
|1848|[Minimum Distance to the Target Element](https://leetcode.com/problems/minimum-distance-to-the-target-element/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1848.java)||Easy|Array|
1112
|1845|[Seat Reservation Manager](https://leetcode.com/problems/seat-reservation-manager/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1845.java)||Medium|Heap, Design|
1213
|1844|[Replace All Digits with Characters](https://leetcode.com/problems/replace-all-digits-with-characters/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1844.java)||Easy|String|
1314
|1837|[Sum of Digits in Base K](https://leetcode.com/problems/sum-of-digits-in-base-k/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_1837.java)||Easy|Math, Bit Manipulation|
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
packagecom.fishercoder.solutions;
2+
3+
publicclass_1848 {
4+
publicstaticclassSolution1 {
5+
publicintgetMinDistance(int[]nums,inttarget,intstart) {
6+
intresult =0;
7+
intminDiff =Integer.MAX_VALUE;
8+
for (inti =0;i <nums.length;i++) {
9+
if (nums[i] ==target) {
10+
if (Math.abs(start -i) <minDiff) {
11+
minDiff =Math.abs(start -i);
12+
result =minDiff;
13+
}
14+
}
15+
}
16+
returnresult;
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp