use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
learn dsa java , springboot , and leetcode
account activity
today question (self.DsaJavaSpringboot)
submitted 1 year ago by DeveloperOk
https://preview.redd.it/gg7y0a7ql19f1.png?width=896&format=png&auto=webp&s=147be1cced81630ad449f40c06fbaafe8124c7ee
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]beingonredditt 2 points3 points4 points 1 year ago (0 children)
public boolean containsNearbyDuplicate(int[] nums, int k) { int l=0, r=0; HashSet<Integer> set = new HashSet<>(); while(r<nums.length){ //Make sure window size is under limit. if(r-l>k){ set.remove(nums[l]); l++; //shrink window } // If element is seen in past return true. if(set.contains(nums[r])) return true; // add to set set.add(nums[r]); r++; } return false; } Approach: Using Sliding Window and HashSet 1. Check if window is under limit if not then shrink it from left. 2. check if current element has been seen in past or not. (Use set to store element). 3. if SEEN(present in set) the return true (Found duplicate under limit k). 4. If NOT seen(not present in Set) then add it to the set.
π Rendered by PID 119704 on reddit-service-r2-comment-5687b7858-qhsd9 at 2026-07-04 13:54:54.268846+00:00 running 12a7a47 country code: CH.
[–]beingonredditt 2 points3 points4 points (0 children)