From 9e2defd6c41e0695c20f7fbb0a637bd71faa2921 Mon Sep 17 00:00:00 2001 From: djay-S Date: Mon, 5 Jun 2023 21:56:13 +0530 Subject: [PATCH 01/12] initial code skeleton --- src/App.jsx | 51 +++++++---------------------------- src/components/login.jsx | 9 +++++++ src/components/problem.jsx | 7 +++++ src/components/problemSet.jsx | 26 ++++++++++++++++++ src/components/signup.jsx | 7 +++++ src/problemList.js | 24 +++++++++++++++++ 6 files changed, 83 insertions(+), 41 deletions(-) create mode 100644 src/components/login.jsx create mode 100644 src/components/problem.jsx create mode 100644 src/components/problemSet.jsx create mode 100644 src/components/signup.jsx create mode 100644 src/problemList.js diff --git a/src/App.jsx b/src/App.jsx index 7743965b..f22dcf6a 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,26 +1,8 @@ -/* - * Temporary problems array schema - */ -const problems = [{ - title: "201. Bitwise AND of Numbers Range", - difficulty: "Medium", - acceptance: "42%" -},{ - title: "201. Bitwise AND of Numbers Range", - difficulty: "Medium", - acceptance: "412%" -}, - { - title: "202. Happy Number", - difficulty: "Easy", - acceptance: "54.9%" - }, - { - title: "203. Remove Linked List Elements", - difficulty: "Hard", - acceptance: "42%" - }]; - +import problems from './problemList.js' +import Login from "./components/login.jsx"; +import Signup from "./components/signup.jsx"; +import Problem from "./components/problem.jsx"; +import ProblemSet from "./components/problemSet.jsx"; function App() { @@ -31,29 +13,16 @@ function App() { /problems/:problem_slug - A single problem page */ + console.log(problems) return (
Finish the assignment! Look at the comments in App.jsx as a starting point + + + +
) } -// A demo component -function ProblemStatement(props) { - const title = props.title; - const acceptance = props.acceptance; - const difficulty = props.difficulty; - - return - - {title} - - - {acceptance} - - - {difficulty} - - -} export default App diff --git a/src/components/login.jsx b/src/components/login.jsx new file mode 100644 index 00000000..86dc34ab --- /dev/null +++ b/src/components/login.jsx @@ -0,0 +1,9 @@ +function Login() { + return( +
+ Login +
+ ) +} + +export default Login \ No newline at end of file diff --git a/src/components/problem.jsx b/src/components/problem.jsx new file mode 100644 index 00000000..5ff050f0 --- /dev/null +++ b/src/components/problem.jsx @@ -0,0 +1,7 @@ +function Problem() { + return( +
Problem
+ ) +} + +export default Problem \ No newline at end of file diff --git a/src/components/problemSet.jsx b/src/components/problemSet.jsx new file mode 100644 index 00000000..953464cd --- /dev/null +++ b/src/components/problemSet.jsx @@ -0,0 +1,26 @@ +function ProblemSet(){ + return ( +
Problem Set
+ ) +} + +// A demo component +function ProblemStatement(props) { + const title = props.title; + const acceptance = props.acceptance; + const difficulty = props.difficulty; + + return + + {title} + + + {acceptance} + + + {difficulty} + + +} + +export default ProblemSet \ No newline at end of file diff --git a/src/components/signup.jsx b/src/components/signup.jsx new file mode 100644 index 00000000..47f90490 --- /dev/null +++ b/src/components/signup.jsx @@ -0,0 +1,7 @@ +function Signup() { + return( +
SignUp
+ ) +} + +export default Signup \ No newline at end of file diff --git a/src/problemList.js b/src/problemList.js new file mode 100644 index 00000000..abc909fa --- /dev/null +++ b/src/problemList.js @@ -0,0 +1,24 @@ +/* + * Temporary problems array schema + */ +const problems = [{ + title: "201. Bitwise AND of Numbers Range", + difficulty: "Medium", + acceptance: "42%" +},{ + title: "201. Bitwise AND of Numbers Range", + difficulty: "Medium", + acceptance: "412%" +}, + { + title: "202. Happy Number", + difficulty: "Easy", + acceptance: "54.9%" + }, + { + title: "203. Remove Linked List Elements", + difficulty: "Hard", + acceptance: "42%" + }]; + +export default problems \ No newline at end of file From dfbefe3c7768f5d2f30b166abfdb2ea06f290ecb Mon Sep 17 00:00:00 2001 From: djay-S Date: Tue, 6 Jun 2023 21:59:04 +0530 Subject: [PATCH 02/12] Added react-router, created header and added appropriate routes --- package-lock.json | 63 ++++++++++++++++++++++++++++++++++++++- package.json | 3 +- src/App.css | 38 +++++++++++++++++++++++ src/App.jsx | 31 ++++++++++++++----- src/components/header.jsx | 9 ++++++ src/components/home.jsx | 7 +++++ src/components/login.jsx | 6 ++-- 7 files changed, 146 insertions(+), 11 deletions(-) create mode 100644 src/components/header.jsx create mode 100644 src/components/home.jsx diff --git a/package-lock.json b/package-lock.json index cd606935..4a36cfa9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,8 @@ "version": "0.0.0", "dependencies": { "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "react-router-dom": "^6.11.2" }, "devDependencies": { "@types/react": "^18.0.28", @@ -766,6 +767,14 @@ "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", "dev": true }, + "node_modules/@remix-run/router": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.6.2.tgz", + "integrity": "sha512-LzqpSrMK/3JBAVBI9u3NWtOhWNw5AMQfrUFYB0+bDHTSw17z++WJLsPsxAuK+oSddsxk4d7F/JcdDPM1M5YAhA==", + "engines": { + "node": ">=14" + } + }, "node_modules/@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", @@ -1226,6 +1235,36 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.11.2.tgz", + "integrity": "sha512-74z9xUSaSX07t3LM+pS6Un0T55ibUE/79CzfZpy5wsPDZaea1F8QkrsiyRnA2YQ7LwE/umaydzXZV80iDCPkMg==", + "dependencies": { + "@remix-run/router": "1.6.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.11.2.tgz", + "integrity": "sha512-JNbKtAeh1VSJQnH6RvBDNhxNwemRj7KxCzc5jb7zvDSKRnPWIFj9pO+eXqjM69gQJ0r46hSz1x4l9y0651DKWw==", + "dependencies": { + "@remix-run/router": "1.6.2", + "react-router": "6.11.2" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/resolve": { "version": "1.22.2", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", @@ -1853,6 +1892,11 @@ } } }, + "@remix-run/router": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.6.2.tgz", + "integrity": "sha512-LzqpSrMK/3JBAVBI9u3NWtOhWNw5AMQfrUFYB0+bDHTSw17z++WJLsPsxAuK+oSddsxk4d7F/JcdDPM1M5YAhA==" + }, "@types/prop-types": { "version": "15.7.5", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz", @@ -2176,6 +2220,23 @@ "integrity": "sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==", "dev": true }, + "react-router": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.11.2.tgz", + "integrity": "sha512-74z9xUSaSX07t3LM+pS6Un0T55ibUE/79CzfZpy5wsPDZaea1F8QkrsiyRnA2YQ7LwE/umaydzXZV80iDCPkMg==", + "requires": { + "@remix-run/router": "1.6.2" + } + }, + "react-router-dom": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.11.2.tgz", + "integrity": "sha512-JNbKtAeh1VSJQnH6RvBDNhxNwemRj7KxCzc5jb7zvDSKRnPWIFj9pO+eXqjM69gQJ0r46hSz1x4l9y0651DKWw==", + "requires": { + "@remix-run/router": "1.6.2", + "react-router": "6.11.2" + } + }, "resolve": { "version": "1.22.2", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.2.tgz", diff --git a/package.json b/package.json index 154dd4dd..208323e3 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ }, "dependencies": { "react": "^18.2.0", - "react-dom": "^18.2.0" + "react-dom": "^18.2.0", + "react-router-dom": "^6.11.2" }, "devDependencies": { "@types/react": "^18.0.28", diff --git a/src/App.css b/src/App.css index b9d355df..0700eb24 100644 --- a/src/App.css +++ b/src/App.css @@ -40,3 +40,41 @@ .read-the-docs { color: #888; } + +#f-leetcode-header { + float: left; + font-size: x-large; +} +header { + display: flex; + justify-content: space-between; + align-items: center; + position: fixed; + top: 0; + left: 0; + width: 100%; + background-color: black; + color: white; + border: 1px solid red; +} + +header ul { + list-style: none; + margin: 0; + float: right; +} + +header ul li { + display: inline-block; + color: white; + margin: 0; + padding: 0 1em; +} + +header a { + color: inherit; + text-decoration: none; +} +.login { + border: 1px solid black; +} \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index f22dcf6a..f5eba75f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,8 +1,12 @@ +import {Route, Routes, Link, BrowserRouter} from "react-router-dom"; import problems from './problemList.js' import Login from "./components/login.jsx"; import Signup from "./components/signup.jsx"; import Problem from "./components/problem.jsx"; import ProblemSet from "./components/problemSet.jsx"; +import "./App.css" +import Home from "./components/home.jsx"; +import Header from "./components/header.jsx"; function App() { @@ -15,13 +19,26 @@ function App() { console.log(problems) return ( -
- Finish the assignment! Look at the comments in App.jsx as a starting point - - - - -
+ + {/*Finish the assignment! Look at the comments in App.jsx as a starting point*/} +
+ F-leetcode +
    +
  • Login
  • +
  • Signup
  • +
  • ProblemSet
  • +
  • Problem
  • +
+
+ + }/> + }/> + }/> + }/> + }/> + + +
) } diff --git a/src/components/header.jsx b/src/components/header.jsx new file mode 100644 index 00000000..7a5d0b3b --- /dev/null +++ b/src/components/header.jsx @@ -0,0 +1,9 @@ +function Header() { + return ( +
+ Header +
+ ) +} + +export default Header \ No newline at end of file diff --git a/src/components/home.jsx b/src/components/home.jsx new file mode 100644 index 00000000..b8dee5ef --- /dev/null +++ b/src/components/home.jsx @@ -0,0 +1,7 @@ +function Home() { + return ( +
Home
+ ) +} + +export default Home \ No newline at end of file diff --git a/src/components/login.jsx b/src/components/login.jsx index 86dc34ab..2fb091f6 100644 --- a/src/components/login.jsx +++ b/src/components/login.jsx @@ -1,7 +1,9 @@ function Login() { return( -
- Login +
+ F-leetcode + +
) } From de4b9bba16b290470eefeb9730e0abf93007165b Mon Sep 17 00:00:00 2001 From: djay-S Date: Wed, 7 Jun 2023 20:18:02 +0530 Subject: [PATCH 03/12] code refactor --- src/App.css | 32 ++------------------------------ src/components/login.jsx | 1 - 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/src/App.css b/src/App.css index 0700eb24..a58f85ca 100644 --- a/src/App.css +++ b/src/App.css @@ -5,46 +5,17 @@ text-align: center; } -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; - transition: filter 300ms; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.react:hover { - filter: drop-shadow(0 0 2em #61dafbaa); -} - -@keyframes logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} - @media (prefers-reduced-motion: no-preference) { a:nth-of-type(2) .logo { animation: logo-spin infinite 20s linear; } } -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} - #f-leetcode-header { float: left; font-size: x-large; } + header { display: flex; justify-content: space-between; @@ -75,6 +46,7 @@ header a { color: inherit; text-decoration: none; } + .login { border: 1px solid black; } \ No newline at end of file diff --git a/src/components/login.jsx b/src/components/login.jsx index 2fb091f6..fdfb30f5 100644 --- a/src/components/login.jsx +++ b/src/components/login.jsx @@ -1,7 +1,6 @@ function Login() { return(
- F-leetcode
From 16953cd713c55e82fbae67f4b41c16829a3ec30c Mon Sep 17 00:00:00 2001 From: djay-S Date: Wed, 7 Jun 2023 21:13:18 +0530 Subject: [PATCH 04/12] Designed Login Page --- src/App.css | 53 ++++++++++++++++++++++++++++++++++++++++ src/components/login.jsx | 21 +++++++++++++--- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/src/App.css b/src/App.css index a58f85ca..5b28174d 100644 --- a/src/App.css +++ b/src/App.css @@ -47,6 +47,59 @@ header a { text-decoration: none; } +.login-screen { + display: flex; + position: relative; + inset: 0; + justify-content: center; +} + .login { border: 1px solid black; + border-radius: 5px; + width: 50%; + display: flex; + flex-direction: column; + justify-items: center; + align-items: center; + padding: 1em; +} + +.input-div { + width: 60%; + margin: 0; +} + +.input-div input { + width: 100%; + height: 1.75em; +} + +.input-mini-div { + padding: 1em 0; +} + +.input-validation-msg { + text-align: initial; + color: red; + font-size: xx-small; +} + +.actions { + width: 100%; + display: flex; + justify-content: space-between; +} + +.login button { + padding: .75em 1.5em; + background-color: teal; + border: none; + border-radius: 5px; + color: white; + margin: 1em 0; +} + +.signup-btn { + margin: 1em; } \ No newline at end of file diff --git a/src/components/login.jsx b/src/components/login.jsx index fdfb30f5..86c98472 100644 --- a/src/components/login.jsx +++ b/src/components/login.jsx @@ -1,8 +1,23 @@ function Login() { return( -
- - +
+
+

F-leetcode

+
+
+ +
Enter the correct email
+
+
+ +
Enter the correct password
+
+
+ + +
+
+
) } From 576475992ab0d5968bd1968967e3268f4e340f5f Mon Sep 17 00:00:00 2001 From: djay-S Date: Wed, 7 Jun 2023 21:15:02 +0530 Subject: [PATCH 05/12] code refactor --- src/App.css | 1 + src/components/login.jsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/App.css b/src/App.css index 5b28174d..74a7e69a 100644 --- a/src/App.css +++ b/src/App.css @@ -83,6 +83,7 @@ header a { text-align: initial; color: red; font-size: xx-small; + height: 1em; } .actions { diff --git a/src/components/login.jsx b/src/components/login.jsx index 86c98472..21bb4757 100644 --- a/src/components/login.jsx +++ b/src/components/login.jsx @@ -6,11 +6,11 @@ function Login() {
-
Enter the correct email
+
-
Enter the correct password
+
From 320292c61e005dee2f6e75fc5aa5106303ee0c33 Mon Sep 17 00:00:00 2001 From: djay-S Date: Wed, 7 Jun 2023 22:03:28 +0530 Subject: [PATCH 06/12] code changes for problem list --- src/App.css | 34 +++++++++++++++++++++++++- src/App.jsx | 5 +--- src/components/problemSet.jsx | 46 ++++++++++++++++++++++++++++++++++- src/problemList.js | 24 +++++++++--------- 4 files changed, 92 insertions(+), 17 deletions(-) diff --git a/src/App.css b/src/App.css index 74a7e69a..af6dc452 100644 --- a/src/App.css +++ b/src/App.css @@ -2,7 +2,7 @@ max-width: 1280px; margin: 0 auto; padding: 2rem; - text-align: center; + /*text-align: center;*/ } @media (prefers-reduced-motion: no-preference) { @@ -103,4 +103,36 @@ header a { .signup-btn { margin: 1em; +} + +/*Problem Set*/ + +.problem-set-screen table { + border: 1px solid grey; + border-radius: 5px; + background-color: dimgrey; + padding: 1em; +} + +.problem-set-screen td { + outline: 1px solid floralwhite; + color: whitesmoke; + margin: 0; + padding: 1em; +} + +.problem-set-screen tr:hover{ + background-color: grey; +} + +.problem-set-screen .medium { + color: yellow; +} + +.problem-set-screen .hard { + color: red; +} + +.problem-set-screen .easy { + color: lightgreen; } \ No newline at end of file diff --git a/src/App.jsx b/src/App.jsx index f5eba75f..0acebf5f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,5 +1,4 @@ import {Route, Routes, Link, BrowserRouter} from "react-router-dom"; -import problems from './problemList.js' import Login from "./components/login.jsx"; import Signup from "./components/signup.jsx"; import Problem from "./components/problem.jsx"; @@ -17,7 +16,6 @@ function App() { /problems/:problem_slug - A single problem page */ - console.log(problems) return ( {/*Finish the assignment! Look at the comments in App.jsx as a starting point*/} @@ -26,8 +24,7 @@ function App() {
  • Login
  • Signup
  • -
  • ProblemSet
  • -
  • Problem
  • +
  • Problems
diff --git a/src/components/problemSet.jsx b/src/components/problemSet.jsx index 953464cd..492f2768 100644 --- a/src/components/problemSet.jsx +++ b/src/components/problemSet.jsx @@ -1,6 +1,50 @@ +import problems from '../problemList.js' + function ProblemSet(){ + + function populateProblemSet() { + console.log(problems) + + function handleProblemSelection(problem) { + console.log(problem) + } + + return( + // problems.map(problem => { + // return ( + //
+ // {problem.title} + //
+ // ) + // }) + + + + + + + + + + {problems.map(problem => { + return ( + handleProblemSelection(problem)}> + + + + + ) + })} + +
Problem TitleDifficultyAcceptance
{problem.title}{problem.difficulty}{problem.acceptance}
+ ) + } + return ( -
Problem Set
+
+ Problem Set +
{populateProblemSet()}
+
) } diff --git a/src/problemList.js b/src/problemList.js index abc909fa..8a879f39 100644 --- a/src/problemList.js +++ b/src/problemList.js @@ -2,23 +2,25 @@ * Temporary problems array schema */ const problems = [{ + id: 1, title: "201. Bitwise AND of Numbers Range", difficulty: "Medium", acceptance: "42%" },{ + id: 2, title: "201. Bitwise AND of Numbers Range", difficulty: "Medium", acceptance: "412%" -}, - { - title: "202. Happy Number", - difficulty: "Easy", - acceptance: "54.9%" - }, - { - title: "203. Remove Linked List Elements", - difficulty: "Hard", - acceptance: "42%" - }]; +},{ + id: 3, + title: "202. Happy Number", + difficulty: "Easy", + acceptance: "54.9%" +},{ + id: 4, + title: "203. Remove Linked List Elements", + difficulty: "Hard", + acceptance: "42%" +}]; export default problems \ No newline at end of file From ed0f5f43a9d3f487c8bb3be132f6d0f53a8a6ac7 Mon Sep 17 00:00:00 2001 From: djay-S Date: Fri, 9 Jun 2023 21:39:51 +0530 Subject: [PATCH 07/12] updated problems array --- src/problemList.js | 128 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 120 insertions(+), 8 deletions(-) diff --git a/src/problemList.js b/src/problemList.js index 8a879f39..2063370c 100644 --- a/src/problemList.js +++ b/src/problemList.js @@ -3,24 +3,136 @@ */ const problems = [{ id: 1, - title: "201. Bitwise AND of Numbers Range", + title: "Add Two Numbers", difficulty: "Medium", - acceptance: "42%" + accepted: 3700000, + submitted: 9000000, + description: "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.\n" + + "\n" + + "You may assume the two numbers do not contain any leading zero, except the number 0 itself.", + examples: [ + { + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + explanation: " 342 + 465 = 807." + }, + { + input: "l1 = [0], l2 = [0]", + output: "[0]" + }, + { + input: "l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]", + output: "[8,9,9,9,0,0,0,1]" + } + ], + constraints: [ + "The number of nodes in each linked list is in the range [1, 100].", + "0 <= Node.val <= 9", + "It is guaranteed that the list represents a number that does not have leading zeros." + ] },{ id: 2, - title: "201. Bitwise AND of Numbers Range", + title: "Longest Substring Without Repeating Characters", difficulty: "Medium", - acceptance: "412%" + accepted: 450, + submitted: 1340, + description: "Given a string s, find the length of the longest \n" + + "substring\n" + + " without repeating characters.", + examples: [ + { + input: "s = \"abcabcbb\"", + output: "3", + explanation: "The answer is \"abc\", with the length of 3." + }, + { + input: "s = \"bbbbb\"", + output: "1", + explanation: "The answer is \"b\", with the length of 1." + }, + { + input: "s = \"pwwkew\"", + output: "3", + explanation: "The answer is \"wke\", with the length of 3.\n" + + "Notice that the answer must be a substring, \"pwke\" is a subsequence and not a substring." + } + ], + constraints: [ + "0 <= s.length <= 5 * 104", + "s consists of English letters, digits, symbols and spaces." + ] },{ id: 3, - title: "202. Happy Number", + title: "Two Sum", difficulty: "Easy", - acceptance: "54.9%" + accepted: 980, + submitted: 1970, + description: "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.\n" + + "\n" + + "You may assume that each input would have exactly one solution, and you may not use the same element twice.\n" + + "\n" + + "You can return the answer in any order.\n" + + "\n", + examples: [ + { + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + explanation: "Because nums[0] + nums[1] == 9, we return [0, 1]." + }, + { + input: "nums = [3,2,4], target = 6", + output: "[1,2]" + }, + { + input: "nums = [3,3], target = 6", + output: "[0,1]" + } + ], + constraints: [ + "2 <= nums.length <= 104", + "-109 <= nums[i] <= 109", + "-109 <= target <= 109", + "Only one valid answer exists." + ] },{ id: 4, - title: "203. Remove Linked List Elements", + title: "Merge k Sorted Lists\n", difficulty: "Hard", - acceptance: "42%" + accepted: 160, + submitted: 330, + description: "You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.\n" + + "\n" + + "Merge all the linked-lists into one sorted linked-list and return it.", + examples: [ + { + input: "lists = [[1,4,5],[1,3,4],[2,6]]", + output: "[1,1,2,3,4,4,5,6]", + explanation: "The linked-lists are:\n" + + "[\n" + + " 1->4->5,\n" + + " 1->3->4,\n" + + " 2->6\n" + + "]\n" + + "merging them into one sorted list:\n" + + "1->1->2->3->4->4->5->6" + }, + { + input: "lists = []", + output: "[]" + }, + { + input: "lists = [[]]", + output: "[]" + } + ], + constraints: [ + "k == lists.length", + "0 <= k <= 104", + "0 <= lists[i].length <= 500", + "-104 <= lists[i][j] <= 104", + "lists[i] is sorted in ascending order.", + "The sum of lists[i].length will not exceed 104." + ] }]; export default problems \ No newline at end of file From 92a4af045edddd7cbc09939205e301ae275d068e Mon Sep 17 00:00:00 2001 From: djay-S Date: Fri, 9 Jun 2023 22:11:23 +0530 Subject: [PATCH 08/12] Added languages list, code refactor --- src/languages.js | 104 ++++++++++++++++++ src/problemList.js | 268 +++++++++++++++++++++++---------------------- 2 files changed, 239 insertions(+), 133 deletions(-) create mode 100644 src/languages.js diff --git a/src/languages.js b/src/languages.js new file mode 100644 index 00000000..4a6ada47 --- /dev/null +++ b/src/languages.js @@ -0,0 +1,104 @@ +const languages = [ + { + "id": 0, + "name": "cpp" + }, + { + "id": 1, + "name": "java" + }, + { + "id": 2, + "name": "python" + }, + { + "id": 11, + "name": "python3" + }, + { + "id": 3, + "name": "mysql" + }, + { + "id": 14, + "name": "mssql" + }, + { + "id": 15, + "name": "oraclesql" + }, + { + "id": 4, + "name": "c" + }, + { + "id": 5, + "name": "csharp" + }, + { + "id": 6, + "name": "javascript" + }, + { + "id": 7, + "name": "ruby" + }, + { + "id": 8, + "name": "bash" + }, + { + "id": 9, + "name": "swift" + }, + { + "id": 10, + "name": "golang" + }, + { + "id": 12, + "name": "scala" + }, + { + "id": 16, + "name": "html" + }, + { + "id": 17, + "name": "pythonml" + }, + { + "id": 13, + "name": "kotlin" + }, + { + "id": 18, + "name": "rust" + }, + { + "id": 19, + "name": "php" + }, + { + "id": 20, + "name": "typescript" + }, + { + "id": 21, + "name": "racket" + }, + { + "id": 22, + "name": "erlang" + }, + { + "id": 23, + "name": "elixir" + }, + { + "id": 24, + "name": "dart" + } +] + +export default languages \ No newline at end of file diff --git a/src/problemList.js b/src/problemList.js index 2063370c..6d2684c3 100644 --- a/src/problemList.js +++ b/src/problemList.js @@ -1,138 +1,140 @@ /* * Temporary problems array schema */ -const problems = [{ - id: 1, - title: "Add Two Numbers", - difficulty: "Medium", - accepted: 3700000, - submitted: 9000000, - description: "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.\n" + - "\n" + - "You may assume the two numbers do not contain any leading zero, except the number 0 itself.", - examples: [ - { - input: "l1 = [2,4,3], l2 = [5,6,4]", - output: "[7,0,8]", - explanation: " 342 + 465 = 807." - }, - { - input: "l1 = [0], l2 = [0]", - output: "[0]" - }, - { - input: "l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]", - output: "[8,9,9,9,0,0,0,1]" - } - ], - constraints: [ - "The number of nodes in each linked list is in the range [1, 100].", - "0 <= Node.val <= 9", - "It is guaranteed that the list represents a number that does not have leading zeros." - ] -},{ - id: 2, - title: "Longest Substring Without Repeating Characters", - difficulty: "Medium", - accepted: 450, - submitted: 1340, - description: "Given a string s, find the length of the longest \n" + - "substring\n" + - " without repeating characters.", - examples: [ - { - input: "s = \"abcabcbb\"", - output: "3", - explanation: "The answer is \"abc\", with the length of 3." - }, - { - input: "s = \"bbbbb\"", - output: "1", - explanation: "The answer is \"b\", with the length of 1." - }, - { - input: "s = \"pwwkew\"", - output: "3", - explanation: "The answer is \"wke\", with the length of 3.\n" + - "Notice that the answer must be a substring, \"pwke\" is a subsequence and not a substring." - } - ], - constraints: [ - "0 <= s.length <= 5 * 104", - "s consists of English letters, digits, symbols and spaces." - ] -},{ - id: 3, - title: "Two Sum", - difficulty: "Easy", - accepted: 980, - submitted: 1970, - description: "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.\n" + - "\n" + - "You may assume that each input would have exactly one solution, and you may not use the same element twice.\n" + - "\n" + - "You can return the answer in any order.\n" + - "\n", - examples: [ - { - input: "nums = [2,7,11,15], target = 9", - output: "[0,1]", - explanation: "Because nums[0] + nums[1] == 9, we return [0, 1]." - }, - { - input: "nums = [3,2,4], target = 6", - output: "[1,2]" - }, - { - input: "nums = [3,3], target = 6", - output: "[0,1]" - } - ], - constraints: [ - "2 <= nums.length <= 104", - "-109 <= nums[i] <= 109", - "-109 <= target <= 109", - "Only one valid answer exists." - ] -},{ - id: 4, - title: "Merge k Sorted Lists\n", - difficulty: "Hard", - accepted: 160, - submitted: 330, - description: "You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.\n" + - "\n" + - "Merge all the linked-lists into one sorted linked-list and return it.", - examples: [ - { - input: "lists = [[1,4,5],[1,3,4],[2,6]]", - output: "[1,1,2,3,4,4,5,6]", - explanation: "The linked-lists are:\n" + - "[\n" + - " 1->4->5,\n" + - " 1->3->4,\n" + - " 2->6\n" + - "]\n" + - "merging them into one sorted list:\n" + - "1->1->2->3->4->4->5->6" - }, - { - input: "lists = []", - output: "[]" - }, - { - input: "lists = [[]]", - output: "[]" - } - ], - constraints: [ - "k == lists.length", - "0 <= k <= 104", - "0 <= lists[i].length <= 500", - "-104 <= lists[i][j] <= 104", - "lists[i] is sorted in ascending order.", - "The sum of lists[i].length will not exceed 104." - ] -}]; +const problems = [ + { + id: 1, + title: "Add Two Numbers", + difficulty: "Medium", + accepted: 370, + submitted: 900, + description: "You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.\n" + + "\n" + + "You may assume the two numbers do not contain any leading zero, except the number 0 itself.", + examples: [ + { + input: "l1 = [2,4,3], l2 = [5,6,4]", + output: "[7,0,8]", + explanation: " 342 + 465 = 807." + }, + { + input: "l1 = [0], l2 = [0]", + output: "[0]" + }, + { + input: "l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]", + output: "[8,9,9,9,0,0,0,1]" + } + ], + constraints: [ + "The number of nodes in each linked list is in the range [1, 100].", + "0 <= Node.val <= 9", + "It is guaranteed that the list represents a number that does not have leading zeros." + ] + }, { + id: 2, + title: "Longest Substring Without Repeating Characters", + difficulty: "Medium", + accepted: 450, + submitted: 1340, + description: "Given a string s, find the length of the longest \n" + + "substring\n" + + " without repeating characters.", + examples: [ + { + input: "s = \"abcabcbb\"", + output: "3", + explanation: "The answer is \"abc\", with the length of 3." + }, + { + input: "s = \"bbbbb\"", + output: "1", + explanation: "The answer is \"b\", with the length of 1." + }, + { + input: "s = \"pwwkew\"", + output: "3", + explanation: "The answer is \"wke\", with the length of 3.\n" + + "Notice that the answer must be a substring, \"pwke\" is a subsequence and not a substring." + } + ], + constraints: [ + "0 <= s.length <= 5 * 104", + "s consists of English letters, digits, symbols and spaces." + ] + }, { + id: 3, + title: "Two Sum", + difficulty: "Easy", + accepted: 980, + submitted: 1970, + description: "Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.\n" + + "\n" + + "You may assume that each input would have exactly one solution, and you may not use the same element twice.\n" + + "\n" + + "You can return the answer in any order.\n" + + "\n", + examples: [ + { + input: "nums = [2,7,11,15], target = 9", + output: "[0,1]", + explanation: "Because nums[0] + nums[1] == 9, we return [0, 1]." + }, + { + input: "nums = [3,2,4], target = 6", + output: "[1,2]" + }, + { + input: "nums = [3,3], target = 6", + output: "[0,1]" + } + ], + constraints: [ + "2 <= nums.length <= 104", + "-109 <= nums[i] <= 109", + "-109 <= target <= 109", + "Only one valid answer exists." + ] + }, { + id: 4, + title: "Merge k Sorted Lists\n", + difficulty: "Hard", + accepted: 160, + submitted: 330, + description: "You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.\n" + + "\n" + + "Merge all the linked-lists into one sorted linked-list and return it.", + examples: [ + { + input: "lists = [[1,4,5],[1,3,4],[2,6]]", + output: "[1,1,2,3,4,4,5,6]", + explanation: "The linked-lists are:\n" + + "[\n" + + " 1->4->5,\n" + + " 1->3->4,\n" + + " 2->6\n" + + "]\n" + + "merging them into one sorted list:\n" + + "1->1->2->3->4->4->5->6" + }, + { + input: "lists = []", + output: "[]" + }, + { + input: "lists = [[]]", + output: "[]" + } + ], + constraints: [ + "k == lists.length", + "0 <= k <= 104", + "0 <= lists[i].length <= 500", + "-104 <= lists[i][j] <= 104", + "lists[i] is sorted in ascending order.", + "The sum of lists[i].length will not exceed 104." + ] + } +]; export default problems \ No newline at end of file From bbd5196f471b8059401cdce1c2e9788e1d0a6e21 Mon Sep 17 00:00:00 2001 From: djay-S Date: Fri, 9 Jun 2023 22:24:37 +0530 Subject: [PATCH 09/12] code refactor --- src/App.css | 179 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 107 insertions(+), 72 deletions(-) diff --git a/src/App.css b/src/App.css index af6dc452..01e340a6 100644 --- a/src/App.css +++ b/src/App.css @@ -1,138 +1,173 @@ #root { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - /*text-align: center;*/ + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + /*text-align: center;*/ } @media (prefers-reduced-motion: no-preference) { - a:nth-of-type(2) .logo { - animation: logo-spin infinite 20s linear; - } + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } } #f-leetcode-header { - float: left; - font-size: x-large; + float: left; + font-size: x-large; } header { - display: flex; - justify-content: space-between; - align-items: center; - position: fixed; - top: 0; - left: 0; - width: 100%; - background-color: black; - color: white; - border: 1px solid red; + display: flex; + justify-content: space-between; + align-items: center; + position: fixed; + top: 0; + left: 0; + width: 100%; + background-color: black; + color: white; + border: 1px solid red; } header ul { - list-style: none; - margin: 0; - float: right; + list-style: none; + margin: 0; + float: right; } header ul li { - display: inline-block; - color: white; - margin: 0; - padding: 0 1em; + display: inline-block; + color: white; + margin: 0; + padding: 0 1em; } header a { - color: inherit; - text-decoration: none; + color: inherit; + text-decoration: none; } .login-screen { - display: flex; - position: relative; - inset: 0; - justify-content: center; + display: flex; + position: relative; + inset: 0; + justify-content: center; } .login { - border: 1px solid black; - border-radius: 5px; - width: 50%; - display: flex; - flex-direction: column; - justify-items: center; - align-items: center; - padding: 1em; + border: 1px solid black; + border-radius: 5px; + width: 50%; + display: flex; + flex-direction: column; + justify-items: center; + align-items: center; + padding: 1em; } .input-div { - width: 60%; - margin: 0; + width: 60%; + margin: 0; } .input-div input { - width: 100%; - height: 1.75em; + width: 100%; + height: 1.75em; } .input-mini-div { - padding: 1em 0; + padding: 1em 0; } .input-validation-msg { - text-align: initial; - color: red; - font-size: xx-small; - height: 1em; + text-align: initial; + color: red; + font-size: xx-small; + height: 1em; } .actions { - width: 100%; - display: flex; - justify-content: space-between; + width: 100%; + display: flex; + justify-content: space-between; } .login button { - padding: .75em 1.5em; - background-color: teal; - border: none; - border-radius: 5px; - color: white; - margin: 1em 0; + padding: .75em 1.5em; + background-color: teal; + border: none; + border-radius: 5px; + color: white; + margin: 1em 0; } .signup-btn { - margin: 1em; + margin: 1em; } /*Problem Set*/ .problem-set-screen table { - border: 1px solid grey; - border-radius: 5px; - background-color: dimgrey; - padding: 1em; + border: 1px solid grey; + border-radius: 5px; + background-color: dimgrey; + padding: 1em; } .problem-set-screen td { - outline: 1px solid floralwhite; - color: whitesmoke; - margin: 0; - padding: 1em; + outline: 1px solid floralwhite; + color: whitesmoke; + margin: 0; + padding: 1em; } -.problem-set-screen tr:hover{ - background-color: grey; +.problem-set-screen tr:hover { + background-color: grey; } .problem-set-screen .medium { - color: yellow; + color: yellow; } .problem-set-screen .hard { - color: red; + color: red; } .problem-set-screen .easy { - color: lightgreen; + color: green; +} + +.problem { + display: flex; + width: 100%; + border: 1px solid blue; + justify-content: space-between; +} + +.problem-details { + border: 1px solid black; + width: 49%; +} + +.problem-details .problem-level.hard { + padding: 0.1em .6em; + border-radius: 10em; + background-color: rgba(255, 0, 0, 0.5); +} + +.problem-details .problem-level.easy { + padding: 0.1em .6em; + border-radius: 10em; + background-color: rgba(0, 255, 0, 0.5); +} + +.problem-details .problem-level.medium { + padding: 0.1em .6em; + border-radius: 10em; + background-color: rgba(255, 234, 0, 0.31); +} + +.playground { + border: 1px solid red; + width: 49%; } \ No newline at end of file From a533ca92d0ef8b30185f234242c7b467270a321f Mon Sep 17 00:00:00 2001 From: djay-S Date: Fri, 9 Jun 2023 22:25:14 +0530 Subject: [PATCH 10/12] Problems rendering completed --- src/components/problem.jsx | 87 ++++++++++++++++++++++++++++++++++- src/components/problemSet.jsx | 49 ++++++++++++++------ 2 files changed, 120 insertions(+), 16 deletions(-) diff --git a/src/components/problem.jsx b/src/components/problem.jsx index 5ff050f0..11653e4c 100644 --- a/src/components/problem.jsx +++ b/src/components/problem.jsx @@ -1,6 +1,89 @@ -function Problem() { +import languages from "../languages.js"; + +function Problem(props) { + console.log("Inside problem") + + function renderExamples() { + return ( +
+ { + props.examples.map((example, idx) => { + return ( +
+ {`Example${idx + 1}:`} +
+ {`Input: ${example.input}`} +
+ {`Output: ${example.output}`} +
+ {example.explanation !== undefined ? `Explanation: ${example.explanation}` : null} +
+ ) + }) + } +
+ ) + } + + function renderConstraints() { + return ( +
+ Constraints: +
    + {props.constraints.map((constraint, idx) => { + return ( +
  • {constraint}
  • + ) + })} +
+
+ ) + } + + function renderLanguageSelection() { + console.log("languages", languages) + return ( +
+ +
+ ) + } + return( -
Problem
+
+
+

{`${props.id}. ${props.title}`}

+ {props.difficulty} + {`Accepted: ${props.accepted}`} + {`Submitted: ${props.submitted}`} + {`Acceptance Rate: ${Math.round(props.accepted / props.submitted * 100)}`}% +

+ {props.description} +

+ {renderExamples()} + {renderConstraints()} +
+
+ {renderLanguageSelection()} +