## DEV Community is a community of 891,295 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Naga Saisriya

Posted on

# 5 Easy LeetCode questions to start competitive-coding

These are 5 LeetCode questions which boost my confidence to start competitive programming and there can be many easy ones out, but I started with these. I provided my Python solutions to the problems, these solutions can be optimized too, just sharing my approach :)

## 1. FizzBuzz

``````class Solution:
def fizzBuzz(self, n: int) -> List[str]:
l=[]
for i in range(1,n+1):
if i%3==0 and i%5==0:
l.append("FizzBuzz")
elif i%3==0:
l.append("Fizz")
elif i%5==0:
l.append("Buzz")
else:
l.append(str(i))
return l
``````

## 2. Single Number

``````class Solution:
def singleNumber(self, nums: List[int]) -> int:
return 2*sum(set(nums))-sum(nums)
``````

## 3. Intersection of two arrays

``````class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
return set(nums1).intersection(set(nums2))
``````

## 4. Fibonacci Number

``````class Solution:
def fib(self, n: int) -> int:
m=0
if n==0:
return 0
elif n==1:
return 1
else:
m=self.fib(n-1)+self.fib(n-2)
return m
``````

## 5. Array Partition-I

``````class Solution:
def arrayPairSum(self, nums: List[int]) -> int:
nums.sort()
return sum(nums[::2])
``````

Just make sure to start your journey no matter if you're a beginner or pro. I just started off and I can definitely feel the difference, be it in my problem-solving ways or maintaining consistency. Hope this article helps!!

## Discussion (2)

bonds

Totally agree. I feel and see a big difference just in the 4 weeks that I have been Leetcoding.
In fact, I just made the same comment in my Leetcode Diary (the Week 4 video is not yet out... too busy coding...little time to blog about the coding).

Anyway, I was working on dissecting problem 21, merging 2 sorted linked list. Leetcode helped me to see how rusty I was. I spent a week on that one problem trying to really hammer out my weaknesses. I feel sooo much better about linked lists (creation, insertion, deletion, traversing). Before problem 21, linked lists terrified me. Now I'm barely shaken by them.

I'm not a star coder yet but I'm also not a scared little kid when it comes to arrays and linked lists.