Skip to content

Commit d607cf2

Browse files
authored
Create Find Closest Person.java
1 parent 6c82d5e commit d607cf2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Easy/Find Closest Person.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution {
2+
public int findClosest(int x, int y, int z) {
3+
int diffOne = Math.abs(x - z);
4+
int diffTwo = Math.abs(y - z);
5+
return diffOne == diffTwo ? 0 : (diffOne < diffTwo ? 1 : 2);
6+
}
7+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy