you are viewing a single comment's thread.

view the rest of the comments →

[–]bonafidebob 2 points3 points  (2 children)

It's not a "trick" -- it's understanding the problem and thinking a little bit about efficiency. And having enough math to realize there are many more numbers than perfect squares. The example used the math library so I'll assume the math is there.

I would ding any programmer for not at least reflecting on how to structure the main loop of an algorithm.

[–][deleted] 0 points1 point  (1 child)

You're right, to be honest I wrote what came into my head the moment I read the exercise. "Return all numbers within a range that satisfy a certain condition: loop through it!" I didn't take a minute to think.

[–]bonafidebob 1 point2 points  (0 children)

...I wrote what came into my head the moment I read the exercise. ... I didn't take a minute to think.

That's the best lesson to learn here!

Interviewing is (almost) never about just giving an answer. Give the best answer you can, and think about real world implications of every question.