Advertisement
Guest User

Untitled

a guest
Oct 24th, 2019
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <algorithm>
  2.  
  3. struct {
  4.   bool operator() (int a, int b) const {
  5.     if (b == 0) {
  6.       if (a == 0) {
  7.         return false;
  8.       }
  9.       else {
  10.         return true;
  11.       }
  12.     } else {
  13.       return false;
  14.     }
  15.   }
  16. } ZeroIsKing;
  17.  
  18. class Solution {
  19. public:
  20.   void moveZeroes(vector<int>& nums) {
  21.     std::stable_sort(nums.begin(), nums.end(), ZeroIsKing);
  22.   }
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement