🚀 #100DaysOfDSA — Day 26/100 Topic: Arrays as Function Arguments in Java 💻 💡 What I Did Today: Today, I learned how arrays can be passed as arguments to functions in Java — and how changes made inside a function affect the original array. This concept is super important for understanding how references work in Java! ⚙️ 🧠 Logic Used: Defined an update() function that increases every array element by 1. Passed the marks[] array into the function. Observed that updates inside the function reflected in the original array — proving arrays are passed by reference (not by value). 📊 Output: Before update → 66 68 72 68 74 After update → 67 69 73 69 75 ✨ Takeaway: Today’s practice gave me clarity on how data moves between methods in Java. Understanding references helps avoid unexpected behavior and write cleaner, safer code 💡 #100DaysOfCode #Day26 #Java #DSA #Arrays #ProblemSolving #CodingJourney #LearnInPublic #CodeNewbie #DeveloperLife
Learned about passing arrays as arguments in Java, a key concept for references.
More Relevant Posts
-
#Day-69) LeetCode 2536: Increment Submatrices by One using a 2D difference array technique in Java — a powerful approach for handling multiple range updates efficiently. 🔧 Instead of brute-force iteration over each query, I used a prefix sum strategy to apply all updates in constant time per query, followed by a cumulative pass to build the final matrix. 🧠 Highlights: Efficient submatrix updates using difference matrix Prefix sum accumulation for final values Clean, scalable Java implementation 📌 This kind of problem is a great reminder: smart preprocessing beats brute force. Let’s connect if you’ve explored similar matrix tricks or want to brainstorm more Java optimizations! #Java #LeetCode #DSA #MatrixOptimization #CodingInPublic #ProblemSolving #TechJourney #LinkedInTech
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
-
-
🚀Day 96/100 #100DaysOfLeetCode 🧩Problem: Reverse Linked List II✅ 💻Language: Java 💡 Approach: 1️⃣ First, use a dummy node to handle edge cases where reversal starts at the head. 2️⃣ Traverse to the node just before the left position — call it prev. 3️⃣ Reverse the sublist between left and right using standard pointer manipulation. 4️⃣ Reconnect the reversed portion back into the original list. 🔑Key Takeaways: 🔹Dummy nodes simplify linked list edge cases. 🔹In-place reversal reduces memory overhead. 🔹Careful pointer tracking ensures list integrity. ⚙️Performance: ⏱️Runtime: 0 ms(beats 100.00%) 💾Memory: 41.29 MB(beats 70.37%) #100DaysOfLeetCode #Java #LinkedList #CodingJourney #ProblemSolving #DSA #LeetCode #CodingChallenge
To view or add a comment, sign in
-
-
🌟 Day 15 – Cracking the Core Concept: Arrays in Java ☕💻 Today, I stepped into one of the most essential concepts in Java — Arrays. They might look simple at first glance, but understanding how they actually store and manage data opened a new perspective for me. 💡 Key Takeaways: 🔹 Arrays allow us to store multiple values of the same type under a single variable name. 🔹 Each element is indexed — starting from 0 — making it easy to access and modify data efficiently. 🔹 Memory for arrays is allocated in a continuous block, which helps in faster data access. 🔹 Learned how to declare, initialize, and traverse arrays using loops. 🔹 Explored common pitfalls like index out of bounds and fixed-size limitations. 💭 Reflection: Before today, I just thought of arrays as “lists of numbers,” but now I realize how crucial they are for building larger data structures like matrices, stacks, and queues later on. #JavaLearningJourney #LearnInPublic #JavaProgramming #Arrays #ProblemSolving #CodeEveryday #100DaysOfCode #DeveloperJourney #BackendDevelopment #NamasteJava #KeepLearning
To view or add a comment, sign in
-
Today I explored, how sorting works in Java 8 using Lambdas and Streams. Here what I learned, List.of() creates an immutable list, so we can't modify it directly. If we want to do any modification on immutable list, we can 1. Create a mutable list List<Integer> immutableList = List.of(5, 8, 3, 2, 7, 1); List<Integer> mutableList = new ArrayList<Integer>(immutableList); mutableList.sort((a, b) -> a.compareTo(b)); 2. By using streams, can get new modified list. List<Integer> immutableList = List.of(5, 8, 3, 2, 7, 1); List<Integer> sortedList = immutableList.stream(). sorted(). collect (Collectors.toList); So, streams in Java 8 are non-mutating, they create a new result instead of modifying original data source. It feels great to understand the subtle differences between mutating (list.sort()) operations and functional operations (stream().sorted()). #Java #Java8 #Streams #Lambdas #CodingJourney #LearningEveryday #SoftwareDevelopment
To view or add a comment, sign in
-
#Day-68) LeetCode #3228 – Maximum Number of Operations to Move Ones to the End (Java Edition) Tackled this neat string problem using a greedy approach in Java. The challenge? Move '1's to the end of the string under specific movement rules, maximizing the number of valid operations. 🧠 Core Idea: Track how many '0's we've seen and how many '1's we've already moved. Only move a '1' if there's enough '0's to justify it and the next character is also '1'. 💻 Java Strategy: Loop through the string Use counters to manage '0's and '1's Let me know how you'd tweak this or if you see a more optimal path! #Java #LeetCode #GreedyAlgorithm #StringProblems #DSA #CodingChallenge #LinkedInTech #ProblemSolving
To view or add a comment, sign in
-
-
(Largest Perimeter Triangle — Java 🔺) Hey everyone 👋 Today I explored how to find the largest perimeter triangle from a given array of side lengths using Java. While solving this, I understood how a simple mathematical condition can help in optimizing the entire logic 🔥 Here’s the breakdown 👇 🧠 Concept: To form a valid triangle from 3 sides, the sum of any two sides must be greater than the third one. → a + b > c → a + c > b → b + c > a 💡 Approach 1: Sort the array in descending order and check triplets from the start. If any 3 consecutive sides satisfy the triangle condition, their sum gives the largest perimeter. ⚡ Approach 2 (Optimized): Instead of reversing the array, just sort it in ascending order and iterate from the end — gives the same result but with cleaner logic and less work. 🧩 Time Complexity: O(N log N) 💾 Space Complexity: O(1) This problem helped me understand how sorting order and traversal direction can make an algorithm more elegant and efficient 🚀 📁 Code is available on my GitHub repo: https://lnkd.in/ekjD9s22 #Java #DSA #ProblemSolving #Arrays #CodingJourney #Developers #LearningByDoing #FullStackDeveloper #MCA #GitHub
To view or add a comment, sign in
-
🚀Day 99/100 #100DaysOfLeetCode 🔍Problem: Sum of Two Integers✅ 💻Language: Java 💡Approach: Instead of using the ‘+’ or ‘–’ operators, this problem leverages bit manipulation to perform addition. 🔸Use XOR (^) to calculate the sum without carry. 🔸Use AND (&) followed by a left shift (<< 1) to calculate the carry. 🔸Repeat until no carry remains. 📚Key Takeaways: 🔹Reinforced understanding of bitwise operations. 🔹Learned how addition can be simulated using logical operations. 🔹Improved understanding of low-level arithmetic computation. ⚡Performance: ⏱️Runtime: 0 ms (Beats 100.00%) 💾Memory: 40.88 MB (Beats 10.05%) #100DaysOfLeetCode #Java #BitManipulation #CodingChallenge #ProblemSolving #DSA #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
🚀Day 88 – DSA in Java Solved “Hand of Straights” (LeetCode – Medium) Approach: ➡️ Sorted the array ➡️ Used HashMap to track frequencies ➡️ Formed consecutive groups of size k ➡️ Decremented counts as groups formed ⚡ Runtime: 24 ms (Beats 89.95%) 💾 Memory: 45.2 MB (Beats 89.4%) Explored how HashMap + sorting can simplify grouping problems and also learned about TreeMap for maintaining sorted order dynamically. #Day88 #LeetCode #Java #DSA #ProblemSolving #LearningEveryday
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
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