{"action":"created","comment":{"url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/comments/169539239","pull_request_review_id":98080103,"id":169539239,"diff_hunk":"@@ -0,0 +1,144 @@\n+/*\n+Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.\n+Note: The solution set must not contain duplicate triplets.\n+For example, given array S = [-1, 0, 1, 2, -1, -4],\n+A solution set is:\n+[\n+  [-1, 0, 1],\n+  [-1, -1, 2]\n+]\n+\n+Approach Used: Hashing\n+\t\t1. Given an array, create two for loops and break down the problem into - for each element 'a' in the array, find a pair s.t their sum=-a\n+\t\t2. For finding a pair which has its sum=target_sum\n+\t\t   2.1 create a hashset \n+\t\t   2.2 traverse the inner loop :\n+\t\t       for each element 'b' check whether the hashset contains target_sum-b\n+\t\t          if true:\n+\t\t             create a list of 3 integers\n+\t\t                ele1=Min(a,b,target_sum-b)\n+\t\t                ele3=Max(a,b,target_sum-b)\n+\t\t                ele2=-(ele1+ele3)\n+\t\t          \n+\t\t          add the element 'b' in the set\n+\t\t3. clear the set to further traverse the outer loop             \n+\t\t4. if the solution exists:\n+\t\t \treturn the list containing the list of triplets (whose sum add to 0)  \n+\t\t   else\n+\t\t    return null\n+ */\n+\n+\n+import java.util.ArrayList;\n+import java.util.Arrays;\n+import java.util.HashSet;\n+import java.util.List;\n+import java.util.Scanner;\n+import org.testng.Assert;\n+import org.testng.annotations.Test;\n+\n+public class Sum3 {\n+\n+\tpublic static void main(String[] args) {\n+\t\t// TODO Auto-generated method stub\n+\t\tScanner sc= new Scanner (System.in);\n+\t\tint n=sc.nextInt();\n+\t\tint arr[]=new int[n];\n+\t\tfor(int i=0;i<n;i++)\n+\t\t\tarr[i]=sc.nextInt();\n+\t\t\n+\t\tList<List<Integer>> reslist=new ArrayList<List<Integer>>();\n+\t\treslist=check3Sum(arr);\n+\t\tif(reslist==null)\n+\t\t\tSystem.out.println(\"Invalid Input or Solution doesn't exists\");\n+\t\telse\n+\t\t{\n+\t\t\tfor (List<Integer> l:reslist)\n+\t\t\t{ \n+\t\t\t\tSystem.out.println(Arrays.toString(l.toArray()));\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\n+    public static List<List<Integer>> check3Sum(int arr[])\n+    {\n+    \tif (arr == null || arr.length < 2)\n+    \t\treturn null;\n+    \tHashSet<Integer> s= new HashSet<>();\n+    \tList<List<Integer>> r = new ArrayList<List<Integer>>();\n+    \tint target,a,b;","path":"3SumProblem.java","position":70,"original_position":70,"commit_id":"5162a4aea301b5c0de42468189066965d55cc4a5","original_commit_id":"5162a4aea301b5c0de42468189066965d55cc4a5","user":{"login":"mooreaarond","id":6600797,"avatar_url":"https://avatars1.githubusercontent.com/u/6600797?v=4","gravatar_id":"","url":"https://api.github.com/users/mooreaarond","html_url":"https://github.com/mooreaarond","followers_url":"https://api.github.com/users/mooreaarond/followers","following_url":"https://api.github.com/users/mooreaarond/following{/other_user}","gists_url":"https://api.github.com/users/mooreaarond/gists{/gist_id}","starred_url":"https://api.github.com/users/mooreaarond/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mooreaarond/subscriptions","organizations_url":"https://api.github.com/users/mooreaarond/orgs","repos_url":"https://api.github.com/users/mooreaarond/repos","events_url":"https://api.github.com/users/mooreaarond/events{/privacy}","received_events_url":"https://api.github.com/users/mooreaarond/received_events","type":"User","site_admin":false},"body":"Similar to my above comment, you should always create your variables as \"late\" as possible.  You should remove this line and have\r\n\r\n73: int target = -arr[i];\r\n78: int a = Math...\r\n79: int b = Math...","created_at":"2018-02-21T05:40:20Z","updated_at":"2018-02-21T05:40:20Z","html_url":"https://github.com/Shreya4496/MicrosoftCoach/pull/2#discussion_r169539239","pull_request_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/2","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/comments/169539239"},"html":{"href":"https://github.com/Shreya4496/MicrosoftCoach/pull/2#discussion_r169539239"},"pull_request":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/2"}}},"pull_request":{"url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/2","id":169791775,"html_url":"https://github.com/Shreya4496/MicrosoftCoach/pull/2","diff_url":"https://github.com/Shreya4496/MicrosoftCoach/pull/2.diff","patch_url":"https://github.com/Shreya4496/MicrosoftCoach/pull/2.patch","issue_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues/2","number":2,"state":"open","locked":false,"title":"Week2","user":{"login":"Shreya4496","id":22656992,"avatar_url":"https://avatars2.githubusercontent.com/u/22656992?v=4","gravatar_id":"","url":"https://api.github.com/users/Shreya4496","html_url":"https://github.com/Shreya4496","followers_url":"https://api.github.com/users/Shreya4496/followers","following_url":"https://api.github.com/users/Shreya4496/following{/other_user}","gists_url":"https://api.github.com/users/Shreya4496/gists{/gist_id}","starred_url":"https://api.github.com/users/Shreya4496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shreya4496/subscriptions","organizations_url":"https://api.github.com/users/Shreya4496/orgs","repos_url":"https://api.github.com/users/Shreya4496/repos","events_url":"https://api.github.com/users/Shreya4496/events{/privacy}","received_events_url":"https://api.github.com/users/Shreya4496/received_events","type":"User","site_admin":false},"body":"Please review the solution.","created_at":"2018-02-17T17:07:46Z","updated_at":"2018-02-21T05:40:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"00de68a27d7f51bcf61ab6b6d70bb7a3ee9b703c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/2/commits","review_comments_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/2/comments","review_comment_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues/2/comments","statuses_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/statuses/5162a4aea301b5c0de42468189066965d55cc4a5","head":{"label":"Shreya4496:Week2","ref":"Week2","sha":"5162a4aea301b5c0de42468189066965d55cc4a5","user":{"login":"Shreya4496","id":22656992,"avatar_url":"https://avatars2.githubusercontent.com/u/22656992?v=4","gravatar_id":"","url":"https://api.github.com/users/Shreya4496","html_url":"https://github.com/Shreya4496","followers_url":"https://api.github.com/users/Shreya4496/followers","following_url":"https://api.github.com/users/Shreya4496/following{/other_user}","gists_url":"https://api.github.com/users/Shreya4496/gists{/gist_id}","starred_url":"https://api.github.com/users/Shreya4496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shreya4496/subscriptions","organizations_url":"https://api.github.com/users/Shreya4496/orgs","repos_url":"https://api.github.com/users/Shreya4496/repos","events_url":"https://api.github.com/users/Shreya4496/events{/privacy}","received_events_url":"https://api.github.com/users/Shreya4496/received_events","type":"User","site_admin":false},"repo":{"id":121006118,"name":"MicrosoftCoach","full_name":"Shreya4496/MicrosoftCoach","owner":{"login":"Shreya4496","id":22656992,"avatar_url":"https://avatars2.githubusercontent.com/u/22656992?v=4","gravatar_id":"","url":"https://api.github.com/users/Shreya4496","html_url":"https://github.com/Shreya4496","followers_url":"https://api.github.com/users/Shreya4496/followers","following_url":"https://api.github.com/users/Shreya4496/following{/other_user}","gists_url":"https://api.github.com/users/Shreya4496/gists{/gist_id}","starred_url":"https://api.github.com/users/Shreya4496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shreya4496/subscriptions","organizations_url":"https://api.github.com/users/Shreya4496/orgs","repos_url":"https://api.github.com/users/Shreya4496/repos","events_url":"https://api.github.com/users/Shreya4496/events{/privacy}","received_events_url":"https://api.github.com/users/Shreya4496/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Shreya4496/MicrosoftCoach","description":null,"fork":false,"url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach","forks_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/forks","keys_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/teams","hooks_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/hooks","issue_events_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues/events{/number}","events_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/events","assignees_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/assignees{/user}","branches_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/branches{/branch}","tags_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/tags","blobs_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/statuses/{sha}","languages_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/languages","stargazers_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/stargazers","contributors_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/contributors","subscribers_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/subscribers","subscription_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/subscription","commits_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/contents/{+path}","compare_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/merges","archive_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/downloads","issues_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues{/number}","pulls_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls{/number}","milestones_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/milestones{/number}","notifications_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/labels{/name}","releases_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/releases{/id}","deployments_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/deployments","created_at":"2018-02-10T10:31:06Z","updated_at":"2018-02-10T10:33:35Z","pushed_at":"2018-02-17T17:07:46Z","git_url":"git://github.com/Shreya4496/MicrosoftCoach.git","ssh_url":"git@github.com:Shreya4496/MicrosoftCoach.git","clone_url":"https://github.com/Shreya4496/MicrosoftCoach.git","svn_url":"https://github.com/Shreya4496/MicrosoftCoach","homepage":null,"size":4,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"Shreya4496:master","ref":"master","sha":"758701c7325468810a6b00d86aaf3f191964fcfd","user":{"login":"Shreya4496","id":22656992,"avatar_url":"https://avatars2.githubusercontent.com/u/22656992?v=4","gravatar_id":"","url":"https://api.github.com/users/Shreya4496","html_url":"https://github.com/Shreya4496","followers_url":"https://api.github.com/users/Shreya4496/followers","following_url":"https://api.github.com/users/Shreya4496/following{/other_user}","gists_url":"https://api.github.com/users/Shreya4496/gists{/gist_id}","starred_url":"https://api.github.com/users/Shreya4496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shreya4496/subscriptions","organizations_url":"https://api.github.com/users/Shreya4496/orgs","repos_url":"https://api.github.com/users/Shreya4496/repos","events_url":"https://api.github.com/users/Shreya4496/events{/privacy}","received_events_url":"https://api.github.com/users/Shreya4496/received_events","type":"User","site_admin":false},"repo":{"id":121006118,"name":"MicrosoftCoach","full_name":"Shreya4496/MicrosoftCoach","owner":{"login":"Shreya4496","id":22656992,"avatar_url":"https://avatars2.githubusercontent.com/u/22656992?v=4","gravatar_id":"","url":"https://api.github.com/users/Shreya4496","html_url":"https://github.com/Shreya4496","followers_url":"https://api.github.com/users/Shreya4496/followers","following_url":"https://api.github.com/users/Shreya4496/following{/other_user}","gists_url":"https://api.github.com/users/Shreya4496/gists{/gist_id}","starred_url":"https://api.github.com/users/Shreya4496/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shreya4496/subscriptions","organizations_url":"https://api.github.com/users/Shreya4496/orgs","repos_url":"https://api.github.com/users/Shreya4496/repos","events_url":"https://api.github.com/users/Shreya4496/events{/privacy}","received_events_url":"https://api.github.com/users/Shreya4496/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Shreya4496/MicrosoftCoach","description":null,"fork":false,"url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach","forks_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/forks","keys_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/teams","hooks_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/hooks","issue_events_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues/events{/number}","events_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/events","assignees_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/assignees{/user}","branches_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/branches{/branch}","tags_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/tags","blobs_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/refs{/sha}","trees_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/statuses/{sha}","languages_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/languages","stargazers_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/stargazers","contributors_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/contributors","subscribers_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/subscribers","subscription_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/subscription","commits_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/commits{/sha}","git_commits_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/git/commits{/sha}","comments_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/comments{/number}","issue_comment_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues/comments{/number}","contents_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/contents/{+path}","compare_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/merges","archive_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/downloads","issues_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues{/number}","pulls_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls{/number}","milestones_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/milestones{/number}","notifications_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/labels{/name}","releases_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/releases{/id}","deployments_url":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/deployments","created_at":"2018-02-10T10:31:06Z","updated_at":"2018-02-10T10:33:35Z","pushed_at":"2018-02-17T17:07:46Z","git_url":"git://github.com/Shreya4496/MicrosoftCoach.git","ssh_url":"git@github.com:Shreya4496/MicrosoftCoach.git","clone_url":"https://github.com/Shreya4496/MicrosoftCoach.git","svn_url":"https://github.com/Shreya4496/MicrosoftCoach","homepage":null,"size":4,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/2"},"html":{"href":"https://github.com/Shreya4496/MicrosoftCoach/pull/2"},"issue":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues/2"},"comments":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/issues/2/comments"},"review_comments":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/2/comments"},"review_comment":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/pulls/2/commits"},"statuses":{"href":"https://api.github.com/repos/Shreya4496/MicrosoftCoach/statuses/5162a4aea301b5c0de42468189066965d55cc4a5"}},"author_association":"OWNER"}}
{"actor":{"display_login":"mooreaarond"}}