Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 1, 2021 02:02 pm GMT

How to Practice for Code Challenges

Introduction

You are given coins of different values and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount.

What code should you write to solve this problem? Or, where would you even start? If you haven't run into coding challenges yet, Google, Amazon, and all of the big software companies use questions like the one above to hire all their new engineers.

If you dont have a solution for this problem yet then you're in good company - neither do 63% of all programmers who try it (according to Leetcode).

What's more important, is that you develop a framework to approach these problems with, so that you're prepared for whatever they'll throw at you in a technical interview.

Here's a list of 5 takeaways that will help you crush code challenges for your technical interview:

Goku trains with lots of push-ups

1. Use a Timer or Stopwatch

Pick the amount of time that you want to give yourself for one problem, and stick with it. You might solve the problem ahead of schedule, you might not either way, it doesnt matter if you solve the challenge or not. As soon as your times up, stop what youre doing and move to the next one. Im serious.

Your goal shouldnt be a green checkmark or a gold star...leave that pass/fail nonsense in grade school where it belongs. Instead, your goal should be to attain knowledge. How do you do that? By failing and adapting. Over and over again. To accomplish this, you need exposure to lots of different kinds of problems. Quickly.

Back when I started solving coding challenges, I spent 45 minutes to an hour on each one and I failed almost all of them. Now, Im spending no more than 20 minutes on each, and Ill solve 5075% depending on the difficulty. But forget about me, just worry about your own timer and set it wherever you feel comfortable. Over time youll find that you shave off a few minutes; the way youll get there is by setting daily goals.

2. Set Daily Goals

This will help you to focus and to shut out some of lifes distractions. Sure, it sounds simple and anyone can set a daily goal the difficult part is completing this goal day after day. Were looking for consistency here. One daily goal, every day, is much better than completing five goals on Monday while failing to do any on Tuesday.

Compound interest is the eighth wonder of the world. He who understands it, earns it he who doesnt pays it. -Albert Einstein

In this quote, Einstein was referring to the tendency of money to earn more of itself over time. But if you apply the same idea to your growth of knowledge over time, you will become unstoppable.

One thing that you might find helpful is that while Ive noticed that Im great at taking somebody elses instructions, but Im terrible at following my own. Luckily, Ive found a way around this; write your daily goals for tomorrow before you go to bed tonight. Set them on your desk, and forget about them. Youll wake up in the morning with a clear head, sit in your chair, and notice a to-do list from a very smart, very organized stranger.

Another thing that helps is if you set a small number of easy-to-achieve goals for yourself. Motivation is key; youre much more likely to solve three Leetcode challenges if you plan on solving two than if you dread solving 30.

3. Follow a Framework

1_WQ4lzbAfqWoq4lTLveghHw

Back when I was solving daily code challenges, I would write notes for every problem I tried. The next time I would job search, my goal will be to fill another notebook. Im sharing this for two reasons. First, because my bootcamp taught me a really simple framework for keeping notes, called UPER

  • Understand
  • Plan
  • Execute
  • Review

The first two steps should happen before you write any code. To accomplish anything, you have to plan how youll get there. But before you can even do that, you need to make sure you understand whats being asked of you.

For example, whats the input type that your function will receive? What will your output be a string, or maybe a float? Are you missing any crucial information?

Next, youll execute each of the steps in your plan by defining your variables and writing your functions. Then lastly, review how you did! What did you do well, what can you improve, and what were you unsure about?

The second reason Im sharing this UPER framework with you, is that I truly believe code challenges are one of the best ways to improve your programming chops. Yes, theyre time-consuming and no you dont have to be as obsessive about them as I was, but daily code challenges will make you better. Youll learn about your programming language, and youll build analytical muscles from all those reps in the Leetcode gym. Most importantly, you'll learn creative problem-solving with every challenge you tackle. And after you're hired, you can flex those muscles when you write code daily at your job!

4. Step Away

Dont take my word for it. Doctors keep finding that our brains are more creative when we take frequent breaks. Fresh air and exercise arent just good for your health. When youre stuck on a problem and youve tried everything, focusing on something new can be the best way forward. Geniuses throughout history such as Steve Jobs, Charles Darwin, Albert Einstein, and Tchaikovsky all knew the importance of taking a walk outside.

A sudden flash of creative insight can come from anywhere, especially when youre outside taking a breath.

Bob Ross petting a deer and smiling

5. Learn from Others

Whats tough about learning a new skill is that theres so much information you havent learned yet that you dont even know what you dont know. This is because youre missing the context researching on your own is hard because you dont know where to start. You dont know what is and is not important; Javascript built-in methods? Functional programming concepts? Data structures? How do you filter through the noise?

Leetcode has a nifty feature that lets you read the code that other people already submitted. When Im solving code challenges, even if I solved the problem Ill read through other users solutions and take notes.

1_fdh-5b8Yer-g4_RIX6p_oA

Just because you solved the problem doesnt mean that you cant still improve. There might be a concise way to solve the same challenge in five lines instead of ten. Maybe you could write a more efficient algorithm or one that uses less computing space. This ties back into the Review step of the UPER framework.

Take a peak at somebody elses code and youll be surprised at how much you can learn about your own.

Conclusion

Hopefully some of this was helpful, but this is just what worked for me! Theres a lot of great advice out there; both Kevin Naughton Jr. and Nick Whites videos were a huge inspiration to me. Just remember, keep iterating and youll find what works best for you.

Follow me on Twitter for more programming tips, and DM me if you have any questions or if youd like some advice. Thank you for reading!


Original Link: https://dev.to/mikechrupcala/how-to-practice-for-code-challenges-4gbc

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To