-
Notifications
You must be signed in to change notification settings - Fork 302
Description
The current endpoint for /daily and /select we get the question data as html string data i would like to propose a feature structured json using the cheerio inbuild library function
how it can implemented?
using the cheerio from the we can only extract the text content now we get the full question from description to constrains as a text , the text is iterated by each word and appended to a variable if we see any key word strats with words like "Example" , "Constraints" etc we separately store the data in a json format
i have forked and almost complete this feature
your current Implementation:
my proposed implementation:
for your infomation:
the full data
{
"questionLink": "https://leetcode.com/problems/maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/",
"date": "2026-01-19",
"questionId": "1413",
"questionFrontendId": "1292",
"questionTitle": "Maximum Side Length of a Square with Sum Less than or Equal to Threshold",
"titleSlug": "maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold",
"difficulty": "Medium",
"isPaidOnly": false,
"question": {
"description": "Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.",
"examples": [
{
"input": "mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4",
"output": 2,
"explanation": "The maximum side length of square with sum less than 4 is 2 as shown.",
"images": []
},
{
"input": "mat = [[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]], threshold = 1",
"output": 0,
"explanation": "",
"images": []
}
],
"constraints": {
"m": "grid.length",
"n": "grid[i].length",
"constraint_2": "1 <= m, n <= 300",
"constraint_3": "0 <= mat[i][j] <= 104",
"constraint_4": "0 <= threshold <= 105"
}
},
"questionHtml": "
Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.
\n
<strong class="example">Example 1:
\n<img alt="" src="https://assets.leetcode.com/uploads/2019/12/05/e1.png\" style="width: 335px; height: 186px;" />\n\nInput: mat = [[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]], threshold = 4\nOutput: 2\nExplanation: The maximum side length of square with sum less than 4 is 2 as shown.\n\n\n
<strong class="example">Example 2:
\n\n\nInput: mat = [[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]], threshold = 1\nOutput: 0\n\n\n
\n
Constraints:
\n\n- \n\t
m == mat.length\n\tn == mat[i].length\n\t1 <= m, n <= 300\n\t0 <= mat[i][j] <= 104\n\t0 <= threshold <= 105\n
"exampleTestcases": "[[1,1,3,2,4,3,2],[1,1,3,2,4,3,2],[1,1,3,2,4,3,2]]\n4\n[[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2],[2,2,2,2,2]]\n1",
"topicTags": [
{
"name": "Array",
"slug": "array",
"translatedName": null
},
{
"name": "Binary Search",
"slug": "binary-search",
"translatedName": null
},
{
"name": "Matrix",
"slug": "matrix",
"translatedName": null
},
{
"name": "Prefix Sum",
"slug": "prefix-sum",
"translatedName": null
}
],
"hints": [
"Store prefix sum of all grids in another 2D array.",
"Try all possible solutions and if you cannot find one return -1.",
"If x is a valid answer then any y < x is also valid answer. Use binary search to find answer."
],
"solution": {
"id": "2908",
"canSeeDetail": true,
"paidOnly": false,
"hasVideoSolution": false,
"paidOnlyVideo": true
},
"companyTagStats": null,
"likes": 1227,
"dislikes": 105,
"similarQuestions": "[]"
}
in the key as question you just returned the html string
i implemented a utilhtml parser and returned the both structured data and html string as question and questionHtml respectively
now i am facing issues in testing , my implementation fails in 3 testes i would like to get assistant on this