Тёмный

GCD of 2 numbers | Euclidean Algorithm | DSA 

Logicup
Подписаться 126
Просмотров 58
50% 1

Given two positive integers a and b, find GCD of a and b.
Example 1:
Input:
a = 3
b = 6
Output: 3
Explanation: GCD of 3 and 6 is 3
Example 2:
Input:
a = 1
b = 1
Output: 1
Explanation: GCD of 1 and 1 is 1
Your Task:
You don't need to read input or print anything. Complete the function gcd() which takes two positive integers as input parameters and returns gcd of a and b as an integer.
Expected Time Complexity: O(log(min(a, b)))
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ a, b ≤ 109
DSA
Euclidean algorithm to find gcd of 2 numbers.
Find gcd of 2 numbers
#dsa #datastructuresandalgorithms #datastructures #programming #coding #codinginterviews #gcdof2numbers #greatestcommonfactor #gcd

Опубликовано:

 

14 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии    
Далее
Fast Inverse Square Root - A Quake III Algorithm
20:08
НЮША РОЖАЕТ?
00:17
Просмотров 893 тыс.
Programming with Math | The Lambda Calculus
21:48
Просмотров 208 тыс.
Visualizing 4D Pt.1
22:56
Просмотров 842 тыс.
Kaktovic Numerals
9:15
Просмотров 18 тыс.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Introduction to Big-O
12:40
Просмотров 286 тыс.
3Blue1Brown's Probability Challenge Solved!
28:51
Просмотров 68 тыс.