Still consistent with my DSA practice — focusing on building strong logic step by step. 🚀 Today’s problem: 🔹 Check Perfect Square Problem: Determine whether a given number is a perfect square or not. Simple brute-force approach, but it builds a clear understanding of loops, conditions, and mathematical logic. Not everything needs to be optimized from day one. First, understand it. Then improve it. That’s the plan. #DSA #JavaScript #ProblemSolving #CodingJourney #Consistency
Check Perfect Square Problem Solution in JavaScript
More Relevant Posts
-
Still consistent with my DSA practice — focusing on core logic building. 🚀 Today I worked on: 🔹 Find Intersection of Two Arrays Problem: Given two arrays, find the common elements between them. Simple brute-force approach, but it clearly shows how nested loops and comparisons work. Yeah, this isn’t optimized — but right now I’m focusing on understanding logic first, optimization later. Because if your base is weak, no “optimized solution” will save you. #DSA #JavaScript #ProblemSolving #CodingJourney #Consistency
To view or add a comment, sign in
-
-
🚀 DSA Challenge – Multiple Pointers Pattern 💡 Problem Given a sorted array and a target average, determine if there exists a pair whose average equals the target. 🔍 Examples averagePair([1,2,3], 2.5) ➝ true averagePair([1,3,3,5,6,7,10,12,19], 8) ➝ true averagePair([], 4) ➝ false ⚡ Approach • Initialize two pointers → one at the start, one at the end • Calculate the average of the two values • Move pointers based on comparison with the target • Achieve O(N) time and O(1) space complexity 🧠 Key Learning Instead of checking all possible pairs (O(N²)), leveraging the sorted nature of the array with the two-pointer technique makes the solution highly efficient. 🔥 Consistency is key — showing up daily to improve problem-solving skills and build stronger fundamentals. 👉 How would you approach this problem? Any edge cases or optimizations you’d consider? 🔗 GitHub: https://lnkd.in/gurx_UXW #DSA #JavaScript #CodingChallenge #100DaysOfCode #ProblemSolving #FrontendDeveloper #FullStackDeveloper #LearningInPublic #TechJourney
To view or add a comment, sign in
-
-
Solved a classic sliding window problem today — and it finally clicked for me. The problem: given a binary array, you can flip at most k zeros. Find the longest subarray of 1s. At first glance it looks like a brute force problem. Try every subarray. But that's O(n²). The insight? Think of it like a bouncer at a club with a strict rule: at most k troublemakers (zeros) allowed inside at any time. → right pointer = front door, letting new people in → left pointer = back door, kicking people out when the rule is violated → zeros counter = troublemaker count The window only ever grows when things are clean. When zeros > k, we shrink from the left until we're back in bounds. We never shrink smaller than our best size — that's the key. Result: O(n) time, O(1) space. function maxConsecutiveOnes(nums, k) { let left = 0, zeros = 0, maxLen = 0 for (let right = 0; right < nums.length; right++) { if (nums[right] === 0) zeros++ while (zeros > k) { if (nums[left] === 0) zeros-- left++ } maxLen = Math.max(maxLen, right - left + 1) } return maxLen } // Input: [1,1,1,0,0,0,1,1,1,1,0], k=2 // Output: 6 Sliding window is one of those patterns that once you see it, you see it everywhere — longest substring, max sum subarray, minimum window substring. What DSA pattern took the longest for you to truly internalize? #DSA #JavaScript #SlidingWindow #LeetCode #CodingInterview #ProblemSolving #WebDevelopment #Programming #100DaysOfCode #FrontendDeveloper
To view or add a comment, sign in
-
I used var, let, and const without really thinking about it. I just followed the usual advice, use const, avoid var, use let when something changes. Recently I actually took the time to understand why. It’s really about control. var doesn’t respect block boundaries, which can lead to unexpected behavior. let and const stay within the block they’re defined in, which makes things more predictable. And then const prevents reassignment, while let allows it. Nothing changed about the syntax. Just the understanding. #javascript #webdevelopment #coding #softwareengineering
To view or add a comment, sign in
-
Continuing the 10-week series where I share questions that separate familiarity from real understanding. 🔹 Engineering Depth – Week 6: Equality & Coercion Q: Why can two values that look completely different be considered equal in JavaScript? “== triggers type coercion.” “JavaScript follows abstract equality rules.” “Conversion happens before comparison.” Examples: [] == false // true "" == 0 // true null == undefined // true But: [] === false // false Why this matters in real systems: • Unexpected condition checks • Hidden bugs in form validation • Inconsistent API comparisons Understanding this helps you: – Avoid implicit coercion traps – Write predictable comparisons – Debug edge-case bugs faster JavaScript doesn’t compare values directly. Sometimes, it transforms them first. #JavaScript #Equality #Coercion #SoftwareEngineering #FrontendDevelopment #TechDepth
To view or add a comment, sign in
-
-
Ever had perfectly fine-looking code… that just won’t run? 🤯 I ran into a sneaky JavaScript bug today: let x = 5; console.log(x) Looks correct, right? But it throws an error. The culprit 👉 that tiny character after 5 is not a real semicolon. It’s actually a Greek question mark (;) instead of the standard ;. ➡️ JavaScript doesn’t recognize it ➡️ The code breaks silently ➡️ You waste time debugging something that looks fine ✅ Fix: let x = 5; console.log(x); 💡 Lesson: Not all characters that look identical are actually the same — especially when copying code from PDFs, websites, or different keyboards. Sometimes debugging isn’t about logic… it’s about spotting the invisible. #JavaScript #Coding #Debugging #WebDevelopment #ProgrammingTips
To view or add a comment, sign in
-
-
🚀 DSA Day 18: Shifting Pointers & Linking Logic! 🔗🧠 Today was less about the theory and more about the logic. Implementing get, insert, and delete really forced me to see the code as a physical chain. The big "Aha!" moment: Realizing the power of O(1) insertions. In an array, adding to the front is a chore; here, you just move the head pointer and you’re done. ⚡️ It’s definitely a game of precision, though. If you don't handle the pointers in the right order—like making the "handshake" before breaking the old link—you lose your entire list to the void. 🕳️ Feeling way more confident with pointer logic now. On to Day 19! ➡️ #Day18 #JavaScript #DSA #LinkedList #CodingJourney #DataStructures #LearningInPublic #WebDev #LogicBuilding
To view or add a comment, sign in
-
-
"React useEffect & useCallback in 2026: Stop Unnecessary Re-renders (React 19 Guide)" Fix unnecessary React re-renders: master useCallback, useMemo, React.memo, and the new React 19 use() hook with real-world patterns, profiling tips, and pitfalls to avoid. #React #React19 #useEffect #useCallback #useMemo 👉 Read full article: https://lnkd.in/d9ypxQex
To view or add a comment, sign in
-
JavaScript array methods visualized with Pokémon. I’ve been experimenting with short visual loops using Claude Code and Remotion to explain concepts faster and this one shows some of the most common array methods in practice. Quick reference using real behavior: • filter() selects matching items • map() transforms items • find() returns the first match • findIndex() returns the index of the match • fill() replaces values • every() checks all items • some() checks at least one • concat() merges arrays • includes() checks existence • push() adds to the end • pop() removes from the end • shift() removes from the start • unshift() adds to the start • splice() removes or replaces items Same concepts, just easier to visualize. #javascript #webdev #frontend #coding #programming
To view or add a comment, sign in
-
For vs. While: Which loop wins? 🔄 I just coded a battery drain simulator to test my JavaScript logic. Here’s the rule of thumb I used: Use FOR when you know the number of laps (e.g., "Loop 10 times"). Use WHILE when you’re waiting for a result (e.g., "Loop until the battery hits 0"). In this code, since the battery drop is random, I don't know the number of laps—making the while loop the perfect tool for the job. #Coding #JavaScript #WebDev #Logic
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