From f55632d7489a5ac1ed7e3b9608697f2df43e6a6c Mon Sep 17 00:00:00 2001 From: SrijaVuppala295 Date: Sun, 27 Oct 2024 20:32:27 +0530 Subject: [PATCH 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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",