Advertisement
nikunjsoni

1509

Jun 29th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  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. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement