Compare vector elements with values in Map
for ( auto itr = m . begin ( ) ; itr != m . end ( ) ; itr ++ ) { if ( itr -> second != v [ i ] ) { flag = 0 ; break ; } i ++ ; } if ( flag == 1 ) return " YES " ; else return " NO " ; }