tag:blogger.com,1999:blog-8522573717713847738.post3509137680866756123..comments2024-03-28T00:14:29.070-07:00Comments on Yu's Coding Garden : leetcode Question: Contains Duplicate IIAnonymoushttp://www.blogger.com/profile/00263085222060621782noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-8522573717713847738.post-27258452647745739462015-10-24T23:42:46.618-07:002015-10-24T23:42:46.618-07:00public class Solution {
public boolean contain...public class Solution {<br /> public boolean containsNearbyDuplicate(int[] nums, int k) {<br /> HashMap map = new HashMap();<br /> for (int i=0; i=k) {<br /> return true;<br /> }<br /> map.put(nums[i], i);<br /> }<br /> return false;<br /> }<br />}<br /><br />The above was my java solution. It failed a test case with input ([99,99], 2). The expectation was true, but I think its wrong.Meghadityahttps://www.blogger.com/profile/18199886403385319996noreply@blogger.com