CARVIEW |
Select Language
HTTP/2 200
date: Wed, 15 Oct 2025 03:00:13 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=446bbd899f7cbc43b7322050f30a576d7da4f3b3e7b4e3da5bc15ab4a351925fa%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22dYbtflSUjaUBnqeTIAa2mnOnbFG8tNvO%22%3B%7D; HttpOnly; Path=/
cf-ray: 98ec10a0e902b22e-BLR
leetcode - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <array>
- using namespace std;
- static constexpr array<pair<int,int>, 256> init_array() {
- array<pair<int,int>,256> alphabet;
- for (int i = 0; i != 256; ++i) {
- alphabet[i].first = 0;
- alphabet[i].second = i;
- }
- return alphabet;
- }
- class Solution {
- private:
- static inline constexpr array<pair<int,int>,256> init = init_array();
- public:
- string frequencySort(string s) {
- array<pair<int,int>,256> alphabet = init;
- for (unsigned char c : s) {
- ++alphabet[c].first;
- }
- sort(alphabet.begin(), alphabet.end(), std::greater{});
- string res;
- res.reserve(s.size());
- for (int i = 0; i != 256 && alphabet[i].first != 0; ++i) {
- for (int j = 0; j != alphabet[i].first; ++j) {
- res.push_back(alphabet[i].second);
- }
- }
- return res;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐Make $15OO in 2O minutesV E⭐⭐
Java | 3 sec ago | 0.15 KB
-
✅⭐ Make huge profits on trading ⭐⭐ T
JavaScript | 6 sec ago | 0.25 KB
-
🔥 Exchange profit method
JavaScript | 9 sec ago | 0.24 KB
-
✅ Marketplace Glitch ✅ Working NEVER SEEN BE...
JavaScript | 14 sec ago | 0.25 KB
-
⭐⭐⭐Make $15OO in 2O minutesV G⭐⭐
Java | 14 sec ago | 0.15 KB
-
🚨 Free Crypto Method 🚨
JavaScript | 21 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ X
JavaScript | 22 sec ago | 0.25 KB
-
⭐⭐⭐MAKE $9OO INSTANTLY D M⭐⭐
Java | 25 sec ago | 0.15 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand