category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

Blackboard GCD

Slight description.

Sample code ```cpp int n; cin >> n; vector arr (n + 2, 0); vector prefix (n + 2, 0); vector suffix (n + 2, 0); for (int i=1; i<=n; i++) cin >> arr[i]; for (int i=1; i<=n; i++) { prefix [i] = gcd (prefix[i-1], arr[i]); } for (int i=n; i>=1; i--) { suffix [i] = gcd (suffix[i+1], arr[i]); } int mx = 0; for (int i=0; i<=n; i++) { mx = max (gcd(prefix[i-1] ,suffix [i+1]), mx ); } cout << mx << "\n"; ``` </details> - Things I learnt - was new approach to me. - similar questions - to be added.