Had a fun experience troubleshooting with a becoming-a-programmer friend.
They had written some logic for an exercise. It worked, it gave correct results for all sample inputs and what have you. But trying to turn it in, digitally, showed it was too slow. They have this fancy system where it actually runs and tests your code, which I think is really cool and up to modern standards. But it also times out on long operations.
So they had to figure out how to shave a few precious seconds off the execution time of the thing. There’s a lot to be said there about correct approaches. The places you look in, the kind of code you want to end up writing, and so on. But most importantly, you need to measure first. Get a clear view of your baseline so you can compare your changes against it. If you’re getting fancy, measuring can also give you a better idea of the specific areas you need to tackle.
But we didn’t, be just slapped some optimizations on there and called it a day. It ended up being sufficient. You don’t get graded on process, sadly.