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.
Here is a very simple solution with the help of JAVA
classResult{/* * Complete the 'bitwiseAnd' function below. * * The function is expected to return an INTEGER. * The function accepts following parameters: * 1. INTEGER N * 2. INTEGER K */publicstaticintbitwiseAnd(intN,intK){intcont=0;for(inti=1;i<=N;i++){//outer loop for(intj=i+1;j<=N;j++){//inner loopif((i&j)<K){//condition to check the BITAND less then the //the given numberif((i&j)>cont){//to compare max and store itcont=(i&j);}}}}returncont;}}
Day 29: Bitwise AND
You are viewing a single comment's thread. Return to all comments →
Java
Here is a very simple solution with the help of JAVA