LeetCode Contains Duplicate II

BabbleDay posted @ 2015年7月17日 03:14 in 刷题防身 with tags LeetCode Contains Duplicate II Python , 490 阅读

心得:思考要完整。。。

 

class Solution:
    # @param {integer[]} nums
    # @param {integer} k
    # @return {boolean}
    def containsNearbyDuplicate(self, nums, k):
        dict = {}
        for i in range(len(nums)):
            if(nums[i] in dict):
                if(i-dict[nums[i]]<=k):
                    return True
            dict[nums[i]] = i
        return False
Avatar_small
JAC Board 8th Class 说:
2023年9月22日 21:17

Jharkhand Students Start to Learn Several Important topics and Concepts of Jharkhand Board class Syllabus 2024 From in-Depth Articles and interactive Fascinating Lesson videos to Exhaustive List JAC Board 8th Class Syllabus 2024 of Resources for Jharkhand Board class new Syllabus 2024 Available in Hindi, English, Mathematics, Science, Social Science All Subjects.Those Students who are eagerly Searching for Jharkhand 8th class Syllabus 2024 can get All the Details From This Article, Jharkhand Academic Council is an state Government Agency has Provided All the Subject wise Syllabus on their official website Only, To help all the Exam Appearing Students.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter