@Value + Lifecycle Annotations The @Value annotation injects constants, property values, or expressions. It simplifies configuration by externalizing values cleanly. With @PostConstruct, you can initialize resources after dependencies load. @PreDestroy helps you release resources before shutdown. Together they ensure smooth object setup and cleanup. #SpringFramework #Java #SoftwareEngineering #BackendDevelopment
How to use @Value, @PostConstruct, and @PreDestroy in Spring Framework
More Relevant Posts
-
#100DaysOfCode – Day 80 Reverse Linked List Problem: Given the head of a singly linked list, reverse the list and return the reversed version. Example: Input: [1, 2, 3, 4, 5] Output: [5, 4, 3, 2, 1] My Approach: Used an iterative method to reverse the list efficiently by manipulating pointers. Initialized three pointers prev, temp, and front. Iteratively reversed each node’s direction until the end of the list was reached. Returned prev as the new head of the reversed list. Time Complexity: O(N) Space Complexity: O(1) Reversing a linked list might look tricky at first, but once you understand pointer manipulation it’s pure logic and flow. #takeUforward #100DaysOfCode #DSA #Java #ProblemSolving #LeetCode #LinkedList #Pointers #CodeNewbie
To view or add a comment, sign in
-
-
🚀 𝐃𝐚𝐲 9 𝐨𝐟 𝐦𝐲 #100𝐃𝐚𝐲𝐬𝐎𝐟𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 𝐏𝐫𝐨𝐛𝐥𝐞𝐦𝐬 𝐒𝐨𝐥𝐯𝐞𝐝 𝐓𝐨𝐝𝐚𝐲 : 🔥 1️⃣ Leetcode (Medium) – Product of Array Except Self 💡 Key Idea: Instead of using division, use Prefix and Suffix Products. Prefix → product of all elements before the current index Suffix → product of all elements after the current index Multiply both to get the result for each element. 🧾 Time Complexity: O(n) ⚙️ Space Complexity: O(1) #DSA #Java #100DaysOfCode #ProblemSolving #LearningInPublic #SortingAlgorithms #CodingJourney
To view or add a comment, sign in
-
-
🚀Day 29/100 - Problem of the day :- Minimum Number of Increments on Subarrays to Form a Target Array. 🎯 Goal: Solve the “Minimum Number of Increments on Subarrays to Form a Target Array” problem efficiently on LeetCode. 💡 Core Idea: The key observation is that we only need to add operations when the current element is greater than the previous one. So, the total operations = target[0] + sum(max(target[i] - target[i-1], 0)). This approach ensures we only count necessary increments, avoiding redundant steps. 🎯 Key Takeaway: By focusing on the difference between consecutive elements, we transform a complex problem into a simple linear pass — achieving both clarity and top performance. ✅ Passed all 129 test cases 🚀 Runtime beats 100% of Java submissions 💾 Space Complexity: O(1) — constant extra space used. ⏱ Time Complexity: O(n) — single pass through the array. #Java #DSA #ProblemSolving #Day29 #Leetcode #CodingJourney #100DaysChallenge
To view or add a comment, sign in
-
-
Day 44/100 – #100DaysOfCode 🚀 | #Java #LinkedList ✅ Problem Solved: Reverse Nodes in k-Group (LeetCode 25) 🧩 Problem Summary: Given a linked list, reverse every group of k consecutive nodes. If the last group has fewer than k nodes, leave it as is. 💡 Approach Used: We first count whether k nodes exist — only then we reverse that segment. Steps: Traverse ahead k nodes to ensure reversal is possible. Reverse exactly k nodes iteratively. Recursively process the remaining list. Connect the reversed part with the next processed segment. This allows efficient in-place operations without extra memory. ⚙️ Time Complexity: O(n) 📦 Space Complexity: O(1) (Reversing done in-place) ✨ Takeaway: This problem strengthens understanding of pointer manipulation and linked list segment handling — vital for clean and bug-free list operations. #Java #LinkedList #Pointers #Recursion #LeetCode #ProblemSolving #100DaysOfCode #CodingChallenge
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 85 Delete the Middle Node of a Linked List Problem Statement: Given the head of a singly linked list, delete the middle node and return the modified list. My Approach: Used two-pointer technique (slow & fast) to identify the middle node in a single traversal. Maintained a prev pointer to skip the middle node without extra space. Carefully handled the edge case when the list has only one node. Complexity: Time: O(N) Space: O(1) Linked lists are all about pointers and precision a small mistake (like an extra semicolon ";") can make a huge difference. Understanding how slow and fast pointers move gives deep insight into efficient traversal patterns. #LeetCode #100DaysOfCode #Java #LinkedList #ProblemSolving #takeUforward #CodingJourney #DataStructures #CodeNewbie
To view or add a comment, sign in
-
-
Day 50/100 – #100DaysOfCode 🚀 | #Java #Arrays #GreedyApproach ✅ Problem Solved: Minimum Operations to Convert All Elements to Zero (LeetCode) 🧩 Problem Summary: You’re given an array of integers. In one operation, you can subtract the smallest non-zero value from every non-zero element. Return the number of operations needed to make all elements zero. 💡 Approach Used: Instead of simulating operations (which would be inefficient), observe: Each distinct positive value in the array contributes exactly one operation. Because removing the smallest non-zero repeatedly is equivalent to counting how many unique positive values exist. So, Answer = Count of unique positive elements Why this works: Each distinct positive number represents one “level” of reduction until zero. ⚙️ Time Complexity: O(N) 📦 Space Complexity: O(N) (for set) ✨ Takeaway: This problem highlights how pattern recognition and mathematical simplification often outperform brute-force logic. #Java #LeetCode #MathLogic #GreedyAlgorithm #ProblemSolving #100DaysOfCode #CodingChallenge
To view or add a comment, sign in
-
-
Day 29/100 – #100DaysOfCode 🚀 | #Java #LeetCode #BinaryTree ✅ Problem Solved: Verify Preorder Serialization of a Binary Tree 🌲 🧩 Problem Summary: Given a string representing a preorder serialization of a binary tree, determine if it’s valid. Example: "9,3,4,#,#,1,#,#,2,#,6,#,#" → ✅ valid "1,#" → ❌ invalid 💡 Approach Used: Used the slot-counting method 🧠 Each node uses one slot and non-null nodes create two new slots. Process the preorder string, ensuring slots never go negative and exactly zero remain at the end. ⚙️ Time Complexity: O(n) 📦 Space Complexity: O(1) ✨ Takeaway: This problem teaches how binary tree structure can be validated with simple counting logic — no need to rebuild the tree! 🌱 #Java #LeetCode #BinaryTree #100DaysOfCode #ProblemSolving #CodingChallenge
To view or add a comment, sign in
-
-
#100DaysOfCode – Day 81 Linked List Cycle Problem Given the head of a linked list, determine whether the list contains a cycle meaning a node’s next pointer refers back to a previous node. My Approach Used Floyd’s Cycle Detection Algorithm (Tortoise & Hare Method): Initialized two pointers slow and fast. Moved slow one step and fast two steps in each iteration. If they ever meet → cycle detected. If fast or fast.next becomes null → no cycle exists. Complexity Time: O(n) Space: O(1) Even in problems involving dynamic structures like linked lists, a simple pointer-based approach can lead to an elegant and optimal solution. #100DaysOfCode #LeetCode #Java #ProblemSolving #DataStructures #LinkedList #TortoiseAndHare #takeUforward #CodeNewbie #CodingJourney
To view or add a comment, sign in
-
-
Day 40/100 – #100DaysOfCode 🚀 | #Java #LeetCode #TwoPointers #DynamicProgramming ✅ Problem Solved: Longest Palindromic Substring 🟣 🧩 Problem Summary: Given a string, return the longest palindromic substring within it. The substring must read the same forward and backward. 💡 Approach Used: Expand Around Center Technique Every palindrome is centered around: A single character (odd length) Or between two characters (even length) For each index: Expand left and right while characters match. Track the longest substring during expansions. This avoids unnecessary recomputation and works efficiently. ⚙️ Time Complexity: O(n²) 📦 Space Complexity: O(1) ✨ Takeaway: Sometimes, the cleanest approach comes from observing patterns — in this case, symmetry around a center 🎯 #Java #LeetCode #TwoPointers #ExpandAroundCenter #ProblemSolving #100DaysOfCode #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 7️⃣7️⃣ of #100DaysOfCode Solved LeetCode Problem #1437 — Check If All 1’s Are at Least K Places Away 🔍✨ 🔧 Concept: Given a binary array, ensure that every 1 is separated by at least K zeros. The solution simply tracks the previous index of 1 and checks the distance. 🧠 Key Idea: Scan the array once When a 1 is found, verify: 👉 currentIndex - previousIndex > k If any pair violates this, return false ⚡ Efficient: Time Complexity: O(n) Space Complexity: O(1) Another clean and efficient logical problem solved. #LeetCode #Java #Arrays #ProblemSolving #DSA #CodingJourney #100DaysOfCode #DeveloperLife #Motivation
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