🚀 [Day 15/30] Coding Challenge Journey with @Educative.io 💻 💡 Problem: Similar String Groups Today’s problem was all about identifying relationships between strings and grouping them based on their “similarity.” Two strings are considered similar if they differ in exactly two character positions — meaning you can swap those characters to transform one into the other. My intuition started with this core idea: 👉 If two strings differ by exactly two positions, they belong to the same group. To solve this, I approached the problem like a graph traversal challenge: 1️⃣ Consider each string as a node in a graph. 2️⃣ Create an edge between two nodes if the strings differ by exactly two characters. 3️⃣ Use DFS to explore all connected strings that form a similarity group. 4️⃣ Maintain a visited array to ensure each string is processed once. So for each unvisited string, I triggered a DFS call. That DFS marked all strings connected to it (all strings that were similar by 2-character difference). This naturally formed groups of similar strings — each connected component counted as one group. This problem beautifully reinforced how string similarity + graph connectivity can come together to form a clean and efficient solution 🧠✨ 🔍 Key Learnings: Many string problems hide an underlying graph structure — discovering it is half the solution. DFS is extremely powerful for grouping, clustering, and connectivity problems. A simple rule (differ by 2 characters) can create surprisingly complex group relationships. ✨ Small win — once I mapped the problem to graph traversal instead of brute-force comparisons, everything became much more intuitive! #30DaysOfCode #Day15 #CodingChallenge #Educative #DSA #GraphTheory #DFS #JavaScript #ProblemSolving #StringAlgorithms #LearningJourney #KeepCoding
"Day 15: Solving Similar String Groups with DFS and Graph Theory"
More Relevant Posts
-
🚀 Day 30 of My COHORT 2.0 Development Journey Sheryians Coding School Topic: Operators in JS Today’s class focused on one of the most important foundations of JavaScript: Operators. Operators help us perform calculations, assign values, compare data, and write logical conditions - basically the backbone of any program. Here’s what we covered: 🔢 1️⃣ Arithmetic Operators Used for basic mathematical operations: + , - , * , / , % , ** These help us calculate values and perform number-based logic. 📝 2️⃣ Assignment Operators Used to assign or update variable values: = , += , -= , *= , /= , %= They make updating values shorter and cleaner. ⚖️ 3️⃣ Comparison Operators Used to compare two values: == , === , != , !== , > , < , >= , <= These return true/false and are essential for conditions, loops, and decision-making. 🔐 4️⃣ Logical Operators Used to combine multiple conditions: && (AND) || (OR) ! (NOT) These help in creating complex logical checks in real-world applications. 🧠 Key Takeaway: Operators may look simple, but they form the base of every function, condition, calculation, and logic flow in JavaScript. Today’s class helped me understand how they work behind the scenes and how to use them effectively while building real projects. #JavaScript #Cohort2 #WebDevelopment #FrontendDevelopment #CodingJourney #OperatorsInJS #LearnByDoing #SheriyansCodingSchool
To view or add a comment, sign in
-
-
🚀 [Day 10/30] Coding Challenge Journey with Educative 💡 Problem: Group Anagrams Today’s challenge was an interesting one — grouping words that are anagrams of each other. This problem pushed me to think deeply about string manipulation and hashing techniques. At first, I tried a frequency map approach — creating a character map for each string and comparing it with others. Though it worked, it wasn’t efficient (≈ O(n × k²) 😅). Then I optimized it by sorting each string and using the sorted value as a key in a hash map — grouping all strings with the same key together. This brought down the complexity to O(n × k log k) and made the logic much cleaner. Finally, I explored another variation — building a frequency-based signature for each string (like "a1b1c1") and using that as the key. This further improved the complexity to O(n × k) and avoided unnecessary sorting 🎯 🔍 Key Learnings: Choosing the right key representation is crucial for efficiency. Hash maps are powerful tools for grouping problems. Optimization is all about rethinking your data structure, not just your logic. ✨ Small win — seeing the same problem solved in 3 different ways reminded me that there’s always room to improve your first approach 💪 #30DaysOfCode #Day9 #CodingChallenge #DSA #Educative #ProblemSolving #JavaScript #HashMap #Anagrams #Optimization #KeepCoding #LearningJourney
To view or add a comment, sign in
-
🚀 [Day 16/30] Coding Challenge Journey with @Educative.io 💻 💡 Problem: Find Longest Self-Contained Substring Today’s challenge was a unique string problem — finding a substring whose characters appear only inside that substring and nowhere else in the entire string. The tricky part? The substring also cannot be the entire string itself. This wasn't a typical sliding window or two-pointer problem, so I had to rethink the approach. My thought process went like this: 1️⃣ Track global character boundaries I first stored the first and last occurrence of every character in the string. This gave me complete information about where each character “lives” inside the string. 2️⃣ Expand substrings smartly Starting from each possible beginning character, I gradually expanded the substring and checked: Do all characters in this substring stay within these boundaries? Is the substring self-contained (i.e., no character appears outside)? 3️⃣ Verify valid windows A substring becomes valid only when: It fully covers all characters within its start–end boundary It is not equal to the full string Every time this condition was satisfied, I tracked its length. This required careful boundary management — but once the logic clicked, the entire substring validation became systematic and efficient ✨ 🔍 Key Learnings: String problems often get easier when you precompute first/last occurrences. Not all problems fit sliding windows — sometimes, boundary-based expansion is the cleaner approach. A substring’s “independence” can be reasoned about using global character positions. ✨ Small win — breaking this problem down into character intervals turned a confusing condition into a clean, workable solution! #30DaysOfCode #Day16 #CodingChallenge #Educative #DSA #JavaScript #StringAlgorithms #ProblemSolving #LearningJourney #KeepCoding
To view or add a comment, sign in
-
🚀 Day 4 | 30-Day Coding Challenge – Educative.io Today’s problem: Find the single non-duplicate element in a sorted array. At first, I explored the simple O(n) approaches — 🔹 Using a Set to track duplicates (O(n) time + O(n) space) 🔹 Summing unique vs. total values and finding the difference (O(n) time) 🔹 Linear scan comparing curr and next (O(n) time, O(1) space) All worked… but the goal was O(log n) time and O(1) space. Then it clicked 💡 — since the array is sorted, every pair of equal numbers appears side-by-side. Before the unique element, pairs start at even indices; after it, they start at odd indices. Using this pattern with binary search, I halved the search space each step: if nums[mid] == nums[mid+1] → move right else move left. Every challenge so far is sharpening how I reason about patterns and constraints rather than just syntax. #Day4 #30DaysOfCode #Educative #JavaScript #BinarySearch #ProblemSolving #DSA #LearningInPublic
To view or add a comment, sign in
-
Day 31 — Operator Practice Session | 2.0 Job-Ready AI-Powered Cohort Sheryians Coding School🚀 Today was all about hands-on JavaScript operator practice — not just learning, but reinforcing by writing code 👨💻🔥 ✅ Practiced Arithmetic Operators let a = 5, b = 3; console.log(a+b, a-b, a/b, a*b); let x = 5; x += 3; x *= 3; x /= 3; ✅ Increment / Decrement let count = 5; console.log(count); count++; console.log(count); count--; // and also --count ✅ Comparison Operators 5 == "5" // true 5 === "5" // false ✅ Checking conditions: 10 > 5 10 < 20 10 === 10 ✅ Logical Operators true && false true || false !true ✅ Variable Hoisting Practice Revising fundamentals with code is helping me strengthen problem-solving and execution flow understanding 💡 #JavaScript #WebDevelopment #Frontend #PracticeMakesPerfect #SheryiansCodingSchool #LearningByDoing
To view or add a comment, sign in
-
-
🚀 [Day 12/30] Coding Challenge Journey with @Educative.io 💻 💡 Problem: Count Subarrays With Fixed Bounds Today’s challenge really tested my understanding of subarray patterns and sliding window logic. The task was to count all subarrays where the minimum and maximum values are exactly equal to given bounds — minK and maxK. At first, my approach was brute force — I generated all possible subarrays, calculated the min and max for each, and increased the count if they matched. It worked, but with a painful O(n² + n) time complexity 😅 Then came the optimization breakthrough 💡 — I introduced three variables: badIndex → to mark positions where elements go out of range minIndex and maxIndex → to store the latest positions of valid min and max For each element, if it stayed within bounds, I could efficiently calculate how many valid subarrays ended at that index by using: count += Math.max(0, Math.min(minIndex, maxIndex) - badIndex) This reduced the complexity to O(n) and turned an expensive brute force into a clean, efficient linear pass ⚡ 🔍 Key Learnings: Identifying invalid states early (like badIndex) saves massive computation. Most subarray problems can be optimized using index tracking instead of recalculating repeatedly. Optimization isn’t about writing less code — it’s about thinking one step deeper 🧠 ✨ Small win — seeing how a few well-chosen variables can simplify a seemingly complex logic! #30DaysOfCode #Day12 #CodingChallenge #DSA #Educative #ProblemSolving #JavaScript #SlidingWindow #Optimization #KeepCoding #LearningJourney #Subarrays
To view or add a comment, sign in
-
Day 33 — Loops & Conditions Practice | 2.0 Job-Ready AI-Powered Cohor Sheryians Coding School🚀 Today was all about hands-on coding with JavaScript loops & conditionals. Practiced real logic-building exercises like: ✅ Print numbers 1 to 10 ✅ Print even numbers using loops + condition ✅ Print numbers 10 to 1 (reverse loop) ✅ Print "YES" 5 times using a loop ✅ Ask a number → check positive or negative ✅ Ask user's age → check voting eligibility ✅ Multiplication table of 5 using loop ✅ Understand & handle edge cases with if-else The more I practice these logic patterns, the more comfortable I get with problem-solving in JavaScript 💪 #JavaScript #WebDevelopment #Frontend #CodingPractice #SheryiansCodingSchool #100DaysOfCode #DeveloperJourney
To view or add a comment, sign in
-
-
Day 31 of #100DaysOfCode – Building Logic with Conditions and Loops in JavaScript Today’s session focused on strengthening core programming logic using conditional statements and loops. Key Learnings: Understood how if, else if, and else conditions control program flow. Explored looping structures to execute repetitive tasks efficiently. Learned how combining these concepts helps in building real-world logic and problem-solving patterns. Takeaway: Mastering loops and conditions is the foundation for writing efficient, dynamic, and logical code in JavaScript. Grateful to Harsh Vandana Sharma from Sheryians Coding School and Sheryians Coding School Community for guiding us through today’s session with clear explanations and practical logic-building examples. #100DaysOfCode #JavaScript #WebDevelopment #CodingJourney #Frontend #ProgrammingLogic
To view or add a comment, sign in
-
-
Day 39 of Cohort 2.0 🚀 Today’s session was all about diving into Objects in JavaScript and applying concepts through practical problem-solving. 💻 Here’s what I learned today: 🔹 Objects in JavaScript → Store data in key-value pairs for structured and organized coding 🔹 Accessing & Modifying Object Properties → Learn how to read, update, and delete data dynamically 🔹 Functions + Arrays + Objects Practice → Strengthened logic by solving real-world coding problems combining all three concepts ✨ Key takeaway: Understanding how to work with objects and integrating them with arrays and functions makes JavaScript code more powerful, modular, and efficient. Sheryians Coding School #sheryianscodingschool #cohort2 #learningjourney #dailyupdates #JavaScript #WebDevelopment #Frontend
To view or add a comment, sign in
-
-
The Art of Efficient Problem-Solving. “Programs must be written for people to read, and only incidentally for machines to execute.” — Harold Abelson Efficiency in JavaScript isn’t just about speed—it’s about clarity and logic. Explore the beauty of efficient coding with LearnMing. https://www.rfr.bz/lb52f75 #CodingQuotes #JSWisdom #ProblemSolving #LearnMing
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