From f55632d7489a5ac1ed7e3b9608697f2df43e6a6c Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 20:32:27 +0530 Subject: [PATCH 01/16] done --- src/data/problemData.ts | 2 ++ src/pages/dsa-interview/index.tsx | 37 +++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index 02a389dc6..17822ad9e 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -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", diff --git a/src/pages/dsa-interview/index.tsx b/src/pages/dsa-interview/index.tsx index 7637a1f88..ac3d54a11 100644 --- a/src/pages/dsa-interview/index.tsx +++ b/src/pages/dsa-interview/index.tsx @@ -1,8 +1,8 @@ import React, { useState } from "react"; import { motion, AnimatePresence } from "framer-motion"; import Layout from "@theme/Layout"; -import Tabs from "@theme/Tabs"; // Import Tabs component -import TabItem from "@theme/TabItem"; // Import TabItem component +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; import problemsData from "../../data/problemData"; const DSAQuestions: React.FC = () => { @@ -127,6 +127,17 @@ const DSAQuestions: React.FC = () => {
                               {problemsData[key].solution.cpp}
                             
+ {/* Time and Space Complexity */} + {problemsData[key].timeComplexity?.cpp && ( +
+

Time Complexity: {problemsData[key].timeComplexity.cpp}

+
+ )} + {problemsData[key].spaceComplexity?.cpp && ( +
+

Space Complexity: {problemsData[key].spaceComplexity.cpp}

+
+ )} @@ -149,6 +160,17 @@ const DSAQuestions: React.FC = () => {
                               {problemsData[key].solution.java}
                             
+ {/* Time and Space Complexity */} + {problemsData[key].timeComplexity?.java && ( +
+

Time Complexity: {problemsData[key].timeComplexity.java}

+
+ )} + {problemsData[key].spaceComplexity?.java && ( +
+

Space Complexity: {problemsData[key].spaceComplexity.java}

+
+ )}
@@ -171,6 +193,17 @@ const DSAQuestions: React.FC = () => {
                               {problemsData[key].solution.python}
                             
+ {/* Time and Space Complexity */} + {problemsData[key].timeComplexity?.python && ( +
+

Time Complexity: {problemsData[key].timeComplexity.python}

+
+ )} + {problemsData[key].spaceComplexity?.python && ( +
+

Space Complexity: {problemsData[key].spaceComplexity.python}

+
+ )}
From 2e77c1a18b6c6cc212232cd4a5f2e0bb8b00e450 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 20:48:55 +0530 Subject: [PATCH 02/16] done --- src/data/problemData.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index 17822ad9e..d7eb70b04 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -127,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", From 46ed47847b03913d11d40c62a1e9b2b5ef089c49 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 20:56:42 +0530 Subject: [PATCH 03/16] done --- src/data/problemData.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index d7eb70b04..78b66cd6d 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -222,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: { From 8169decf3b166e47a3bc89c9a072c3ba2e2e8bee Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:04:23 +0530 Subject: [PATCH 04/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index 78b66cd6d..42e58809d 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -290,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: { From 6a8485706164834c8acc6af81a413cd4e427f16b Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:08:16 +0530 Subject: [PATCH 05/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index 42e58809d..f66ca40e7 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -356,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: { From 7eae2f736d1b945d7d8d0253735254925c3bc2d1 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:18:37 +0530 Subject: [PATCH 06/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index f66ca40e7..cbb9af556 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -427,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", From d8a2033fb0ccbd52c1ddcc60e11949dec4946096 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:23:46 +0530 Subject: [PATCH 07/16] done --- src/data/problemData.ts | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index cbb9af556..b2e3dd2c0 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -428,16 +428,16 @@ class Solution: 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)", - }, - + 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", @@ -490,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: { From 5821e081cc7533c293596a8e09ac40d902233f32 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:26:26 +0530 Subject: [PATCH 08/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index b2e3dd2c0..8e531ea0e 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -567,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: { From 9f1623b4b5a0d64678f3ae5ca3969cf67c1242be Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:28:41 +0530 Subject: [PATCH 09/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index 8e531ea0e..b812980f5 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -631,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: { From 4dc4f4d22468b0a6f10afccd86b8491b6ab7393f Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:31:36 +0530 Subject: [PATCH 10/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index b812980f5..02e8cbd40 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -687,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)", From 55fafd8bfc2e68aca3edfb85b53abfa9e2bdb847 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:33:53 +0530 Subject: [PATCH 11/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index 02e8cbd40..f910be81a 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -756,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: { From 091810ebb050c1e8028ef84b1fed9f830c8b7076 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:36:20 +0530 Subject: [PATCH 12/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index f910be81a..d33a968d6 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -824,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: { From bd72c0351c1827827b9bfa429be34705531683e4 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:39:10 +0530 Subject: [PATCH 13/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index d33a968d6..c348ac180 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -885,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: { From 832a8a4e8293c6669b36f6c9921c1c5545707d24 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:41:31 +0530 Subject: [PATCH 14/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index c348ac180..317c7fc99 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -944,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", From 29266104f12c98976a34ad2a19175aab29e8bd43 Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:44:20 +0530 Subject: [PATCH 15/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index 317c7fc99..21f51dc2d 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -1005,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: { From a0d7f7a1954bb167a1ead1c7df6805bc4eff45dd Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 21:46:23 +0530 Subject: [PATCH 16/16] done --- src/data/problemData.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/data/problemData.ts b/src/data/problemData.ts index 21f51dc2d..02ee79af1 100644 --- a/src/data/problemData.ts +++ b/src/data/problemData.ts @@ -1066,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: {