🚀Day 91/100 #100DaysOfLeetCode 🔍Problem: Combination Sum✅ 💻Language: Java 💡Approach: Used Backtracking to explore all possible combinations that sum up to the target. At each step, I either include or skip the current candidate, ensuring no duplicates by maintaining a start index. When the target becomes 0, the current combination is added to the result list. 🧠Key Takeaways: 🔹Backtracking is ideal for exploring multiple decision paths. 🔹Efficient pruning avoids unnecessary recursive calls. 🔹Always clone the current path before adding it to the result to avoid mutation issues. ⚙️Performance: ⏱️Runtime: 2 ms (Beats 84.56%) 💾Memory: 44.65 MB (Beats 64.98%) #100DaysOfLeetCode #Java #Backtracking #LeetCode #ProblemSolving #CodingJourney #CodingChallenge
Solved Combination Sum with Java Backtracking
More Relevant Posts
-
🚀 Day 4 of My DSA with Java Journey 📘 Problem: Square of a Sorted Array 🧩 Topic: Two Pointers 💻 Language: Java ⚙️ Approach: Two Pointer Technique (O(n)) 🔍 What I Learned: Handling both negative and positive numbers while keeping the array sorted after squaring — optimized using two pointers instead of sorting after squaring. ✨ Key Takeaway: Think in terms of pointers and comparisons, not just brute force — that’s how optimization begins. #Java #DSA #LeetCode #TwoPointers #CodingJourney #100DaysOfCode #PlacementPrep #LearnInPublic #CodingCommunity #JavaDeveloper
To view or add a comment, sign in
-
-
Reverse of a string in Java This method is like rewriting a word from the end to the beginning, letter by letter class ReverseString { public static void main(String[] args) { String original = "Hello"; String reversed = ""; for (int i = 0; i < original.length(); i++) { reversed = original.charAt(i) + reversed; } System.out.println("Reversed String: " + reversed); } } #java #Coding
To view or add a comment, sign in
-
"A ‘byte’-sized example with a big Java lesson — Type Casting in Action!" KEY POINTS ‣byte a = 10; byte b = 20; → Two variables declared using the byte data type (range: -128 to 127). ‣a + b → In Java, arithmetic operations on byte, short, or char are automatically promoted to int. ‣(byte) (a + b) → Explicit type casting is required to store the result back into a byte variable. ‣Without casting, the compiler throws an error because int cannot be directly assigned to byte. ‣r = (byte) (a + b); → Safely converts the int result back to byte. ‣System.out.println(r); → Prints the result (30) on the console. ‣This example demonstrates type promotion and explicit casting — two important Java fundamentals. Here is the code snippet!👇🏻 #Java #LearningToCode #Practice #Buildinpublic #JavaDevelopment
To view or add a comment, sign in
-
-
#Day45 of #50DaysOfCoding Divisible Sum Pairs Problem (Java) Today, I tackled the “Divisible Sum Pairs” problem from HackerRank using Java. The objective was to identify all pairs of numbers in a list whose sum is divisible by a specified integer k. Concepts Used: - Nested loops to check every unique pair (i, j) where i < j. - Modulo operation to verify divisibility: (ar[i] + ar[j]) % k == 0. - Basic iteration and condition checking logic. Working: - Read input values n, k, and the array ar. - Iterate through all pairs. - Count how many pairs have sums divisible by k. - Print the total count. Example: If n = 6, k = 3, and ar = [1, 3, 2, 6, 1, 2], the valid pairs are (1,2), (3,6), (2,4), etc. Output: 5 Complexity: - Time Complexity: O(n²) - Space Complexity: O(1) This exercise enhanced my understanding of modulo operations, loops, and pair iteration logic — essential concepts for many coding interviews. #Java #ProblemSolving #CodingJourney #Programming #LearningEveryday #LogicBuilding #leetcode #DSA #CodingChallenge #LearnJava #CodeNewbie #Algorithms #DataStructures #TechJourney #javaProgramming #LearningInPublic #PentagonSpace
To view or add a comment, sign in
-
-
🔍 Java Insight of the Day -18: Method Overloading Today I explored Method Overloading, a key concept in Java that enables compile-time polymorphism. It allows multiple methods with the same name but different parameters—making code more readable and flexible. 💡 The Java compiler decides which method to invoke based on: • Method name • Number and type of parameters • Implicit type casting (type promotion) Also discovered that even the main() method can be overloaded—though only the standard signature is executed at runtime. #Java #MethodOverloading #OOP #CompileTimePolymorphism #TechLearning #WomenWhoCode #TapAcademy #100DaysOfCode #JavaDeveloper #CodingJourney #LinkedInLearning
To view or add a comment, sign in
-
-
🚀Day 92/100 #100DaysOfLeetCode 🧩Problem: Swap Nodes in Pairs✅ 💻Language: Java 🔍Approach: 🔹To swap every two adjacent nodes in a linked list, I used a dummy node to simplify pointer handling. 🔹The dummy node helps manage edge cases (like swapping the first pair). 🔹I iteratively swapped pairs by adjusting the next pointers of each node. 🔹Finally, I returned dummy.next as the new head of the list. 🧠Key Takeaways: 🔹Dummy nodes are powerful tools for simplifying linked list manipulations. 🔹Careful pointer tracking ensures no data loss during swaps. 🔹Iterative solutions can be more memory-efficient than recursion in linked lists. ⚙️Performance: ⏱️Runtime: 0 ms (Beats 100.00%) 💾Memory: 41.76 MB (Beats 11.86%) #100DaysOfLeetCode #Java #LinkedList #CodingJourney #ProblemSolving #LeetCode #CodingChallenge
To view or add a comment, sign in
-
-
Memory Safety: Where Rust Goes Further Rust eliminates entire classes of memory errors — without a Garbage Collector. Some key differences 👇 ❌ Java: NullPointerException is always possible. ✅ Rust: uses Option<T> — absence must be handled explicitly. ❌ Java: needs synchronized to prevent data races. ✅ Rust: the borrow checker forbids conflicting mutable access at compile time. ❌ Java: avoids use-after-free through GC at runtime. ✅ Rust: makes that scenario impossible to compile. ❌ Java: can leak via static caches or circular references. ✅ Rust: leaks only if you explicitly choose to (Box::leak). Rust doesn’t collect garbage —it prevents garbage from existing. 🚀 #RustLang #Java #MemorySafety #Backend #SystemsProgramming #ProgrammingLanguages
To view or add a comment, sign in
-
🚀 *Learning Update: Java Arrays & Strings* This week, I explored *Arrays* and *Strings* in Java! 🌟 ✅ *Arrays*: Learned how to store multiple values of the same type in a single data structure, access elements using indices, iterate using loops, and perform common operations like sorting, searching, and updating values. ✅ *Strings*: Practiced handling text data, using methods like `length()`, `charAt()`, `substring()`, `concat()`, `replace()`, and `split()`. I also explored string immutability and how to manipulate strings efficiently. #Java #Programming #Coding #LearningJourney #Arrays #Strings #SoftwareDevelopment
To view or add a comment, sign in
-
-
🧠 Daily LeetCode Grind — Java Edition Today’s challenge: ✅ Palindrome Number (#9 - Easy) 📌 Goal: Check whether an integer reads the same backward as forward without converting it to a string. 📌 Approach: 🔹 Handle negatives and numbers ending in 0 (except 0 itself). 🔹 Reverse only half of the digits using modulo and division. 🔹 Compare the original and reversed halves for equality. 🧩 Test Cases: Input: 121 → Output: true Input: -121 → Output: false Input: 10 → Output: false 💡 Key Takeaways: 🔹 Strengthened arithmetic-based problem-solving (no string ops). 🔹 Learned efficient O(1) space reversal logic. 🔹 Improved understanding of numeric pattern recognition. 💻 Language: Java 🧠 Complexity: O(log₁₀ n) — reverse digits only once. #LeetCode #Java #CodingPractice #ProblemSolving #DSA #PalindromeNumber #DeveloperLife #AcceptedSolution #CybernautEdTech
To view or add a comment, sign in
-
Explore related topics
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