The Deceptive Ease of Easy Problems on LeetCode: 10 Confidence-Boosting Challenges for Beginners
Tags: leetcode, javascript, beginners, webdev
Published: 2023-10-21 17:32:48

LeetCode, the online platform for sharpening your coding and problem-solving skills, offers problems categorized as "Easy," "Medium," and "Hard." While the "Easy" label may suggest simplicity, many aspiring programmers and developers soon realize that these problems can be deceptively challenging. In this blog post, I'll explore why easy problems on LeetCode are not as easy as they seem and present 10 of these problems that can help boost your confidence as you progress in your coding journey.

## The Deceptive Nature of "Easy" Problems

LeetCode's "Easy" problems are often the starting point for beginners or those looking to refresh their coding skills. However, they can be far from a walk in the park. The ease label tends to mislead many, but these problems are thoughtfully designed to assess your understanding of fundamental concepts and data structures. They serve as building blocks for more complex problems and real-world applications.

Here's why easy problems are not as simple as they appear:

1. **Conceptual Understanding:** Solving easy problems requires a strong grasp of fundamental programming concepts. These problems may test your understanding of basic data structures, algorithmic thinking, and logical reasoning. 
2. **Problem-Solving Skills:** While the code for easy problems may not be lengthy, devising efficient solutions still demands creativity and strategic thinking.
3. **Time Complexity:** It's important to optimize your code to run efficiently, even for easy problems. This practice becomes crucial when tackling more complex challenges.

## 10 Confidence-Boosting LeetCode Easy Problems

If you're looking to boost your confidence as a coder and want to conquer those "easy" LeetCode problems, here are 10 handpicked challenges to help you get started:

1. **[Add Two Integers](https://leetcode.com/problems/add-two-integers/description/)** _Given two integers num1 and num2, return the sum of the two integers._

2. **[Counter](https://leetcode.com/problems/counter/description/)** _Given an integer n, return a counter function. This counter function initially returns n and then returns 1 more than the previous value every subsequent time it is called (n, n + 1, n + 2, etc)._

3. **[Create Hello World Function](https://leetcode.com/problems/create-hello-world-function/description/)** _Write a function createHelloWorld. It should return a new function that always returns "Hello World"._

4. **[To Lower Case](https://leetcode.com/problems/to-lower-case/)** _Given a string s, return the string after replacing every uppercase letter with the same lowercase letter._

5. **[Return Length Of Arguments Passed](https://leetcode.com/problems/return-length-of-arguments-passed/description/)** _Write a function argumentsLength that returns the count of arguments passed to it._

6. **[Convert The Temperatures](https://leetcode.com/problems/convert-the-temperature/description/)** _You are given a non-negative floating point number rounded to two decimal places celsius, that denotes the temperature in Celsius._

7. **[Concatenation of Array](https://leetcode.com/problems/concatenation-of-array/description/)** _Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n_

8. **[Jewels and Stones](https://leetcode.com/problems/jewels-and-stones/description/)** _You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type of stone you have. You want to know how many of the stones you have are also jewels._

9. **[Number of Good Pairs](https://leetcode.com/problems/number-of-good-pairs/description/)** _Given an array of integers nums, return the number of good pairs._

10. **[Fibonacci Number](https://leetcode.com/problems/fibonacci-number/description/)** _The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1._

## SOLUTIONS in JavaScript

```
// 1. Add Two Integers
var sum = function(num1, num2) {
    return num1 + num2; 
};
```

```
// 2. Counter
var createCounter = function(n) {
    return function() {
        return n ++;
    };
};
```

```
// 3. Create Hello World Function
var createHelloWorld = function() { 
    return function(...args) {
        return "Hello World"
    }
};
```

```
// 4. To Lower Case
var toLowerCase = function(s) {
    return s.toLowerCase();
};
```

```
// 5. Return Length Of Arguments Passed
let argumentsLength = (...args) => [...args].length
```

```
// Convert Temperatures
var convertTemperature = function(celsius) {
    let kelvin = celsius + 273.15;
    let fahrenheit = celsius * 1.80 + 32.00;
    return [kelvin, fahrenheit];
};
```

```
// Concatenating two arrays
var getConcatenation = function(nums) {
    return [...nums, ...nums];
}
```

```
// Jewels in Stones
var numJewelsInStones = function(jewels, stones) {
    let count = 0;
    for (let i = 0; i < jewels.length; i++){
        for (let j = 0; j < stones.length; j++){
            if (jewels[i] === stones[j]) count++
        }
    }
    return count
};
```

```
// Number of Good Pairs
var numIdenticalPairs = function(nums) {
    let left = nums[0];
    let right = nums[nums.length-1];
    let count = 0;
    for(let i = 0; i < nums.length; i++){
        for (let j = i + 1; j < nums.length; j++){ // not j = 0
            if (nums[i] === nums [j]) count++
        }
    }
    return count;
};
```

```
// Senior Fibonacci
var fib = function(n) {
    if (n === 0 || n === 1) return n // cover base cases 
    let array = [0,1]
    for (let i = 2; i<=n; i++) {
       array[i]=array[i-2]+array[i-1]
     }
     return array[n];
};
```