Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static String plusMutl(List<Integer> list) {
- int evenPos = 0;
- int oddPos = 1;
- long reven = 0;
- long rodd = 0;
- for (int i = 0; i < list.size(); i++) {
- if (i == evenPos) {
- reven = reven + list.get(i);
- if (i + 2 < list.size()) {
- reven = reven * 1L * list.get(i + 2);
- }
- evenPos += 4;
- } else if (i == oddPos) {
- rodd += list.get(i);
- if (i + 2 < list.size()) {
- rodd = rodd * 1L * list.get(i + 2);
- }
- oddPos += 4;
- }
- }
- reven %= 2L;
- rodd %= 2L;
- if (reven > rodd) {
- return "EVEN";
- } else if (rodd > reven) {
- return "ODD";
- }
- return "NEUTRAL";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement