Day 45/100 | #100DaysOfDSA 🚀🧩 Today’s problem: Remove All Occurrences of a Substring The task is simple: Given a string s and a substring part, keep removing the leftmost occurrence of part until it no longer exists in s. Approach: • Use StringBuilder for efficient modifications • Find the index of part using indexOf() • Delete that portion from the string • Repeat the process until part is no longer found Time Complexity: O(n × k) in worst case (where n is length of string and k is length of substring) Big takeaway: Sometimes the easiest solution is just repeating a simple operation until the condition disappears. Clean string manipulation problem today. 🔥 Day 45 done. #100DaysOfCode #LeetCode #DSA #Algorithms #Java #String #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
Yogesh ..’s Post
More Relevant Posts
-
💡 LeetCode 191 — Number of 1 Bits (Hamming Weight) Recently solved an interesting bit manipulation problem that highlights the power of low-level optimization 🚀 🔍 Problem Statement: Given an unsigned integer, count the number of set bits (1s) in its binary representation. 🧠 Key Insight: Instead of checking every bit individually, we can use a clever trick: 👉 n & (n - 1) removes the rightmost set bit in each operation. This allows us to count only the set bits, making the solution more efficient. ⚙️ Approach Used (Brian Kernighan’s Algorithm): Initialize a counter Repeatedly apply n = n & (n - 1) Increment count until n becomes 0 📈 Time Complexity: O(k), where k = number of set bits (faster than checking all 32 bits) 📦 Space Complexity: O(1) ✨ Why this problem is important: Strengthens understanding of bit manipulation Frequently asked in interviews Useful in low-level optimization and system design 💬 Takeaway: Sometimes the best solutions come from understanding how data is represented at the binary level. Small tricks can lead to big optimizations! #LeetCode #DSA #CodingInterview #Java #BitManipulation #ProblemSolving #TechJourney
To view or add a comment, sign in
-
-
Day 100/100 – LeetCode Challenge ✅ Problem: #41 First Missing Positive Difficulty: Hard Language: Java Approach: In-Place Index Marking Time Complexity: O(n) Space Complexity: O(1) Key Insight: Place each positive integer in its correct position (index i should contain i+1). Mark presence using negative values without extra space. Solution Brief: First pass: replace numbers outside range [1, n] with n+1 (ignore them) Second pass: treat each number as index, mark that index negative Third pass: first positive index = missing number If all marked, answer is n+1 #LeetCode #Day100 #100DaysOfCode #Array #Java #Algorithm #CodingChallenge #ProblemSolving #FirstMissingPositive #HardProblem #InPlace #Optimization #DSA
To view or add a comment, sign in
-
-
Solved a matrix problem : checking whether one matrix can be obtained from another using rotations. At first it looked a bit tricky, but the key idea was simple: 👉 A 90° rotation can be done using transpose + reverse each row This makes the solution clean and efficient (O(n²)) and is a useful pattern to remember for similar problems. #DataStructures #Algorithms #DSA #Java #LeetCode #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 60/100 📌 Problem: String to Integer Given a string, convert it into a 32-bit signed integer while: • Ignoring leading whitespaces • Handling '+' and '-' signs • Reading digits until a non-digit appears • Returning INT_MAX or INT_MIN in case of overflow 💡 What I Learned: • Importance of handling edge cases • How to safely manage overflow • Writing clean and efficient parsing logic ⚡ Result: Runtime 1 ms (Beats 100%) Consistency + Practice = Improvement 📈 #Day60 #Java #DSA #LeetCode #CodingJourney #ProblemSolving #100DaysOfCode #LearnToCode
To view or add a comment, sign in
-
-
Day 35/75 — Generate Parentheses (Backtracking) Today’s problem was about generating all valid combinations of parentheses. Instead of brute force, I used backtracking with constraints. Key conditions: • Add '(' if open < n • Add ')' if close < open Base case: if (open == n && close == n) This ensures only valid sequences are generated. Time Complexity: ~ O(2ⁿ) Space Complexity: O(n) This problem helped strengthen my understanding of recursive decision trees. 35/75 🚀 #Day35 #DSA #Backtracking #Java #Algorithms #LeetCode
To view or add a comment, sign in
-
-
Day 59/100 | #100DaysOfDSA 🔍⚡ Today’s problem: Single Element in a Sorted Array A clever Binary Search problem with a twist. Key observation: In a sorted array where every element appears twice except one, pairs follow a pattern. Before the single element: • First occurrence → even index • Second occurrence → odd index After the single element: • Pattern breaks Approach: • Use binary search • Check mid with its pair using index trick (mid ^ 1) • If nums[mid] == nums[mid ^ 1] → move right • Else → move left This helps pinpoint where the pattern breaks. Time Complexity: O(log n) Space Complexity: O(1) Big takeaway: Bit manipulation + pattern observation can simplify binary search problems significantly. Small tricks → big optimizations. 🔥 Day 59 done. #100DaysOfCode #LeetCode #DSA #Algorithms #BinarySearch #BitManipulation #Arrays #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
To view or add a comment, sign in
-
-
Day 69/100 | #100DaysOfDSA 🧩🚀 Today’s problem: Reverse Nodes in k-Group A challenging linked list problem focused on reversing nodes in fixed-size groups. Problem idea: Reverse nodes of a linked list in groups of size k, while keeping remaining nodes as it is. Key idea: Linked list manipulation + iterative reversal in segments. Why? • We need to reverse nodes in chunks, not the whole list • Careful pointer handling is required • Must preserve connections between groups How it works: • Use a dummy node for easier handling of head • Identify the k-th node from current position • Reverse nodes between current and k-th node • Connect reversed group back to the list • Move to next group and repeat • Stop if remaining nodes are less than k Time Complexity: O(n) Space Complexity: O(1) Big takeaway: Mastering pointer manipulation in linked lists is key to solving advanced problems efficiently. This problem is a great example of combining reversal logic with structural control. 🔥 Day 69 done. 🚀 #100DaysOfCode #LeetCode #DSA #Algorithms #LinkedList #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
To view or add a comment, sign in
-
-
Day 63/100 🚀 | #100DaysOfDSA Solved LeetCode 205 – Isomorphic Strings today. The task was to determine if two strings are isomorphic, meaning each character in one string can be replaced to get the other string, maintaining order and uniqueness. Approach: Used two HashMaps to ensure a one-to-one mapping between characters of s and t. • Checked if lengths are equal; if not, return false. • Iterated through both strings simultaneously. • For each character pair (c1, c2): Checked if c1 is already mapped to another character in t. Checked if c2 is already mapped to another character in s. If any mapping violates the isomorphic condition, returned false. • If iteration completes without conflicts, returned true. Time Complexity: O(n) Space Complexity: O(n) Key takeaway: When checking bijective mappings between two sets, always validate both directions to avoid false positives. #100DaysOfDSA #LeetCode #DSA #Java #Strings #HashMap #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🚀 Day 8 of #100DaysOfDSA Today’s problem: Longest Substring Without Repeating Characters 🧠 Problem Statement: Given a string, find the length of the longest substring without repeating characters. 💡 Approach: Sliding Window Technique Used two pointers (left & right) Maintained a HashSet to track characters Expanded window when unique Shrunk window when duplicate found ⚡ Key Learning: Efficient use of the sliding window helps reduce time complexity to O(n), which is crucial for optimizing string-based problems. 💻 Example: Input: "abcabcbb" Output: 3 ("abc") 🔥 This problem strengthened my understanding of: ✔️ Two-pointer technique ✔️ Hashing (Set/Map) ✔️ Optimizing brute force solutions Consistency is the key — small steps every day lead to big results 💪 #DSA #Java #CodingJourney #LeetCode #ProblemSolving #100DaysOfCode 🍁 Saidhanya Sree
To view or add a comment, sign in
-
-
📘 DSA Journey — Day 30 Today’s focus: HashMap for frequency counting. Problem solved: • Number of Good Pairs (LeetCode 1512) Concepts used: • HashMap • Frequency counting • Incremental counting technique Key takeaway: The goal is to count pairs (i, j) such that nums[i] == nums[j] and i < j. Instead of checking all pairs (which would take O(n²)), we use a HashMap to track frequencies. As we iterate through the array: • For each number, we check how many times it has already appeared • That count directly contributes to the number of valid pairs • Then we update its frequency in the map This allows counting pairs in a single pass with O(n) time complexity. Continuing to strengthen fundamentals and consistency in problem solving. #DSA #Java #LeetCode #CodingJourney
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