{"id":350,"date":"2013-03-22T16:53:17","date_gmt":"2013-03-22T23:53:17","guid":{"rendered":"http:\/\/192.168.1.2\/wordpress\/?p=350"},"modified":"2013-05-13T16:21:47","modified_gmt":"2013-05-13T23:21:47","slug":"chapter-1-arrays-and-strings","status":"publish","type":"post","link":"http:\/\/cywang.no-ip.org\/wordpress\/?p=350","title":{"rendered":"Chapter 1. Arrays and Strings"},"content":{"rendered":"<p>\n\t&nbsp;\n<\/p>\n<ol>\n<li>\n\t\tImplement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? [<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/?p=357\" target=\"_blank\">C++<\/a>]\n\t<\/li>\n<li>\n\t\tImplement a function void reverse(char* str) in C or C++ which reverses a null-terminated string. [<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/?p=369\" target=\"_blank\">C++<\/a>]\n\t<\/li>\n<li>\n\t\tGiven two strings, write a method to decide if one is a permutation of the other.&nbsp;[<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/?p=406\" target=\"_blank\">C++<\/a>]\n\t<\/li>\n<li>\n\t\tWrite a method to replace all spaces in a string with &lsquo;%20&rsquo;. You may assume that the string has sufficient space at the end of the string to hold the additional characters, and that you are given the &ldquo;true&rdquo; length of the string. (Note: if implementing in Java, please use a character array so that you can perform this operation in place.)[<a href=\"http:\/\/cywang.no-ip.org\/wordpress\/?p=415\" target=\"_blank\">C++<\/a>]<br \/>\n\t\tEXAMPLE<br \/>\n\t\tInput: &ldquo;Mr John Smith &rdquo;<br \/>\n\t\tOutput: &ldquo;Mr%20John%20Smith&rdquo; <!--more-->\n\t<\/li>\n<li>\n\t\tImplement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2b1c5a3. If the &ldquo;compressed&rdquo; string would not become smaller than the original string, your method should return the original string.<span style=\"font-size: 13px; \">[<\/span><a href=\"http:\/\/cywang.no-ip.org\/wordpress\/?p=437\" style=\"font-size: 13px; \" target=\"_blank\">C++<\/a><span style=\"font-size: 13px; \">]<\/span>\n\t<\/li>\n<li>\n\t\tGiven an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?\n\t<\/li>\n<li>\n\t\tWrite an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.\n\t<\/li>\n<li>\n\t\tAssume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring (i.e., &ldquo;waterbottle&rdquo; is a rotation of &ldquo;erbottlewat&rdquo;).<span style=\"font-size: 13px; \">[<\/span><a href=\"http:\/\/cywang.no-ip.org\/wordpress\/?p=443\" style=\"font-size: 13px; \" target=\"_blank\">C++<\/a><span style=\"font-size: 13px; \">]<\/span>\n\t<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? [C++] Implement a function void reverse(char* str) in C or C++ which reverses a null-terminated string. [C++] Given two &hellip; <a href=\"http:\/\/cywang.no-ip.org\/wordpress\/?p=350\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/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":[6],"tags":[],"class_list":["post-350","post","type-post","status-publish","format-standard","hentry","category-cracking-the-coding-interview"],"_links":{"self":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/350","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=350"}],"version-history":[{"count":13,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions"}],"predecessor-version":[{"id":603,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/350\/revisions\/603"}],"wp:attachment":[{"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=350"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cywang.no-ip.org\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}