Last active
March 15, 2022 07:32
-
-
Save riyafa/c15bef065e4ce84581a1252f3f0e2baa to your computer and use it in GitHub Desktop.
Mathematical solution for 441. Arranging Coins: https://youtu.be/H-Tdu8qJ_uk
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
class ArrangingCoins { | |
public int arrangeCoins(int n) { | |
double result = (-1.0 + Math.sqrt(1.0+8.0*n))/2.0; | |
return (int)Math.floor(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment