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.
publicstaticintbitwiseAnd(intN,intK){// Write your code hereint[]S=newint[N];List<Integer>lst=newArrayList<>();for(inti=0;i<S.length;i++){S[i]=i+1;}intA=0;intB=0;for(inti=0;i<S.length-1;i++){A=S[i];for(intj=i+1;j<S.length;j++){B=S[j];if(A<B){lst.add(A&B);}}}intpos=lst.get(0);for(inti:lst){if(K>i&&pos<i)pos=i;}returnpos;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 29: Bitwise AND
You are viewing a single comment's thread. Return to all comments →
This is my Solution for the problem!
in Java!