euclidean gcd
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
# Algorithms ω
|
||||
|
||||
- [x] Kadane's Algorithm
|
||||
- [x] Euclidean gcd
|
||||
|
||||
# Each category solves different problems:
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package algo
|
||||
|
||||
// GCD gives the greatest common factor of two numbers
|
||||
// EuclideanGCD O(log(n))
|
||||
func GCD(a int, b int) int {
|
||||
if b == 0 {
|
||||
return a
|
||||
}
|
||||
return GCD(b, a%b)
|
||||
}
|
||||
@@ -4,6 +4,7 @@ package algo
|
||||
// https://www.youtube.com/watch?v=qj3CjNEKFeM
|
||||
|
||||
// MaxSubarray -> returns the max sum of possible sub arrays
|
||||
// O(n)
|
||||
func MaxSubarray(array []int) int {
|
||||
minimum := array[0]
|
||||
maximum := 0
|
||||
|
||||
Reference in New Issue
Block a user