nikunjsoni

1509

Jun 29th, 2021
94
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution {
  2. public:
  3.     int minDifference(vector<int>& A) {
  4.         int n = A.size();
  5.         if(n < 5) return 0;
  6.         sort(A.begin(), A.end());
  7.         return min({A[n - 1] - A[3], A[n - 2] - A[2], A[n - 3] - A[1], A[n - 4] - A[0]});
  8.     }
  9. };
RAW Paste Data