Reintroducing Code Review with an Interview Question Asked at Amazon
Tags: codenewbie, career, challenge, javascript
Published: 2020-10-01 13:53:49

## Reintroducing Code Review

Hi there! I’m Cindy from [Coderbyte](https://coderbyte.com/), an online developer interview prep and learning platform. In celebration of Coderbyte reaching 500,000 developers, we’re relaunching our weekly code challenge series: [Code Review](https://dev.to/coderbyte/introducing-code-review-a-weekly-coding-challenge-series-1jlg). Every **Thursday**, we’ll launch a new coding challenge used in a real interview for free to Dev.to. Readers can submit their solutions in the comments section of each article for the opportunity to have their code reviewed by Codebyte and our readers. Let’s jump directly to this week’s challenge.

## The Challenge

This week we’re focusing on an algorithms based question asked during an interview at Amazon.  In this challenge, we’re asked to write a function `ArrayAddition` in Javascript that takes in an array of numbers stored in a variable named `arr`.

The function should return the string `true` if any combination of numbers in the array (excluding the largest number) can be added up to equal the largest number in the array. 

Otherwise, the function should return the string `false`.

**Examples:**
* If `arr` contains `[ 4, 6, 23, 10, 1, 3 ]` the output should return true because `23` is the largest number and `4 + 6 + 10 + 3 = 23`.
* If `arr` contains `[ 5, 7, 16, 1, 2 ]`, the output should return false because none of the numbers add up to the largest number of `16`.
* If `arr` contains `[ 3, 5, -1, 8, 12 ]`, the output should return true because `12` is the largest number and `5 + 8 - 1 = 12`. 

Some assumptions we can make:  
1. The `arr` will not be empty.
2. The `arr` will not contain all the same elements but can contain some duplicate elements. For instance, the array cannot be `[ 2, 2 ]`, however, it can be `[ 2, 2, 4 ]`
3. The array may contain negative numbers.

## Tips for Solving the Problem 
Some things to consider when approaching this problem:
1. Are there any edge cases we have not accounted for?
2. How would you approach whiteboarding an approach before coding? 
3. What would a recursive solution look like and how would it compare to an iterative approach? If you need a refresher on recursion, check out our [Master Recursion Youtube series](http://bit.ly/master-recursion-youtube).  
4. What is the time and space complexity of your solution? Check out our [video guide on Big O](https://bit.ly/coderbyte-big-o-guide-1) for reference.

Once you have a solution that passes the test scenarios above, please share with us in the comments for a chance to be selected as this week’s winner. 

## More Resources 
At [Coderbyte](https://coderbyte.com/), you can sign up for our free 10-day interview prep email course, access our challenge library of over one million solutions, learn through interview kits and starter courses, and practice with mock interviews. We also have more insights on career and interview prep on [Medium](https://medium.com/coderbyte) as well as additional free video tutorials on [Youtube](https://bit.ly/algorithm-fundamentals-playlist). 

## About Me 
I’ve worked in tech for over five years. My journey to engineering has been non-traditional. In my former lives, I’ve worked as a real estate broker, product manager, growth lead and UX designer. I’ve also taught full-stack development at App Academy, a coding bootcamp where I also learned how to code. Currently, outside of Coderbyte I work as a backend engineer at Knotch where we build a content intelligence platform used by Fortune 100 companies. My passion for making engineering careers accessible is what drew me to join the Coderbyte team. Feel free to reach out to me at cindy.tong@coderbyte.com if you have ideas on how we can improve this series.

## Til Next Week
We’ll see you next Thursday where we will discuss various approaches to this problem and highlight some reader-submitted solutions.

*Credits: <span>Photo by <a href="https://unsplash.com/@thisisengineering?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">ThisisEngineering RAEng</a> on <a href="https://unsplash.com/s/photos/coding?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>*