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.
floor(sqrt(l))<=rows<=columns<=ceil(sqrt(l)) -------given condition
when l=8;
we take rows=2,columns=3 but the product is less than 8;
so we should INCREMENT the ROWS(rows=3) not the columns..because if we columns it exceeds the ceil value...
suppose if l=25;
now we should take rows=5 and columns=5 insted of rows=5 and columns=6 to satisfy the condition of row*columns should be minimum....
so its better to use floor and ceil functions...
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →
floor(sqrt(l))<=rows<=columns<=ceil(sqrt(l)) -------given condition when l=8; we take rows=2,columns=3 but the product is less than 8; so we should INCREMENT the ROWS(rows=3) not the columns..because if we columns it exceeds the ceil value... suppose if l=25; now we should take rows=5 and columns=5 insted of rows=5 and columns=6 to satisfy the condition of row*columns should be minimum.... so its better to use floor and ceil functions...