You are viewing a single comment's thread. Return to all comments →
My code works according to the logic shown . Test cases 6 , 11 still fail though . Please tell me whats wrong here....
HashMap<Long,Long> map = new HashMap<>() ; for(int i =0 ;i < arr.size() ; i++) map.put(arr.get(i) , map.containsKey(arr.get(i))?(map.get(arr.get(i))+1):1) ; long res = 0 ; for(int i= 0 ; i < arr.size() ; i++){ long n = arr.get(i) ; long count = map.get(n) ; Long _1 = map.get(n*r) ; Long _2 = map.get(n*r*r) ; if(_1!=null && _2!=null) res+=_1 * _2 ; map.put(n, Math.max(0,count-1)) ; } return res ;
Seems like cookies are disabled on this browser, please enable them to open this website
Count Triplets
You are viewing a single comment's thread. Return to all comments →
My code works according to the logic shown . Test cases 6 , 11 still fail though . Please tell me whats wrong here....