leetcode

Leetcode submissions
git clone git://git.laack.co/leetcode.git
Log | Files | Refs | README

sign-of-productV1.dart (460B)


      1 //Find the sign of the total product of an array. This
      2 //is the brute force way and does not work in leetcode because
      3 //the values go beyong 64bits.
      4 class Solution {
      5   int arraySign(List<int> nums) {
      6       int total = 1;
      7       for(int i = 0 ; i < nums.length ; ++i){
      8           total *= nums[i];
      9           print(total);
     10       }
     11       if(total == 0){
     12           return 0;
     13       }
     14       if(total == total.abs()){
     15           return 1;
     16       }
     17       return -1;
     18   }
     19 }