✅ Day 89 of 100 Days LeetCode Challenge Problem: 🔹 #1480 – Running Sum of 1D Array 🔗 https://lnkd.in/gSTZrxF7 Learning Journey: 🔹 Today’s problem focused on computing the running (prefix) sum of an array. 🔹 Instead of using an extra array, I optimized the solution by modifying the input array in-place. 🔹 Starting from index 1, I updated each element as: • nums[i] += nums[i-1] 🔹 This way, each index stores the cumulative sum up to that point. 🔹 Finally, returned the modified array. Concepts Used: 🔹 Prefix Sum 🔹 In-place Computation 🔹 Array Traversal Key Insight: 🔹 The previous element already stores the prefix sum, so we can reuse it directly. 🔹 Eliminates the need for extra space while maintaining linear time. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
LeetCode Challenge: Prefix Sum Optimization
More Relevant Posts
-
✅ Day 95 of 100 Days LeetCode Challenge Problem: 🔹 #869 – Reordered Power of 2 🔗 https://lnkd.in/gkNXaSFM Learning Journey: 🔹 Today’s problem focused on checking whether the digits of a number can be rearranged to form a power of 2. 🔹 I created a helper function to extract and store the digits of a number. 🔹 Then I sorted the digits of the input number for comparison. 🔹 Next, I generated powers of 2 iteratively and compared their sorted digit lists with the input. 🔹 If any match was found, I returned True. Otherwise, continued until the digit length exceeded the input. Concepts Used: 🔹 Digit Extraction 🔹 Sorting 🔹 Simulation of Powers of 2 🔹 Brute Force Optimization Key Insight: 🔹 Instead of generating permutations (which is expensive), sorting digits allows quick comparison. 🔹 Any valid rearrangement must have the same digit frequency as some power of 2. Complexity: 🔹 Time: O(log n * d log d) 🔹 Space: O(d) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
Day 56 of #GeekStreak60: The Phantom Pointer Trick! 🕵️♂️📈 Tackled the "Sorted subsequence of size 3" problem on @GeeksforGeeks today. Key Learning: Finding an increasing triplet is easy if you use extra arrays to track minimums and maximums, but that violates the O(1) space constraint. The optimal solution is to use "Greedy State Tracking." By iterating through the array in a single pass, I maintained three variables: the absolute smallest number seen (num1), a valid middle number (num2), and a snapshot of num1 locked in at the exact moment num2 was discovered. If the loop encounters any number strictly greater than num2, the valid triplet is instantly formed! This perfectly eliminates the need for O(n) memory arrays while keeping the time complexity to a strict O(n). Just 4 days left! The logic is feeling sharper than ever. 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #Optimization #SoftwareEngineering
To view or add a comment, sign in
-
-
✅ Day 98 of 100 Days LeetCode Challenge Problem: 🔹 #338 – Counting Bits 🔗 https://lnkd.in/gXdNxX66 Learning Journey: 🔹 Today’s problem focused on counting the number of 1s in the binary representation of numbers from 0 to n. 🔹 I initialized an array ans of size n+1. 🔹 For each number i, I converted it to binary using bin(i)[2:]. 🔹 Counted the number of '1' bits by iterating through the binary string. 🔹 Stored the count in ans[i] and returned the final array. Concepts Used: 🔹 Bit Manipulation (Binary Representation) 🔹 Array Traversal 🔹 String Processing 🔹 Brute Force Approach Key Insight: 🔹 Each number’s bit count can be computed independently. 🔹 Converting to binary and counting '1' works, but can be optimized further using DP or bit tricks. Complexity: 🔹 Time: O(n log n) (binary conversion for each number) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #100DaysOfCode #Python #CodingJourney #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
Day 47 of #GeekStreak60: The Binary State Machine! 0️⃣1️⃣ Tackled the "Consecutive 1's not allowed" problem on @GeeksforGeeks today. Key Learning: Counting valid combinations often looks like a backtracking problem, which leads to an O(2^n) time trap. By analyzing the strict rules of binary generation, I modeled the problem as a Finite State Machine. Because a 1 can only follow a 0, but a 0 can follow anything, I simply tracked the counts of strings ending in each digit iteratively. This completely eliminated the need to generate the strings themselves, dropping the time complexity to a highly efficient O(n) and the auxiliary space down to a perfect O(1)! (Fun fact: This strict state transition actually generates the Fibonacci sequence under the hood!) Less than two weeks left in the 60-day sprint! 🚀 #geekstreak60 #npci #coding #Algorithms #Python #DataStructures #DynamicProgramming #StateMachines #Optimization
To view or add a comment, sign in
-
-
A 10 million document RAG dataset occupies 31 GB of RAM at float32. turbovec fits it in just 4 GB - and now it searches it faster than FAISS. I just shipped a new release of turbovec: a Rust vector index with Python bindings, built on Google Research's TurboQuant algorithm. Data-oblivious 2-4 bit quantization that matches the Shannon lower bound on distortion - zero training and no rebuilds when the corpus grows. What's in the box: → Hand-written SIMD kernels - 12–20% faster than FAISS FastScan on ARM; match-or-beat on x86. → O(1) stable-id delete and save/load. The corpus is live and mutable, not a static snapshot. → Drop-in integrations for LangChain, LlamaIndex, and Haystack. → Published benchmarks (recall, speed, compression) at d=200/1536/3072 — every number reproducible from the repo. If you're building RAG where memory, latency, or privacy matters, give it a spin. GitHub: https://lnkd.in/e5M4dVRk Paper: https://lnkd.in/eHRmpYms #RAG #VectorSearch #OpenSource #Rust #Python #𝗟𝗟𝗠 #𝗢𝗽𝗲𝗻𝗦𝗼𝘂𝗿𝗰𝗲 #𝗚𝗲𝗺𝗺𝗮4
To view or add a comment, sign in
-
-
The Magic of the Mirror: Image Flipping with NumPy! 🤳🔄 Day 85/100 Ever wondered how your phone 'mirrors' your selfies instantly? It’s just one line of array slicing! For Day 85 of my #100DaysOfCode, I explored Image Flipping and Mirroring. In the world of Computer Vision, an image is just a matrix, and to flip it, we simply reverse the order in which we read the rows or columns. Technical Highlights: 🔄 Axis Reversal: Mastering the [::-1] slicing syntax to reverse array indices without complex loops. 🤳 Mirror Logic: Implementing horizontal flips to simulate the front-camera 'selfie' experience. 🌊 Vertical Reflection: Creating water surface reflection effects by reversing the row order of 2D matrices. 🤖 AI Data Augmentation: Learning how flipping images is used in Machine Learning to double the size of training datasets and prevent model bias. Do check my GitHub repository here : https://lnkd.in/d9Yi9ZsC #100DaysOfCode #ComputerVision #NumPy #Python #BTech #IILM #AIML #ImageProcessing #DataAugmentation #SoftwareEngineering #LearningInPublic #WomenInTech
To view or add a comment, sign in
-
-
✅ Day 97 of 100 Days LeetCode Challenge Problem: 🔹 #1281 – Subtract the Product and Sum of Digits of an Integer 🔗 https://lnkd.in/gxTAZc6U Learning Journey: 🔹 Today’s problem involved extracting digits of a number and performing two operations simultaneously. 🔹 I initialized two variables: one for product (pr) and one for sum (sm). 🔹 Using a while loop, I extracted each digit using n % 10. 🔹 Updated the product by multiplying the digit and updated the sum by adding it. 🔹 Reduced the number using integer division (n //= 10) after each step. 🔹 Finally returned the difference between product and sum. Concepts Used: 🔹 Digit Extraction 🔹 While Loop 🔹 Arithmetic Operations 🔹 Number Manipulation Key Insight: 🔹 Both product and sum can be computed in a single traversal of digits. 🔹 Efficient use of modulus and division avoids converting the number to a string. Complexity: 🔹 Time: O(d) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
🗓 7 April 2026 LeetCode Problem #128 – Longest Consecutive Sequence Solved the problem of finding the longest consecutive sequence in an unsorted array. Key insight: use a set for O(1) lookups and only start counting sequences from numbers that are the beginning of a sequence. Takeaways: - Using the right data structure reduces time complexity from O(n²) to O(n). - Avoid redundant work while scanning arrays. - Handle edge cases like empty or single-element arrays efficiently. This problem reinforces how a smart approach beats brute force every time! #LeetCode #Algorithms #Python #DataStructures #ProblemSolving #Coding #TechLearning
To view or add a comment, sign in
-
-
🚀 Day 39/60 — LeetCode Discipline Problem Solved: Sqrt(x) Difficulty: Easy Today’s challenge was to compute the square root of a number without using built-in functions. Instead of brute force, I used Binary Search — a classic, elegant approach that narrows down the answer efficiently. 💡 Key Learnings: • Binary Search application beyond arrays • Handling edge cases (x < 2) • Avoiding overflow using conditions carefully • Finding floor value of square root • Optimized thinking over brute force ⚡ Performance: Runtime: 4 ms Like walking in a foggy path, I didn’t see the answer directly… But step by step— cutting the search space in half— the truth revealed itself. That’s the beauty of algorithms. #LeetCode #60DaysOfCode #DSA #BinarySearch #ProblemSolving #CodingJourney #Python #Consistency #TechGrowth
To view or add a comment, sign in
-
-
Your dataset has 500 features. Your model only needs 20. The other 480 are noise, redundancy, or both — slowing down training and hurting accuracy. We broke down the 3 algorithms you actually need: Slide 1: PCA — linear, interpretable, fast. Your default. Slide 2: t-SNE — nonlinear, beautiful for visualization, slow on large data Slide 3: UMAP — modern, 10x faster than t-SNE, preserves local + global structure Slide 4: When to use which (decision tree with 4 questions) Slide 5: The common trap: t-SNE axes are NOT features. You can't use them as inputs to a model. Slide 6: Free notebook with all 3 on the same dataset — see the differences yourself Free notebook with side-by-side code for all three: https://lnkd.in/gcbS7m-m If you've been using PCA as a black box, this upgrades you. #MachineLearning #DataScience #PCA #UMAP #DimensionalityReduction #UnsupervisedLearning #Python #Sklearn
To view or add a comment, sign in
Explore related topics
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