😆 😉 #Day32 in Solving problem of the Day from GeeksforGeeks. Today's problem is from Hashing had solved successfully. 🥰 😍 From today onwards I will try to speak something on the topic which I had used to solve the #potd from GeeksforGeeks. #Hashing is all about mapping one object with another object, It had certain elements like hash map, hash set, tree set etc. Every Data structure in #Hashing had a unique properties and depends upon the requirement we will use. Problem : Remove Duplicates Topics : Hashing, Hash Set Problem Link : https://lnkd.in/g5aBDDBw Approach : 👏 First I had created a Hash Set and Hash set stores the only unique elements. 👏 Created an Array List to return the unique elements. 👏 Then Iterated the given array. 👏 If the current element is not present in set then added in the array list. and added the element into the set. #Hashing #Java #DSA #Development #Software #IT #100DaysOfCoding #Code #Coder #Coding #JavaDeveloper #PythonDeveloper #it #Work #geeksforgeeks #GFG #POTD #Google #Infosys #Creds #Wipro #tcs
Teja Chidapana’s Post
More Relevant Posts
-
🌟 💥 𝐃𝐚𝐲 13 𝐨𝐟 𝐃𝐒𝐀 𝟏𝟔𝟎 𝐃𝐀𝐘𝐒 𝐂𝐡𝐚𝐥𝐥𝐞𝐧𝐠𝐞 🌟 🎯 𝐃𝐀𝐘 13 𝐏𝐫𝐨𝐛𝐥𝐞𝐦: Missing Number ✅ 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧: The goal is to find the smallest positive integer missing from the array in O(n) time without using extra space. 🔢 Approach: 1️⃣ Rearrange the array so that each element is in its correct position (i.e., arr[i] should be i+1). 2️⃣ Iterate through the array and check if the value at each index matches its expected value (i+1). 3️⃣ If a mismatch is found, the missing number is i+1. 4️⃣ If no mismatch exists, the missing number is n+1. ✅ Code in Java: class Solution { public int missingNumber(int[] arr) { int n = arr.length; for (int i = 0; i < n; i++) { while (arr[i] > 0 && arr[i] <= n && arr[arr[i] - 1] != arr[i]) { int temp = arr[arr[i] - 1]; arr[arr[i] - 1] = arr[i]; arr[i] = temp; } } for (int i = 0; i < n; i++) { if (arr[i] != i + 1) { return i + 1; } } return n + 1; } } ✅ WHY THIS APPROACH: This method uses the Cyclic Sort algorithm to rearrange elements in their correct positions without additional space. It ensures a time complexity of O(n), making it optimal for finding the missing number. 🌟 𝐇𝐢𝐠𝐡𝐥𝐢𝐠𝐡𝐭𝐬 Successfully implemented the Missing Number problem using Cyclic Sort. This problem was a fantastic exercise in understanding in-place sorting and efficient number positioning techniques. Excited to keep the streak alive and conquer more challenges in the next 160 days! 🚀 A big thanks to GeeksforGeeks for this amazing challenge. Let’s continue pushing boundaries and growing together! #DSA #DSAChallenge #MissingNumber #CyclicSort #GeeksforGeeks #GeekStreak2024 #Java #ProblemSolving #Learning #160DaysChallenge #gfg160
To view or add a comment, sign in
-
🌟 💥 𝐃𝐚𝐲 8 𝐨𝐟 𝐃𝐒𝐀 𝟏𝟔𝟎 𝐃𝐀𝐘𝐒 𝐂𝐡𝐚𝐥𝐋𝐞𝐧𝐠𝐞 🌟 🎯 𝐃𝐀𝐘 8 𝐏𝐫𝐨𝐛𝐥𝐞𝐦: Stock Buy and Sell – Max one Transaction Allowed ✅ 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧: The problem is solved by tracking the minimum price seen so far and calculating the maximum profit from a single transaction in O(n) time. 🔢 Approach: 1️⃣ Initialize the min price with the first price and the initial profit as 0. 2️⃣ Traverse the array, and for each price, calculate the potential profit if you sell at that price (i.e., the difference between the current price and the minimum price encountered so far). 3️⃣ Update the min price if a lower price is found. 4️⃣ Keep updating the profit with the highest possible profit at each step. ✅ Code in Java: java Copy code class Solution { public int maximumProfit(int prices[]) { int min = prices[0]; int profit = 0; int tempProfit = 0; for (int i = 1; i < prices.length; i++) { if (min < prices[i]) { tempProfit = prices[i] - min; } else { min = prices[i]; } if (tempProfit > profit) { profit = tempProfit; } } return profit; } } ✅ WHY THIS APPROACH: This approach ensures an optimal solution by focusing on maximizing the profit from a single transaction, ensuring O(n) time complexity and minimal space complexity. 🌟 𝐇𝐢𝐠𝐡𝐥𝐢𝐠𝐡𝐭𝐬 Successfully implemented an efficient solution for calculating the maximum profit from a single stock transaction, handling edge cases like constant or decreasing price trends. Excited to continue the streak and learn more every day! 🚀 A big thanks to GeeksforGeeks #gfg160 for this challenge. Let’s keep learning and growing together! #DSA #DSAChallenge #StockBuyAndSell #MaxOneTransaction #GeeksforGeeks #GeekStreak2024 #Java #ProblemSolving #Learning #160DaysChallenge #Algorithm
To view or add a comment, sign in
-
🎉 Day 27 of My Coding Journey 🎉 Today, I want to take a moment to remember Ratan Tata, a visionary leader and a true icon of Indian industry. His contributions to the business world and his commitment to social causes will always inspire us. Moving on to my coding journey, another day filled with challenges! Today was all about exploring different coding concepts, refining my problem-solving approach, and continuing to push my boundaries. Here's what I tackled: 🖥 Task 1: Java ArrayList - HackerRank I dove into dynamic arrays with Java's ArrayList today. This was all about creating lists, handling variable-length input, and answering queries. It was fun to see how flexible ArrayLists can be compared to traditional arrays, and it helped me improve my understanding of Java’s collection framework. 📚 Task 2: DSA ArrayList - Data Structures and Algorithms Today’s DSA focus was on using ArrayLists for various operations, like insertion and deletion. Understanding how these lists can optimize certain operations in algorithms reinforced my knowledge of dynamic data structures and their efficiency in real-world applications. 🔢 Task 3: GeeksforGeeks Problem of the Day - Max Distance Between Same Elements This problem was all about finding the maximum distance between two occurrences of the same element in an array. It required careful tracking of indices and optimizing the solution for better performance. A neat problem that sharpened my approach to array-based algorithms! 💻 Task 4: SQL - Aggregation Worked with SQL to dive deeper into aggregation functions, practicing GROUP BY, SUM, COUNT, and more. It was amazing to see how these functions allow us to process and summarize data meaningfully, particularly in large datasets. The challenge made me more comfortable with handling data aggregation tasks. 💪 Day 27 complete, and it was filled with both Java and SQL goodness! Tackling a diverse set of challenges is making me more versatile as a developer. Ready for more learning and growth tomorrow! #Day27 #CodingJourney #Java #ArrayList #GeeksforGeeks #DSA #SQL #LearningEveryday #100DaysOfCode #KeepGoing
To view or add a comment, sign in
-
"🚀 Just completed 50 questions on Java & Data Structures/Algorithms on GeeksforGeeks! ✨It’s been an exciting journey full of learning, but it hasn’t come without its fair share of challenges. From debugging countless errors to overcoming tricky mistakes, each problem taught me something new and helped me improve as a coder. 🙌🏻This experience has reinforced that growth isn’t just about the wins but also about embracing the process, learning from failures, and moving forward stronger. 🙂 Grateful for the progress so far and excited for the road ahead! 💻 #Java #DSA #GeeksforGeeks #ProblemSolving"
To view or add a comment, sign in
-
Hello every #Java #DSA #learners. This is Udit Namdev. Today I am very 🚀 Excited to share my latest GeeksForGeeks solution with you all! 💡 based on #BitManipulation and #Strings in #Java. This is the ... #Day22 of the Coding Contest is now live! Test your coding skills with today's challenge from #GeeksForGeeks and #LeetCode too. The challenge problem is " To check Given Binary String is Multiple of 3 or not" . This is Basically BitManipulation Based #question in java where we need to check the Given binary number is divisible by 3 or no. Participate in the contest and see what you're made of. #Question's Link :- https://lnkd.in/dJiRaZKy #Algorithm and #Approach :- * Here we need to extract each character from the given #Strings. * Now count all the 1's which are at even index in the Given string and similarly for odd. * Now take the absolute difference of both count variables. * Check if this difference is divisible by 3 then the number is also divisible by 3. #Suggestions :- If you have the better approach to solve this question or any another way so please also share your idea with me. I have participated in this contest to solve the #problmes on #DSA. Participate you also in this #Challenge and see what you made off. The key of Success is not only Practice also Mistakes makes us more clear and confidant person. Start you journey with thes wonderful challenges daily and let's see what happened. #GeeksForGeeks #Strings #MicroSoft #LinkedIn #Google #Youtube #leetcodechallenge #leetcodestreak #leetcode2024 #leetcodeinjava #coding #java #javadevelopers #dsa #dsainjava #microsoft #google #linkdin #dsachallenge #coding #codingthinker #OOPs #Getters #Setters #Constructors #dailyPractice #dailyChallenge #challenge #coder #codingThinker #hackerrank #GeeksForGeeks #recursion.
To view or add a comment, sign in
-
"Day 4 of the #GeeksforGeeks 160-day #DSA challenge completed! 🚀 Solved the 'Rotate Array from D Place' problem today. Every day is a step closer to mastering #DataStructures and #Algorithms. Excited for what's next! 💻 #CodingJourney #ProblemSolving #KeepLearning #Java #GFG" GeeksforGeeks
To view or add a comment, sign in
-
Namaste Duniya, Day 9/75: 4th Day with Recursion with Priya Bhatia Today, on Day 9 of the challenge, I chose to prioritize consolidating my understanding of recursion rather than exploring new concepts. Feeling under the weather and grappling with confidence in recursion, I revisited all related topics through a focused revision session. With a calm and determined mindset, I diligently reviewed fundamental concepts, solved practice problems, and honed my skills. Though the day didn't bring new revelations, it offered an invaluable opportunity to reinforce my understanding and bolster my confidence in recursion. Despite the challenges, I embraced the opportunity to tackle a new problem: balanced parenthesis. Leveraging my strengthened understanding, I approached the task methodically, achieving a successful outcome. #CodingJourney #Java #dsachallenge #Recusrion #75dayshardchallenge
To view or add a comment, sign in
-
🌟 💥 𝐃𝐚𝐲 10 𝐨𝐟 𝐃𝐒𝐀 𝟏𝟔𝟎 𝐃𝐀𝐘𝐒 𝐂𝐡𝐚𝐥𝐥𝐞𝐧𝐠𝐞 🌟 🎯 𝐃𝐀𝐘 10 𝐏𝐫𝐨𝐛𝐥𝐞𝐦: Maximum Sum Subarray (Kadane's Algorithm) ✅ 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧: This problem is solved using Kadane’s Algorithm, an efficient approach to find the largest sum of a contiguous subarray in O(n) time. 🔢 Approach: 1️⃣ Initialize two variables: max_sum to track the maximum subarray sum ending at the current index. res to store the overall maximum sum. 2️⃣ Iterate through the array: Update max_sum as the maximum of max_sum + current element and current element. Update res to hold the maximum of max_sum and its current value. 3️⃣ Return res as the maximum sum of the subarray. ✅ Code in Java: class Solution { int maxSubarraySum(int[] a) { int max_sum = a[0]; int res = a[0]; for (int i = 1; i < a.length; i++) { max_sum = max(max_sum + a[i], a[i]); res = max(res, max_sum); } return res; } int max(int a, int b) { return (a > b) ? a : b; } } ✅ WHY THIS APPROACH: Kadane’s Algorithm efficiently computes the maximum subarray sum with a single pass through the array, ensuring O(n) time complexity. It is a widely used technique in competitive programming for solving subarray problems. 🌟 𝐇𝐢𝐠𝐡𝐥𝐢𝐠𝐡𝐭𝐬 Successfully implemented Kadane’s Algorithm for identifying the maximum sum subarray, with a clean and optimized solution. Handling edge cases like negative arrays was also achieved effectively. Excited to stay consistent and keep building skills every day! 🚀 A big thanks to GeeksforGeeks for this challenge. Let’s keep growing and excelling together! #DSA #DSAChallenge #MaximumSumSubarray #KadanesAlgorithm #GeeksforGeeks #GeekStreak2024 #Java #ProblemSolving #Learning #160DaysChallenge #gfg160 #Algorithm
To view or add a comment, sign in
-
🎉 Exciting Update! 🎉 Today marks a significant milestone in my journey - I've completed the GeeksforGeeks 100 Days DSA in Java Challenge! 🚀💯 Over the past 100 days, I've delved deep into the world of Data Structures and Algorithms, mastering key concepts and sharpening my problem-solving skills using Java. From arrays to dynamic programming, each day presented new challenges and opportunities for growth. I'm immensely grateful for the support and encouragement from the GeeksforGeeks community and my peers who have been a constant source of inspiration throughout this journey. Here are some highlights from my 100-day journey: 📚 Explored a wide range of DSA topics, including linked lists, trees, graphs, sorting algorithms, and more. 💻 Solved numerous practice problems and challenges, honing my coding skills and improving efficiency. 🌟 Celebrated victories and learned valuable lessons from setbacks, fostering resilience and determination. 🤝 Connected with like-minded individuals, sharing insights and fostering meaningful collaborations. As I reflect on this achievement, I'm excited to continue applying my newfound knowledge and skills to real-world projects and challenges. Thank you, GeeksforGeeks, for providing such a comprehensive and invaluable learning experience! Here's to many more milestones ahead! 🥂 #GeeksforGeeks #DSA #Java #100DaysChallenge #DataStructures #Algorithms #CodingJourney #ProfessionalDevelopment #AchievementUnlocked
To view or add a comment, sign in
-
👋 Hello, everyone! Hope you’re doing great! 😊 🌟 Day 12/160: #GFG160 Challenge - 160 𝐃𝐚𝐲𝐬 𝐨𝐟 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐢𝐧𝐠! 🌟 🎯 Today, I tackled another interesting problem on GeeksforGeeks - Maximum Circular Subarray Sum Using Kadane’s Algorithm. The goal is to find the maximum sum of a subarray, where the subarray can either be normal or circular. ✨ Approach: 1️⃣ Initialization: 🔹totalSum: To store the sum of all array elements. 🔹currMaxSum and maxSum: To calculate the maximum subarray sum. 🔹currMinSum and minSum: To calculate the minimum subarray sum. 2️⃣ Traverse the Array: 🔹For each element arr[i]: 🔹Update currMaxSum: The maximum between extending the current subarray or starting fresh. 🔹Update maxSum: The global maximum subarray sum encountered so far. 🔹Update currMinSum: The minimum between extending the current subarray or starting fresh. 🔹Update minSum: The global minimum subarray sum encountered so far. 🔹Update totalSum by adding the current element. 3️⃣ Handle Edge Case: 🔹If minSum == totalSum, all elements are negative. In this case, the circular subarray sum would be 0, which is invalid. Return maxSum. 4️⃣ Return the Result: 🔹The final result is the maximum of maxSum (non-circular case) and totalSum−minSum - totalSum−minSum (circular case). 💡By utilizing Kadane’s algorithm twice, we efficiently compute both normal and circular cases. Let’s stay consistent and keep this streak alive! 💪 📌 Problem Link: https://lnkd.in/dxw9hBCd 📂 GitHub repo: https://lnkd.in/ggruBeeY Let’s make these 160 days a journey of growth and learning!🚀 till then Keep learning 📖 and keep coding! 💻 #GeeksForGeeks #gfg160 #day12 #geekstreak2024 #dailydsa #practicedsa #100daysofcode #160daysofdsa #dsaproblems #java #dsawithjava #ProblemSolving #learntocode #CodingJourney #MarwadiUniversity
To view or add a comment, sign in