🚀 Day 15 / 85 Days of DSA Challenge Today’s problem was about applying range-based updates with a twist — stepping through the array using a custom interval (k) and applying modular multiplication. 💡 Key Learnings: Handling queries with non-contiguous updates (i += k pattern) Importance of modulo arithmetic to prevent overflow Final aggregation using bitwise XOR 🔍 Approach: For each query [l, r, k, v]: Start from index l Jump k steps each time Multiply elements by v (mod 1e9+7) Finally, compute XOR of the modified array. ⚡ This problem highlights how brute-force works but may need optimization for large constraints. Consistency > Perfection 💯 85 Days Challenge — Let’s go! 🔥 #DSA #CodingChallenge #Java #ProblemSolving #100DaysOfCode #LearningJourney
Range-Based Updates with Custom Interval and Modular Multiplication
More Relevant Posts
-
🚀 Day 128/500 – DSA LeetCode Challenge Today I solved problems focused on circular arrays and greedy logic. ✅ Closest Target in Circular Array – Used linear scan + circular distance calculation to find the minimum steps. TC: O(n) | SC: O(1) ✅ Partitioning Into Minimum Number of Deci-Binary Numbers – Applied a greedy observation that the answer is the maximum digit in the string. TC: O(n) | SC: O(1) 💡 Key Learning: Sometimes the best solution comes from identifying the core mathematical insight, not complex logic. 👉 Day 128/500 #DSA #Java #500DaysChallenge #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
Day 3 / 75 – DSA Challenge Solved “Longest Substring Without Repeating Characters” using the Sliding Window technique. Optimized the solution to achieve: • Time Complexity: O(n) • Space Complexity: O(1) (fixed-size frequency array) Focused on improving window management logic and reducing unnecessary computations. The solution was accepted with strong runtime and memory performance. Consistent progress, one problem at a time. #75DaysOfDSA #DataStructures #Algorithms #Java #ProblemSolving #LeetCode
To view or add a comment, sign in
-
-
Solved the Binary Tree Level Order Traversal problem using a BFS (Queue) approach. The idea is to traverse the tree level by level using a queue. For each level, we process all nodes currently in the queue and add their children for the next level. This ensures nodes are grouped level-wise in the result. Time Complexity: O(n) Space Complexity: O(n) #Java #DSA #Tree #BFS #LeetCode #Coding
To view or add a comment, sign in
-
-
Day 84 of My DSA Journey Today’s problem: Counting Bits Given a number n, the task is to return an array where each index i contains the number of 1’s in the binary representation of i. 🔍 Example: Input: n = 5 Output: [0, 1, 1, 2, 1, 2] 💡 Key Insight: Instead of counting bits every time, we reuse previous results: i >> 1 → removes last bit i & 1 → checks if last bit is 1 So, 👉 ans[i] = ans[i >> 1] + (i & 1) ⚡ This reduces time complexity to O(n) (single pass!) 📈 What I learned today: Dynamic Programming can simplify repeated computations Bit manipulation makes problems faster and cleaner Small patterns can lead to big optimizations #Day84 #DSA #Java #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 48 of Daily DSA 🚀 Solved LeetCode 48: Rotate Image ✅ Problem: Given an n x n matrix, rotate the image by 90° clockwise — in-place (without using extra space). Approach: Used a two-step transformation: Transpose the matrix Reverse each row Steps: Traverse upper triangle and swap → matrix[i][j] ↔ matrix[j][i] For each row: Use two pointers (left, right) Swap elements to reverse the row Matrix gets rotated in-place ⏱ Complexity: • Time: O(n²) • Space: O(1) 📊 LeetCode Stats: • Runtime: 0 ms (Beats 100%) ⚡ • Memory: 43.56 MB In-place transformations are powerful — no extra space, just smart manipulation 💡 #DSA #LeetCode #Java #Matrix #Arrays #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🔥 DSA Challenge – Day 136/360 🚀 📌 Topic: Bit Manipulation 🧩 Problem: Number of 1 Bits (Hamming Weight) Problem Statement: Given an integer, return the number of set bits (1’s) present in its binary representation. 🔍 Example: Input: 6 Output: 2 Explanation: Binary of 6 → 110 → 2 set bits 💡 Optimized Approach (Brian Kernighan’s Algorithm): Instead of checking each bit one by one, we use a smart trick: n & (n - 1) removes the rightmost set bit in each iteration This reduces the number of operations to the number of set bits only ⚡ Time Complexity: O(k) (k = number of set bits) ⚡ Space Complexity: O(1) 🚀 Key Takeaway: Using bit manipulation can drastically optimize performance compared to brute force approaches. Always look for patterns in binary operations! #DSA #Coding #Java #BitManipulation #136DaysOfCode #LeetCode #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
Day 109: Vector Vibes & C++ Logic 🚀 Problem 1855: Maximum Distance Between a Pair of Values Ported my Java logic to C++ today because performance is the goal. Switching languages is basically just remapping your brain's "how to get the length" function to .size(). The Strategy: • Two-Pointer Efficiency: Used two pointers to find the max gap in O(N+M) time. No nested loops, just speed. • The Logic: If nums1[i]≤nums2[j], I track the distance and move j; otherwise, I move i. • C++ Pivot: Getting comfortable with std::vector and the STL. It's all about that low-level control for the HPC path. The transition is officially in motion. Day 109—we're evolving. ⚡ #LeetCode #Cpp #TwoPointers #HPC #DailyCode
To view or add a comment, sign in
-
-
75 Days of DSA – Day 2 Solved: Trapping Rain Water Approach: Two Pointers Time: O(n) | Space: O(1) Implemented an optimized solution by maintaining leftMax and rightMax to eliminate extra space and achieve linear time complexity. 324 / 324 test cases passed Runtime: 0 ms (100th percentile) Focused on improving problem-solving depth and writing optimal solutions consistently. #DSA #Algorithms #Java #ProblemSolving
To view or add a comment, sign in
-
-
Day 63/75 — Rotate Array Today’s problem was about rotating an array to the right by k steps. Approach: • Use reversal algorithm for optimal in-place rotation • Reverse entire array • Reverse first k elements • Reverse remaining elements Key logic: k = k % n; reverse(nums, 0, n - 1); reverse(nums, 0, k - 1); reverse(nums, k, n - 1); Time Complexity: O(n) Space Complexity: O(1) A classic array problem that reinforces in-place manipulation techniques. 63/75 🚀 #Day63 #DSA #Arrays #InPlace #Java #Algorithms #LeetCode
To view or add a comment, sign in
-
-
Day 70 of My DSA Journey Problem: Linked List Cycle (LeetCode 141) Today’s problem was all about detecting whether a linked list contains a cycle — a classic and very important concept in data structures. Key Idea: Floyd’s Cycle Detection Algorithm (Tortoise & Hare) Instead of using extra memory, we use two pointers: • Slow pointer → moves 1 step • Fast pointer → moves 2 steps If there’s a cycle, these two pointers will eventually meet. If not, the fast pointer will reach the end (null). Insight: This approach is efficient because it avoids using extra space like a HashSet and still guarantees detection in linear time. Complexity: • Time: O(n) • Space: O(1) What I learned: Sometimes, the smartest solutions don’t require extra space — just a clever observation and pointer manipulation! Consistency > Perfection 💯 On to Day 71 🚀 #DSA #100DaysOfCode #Java #CodingJourney #ProblemSolving #LinkedList
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development