You are viewing a single comment's thread. Return to all comments →
Source code:
// 1st approach static int[] acmTeam(String[] topic) { int n = topic.length; BigInteger[] bi = new BigInteger[n]; for (int i = 0; i < n; i++) bi[i] = new BigInteger(topic[i], 2); int maxTopic = 0; int teamCount = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { BigInteger iuj = bi[i].or(bi[j]); int bitCount = iuj.bitCount(); if (bitCount > maxTopic) { maxTopic = bitCount; teamCount = 1; } else if (bitCount == maxTopic) { teamCount++; } } } int result[] = { maxTopic, teamCount }; return result; }
Click here for video explanation
Would really appreciate your feedback like, dislike , comment etc. on my video.
Seems like cookies are disabled on this browser, please enable them to open this website
ACM ICPC Team
You are viewing a single comment's thread. Return to all comments →
ACM ICPC Team HackerRank Solution | Algorithms | Implementation
Source code:
Click here for video explanation
Would really appreciate your feedback like, dislike , comment etc. on my video.