Created
February 24, 2017 02:31
-
-
Save hikilaka/a00b015dc05d30ee892f95e292516806 to your computer and use it in GitHub Desktop.
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
int shapeArea(int n) { | |
int maxLen = ((n - 1) * 2) + 1; | |
int area = 0; | |
for (int i = maxLen - 2; i > 0;) { | |
area += i * 2; | |
i -= 2; | |
} | |
area += maxLen; | |
return area; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment