Day 25 | Programming Classes at TAP Academy Strings Subsequences ✨ 🔍 Problem 1: Find the Index of a Character in a String Given a string S and a character K, find the index of K. 💡 Core logic: Traverse the string Compare each character using == Return index immediately when found If not found -> return -1 👉 Sounds basic… but execution exposed gaps. ⚠️ Big Reality Check The logic is literally the same as “index of element in array” — just applied to strings. 🧠 Hidden Trap: Taking Character Input in Java Most common mistake: Trying scanner.nextChar() ❌ (doesn’t exist) ✔️ Correct way: Take input as string Extract first character using .charAt(0) This tiny detail broke a lot of code. 🔁 Problem 2: Last Index of Character Same logic. Just reverse traversal. Start from length - 1 Move backwards Return first match Simple twist. Same foundation. 🔗 Problem 3: Subsequence Check Now things got interesting. 👉 Given two strings S and T, check if T is a subsequence of S. Meaning: All characters of T must appear in S Order must be maintained They don’t need to be continuous Example: S = "hereiamstackerrank" T = "hackerrank" → ✅ YES 💡 Approach Use two pointers: i -> for string S j -> for string T Logic: If characters match -> move both i++, j++ If not -> move only i++ Continue until end Final check: If j == T.length() → YES Else → NO 🧩 Bonus Concept: Loop Understanding Quick reminder that hit hard: while loop -> runs only if condition is true do-while loop -> runs at least once no matter what Understanding this difference = avoiding silent logical bugs. #Programming #Java #DSA #LearningJourney #CodingLife #ProblemSolving #TechGrowth #Software #Development #TAPAcademy #Upskilling #Logics #Strings #DSA #Coding #Problems #Logics #Syntax #CoreJava #Loops #Subsequence #Index #Learning
Find Index of Character in String with Java Code Examples
More Relevant Posts
-
Day 24 | Programming Classes at TAP Academy 🚨 Handling Extra Spaces in Strings 💡 1. Trim spaces from start and end only (without using .trim()) Traverse from left -> find first non-space -> start Traverse from right -> find first non-space -> end Loop between start and end ⚡ 2. “Remove extra spaces” is NOT “remove all spaces” Input: " how are you " Expected: "how are you" Not: "howareyou" 🔥 Core logic: Keep all characters Allow only one space between words Condition that matters: if (s.charAt(i) != ' ' || (s.charAt(i) == ' ' && s.charAt(i+1) != ' ')) 👉 That single condition = 80% of the problem solved. 🧠 3. Operators are silent killers || ->stops early (short-circuit) && -> stops early That’s why this doesn’t crash: s.charAt(i+1) Because sometimes Java never even checks it. 🔥 4. “NOT of vowel = consonant” ❌ (Big trap) Most common mistake: if (!(ch == 'a' || ch == 'e' ...)) Looks correct. It’s not. Why? Because: 👉 Character can be: Alphabet Number Special character So NOT vowel ≠ consonant ✅ Correct thinking: Check if alphabet Then check if NOT vowel THEN it’s consonant 🚀 5. Pattern mindset > Code memorization Example: 👉 Print * before every ‘a’ in "banana" Output: b*a n*a n*a Logic: Traverse If 'a' -> add "*a" Else -> normal char 👉 Every string problem = pattern + condition + traversal #Java #Strings #Programming #CoreJava #TAPAcademy #Upskilling #LearnByDoing #CodingMindset #DeveloperMindset #LogicOverSyntax #Learning #ProblemSolving #DSA #Logics #Problems #Learning #SoftwareDevelopment #Coding #CodingJourney #CodingPractice #LogicBuilding #ThinkLikeAProgrammer
To view or add a comment, sign in
-
-
🚀 Exciting News for V Programming Enthusiasts! 🚀 I'm thrilled to announce a brand-new module in my Udemy course, Learn V Programming! 🎉 Introducing "Handling JSON using Vlang"—a comprehensive guide to mastering JSON manipulation in Vlang. This module is designed to enhance your skills in working with JSON data, a vital aspect of modern programming. Here's what you'll learn in this module: 1️⃣ Encoding and Decoding JSON Data: Seamlessly convert data to and from JSON formats. 2️⃣ Working with json and json2 Modules: Learn the ins and outs of Vlang's powerful JSON handling libraries. 3️⃣ Decoding JSON Responses from the Web: Handle real-world scenarios by decoding JSON responses from APIs and web services. If you’re eager to level up your V programming skills and gain hands-on experience with JSON, this module is perfect for you. 🎯 Enroll now and start your journey today: https://lnkd.in/dFquAqbC Let’s code the future together! 💻✨ #vlang #vprogramming #learnvprogramming #programming #programminglanguage #technology #newhire #ITprofessional #ITskills
To view or add a comment, sign in
-
Creating your own game through coding as a beginner feels different. Seeing characters move, scores change, and ideas come to life on the screen made programming exciting from the very beginning. While many people start with Python, Java, or JavaScript, my journey started with the block-based visual programming language Scratch and honestly, it was one of the best ways to begin. That first step later led to completing CS50’s Introduction to Programming with Scratch from Harvard University, instructed by Professor David J. Malan. The course introduced programming in a simple but powerful way and helped build the mindset behind problem-solving, logic, and creating things from scratch. As part of the course, nine projects were completed, with a minimum score of 70% required to successfully pass each project level. Two that still bring back good memories: 🎮 Monkey Loves Banana https://lnkd.in/g9XW4Js6 🎩 Wizard Hat Game https://lnkd.in/gkt_qeAU Looking back, starting with Scratch made coding feel less intimidating and more enjoyable. Sometimes the simplest beginning becomes the most meaningful one. #CS50 #HarvardUniversity #Scratch #Programming
To view or add a comment, sign in
-
-
🚀 Learning Progress: Java OOP – Inheritance Continuing my journey in mastering Object-Oriented Programming in Java, I implemented a program to demonstrate Inheritance. In this program, I created a base class Plane with common behaviors like: Taking off Flying Landing Then, I extended this class into specialized subclasses such as CargoPlane, PassengerPlane, and FighterPlane, where each class adds its own specific functionality like carrying goods, passengers, or weapons. This hands-on implementation helped me understand how: Code reusability is achieved using inheritance Common methods can be written once in the parent class and reused by child classes Subclasses can extend and customize behavior based on requirements It was interesting to see how Java enforces a clear and structured approach to inheritance, making the program more organized and scalable. A special thanks to TAP Academy for teaching these concepts so effortlessly and making learning OOP both clear and practical. Looking forward to exploring more advanced OOP concepts! #Java #OOP #Inheritance #LearningJourney #Programming #SoftwareDevelopment #TAPAcademy
To view or add a comment, sign in
-
✨ LEARNING TAP Academy One of the fundamental pillars of Object-Oriented Programming (OOPS) is ABSTRACTION. 🔹 What is Abstraction? Abstraction is the concept of hiding implementation details and showing only the essential features of an object. 🔹 Abstract Class An abstract class is a restricted class that cannot be used to create objects. It acts as a blueprint for other classes. 🔹 Abstract Method An abstract method contains only the method signature (declaration) and no body (implementation). 💡 Key Points to Remember: ✔ An abstract class can inherit from another abstract class ✔ An abstract class can also inherit from a normal class ✔ A normal class can inherit from an abstract class ✔ An abstract class can have both abstract methods and concrete (normal) methods ✔ abstract and final keywords cannot be used together 💻 Example Program (Java): abstract class Animal { abstract void sound(); // abstract method void eat() { // concrete method System.out.println("Animal eats food"); } } class Dog extends Animal { void sound() { System.out.println("Dog barks"); } } public class Main { public static void main(String[] args) { // Animal a = new Animal(); ❌ Not allowed Dog d = new Dog(); d.sound(); d.eat(); } } 📌 Output: Dog barks Animal eats food ✨ Understanding abstraction helps you write cleaner, more secure, and maintainable code by focusing only on what is necessary. #Java #OOPS #Abstraction #Programming #TapAcademy #Learning #Coding
To view or add a comment, sign in
-
-
When I started learning programming, I was mainly focused on writing functions and making things work. But after getting introduced to Object-Oriented Programming (OOP), my way of thinking started to change. Instead of only asking "what should the program do?", I began asking "who should be responsible for doing it?" Even with the basics like classes and constructors, I can already see how OOP helps in organizing code and making it easier to understand and maintain. I’m still at the beginning of my journey, but I’m starting to realize that programming is not just about writing code — it’s about thinking in a more structured and logical way. #programming #dart #flutter #learningjourney #mobileApplications
To view or add a comment, sign in
-
Day 32 of Java Learning at TAP Academy Aggregation and Composition.......... by Sharath R Sir 💖💖 🎬 In the world of Object-Oriented Programming… every object has a story. Imagine a cinematic universe where a Mobile Phone is the hero. 🔥 Inside it lives an Operating System — not just a companion, but its very soul. If the phone falls… the OS fades with it. This is Composition — a bond so strong, they exist and end together. ⚡ But then comes the Charger — a traveler. It helps the hero, powers it up, but lives its own life. Even if the phone is gone, the charger continues its journey. This is Aggregation — connection without dependency. 💡 That’s the beauty of Association in Java: Some relationships are destiny (tight coupling) Some are companionship (loose coupling) 🎭 As developers, we don’t just write code… We design relationships, define lifecycles, and build worlds where objects interact meaningfully. 🚀 Today’s lesson: Mastering concepts like Aggregation & Composition isn’t just for exams… It’s what makes you stand out in interviews and think like a real engineer. Because in the end… Great developers don’t just code — They craft stories between objects. #Java #OOP #Programming #SoftwareEngineering #LearningJourney #CodingLife #TechStories
To view or add a comment, sign in
-
-
Day 7/50 - Wild Coding Kickoff Today's challenge was all about counting frequency of elements using a clean and efficient approach in Java. ⚡️Instead of writing complex logic, I used a Hash Map + getorDefault() make the solution simple 🥶Problem: Count how many times each element appearsin an array Input [ 1,2,2,3.1.4] Output 1->2 2->2 3->1 4->1 🔥Key Learning: Using getorDefault ( ) helps avoid unnecessary condition checks and keeps the code clean and readable #Learning #CareerGrowth #DSA #SkillDevelopment #TechCareers #DeveloperJourney #ContinuousLearning
To view or add a comment, sign in
-
-
We recently conducted an innovative Gamified Assessment Activity – “OOP’s Class-A-Thon” in our Object Oriented Programming using Java (CSE48D) course. Instead of a traditional evaluation, we transformed the classroom into a competitive learning arena, where students actively engaged in a real-time quizathon based on core OOP concepts. 🎯 Key Highlights: 🔥 Boosted student participation through gamification 🧠 Assessed real-time conceptual understanding of OOP (Inheritance, Polymorphism, Constructors, etc.) 🛡️ Ensured fairness with anti-cheating mechanisms (tab-switch tracking) 🏆 Recognized top performers based on both accuracy and behavior 📊 Live leaderboard created excitement and healthy competition 📈 The results were highly encouraging — students were more involved, focused, and motivated throughout the activity. This initiative reflects how gamification can redefine traditional assessments and make learning more interactive, transparent, and impactful. Looking forward to conducting more such engaging and outcome-driven activities! #GamifiedLearning #OOP #Java #InnovationInTeaching #StudentEngagement #EdTech #ActiveLearning #HigherEducation #TeachingExcellence
To view or add a comment, sign in
-
-
"Started with OOP… ended up with OOPS 😅 That’s the journey of every developer learning Object-Oriented Programming. From understanding classes and objects to struggling with inheritance and polymorphism… we’ve all been there. Mistakes aren’t failures — they’re part of mastering the logic. Keep coding. Keep breaking. Keep learning. #OOP #CodingJourney #ProgrammerLife #Learning #SoftwareDevelopment"
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