tag:blogger.com,1999:blog-6605110739831561983.post8164657902370438701..comments2023-05-19T06:20:57.916-07:00Comments on Algorithms and Data Structures - Coding, Interviews, Google, Amazon, Microsoft, Apple, IBM: Check if one string is permutation of another stringIvan Kadiyskihttp://www.blogger.com/profile/16028324970371404209noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6605110739831561983.post-1775610688763606022016-08-02T18:56:38.515-07:002016-08-02T18:56:38.515-07:00We checked in the first line if the strings are of...We checked in the first line if the strings are of equal length - so if they are, and none of the counts are below zero, then they shall all be zero.Anonymoushttps://www.blogger.com/profile/00545027859872427588noreply@blogger.comtag:blogger.com,1999:blog-6605110739831561983.post-41703169402887056192016-05-17T23:36:26.890-07:002016-05-17T23:36:26.890-07:00This method gives us O(n) time at the cost of the ...This method gives us O(n) time at the cost of the memory size of a hashmap. Sorting would save us the memory cost, but the fastest sorting algorithm would produce O(nlogn) results. Also the cost of comparing after sorting should be taken into account.Anonymoushttps://www.blogger.com/profile/08776517375217212687noreply@blogger.comtag:blogger.com,1999:blog-6605110739831561983.post-2048556831356645752016-04-30T13:52:03.467-07:002016-04-30T13:52:03.467-07:00where is the case where count can be greater than ...where is the case where count can be greater than 0 at the end of string 2?unknownhttps://www.blogger.com/profile/03685267270782015949noreply@blogger.comtag:blogger.com,1999:blog-6605110739831561983.post-78101956344779090812016-01-20T13:49:18.415-08:002016-01-20T13:49:18.415-08:00sorting them both and comparing works if you are a...sorting them both and comparing works if you are allowed to modify the existing strings. Otherwise this method isn't bad. zmans8https://www.blogger.com/profile/18164953584359959521noreply@blogger.comtag:blogger.com,1999:blog-6605110739831561983.post-16783365542097870682014-04-01T11:50:23.090-07:002014-04-01T11:50:23.090-07:00Or sort them both and compare.Or sort them both and compare.Hedgehttps://www.blogger.com/profile/03419644622753437189noreply@blogger.comtag:blogger.com,1999:blog-6605110739831561983.post-36141181906688707512013-06-29T13:33:34.608-07:002013-06-29T13:33:34.608-07:00Use of an array would be much faster for large str...Use of an array would be much faster for large strings I think ! Anonymoushttps://www.blogger.com/profile/11232776615158405346noreply@blogger.com