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.
I have a question regarding this condition
If our numInputs is an odd number
if(j == k)
{
leftD += curInput;
}
at some point we will have a (j==k) in rightD as well
and at this point the code will add to the leftD and rightD as well which would make the same to give you a wrong answer. Wont It?
Please forgive me. Noob Question if i havent seen something correctly.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
Hi,
I have a question regarding this condition If our numInputs is an odd number
if(j == k) { leftD += curInput; }
at some point we will have a (j==k) in rightD as well and at this point the code will add to the leftD and rightD as well which would make the same to give you a wrong answer. Wont It?
Please forgive me. Noob Question if i havent seen something correctly.