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.
Yes, you can take 'int k' and 'int data' out of the for loops and declare them outside. This is for scoping purpose (that is, to be 'defensive' in programming). This is just in case there is a 'k' somewhere else in the code too. The 'k' or 'data' inside the for loops will be different from those elsewhere.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Variable Sized Arrays
You are viewing a single comment's thread. Return to all comments →
Yes, you can take 'int k' and 'int data' out of the for loops and declare them outside. This is for scoping purpose (that is, to be 'defensive' in programming). This is just in case there is a 'k' somewhere else in the code too. The 'k' or 'data' inside the for loops will be different from those elsewhere.