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.
I implemented algorithm in Java , and after testing , I found that in Test Case 5 , the expected result is 50 , but my actual calculation is 45 , Has anyone encountered this issue?
I know the issue is on my side , Please , could someone help me check where the problem is in my Code ,
The following is my code ...
publicstaticintnonDivisibleSubset(intk,List<Integer>s){s=s.stream().map(item->item%k).collect(Collectors.toList());// Write your code heres=s.stream().sorted().collect(Collectors.toList());intmax=0;for(inti=0;i<s.size();i++){List<Integer>ans=newArrayList<>();ans.add(s.get(i));for(intj=i+1;j<s.size();j++){IntegerneedCheck=s.get(j);booleanmatch=true;for(Integeran:ans){if((an+needCheck)%k==0){match=false;break;}}if(match){ans.add(needCheck);}}if(max<ans.size()){max=ans.size();}}returnmax;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Non-Divisible Subset
You are viewing a single comment's thread. Return to all comments →
I implemented algorithm in Java , and after testing , I found that in Test Case 5 , the expected result is 50 , but my actual calculation is 45 , Has anyone encountered this issue?
I know the issue is on my side , Please , could someone help me check where the problem is in my Code ,
The following is my code ...