#100DaysOfCode: Day3

Shawn McMahon
3 min readJul 15, 2021

--

Interview Practice Reflection

Source: https://www.pexels.com/photo/man-in-black-crew-neck-t-shirt-sitting-on-gray-couch-5989930/

Last week we received an interview assessment practice during class. Since we are halfway through the program we are beginning to prepare for interviews more and more. We were given a technical challenge that we needed to solve within 40min.

The Problem

The task seemed simple enough. Return an array with the lowest sum and the highest sum using only 4 out of the 5 numbers. Before I dove into the code, I wrote down my pseudocode to think about the problem step by step. I am usually tempted to jump in immediately and break things to learn about the problem. But I have learned the value of writing down each step before I start. It forced me to think of the problem at a high level. It’s more work upfront but it does save me time on the backend by having a step-by-step list I can reference when I get stuck.

My Pseudocode

Immediately I can see that my pseudocode differs a bit from the end result — and that’s okay! Your pseudocode may not be 100% accurate but forcing yourself to look at the problem from start to finish is where the magic happens. In my planning, I decided I was going to use .pop() and .unshift() to take off the first and last integers. Doing this well helps me create arrays I can reduce through in order to find the two sums I need. In the future, I need to get better at specifically writing down my expected input and outputs. This is a good habit to remind me what my end result needs to be.

My Solution

Here is the final answer I came up with. Part of me knows this could likely be refactored into dryer code but I was glad I finished this problem within the time given. My end result differed from my plan in a few ways

After working with array iterator methods for 6 weeks in mod2, I realized my skills are a little rusty on the array mutator methods we learned in mod1.

1. Shift and unshift mutate the front of the array — not the back like I originally planned.

2. I was looking to remove the integer, so I needed .shift() not .unshift() which adds the integer to an array.

3. I forgot that after I calculated the lowest sum, I needed to add that integer back on the array with .push() in order to create the second sum. These are mutator methods, not iterator methods, so they DO mutate the original array!

While I am glad I solved this in the time we are given, it’s pretty clear I need to go back to my array mutator methods and practice some more. Array iterator methods made my life a lot easier these last few weeks but it’s critical to have a solid understanding of the foundations of JS in order to keep my toolkit sharp.

That’s all for today ~ later!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Shawn McMahon
Shawn McMahon

Written by Shawn McMahon

Software Engineer, Snowboarder, Music Enthusiast

No responses yet

Write a response