Binary Search with Sorting | n*log(n) | Rust
Complexity\n- Time complexity: O(n*log(n))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \
# Complexity\n- Time complexity: $$O(n*log(n))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nimpl Solution {\n    pub fn maximize_greatness(mut nums: Vec<i32>) -> i32 {\n        nums.sort();\n        let n = nums.len();\n        let (mut ans, mut l, mut r) = (0, 0, n);\n        \n        for i in 0..n-1 {\n            r = n;\n            l += 1;\n            while l < r {\n                let mid = l + (r - l) / 2;\n                if nums[mid] > nums[i] { r = mid }\n                else { l = mid + 1 };\n            }\n            \n            if l < n && nums[l] > nums[i] { ans += 1 }\n            else { break };\n            \n        }\n        \n        ans\n    }\n}\n```
['Rust']