Sort by

recency

|

59 Discussions

|

  • + 0 comments

    public static int bitwiseAnd(int n, int k) { int max = 0; for (int i = 1; i <= n; i++) { if (i == k-1) continue; int val = i&(k-1); if (val > max && val < k) max = val; } return max; }

    }

  • + 0 comments

    class Result {

    public static int bitwiseAnd(int n, int k) {
    // Write your code here
    

    int max = 0; for (int i = 1; i <= n; i++) { if (i == k-1) continue; int val = i&(k-1); if (val > max && val < k) max = val; } return max; }

    }

    public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));

        int t = Integer.parseInt(bufferedReader.readLine().trim());
    
        for (int tItr = 0; tItr < t; tItr++) {
            String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
    
            int count = Integer.parseInt(firstMultipleInput[0]);
    
            int lim = Integer.parseInt(firstMultipleInput[1]);
    
            int res = Result.bitwiseAnd(count, lim);
    
            bufferedWriter.write(String.valueOf(res));
            bufferedWriter.newLine();
        }
    
        bufferedReader.close();
        bufferedWriter.close();
    }
    

    }

  • + 0 comments

    class Result {

    /*
     * Complete the 'bitwiseAnd' function below.
     *
     * The function is expected to return an INTEGER.
     * The function accepts following parameters:
     *  1. INTEGER N
     *  2. INTEGER K
     */
    
    public static int bitwiseAnd(int n, int k) {
    // Write your code here
    

    int max = 0; for (int i = 1; i <= n; i++) { if (i == k-1) continue; int val = i&(k-1); if (val > max && val < k) max = val; } return max; }

    }

    public class Solution { public static void main(String[] args) throws IOException { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));

        int t = Integer.parseInt(bufferedReader.readLine().trim());
    
        for (int tItr = 0; tItr < t; tItr++) {
            String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" ");
    
            int count = Integer.parseInt(firstMultipleInput[0]);
    
            int lim = Integer.parseInt(firstMultipleInput[1]);
    
            int res = Result.bitwiseAnd(count, lim);
    
            bufferedWriter.write(String.valueOf(res));
            bufferedWriter.newLine();
        }
    
        bufferedReader.close();
        bufferedWriter.close();
    }
    

    }

  • + 0 comments

    https://www.hackerrank.com/challenges/linkedin-practice-bitwise-and/submissions

  • + 0 comments

    include

    include

    include

    include

    include

    include

    include

    int main() { int t,i,j; scanf("%d",&t); for(int a0 = 0; a0 < t; a0++) { int n; int k; int x,y=0; scanf("%d %d",&n,&k); for(i=n;i>0;--i) for(j=n-1;j>1;--j) { x=(i & j); { if(x>y && xwhat is wrong in this program