{"action":"created","comment":{"url":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/comments/89952855","pull_request_review_id":10479380,"id":89952855,"diff_hunk":"@@ -0,0 +1,115 @@\n+# Abbreviation\n+\n+## Problem\n+This problem comes from [HackerRank](https://www.hackerrank.com/contests/world-codesprint-6/challenges/abbr).\n+Category: Dynamic Programming\n+Difficulty: Medium\n+\n+### Overview\n+Read the link instructions,\n+they are helpful when solving\n+greater than eye deep\n+\n+Edge cases and complexities are covered below. Please read the problem first.\n+\n+## Algorithm\n+### Overview\n+This problem is complex because of the edge cases that exist. Some\n+solutions don't need to worry about them, however when trying to maximize\n+efficiency it becomes a problem. When I approached the problem I tried to\n+use a double pointer method, iterating through both strings at the same time.\n+\n+The following example will show why this problem is tough to get right\n+the first time, or second.\n+\n+It looks like this (credit to Orion for the edge case),\n+- A = abcBBcA and B = ABBCA\n+  - p1 (pointer one) = a | p2 (pointer two) = A\n+    - a can be turned into A, so B is possible so far.\n+  - p1 = b | p2 = B\n+    - Another match\n+  - p1 = c | p2 = B\n+    - Move p1 forward (since c can be ignored and deleted).\n+  - p1 = B | p2 = B\n+    - Both are uppercase and they match, so move both pointers forward.\n+  - p1 = B | p2 = C\n+    - Oops! This situation causes a return of \"NO\", even though it should\n+    print \"YES\". The problem is that the lowercase 'b' \"uses\" a slot that\n+    should be used by the uppercase 'B'. Because lowercase characters can\n+    be deleted but uppercase cannot, **every uppercase character must be\n+    used by the algorithm.**\n+\n+So what's the solution? Well, either you can backtrack whenever you reach\n+an uppercase character that could have been used up by a lowercase\n+character previously. Or, you can create a kind of \"memory\" for the\n+algorithm. A memory would need the following,\n+- A unique ID for combinations of lowercase characters.\n+- A way for uppercase characters to check if they could replace those\n+lowercase characters that had been previously used.\n+\n+It should be possible to create a nearly unique ID for any combination of\n+lowercase characters. By having a counter that increases as new\n+characters are added to memory, and multiplying the numeric value\n+of new characters by it as part of the hash, it will help guarantee a\n+nearly unique ID for each sequence. Like the following example,\n+- abc compared to bca where counter starts at one.\n+  - a*counter + b*(counter+1) + c*(counter+2) = 1*1 + 2*2 + 3*3 = 14\n+  - b*counter + c*(counter+1) + a*(counter+2) = 2*1 + 3*2 + 1*3 = 11\n+\n+This memory will be stored in an array, like a hash map. By adding\n+in a modulus operator and by using a prime number for the\n+modulus, we help guarantee that few IDs will conflict. The prime\n+number will also match the size of the array used to store the\n+memory.\n+\n+In using this memory we make it possible to get an O(M + N)\n+time complexity for this problem, since there is no need\n+to backtrack.\n+\n+Assumption: Although lowercase letters may be turned uppercase,\n+every lowercase character remaining must be deleted. This is not\n+explicitly stated in the problem, but it is an assumption I am\n+using.\n+\n+### Pseudo Code\n+1. Read in the number of string pairs or \"queries\" as they are called.\n+2. Read in the next pair of strings. Create index pointers and set to 0.\n+3. If the char at p1 can match the char p2,\n+  - If the char at p1 is lowercase, add it to memory.\n+  - Else, if it can be replaced by a char in memory, do so,\n+  otherwise clear the memory.\n+  - If the char at the first pointer was lowercase or memory was cleared,\n+  advance both p1 and p2.\n+4. Else if both characters are uppercase and don't match, check if\n+the memory has a char that took the place of the char at p1.\n+  - Continue until the char at p1 is no longer uppercase or\n+  it has reached the end of the string. Advance p1 after each iteration.\n+5. If both p1 and p2 are less than the length of their respective strings,\n+continue at step 3.\n+6. If p2 does not equal the length of the final string, print \"NO\".\n+7. If the p1 does not equal the length of the original string,\n+  - Scan through the rest of the original string and check if any\n+  remaining uppercase chars need to (and can be) replaced by\n+  memory. If any cannot be replaced, then print \"NO\".\n+8. If the algorithm has not printed \"NO\" for the query, print \"YES\".\n+9. Start at step 2 if queries remain. Otherwise finish.\n+\n+### Analysis\n+For each query the loop iterates a maximum number of O(M + N) times\n+where M is the length of the original string and N is the length of the\n+final string. The hash set has O(1) access, insert, and retrieval and\n+it does not change in size.\n+\n+This algorithm wil run in O(M + N) time. The max runtime was .22s for\n+Test Case #10.\n+\n+## Conclusion\n+This is a good problem to practice dynamic programming on. Although my","path":"Guide/DynamicProgramming/Abbreviation/README.md","position":107,"original_position":107,"commit_id":"2da8c6513119c2eb5435973043d81e16ca247706","original_commit_id":"2da8c6513119c2eb5435973043d81e16ca247706","user":{"login":"asclines","id":4149872,"avatar_url":"https://avatars.githubusercontent.com/u/4149872?v=3","gravatar_id":"","url":"https://api.github.com/users/asclines","html_url":"https://github.com/asclines","followers_url":"https://api.github.com/users/asclines/followers","following_url":"https://api.github.com/users/asclines/following{/other_user}","gists_url":"https://api.github.com/users/asclines/gists{/gist_id}","starred_url":"https://api.github.com/users/asclines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asclines/subscriptions","organizations_url":"https://api.github.com/users/asclines/orgs","repos_url":"https://api.github.com/users/asclines/repos","events_url":"https://api.github.com/users/asclines/events{/privacy}","received_events_url":"https://api.github.com/users/asclines/received_events","type":"User","site_admin":false},"body":"Maybe explain a little bit on why it _wasn't_ dynamic?","created_at":"2016-11-29T07:25:58Z","updated_at":"2016-11-29T07:29:27Z","html_url":"https://github.com/asclines/AppliedAlgorithms/pull/19#discussion_r89952855","pull_request_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/comments/89952855"},"html":{"href":"https://github.com/asclines/AppliedAlgorithms/pull/19#discussion_r89952855"},"pull_request":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/19","id":95538713,"html_url":"https://github.com/asclines/AppliedAlgorithms/pull/19","diff_url":"https://github.com/asclines/AppliedAlgorithms/pull/19.diff","patch_url":"https://github.com/asclines/AppliedAlgorithms/pull/19.patch","issue_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues/19","number":19,"state":"open","locked":false,"title":"Week ten","user":{"login":"ASAAR","id":1311843,"avatar_url":"https://avatars.githubusercontent.com/u/1311843?v=3","gravatar_id":"","url":"https://api.github.com/users/ASAAR","html_url":"https://github.com/ASAAR","followers_url":"https://api.github.com/users/ASAAR/followers","following_url":"https://api.github.com/users/ASAAR/following{/other_user}","gists_url":"https://api.github.com/users/ASAAR/gists{/gist_id}","starred_url":"https://api.github.com/users/ASAAR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ASAAR/subscriptions","organizations_url":"https://api.github.com/users/ASAAR/orgs","repos_url":"https://api.github.com/users/ASAAR/repos","events_url":"https://api.github.com/users/ASAAR/events{/privacy}","received_events_url":"https://api.github.com/users/ASAAR/received_events","type":"User","site_admin":false},"body":"Closes #6 ","created_at":"2016-11-28T17:09:31Z","updated_at":"2016-11-29T07:29:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"73fc2436e1fbb23e52e1735239b98080e0b2a389","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/19/commits","review_comments_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/19/comments","review_comment_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/comments{/number}","comments_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues/19/comments","statuses_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/statuses/2da8c6513119c2eb5435973043d81e16ca247706","head":{"label":"asclines:weekTen","ref":"weekTen","sha":"2da8c6513119c2eb5435973043d81e16ca247706","user":{"login":"asclines","id":4149872,"avatar_url":"https://avatars.githubusercontent.com/u/4149872?v=3","gravatar_id":"","url":"https://api.github.com/users/asclines","html_url":"https://github.com/asclines","followers_url":"https://api.github.com/users/asclines/followers","following_url":"https://api.github.com/users/asclines/following{/other_user}","gists_url":"https://api.github.com/users/asclines/gists{/gist_id}","starred_url":"https://api.github.com/users/asclines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asclines/subscriptions","organizations_url":"https://api.github.com/users/asclines/orgs","repos_url":"https://api.github.com/users/asclines/repos","events_url":"https://api.github.com/users/asclines/events{/privacy}","received_events_url":"https://api.github.com/users/asclines/received_events","type":"User","site_admin":false},"repo":{"id":74715157,"name":"AppliedAlgorithms","full_name":"asclines/AppliedAlgorithms","owner":{"login":"asclines","id":4149872,"avatar_url":"https://avatars.githubusercontent.com/u/4149872?v=3","gravatar_id":"","url":"https://api.github.com/users/asclines","html_url":"https://github.com/asclines","followers_url":"https://api.github.com/users/asclines/followers","following_url":"https://api.github.com/users/asclines/following{/other_user}","gists_url":"https://api.github.com/users/asclines/gists{/gist_id}","starred_url":"https://api.github.com/users/asclines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asclines/subscriptions","organizations_url":"https://api.github.com/users/asclines/orgs","repos_url":"https://api.github.com/users/asclines/repos","events_url":"https://api.github.com/users/asclines/events{/privacy}","received_events_url":"https://api.github.com/users/asclines/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/asclines/AppliedAlgorithms","description":"Guides and solutions to various types of programming problems.","fork":false,"url":"https://api.github.com/repos/asclines/AppliedAlgorithms","forks_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/forks","keys_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/teams","hooks_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/hooks","issue_events_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues/events{/number}","events_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/events","assignees_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/assignees{/user}","branches_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/branches{/branch}","tags_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/tags","blobs_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/refs{/sha}","trees_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/statuses/{sha}","languages_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/languages","stargazers_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/stargazers","contributors_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/contributors","subscribers_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/subscribers","subscription_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/subscription","commits_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/commits{/sha}","git_commits_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/commits{/sha}","comments_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/comments{/number}","issue_comment_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues/comments{/number}","contents_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/contents/{+path}","compare_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/merges","archive_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/downloads","issues_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues{/number}","pulls_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls{/number}","milestones_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/milestones{/number}","notifications_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/labels{/name}","releases_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/releases{/id}","deployments_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/deployments","created_at":"2016-11-25T01:18:13Z","updated_at":"2016-11-28T17:08:26Z","pushed_at":"2016-11-28T21:31:49Z","git_url":"git://github.com/asclines/AppliedAlgorithms.git","ssh_url":"git@github.com:asclines/AppliedAlgorithms.git","clone_url":"https://github.com/asclines/AppliedAlgorithms.git","svn_url":"https://github.com/asclines/AppliedAlgorithms","homepage":null,"size":35,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"base":{"label":"asclines:master","ref":"master","sha":"41c384cf6d057a90549e0eaf28adc9bbbc791404","user":{"login":"asclines","id":4149872,"avatar_url":"https://avatars.githubusercontent.com/u/4149872?v=3","gravatar_id":"","url":"https://api.github.com/users/asclines","html_url":"https://github.com/asclines","followers_url":"https://api.github.com/users/asclines/followers","following_url":"https://api.github.com/users/asclines/following{/other_user}","gists_url":"https://api.github.com/users/asclines/gists{/gist_id}","starred_url":"https://api.github.com/users/asclines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asclines/subscriptions","organizations_url":"https://api.github.com/users/asclines/orgs","repos_url":"https://api.github.com/users/asclines/repos","events_url":"https://api.github.com/users/asclines/events{/privacy}","received_events_url":"https://api.github.com/users/asclines/received_events","type":"User","site_admin":false},"repo":{"id":74715157,"name":"AppliedAlgorithms","full_name":"asclines/AppliedAlgorithms","owner":{"login":"asclines","id":4149872,"avatar_url":"https://avatars.githubusercontent.com/u/4149872?v=3","gravatar_id":"","url":"https://api.github.com/users/asclines","html_url":"https://github.com/asclines","followers_url":"https://api.github.com/users/asclines/followers","following_url":"https://api.github.com/users/asclines/following{/other_user}","gists_url":"https://api.github.com/users/asclines/gists{/gist_id}","starred_url":"https://api.github.com/users/asclines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asclines/subscriptions","organizations_url":"https://api.github.com/users/asclines/orgs","repos_url":"https://api.github.com/users/asclines/repos","events_url":"https://api.github.com/users/asclines/events{/privacy}","received_events_url":"https://api.github.com/users/asclines/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/asclines/AppliedAlgorithms","description":"Guides and solutions to various types of programming problems.","fork":false,"url":"https://api.github.com/repos/asclines/AppliedAlgorithms","forks_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/forks","keys_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/keys{/key_id}","collaborators_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/teams","hooks_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/hooks","issue_events_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues/events{/number}","events_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/events","assignees_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/assignees{/user}","branches_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/branches{/branch}","tags_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/tags","blobs_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/refs{/sha}","trees_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/trees{/sha}","statuses_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/statuses/{sha}","languages_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/languages","stargazers_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/stargazers","contributors_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/contributors","subscribers_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/subscribers","subscription_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/subscription","commits_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/commits{/sha}","git_commits_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/git/commits{/sha}","comments_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/comments{/number}","issue_comment_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues/comments{/number}","contents_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/contents/{+path}","compare_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/compare/{base}...{head}","merges_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/merges","archive_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/downloads","issues_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues{/number}","pulls_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls{/number}","milestones_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/milestones{/number}","notifications_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/labels{/name}","releases_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/releases{/id}","deployments_url":"https://api.github.com/repos/asclines/AppliedAlgorithms/deployments","created_at":"2016-11-25T01:18:13Z","updated_at":"2016-11-28T17:08:26Z","pushed_at":"2016-11-28T21:31:49Z","git_url":"git://github.com/asclines/AppliedAlgorithms.git","ssh_url":"git@github.com:asclines/AppliedAlgorithms.git","clone_url":"https://github.com/asclines/AppliedAlgorithms.git","svn_url":"https://github.com/asclines/AppliedAlgorithms","homepage":null,"size":35,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":13,"forks":0,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/19"},"html":{"href":"https://github.com/asclines/AppliedAlgorithms/pull/19"},"issue":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues/19"},"comments":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/asclines/AppliedAlgorithms/statuses/2da8c6513119c2eb5435973043d81e16ca247706"}}}}
{"actor":{"display_login":"asclines"}}