📌 LeetCode Solved | Two Sum (JavaScript) ✅ Revisited one of the most classic problems in DSA — Two Sum — but with an optimized mindset. 🧠 Approach Used a HashMap (Map in JS) to store values with their indices and quickly check if the required complement exists. ⏱️ Complexity Time Complexity: O(n) Space Complexity: O(n) #LeetCode #DSA #JavaScript #ProblemSolving #HashMap #CodingJourney #LearnInPublic
Two Sum Optimized with JavaScript HashMap
More Relevant Posts
-
🟢 Day 17 / 100 – 📌JavaScript Practice 🚀 ✅ Practiced nested arrays using a Tic-Tac-Toe board today. ✅Explored how indexing works in JavaScript by accessing valid, invalid, and negative indexes through the console. • Learned - Errors and undefined values help in understanding how JavaScript actually behaves under the hood. #Day17 #JavaScript #WebDevelopment #FrontendDevelopment
To view or add a comment, sign in
-
-
Quick JS Brain Teaser: Strings are immutable in JavaScript, but what does that really mean in practice? Take a look at this image: What will be the output? A) "KavaScript" B) "JavaScript" C) undefined D) TypeError Does this match your expectation? Drop your answer in the comments and explain WHY! Understanding string immutability is crucial for avoiding common bugs in JavaScript. #JavaScript #JavaScriptInterviewQuestion #JavaScriptFundamentals
To view or add a comment, sign in
-
-
JavaScript Proxies let you intercept and modify the logic of property access and assignment on objects (see below for a toy example). I don’t reach for Proxies often, but they were a perfect fit for a small side project of mine: I wanted to write an SPA using only vanilla JS, and I used proxies as a lightweight form of state management. 👨💻🛠️ I’ve always thought they’re pretty cool! 🔥😎 Do you use Proxies often in your code? What are your use cases (validation, logging, testing, ...)? 👨💻🤔 #javascript #proxies
To view or add a comment, sign in
-
-
✨ What is a 𝗧𝗿𝗮𝗻𝘀𝗽𝗶𝗹𝗲𝗿 used for in #JavaScript? A transpiler (source-to-source compiler) takes modern JavaScript code (ES6+, ESNext) and converts it into older, widely supported JavaScript (usually ES5). The most popular example is Babel – it lets us write clean arrow functions, classes, async/await, optional chaining and more… while still running perfectly in older browsers and environments. Do you already use a transpiler (consciously :D) in your workflow? Share in the comments! #CleanCodeSolutions #WebDevelopment #JavaScript #Babel
To view or add a comment, sign in
-
-
In DevOps we work a lot with YAML. But YAML only describes data. The meaning lives entirely in the controllers that consume it. Concrete example: A GitOps notification messageTemplate references .Updated.Changes. After a controller upgrade the field becomes .Changed.Changes. The YAML is still valid and the intent is unchanged but CI fails because the internal data model changed. Tools like Helm or Kustomize render YAML, but they don’t protect intent when controller internals or template fields evolve. We have no real transpilers that adapt old intent to new controller versions. Similar to how Babel outputs JS for a specific runtime, treating YAML more like compiled output instead of static config would save a lot of pain. Until then, logs help us bridge the gap. 😂 #DevOps #GitOps #FluxCD #CI #BonnConsulting
✨ What is a 𝗧𝗿𝗮𝗻𝘀𝗽𝗶𝗹𝗲𝗿 used for in #JavaScript? A transpiler (source-to-source compiler) takes modern JavaScript code (ES6+, ESNext) and converts it into older, widely supported JavaScript (usually ES5). The most popular example is Babel – it lets us write clean arrow functions, classes, async/await, optional chaining and more… while still running perfectly in older browsers and environments. Do you already use a transpiler (consciously :D) in your workflow? Share in the comments! #CleanCodeSolutions #WebDevelopment #JavaScript #Babel
To view or add a comment, sign in
-
-
📌 LeetCode Solved | Check if Array Is Sorted and Rotated (JavaScript) ✅ Yesterday’s problem was a great reminder that simple observations beat complex code. 🧠 Key Insight In a sorted & rotated array, there can be at most one “drop” where nums[i] > nums[i+1]. So instead of rotating or sorting: 1. Traverse the array once 2. Count how many times the order breaks 3. If breaks > 1 → ❌ Not sorted & rotated 4. Using modulo helped handle the circular comparison cleanly. ⏱️ Complexity Time Complexity: O(n) Space Complexity: O(1) 💡 Takeaway Problems like this reward pattern recognition over brute force. #LeetCode #DSA #JavaScript #ProblemSolving #Arrays #CleanCode #LearnInPublic #CodingJourney
To view or add a comment, sign in
-
-
Consider the following code: JavaScript for (var i = 1; i <= 3; i++) { setTimeout(function () { console.log(i); }, 1000); } 👉 What will be the output and why? 👉 How would you fix it so that it prints 1 2 3 instead? 💡 This question tests: Closures Scope (var vs let) Asynchronous behavior Event loop understanding JavaScript Developer #react #JavaScript #AdvancedJavaScript #JavaScriptInterview #JSClosures #AsyncJavaScript #WebDevelopment #FrontendDeveloper #BackendDeveloper #FullStackDeveloper #DevelopersOnLinkedIn #TechCommunity #LearnToCode #CodingTips #CareerInTech
To view or add a comment, sign in
-
Today I implemented a HashMap in JavaScript - not because I need to (JavaScript already has Map!), but because understanding the fundamentals makes you a better developer. Key takeaways: → How hashing functions work → Managing collisions efficiently → The trade-offs between time and space complexity What fundamental concept have you explored lately? #SoftwareEngineering #JavaScript #ContinuousLearning
To view or add a comment, sign in
-
-
Day (58/100) #100DaysOfWEB Building an Authentication System using JavaScript and LocalStorage. Code: https://lnkd.in/egXytznT Live: https://lnkd.in/ey3Pq9Um #100DaysOfCode #JavaScript #WomenInTech #TorontoTech #SenecaCollege #BuildInPublic #100daysofchallenge
To view or add a comment, sign in
-
💡 JavaScript Tip of the day What will be the output? console.log(typeof null); 👉 Answer: "object" Yes, it’s a well-known JavaScript bug 😉 #JavaScript #DeveloperLife #FrontendDeveloper #CodingQuestions #Developers
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