Created
May 29, 2020 07:24
-
-
Save vigneshwaranr/a455eeb9277cb82c1dd1ed8eca960da0 to your computer and use it in GitHub Desktop.
9e8a12f2112b / sumOfSquaresOfEvenElements
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 int sumOfSquaresOfEvenElements(List<Integer> list) { | |
if (list == null) { | |
return 0; | |
} | |
int acc = 0; | |
for (int elem: list) { | |
if (elem % 2 == 0) { | |
acc += (elem * elem); | |
} | |
} | |
return acc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment