We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
When case 3 occurs the expression "(s.length()+t.length()-k) < 0" will always be false using C++. That is because you are substracting a signed integer from an unsigned integer, which will result in an unsigned integer and thus will never be less than 0. To correct this, you can write: "(int(s.length()+t.length())-k)". I spent half an hour figuring this out...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Append and Delete
You are viewing a single comment's thread. Return to all comments →
When case 3 occurs the expression "(s.length()+t.length()-k) < 0" will always be false using C++. That is because you are substracting a signed integer from an unsigned integer, which will result in an unsigned integer and thus will never be less than 0. To correct this, you can write: "(int(s.length()+t.length())-k)". I spent half an hour figuring this out...