{"action":"opened","issue":{"url":"https://api.github.com/repos/cbweixin/algorithm-practice/issues/33","labels_url":"https://api.github.com/repos/cbweixin/algorithm-practice/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/cbweixin/algorithm-practice/issues/33/comments","events_url":"https://api.github.com/repos/cbweixin/algorithm-practice/issues/33/events","html_url":"https://github.com/cbweixin/algorithm-practice/issues/33","id":112417411,"number":33,"title":"Missing number","user":{"login":"cbweixin","id":1326906,"avatar_url":"https://avatars.githubusercontent.com/u/1326906?v=3","gravatar_id":"","url":"https://api.github.com/users/cbweixin","html_url":"https://github.com/cbweixin","followers_url":"https://api.github.com/users/cbweixin/followers","following_url":"https://api.github.com/users/cbweixin/following{/other_user}","gists_url":"https://api.github.com/users/cbweixin/gists{/gist_id}","starred_url":"https://api.github.com/users/cbweixin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbweixin/subscriptions","organizations_url":"https://api.github.com/users/cbweixin/orgs","repos_url":"https://api.github.com/users/cbweixin/repos","events_url":"https://api.github.com/users/cbweixin/events{/privacy}","received_events_url":"https://api.github.com/users/cbweixin/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-20T17:17:07Z","updated_at":"2015-10-20T17:17:07Z","closed_at":null,"body":"### Problem\r\n### Attempt 1\r\n```c++\r\nclass Solution {\r\npublic:\r\n    int missingNumber(vector<int>& nums) {\r\n        int sum = 0;\r\n        int max = INT_MIN, min = INT_MAX;\r\n        \r\n        for(int i = 0; i < nums.size();i++){\r\n            if(nums[i] >= max){\r\n                max = nums[i];\r\n            }\r\n            if(nums[i] <= min){\r\n                min = nums[i];\r\n            }\r\n            sum += nums[i];\r\n        }\r\n        \r\n        int res = (min + max) * (max - min + 1) / 2;\r\n        \r\n        if(sum - res==0){\r\n            if(max == 0) return 1;\r\n            if(min == 0) return max + 1;\r\n            return min -1;\r\n        }\r\n        return res - sum;\r\n    }\r\n};\r\n```\r\n\r\n#### result\r\n![image](https://cloud.githubusercontent.com/assets/1326906/10614549/c50a9988-770f-11e5-8667-51f3f15dd404.png)\r\n\r\n### further jobs\r\nneed to re-implement it with counting sort\r\n"}}