Multiset Equivalence Problem | Java program to check if two given multisets are equivalent ; sort the elements of both multisets ; Return true if both multisets are same . ; Driver code
import java . util . * ; class GFG { static boolean areSame ( Vector < Integer > a , Vector < Integer > b ) { Collections . sort ( a ) ; Collections . sort ( b ) ; return ( a == b ) ; } public static void main ( String [ ] args ) { Vector < Integer > a = new Vector < Integer > ( Arrays . asList ( 7 , 7 , 5 ) ) ; Vector < Integer > b = new Vector < Integer > ( Arrays . asList ( 7 , 5 , 5 ) ) ; if ( areSame ( a , b ) ) System . out . print ( "YesNEW_LINE"); else System . out . print ( "NoNEW_LINE"); } }