Length of Longest Subarray With at Most K Frequency - Leetcode 2958 - Python

preview_player
Показать описание


0:00 - Read the problem
0:55 - Drawing Explanation
5:16 - Coding Explanation

leetcode 2958

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

Aren't you using hahmap so, how constant space?

Shivam-dryj
Автор

I can feel us becoming not neetcoders. But NeetBro-thers. Keep posting man your videos are like therapy for me. Whenever I solve a problem your voice pops up in my head.

walkastray
Автор

I never thought that I'd solve a problem on my own before even watching your video. The moment I saw this problem I could recognise this was a sliding window problem and I should keep track of the int count in sliding window.

Thanks for helping me build the intuition and identify patterns.All credits to you!

dineshkumarkb
Автор

Thanks for teaching us sliding window, I was able to solve this problem on my own after being able to identify the patterns in Leetcode problems

yang
Автор

Thanks for all your videos! Managed to solve this first try! Your sliding window problems and solutions have really helped me build the intuition for these questions

austingoh
Автор

Thank you!
Your yesterdays video helped to solve this problem 👍👍

NursultanBegaliev
Автор

Just want you to know I really appreciate your uploading videos till 2024 XD. I’m currently practicing for upcoming Codility test and I am super happy seeing your videos uploaded from 2 weeks ago. Great to see Neetcode IO still supporting new learners <3 You are one of my best teachers ever ❤

huyennguyenmaingoc
Автор

I started to do daily questions yesterday. This is my second Daily Question, it's a bit hard but your explanation really helped me a lot thanks!

kozma
Автор

How solved the 3090 contest question?
Its similar

staywithmeforever
Автор

coded my self, but I'm here to find some more insights, thanks navdeep

varunpalsingh
Автор

Hey neetcode.. I follow your channel all the time and you are really great. I wanted to request if you can do a video on the problem 291. Word Pattern II. Thanks in advance. 😊

shwethaks
Автор

Hey, good morning! I just completed this question.

Edit: where's da webcam 🙁

spsc
Автор

Java Solution

class Solution {
public int maxSubarrayLength(int[] nums, int k) {
int rc = 0;
int l = 0;
Map<Integer, Integer> map = new HashMap();
for (int r=0;r<nums.length;r++) {
int n = nums[r];
while ( map.containsKey(n) && map.get(n) + 1 > k ) {
map.put(nums[l], map.get(nums[l])-1);
l++;
}
map.put(n, map.getOrDefault(n, 0)+1);
rc = Math.max(r-l+1, rc);
}


return rc;
}
}

yang
Автор

how it is a constant space solution, you said in video ?

sanchitdeepsingh
Автор

Big bruh I have this small doubt ...you know ..doing DSA in python or C++, which one is better..? Could you make a video on this please ❤ :)

electrode
Автор

Nearly found the solution on my own, but i made a mistake after watching this video i feel like i can give some more time to think 😐

jegadheeswarank
Автор

Your videos always make me smile, wanna be friends?

IOSALive