{"id":406,"date":"2013-05-02T16:02:03","date_gmt":"2013-05-02T23:02:03","guid":{"rendered":"http:\/\/192.168.1.2\/wordpress\/?p=406"},"modified":"2013-05-13T14:48:18","modified_gmt":"2013-05-13T21:48:18","slug":"ctci-ch-1-3","status":"publish","type":"post","link":"http:\/\/cywang.no-ip.org\/wordpress\/?p=406","title":{"rendered":"CTCI: Ch. 1-3"},"content":{"rendered":"<p>\n\t<strong>Given two strings, write a method to decide if one is a permutation of the other.<\/strong>\n<\/p>\n<p><!--more--><\/p>\n<pre class=\"brush:cpp;\">\r\n#include &lt;iostream&gt;\r\n#include &lt;string.h&gt;\r\nusing namespace std;\r\nbool isPermutationStr(string s1, string s2);\r\n\r\nbool isPermutationStr(string s1, string s2)\r\n{\r\n    if(s1.length() != s2.length())\r\n        return false;\r\n    else\r\n    {\r\n        sort(s1.begin(),s1.end());\r\n        sort(s2.begin(),s2.end());\r\n        if( s1 == s2)\r\n            return true;\r\n        else\r\n            return false;\r\n    }\r\n}\r\n\r\nint main(int argc, const char * argv[])\r\n{\r\n    string s1 = &quot;abcde&quot;;\r\n    string s2 = &quot;eadcb&quot;;\r\n    if(isPermutationStr(s1,s2))\r\n        cout&lt;&lt;&quot;TRUE&quot;;\r\n    else\r\n        cout&lt;&lt;&quot;FALSE&quot;;\r\n    \r\n    return 0;\r\n}\r\n<\/pre>\n<p>\n\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Given two strings, write a method to decide if one is a permutation of the other.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[19,6],"tags":[],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-chapter-1-arrays-and-strings","category-cracking-the-coding-interview"],"_links":{"self":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=406"}],"version-history":[{"count":5,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":429,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/406\/revisions\/429"}],"wp:attachment":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}