Timeline for Checking if string characters can be arranged to form another string
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 19, 2016 at 21:27 | comment | added | Darrel Hoffman | @greybeard - That will work, and would probably be ideal provided the input was fairly short. Sorting takes longer than using a map as in James' solution, so I'd prefer that if the input could get long... | |
Jan 19, 2016 at 20:52 | comment | added | greybeard | While sorting and comparing isn't quite enough, it's almost there: walk both sort results checking whether for equality. Skip "1" when smaller, return false if end on 1 or greater, true when end on 2. (You may consider the approaches establishing char -> count an application of counting sort.) | |
Jan 19, 2016 at 20:23 | comment | added | dpg5000 | Hi Amit! Thanks for the help, however I realized that this might not work for my needs (i.e. str1 may be of larger length than str2, so a strict sort and compare between strings wouldn't return properly for all test cases). I added some test cases above that hopefully sheds more light on what's the requirement for the code. | |
Jan 19, 2016 at 20:13 | history | migrated | from stackoverflow.com (revisions) | ||
Jan 19, 2016 at 19:54 | history | answered | Amit | CC BY-SA 3.0 |