Mastering Coding Interviews: Take the 100 Days LeetCode Challenge with Me!

Ahmed Islam
3 min readJun 1, 2024

--

Greetings, Fellow tech enthusiasts!

I am excited to kick off my 100 Days of LeetCode Challenge today. But before we delve into the details, let’s delve into LeetCode and understand why mastering it can be a game-changer for those aiming to secure a coveted position at renowned tech firms.

Unveiling the Power of LeetCode

LeetCode stands as a prominent online platform offering a diverse array of coding challenges tailored to enhance your programming skills, acquaint you with essential data structures, and deepen your understanding of algorithms. It remains a popular choice among software engineers gearing up for technical interviews at leading tech enterprises like Facebook, Amazon, Apple, Netflix, and Google (commonly referred to as FAANG).

The Significance of LeetCode in Programming

Here are a few reasons why LeetCode holds immense value:

1. Extensive Practice: Featuring thousands of problems spanning various topics, from basic arrays and strings to intricate concepts like dynamic programming and graphs.

2. Real Interview Scenarios: Many challenges on LeetCode mirror actual questions posed during technical interviews by FAANG firms. Nurturing proficiency in these problems offers a competitive edge in interview readiness.

3. Skill Validation: With a robust platform for testing and refining your problem-solving abilities, LeetCode provides instant feedback and detailed solutions to facilitate efficient learning and growth.

4. Mastering DSA: For those delving into Data Structures and Algorithms (DSA), LeetCode emerges as an invaluable resource that not only elucidates theoretical concepts but also offers hands-on exposure to practical problems.

Today’s Accomplishments

1. Two Sum

Task: Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

Approach: Employing a hash map to track encountered elements’ indices, enabling an O(n) time complexity solution.

Solution:

def twoSum(self, nums: List[int], target: int) -> List[int]:
prevMap= {}
for i, n in enumerate(nums):
diff = target-n
if diff in prevMap:
return [prevMap[diff], i]
prevMap[n]= i

2. Find First and Last Position of Element in Sorted Array

Task: Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.

If target is not found in the array, return [-1, -1].

You must write an algorithm with O(log n) runtime complexity.

Approach: Leveraging binary search to pinpoint the leftmost and rightmost positions of the target, thereby ensuring O(log n) complexity.

def searchRange(self, nums: List[int], target: int) -> List[int]:
if not nums:
return [-1,-1]
N=len(nums)
st,end = -1,-1

l= bisect_left(nums,target)
r= bisect_right(nums,target)

if l<N and nums[l]==target:
st = l
if nums[r-1]== target:
end =r-1

return [st,end]

3. Score of a String

Task: You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters.

Return the score of s.

Approach: Compute the score by iterating through the string and summing the absolute ASCII value differences of adjacent characters.

def scoreOfString(self, s: str) -> int:
sum =0

for i in range(1, len(s)):
sum += abs(ord(s[i-1]) - ord(s[i]))

return sum

Let’s Connect!

Stay updated on my progress and embark on this exhilarating journey with me by following me on LinkedIn, Instagram, Twitter, GitHub, and Facebook.

Don’t forget to Follow to my Medium page for enriching content and updates.

Let’s conquer these 100 days together! 💪

— -

Share your feedback and suggestions in the comments. Happy programming!

--

--

Ahmed Islam

GDSC-VU Core Team 2023 - 24 | Tech Lead @ Web3 Pak | Data Science & Business Analytics intern @ The Sparks Foundation | IBM Certified Machine Learning