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.
Try taking this code logic and your code logic and comparing what assembly code is generated:
int max_of_four(int a, int b, int c, int d){
int max = a;
if(b > max){
max = b;
}
if(c > max){
max = c;
}
if(d > max){
max = d;
}
return max;
}
It may surprise you. Efficient code is at the assembly level not at the higher language level. If you confuse the compiler it will generate code that is a lot more inefficient.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Functions
You are viewing a single comment's thread. Return to all comments →
Try taking this code logic and your code logic and comparing what assembly code is generated:
int max_of_four(int a, int b, int c, int d){ int max = a;
}
It may surprise you. Efficient code is at the assembly level not at the higher language level. If you confuse the compiler it will generate code that is a lot more inefficient.