Count items common to both the lists but with different prices | function to count items common to both the lists but with different prices ; for each item of ' list1' check if it is in ' list2' but with a different price ; required count of items ; Driver program to test above
function countItems ( list1 , m , list2 , n ) { var count = 0 ; for ( var i = 0 ; i < m ; i ++ ) for ( var j = 0 ; j < n ; j ++ ) if ( list1 [ i ] [ 0 ] === list2 [ j ] [ 0 ] && ( list1 [ i ] [ 1 ] != list2 [ j ] [ 1 ] ) ) count ++ ; return count ; } var list1 = [ [ " " , 60 ] , [ " " , 20 ] , [ " " , 50 ] , [ " " , 30 ] ] ; var list2 = [ [ " " , 20 ] , [ " " , 15 ] , [ " " , 40 ] , [ " " , 60 ] ] ; var m = list1 . length ; var n = list2 . length ; document . write ( " " + countItems ( list1 , m , list2 , n ) ) ;