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)


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