Find whether an array is subset of another array | GeeksforGeeks

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

This video is contributed by Anik Shah.

Please Like, Comment and Share the Video among your friends.

Install our Android App:

If you wish, translate into local language and help us reach millions of other geeks:

Follow us on Facebook:

And Twitter:

Also, Subscribe if you haven't already! :)
Рекомендации по теме
Комментарии
Автор

What if n>m? Will it work efficiently in that condition too?

deepanjandatta
Автор

Brilliant, simple, and beautiful solution! Thank you! ✨✨✨✨✨

lolaueda
Автор

I would like to mention that Your algorithm is not linear as we are using contains () method which itslef has a loop inside .
Secondly, we are using add() method of hashser which implicitly calls contains() method to check duplicate elements.

Hence its complexity is not linear

randhish
Автор

Because of you I got to know hashing easily tq bro🙏✨✨✨

bisatisrilatha
Автор

What if the given arrays are a[]={1, 2, 3, 4, 5} b[1, 2, 3, 3]

shahbazalam
Автор

incase of duplicates elements in arrat, it will fail. right?

rishabhsahu
Автор

Is anyone able to submit Java solution for this problem...method is declared as public String isSubset( long a1[], long a2[], long n, long m). Facing issue with 'long'

abhisheksoti
Автор

Suppose arr1 = {11, 1, 13, 21, 3, 7}
arr2 = {11, 3, 7, 1, 1}
Using the method that you told would fail for this case because all the elements of arr2 have atleast 1 occurrence in arr1 but as arr2 contains two 1s and arr1 contains only one 1s, arr2 isn't a subset of arr1. But your function will return true for that.

divyanshr