Leetcode Challenge Problem 347:Top K Frequent Elements (https://lnkd.in/g_3piXcG) ✨Today while reviewing other submissions at the end, I learned instead of write your own method from scratch like the second loop in this code is unnesscary instead i could use slice method to limit the number of values i could get. 🔧 From line number 14 to 21 could be replaced by the builtin functions and optimized solution, i have attached in second screenshot, do give it a look. Give your reviews. #100daysofcodechallenge #coding #programmer #problems #leetcode #neetcode #dsa #algorithm #typescript #maps #leetcode347 #leetcodeproblems
Muhammad Azim Amjad’s Post
More Relevant Posts
-
🚀 𝗗𝗮𝘆 𝟰: Just tackled LeetCode Problem 27: a classic challenge, 𝗥𝗲𝗺𝗼𝘃𝗲 𝗘𝗹𝗲𝗺𝗲𝗻𝘁! 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: Given an integer array 𝗻𝘂𝗺𝘀 and an integer 𝘃𝗮𝗹, remove all occurrences of 𝘃𝗮𝗹 in 𝗻𝘂𝗺𝘀 in-place. The relative order of the elements may be changed. I used a two-pointer technique to efficiently process the array, keeping track of elements that should remain. One pointer iterates through each element, while the other pointer helps overwrite positions where the target value is found, effectively "removing" elements in-place. This approach kept the solution fast and memory-efficient, as required by the problem constraints. 📍 Excited to keep growing my skills one problem at a time. LeetCode, bring on the next challenge! #LeetCode #CodingJourney #DataStructures #Algorithms #Cpp #DSA #RemoveElement #Programming #DailyLearning #Developer #ProblemSolving
To view or add a comment, sign in
-
🚀 Just solved another LeetCode problem using C++ 💡✨ 🧠 Problem: Rotate Array 🔗 Link: https://lnkd.in/gd6p8ZdH 💡 Solution Approach: Without using any built in method. 🤓 Time complexity: O(n) 🤓 Space complexity: O(n) #LeetCode #ProblemSolving #Coding #Programming #Tech #Algorithm #LinkedInLearning #dsa #backend #challange
To view or add a comment, sign in
-
Almost 60 ;-) Some of the recent and good problems are :- 1451. Rearrange Words in a Sentence link :- https://lnkd.in/gGtUjmNq ----- 1679. Max Number of K-Sum Pairs Link:- https://lnkd.in/gzVjWrV3 ----- 56. Merge Intervals Link:- https://lnkd.in/gEHcKSwS Must give Try to these problems ☝️ #LeetCode #100DaysOfCode #softwaredevelopment #programming #Algorithm #dsa #DataStructures #coding #codingchallenge #geekforgeeks #programmers #code #Motivation
To view or add a comment, sign in
-
🚀 Day 2: LeetCode Problem of the Day Series 🚀 Problem: Linked List in a Binary Tree 🧠 Intuition Today’s problem involves checking if a linked list is a subpath of a binary tree. The challenge is to trace the list along the tree's branches and find if it matches a downward path starting from any node. The key insight here is that we need to compare the linked list with multiple potential starting points in the binary tree. 🔍 Approach 1️⃣ Traverse the binary tree and, for each node, initiate a DFS if the value matches the head of the linked list. 2️⃣ The DFS will recursively compare the linked list with the tree’s branches, checking both left and right subtrees. 3️⃣ The search continues until either the linked list is fully matched, or we exhaust all potential starting points in the tree. ⬇️ Question link:https://lnkd.in/dxVbfMdY ⬇️ Solution link: https://lnkd.in/diKd49NH #leetcode #coding #problemsolving #programming #binarytree #linkedlist #dfs #dynamicprogramming #codingchallenge #leetcodechallenge
To view or add a comment, sign in
-
🚀 Solved the 3Sum Problem on LeetCode! "Day 29 of #100DaysOfCode Challenge!" Today, I tackled the classic 3Sum problem on LeetCode and implemented an efficient solution using the two-pointer technique. The challenge was to find all unique triplets in an array that sum up to zero. Approach: Sorting the array followed by a two-pointer technique to find triplets. https://lnkd.in/g29UEZF6 Complexity: Optimized the solution to run in 𝑂(𝑛2) O(n2 ) time complexity. Edge Cases: Handled duplicates to ensure each triplet is unique. Here's a brief summary of my solution: Sort the Array: Helps in using the two-pointer approach effectively. Two-Pointer Technique: Iterate with a fixed element and use two pointers to find pairs that sum to zero. Duplicate Handling: Skipped over duplicates to avoid repeating triplets. #LeetCode #Algorithm #ProblemSolving #Coding #Programming #Java
To view or add a comment, sign in
-
Leetcode problem of the day : The probelm that we are tackling for today is to reverse a given character array char[] s in place, meaning you should modify the input array directly without using additional space for another array. Approach used: 1. Two-Pointer Technique: Utilize two pointers, start and end. Initialize start at the beginning (index 0) and end at the last character (index n-1). 2. Swap Elements: Swap the characters at the start and end pointers. 3. Move Pointers: Increment the start pointer and decrement the end pointer. 4. Loop Until Complete: Continue the process until the start pointer is greater than or equal to the end pointer. Time Complexity : O(N) Space Complexity : O(1) Link : https://lnkd.in/gXmWT-HW I hope you find this approach useful! Feel free to share your thoughts or alternative methods in the comments below. Let's keep learning and growing together! 💡 ✨ #Java #Programming #Coding #Tech #SoftwareDevelopment #ProblemSolving #Algorithms #DSA #CodingJourney #CodingChallenge #DataStructuresAndAlgorithms #LeetcodeDailyChallenge #CompetativeProgramming #Consistency 💪🏻❤
To view or add a comment, sign in
-
🚀 solved another LeetCode problem using C++ 💡✨ 🧠 Problem: Summary Ranges (Leetcode - 228) 🔗 Link: https://lnkd.in/g9TMyueg 🤓 Time complexity: O(n) 🤓 Space complexity: O(1) #LeetCode #ProblemSolving #Coding #Programming #Tech #Algorithm #LinkedInLearning #dsa #backend #challange
To view or add a comment, sign in
-
#30DayProblemSolvingChallenge 𝗗𝗮𝘆 𝗙𝗶𝗳𝘁𝗲𝗲𝗻: 🚀 Solved 𝗦𝗼𝗿𝘁 𝗧𝗵𝗲 𝗣𝗲𝗼𝗽𝗹𝗲 #Leetcode problems using C++ 💡✨ 𝗦𝗼𝗿𝘁 𝗧𝗵𝗲 𝗣𝗲𝗼𝗽𝗹𝗲: 📂𝗧𝗼𝗽𝗶𝗰: Heap, String ⌛ 𝗧𝗶𝗺𝗲 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆: O(n) 💾 𝗦𝗽𝗮𝗰𝗲 𝗖𝗼𝗺𝗽𝗹𝗲𝘅𝗶𝘁𝘆: O(n) #ProblemSolving #Coding #Programming #Tech #Algorithm #frontend #DSA #Backend #Challenge
To view or add a comment, sign in
-
2490. Circular Sentence (LeetCode) In this problem you are required to check if the sentence is circular. Wich means that the first and last letters of the sentence are equal as well as the end of every last letter with the word after it. EXAMPLE: "leetcode exercises sound delightful" is circular. "Leetcode is cool" is not circular. The fastest way to do it is first checking the first and last character and then looping on the string and when encounter a space we check if the characters before and after it are equal to each other. if they aren't we return false. #leetcode #codinginterview #techinterview #algorithm #programming #leetcodeproblems #softwareengineering #codingchallenge #interviewprep #leetcodecommunity
To view or add a comment, sign in
-
🚀 LeetCode100 : Problem #6 - 58. Length of Last Word 🧠 Approach : find the length of the last word in a string, trim any leading or trailing spaces, then iterate from right to left counting characters until encountering a space. 📊 Complexity Analysis: Time Complexity: O(n). Space Complexity: O(1). #Leetcode #Algorithm #Java #DataStructures #String #Length #Programming #Coding Happy LeetCoding! 💻✨
To view or add a comment, sign in