This guide explains how to add your own problems or modify existing ones in the built application without needing to rebuild or have internet access.
The application is designed to allow users to modify the problem database even in offline environments like airplanes, remote locations, or secure networks. All problem data is stored in a single JSON file that you can edit directly.
After building the application, the problem database is located at:
your-app-folder/public/problems.json
Important: Always edit the file in the public folder, not the original problems folder, as the application reads from the public location at runtime.
- No Rebuild Required: Changes to
problems.jsontake effect immediately - Runtime Loading: The application reads the file on each request
- Offline Friendly: Works completely without internet connection
- Real-time Updates: Refresh your browser to see changes
Navigate to your built application folder and open:
public/problems.json
Copy this template and add it to the problems array:
{
"id": "your-problem-id",
"title": {
"en": "Your Problem Title",
"zh": "你的问题标题"
},
"difficulty": "Easy",
"tags": ["array", "hash-table"],
"description": {
"en": "Your problem description in English...",
"zh": "你的问题描述中文版..."
},
"examples": [
{
"input": "nums = [1,2,3], target = 4",
"output": "1"
}
],
"template": {
"js": "function yourFunction(nums, target) {\n // Write your code here\n return -1;\n}\nmodule.exports = yourFunction;"
},
"solution": {
"js": "function yourFunction(nums, target) {\n // Reference solution\n return nums.indexOf(target);\n}\nmodule.exports = yourFunction;"
},
"tests": [
{ "input": "[1,2,3],2", "output": "1" },
{ "input": "[4,5,6],7", "output": "-1" }
]
}- Save the file
- Refresh your browser (or visit the app)
- Your new problem should appear immediately!
id: Unique identifier (use lowercase with hyphens)title: Problem title in English and Chinesedifficulty: "Easy", "Medium", or "Hard"description: Problem description in both languagestemplate: Starting code template for userstests: Array of test cases for validation
tags: Array of tags like ["array", "hash-table"]examples: Sample input/output for clarificationsolution: Reference solution (hidden by default)
- Add a problem using the template above
- Visit the homepage to see it in the list
- Click on it to test the code editor
- Submit some code to verify the tests work
# Add a test problem
npm run test:dynamic
# Visit the app to verify it appears
# Remove the test problem
npm run test:cleanup- Use lowercase letters and hyphens:
two-sum,binary-search - Keep it descriptive but concise
- Ensure uniqueness across all problems
- Include edge cases (empty arrays, single elements)
- Test both positive and negative scenarios
- Keep input/output format consistent
- Provide a meaningful function signature
- Include helpful comments
- Always end with
module.exports = yourFunction;
{
"id": "reverse-string",
"title": {
"en": "Reverse String",
"zh": "反转字符串"
},
"difficulty": "Easy",
"tags": ["string", "two-pointers"],
"description": {
"en": "Write a function that reverses a string. The input string is given as an array of characters.",
"zh": "编写一个函数,其作用是将输入的字符串反转过来。输入字符串以字符数组的形式给出。"
},
"examples": [
{
"input": "s = ['h','e','l','l','o']",
"output": "['o','l','l','e','h']"
}
],
"template": {
"js": "function reverseString(s) {\n // Write your code here\n // Modify s in-place\n}\nmodule.exports = reverseString;"
},
"solution": {
"js": "function reverseString(s) {\n let left = 0, right = s.length - 1;\n while (left < right) {\n [s[left], s[right]] = [s[right], s[left]];\n left++;\n right--;\n }\n}\nmodule.exports = reverseString;"
},
"tests": [
{ "input": "[\"h\",\"e\",\"l\",\"l\",\"o\"]", "output": "[\"o\",\"l\",\"l\",\"e\",\"h\"]" },
{ "input": "[\"H\",\"a\",\"n\",\"n\",\"a\",\"h\"]", "output": "[\"h\",\"a\",\"n\",\"n\",\"a\",\"H\"]" }
]
}- Always validate JSON syntax before saving
- Watch out for trailing commas
- Ensure proper quote escaping in strings
- Input parameters must be JSON-parseable
- Multiple parameters: use comma separation like
"[1,2,3],5" - String inputs: use proper JSON string format
"\"hello\""
- Always include
module.exports = yourFunction; - Function name must match the one being exported
- Ensure function signature matches test expectations
- Check JSON syntax validity
- Ensure the file is saved in
public/problems.json - Refresh the browser page
- Check browser console for errors
- Verify input/output formats match
- Check function signature
- Ensure
module.exportsis correct - Test function logic independently
- Large problem sets (100+ problems) may load slower
- Consider splitting into categories if needed
- Each problem adds ~1-2KB to the JSON file
Group related problems using consistent naming:
array-easy-1,array-easy-2dp-medium-1,dp-medium-2
Always provide both English and Chinese translations for:
- Title
- Description
- Consider adding comments in both languages
Create your own tag system:
custom-algorithminterview-prepcompany-specific
Happy Coding!
Perfect for offline algorithm practice anywhere!