leetcode

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 1e4f4a018cf65c0b3be3cfe4539f2186e591a6e5
parent 3f1ca9c882f606d0ffcb5d94eda594f640f45961
Author: AndrewLockVI <andrewlaack1@gmail.com>
Date:   Tue,  2 May 2023 08:28:34 -0500

Product of array V1 dart

Diffstat:
Asign-of-product-of-array/sign-of-productV1.dart | 19+++++++++++++++++++
1 file changed, 19 insertions(+), 0 deletions(-)

diff --git a/sign-of-product-of-array/sign-of-productV1.dart b/sign-of-product-of-array/sign-of-productV1.dart @@ -0,0 +1,19 @@ +//Find the sign of the total product of an array. This +//is the brute force way and does not work in leetcode because +//the values go beyong 64bits. +class Solution { + int arraySign(List<int> nums) { + int total = 1; + for(int i = 0 ; i < nums.length ; ++i){ + total *= nums[i]; + print(total); + } + if(total == 0){ + return 0; + } + if(total == total.abs()){ + return 1; + } + return -1; + } +}