Count of Equivalent Subarrays | Hashmap Interview Questions
Вставка
- Опубліковано 19 жов 2024
- Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. In this video, we discuss the count of equivalent subarrays problem using hashmaps in java. In this problem,
1. You are given an array of integers(arr).
2. You have to find the count of equivalent subarrays.
3. A subarray is equivalent if,
count of unique integers in the subarray = count of unique integers in the given array.
To attempt and submit this question, click here: www.pepcoding....
For a better experience and more exercises, VISIT: www.pepcoding....
#hashmaps #datastructure #algorithms
Have a look at our result: www.pepcoding....
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education
Amazing explanation..These questions are tricky one and only you can explain these things in lucid way.
Sir I hope that ad revenue you are earning through these videos is enough to support you.
Sir why are you adding arr. Len - i in answer, why not just incrementing ans variable????
Great sir❤️❤️❤️❤️
Glad you liked it!
Keep learning.
And for better experience and well organised content visit nados.pepcoding.com
Is this Not Same as Count Substrings with K Distinct Characters ? Can we do these two problems with one solution ?
Yes
yeah its same thats what i did
but why do u wanna write that complex code when you can write this simple code that will be much easier
No
In this question K is always equal to maximum unique character ,
whereas in Count Substrings with K Distinct Characters K range is 1=
Nope both are different questions. Here value of k is fix, that is number of distinct characters present in the whole string but that question(k distinct substring) can have a random value of k. Here the value of k was fix, so after acquiring k unique characters, you can safely say the substring substr(j, i) and the substrings lying after that will have repeate characters because 'k' in this questions was the maximum unique characters that can be found. But in the question, count substring with k unique chars, k was random and hence you can't safely say that after acquiring k chars, the substring lying beyond that will also have repeated chars
last test case with 10,000 elements is failing in c++