leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0791.cpp (347B)


0 class Solution { 1 public: 2 string customSortString(const string &order, string &s) { 3 uint8_t index[27] = {0}; 4 for (int i = 0; i < order.size(); i++) 5 index[order[i] & 0x1F] = i; 6 sort(begin(s), end(s), [&](const char a, const char b) { return index[a & 0x1F] < index[b & 0x1F]; }); 7 return s; 8 } 9 };