Leet Code 204: Medium marked Solved Today: Count primes Input: n = 10 Output: 4 Explanation: There are 4 prime numbers less than 10: 2, 3, 5, and 7. Using sieve of Eratosthenes It is the simple approach to find the prime number in the number in optimal time and space complexity. Space complexity: O(n) Time complexity: O(n*log(log(n))) #leetcode #algorithm #problemsolving #medium
Tribhuvan nath Sagar’s Post
More Relevant Posts
-
Day - 35/100 Problem: Dijkstra's shortest path Codingninjas: https://lnkd.in/eWp3npX9 #100daysofcodingchallenge #graphs #algorithms #codingninjas #consistencyiskey 😎
To view or add a comment, sign in
-
Dijkstra’s #algorithm a classic to solve the shortest path problem on positive graphs using a min-priority queue and greedy strategy https://lnkd.in/dpS-V-B3
To view or add a comment, sign in
-
🚀 Day 138/300 of #300DaysCodeChallenge Solved finding cube root using Binary Search today! 🧮 Binary Search isn’t just for arrays – it’s great for precise calculations too. 🔍 #BinarySearch #Algorithms #CodingChallenge #300DaysCodeChallenge #ProblemSolving
To view or add a comment, sign in
-
**Day 14 of #geekstreak2024** **Problem:** Given two sorted arrays `arr1` and `arr2` and an element `k`, find the element that would be at the k-th position of the combined sorted array. **Approach:** The solution iterates through both arrays, incrementing pointers and reducing `k` until the k-th element is identified. If one array is exhausted, the solution directly accesses the k-th element in the other array. #codingchallenge #geeksforgeeks #algorithms #arraymanipulation 💻🔍🔢✨
To view or add a comment, sign in
-
𝐑𝐞𝐦𝐨𝐯𝐞 𝐃𝐮𝐩𝐥𝐢𝐜𝐚𝐭𝐞𝐬 𝐟𝐫𝐨𝐦 𝐒𝐨𝐫𝐭𝐞𝐝 𝐀𝐫𝐫𝐚𝐲 𝐎𝐧 𝐋𝐞𝐞𝐭𝐜𝐨𝐝𝐞: The problem states that the number of unique elements in the array should be returned. 𝑰𝒏𝒕𝒖𝒊𝒕𝒊𝒐𝒏: * Since the array is sorted, duplicates will always be consecutive. * I overwrite duplicates in place by maintaining a pointer (lastUniqueElement) to track the last unique element. Time Complexity: O(n) Space Complexity: O(1) #LeetCode #DataStructures #Algorithms #ProblemSolving
To view or add a comment, sign in
-
🌟Day 71 of 75: Daily DSA Challenge Today's problem: Ques:- Partition Array into Disjoint Intervals. (https://lnkd.in/gE6SYndK) 🔍 Breaking down complex problems, one day at a time. The finish line is in sight! #CodingJourney #DataStructures #Algorithms #CodeChallenge #DSAProgress #DailyCoding #TechMindset #75DaysChallenge #KeepPushing
To view or add a comment, sign in
-
Found the smallest divisor to meet the threshold for array division. Time complexity led me to employ binary search for this challenge! 🔍 #codingskills #algorithms #dailycodingchallenge
To view or add a comment, sign in
-
🎯This is my Day 16 of #100DaysOfCode🚀 Today's problem was , Given a Binary Search Tree and a target sum. Check whether there's a pair of Nodes in the BST with value summing up to the target sum. #DrGViswanathan #100DaysOfCode #AdvancedDSA #CompetitiveCoding #Algorithms #TechJourney
To view or add a comment, sign in
-
🎯This is my Day 28 of #100DaysOfCode🚀 Today's problem was , Given a Binary Search Tree. Convert a given BST into a Special Max Heap with the condition that all the values in the left subtree of a node should be less than all the values in the right subtree of the node. This condition is applied on all the nodes in the so converted Max Heap. #DrGViswanathan #100DaysOfCode #AdvancedDSA #CompetitiveCoding #Algorithms #TechJourney
To view or add a comment, sign in
-
🎯This is my Day 9 of #100DaysOfCode🚀 Today's problem was , Given the root of a binary tree, flatten the tree into a "Linked list": The "linked list" should use the same Node class where the right child pointer points to the next node in the list and the left child pointer is always null. The "linked list" should be in the same order as a pre-order traversal of the binary tree. #DrGViswanathan #100DaysOfCode #AdvancedDSA #CompetitiveCoding #Algorithms #TechJourney
To view or add a comment, sign in
👨🎓MCA'25 || Ex- Future Ready Talent Intern at Microsoft
5moGood to know!