@@ -0,0 +1,765 @@
+#!/usr/bin/env python%0A# encoding: utf-8%0A%0A%22%22%22%0Acontains-duplicate-ii.py%0A %0ACreated by Shuailong on 2016-03-01.%0A%0Ahttps://leetcode.com/problems/contains-duplicate-ii/.%0A%0A%22%22%22%0A%0Aclass Solution(object):%0A    def containsNearbyDuplicate(self, nums, k):%0A        %22%22%22%0A        :type nums: List%5Bint%5D%0A        :type k: int%0A        :rtype: bool%0A        %22%22%22%0A%0A        pos = %7B%7D%0A        for i in range(len(nums)):%0A            num = nums%5Bi%5D%0A            if pos.has_key(num) and i - pos%5Bnum%5D %3C= k:%0A                return True%0A            else:%0A                pos%5Bnum%5D = i%0A%0A        return False%0A        %0A%0Adef main():%0A    solution = Solution()%0A    nums = %5B1,2,3,4,5,6,2,8,9,10%5D%0A    k = 4%0A    print solution.containsNearbyDuplicate(nums, k)%0A    %0Aif __name__ == '__main__':%0A    main()%0A%0A        %0A

solve 1 problem