LeetCode Practice - 747. Largest Number At Least Twice of Others ✅ Approach (Simple Logic) 1. Read the size of the array. 2. Read array elements dynamically. 3. Find: 📌the largest number 📌its index 4. Check whether the largest number is at least twice every other number. 5. If yes → return its index Else → return -1 #LeetCode #Java #CodingPractice #ProblemSolving #DSA #Array #DeveloperJourney #TechLearning
LeetCode 747: Largest Number At Least Twice of Others
More Relevant Posts
-
🔹 Day 97 – LeetCode Practice 📌 Problem: Divide Array Into Equal Pairs (LeetCode #2206) 📊 Difficulty: Easy 🧠 Problem Overview: You’re given an integer array containing 2n elements. The goal is to check whether the array can be divided into n pairs such that: Every element is used exactly once Both elements in each pair are equal ✅ Approach Used: Sorted the array to bring identical elements together. Traversed the array while counting occurrences of each number. Verified that every number appears an even number of times, ensuring valid pairs. 📈 Submission Results: Status: Accepted ✅ Runtime: 8 ms Memory Usage: 46.94 MB 💡 Reflection: This problem is a great reminder that sorting can simplify pairing logic significantly. Once the array is ordered, validating pairs becomes straightforward and efficient. #LeetCode #ProblemSolving #Arrays #Java #DSA #CodingPractice #Consistency
To view or add a comment, sign in
-
-
#Day_64 Problem: Merge Strings Alternately (LeetCode 1768) A classic two-pointer problem that strengthens loop control 🔁 🧠 Insights: • Alternate characters from both strings • Continue appending remaining characters if lengths differ • Loop until both strings are fully processed ⚙️ Approach Used: • Use two indices i and j • Append from word1 and word2 alternately • Handle extra characters gracefully 📌 What this improved: • Two-pointer technique • Loop condition clarity • Writing clean iterative logic ✨ Simple logic, solid fundamentals. #Day63 #MergeStrings #LeetCode #Java #TwoPointers #DSA #DailyCoding
To view or add a comment, sign in
-
-
#day287 of #1001daysofcode problem statement (1895): Largest Magic Square // Used row-wise and column-wise prefix sums to validate sums efficiently, then checked diagonals only when needed. Key learning: ->Prefix sums can turn heavy nested loops into manageable checks. #DSA #Java #LeetCode #ProblemSolving Shivam Mahajan #leetcode #1001daysofcode
To view or add a comment, sign in
-
-
🚀 Day 46 of #100DaysOfCode Solved LeetCode Problem #1390 – Four Divisors 🔢 This problem focused on identifying numbers that have exactly four divisors and summing those divisors efficiently. The key challenge was optimizing divisor counting to avoid unnecessary computations. Key Learnings: -> Iterated divisors only up to √n for efficiency -> Carefully tracked divisor count and sum simultaneously -> Pruned early when divisor count exceeded four -> Reinforced number theory basics with practical optimization Language Used: Java -> Runtime: 9 ms (Beats 97.47%) -> Memory: 46.32 MB Small constraints, clean logic, and efficient pruning make a big difference 🚀 #LeetCode #Java #ProblemSolving #NumberTheory #100DaysOfCode #DSA
To view or add a comment, sign in
-
-
🚀 Day 77 of #100DaysOfLeetCode 📌 Problem: 1877. Minimize Maximum Pair Sum in Array 📊 Difficulty: Medium 🧠 Key Insight: To minimize the maximum pair sum, pair the smallest element with the largest, the second smallest with the second largest, and so on. This balances the sums and avoids any single pair becoming too large. ⚙️ Approach: Sort the array Use two pointers: i starting from the beginning j starting from the end Pair nums[i] + nums[j] and track the maximum sum Move both pointers inward until all pairs are formed ⏱️ Complexity: Time: O(n log n) Space: O(1) #LeetCode #Java #ProblemSolving #CodingChallenge #100DaysOfCode #DSA #LearningEveryday
To view or add a comment, sign in
-
-
🌟 Day 29/30 – Add Two Numbers Approach: Instead of handling multiple loops for different list lengths, I used one single loop. At each step, I: Added values from both lists (if present) Included the carry Created a new node with sum % 10 Updated carry using sum / 10 Missing nodes are treated as 0, which simplifies the logic a lot. Complexity: Time: O(max(n, m)) Space: O(max(n, m)) Key Takeaway: A dummy node + single loop can replace multiple edge-case loops and make the solution much cleaner. #DSA #LeetCode #Java #LinkedList #ProblemSolving #Day29 #30DayChallenge #Coding
To view or add a comment, sign in
-
-
#PostLog92 LeetCode 1704: Determine if String Halves Are Alike 🧵🔍 Another problem locked in, another concept strengthened ✅ This one leaned on clean string handling and a neat two-pointer approach to compare both halves efficiently ⚙️📊 Key takeaways from this problem: 🧩 Breaking problems into helper functions 🔍 Case normalization for simpler logic 🔄 Traversing from both ends with clarity Writing readable and maintainable code #LeetCode1704 #DetermineIfStringHalvesAreAlike #DSA #Java #ProblemSolving #LearningInPublic #CodingJourney
To view or add a comment, sign in
-
-
Day 8/100 – LeetCode Challenge 🚀 Problem: Implement strStr() Approach: Checked every possible starting index in haystack Matched characters one by one with needle Time Complexity: O(n × m) Space Complexity: O(1) Key takeaway: Brute-force solutions are fine when constraints allow them. Understanding the basic approach comes before optimization. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #100DaysOfLeetCode
To view or add a comment, sign in
-
-
#day283 of #1001daysofcode problem statement (0150): Evaluate Reverse Polish Notation. //Worked on Reverse Polish Notation today. This problem stays simple because of one key constraint: “The input represents a valid arithmetic expression in a reverse polish notation.” Key takeaway: -> Constraints can drastically simplify logic -> Stack is the natural fit for RPN -> Read constraints carefully #DSA #Java #LeetCode #ProblemSolving Shivam Mahajan #leetcode #1001daysofcode
To view or add a comment, sign in
-
-
Solved LeetCode 21 – Merge Two Sorted Lists ✅ Implemented an efficient solution using the two-pointer technique on linked lists. Focused on: Clean pointer manipulation Avoiding extra space Writing readable and optimized code 📌 Time Complexity: O(n + m) 📌 Space Complexity: O(1) (in-place merge) Consistent DSA practice to strengthen fundamentals and problem-solving skills 🚀 #DSA #LinkedList #LeetCode #Java #ProblemSolving
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