Tips for solving a problem in a limited time
Some tips I got for coding/math tests in exams, interviews thru some failures. LOL
1. Don't panic.
Obvious but mostly overlooked principle. DO NOT PANIC. Being panicked will not make anything better. I was being interviewed for one of the greatest bootcamps (I believe) in the US and I answered some simple math questions out of my stupidity, because I was nervous and finally panicked. I couldn't even speak English properly. I was so dumb. Just don't panic. Relax and have the attitude of being 'half-given up'. This will really help you if you know what I mean. You have not given up the exam entirely, but your mind is relaxed as if you have given up the exam, but at the same time you are doing your best (or probably 90%, because being at a full power may make you nervous again)
Obvious but mostly overlooked principle. DO NOT PANIC. Being panicked will not make anything better. I was being interviewed for one of the greatest bootcamps (I believe) in the US and I answered some simple math questions out of my stupidity, because I was nervous and finally panicked. I couldn't even speak English properly. I was so dumb. Just don't panic. Relax and have the attitude of being 'half-given up'. This will really help you if you know what I mean. You have not given up the exam entirely, but your mind is relaxed as if you have given up the exam, but at the same time you are doing your best (or probably 90%, because being at a full power may make you nervous again)
2. Remember to initialize a variable / assign a value to a variable at the right time (place).
Here's an example code. The program is intended to get the biggest sum between two adjacent integers.
Here's an example code. The program is intended to get the biggest sum between two adjacent integers.
-
See the problem? The variable sum has only been assigned a value once, so inside the for loop, the value will be just accumulated over and over, which is not the intended purpose, obviously. So make a revision as follows:
-
3. Remember to catch exceptions.
4. Think relatively long if the time allows. It's ok. You are probably going to figure out better solutions (probably with better time/space complexity). And, DO NOT write the code first. Codes without thoughts are pretty much useless.
5. Use APIs instead of doing the harsh work yourself.
Google for the API needed (or use linter on your IDE) to check the relevant function. Many times, there is a function that would do the work for you. But, be aware of the time complexities of different functions. It may not make the things straight.
Google for the API needed (or use linter on your IDE) to check the relevant function. Many times, there is a function that would do the work for you. But, be aware of the time complexities of different functions. It may not make the things straight.
6. Don't try to test ALL the cases if that's possible. In some cases, it is just not necessary to test all cases. You may only need to test some to return a desired value from a function.