🌻Day 56 LeetCode: Number of Ways to Split Array (2270) Approach: Calculated prefix sums to efficiently determine valid split points where the left sum is greater than or equal to the right sum. ✨ Learned how prefix sums simplify cumulative comparison problems and help avoid repeated summations — boosting both logic and efficiency! 📈 Improved understanding of prefix arrays, cumulative sums, and linear-time array traversal in C++. #LeetCode #100DaysOfCode #DSA #Arrays #PrefixSum #ProblemSolving #CodingJourney #CodeEveryday
"Day 56: LeetCode 2270 - Prefix Sums for Efficient Array Splitting"
More Relevant Posts
-
✨Day 67 LeetCode: Letter Combinations of a Phone Number (17) Approach: Used backtracking to generate all possible letter combinations mapped from digits, following the classic phone keypad pattern. ✨ Learned how recursion and backtracking can explore all possible paths efficiently — a great exercise in mapping and combinatorial logic! 📈 Improved understanding of recursion, string building, and backtracking patterns in C++. #LeetCode #100DaysOfCode #DSA #Backtracking #Strings #ProblemSolving #CodingJourney #CodeEveryday
To view or add a comment, sign in
-
-
It's easy to check if "racecar" is a palindrome, but can your code handle "A man, a plan, a canal: Panama" gracefully? This simple-looking problem is a fantastic test of string pre-processing, data normalization, and C++ STL skills! My solution has an O(N) space complexity because it creates a new clean_s string. Challenge: How would you rewrite this function using the Two-Pointer technique to achieve O(1) extra space complexity? #CPP #CodingChallenge #ProblemSolving #StringManipulation #STL #SoftwareDevelopment #TechInterviewPrep
To view or add a comment, sign in
-
-
🌿Day 73 LeetCode: Next Greater Element I (496) Approach: Used a stack to find the next greater element for each number in nums2 and stored results in a hash map for quick lookup in nums1. ✨ Learned how to use monotonic stacks for next-greater problems — a smart way to reduce time complexity and strengthen logic! 📈 Improved understanding of stacks, hash maps, and element mapping techniques in C++. #LeetCode #100DaysOfCode #DSA #Stack #HashMap #Arrays #ProblemSolving #CodingJourney #CodeEveryday
To view or add a comment, sign in
-
-
🌿Day 55 LeetCode: Daily Temperatures (739) Approach: Used a stack to keep track of indices of unresolved temperatures. Traversed the array and calculated the number of days until a warmer temperature efficiently. ✨ Learned how to use monotonic stacks for next-greater-element problems — a great exercise in optimizing brute-force solutions! 📈 Improved understanding of stacks, array traversal, and problem-solving patterns in C++. #LeetCode #100DaysOfCode #DSA #Arrays #Stack #ProblemSolving #CodingJourney #CodeEveryday
To view or add a comment, sign in
-
-
#leetcode #14 #You are given the heads of two sorted linked lists list1 and list2. Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2 = [0] Output: [0]
To view or add a comment, sign in
-
-
🎯 LeetCode Daily – Partition Equal Subset Sum (Day 119) Today I revisited one of the classic Dynamic Programming problems - Partition Equal Subset Sum, and focused on space optimization techniques. ✅ My Approach: • The goal is to determine if an array can be split into two subsets with equal sum. • After calculating the total sum, I reduced the problem to a Subset Sum check using DP. • Initially implemented it with a 2D DP table, but today I optimized it to use just two 1D arrays (prev and curr) - cutting space complexity from O(N × Target) to O(Target). • Each element’s inclusion/exclusion decision depends only on the previous row’s state. 🧠 Key Insight: Space optimization in DP is all about recognizing dependency patterns - when a solution relies only on the previous computation, we can safely compress dimensions without losing correctness. 📊 Time Complexity: O(N × Target) 📦 Space Complexity: O(Target) #LeetCode #DSA #DynamicProgramming #ProblemSolving #Optimization #DailyCoding #LearningInPublic #Day119
To view or add a comment, sign in
-
-
🔹 19th Problem – Remove Nth Node From End of List Difficulty: Medium 📘 Problem: Given the head of a linked list, the task is to remove the n-th node from the end of the list and return its head. Example: Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5] 💡 Algorithm Used – Two Pointer (One-Pass) Approach: To solve this efficiently, I used the two-pointer technique. Create a dummy node before the head to handle edge cases easily. Move the first pointer n + 1 steps ahead to create a gap of n nodes. Move both pointers together until the first reaches the end. The second pointer will now be just before the node that needs to be removed. Adjust the links to remove the target node. ⏱️ Time Complexity: O(L) (We traverse the list only once.) 💾 Space Complexity: O(1) (Constant extra space used.) 🚀 Day 19 of my #120DaysLeetCodeChallenge completed! This problem helped me strengthen my understanding of linked list traversal and efficient pointer manipulation in C++. #LeetCode #DSA #CodingChallenge #TwoPointer #LinkedList #CPlusPlus #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🌿Day 52 LeetCode: Valid Sudoku (36) Approach: Used hash sets to track numbers appearing in each row, column, and 3×3 sub-box while validating the board. ✨ Learned how to handle 2D grids efficiently and apply set-based validation for constraints checking! 📈 Strengthened logical reasoning and improved understanding of hash sets and matrix traversal in C++. #LeetCode #100DaysOfCode #DSA #HashSet #Matrix #ProblemSolving #CodingJourney #LogicBuilding
To view or add a comment, sign in
-
-
✅ Day 42 | LeetCode | Remove Element Today’s challenge was about removing all occurrences of a given value from an array in-place and without using extra space. Approach: 1️⃣ Used the two-pointer technique one pointer iterates through the array, while the other (k) keeps track of the next valid (non-val) position. 2️⃣ Whenever the current element is not equal to val, I move it to index k and increment k. 3️⃣ After the loop, the first k elements represent the new array without the unwanted values. Learned how efficiently the two-pointer method can be applied for in-place array modification clean, simple, and O(n) time complexity! #Day42 #LeetCode #DSA #CPlusPlus #ProblemSolving #100DaysOfCode #CodingChallenge
To view or add a comment, sign in
-
-
🌿Day 71 LeetCode: Remove Nth Node From End of List (19) Approach: Used the two-pointer technique — moved one pointer n steps ahead, then traversed both to locate and remove the target node efficiently. ✨ Learned how the two-pointer approach simplifies linked list problems and improves traversal logic! 📈 Improved understanding of pointer manipulation, edge case handling, and linked list traversal in C++. #LeetCode #100DaysOfCode #DSA #LinkedList #TwoPointers #ProblemSolving #CodingJourney #CodeEveryday
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