Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
                                                        C++ Programming
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    int arr[n];
    for(int i = 0; i < n; i++){
      cin>>arr[i];
    }
    sort(arr, arr + n);
    int brr[n];
    brr[0] = arr[0];
    for(int i = 1; i < n; i++){
      brr[i] = arr[i] - arr[i - 1];
    }
    sort(brr, brr+n, greater<int>());
    cout<<brr[0]<<endl;
  }
}Input
                                                            8
1
10
2
0 0
3
-1 2 0
4
2 10 1 7
2
2 3
5
3 2 -4 -2 0
2
-1 1
1
-2
                                                    1
10
2
0 0
3
-1 2 0
4
2 10 1 7
2
2 3
5
3 2 -4 -2 0
2
-1 1
1
-2
Output
                                                            10
0
2
5
2
2
2
-2
                                                    0
2
5
2
2
2
-2
Demonstration
Codeforcess Solution 1607-C C. Minimum Extraction ,C++, Java, Js and Python ,1607-C,Codeforcess Solution
