🚀 Day 20 of #100DaysOfCode Challenge: Today, I tackled the "Three Indices" problem, where I had to find three indices i, j, and k in a permutation such that pi<pj and pj>pk. 🧠💻 Question link : https://lnkd.in/dsd_4AGd The task was to determine if such indices exist or not in a given permutation. My approach was a simple brute-force method: I iterated through the array and checked for the condition. If the condition was met, I outputted "yes"; otherwise, "no." Github link of my solution : https://lnkd.in/dP2TvA4c I'm excited to share this approach with you and would love to hear your thoughts. If you have a different or more efficient approach, or if you'd like clarification on my method, let's connect and discuss! 🔗 #100DaysOfCode #CodingChallenge #PersonalGrowth #Consistency #Discipline #Programming #TechJourney #CodeforcesStreak #Coding #Algorithm #Optimization
Allan Santosh Joseph’s Post
More Relevant Posts
-
🚀 30-day LeetCode challenge! 🌟 🌟Day - 19🌟 Today, I tackled the "Binary Tree Level Order Traversal" problem Question Link : hhttps://lnkd.in/gQqEF9Jr Description: Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). Example 1: Input: root = [3,9,20,null,null,15,7] Output: [[3],[9,20],[15,7]] Example 2: Input: root = [1] Output: [[1]] Example 3: Input: root = [] Output: [] Github Link for code : https://lnkd.in/gv5-Vj3H #LeetCodeChallenge #CodingJourney #30DaysOfCode #SoftwareEngineering #CodingLife #Programming #JavaProgramming #DataStructures #Algorithms #ProblemSolving #keeptrying
To view or add a comment, sign in
-
🎯 Day 42 of #100DaysOfCode 🎯 ✅ Challenge Solved: 330. Patching Array 📚 Topic: Greedy Algorithms Today, I tackled a challenging problem that required patching an array to ensure all integers in a given range [1, n] could be formed by summing elements from the array. Using a greedy approach, I was able to solve the problem efficiently and learn some valuable lessons along the way. 💡 Key Takeaways: Identified how to track the smallest number that cannot be formed yet and maintain an expanding range dynamically. Optimized the solution with a combination of existing elements and calculated patches to cover the full range. Gained deeper insight into applying greedy algorithms to solve real-world problems effectively. Example Problem: Input: nums = [1, 3], n = 6 Output: 1 patch required (to cover the full range [1, 6]). What I Loved: The elegance of the solution that emerged through logical reasoning. A perfect runtime on submission—always a rewarding feeling! 🚀 Looking forward to continuing my coding journey and tackling more challenging problems in the days ahead. ✨ #100DaysOfCode #Coding #Programming #LeetCode #Algorithms #ProblemSolving #VITBhopalLions #DrGVishwanathanChallenge
To view or add a comment, sign in
-
🌟 Day 42 of #50Days50LeetCodeProblems 🌟 Today, I solved the "First Bad Version" problem, another classic binary search challenge! Problem Objective: 1️⃣ Identify the first bad version in a series of versions. 2️⃣ Utilize the provided API isBadVersion(version) to determine if a version is bad. Approach: 🔹 Binary Search for Efficiency: Narrowed the search space by comparing the middle version with the API result. Adjusted the search bounds (left and right) accordingly. Achieved logarithmic time complexity O(logn)O(\log n)O(logn). 🔹 Edge Case Handling: Considered scenarios where the first version itself is bad. Key Learnings: ✨ Reinforced understanding of binary search in decision-making problems. ✨ Improved skills in balancing time efficiency with API constraints. ✨ Enhanced problem-solving abilities through iterative debugging. 🔗 Check out my solution on GitHub: [https://lnkd.in/dB3QFgDP] #LeetCode #BinarySearch #Programming #CodingChallenge #50DaysChallenge #TechLearning #ProblemSolving #Algorithms #DataStructures #CodeNewbie
To view or add a comment, sign in
-
🚀 Day 26 of #100DaysOfCode Challenge: Today, I tackled the "Odd Queries" problem, where I had to determine if changing elements in a range of an array to a specific value would result in the sum of the entire array being odd! 🧠💻 Question link : https://lnkd.in/gf3X7Qzk In this problem, I devised a straightforward approach. I calculated the sum of the new (l-r) elements after changing them to k, which would be (k*(l-r+1)). Then, I used the prefix sum method to calculate the sum of the rest of the array. Github link of my solution : https://lnkd.in/gmKn-KzM I'm excited to share this approach with you and would love to hear your thoughts. If you have a different or more efficient approach, or if you'd like clarification on my method, let's connect and discuss! 🔗 #100DaysOfCode #CodingChallenge #PersonalGrowth #Consistency #Discipline #Programming #TechJourney #CodeforcesStreak #Coding #Algorithm #Optimization
To view or add a comment, sign in
-
🔢 LeetCode Problem #1331: Rank Transform of an Array Today, I implemented an efficient solution in C to solve the Rank Transform of an Array problem. My approach involved designing a custom structure to pair each array value with its original index. I utilized the qsort function to sort the array by value and then assigned ranks, ensuring that duplicate values receive the same rank. This method optimizes both accuracy and performance. By leveraging effective sorting and data handling techniques, this solution highlights the importance of algorithmic precision in problem-solving. Excited to continue honing my skills! Git: https://lnkd.in/g2jPgKsz Leetcode: https://lnkd.in/gJgptwW8 #LeetCode #CProgramming #Algorithms #DataStructures #CodingChallenges #ProblemSolving #100DaysOfCode #SoftwareEngineering #TechSkills #CodeMaster #Programming #DevCommunity #CodingLife #CompetitiveProgramming #LearnToCode #CodeNewbie #TechInnovation
To view or add a comment, sign in
-
🌟 Day 62/75 of #75DaysOfCode 🌟 🚀 Problem Solved: Binary Tree Preorder Traversal 🚀 🔢 Problem 144 - Binary Tree Preorder Traversal Difficulty: Easy I'm excited to share that I've successfully tackled a key problem in tree traversal: the preorder traversal of a binary tree! This traversal method involves visiting the root node first, then the left subtree, and finally the right subtree. Problem Summary: Given the root of a binary tree, return the preorder traversal of its nodes' values. My Approach: Recursive Approach: Implement a helper function to recursively visit nodes in preorder. Iterative Approach: Use a stack to emulate the recursive process, ensuring nodes are visited in the correct order. Edge Cases: Handle scenarios where the tree is empty or has only one node. Problem Link: https://lnkd.in/gVbgdH6n I'm thrilled to add this problem to my list of solved challenges. It was a great exercise in understanding and implementing tree traversal algorithms. Keep coding and solving! 🚀 #Coding #Programming #LeetCode #BinaryTree #PreorderTraversal #CodingChallenge #TechJourney
To view or add a comment, sign in
-
🚀 𝗗𝗮𝘆 𝟳: Just solved LeetCode Problem 28: a string challenge to find the 𝗜𝗻𝗱𝗲𝘅 𝗼𝗳 𝗮 𝗦𝘂𝗯𝘀𝘁𝗿𝗶𝗻𝗴’𝘀 𝗙𝗶𝗿𝘀𝘁 𝗢𝗰𝗰𝘂𝗿𝗿𝗲𝗻𝗰𝗲 in a larger string! 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: Given two strings 𝗻𝗲𝗲𝗱𝗹𝗲 and 𝗵𝗮𝘆𝘀𝘁𝗮𝗰𝗸, return the index of the first occurrence of needle in haystack, or -𝟭 if needle is not part of haystack. The task was to locate where one string (the needle) first appears in another string (the haystack). I used a straightforward iteration with the 𝘀𝘂𝗯𝗦𝘁𝗿() method to extract slices of the haystack string matching the length of the needle. Each slice was compared to the needle to check for a match, allowing me to efficiently locate the index of the first occurrence. If no match was found, the function returned -𝟭 as specified by the problem. 📍 Excited to continue tackling more problems and sharpening my skills one challenge at a time. Onward to the next! #LeetCode #CodingJourney #DataStructures #Algorithms #Cpp #DSA #FindingIndex #FirstOccurance #Programming #DailyLearning #Developer #ProblemSolving
To view or add a comment, sign in
-
🚀 𝗗𝗮𝘆 𝟴: Just solved LeetCode Problem 66: the famous one, 𝗣𝗹𝘂𝘀 𝗢𝗻𝗲! 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: You are given a non-negative integer represented as a non-empty array of 𝗱𝗶𝗴𝗶𝘁𝘀, and you need to add 𝟭 to that number. The digits are stored in reverse order (from least significant to most significant), and the goal is to return the result as an array. Here’s how I approached this: • Since we need to add 1, start from the last element of the array. • If the digit is not equal to 9, just add 1 and return the array. • If the digit is 9, set it to 0 (carry over) and move to the next digit. • If we finish the array and still have a carry (like adding 1 to [9,9,9]), prepend a 1 to the result. 📍 Feeling accomplished after solving this. Let’s keep up the momentum and tackle more challenges! #LeetCode #CodingJourney #DataStructures #Algorithms #Cpp #DSA #PlusOne #Programming #DailyLearning #Developer #ProblemSolving
To view or add a comment, sign in
-
Day 29/100 🔎 Program Solved - Maximum Number of Vowels in a Substring of Given Length 🛠️ Solution - https://lnkd.in/gYngQzWr #100daysofcodechallenge #competitiveprogramming #LeetCode #CodingJourney #Gratitude #100DaysOfCode #ConsistencyIsKey #DeveloperCommunity #Algorithm #ProgrammingAchievement #JavaProgramming #CodingSuccess #AlgorithmicChallenge #CodeChallenge #DataStructures #TechJourne #SoftwareEngineering #CodeEveryday #TechCommunity #ProgrammingGoals #AchievementUnlocked #ProblemSolving #CodingSkills
To view or add a comment, sign in
-
🚀 🚀 DAY 3 of #28daysofcode :- Hey linkedIn people!!!👋 🌟 Today, I have started revising the basic concepts of arrays(1D) .I have gone through the theory of arrays(for instance; syntax , intialisation and various operations that can be done) along with practising some questions on different platforms.. I had tackled numerous problems on leetcode to get the deeper knowledge of the concepts like :- 1. finding the first occurence of a given number(t) in a specific array. 2. finding the last occurence of a given number(t) in a specific array. 3. finding all the occurences of a given number(t) in an array. 4. reversing an array. 5.rotating an array 6.finding the three largest number present in an array. I would love to connect with you people at any hour here on the LinkedIn. You can even drop your suggestions in the following comment box.. #28daysofcode #codingchallenge #DSA #algorithms #problemsolving #dailylearning #Arrays #codingskills #techlearning #coding #programmingjourney #techskills #codelife #leetcode #codeforces
To view or add a comment, sign in
-- Full stack mern developer | B.Sc. CS student
9moKeep it up