π 90 Days of DSA β Day 7: Strings & Arrays Deep Dive


π Day 7 of my #90DaysOfDSA journey was packed with string and array-based problems. From detecting duplicates to checking isomorphism between strings β it was all about pattern recognition and data structure efficiency.
π Full Repo Link: DSA-Problems β Day 7
β Problem 1: Contains Duplicate
π View Code
pythonCopyEditclass Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
return len(set(nums)) < len(nums)
π Logic: Convert the list to a set and compare lengths. If set size is smaller, duplicates exist.
β Problem 2: First Unique Character in a String
π View Code
from collections import Counter
class Solution:
def firstUniqChar(self, s: str) -> int:
dict1=Counter(s)
for i in dict1.keys():
if dict1[i] == 1:
return s.index(i)
return -1
π Logic: Iterate through characters and return the index of the first character that appears exactly once.
β Problem 3: Isomorphic Strings
π View Code
pythonCopyEditclass Solution:
def isIsomorphic(self, s: str, t: str) -> bool:
return len(set(s)) == len(set(t)) == len(set(zip(s, t)))
π Logic: Ensure the number of unique characters and their mappings match using set(zip(s, t))
.
β Problem 4: Valid Anagram
π View Code
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
if len(s)!=len(t):
return False
sets=set(s)
for i in sets:
if s.count(i)!=t.count(i):
return False
return True
π Logic: Check if both strings have the same character counts.
β Problem 5: Intersection of Two Arrays II
π View Code
from collections import Counter
class Solution:
def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]:
count1 = Counter(nums1)
result = []
for num in nums2:
if count1[num] > 0:
result.append(num)
count1[num] -= 1
return result
π Logic: Use Counter
to track occurrences and build the intersection using minimum counts.
π All Code Files
Browse and fork the complete Day 7 progress here:
π GitHub Repo β Day 7
π Reflections
Practiced frequency-based solutions and mapping logic
Learned more about efficient Python tricks like
set(zip(s, t))
Starting to spot patterns quickly in string and array problems!
π Connect with Me
Follow my journey on Twitter @CodeWithPiyush and explore my projects and tools built with AI and Python.
Subscribe to my newsletter
Read articles from Piyush Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Piyush Kumar
Piyush Kumar
Hey there! Iβm Piyush Kumar, a curious mind on a mission to master Data Structures & Algorithms β one problem at a time. Iβm not just solving questions; Iβm building habits, debugging my thinking, and documenting the highs and lows of my coding grind. Whether itβs arrays at midnight, graph theory before coffee, or that satisfying βACβ moment after 17 failed attempts β Iβm sharing it all openly. π Currently on a 90-day DSA challenge, I post daily blogs and code logs that unpack: Real-world problem-solving strategies Patterns and techniques I learn (and unlearn) Honest reflections on growth, failure, and consistency Along the way, Iβm also exploring how to apply AI to meaningful problems β because I believe in learning out loud and building in public. Letβs connect if youβre into: Open learning journeys π Problem-solving and pattern recognition π§ Building cool things with code βοΈ β‘ Follow along and letβs decode DSA β together!