🚀 Day 4 of my Coding Challenge Today's problem was simple but a great reminder of string fundamentals in JavaScript. Problem Statement Given a string s, return the last character of the string. Example Input: "learncoding" Output: "g" Any language Approach Use string indexing with length - 1 to access the last character. function getLastCharacter(s) { return s[s.length - 1]; } console.log(getLastCharacter("learncoding")); // g Key Learning:- Strings are index-based length - 1 always points to the last character Small problems help strengthen core programming logic Consistency matters more than complexity. One problem every day 📚 #CodingChallenge #Day4CodingChallenge #JavaScriptDeveloper #DSA #DataStructures #Algorithms #ProblemSolving #CodingJourney #CodeDaily #LearnToCode #DevelopersLife #SoftwareDeveloper #FrontendDeveloper #FullStackDeveloper #TechCommunity #ProgrammingLife #CodeNewbie #CodingPractice #DeveloperJourney #CodingSkills #TechLearning #JavaScriptCoding #WebDeveloper #ProgrammingChallenge #DailyCoding #CodeMotivation #CareerInTech #DeveloperMindset #CodingGrind #TechGrowth
JavaScript Last Character of String Challenge
More Relevant Posts
-
🚀 Day 24 of My Coding Journey — Power of Two Today’s problem was “Power of Two” — a simple-looking question that really highlights the beauty of bit manipulation. 🔍 What I learned: Instead of using loops or recursion, I explored how binary representation works. A power of two always has only one set bit (1) in its binary form — and that insight leads to a super efficient solution. 💡 Key trick: n & (n - 1) === 0 This removes the lowest set bit, and if the result is zero, the number is a power of two. ⚡ Takeaway: Sometimes the most optimized solutions come from understanding how data is represented internally, not just from writing more code. 📈 Progress: Day by day, I'm getting more comfortable with problem-solving patterns and thinking beyond brute force approaches. #128DaysOfCode #LeetCode #JavaScript #CodingJourney #ProblemSolving #BitManipulation
To view or add a comment, sign in
-
-
Leetcode Day 1 : Problem 1 (Merge Sorted Array) Just solved my first LeetCode problem. It was the classic "Merge Sorted Array" sounds simple, right? But here's what I actually learned: JavaScript's .sort() doesn't sort numbers by default, it sorts them as strings. [1, 10, 2] becomes [1, 10, 2] not [1, 2, 10]. A one-line bug that would fail silently. Reassigning an array variable (arr = []) doesn't modify the original. LeetCode wants in-place changes. That took me a moment. I was filtering out zeros thinking they were empty slots, but 0 is a perfectly valid element. Hidden test cases would've caught me. Three bugs. One "easy" problem. Tons of learning. The real lesson? Passing the visible test cases doesn't mean your code is correct. Always think about edge cases. If you've been putting off starting DSA Interview questions like I was just open problem 1 and start. The first step is the hardest. #DSA #LeetCode #JavaScript #CodingJourney #Programming
To view or add a comment, sign in
-
-
🚀 Day 10 of My LeetCode Journey — Mastering Linked Lists Today’s problems: 🔹 Middle of the Linked List (LeetCode 876) 🔹 Reverse Linked List (LeetCode 206) 💡 Problem 1: Middle of the Linked List Used the classic slow & fast pointer approach: 👉 Slow moves 1 step 👉 Fast moves 2 steps 👉 When fast reaches the end → slow is at the middle 🎯 Such a simple trick, yet super powerful! 💡 Problem 2: Reverse Linked List This one is a must-know 🔥 👉 Iteratively reverse pointers 👉 Keep track of prev, current, and next 👉 Flip links step by step Also explored how this can be done using recursion 🧠 What I Learned: Two-pointer techniques are extremely useful Pointer manipulation builds real confidence in DSA Linked Lists are all about careful handling of references 🔥 Key Takeaways: Small tricks (like slow/fast pointers) can simplify problems a lot Practicing core problems like reversing a linked list is essential for interviews Understanding the logic > memorizing code Grateful for the learning journey with Namaste DSA and Akshay Saini 🚀 🙌 Day 11 loading… 💪 #LeetCode #DataStructures #Algorithms #CodingJourney #100DaysOfCode #SoftwareEngineering #Programming #InterviewPrep #JavaScript #CodingLife #TechGrowth #ProblemSolving #Developers #LearnToCode #LinkedList #ReverseLinkedList #TwoPointers #NamasteDSA
To view or add a comment, sign in
-
A random yet interesting learning update.... Dove deeper into Javascript and explored one of its most powerful (and often misunderstood) concepts — Prototypal Inheritance. Understanding how objects inherit properties and methods through prototypes really changed the way I think about code structure and reusability. It’s fascinating how JavaScript handles inheritance so differently compared to traditional class-based languages. Excited to keep building and learning more every day! #JavaScript #WebDevelopment #LearningJourney #Coding #FrontendDevelopment#chaiaurcode
To view or add a comment, sign in
-
LeetCode Day 18 : Problem 392 (Is Subsequence) Just solved another LeetCode problem. It was "Is Subsequence", sounds like a string problem, right? But here's what I actually learned: A subsequence doesn't need to be contiguous. "ace" is a subsequence of "abcde" because the characters appear in the same order, even with other characters in between. That single insight shapes the entire solution. The approach is clean two pointer. One pointer walks through s, one walks through t. Only move the s pointer when characters match. Always move the t pointer. If the s pointer reaches the end, every character in s was found in order inside t. No nested loops, no extra space, no complex logic. Just two pointers, one condition, done. This is what a clean O(n) solution looks like when you fully understand the problem before writing code. Twenty three problems in. The two pointer pattern keeps rewarding you. Once you see it, you stop reaching for nested loops entirely. The real lesson? Understanding the problem deeply always leads to a simpler solution. Complexity in code is usually a sign of confusion in thinking. #DSA #LeetCode #JavaScript #CodingJourney #Programming
To view or add a comment, sign in
-
-
I recently shared a short blog where I explain Object-Oriented Programming (OOP) in JavaScript along with its four core concepts — Encapsulation, Inheritance, Polymorphism, and Abstraction — using simple and beginner-friendly examples 💡 If you're learning JavaScript or just brushing up your OOP fundamentals, this might be useful for you 🚀 👉 Read the blog here: https://lnkd.in/g-B4g5gk Hitesh Choudhary | Piyush Garg | Suraj Kumar Jha | Chai Code | Akash Kadlag ☕ #JavaScript #OOP #WebDevelopment #Programming #LearnInPublic #Blog #Cohort2026
To view or add a comment, sign in
-
-
🚀 Day 3 of My LeetCode Journey — Consistency > Motivation Today’s problem: Merge Sorted Array (LeetCode 88) At first glance, it looks simple — just merge two arrays, right? But the real challenge is doing it in-place without extra space 🤯 💡 Key Learning: Instead of merging from the front (which causes overwriting), the optimal approach is to: 👉 Use two pointers from the end 👉 Fill the array backwards This small shift in thinking makes a huge difference: ⏱️ Time Complexity: O(m + n) 📦 Space Complexity: O(1) 🔥 What I’m realizing: It’s not about solving problems — it’s about learning how to think differently Every problem is teaching me: How to optimize How to avoid brute force How to think like an interviewer On to Day 4 💪 #LeetCode #DataStructures #Algorithms #CodingJourney #100DaysOfCode #SoftwareEngineering #Programming #InterviewPrep #JavaScript #CodingLife #TechGrowth #ProblemSolving #Developers #LearnToCode #Consistency #CodeDaily
To view or add a comment, sign in
-
🚀 Day 29/128 – LeetCode Challenge Today’s problem: Combination Sum (Medium) This problem was a great exercise in understanding backtracking and recursion. The goal was to find all unique combinations of numbers that add up to a target, with the twist that each number can be used multiple times. 🔍 Key Learnings: Backtracking is all about exploring possibilities and undoing choices Using a start index helps avoid duplicate combinations Recursive thinking becomes much easier with practice Important to handle base cases properly (target reached / exceeded) 💡 What clicked today: Instead of thinking “which combination is correct?”, I focused on trying every possible path and letting recursion filter valid ones. 🧠 Pattern recognized: This is a classic DFS + Backtracking problem — a pattern that shows up frequently in coding interviews. 📈 Progress update: Consistency is starting to pay off. Problems that once felt complex are becoming more intuitive. On to Day 30 🔥 #LeetCode #128DaysOfCode #DSA #CodingJourney #Backtracking #JavaScript #ProblemSolving
To view or add a comment, sign in
-
-
What is the difference between let, var, and const? `var`, `let`, and `const` are used to declare variables in JavaScript, but they behave differently. `var` is the older way and has function scope, which can lead to unexpected behavior. It also allows redeclaration and can be updated freely. `let` is block-scoped, meaning it only exists within the block where it’s defined. It can be updated but not redeclared in the same scope, making it safer than `var`. `const` is also block-scoped but cannot be reassigned after it’s declared. It’s used for values that should not change. Overall, `let` and `const` are preferred in modern JavaScript. #webdeveloper #tech #coding #programming
To view or add a comment, sign in
-
-
Day 98 of my #100DaysOfCodeChallenge Today I explored Object-Oriented Programming in JavaScript using classes. Here’s what I worked on: Built a Product class with methods to display details and calculate total price Learned how constructors initialize object properties Implemented static properties and methods using a utility class Created a User class to track the number of users created This helped me understand the difference between instance-level and class-level behavior, and how to structure code more effectively. It’s a shift from just writing functions to designing systems. #JavaScript #OOP #WebDevelopment #SoftwareEngineering
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
In Python a = "Harsh Dhaduk" a[-1:] Output k