@cardosopab

24 Followers
84 Following
120 Posts
Software Developer on a journey.
Githubhttps://github.com/cardosopab
Portfoliohttps://cardosopab.web.app

LeetCode daily problem 2958. Length of Longest Subarray With at Most K Frequency, was a fun one, I used a sliding window and a dictionary that kept count of each value's frequency, while the right pointer's frequency was above K I adjusted the frequency count, and left pointer. I believe the time & space complexity are O(n) linear. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/2024/03/2958.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/2024/03/2958.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem 234. Palindrome Linked List, simple enough, traversed the linked list while adding the node's value into an array, then compared it to a version going backwards. I believe the time & space complexity are O(n) linear. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/2024/03/234.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/2024/03/234.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem 206. Reverse Linked List, I like to think about swapping the liquids between cup A and B, it's simple if you have a third cup (although it took me a bit to understand/remember the forth command is to progress the list along). I believe the time complexity is O(n) linear while the space is O(1) constant. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/2024/03/206.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/2024/03/206.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem 452. Minimum Number of Arrows to Burst Balloons, I took inspiration from yesterday's problem, merged the intervals while taking the overlap, and returning the number of overlaps. I believe the time complexity is O(n log n), where space is O(n) linear. Did you give it a try? Link to my solution, and two other solutions I came across.

https://github.com/cardosopab/LeetCodeNotes/blob/main/452.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/452.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem 2485. Find the Pivot Integer, tricky problem, one of the ones that is simple after you find the trick, I tried a combination of prefix sum and two pointers, iterating closer to the pivot. I believe the time complexity is O(n) linear, where space is O(1) constant. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/2485.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/2485.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem 1171. "Remove Zero Sum Consecutive Nodes from Linked List" Today's problem was a bit difficult to wrap my mind around, I used a stack to hold the values, a prefix sum, and a seen set. If a value was seen before, I popped the values until the matching seen value was encountered. I believe the time and space complexity are O(n) linear. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/1171.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/1171.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem 791. "Custom Sort String" I iterated through the order string pulling the matches out, and adding them into the ans array, then return ans plus the remaining s string. I believe the time and space complexity are O(n) linear. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/791.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/791.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem 349. "Intersection of Two Arrays" I created a set for each array, and iterated the shorter one, checking availability in the larger. I believe the time complexity and space complexity are O(n) linear. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/349.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/349.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem 2540. "Minimum Common Value" great use case for the two pointer method, iterate through the values, until you find and return the match, and if no match is found increment the pointer from the array that has the smaller value in the 0th index. I believe the time complexity is O(n) linear, where the space complexity is O(1) constant. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/2540.py

#python
#pythonprogramming
#algorithms
#datastructures

LeetCodeNotes/2540.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub

LeetCode daily problem number 3005 "Count Elements With Maximum Frequency" was a great use case for #Python 's default dictionary, just a matter of counting the frequencies with it, then iterate its values, and increment the element count with the max frequency. I believe the time and space complexity are O(n) linear. Did you give it a try? Link to my solution.

https://github.com/cardosopab/LeetCodeNotes/blob/main/3005.py

LeetCodeNotes/3005.py at main · cardosopab/LeetCodeNotes

Culmination of daily LeetCode problems. Contribute to cardosopab/LeetCodeNotes development by creating an account on GitHub.

GitHub