Java Arrays: The Ultimate Building Blocks Before building complex data structures, the foundation needs to be rock solid. Arrays are the ultimate building blocks. Today, I locked down the 4 core operations: 1. Declare: Reserving contiguous memory. 2. Initialize: Populating the data. 3. Access: The magic of O(1). 4. Traverse: Looping through the elements. The biggest takeaway? Understanding fixed memory allocation in Java is crucial before moving to dynamic structures like ArrayLists or HashMaps. #DSA #Java #ArrayBasics
Java Arrays: Declare, Initialize, Access, Traverse
More Relevant Posts
-
Day 82 – Univalued Binary Tree Solved a problem to determine whether all nodes in a binary tree have the same value using depth-first traversal. Key Learnings: Applied DFS recursion to traverse all nodes in the tree Compared each node’s value with the root value for validation #DSA #Java #BinaryTree #DFS #Recursion #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
🚀 Day 35/50 – #50DaysOfCode Today, I learned about array concatenation, array slicing, and multidimensional arrays in Java, along with how to iterate over multidimensional arrays. These concepts help in handling complex data structures more efficiently. ☕💻 #Day35 #JavaFullStack #Java #CCBP #NxtWave #LearningJourney #Consistency
To view or add a comment, sign in
-
Most Java performance issues don’t show up in code reviews They show up in object lifetimes. Two pieces of code can look identical: same logic same complexity same output But behave completely differently in production. Why? Because of how long objects live. Example patterns: creating objects inside tight loops → short-lived → frequent GC holding references longer than needed → objects move to old gen caching “just in case” → memory pressure builds silently Nothing looks wrong in the code. But at runtime: GC frequency increases pause times grow latency becomes unpredictable And the worst part? 👉 It doesn’t fail immediately. 👉 It degrades slowly. This is why some systems: pass load tests work fine initially then become unstable weeks later Takeaway: In Java, performance isn’t just about what you do. It’s about how long your data stays alive while doing it. #Java #JVM #Performance #Backend #SoftwareEngineering
To view or add a comment, sign in
-
Day 78 - Binary Tree Level Order Traversal Implemented level-by-level traversal of a binary tree using a queue (BFS). Approach: • Use a queue to process nodes • Traverse level by level • Track size of each level • Store values accordingly Time Complexity: O(n) Space Complexity: O(n) #Day78 #LeetCode #BinaryTree #DSA #Java #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 60 of #100DaysOfCode Solved 100. Same Tree on LeetCode 🔗 🧠 Key Insight: Two trees are the same if: 👉 Their structure is identical 👉 Corresponding nodes have equal values ⚙️ Approach (Recursive DFS): 1️⃣ If both nodes are null → ✅ return true 2️⃣ If one is null and other is not → ❌ return false 3️⃣ If values are different → ❌ return false 4️⃣ Recursively check: 🔹 Left subtree → isSame(p.left, q.left) 🔹 Right subtree → isSame(p.right, q.right) 5️⃣ Return: 👉 leftCheck && rightCheck ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(h) (recursive stack) #100DaysOfCode #LeetCode #DSA #BinaryTree #Recursion #DFS #Java #InterviewPrep #CodingJourney
To view or add a comment, sign in
-
-
Day 66 — LeetCode Progress (Java) Problem: Find the Difference of Two Arrays Required: Given two integer arrays, return: Elements present in nums1 but not in nums2 Elements present in nums2 but not in nums1 Idea: Use sets to remove duplicates and quickly check membership. Approach: Convert both arrays into sets Iterate over nums1 set: Add elements not present in nums2 set to result1 Iterate over nums2 set: Add elements not present in nums1 set to result2 Return both lists Time Complexity: O(n + m) Space Complexity: O(n + m) #LeetCode #DSA #Java #HashSet #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 84 - Binary Tree Right Side View Computed the visible nodes when viewing a binary tree from the right side. Approach: • Use level order traversal (BFS) • Process nodes level by level • Add the last node of each level to the result Key Idea: The rightmost node at each level is the visible one Time Complexity: O(n) Space Complexity: O(n) #Day84 #LeetCode #BinaryTree #BFS #DSA #Java #CodingJourney
To view or add a comment, sign in
-
-
Day 63 — LeetCode Progress (Java) Problem: Crawler Log Folder Required: Given a list of folder operations, return the minimum number of operations needed to go back to the main folder. Idea: Track the current depth like a counter — move forward increases depth, move back decreases depth, and staying does nothing. Approach: Initialize a variable to track current depth. Traverse each log: "../" → move up (decrease depth, but not below 0) "./" → stay in the same folder "x/" → move into a subfolder (increase depth) Final depth represents the number of steps needed to return to the main folder. Time Complexity: O(n) Space Complexity: O(1) #LeetCode #DSA #Java #Simulation #Strings #Algorithms #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🌱 A Small Step in My DSA Journey (Java) As part of my ongoing Data Structures practice, I recently worked on a problem: 👉 Converting a Binary Tree into a Linked List (in-place) using Java This helped me strengthen my understanding of: • Preorder traversal and its practical use • Managing pointers carefully without losing node references • Modifying data structures efficiently without extra space 💡 One key realization: Writing code is one part—but understanding how data flows through the structure makes the real difference. Practiced implementing this using Java and gained better clarity on pointer manipulation. Taking it one step at a time and building stronger fundamentals 🚀 #Java #DataStructures #DSA #BinaryTree #ProblemSolving #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Day 70 of #100DaysOfCode Solved 107. Binary Tree Level Order Traversal II on LeetCode 🔗 🧠 Key Insight: This is just level order traversal (BFS) but: 👉 Return levels from bottom to top instead of top to bottom ⚙️ Approach (DFS with Level Tracking): 1️⃣ Start traversal with level = 0 2️⃣ For each node: 🔹 If level not present → insert new list at front 🔹 Add value at correct position: 👉 res.get(res.size() - 1 - level) 3️⃣ Recurse: 🔹 Left → level + 1 🔹 Right → level + 1 ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) #100DaysOfCode #LeetCode #DSA #BinaryTree #BFS #DFS #Java #InterviewPrep #CodingJourney
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