{"action":"created","issue":{"url":"https://api.github.com/repos/congr/world/issues/169","repository_url":"https://api.github.com/repos/congr/world","labels_url":"https://api.github.com/repos/congr/world/issues/169/labels{/name}","comments_url":"https://api.github.com/repos/congr/world/issues/169/comments","events_url":"https://api.github.com/repos/congr/world/issues/169/events","html_url":"https://github.com/congr/world/issues/169","id":323535624,"node_id":"MDU6SXNzdWUzMjM1MzU2MjQ=","number":169,"title":"InterviewBit : Merge K Sorted Lists","user":{"login":"congr","id":9853714,"node_id":"MDQ6VXNlcjk4NTM3MTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/9853714?v=4","gravatar_id":"","url":"https://api.github.com/users/congr","html_url":"https://github.com/congr","followers_url":"https://api.github.com/users/congr/followers","following_url":"https://api.github.com/users/congr/following{/other_user}","gists_url":"https://api.github.com/users/congr/gists{/gist_id}","starred_url":"https://api.github.com/users/congr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/congr/subscriptions","organizations_url":"https://api.github.com/users/congr/orgs","repos_url":"https://api.github.com/users/congr/repos","events_url":"https://api.github.com/users/congr/events{/privacy}","received_events_url":"https://api.github.com/users/congr/received_events","type":"User","site_admin":false},"labels":[{"id":784394767,"node_id":"MDU6TGFiZWw3ODQzOTQ3Njc=","url":"https://api.github.com/repos/congr/world/labels/-InterviewBIt","name":"-InterviewBIt","color":"cceeff","default":false},{"id":807126100,"node_id":"MDU6TGFiZWw4MDcxMjYxMDA=","url":"https://api.github.com/repos/congr/world/labels/-LeetCode","name":"-LeetCode","color":"ffcc47","default":false},{"id":809527828,"node_id":"MDU6TGFiZWw4MDk1Mjc4Mjg=","url":"https://api.github.com/repos/congr/world/labels/Divide&Conquer","name":"Divide&Conquer","color":"d7db00","default":false},{"id":547569275,"node_id":"MDU6TGFiZWw1NDc1NjkyNzU=","url":"https://api.github.com/repos/congr/world/labels/Heap","name":"Heap","color":"70eac1","default":false},{"id":911847477,"node_id":"MDU6TGFiZWw5MTE4NDc0Nzc=","url":"https://api.github.com/repos/congr/world/labels/LinkedList","name":"LinkedList","color":"d073f4","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-05-16T09:18:36Z","updated_at":"2018-06-27T01:48:56Z","closed_at":"2018-05-16T10:12:41Z","author_association":"OWNER","body":"https://www.interviewbit.com/problems/merge-k-sorted-lists/\r\n\r\n![image](https://user-images.githubusercontent.com/9853714/40108285-746d71de-5935-11e8-8746-3f7fd21e811c.png)\r\n"},"comment":{"url":"https://api.github.com/repos/congr/world/issues/comments/400516737","html_url":"https://github.com/congr/world/issues/169#issuecomment-400516737","issue_url":"https://api.github.com/repos/congr/world/issues/169","id":400516737,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDUxNjczNw==","user":{"login":"congr","id":9853714,"node_id":"MDQ6VXNlcjk4NTM3MTQ=","avatar_url":"https://avatars1.githubusercontent.com/u/9853714?v=4","gravatar_id":"","url":"https://api.github.com/users/congr","html_url":"https://github.com/congr","followers_url":"https://api.github.com/users/congr/followers","following_url":"https://api.github.com/users/congr/following{/other_user}","gists_url":"https://api.github.com/users/congr/gists{/gist_id}","starred_url":"https://api.github.com/users/congr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/congr/subscriptions","organizations_url":"https://api.github.com/users/congr/orgs","repos_url":"https://api.github.com/users/congr/repos","events_url":"https://api.github.com/users/congr/events{/privacy}","received_events_url":"https://api.github.com/users/congr/received_events","type":"User","site_admin":false},"created_at":"2018-06-27T01:48:56Z","updated_at":"2018-06-27T01:48:56Z","author_association":"OWNER","body":"23. Merge k Sorted Lists\r\nhttps://leetcode.com/problems/merge-k-sorted-lists/description/\r\n\r\n```\r\nclass Solution {\r\n    public ListNode mergeKLists(ListNode[] lists) {\r\n        if (lists == null || lists.length == 0) return null; // []\r\n        \r\n        return mergeKLists(lists, 0, lists.length-1);\r\n    }\r\n    \r\n    ListNode mergeKLists(ListNode[] lists, int start, int end) {\r\n        if (start > end) return null;\r\n        if (start == end) return lists[start]; // !!!!!!\r\n        \r\n        int mid = (start+end)/2;\r\n        ListNode left = mergeKLists(lists, start, mid);\r\n        ListNode right = mergeKLists(lists, mid+1, end);\r\n        return merge2Lists(left, right);\r\n    }\r\n    \r\n    ListNode merge2Lists(ListNode left, ListNode right) {\r\n        ListNode dummy = new ListNode(0);\r\n        ListNode tail = dummy;\r\n        \r\n        while (left != null && right != null) {\r\n            if (left.val >= right.val) {\r\n                tail.next = right;\r\n                right = right.next;\r\n            } else {\r\n                tail.next = left;\r\n                left = left.next;\r\n            }\r\n            tail = tail.next;\r\n        }\r\n        \r\n        if (left != null) tail.next = left; // !!!!\r\n        if (right != null) tail.next = right; // !!!!\r\n        \r\n        return dummy.next;\r\n    }\r\n}\r\n```"}}
{"actor":{"display_login":"congr"}}