I just learned the basics of the binary system, but am still struggling to implement this in Java for Paying Up. Looked at other problems and still not understanding the basics.

How do we look at/process the different ways 2^n where n=3 = 8 can be 0 0 0, 0 1 0 … etc.

These are only 3 digits in this tutorial example - isn’t this a byte? and aren’t bytes composed of 8 digits?

Also what is really happening when “For checking if the bit is set at position ‘j’(starting from 0) we can just check if the value of (i & (1<<j)) is 0”

Below is my basic code with just the input taken care of - I’d really appreciate help figuring out where and how to represent the problem in binary.

Thanks,

public class Main {

```
public static void main(String[] args)throws java.io.IOException{
java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
java.io.BufferedWriter out = new java.io.BufferedWriter(new java.io.OutputStreamWriter(System.out));
int tests = Integer.parseInt(reader.readLine());
while(tests-->0){
String[] params = reader.readLine().split(" ");
int n = Integer.parseInt(params[0]); //quantity of different notes in wallet <= 20
int m = Integer.parseInt(params[1]); //demanded amount $
int[] noteValues = new int[n]; //store each distinct note
for(int i = 0; i < n; i += 1)
noteValues[i] = Integer.parseInt(reader.readLine());
if(validSet(noteValues,m))
out.write("Yes\r\n");
else
out.write("No\r\n");
}
out.flush();
}
/**check if a set of sorted notes can meet the exact demand.*/
public static boolean validSet(int[] notes, int demand){
return false;
}
```

}