Important things

302 http response with Location header for url redirection(GET and Head) - 307 for temporary redirection ,==> Spring Sleuth - tracing in microservices, ==> https://astikanand.github.io/techblogs/high-level-system-design/design-bookmyshow, https://www.hellointerview.com/learn/system-design/in-a-hurry/introduction

Saturday, 27 June 2020

Count the number of Set bits in an Integer/decimal number | Java | interview question





public class SetBits {

public static void main(String[] args) {
// how to find number of set bits in Decimal number
// means number of 1's present in decimal number


int num = 5 ;
int count = 0;
// 8 bits representation of 5 : 00001001

while(num>0) {

if((num & 1) == 1) {
count++;
}

num=num>>1;
}




System.out.println(count);
}
}


Output : 2

Youtube video link:
https://youtu.be/Jh9i1OLLfks