Skip to content

Commit

Permalink
add tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslaw-weber committed May 15, 2024
1 parent 22940bc commit fa59e39
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 7 deletions.
17 changes: 14 additions & 3 deletions pages/problems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,30 @@ const Problems: NextPage = () => {
<div className="">
<Head>
<title>List of Problems</title>
<meta name="description" content="Browse through a list of all available problems" />
<meta
name="description"
content="Browse through a list of all available problems"
/>
</Head>

<main className="container mx-auto p-4 justify-center flex flex-col items-center">
<h1 className="text-3xl text-center mb-6 mt-6 font-display">Problems</h1>
<h1 className="text-3xl text-center mb-6 mt-6 font-display">
Problems
</h1>
<div className="max-w-lg mx-auto">
<div className="p-4">
<ul className="list-decimal list-inside">
{problems.map((problem, index) => (
<li key={index} className="py-2">
<Link className="link link-hover" href={`/problem/${problem.id}`}>
<Link
className="link link-hover"
href={`/problem/${problem.id}`}
>
{problem.title}
</Link>
{problem.tags
? problem.tags.map((x) => <div className="badge badge-accent ml-4 badge-sm text-accent-content" key={x}>{x}</div>)
: null}
</li>
))}
</ul>
Expand Down
1 change: 1 addition & 0 deletions src/problem/list/bestTimeToBuyAndSellStocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,5 @@ export const maxProfitProblem: Problem<MaxProfitInput, ProblemState> = {
func: maxProfit,
tested: true,
id: "best-time-to-buy-and-sell-stock",
tags:["dynamic programming"]
};
1 change: 1 addition & 0 deletions src/problem/list/climbingStairs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ export const climbStairsProblem: Problem<ClimbingStairsInput, ProblemState> = {
getInput: getInput,
func: climbStairs,
id: "climbing-stairs",
tags: ["dynamic programming"],
};
1 change: 1 addition & 0 deletions src/problem/list/coinChange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ export const coinChangeProblem: Problem<CoinChangeInput, ProblemState> = {
func: coinChange,
id: "coin-change",
tested: true,
tags: ["dynamic programming"]
};
1 change: 1 addition & 0 deletions src/problem/list/container-with-most-water.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ export const maxAreaProblem: Problem<ContainerInput, ProblemState> = {
getInput,
func: maxArea,
id: "container-with-most-water",
tags: ["array", "two pointers"],
};
1 change: 1 addition & 0 deletions src/problem/list/counting-bits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,5 @@ export const countBitsProblem: Problem<CountBitsInput, ProblemState> = {
getInput,
func: countBits,
id: "counting-bits",
tags: ["bit manipulation"],
};
1 change: 1 addition & 0 deletions src/problem/list/editDistance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,5 @@ export const editDistanceProblem: Problem<EditDistanceInput, ProblemState> = {
getInput,
func: editDistance,
id: "edit-distance",
tags: ["dynamic programming", "string"],
};
1 change: 1 addition & 0 deletions src/problem/list/houseRobber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@ export const houseRobberProblem: Problem<HouseRobberInput, ProblemState> = {
func: rob,
id: "house-robber",
tested: true,
tags: ["dynamic programming"],
};
1 change: 1 addition & 0 deletions src/problem/list/longestIncreasingSubsequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ export const longestIncreasingSubsequenceProblem: Problem<LISInput, ProblemState
getInput: getInput,
func: longestIncreasingSubsequence,
id: "longest-increasing-subsequence",
tags: ["dynamic programming"],
};
1 change: 1 addition & 0 deletions src/problem/list/maximum-subarray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,5 @@ export const maxSubArrayProblem: Problem<MaxSubArrayInput, ProblemState> = {
getInput,
func: maxSubArray,
id: "maximum-subarray",
tags: ["dynamic programming"],
};
1 change: 1 addition & 0 deletions src/problem/list/minimumPathSum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ export const minPathSumProblem: Problem<MinPathSumInput, MinPathSumState> = {
getInput: getInput,
func: minPathSum,
id: "minimum-path-sum",
tags: ["2d dynamic programming"],
};
1 change: 1 addition & 0 deletions src/problem/list/missing-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,5 @@ export const missingNumberProblem: Problem<MissingNumberInput, number> = {
getInput,
func: missingNumber,
id: "missing-number",
tags: ["math", "array"],
};
1 change: 1 addition & 0 deletions src/problem/list/number-of-1-bits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ export const hammingWeightProblem: Problem<HammingWeightInput, ProblemState> = {
getInput,
func: hammingWeight,
id: "hamming-weight",
tags: ["bit manipulation"],
};
1 change: 1 addition & 0 deletions src/problem/list/two-sum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,5 @@ export const twoSumProblem: Problem<TwoSumInput, ProblemState> = {
getInput,
func: twoSum,
id: "two-sum",
tags: ["array", "two pointers"],
};
1 change: 1 addition & 0 deletions src/problem/list/uniquePaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ export const uniquePathsProblem: Problem<UniquePathsInput, UniquePathsState> = {
getInput: getInput,
func: uniquePaths,
id: "unique-paths",
tags: ["2d dynamic programming"]
};
1 change: 1 addition & 0 deletions src/problem/list/wordBreak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ export const wordBreakProblem: Problem<WordBreakInput, ProblemState> = {
func: wordBreak,
id: "word-break",
tested: true,
tags: ["dynamic programming", "string"],
};
9 changes: 5 additions & 4 deletions src/problem/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export interface Problem<Input, State> {

/* did i test this code? does it work well? */
tested?: boolean;

tags?: string[];
}

/** Represents a variable used within a ProblemState, can be a simple number or an array. */
Expand Down Expand Up @@ -100,12 +102,11 @@ export interface ProblemState {
breakpoint: number;
}


export class ListNode {
val: number;
next: ListNode | null;
constructor(val?: number, next?: ListNode | null) {
this.val = (val===undefined? 0 : val);
this.next = (next===undefined? null : next);
this.val = val === undefined ? 0 : val;
this.next = next === undefined ? null : next;
}
}
}

0 comments on commit fa59e39

Please sign in to comment.