Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linked List Cycle #1436

Closed
wants to merge 22 commits into from
231 changes: 231 additions & 0 deletions src/data/problemData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ const problemsData = {

res[num] = i`,
},
timeComplexity: { cpp: "O(n)", java: "O(n)", python: "O(n)" },
spaceComplexity: { cpp: "O(1)", java: "O(1)", python: "O(1)" }
},
containerWithMostWater: {
title: "2. Container With Most Water",
Expand Down Expand Up @@ -125,6 +127,16 @@ class Solution:

return max_area`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},
},
threeSum: {
title: "3. 3Sum",
Expand Down Expand Up @@ -210,6 +222,16 @@ class Solution:
k -= 1
return res`,
},
timeComplexity: {
cpp: "O(n^2)",
java: "O(n^2)",
python: "O(n^2)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},
},

isValidParentheses: {
Expand Down Expand Up @@ -268,6 +290,17 @@ class Solution:
stack.append(char)
return not stack`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},

},

mergeTwoLists: {
Expand Down Expand Up @@ -323,6 +356,17 @@ class Solution:
l2.next = self.mergeTwoLists(l1, l2.next)
return l2`,
},
timeComplexity: {
cpp: "O(n + m)",
java: "O(n + m)",
python: "O(n + m)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},

nextPermutation: {
Expand Down Expand Up @@ -383,6 +427,17 @@ class Solution:
nums[i], nums[j] = nums[j], nums[i]
nums[i + 1:] = nums[i + 1:][::-1]`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},
searchInsert: {
title: "7. Search Insert Position",
Expand Down Expand Up @@ -435,6 +490,17 @@ class Solution:
low = mid + 1
return low`,
},
timeComplexity: {
cpp: "O(log n)",
java: "O(log n)",
python: "O(log n)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},

isValidSudoku: {
Expand Down Expand Up @@ -501,6 +567,17 @@ class Solution:
blocks[(i//3)*3+j//3].add(curr)
return True`,
},
timeComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},

firstMissingPositive: {
Expand Down Expand Up @@ -554,6 +631,17 @@ class Solution:
if not present[i]: return i
return n + 1`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},

},

maxSubArray: {
Expand Down Expand Up @@ -599,6 +687,17 @@ class Solution:
max_sum = max(max_sum, curr_sum)
return max_sum`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},
mySqrt: {
title: "11. Sqrt(x)",
Expand Down Expand Up @@ -657,6 +756,17 @@ class Solution:
return res
`,
},
timeComplexity: {
cpp: "O(log n)",
java: "O(log n)",
python: "O(log n)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},

searchMatrix: {
Expand Down Expand Up @@ -714,6 +824,17 @@ class Solution:
return False
`,
},
timeComplexity: {
cpp: "O(log(m * n))",
java: "O(log(m * n))",
python: "O(log(m * n))",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},

deleteDuplicates: {
Expand Down Expand Up @@ -764,6 +885,17 @@ class Solution:
return head
`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},

mergeTwoSortedLists: {
Expand Down Expand Up @@ -812,6 +944,17 @@ class Solution:
nums1.sort()
`,
},
timeComplexity: {
cpp: "O((m+n) log(m+n))",
java: "O((m+n) log(m+n))",
python: "O((m+n) log(m+n))",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},
inorderTraversal: {
title: "15. Binary Tree Inorder Traversal",
Expand Down Expand Up @@ -862,6 +1005,17 @@ class Solution:
return ans
`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(h)",
java: "O(h)",
python: "O(h)",
},

},

isSymmetric: {
Expand Down Expand Up @@ -912,6 +1066,17 @@ class Solution:
return self.isSymmetricTest(p.left, q.right) and self.isSymmetricTest(p.right, q.left)
`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(h)",
java: "O(h)",
python: "O(h)",
},

},

levelOrderTraversal: {
Expand Down Expand Up @@ -988,6 +1153,17 @@ class Solution:
return ans
`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(w)",
java: "O(w)",
python: "O(w)",
},

},

maxDepthBinaryTree: {
Expand Down Expand Up @@ -1027,6 +1203,17 @@ class Solution:
return max(leftDepth, rightDepth) + 1
`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(h)",
java: "O(h)",
python: "O(h)",
},

},
hasPathSum: {
title: "19. Path Sum",
Expand Down Expand Up @@ -1074,6 +1261,17 @@ class Solution:
return self.hasPathSum(root.left, sum - root.val) or self.hasPathSum(root.right, sum - root.val)
`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(h)",
java: "O(h)",
python: "O(h)",
},

},

generatePascalTriangle: {
Expand Down Expand Up @@ -1134,6 +1332,17 @@ class Solution:
return res
`,
},
timeComplexity: {
cpp: "O(n^2)",
java: "O(n^2)",
python: "O(n^2)",
},
spaceComplexity: {
cpp: "O(n^2)",
java: "O(n^2)",
python: "O(n^2)",
},

},

maxProfit: {
Expand Down Expand Up @@ -1185,6 +1394,17 @@ class Solution:
return result
`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},

hasCycle: {
Expand Down Expand Up @@ -1257,6 +1477,17 @@ class Solution:
return False
`,
},
timeComplexity: {
cpp: "O(n)",
java: "O(n)",
python: "O(n)",
},
spaceComplexity: {
cpp: "O(1)",
java: "O(1)",
python: "O(1)",
},

},
preorderTraversal: {
title: "23. Binary Tree Preorder Traversal",
Expand Down
Loading
Loading