DevVortex (@dev_vortex_) 's Twitter Profile
DevVortex

@dev_vortex_

#Full Stack Development | MERN | NextJs | Typescript | Python | OpenAI | BuildInPublic | Open Source | #100DaysOfCode

ID: 1618577385758298113

calendar_today26-01-2023 11:51:54

2,2K Tweet

587 Takipçi

243 Takip Edilen

DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 43) ✅ Construct String With Repeat Limit 💡 Approach (Heap) 1️⃣ Count character frequencies 2️⃣ Use a max-heap to pick the largest char 3️⃣ Append up to repeatLimit times 4️⃣ If chars remain, use the next largest char, then push back unused chars

🚀 #LeetCode POTD (Day 43) ✅
Construct String With Repeat Limit

💡 Approach (Heap)

1️⃣ Count character frequencies
2️⃣ Use a max-heap to pick the largest char
3️⃣ Append up to repeatLimit times
4️⃣ If chars remain, use the next largest char, then push back unused chars
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 44) ✅ Final Prices With Special Discount 💡 Approach (Stack) 1️⃣ Traverse prices in reverse 2️⃣ Use stack to find nearest smaller price to right 3️⃣ Discount: prices[i] - stack.top() or prices[i] 4️⃣ Push current price onto stack

🚀 #LeetCode POTD (Day 44) ✅
Final Prices With Special Discount

💡 Approach (Stack)

1️⃣ Traverse prices in reverse
2️⃣ Use stack to find nearest smaller price to right
3️⃣ Discount: prices[i] - stack.top() or prices[i]
4️⃣ Push current price onto stack
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 45) ✅ Max Chunks To Make Sorted 💡 Approach 1️⃣ Track curr_max while iterating. 2️⃣ If curr_max == i, it’s a valid chunk end. 3️⃣ Increment chunk count and return total.

🚀 #LeetCode POTD (Day 45) ✅

Max Chunks To Make Sorted

💡 Approach

1️⃣ Track curr_max while iterating.
2️⃣ If curr_max == i, it’s a valid chunk end.
3️⃣ Increment chunk count and return total.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 47) ✅ Maximum Number of K-Divisible Components 💡 Approach (DFS) 1️⃣ Perform a DFS traversal to compute subtree sums. 2️⃣ If a subtree sum is divisible by k, it forms a valid component. 3️⃣ Increment component count (ans) and reset sum for that subtree.

🚀 #LeetCode POTD (Day 47) ✅
Maximum Number of K-Divisible Components

💡 Approach (DFS)

1️⃣ Perform a DFS traversal to compute subtree sums.
2️⃣ If a subtree sum is divisible by k, it forms a valid component.
3️⃣ Increment component count (ans) and reset sum for that subtree.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 50) ✅ Find Minimum Diameter After Merging Two Trees 💡 Approach (BFS) 1️⃣ Compute diameters (d1, d2) of both trees using BFS. 2️⃣ Merged diameter: max(d1, d2, ⌈d1/2⌉ + ⌈d2/2⌉ + 1). 3️⃣ BFS twice finds the farthest nodes to calculate tree diameter.

🚀 #LeetCode POTD (Day 50) ✅
Find Minimum Diameter After Merging Two Trees

💡 Approach (BFS)

1️⃣ Compute diameters (d1, d2) of both trees using BFS.
2️⃣ Merged diameter: max(d1, d2, ⌈d1/2⌉ + ⌈d2/2⌉ + 1).
3️⃣ BFS twice finds the farthest nodes to calculate tree diameter.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 51) ✅ Find Largest Value in Each Tree Row 💡 Approach (Simple BFS) 1️⃣ Apply plain BFS to traverse the tree level by level. 2️⃣ At each level, store the maximum value in the result vector.

🚀 #LeetCode POTD (Day 51) ✅

Find Largest Value in Each Tree Row

💡 Approach (Simple BFS)

1️⃣ Apply plain BFS to traverse the tree level by level.
2️⃣ At each level, store the maximum value in the result vector.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 52) ✅ Target Sum 💡 Approach (DP) 1️⃣ Use recursion with memoization to explore adding/subtracting nums[ind]. 2️⃣ Handle negatives by offsetting currSum with S = sum(nums). 3️⃣ Store results in dp[ind][currSum + S] to avoid recomputation and optimize.

🚀 #LeetCode POTD (Day 52) ✅

Target Sum

💡 Approach (DP)

1️⃣ Use recursion with memoization to explore adding/subtracting nums[ind].
2️⃣ Handle negatives by offsetting currSum with S = sum(nums).
3️⃣ Store results in dp[ind][currSum + S] to avoid recomputation and optimize.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 55) ✅ 💡 Approach (Dynamic Programming) 1️⃣ Precompute freq for char counts at each column in words 2️⃣ Use recursion + memoization to find ways to form target[i] starting from column j 3️⃣ Either skip or use column j, ensuring results are modulo 1e9 + 7

🚀 #LeetCode POTD (Day 55) ✅

💡 Approach (Dynamic Programming)

1️⃣ Precompute freq for char counts at each column in words
2️⃣ Use recursion + memoization to find ways to form target[i] starting from column j
3️⃣ Either skip or use column j, ensuring results are modulo 1e9 + 7
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 56) ✅ 💡 Approach (Dynamic Programming) 1️⃣ Start recursion with curr_len = 0, check bounds [low, high], set addOne = true if valid 2️⃣ Count ways via recursive calls for take_one & take_zero 3️⃣ Return addOne + take_one + take_zero (total ways)

🚀 #LeetCode POTD (Day 56) ✅

💡 Approach (Dynamic Programming)

1️⃣ Start recursion with curr_len = 0, check bounds [low, high], set addOne = true if valid

2️⃣ Count ways via recursive calls for take_one & take_zero

3️⃣ Return addOne + take_one + take_zero (total ways)
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 59) ✅ Count Vowel Strings in Ranges 💡 Approach (Prefix Sum) 1️⃣ Count words starting & ending with vowels, storing cumulative counts 2️⃣ For each query, use pf_sum[r] - pf_sum[l-1] formula 3️⃣ Store results for all queries

🚀 #LeetCode POTD (Day 59) ✅

Count Vowel Strings in Ranges

💡 Approach (Prefix Sum)

1️⃣ Count words starting & ending with vowels, storing cumulative counts
2️⃣ For each query, use pf_sum[r] - pf_sum[l-1] formula
3️⃣ Store results for all queries
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 61) ✅ 💡 Approach (Set + Two Pointers) 1️⃣ Identify first & last occurrence of each character. 2️⃣ Collect unique middle characters for valid ranges. 3️⃣ Return the count of unique palindromic subsequences.

🚀 #LeetCode POTD (Day 61) ✅

💡 Approach (Set + Two Pointers)

1️⃣ Identify first & last occurrence of each character.
2️⃣ Collect unique middle characters for valid ranges.
3️⃣ Return the count of unique palindromic subsequences.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 62) ✅ Shifting Letters II 💡 Approach (Difference Array Pattern) 1️⃣ Build difference array for range shifts. 2️⃣ Compute cumulative shifts with prefix sum. 3️⃣ Apply mod 26 to handle shifts (negative/large), wrapping 'a' to 'z' accordingly.

🚀 #LeetCode POTD (Day 62) ✅

 Shifting Letters II

💡 Approach (Difference Array Pattern)

1️⃣ Build difference array for range shifts.
2️⃣ Compute cumulative shifts with prefix sum.
3️⃣ Apply mod 26 to handle shifts (negative/large), wrapping 'a' to 'z' accordingly.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 65) ✅ 💡 Approach (Brute Force) 1️⃣ For each word pair (i, j) where i < j, check if the first word is both a prefix and suffix of the second. 2️⃣ Use find and rfind to verify prefix-suffix match. 3️⃣ Count and return total valid pairs.

🚀 #LeetCode POTD (Day 65) ✅

💡 Approach (Brute Force)

1️⃣ For each word pair (i, j) where i &lt; j, check if the first word is both a prefix and suffix of the second.

2️⃣ Use find and rfind to verify prefix-suffix match.

3️⃣ Count and return total valid pairs.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 66) ✅ Counting Words With a Given Prefix 💡 Approach (String Matching) 1️⃣ Loop through the words, check if each starts with the prefix using starts_with(). 2️⃣ Increment a counter for each match and return the total.

🚀 #LeetCode POTD (Day 66) ✅

Counting Words With a Given Prefix

💡 Approach (String Matching)

1️⃣ Loop through the words, check if each starts with the prefix using starts_with().

2️⃣ Increment a counter for each match and return the total.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 72) ✅ 💡 Approach (Bit Manipulation) 1️⃣ Count set bits in num1 & num2 using __builtin_popcount(). 2️⃣ If num1 has fewer set bits, turn on unset bits from LSB. 3️⃣ If num1 has more set bits, turn off set bits from LSB.

🚀 #LeetCode POTD (Day 72) ✅

💡 Approach (Bit Manipulation)

1️⃣ Count set bits in num1 &amp; num2 using __builtin_popcount().

2️⃣ If num1 has fewer set bits, turn on unset bits from LSB.

3️⃣ If num1 has more set bits, turn off set bits from LSB.
DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 73) ✅ 💡 Approach (Bit Manipulation) 1️⃣ Elements with even frequency cancel out: x ^ x = 0 2️⃣ If nums1.size() is odd, XOR all elements of nums2. 3️⃣ If nums2.size() is odd, XOR all elements of nums1. 4️⃣ Return the final XOR result.

🚀 #LeetCode POTD (Day 73) ✅

💡 Approach (Bit Manipulation)

1️⃣ Elements with even frequency cancel out: x ^ x = 0
2️⃣ If nums1.size() is odd, XOR all elements of nums2.
3️⃣ If nums2.size() is odd, XOR all elements of nums1.
4️⃣ Return the final XOR result.
Arindam Majumder 𝕏 (@arindam_1729) 's Twitter Profile Photo

You don't need to know everything to be a developer. You need just enough knowledge to ask the right questions and make meaningful progress.

DevVortex (@dev_vortex_) 's Twitter Profile Photo

🚀 #LeetCode POTD (Day 74) ✅ 💡 Approach (Bit Manipulation) : 1️⃣ In a circular XOR, original[0] repeats twice, so XOR of all derived must be 0. 2️⃣ Compute XOR of all derived elements. 3️⃣ Return true if XOR == 0, else false.

🚀 #LeetCode POTD (Day 74) ✅

💡 Approach (Bit Manipulation) :

1️⃣ In a circular XOR, original[0] repeats twice, so XOR of all derived must be 0.
2️⃣ Compute XOR of all derived elements.
3️⃣ Return true if XOR == 0, else false.