java - (LeetCode) Contains Duplicate III -
given array of integers, find out whether there 2 distinct indices , j in array such difference between nums[i] , nums[j] @ t , difference between , j @ k.
hello!
i kinda stumped question, honest. solutions provided in (leetcode) discussion forum question did not provide explanation/thought process how solve it. i'd rather understand technique solving problem having full implementation code given me. feel best way learn.
so, clue here use (java) treeset approach problem. assuming floor , ceiling methods useful here.
i'd appreciate if there out there can give me bit of clue/hint approach problem. pseudocode welcome well! don't need full implementation code i've said before. starting point great! :)
thanks!
edit: i'm working on in meantime! so, if answer, i'll post on here future reference. :)
first implementation comes mind 2 loops, 1 nested.
within inner loop check logic abs(nums[i]-nums[j]) <= t , abs(i-j)<=k.
outer loop: 0 n
inner loop: j i+1 n
Comments
Post a Comment