Given two strings, determine if one is a permutation of the other
This code is broken.

// This creates an array with size elements all set to zero.
// But your string (in the examples) are not more than 4 long.
// So the largest vector is 4 elements long.
vector&lt;int&gt; s1_set(s1.size());

// Here x is char.
for (const auto&amp; x : s1) { 
// It is undefined if char is signed or unsigned.
// so the range of values for x is
//       0 -&gt; 255
// or -127 -&gt; 128
//
// Either way the range is well beyond the size of
// the array defined above.