Was asked this during a job interview today. I'm sure it's a pretty simple trick, but I couldn't think of it. How can I traverse a simple Java array from end to beginning (for example, in order to aggregate the sum of all values form right to left), without using the "minus" (-
) sign (so no i--
in the loop, or something similar)?
Edit: I'm pretty sure it was supposed to be a trick that doesn't involve Java-specific structures (like Collections
). Unfortunately I thought I'd think of it myself later, so I didn't ask what the answer was :/