[Array] LeetCode 80. Remove Duplicates from Sorted Array II
Solution O(n) class Solution: def removeDuplicates(self, nums: List[int]) -> int: n = len(nums) current_num = nums[0] count, idx = 1, 0 for i in range(1,n):...
Solution O(n) class Solution: def removeDuplicates(self, nums: List[int]) -> int: n = len(nums) current_num = nums[0] count, idx = 1, 0 for i in range(1,n):...
First Solution O(n) class Solution: def reverseWords(self, s: str) -> str: result = "" n = len(s) start, end = n, 0 count = 0 for i in range(n-1, -...
Solution import random class RandomizedSet: def __init__(self): self.data_map = {} self.data = [] def insert(self, val: int) -> bool: if val not in self.data_...
Solution O(n^2) class Solution: def findNumberOfLIS(self, nums: List[int]) -> int: n = len(nums) max_length, ans = 0, 0 dp = [1] * n count = [1] * n ...
1. Unary Operators Operators that take only one value (typeof, !). Minus operator can be both binary and unary. console.log(typeof 4.5); // -> number console.log(-(10 - 2)); // -> -8...
Solution using BFS O(len(bank))^2 * len(gene)) class Solution: def minMutation(self, startGene: str, endGene: str, bank: List[str]) -> int: q = deque([(startGene,0)]) visite...
1. Use sort O(nlogn) class Solution: def hIndex(self, citations: List[int]) -> int: citations = sorted(citations) result = 0 for i in range(len(citations)): ...
Introduction It is easy to see the word imperative and declarative when developing code. Most of us know that React has a declarative syntax. What does declarative mean anyway? In this article we ...
Introduction We all know that React uses virtual DOM to optimize performance. However, do we really know what virtual DOM is? In this article, we are going to learn about what virtual DOM is and i...
Introduction In this article, we will discover how we can implement server-side pagination using MUI’s data grid and paginated queries in react-query. Difference between client-side and server-si...