diff --git a/README.md b/README.md index 7b801b7a..5fb2ffd6 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ - [Fundamentals](#fundamentals) - [Notes](#notes) - [Question List](#question-list) +- [New Features](#new-features) + - [Time & Space Complexity Analysis](#time--space-complexity-analysis) + - [Pattern Deep-Dive Guides](#pattern-deep-dive-guides) - [Solutions](#solutions) - [Suggestions](#suggestions) - [Acknowledgements](#acknowledgements) @@ -54,6 +57,40 @@ Other useful methods to know include [`substring()`](https://docs.oracle.com/jav The entire question list can be found here: https://seanprashad.com/leetcode-patterns/. +## New Features + +### Time & Space Complexity Analysis + +Each problem now includes **optimal time and space complexity** information. This helps you: +- Understand the efficiency of solutions +- Prioritize problems based on complexity +- Prepare for interview discussions about optimization + +The complexity values are displayed in the main question table and reflect the optimal pattern-based solution for each problem. + +### Pattern Deep-Dive Guides + +Comprehensive guides for each coding pattern are now available in the `/guides` directory. Each guide includes: + +- **Core Concept**: Clear explanation of what the pattern is and why it exists +- **When to Use**: Key problem characteristics that signal this pattern is applicable +- **Template Code**: Generalized code templates in Python and JavaScript showing the structure +- **Related Problems**: Links back to relevant problems in the main list +- **Time & Space Complexity**: Complexity analysis for the pattern +- **Tips & Best Practices**: Practical advice for applying the pattern + +Access the guides: +- Through the **Pattern Guides** tab in the web interface +- Directly in the repository: [`/guides`](./guides/) +- Pattern badges in the question table are clickable and link to their respective guides + +Available patterns: +- Arrays, BFS, Backtracking, Binary Search, Bit Manipulation, Bucket Sort +- DFS, Design, Dynamic Programming, Fast & Slow Pointers +- Graph, Greedy, Heap, In-place reversal of a linked list +- Intervals, QuickSelect, Sliding Window, Sorting +- Topological Sort, Trie, Two Pointers, Union Find + ## Solutions Solutions written in Java can be found in the [solutions] branch. diff --git a/package-lock.json b/package-lock.json index cc5cd23e..858c2cb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -83,6 +83,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.28.5.tgz", "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -687,6 +688,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.27.1.tgz", "integrity": "sha512-p9OkPbZ5G7UT1MofwYFigGebnrzGJacoBSQM0/6bi/PUMVE+qlWDD/OalvQKbwgQzU6dl0xAv6r4X7Jme0RYxA==", "license": "MIT", + "peer": true, "dependencies": { "@babel/helper-plugin-utils": "^7.27.1" }, @@ -1570,6 +1572,7 @@ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.27.1.tgz", "integrity": "sha512-2KH4LWGSrJIkVf5tSiBFYuXDAoWRq2MMwgivCf+93dd0GQi8RXLjKA/0EvRnVV5G0hrHczsquXuD01L8s6dmBw==", "license": "MIT", + "peer": true, "dependencies": { "@babel/helper-annotate-as-pure": "^7.27.1", "@babel/helper-module-imports": "^7.27.1", @@ -3319,6 +3322,7 @@ "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", "integrity": "sha512-P1st0aksCrn9sGZhp8GMYwBnQsbvAWsZAX44oXNNvLHGqAOcoVxmjZiohstwQ7SqKnbR47akdNi+uleWD8+g6A==", "license": "MIT", + "peer": true, "funding": { "type": "opencollective", "url": "https://opencollective.com/popperjs" @@ -4184,6 +4188,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.62.0.tgz", "integrity": "sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==", "license": "BSD-2-Clause", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "5.62.0", "@typescript-eslint/types": "5.62.0", @@ -4577,6 +4582,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -4675,6 +4681,7 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -5602,6 +5609,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.25", "caniuse-lite": "^1.0.30001754", @@ -7634,6 +7642,7 @@ "integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==", "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", @@ -7836,6 +7845,7 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz", "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "license": "MIT", + "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -7914,6 +7924,7 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.2.tgz", "integrity": "sha512-scB3nz4WmG75pV8+3eRUQOHZlNSUhFNq37xnpgRkCCELU3XMvXAxLk1eqWWyE22Ki4Q01Fnsw9BA3cJHDPgn2Q==", "license": "MIT", + "peer": true, "dependencies": { "aria-query": "^5.3.2", "array-includes": "^3.1.8", @@ -7965,6 +7976,7 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.37.5.tgz", "integrity": "sha512-Qteup0SqU15kdocexFNAJMvCJEfa2xUKNV4CC1xsVMrIIqEy3SQ/rqyxCWNzfrd3/ldy6HMlD2e0JDVpDg2qIA==", "license": "MIT", + "peer": true, "dependencies": { "array-includes": "^3.1.8", "array.prototype.findlast": "^1.2.5", @@ -7997,6 +8009,7 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.6.2.tgz", "integrity": "sha512-QzliNJq4GinDBcD8gPB5v0wh6g8q3SUi6EFF0x8N/BL9PoVs0atuGc47ozMRyOWAKdwaZ5OnbOEa3WR+dSGKuQ==", "license": "MIT", + "peer": true, "engines": { "node": ">=10" }, @@ -10576,6 +10589,7 @@ "resolved": "https://registry.npmjs.org/jest/-/jest-27.5.1.tgz", "integrity": "sha512-Yn0mADZB89zTtjkPJEXwrac3LHudkQMR+Paqa8uxJHCBr9agxztUifWCyiYrjhMPBoUVBjyny0I7XH6ozDr7QQ==", "license": "MIT", + "peer": true, "dependencies": { "@jest/core": "^27.5.1", "import-local": "^3.0.2", @@ -11573,6 +11587,7 @@ "resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.7.tgz", "integrity": "sha512-/imKNG4EbWNrVjoNC/1H5/9GFy+tqjGBHCaSsN+P2RnPqjsLmv6UD3Ej+Kj8nBWaRAwyk7kK5ZUc+OEatnTR3A==", "license": "MIT", + "peer": true, "bin": { "jiti": "bin/jiti.js" } @@ -13617,6 +13632,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -14763,6 +14779,7 @@ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.2.tgz", "integrity": "sha512-Q8qQfPiZ+THO/3ZrOrO0cJJKfpYCagtMUkXbnEfmgUjwXg6z/WBeOyS9APBBPCTSiDV+s4SwQGu8yFsiMRIudg==", "license": "MIT", + "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -14881,6 +14898,7 @@ "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "dev": true, "license": "MIT", + "peer": true, "bin": { "prettier": "bin-prettier.js" }, @@ -15085,6 +15103,7 @@ "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.4.0", "object-assign": "^4.1.1", @@ -15266,6 +15285,7 @@ "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -15339,6 +15359,7 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" @@ -15437,6 +15458,7 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.11.0.tgz", "integrity": "sha512-F27qZr8uUqwhWZboondsPx8tnC3Ct3SxZA3V5WyEvujRyyNv0VYPhoBg1gZ8/MV5tubQp76Trw8lTv9hzRBa+A==", "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -16027,6 +16049,7 @@ "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.2.tgz", "integrity": "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ==", "license": "MIT", + "peer": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -16188,6 +16211,7 @@ "resolved": "https://registry.npmjs.org/sass/-/sass-1.94.2.tgz", "integrity": "sha512-N+7WK20/wOr7CzA2snJcUSSNTCzeCGUTFY3OgeQP3mZ1aj9NMQ0mSTXwlrnd89j33zzQJGqIN52GIOmYrfq46A==", "license": "MIT", + "peer": true, "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.0.2", @@ -16320,6 +16344,7 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -17862,6 +17887,7 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -18071,6 +18097,7 @@ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "license": "(MIT OR CC0-1.0)", + "peer": true, "engines": { "node": ">=10" }, @@ -18618,6 +18645,7 @@ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.103.0.tgz", "integrity": "sha512-HU1JOuV1OavsZ+mfigY0j8d1TgQgbZ6M+J75zDkpEAwYeXjWSqrGJtgnPblJjd/mAyTNQ7ygw0MiKOn6etz8yw==", "license": "MIT", + "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.8", @@ -18689,6 +18717,7 @@ "resolved": "https://registry.npmjs.org/webpack-dev-server/-/webpack-dev-server-4.15.2.tgz", "integrity": "sha512-0XavAZbNJ5sDrCbkpWL8mia0o5WPOd2YGtxrEiZkBK9FjLppIUK2TgxK6qGD2P3hUXTJNNPVibrerKcx5WkR1g==", "license": "MIT", + "peer": true, "dependencies": { "@types/bonjour": "^3.5.9", "@types/connect-history-api-fallback": "^1.3.5", @@ -19101,6 +19130,7 @@ "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz", "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -19424,6 +19454,7 @@ "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.2.tgz", "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", "license": "ISC", + "peer": true, "bin": { "yaml": "bin.mjs" }, diff --git a/scripts/add_complexity.py b/scripts/add_complexity.py new file mode 100644 index 00000000..185acad2 --- /dev/null +++ b/scripts/add_complexity.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python3 +""" +Script to add time and space complexity fields to questions.json +Based on patterns, assigns appropriate complexity values +""" + +import json +import sys +from pathlib import Path + +# Pattern-based complexity mapping (optimal solution for each pattern) +COMPLEXITY_MAP = { + "Arrays": {"time": "O(n)", "space": "O(1)"}, + "Sliding Window": {"time": "O(n)", "space": "O(1)"}, + "Two Pointers": {"time": "O(n)", "space": "O(1)"}, + "Fast & Slow Pointers": {"time": "O(n)", "space": "O(1)"}, + "Binary Search": {"time": "O(log n)", "space": "O(1)"}, + "BFS": {"time": "O(V + E)", "space": "O(V)"}, + "DFS": {"time": "O(V + E)", "space": "O(V)"}, + "Backtracking": {"time": "O(2^n) or O(n!)", "space": "O(n)"}, + "Dynamic Programming": {"time": "O(n) or O(n²)", "space": "O(n) or O(n²)"}, + "Greedy": {"time": "O(n log n)", "space": "O(1)"}, + "Heap": {"time": "O(n log k)", "space": "O(k)"}, + "Graph": {"time": "O(V + E)", "space": "O(V)"}, + "Intervals": {"time": "O(n log n)", "space": "O(1)"}, + "Trie": {"time": "O(m)", "space": "O(ALPHABET_SIZE * N * M)"}, + "Union Find": {"time": "O(α(n))", "space": "O(n)"}, + "Topological Sort": {"time": "O(V + E)", "space": "O(V)"}, + "Bit Manipulation": {"time": "O(n)", "space": "O(1)"}, + "Sorting": {"time": "O(n log n)", "space": "O(1)"}, + "Bucket Sort": {"time": "O(n)", "space": "O(n)"}, + "QuickSelect": {"time": "O(n)", "space": "O(1)"}, + "In-place reversal of a linked list": {"time": "O(n)", "space": "O(1)"}, + "Design": {"time": "Varies", "space": "Varies"}, +} + +def get_complexity_for_patterns(patterns): + """ + Determine complexity based on patterns. + For multiple patterns, use the most complex one or combine appropriately. + """ + if not patterns: + return {"time": "O(n)", "space": "O(1)"} + + # For single pattern, return its complexity + if len(patterns) == 1: + pattern = patterns[0] + return COMPLEXITY_MAP.get(pattern, {"time": "O(n)", "space": "O(1)"}) + + # For multiple patterns, prioritize certain patterns + # DP and Backtracking are usually the dominant complexity + if "Dynamic Programming" in patterns: + return COMPLEXITY_MAP["Dynamic Programming"] + if "Backtracking" in patterns: + return COMPLEXITY_MAP["Backtracking"] + if "BFS" in patterns or "DFS" in patterns: + return COMPLEXITY_MAP["BFS"] + + # Default to first pattern's complexity + return COMPLEXITY_MAP.get(patterns[0], {"time": "O(n)", "space": "O(1)"}) + +def add_complexity_to_questions(input_file, output_file=None): + """Add time and space complexity to all questions""" + if output_file is None: + output_file = input_file + + # Read the JSON file + with open(input_file, 'r', encoding='utf-8') as f: + data = json.load(f) + + # Add complexity to each question + for question in data['data']: + if 'timeComplexity' not in question: + complexity = get_complexity_for_patterns(question.get('pattern', [])) + question['timeComplexity'] = complexity['time'] + question['spaceComplexity'] = complexity['space'] + + # Write back to file + with open(output_file, 'w', encoding='utf-8') as f: + json.dump(data, f, indent=2, ensure_ascii=False) + + print(f"Added complexity fields to {len(data['data'])} questions") + print(f"Output written to {output_file}") + +if __name__ == "__main__": + script_dir = Path(__file__).parent + repo_root = script_dir.parent + questions_file = repo_root / "src" / "data" / "questions.json" + + if not questions_file.exists(): + print(f"Error: {questions_file} not found") + sys.exit(1) + + add_complexity_to_questions(questions_file) + diff --git a/src/components/PatternGuides/index.js b/src/components/PatternGuides/index.js new file mode 100644 index 00000000..0f98d01b --- /dev/null +++ b/src/components/PatternGuides/index.js @@ -0,0 +1,135 @@ +import React, { useState } from 'react'; +import { Container, Row, Col, Card, CardBody, CardTitle, NavLink } from 'reactstrap'; +import ReactMarkdown from 'react-markdown'; +import { FaExternalLinkAlt } from 'react-icons/fa'; +import { Event } from '../Shared/Tracking'; + +import './styles.scss'; + +const PATTERNS = [ + { name: 'Arrays', file: 'arrays.md', slug: 'arrays' }, + { name: 'BFS', file: 'bfs.md', slug: 'bfs' }, + { name: 'Backtracking', file: 'backtracking.md', slug: 'backtracking' }, + { name: 'Binary Search', file: 'binary-search.md', slug: 'binary-search' }, + { name: 'Bit Manipulation', file: 'bit-manipulation.md', slug: 'bit-manipulation' }, + { name: 'Bucket Sort', file: 'bucket-sort.md', slug: 'bucket-sort' }, + { name: 'DFS', file: 'dfs.md', slug: 'dfs' }, + { name: 'Design', file: 'design.md', slug: 'design' }, + { name: 'Dynamic Programming', file: 'dynamic-programming.md', slug: 'dynamic-programming' }, + { name: 'Fast & Slow Pointers', file: 'fast-slow-pointers.md', slug: 'fast-slow-pointers' }, + { name: 'Graph', file: 'graph.md', slug: 'graph' }, + { name: 'Greedy', file: 'greedy.md', slug: 'greedy' }, + { name: 'Heap', file: 'heap.md', slug: 'heap' }, + { name: 'In-place reversal of a linked list', file: 'in-place-reversal-linked-list.md', slug: 'in-place-reversal-linked-list' }, + { name: 'Intervals', file: 'intervals.md', slug: 'intervals' }, + { name: 'QuickSelect', file: 'quickselect.md', slug: 'quickselect' }, + { name: 'Sliding Window', file: 'sliding-window.md', slug: 'sliding-window' }, + { name: 'Sorting', file: 'sorting.md', slug: 'sorting' }, + { name: 'Topological Sort', file: 'topological-sort.md', slug: 'topological-sort' }, + { name: 'Trie', file: 'trie.md', slug: 'trie' }, + { name: 'Two Pointers', file: 'two-pointers.md', slug: 'two-pointers' }, + { name: 'Union Find', file: 'union-find.md', slug: 'union-find' }, +]; + +const PatternGuides = () => { + const [selectedPattern, setSelectedPattern] = useState(null); + const [guideContent, setGuideContent] = useState(''); + + const loadGuide = async (pattern) => { + setSelectedPattern(pattern); + try { + // In production, guides would be served from public/guides + // For now, we'll link to GitHub + const response = await fetch( + `https://raw.githubusercontent.com/SeanPrashad/leetcode-patterns/main/guides/${pattern.file}` + ); + if (response.ok) { + const text = await response.text(); + setGuideContent(text); + } else { + setGuideContent(`# ${pattern.name}\n\nGuide content will be available soon. Please check the [GitHub repository](https://github.com/SeanPrashad/leetcode-patterns/tree/main/guides) for the latest guides.`); + } + } catch (error) { + setGuideContent(`# ${pattern.name}\n\nUnable to load guide. Please check the [GitHub repository](https://github.com/SeanPrashad/leetcode-patterns/tree/main/guides/${pattern.file}) for this guide.`); + } + }; + + return ( + + + +
+

Pattern Deep-Dive Guides

+

+ Comprehensive guides for each coding pattern used in LeetCode problems. + Each guide explains the core concept, when to use the pattern, provides template code, + and links to relevant problems. +

+ Event('PatternGuides', 'Clicked link', 'GitHub guides link')} + > + View all guides on GitHub + +
+ +
+ + + + + Available Patterns +
+ {PATTERNS.map((pattern) => ( + { + e.preventDefault(); + loadGuide(pattern); + Event('PatternGuides', 'Selected pattern', pattern.name); + }} + className={selectedPattern?.slug === pattern.slug ? 'active' : ''} + > + {pattern.name} + + ))} +
+
+
+ + + {selectedPattern ? ( + + +
+ {guideContent} +
+
+
+ ) : ( + + +

+ Select a pattern from the list to view its comprehensive guide. + Each guide includes: +

+
    +
  • Core Concept: What the pattern is and why it exists
  • +
  • When to Use: Problem characteristics that signal this pattern
  • +
  • Template Code: Skeleton code showing the structure
  • +
  • Related Problems: Links to problems using this pattern
  • +
  • Time & Space Complexity: Complexity analysis
  • +
+
+
+ )} + +
+
+ ); +}; + +export default PatternGuides; + diff --git a/src/components/PatternGuides/styles.scss b/src/components/PatternGuides/styles.scss new file mode 100644 index 00000000..5a1d0600 --- /dev/null +++ b/src/components/PatternGuides/styles.scss @@ -0,0 +1,99 @@ +.pattern-guides { + padding: 20px 0; + + .guides-header { + h2 { + margin-bottom: 10px; + } + + p { + margin-bottom: 15px; + } + } + + .pattern-list { + max-height: 600px; + overflow-y: auto; + + a { + display: block; + padding: 8px 12px; + margin: 4px 0; + border-radius: 4px; + text-decoration: none; + color: var(--text-color, #333); + transition: background-color 0.2s; + + &:hover { + background-color: var(--hover-bg, #f5f5f5); + } + + &.active { + background-color: var(--active-bg, #007bff); + color: white; + font-weight: bold; + } + } + } + + .guide-content { + h1, h2, h3, h4, h5, h6 { + margin-top: 20px; + margin-bottom: 10px; + } + + code { + background-color: var(--code-bg, #f4f4f4); + padding: 2px 6px; + border-radius: 3px; + font-family: 'Courier New', monospace; + font-size: 0.9em; + } + + pre { + background-color: var(--code-bg, #f4f4f4); + padding: 15px; + border-radius: 5px; + overflow-x: auto; + + code { + background-color: transparent; + padding: 0; + } + } + + ul, ol { + margin-left: 20px; + margin-bottom: 15px; + } + + li { + margin-bottom: 5px; + } + + blockquote { + border-left: 4px solid var(--border-color, #ddd); + padding-left: 15px; + margin: 15px 0; + color: var(--text-muted, #666); + } + + table { + width: 100%; + border-collapse: collapse; + margin: 15px 0; + + th, td { + border: 1px solid var(--border-color, #ddd); + padding: 8px 12px; + text-align: left; + } + + th { + background-color: var(--table-header-bg, #f8f9fa); + font-weight: bold; + } + } + } +} + diff --git a/src/components/Table/index.js b/src/components/Table/index.js index 3ec8863b..8fae8295 100644 --- a/src/components/Table/index.js +++ b/src/components/Table/index.js @@ -398,19 +398,63 @@ const Table = () => { disableSortBy: true, id: 'pattern', Cell: (cellInfo) => { + // Map pattern names to guide slugs + const patternToSlug = { + 'Arrays': 'arrays', + 'BFS': 'bfs', + 'Backtracking': 'backtracking', + 'Binary Search': 'binary-search', + 'Bit Manipulation': 'bit-manipulation', + 'Bucket Sort': 'bucket-sort', + 'DFS': 'dfs', + 'Design': 'design', + 'Dynamic Programming': 'dynamic-programming', + 'Fast & Slow Pointers': 'fast-slow-pointers', + 'Graph': 'graph', + 'Greedy': 'greedy', + 'Heap': 'heap', + 'In-place reversal of a linked list': 'in-place-reversal-linked-list', + 'Intervals': 'intervals', + 'QuickSelect': 'quickselect', + 'Sliding Window': 'sliding-window', + 'Sorting': 'sorting', + 'Topological Sort': 'topological-sort', + 'Trie': 'trie', + 'Two Pointers': 'two-pointers', + 'Union Find': 'union-find', + }; + const patterns = `${cellInfo.row.original.pattern}` .split(',') .map((pattern) => { + const trimmedPattern = pattern.trim(); + const slug = patternToSlug[trimmedPattern]; + const guideUrl = slug + ? `https://github.com/SeanPrashad/leetcode-patterns/blob/main/guides/${slug}.md` + : null; + if (showPatterns[0] || checked[cellInfo.row.original.id]) { return ( - - {pattern} + { + if (guideUrl) { + window.open(guideUrl, '_blank'); + Event('Table', 'Clicked pattern badge', trimmedPattern); + } + }} + title={guideUrl ? `Click to view ${trimmedPattern} guide` : ''} + > + {trimmedPattern} ); } return ( - + *** ); @@ -439,6 +483,30 @@ const Table = () => { ), Filter: SelectDifficultyColumnFilter, }, + { + Header: 'Time Complexity', + accessor: 'timeComplexity', + id: 'timeComplexity', + disableSortBy: true, + Cell: (cellInfo) => ( +
+ {cellInfo.row.original.timeComplexity || 'N/A'} +
+ ), + disableFilters: true, + }, + { + Header: 'Space Complexity', + accessor: 'spaceComplexity', + id: 'spaceComplexity', + disableSortBy: true, + Cell: (cellInfo) => ( +
+ {cellInfo.row.original.spaceComplexity || 'N/A'} +
+ ), + disableFilters: true, + }, { Header: () => { const date = new Date(updated); diff --git a/src/components/Tabs/index.js b/src/components/Tabs/index.js index d676971f..3a77f6d0 100644 --- a/src/components/Tabs/index.js +++ b/src/components/Tabs/index.js @@ -13,6 +13,7 @@ import { Event } from '../Shared/Tracking'; import Table from '../Table'; import Tips from '../Tips'; import Acknowledgements from '../Acknowledgements'; +import PatternGuides from '../PatternGuides'; import './styles.scss'; @@ -53,6 +54,17 @@ const Tabs = () => { className={classnames({ active: activeTab === '3' })} onClick={() => { toggle('3'); + Event('Tabs', 'Clicked Tab', 'Pattern Guides tab'); + }} + > + Pattern Guides + + + + { + toggle('4'); Event('Tabs', 'Clicked Tab', 'Acknowledgements tab'); }} > @@ -68,6 +80,9 @@ const Tabs = () => { + + + diff --git a/src/data/questions.json b/src/data/questions.json index 289083f7..f798775d 100644 --- a/src/data/questions.json +++ b/src/data/questions.json @@ -51,7 +51,9 @@ "slug": "visa", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 1, @@ -104,7 +106,9 @@ "slug": "arista-networks", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 2, @@ -126,7 +130,9 @@ "slug": "amazon", "frequency": 4 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 3, @@ -169,7 +175,9 @@ "slug": "bloomberg", "frequency": 3 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 4, @@ -261,7 +269,9 @@ "slug": "zs-associates", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 5, @@ -315,7 +325,9 @@ "slug": "goldman-sachs", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 6, @@ -352,7 +364,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 7, @@ -434,7 +448,9 @@ "slug": "jpmorgan", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 8, @@ -581,7 +597,9 @@ "slug": "pornhub", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 9, @@ -678,7 +696,9 @@ "slug": "rakuten", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 10, @@ -795,7 +815,9 @@ "slug": "grammarly", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 11, @@ -877,7 +899,9 @@ "slug": "cognizant", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 12, @@ -964,7 +988,9 @@ "slug": "deloitte", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 13, @@ -981,7 +1007,9 @@ "slug": "facebook", "frequency": 5 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 14, @@ -1033,7 +1061,9 @@ "slug": "wix", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 15, @@ -1070,7 +1100,9 @@ "slug": "bloomberg", "frequency": 3 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 16, @@ -1142,7 +1174,9 @@ "slug": "american-express", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 17, @@ -1189,7 +1223,9 @@ "slug": "apple", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 18, @@ -1221,7 +1257,9 @@ "slug": "microsoft", "frequency": 3 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 19, @@ -1308,7 +1346,9 @@ "slug": "hpe", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 20, @@ -1365,7 +1405,9 @@ "slug": "tiktok", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 21, @@ -1387,7 +1429,9 @@ "slug": "google", "frequency": 3 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 22, @@ -1484,7 +1528,9 @@ "slug": "epam-systems", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 23, @@ -1533,7 +1579,9 @@ "slug": "myntra", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 24, @@ -1570,7 +1618,9 @@ "slug": "bloomberg", "frequency": 3 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 25, @@ -1657,7 +1707,9 @@ "slug": "de-shaw", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 26, @@ -1668,7 +1720,9 @@ ], "difficulty": "Medium", "premium": true, - "companies": [] + "companies": [], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 27, @@ -1710,7 +1764,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 28, @@ -1772,7 +1828,9 @@ "slug": "ibm", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 29, @@ -1844,7 +1902,9 @@ "slug": "qualcomm", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 30, @@ -1926,7 +1986,9 @@ "slug": "tcs", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 31, @@ -2153,7 +2215,9 @@ "slug": "ozon", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 32, @@ -2300,7 +2364,9 @@ "slug": "zomato", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 33, @@ -2332,7 +2398,9 @@ "slug": "bloomberg", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 34, @@ -2389,7 +2457,9 @@ "slug": "docusign", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 35, @@ -2486,7 +2556,9 @@ "slug": "mastercard", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 36, @@ -2553,7 +2625,9 @@ "slug": "siemens", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 37, @@ -2640,7 +2714,9 @@ "slug": "nvidia", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 38, @@ -2822,7 +2898,9 @@ "slug": "autodesk", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 39, @@ -2899,7 +2977,9 @@ "slug": "millennium", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 40, @@ -2926,7 +3006,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 41, @@ -2998,7 +3080,9 @@ "slug": "flipkart", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 42, @@ -3050,7 +3134,9 @@ "slug": "akamai", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 43, @@ -3143,7 +3229,9 @@ "slug": "navi", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 44, @@ -3225,7 +3313,9 @@ "slug": "netskope", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 45, @@ -3242,7 +3332,9 @@ "slug": "google", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 46, @@ -3289,7 +3381,9 @@ "slug": "tiktok", "frequency": 3 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 47, @@ -3316,7 +3410,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 48, @@ -3343,7 +3439,9 @@ "slug": "tiktok", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 49, @@ -3381,7 +3479,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(n) or O(n²)", + "spaceComplexity": "O(n) or O(n²)" }, { "id": 50, @@ -3423,7 +3523,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 51, @@ -3470,7 +3572,9 @@ "slug": "apple", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 52, @@ -3547,7 +3651,9 @@ "slug": "epam-systems", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 53, @@ -3589,7 +3695,9 @@ "slug": "ebay", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 54, @@ -3626,7 +3734,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 55, @@ -3668,7 +3778,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 56, @@ -3705,7 +3817,9 @@ "slug": "american-express", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 57, @@ -3782,7 +3896,9 @@ "slug": "zoho", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 58, @@ -3859,7 +3975,9 @@ "slug": "tiktok", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 59, @@ -3906,7 +4024,9 @@ "slug": "oracle", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 60, @@ -3958,7 +4078,9 @@ "slug": "arista-networks", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 61, @@ -3996,7 +4118,9 @@ "slug": "nutanix", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 62, @@ -4230,7 +4354,9 @@ "slug": "barclays", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 63, @@ -4260,7 +4386,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 64, @@ -4300,7 +4428,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 65, @@ -4362,7 +4492,9 @@ "slug": "nutanix", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 66, @@ -4409,7 +4541,9 @@ "slug": "linkedin", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 67, @@ -4456,7 +4590,9 @@ "slug": "yandex", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 68, @@ -4493,7 +4629,9 @@ "slug": "bloomberg", "frequency": 3 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 69, @@ -4570,7 +4708,9 @@ "slug": "cadence", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 70, @@ -4667,7 +4807,9 @@ "slug": "palo-alto-networks", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 71, @@ -4705,7 +4847,9 @@ "slug": "apple", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 72, @@ -4742,7 +4886,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 73, @@ -4854,7 +5000,9 @@ "slug": "yandex", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 74, @@ -4876,7 +5024,9 @@ "slug": "linkedin", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 75, @@ -4923,7 +5073,9 @@ "slug": "apple", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 76, @@ -5195,7 +5347,9 @@ "slug": "ripple", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 77, @@ -5242,7 +5396,9 @@ "slug": "nuro", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 78, @@ -5294,7 +5450,9 @@ "slug": "goldman-sachs", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 79, @@ -5412,7 +5570,9 @@ "slug": "snowflake", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 80, @@ -5505,7 +5665,9 @@ "slug": "goldman-sachs", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 81, @@ -5542,7 +5704,9 @@ "slug": "goldman-sachs", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 82, @@ -5584,7 +5748,9 @@ "slug": "phonepe", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 83, @@ -5607,7 +5773,9 @@ "slug": "google", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 84, @@ -5649,7 +5817,9 @@ "slug": "pure-storage", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 85, @@ -5681,7 +5851,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 86, @@ -5718,7 +5890,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 87, @@ -5775,7 +5949,9 @@ "slug": "yandex", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 88, @@ -5867,7 +6043,9 @@ "slug": "waymo", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 89, @@ -6014,7 +6192,9 @@ "slug": "palo-alto-networks", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 90, @@ -6051,7 +6231,9 @@ "slug": "google", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 91, @@ -6118,7 +6300,9 @@ "slug": "nutanix", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 92, @@ -6165,7 +6349,9 @@ "slug": "paypal", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 93, @@ -6232,7 +6418,9 @@ "slug": "uber", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 94, @@ -6243,7 +6431,9 @@ ], "difficulty": "Hard", "premium": false, - "companies": [] + "companies": [], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 95, @@ -6290,7 +6480,9 @@ "slug": "oracle", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 96, @@ -6332,7 +6524,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 97, @@ -6384,7 +6578,9 @@ "slug": "cisco", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 98, @@ -6451,7 +6647,9 @@ "slug": "uipath", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 99, @@ -6568,7 +6766,9 @@ "slug": "zeta", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 100, @@ -6820,7 +7020,9 @@ "slug": "kpmg", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 101, @@ -6837,7 +7039,9 @@ "slug": "google", "frequency": 4 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 102, @@ -6854,7 +7058,9 @@ "slug": "amazon", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 103, @@ -6956,7 +7162,9 @@ "slug": "meesho", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 104, @@ -6993,7 +7201,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 105, @@ -7040,7 +7250,9 @@ "slug": "bloomberg", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 106, @@ -7087,7 +7299,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 107, @@ -7254,7 +7468,9 @@ "slug": "robinhood", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 108, @@ -7301,7 +7517,9 @@ "slug": "epam-systems", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 109, @@ -7394,7 +7612,9 @@ "slug": "coupang", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 110, @@ -7452,7 +7672,9 @@ "slug": "audible", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 111, @@ -7464,7 +7686,9 @@ ], "difficulty": "Hard", "premium": true, - "companies": [] + "companies": [], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 112, @@ -7482,7 +7706,9 @@ "slug": "amazon", "frequency": 3 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 113, @@ -7520,7 +7746,9 @@ "slug": "nutanix", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(n)" }, { "id": 114, @@ -7640,7 +7868,9 @@ "slug": "ixl", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 115, @@ -7775,7 +8005,9 @@ "slug": "remitly", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 116, @@ -7799,7 +8031,9 @@ "slug": "splunk", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 117, @@ -7852,7 +8086,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 118, @@ -7870,7 +8106,9 @@ "slug": "google", "frequency": 5 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 119, @@ -7892,7 +8130,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 120, @@ -7914,7 +8154,9 @@ "slug": "google", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 121, @@ -7942,7 +8184,9 @@ "slug": "amazon", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 122, @@ -7994,7 +8238,9 @@ "slug": "palo-alto-networks", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 123, @@ -8071,7 +8317,9 @@ "slug": "tiktok", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 124, @@ -8129,7 +8377,9 @@ "slug": "servicenow", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 125, @@ -8177,7 +8427,9 @@ "slug": "google", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 126, @@ -8224,7 +8476,9 @@ "slug": "apple", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 127, @@ -8266,7 +8520,9 @@ "slug": "goldman-sachs", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 128, @@ -8323,7 +8579,9 @@ "slug": "facebook", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 129, @@ -8370,7 +8628,9 @@ "slug": "verkada", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 130, @@ -8407,7 +8667,9 @@ "slug": "josh-technology", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 131, @@ -8449,7 +8711,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 132, @@ -8476,7 +8740,9 @@ "slug": "facebook", "frequency": 3 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 133, @@ -8518,7 +8784,9 @@ "slug": "palo-alto-networks", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 134, @@ -8560,7 +8828,9 @@ "slug": "oracle", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 135, @@ -8602,7 +8872,9 @@ "slug": "salesforce", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 136, @@ -8679,7 +8951,9 @@ "slug": "adobe", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 137, @@ -8690,7 +8964,9 @@ ], "difficulty": "Medium", "premium": false, - "companies": [] + "companies": [], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 138, @@ -8732,7 +9008,9 @@ "slug": "bytedance", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 139, @@ -8769,7 +9047,9 @@ "slug": "bloomberg", "frequency": 3 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 140, @@ -8826,7 +9106,9 @@ "slug": "salesforce", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 141, @@ -8904,7 +9186,9 @@ "slug": "grammarly", "frequency": 2 } - ] + ], + "timeComplexity": "Varies", + "spaceComplexity": "Varies" }, { "id": 142, @@ -8976,7 +9260,9 @@ "slug": "snapchat", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 143, @@ -9058,7 +9344,9 @@ "slug": "tcs", "frequency": 2 } - ] + ], + "timeComplexity": "Varies", + "spaceComplexity": "Varies" }, { "id": 144, @@ -9136,7 +9424,9 @@ "slug": "aurora", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 145, @@ -9273,7 +9563,9 @@ "slug": "kla", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 146, @@ -9310,7 +9602,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log k)", + "spaceComplexity": "O(k)" }, { "id": 147, @@ -9587,7 +9881,9 @@ "slug": "thoughtworks", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 148, @@ -9634,7 +9930,9 @@ "slug": "microsoft", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 149, @@ -9676,7 +9974,9 @@ "slug": "agoda", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 150, @@ -9783,7 +10083,9 @@ "slug": "meesho", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 151, @@ -9825,7 +10127,9 @@ "slug": "flipkart", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 152, @@ -9882,7 +10186,9 @@ "slug": "squarepoint-capital", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 153, @@ -9984,7 +10290,9 @@ "slug": "capgemini", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 154, @@ -10181,7 +10489,9 @@ "slug": "qualcomm", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 155, @@ -10283,7 +10593,9 @@ "slug": "hashedin", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 156, @@ -10294,7 +10606,9 @@ ], "difficulty": "Medium", "premium": false, - "companies": [] + "companies": [], + "timeComplexity": "O(m)", + "spaceComplexity": "O(ALPHABET_SIZE * N * M)" }, { "id": 157, @@ -10305,7 +10619,9 @@ ], "difficulty": "Easy", "premium": true, - "companies": [] + "companies": [], + "timeComplexity": "O(m)", + "spaceComplexity": "O(ALPHABET_SIZE * N * M)" }, { "id": 158, @@ -10327,7 +10643,9 @@ "slug": "amazon", "frequency": 2 } - ] + ], + "timeComplexity": "O(m)", + "spaceComplexity": "O(ALPHABET_SIZE * N * M)" }, { "id": 159, @@ -10344,7 +10662,9 @@ "slug": "amazon", "frequency": 11 } - ] + ], + "timeComplexity": "O(m)", + "spaceComplexity": "O(ALPHABET_SIZE * N * M)" }, { "id": 160, @@ -10355,7 +10675,9 @@ ], "difficulty": "Hard", "premium": false, - "companies": [] + "companies": [], + "timeComplexity": "O(m)", + "spaceComplexity": "O(ALPHABET_SIZE * N * M)" }, { "id": 161, @@ -10387,7 +10709,9 @@ "slug": "airbnb", "frequency": 2 } - ] + ], + "timeComplexity": "O(m)", + "spaceComplexity": "O(ALPHABET_SIZE * N * M)" }, { "id": 162, @@ -10439,7 +10763,9 @@ "slug": "mongodb", "frequency": 2 } - ] + ], + "timeComplexity": "O(m)", + "spaceComplexity": "O(ALPHABET_SIZE * N * M)" }, { "id": 163, @@ -10450,7 +10776,9 @@ ], "difficulty": "Hard", "premium": true, - "companies": [] + "companies": [], + "timeComplexity": "O(m)", + "spaceComplexity": "O(ALPHABET_SIZE * N * M)" }, { "id": 164, @@ -10474,7 +10802,9 @@ "slug": "bloomberg", "frequency": 2 } - ] + ], + "timeComplexity": "O(V + E)", + "spaceComplexity": "O(V)" }, { "id": 165, @@ -10561,7 +10891,9 @@ "slug": "autodesk", "frequency": 2 } - ] + ], + "timeComplexity": "O(log n)", + "spaceComplexity": "O(1)" }, { "id": 166, @@ -10623,7 +10955,9 @@ "slug": "autodesk", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" }, { "id": 167, @@ -10634,7 +10968,9 @@ ], "difficulty": "Easy", "premium": false, - "companies": [] + "companies": [], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 168, @@ -10732,7 +11068,9 @@ "slug": "netapp", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 169, @@ -10774,7 +11112,9 @@ "slug": "tinkoff", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 170, @@ -10812,7 +11152,9 @@ "slug": "bloomberg", "frequency": 2 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 171, @@ -10830,7 +11172,9 @@ "slug": "linkedin", "frequency": 3 } - ] + ], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 172, @@ -10841,7 +11185,9 @@ ], "difficulty": "Medium", "premium": false, - "companies": [] + "companies": [], + "timeComplexity": "O(2^n) or O(n!)", + "spaceComplexity": "O(n)" }, { "id": 173, @@ -10878,7 +11224,9 @@ "slug": "goldman-sachs", "frequency": 2 } - ] + ], + "timeComplexity": "O(n)", + "spaceComplexity": "O(1)" }, { "id": 174, @@ -10955,7 +11303,9 @@ "slug": "visa", "frequency": 2 } - ] + ], + "timeComplexity": "O(n log n)", + "spaceComplexity": "O(1)" } ] } \ No newline at end of file