💡 Post Idea: Implementing myPow(x, n) — Fast Power Function in JavaScript 🚀 Today I implemented an optimized power function myPow(x, n) using exponentiation by squaring, which is much faster than multiplying x repeatedly in a loop. ⚙️ What this code does: Handles both positive and negative exponents. Uses bit manipulation logic (divide exponent by 2) for efficiency. Reduces time complexity from O(n) → O(log n). 🔍 Why it matters: This technique is widely used in competitive programming, numerical methods, and system-level calculations where performance matters. #JavaScript #Coding #SoftwareEngineering #ProblemSolving #TechLearning
Optimized myPow(x, n) function in JavaScript with exponentiation by squaring
More Relevant Posts
-
In today’s class, we explored some really interesting JavaScript concepts related to Arrays — and how we can add, remove, and modify elements dynamically. Here’s a quick overview of what we covered 👇 📘 Topics we practiced: 🔹 Adding elements using push() and unshift() 🔹 Removing elements using pop() and shift() 🔹 Copying parts of an array with slice() 🔹 Replacing or removing elements with splice() A big shoutout to Miss Fatima Khalid for explaining everything so clearly and making the session interactive and fun! 🙌 Every small concept we learn adds up — one step closer to writing cleaner, smarter code 💪✨ #JavaScript #WebDevelopment #LearningJourney #Coding #Arrays #WomenInTech #StudentLife
To view or add a comment, sign in
-
-
🚀 Efficient Task Scheduling with JavaScript (LeetCode 621: Task Scheduler) Today I explored an interesting problem — scheduling tasks with cooldown periods efficiently. 🔹 Problem: Given a list of tasks (like ['A', 'A', 'A', 'B', 'B', 'B']) and a cooldown interval n, find the least number of intervals needed to finish all tasks without breaking the cooldown rule. 🔹 Key Idea: Count the frequency of each task. Sort to find the most frequent task. Use idle slots to manage cooldowns. Minimize idle time and calculate total intervals. 💡 Learning: This problem taught me how to use frequency counting, sorting, and greedy scheduling together to reduce idle time and improve performance. #JavaScript #TypeScript #Coding #ProblemSolving #LeetCode #WebDevelopment #TechLearning
To view or add a comment, sign in
-
-
💻 JavaScript Conditional Statements (If-Else, Else If, Switch & Ternary) In today’s practice, I explored how JavaScript makes decisions using conditional statements. These help programs respond differently based on input or conditions — just like real-life choices! 🌟 🧩 Covered Concepts: ✅ If–Else: Checking even/odd numbers, eligibility, positive/negative, passwords, divisibility 🧠 Else–If Ladder: Grades, largest number, months, temperature, character types 🔁 Switch Case: Days, seasons, calculator, traffic lights, grades ⚡ Ternary Operator: Quick checks for positivity, largest number, leap year, pass/fail, and case 💬 Practicing these statements improved my logic-building and problem-solving skills in JavaScript! #JavaScript #WebDevelopment #CodingPractice #FrontendDevelopment #LearnToCode #ProgrammingJourney
To view or add a comment, sign in
-
This session was all about making our JavaScript code think and decide the real start of programming logic We explored: 1. Operators - how JavaScript performs calculations, comparisons & logical checks 2. Type Casting - how data changes from one type to another (and how it can silently break logic 😅) 3. Loops - for, while, do-while to make our code repeat smartly 4. Conditional Statements - if, else, switch to make our code make decisions Students started realizing how programming is not about syntax… It’s about teaching the computer to think logically 🧠 I always say: “When you master loops and conditions, you stop memorizing code and start understanding logic.” Excited to see how my learners are growing day by day and building real logic foundations #JavaScript #MERN #FullStack #CodingBootcamp #ProgrammingLogic #LearnToCode #WebDevelopment #TrainerLife
To view or add a comment, sign in
-
-
💡 JavaScript LeetCode Challenge — Day 19: Longest Common Prefix 🚀 Today’s Challenge: Find the longest common prefix among an array of strings. 🧩 Problem Example: Input: ["flower", "flow", "flight"] Output: "fl" If no common prefix exists, return "". 💭 Key Takeaways: Improved understanding of string manipulation in JavaScript Practiced prefix trimming logic using indexOf() and slice() Every solved problem = better problem-solving muscle 💪 📈 #Day19 #JavaScript #LeetCode #CodingChallenge #100DaysOfCode #WebDevelopment #ProblemSolving #LearningInPublic #CodeNewbie
To view or add a comment, sign in
-
-
Day 34 -Strengthening Logic with Loops & Conditionals in JavaScript 🔁 Today’s session focused on building the foundation of programming logic mastering loops and conditionals to make code smarter and more dynamic. Here’s what I practiced today: 🔹 Printed numbers in both increasing and decreasing order 🔹 Filtered even numbers using conditional checks 🔹 Repeated words for pattern-based outputs 🔹 Checked even/odd numbers using loop logic 🔹 Took user input to detect positive or negative values 🔹 Created a small program to check voting eligibility based on age Each exercise helped sharpen my logical thinking and problem-solving skills step by step, getting closer to writing cleaner and more efficient code! 💪 #Day34 #JavaScript #WebDevelopment #CodingJourney #SheryiansCodingSchool #FrontendDeveloper #ProblemSolving
To view or add a comment, sign in
-
-
Day 25/90 – 90 Days DSA Challenge Today I learned how to find the factorial of a number using recursion in JavaScript 💡 🧠 Concept Recap: Recursion is a process where a function calls itself to solve smaller subproblems. In the case of factorial, we multiply the number by the factorial of the previous number until we reach 1. ⚙️ Problem Statement: 👉 Write a recursive function fact(n) that returns the factorial of a number n. 🧩 Example: Input: 5 Process: 5 * 4 * 3 * 2 * 1 Output: 120 Time Complexity: O(n) 💾 Space Complexity: O(n) (recursive call stack) ✨ Key Takeaway: Recursion simplifies problems like factorial by breaking them down into smaller, repeatable steps — clean, simple, and powerful! 🚀 #Day25 #90DaysDSAChallenge #Recursion #JavaScript #ProblemSolving #Factorial #MechCode #LearningInPublic #FrontendDeveloper #CodeEveryday
To view or add a comment, sign in
-
-
Let’s decode three of the most confusing JavaScript topics 👇 🔹 1. Scope Scope defines where your variables and functions are accessible. Global Scope: Accessible everywhere in the code. Function Scope: Accessible only inside a function. Block Scope: (introduced with let & const) accessible only within { }. 🔹 2. Hoisting JavaScript moves declarations to the top of their scope before code execution. But remember — only declarations are hoisted, not initializations. That’s why var behaves differently than let and const. 🔹 3. TDZ (Temporal Dead Zone) The period between entering a scope and initializing a variable declared with let or const. Accessing a variable in TDZ results in a ReferenceError — it exists but isn’t accessible yet! #JavaScript #FrontendDevelopment #WebDevelopment #Coding #Programming #LearnToCode #Scope #Hoisting #TDZ
To view or add a comment, sign in
-
-
Day 32 — Loops & Conditional Logic in JavaScript | 2.0 Job-Ready AI-Powered Cohort Sheryians Coding School 🚀 Today was all about building strong control-flow logic in JavaScript: 🟡 Truthy & Falsy Values Falsy → 0, "", null, NaN, undefined, false, document.all Everything else is Truthy ✅ 🧠 Conditional Statements if, else, if-else, else-if switch Ternary Operator for compact logic 🔁 Loops for loop basics & patterns ⛔ Loop Control Statements break — exit loop continue — skip to next iteration Understanding these deeply helps write cleaner, efficient control flow and decision-making logic in JS 💡 #JavaScript #WebDevelopment #Frontend #ControlFlow #SheryiansCodingSchool #DeveloperJourney
To view or add a comment, sign in
-
-
Today I practiced one of the classic algorithm problems — implementing the atoi (string to integer) function manually in JavaScript. This problem helps understand: String parsing Handling whitespace and signs Managing integer overflow and boundaries (INT_MAX, INT_MIN) Character to digit conversion using charCodeAt() Here’s a short summary of what my code does: Skips leading spaces Checks for '+' or '-' sign Converts valid numeric characters into an integer Stops at the first invalid character Returns result within 32-bit integer range #JavaScript #CodingChallenge #LeetCode #WebDevelopment #ProblemSolving #LearningJourney
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