Skip to content

Commit

Permalink
Q1979 added.
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Mar 25, 2023
1 parent 651d51c commit 3192f2d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions E_1979_FindGreatestCommonDivisorofArray.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Solution {
public int findGCD(int[] nums) {
int min=1001;
int max=0;
int ebob=1;
for(int i=0; i<nums.length;i++){
if(nums[i]<min)
min=nums[i];
if(nums[i]>max)
max=nums[i];
}
for(int i=1;i<=max && i<=min; i++){
if(max%i==0 && min%i==0)
ebob=i;
}
return ebob;
}
}

0 comments on commit 3192f2d

Please sign in to comment.