We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticintgetTotalX(List<Integer>a,List<Integer>b){// Write your code herea.sort(Collections.reverseOrder());b.sort(Collections.reverseOrder());booleanflag=true;intcounter=0;for(intnum=a.get(0);num<=b.get(b.size()-1);num++){flag=true;for(intaValue:a){if(num%aValue!=0)flag=false;}if(flag)for(intbValue:b){if(bValue%num!=0)flag=false;}if(flag)counter++;}returncounter;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
In Java 8