No. When there are no letters in the string, the result is an empty string. This is when the behaviors are not equivalent:
In the first case, you try to delete a character that does not exist - since the string is empty. This is undefined behavior.
In the second case, you take a substring of the empty string, which is legal because result.size() - 1 will evaluate to (size_t)0 - 1 aka string::npos, and substr() specifies:
A value of string::npos indicates all characters until the end of the string
Read several times before understood what was going on. Probably better to emphasize that first the queue is sorted by priorities, then with every "known customer" swapping occurs.
gorgeous!!!
No. When there are no letters in the string, the result is an empty string. This is when the behaviors are not equivalent:
In the first case, you try to delete a character that does not exist - since the string is empty. This is undefined behavior.
In the second case, you take a substring of the empty string, which is legal because
result.size() - 1
will evaluate to(size_t)0 - 1
akastring::npos
, andsubstr()
specifies:Read several times before understood what was going on. Probably better to emphasize that first the queue is sorted by priorities, then with every "known customer" swapping occurs.
Fixed.
Sample tests in JS is not using the
chai
frameworkApproved
TypeScript translation
Approved
Approved
Fork adding random tests for Javascript
Too ez
What a nice Kata! It made my day!
Don't feels like 6 kyu honestly
Better to read the condition carefully first...
Too easy for 6 kyu, isn't it?
Loading more items...