-
1822. Sign of the Product of an Array javaLeetCode_Study_Plan/Programming Skills 2022. 9. 19. 22:10
class Solution { public int arraySign(int[] nums) { int cnt = 0; for (int i = 0 ; i < nums.length ; i++) { if (nums[i] == 0){ return 0; } if (nums[i] < 0) { cnt +=1; } } if (cnt % 2 == 0) { return 1; } else { return -1; } } }
'LeetCode_Study_Plan > Programming Skills' 카테고리의 다른 글
202. Happy Number java (0) 2022.09.20 1502. Can Make Arithmetic Progression From Sequence java (0) 2022.09.19 1779. Find Nearest Point That Has the Same X or Y Coordinate java (0) 2022.09.19 976. Largest Perimeter Triangle java (0) 2022.09.19 1281. Subtract the Product and Sum of Digits of an Integer java (0) 2022.09.19