Another late-night success Solved a tricky binary search + sliding window problem efficiently in Java, optimizing power distribution logic in minimal runtime. 📊 Runtime: 31 ms 💡 Beats 89.29% of Java submissions 🧩 Concepts used: Binary Search, Prefix Sum, Sliding Window Each accepted solution reminds me that writing clean, efficient code isn’t just about passing tests — it’s about thinking like the system itself. #Java #LeetCode #ProblemSolving #Algorithms #CodingJourney
Solved binary search + sliding window problem in Java, beating 89% of submissions
More Relevant Posts
-
💡 Java Collections — Under the Hood Understanding how collections work = writing faster, efficient code. 🔹 HashMap → Key-value, hash buckets + tree structure (since Java 8) 🔹 HashSet → Built on HashMap 🔹 ArrayList → Dynamic resizing arrays 🔹 LinkedList → Doubly linked nodes 🔹 TreeMap → Red-black tree sorted by key Master these, and performance tuning becomes instinctive ⚙️ 💬 Which one do you use most often — and why? #Java #DataStructures #Coding #SystemDesign #BackendDevelopment
To view or add a comment, sign in
-
-
🧠 Total Grid Ways Problem — Recursive Approach in Java 💻 Exploring how to find all possible paths from the top-left corner to the bottom-right corner in a grid — moving only right or down. This recursive solution breaks the problem into smaller subproblems, combining their results to find total unique paths. ✨ Sometimes, even a simple grid teaches us how powerful recursion can be!
To view or add a comment, sign in
-
-
🌟 Java Insight: @IntrinsicCandidate Annotation Just discovered @IntrinsicCandidate in Java! It’s a special tag in the code that tells the JVM, “This method could be supercharged for speed.” If the JVM agrees, it swaps in a highly optimized version behind the scenes—no extra work needed from us. Think of it like giving the JVM permission to use a power tool instead of a regular one for certain jobs, making things run faster and smoother. You’ll find this in core methods like Math, String, and Array operations—places where speed really matters. It’s internal magic that helps Java stay both easy to use and lightning fast! #Java #Performance #JVM
To view or add a comment, sign in
-
-
🌟 Main Method in Java The main method is the entry point of every Java program. It allows the OS to hand over control to your code for execution. 📝 Signature: public static void main(String[] args) 💡 public → accessible to OS 💡 static → no object needed 💡 void → no return 💡 String[] args → command-line arguments ✅ Example: class Demo { public static void main(String[] args) { System.out.println("Hello World!"); } } #Java #ProgrammingBasics #Coding #HelloWorld #LearningJourney #ComputerScience
To view or add a comment, sign in
-
-
Week 8 || Day 2💡 Reversing words in Java — step by step! Today I practiced reversing each word in a sentence using two different approaches: 🔹 Approach 1 — With .reverse() method: Split the sentence using split(" ") to separate words. Used StringBuffer for each word and applied .reverse() directly. Joined the reversed words back with spaces. 🔹 Approach 2 — Without using .reverse(): Again split the string into words. For each word, used a for loop running from the last character to the first. Appended each character manually into a new StringBuffer. Combined the reversed words carefully, avoiding extra spaces.⚡ #Java #StringBuffer #ProgrammingLogic #JavaFullStack
To view or add a comment, sign in
-
“𝒀𝒆𝒉 𝒐𝒓𝒊𝒈𝒊𝒏𝒂𝒍 𝒘𝒂𝒍𝒂 𝒌𝒚𝒖𝒏 𝒃𝒂𝒅𝒂𝒍 𝒈𝒂𝒚𝒂?” If you’ve ever asked that while cloning objects in Java — this post is for you! Here’s a simple visual breakdown of Shallow vs Deep Copy. #Java #LearningEveryday #SoftwareDevelopment #Coding
To view or add a comment, sign in
-
Day 24 of #50DaysOfCode – Java 💻 Today’s challenge was to check whether a number is an Automorphic Number. An Automorphic Number is a number whose square ends with the same digits as the number itself. Examples: 5 → 25 ✔️ (ends with 5) 76 → 5776 ✔️ (ends with 76) This problem helped me understand digit comparison, modulus operations, and number patterns in Java 🔍✨ #Java #CodingChallenge #50DaysOfCode #LearnToCode #ProgrammingBasics #LogicBuilding #CodeDaily #ProblemSolving #AutomorphicNumber #JavaBeginner
To view or add a comment, sign in
-
🧠 Deep Dive into Java’s Object Class Methods Every class in Java ultimately traces back to the Object class, the universal ancestor of all! This powerful class defines essential methods that give life to object behavior in Java 👇 getClass() – Identifies the runtime class of an object hashCode() – Generates a unique code for each object equals() – Enables logical comparison between objects clone() – Creates a copy of an existing object toString() – Converts an object into a human-readable string wait(), notify(), notifyAll() – Facilitate communication between threads. #ObjectClass #OOPsConcepts #LearnJava #ObjectOrientedProgramming #CodeWithJava #JavaDeveloper #ProgrammingConcepts
To view or add a comment, sign in
-
-
Extract a character from a string To get a character from a string in Java, you can use the charAt() method of the String class. This method takes an index as an argument and returns the character at that position (0-based index). Here's a simple Java program to demonstrate this: Code : public class GetCharacterFromString { public static void main(String[] args) { String str = "Hello, World!"; int index = 7; // Index of the character to retrieve (0-based) // Get the character at the specified index char ch = str.charAt(index); // Print the character System.out.println("Character at index " + index + " is: " + ch); } } Can anyone guess the output ?. #JavaProgramming #JavaCode #Coding #ProgrammingTips #LearnJava #JavaDevelopment #CodeSnippet #SoftwareDevelopment #TechTips #100DaysOfCode
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