Contains Duplicate II | LeetCode problem 219

  Рет қаралды 9,748

Technosage

Technosage

Жыл бұрын

Contains Duplicate II
Leetcode problem number 219
Solution in JAVA
JAVA interview programming playlist:
• Interview Programming ...
Linkedin: / amrita-bala-a2b79460
#java #interviewquestions #leetcode

Пікірлер: 12
@Nishi-Tiwari
@Nishi-Tiwari Жыл бұрын
The second example you showed is not false but true {1,0,1,1}
@nandinideshpande1467
@nandinideshpande1467 Ай бұрын
very well explained!!
@Shawarmaseem
@Shawarmaseem Жыл бұрын
Amazing and easy solution!
@yuvrajsingh3693
@yuvrajsingh3693 Жыл бұрын
Thankyou so much Mam ✌🏻
@pavanrajjagdale9369
@pavanrajjagdale9369 Жыл бұрын
Hello di,can you explain the second example is {1,0,1,1} is actually false but in leetcode it is showing the output as true;
@Shawarmaseem
@Shawarmaseem Жыл бұрын
yes, it is true. When you look at the second pair of 1's, which are the 2nd and 3rd indices, their absolute difference is one, therefore it is true.
@hybi666
@hybi666 11 ай бұрын
Я не понимал почему не могу решить задачу, а я оказывается неправильно прочитал задание. Спасибо
@shashankchaurasia8428
@shashankchaurasia8428 Жыл бұрын
Nice explanation mam
@gnaneswarreddy5243
@gnaneswarreddy5243 4 ай бұрын
I guess the solution will not work for all test cases once go through the below one public class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { Map inputNumbers = new HashMap(); for (int i = 0; i < nums.length; i++) { if (inputNumbers.containsKey(nums[i])) { int firstIndex = inputNumbers.get(nums[i]); if (Math.abs(i - firstIndex)
@jalaibebai
@jalaibebai 8 ай бұрын
Sorry you have not explained this problem beginner friendly
@ishansrivastava598
@ishansrivastava598 Жыл бұрын
Bahot sundar ho yr sorry 😢
@shivambhatnagar9473
@shivambhatnagar9473 Жыл бұрын
Code that covers {1, 0, 1, 1} as `true` + passes all test cases = var containsNearbyDuplicate = function (nums, k) { let hashMap = new Map(); for (let i = 0; i < nums.length; i++) { if (hashMap.get(nums[i]) === undefined) { hashMap.set(nums[i], i); continue; } if (Math.abs(i - hashMap.get(nums[i])) > k) { hashMap.set(nums[i], i); } else { return true; } } return false; };
Single Number | LeetCode problem 136
5:26
Technosage
Рет қаралды 7 М.
Maximum Subarray | Kadane's Algorithm | Leetcode 53
7:20
Technosage
Рет қаралды 7 М.
БОЛЬШОЙ ПЕТУШОК #shorts
00:21
Паша Осадчий
Рет қаралды 11 МЛН
Nutella bro sis family Challenge 😋
00:31
Mr. Clabik
Рет қаралды 14 МЛН
УГАДАЙ ГДЕ ПРАВИЛЬНЫЙ ЦВЕТ?😱
00:14
МЯТНАЯ ФАНТА
Рет қаралды 2,6 МЛН
219. Contains Duplicate II | LEETCODE EASY
7:07
code Explainer
Рет қаралды 10 М.
Concatenated Words | LeetCode problem 472
11:26
Technosage
Рет қаралды 1,2 М.
219. Contains Duplicate II || LeetCode ||C++
7:23
Code with Sky
Рет қаралды 2,1 М.
Is Subsequence | LeetCode problem 392
6:41
Technosage
Рет қаралды 3,4 М.
Remove Element | Leetcode problem 27
6:30
Technosage
Рет қаралды 29 М.
Valid Palindrome | LeetCode problem 125
5:43
Technosage
Рет қаралды 12 М.
Search Insert Position | Leetcode 35
15:30
Technosage
Рет қаралды 8 М.
Word Pattern | LeetCode problem 290
7:51
Technosage
Рет қаралды 4,9 М.
Samsung Galaxy 🔥 #shorts  #trending #youtubeshorts  #shortvideo ujjawal4u
0:10
Ujjawal4u. 120k Views . 4 hours ago
Рет қаралды 8 МЛН
😱Хакер взломал зашифрованный ноутбук.
0:54
Последний Оплот Безопасности
Рет қаралды 940 М.
Копия iPhone с WildBerries
1:00
Wylsacom
Рет қаралды 367 М.