Created
June 17, 2025 17:04
-
-
Save blzjns/eaee40972919ff27fd885b27a3af654c to your computer and use it in GitHub Desktop.
Check whether 3 nums are evenly spaced. E.g. Get the smallest, and largest numbers and use them to calculate the medium, then return whether the diff from mid to small equals the diff from large to mid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public boolean evenlySpaced(int a, int b, int c) { | |
int sm = Math.min(Math.min(a, b), c); | |
int lg = Math.max(Math.max(a, b), c); | |
//int md = (a+b+c) - (Math.min(Math.min(a,b),c) + Math.max(Math.max(a,b),c)); | |
int md = (a+b+c)-(sm+lg); | |
return md-sm == lg-md; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment