Compare commits

..

3 Commits

  1. 162
      src/main/java/net/lensfrex/oj/collector/Collector.java
  2. 14
      src/main/java/net/lensfrex/oj/collector/Main.java
  3. 65
      src/main/java/net/lensfrex/oj/collector/Record.java
  4. 114
      src/main/java/net/lensfrex/oj/collector/data/QuestionDetail.java
  5. 154
      src/main/java/net/lensfrex/oj/collector/data/Result.java
  6. 32
      src/main/java/net/lensfrex/oj/collector/data/Sample.java
  7. 26
      src/main/java/net/lensfrex/oj/collector/data/Tag.java
  8. 25
      src/main/java/net/lensfrex/oj/collector/utils/NetworkUtil.java
  9. 1
      src/main/java/net/lensfrex/oj/collector/utils/ParamFiller.java
  10. 1
      src/main/resources/details_request_body.txt
  11. 1
      src/main/resources/index_request_body.txt
  12. 8
      src/main/resources/leetcode-details-request.json
  13. 177
      src/main/resources/leetcode-details.json
  14. 63
      src/main/resources/leetcode-index.json
  15. 21
      src/main/resources/template.txt

@ -1,93 +1,141 @@
package net.lensfrex.oj.collector; package net.lensfrex.oj.collector;
import com.google.gson.Gson; import com.google.gson.*;
import com.google.gson.JsonArray; import net.lensfrex.oj.collector.data.QuestionDetail;
import com.google.gson.JsonParser; import net.lensfrex.oj.collector.utils.IOUtil;
import net.lensfrex.oj.collector.data.Result;
import net.lensfrex.oj.collector.utils.NetworkUtil; import net.lensfrex.oj.collector.utils.NetworkUtil;
import org.apache.http.client.utils.URIBuilder; import net.lensfrex.oj.collector.utils.Random;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class Collector { public class Collector {
private static final String API_BASE = "https://oj.wust-acm.top/api/problem"; private static final String API_BASE = "https://leetcode.cn/graphql/";
private static final int PAGE_LIMIT = 100; private static final String DETAILS_REQUEST_BODY = IOUtil.inputStreamToString(Record.class.getResourceAsStream("/details_request_body.txt"), StandardCharsets.UTF_8);
private String generatePageRequestUrl(String baseUrl, int offset, int limit, int page) throws URISyntaxException {
URIBuilder uriBuilder = new URIBuilder(baseUrl);
uriBuilder.addParameter("paging", "true");
uriBuilder.addParameter("offset", String.valueOf(offset));
uriBuilder.addParameter("limit", String.valueOf(limit));
uriBuilder.addParameter("page", String.valueOf(page));
return uriBuilder.toString();
}
private HashMap<String, String> getHeaders() {
HashMap<String, String> headers = new HashMap<>();
headers.put("User-Agent", "lensfrex/0.0.1 CanYouSeeMe/0.0.2 IJustLearning/0.0.3");
headers.put("Host", "oj.wust-acm.top");
headers.put("Accept-Encoding", "gzip, deflate, br");
return headers;
}
private Result[] getResults(String url, Map<String, String> headers) throws IOException { private static final String INDEX_REQUEST_BODY = IOUtil.inputStreamToString(Record.class.getResourceAsStream("/index_request_body.txt"), StandardCharsets.UTF_8);
String json = NetworkUtil.get(url, headers);
JsonArray resultJsonArray = JsonParser.parseString(json).getAsJsonObject() // leetcode每次最大只能获取100条。就算设置1000每次也只能获取到100条
.getAsJsonObject("data") private static final int PAGE_LIMIT = 100;
.getAsJsonArray("results");
return new Gson().fromJson(resultJsonArray, Result[].class);
}
public ArrayList<Result> collectAllResults() { public ArrayList<QuestionDetail> collectAllQuestion() {
ArrayList<Result> results = new ArrayList<>(); ArrayList<QuestionDetail> QuestionDetails = new ArrayList<>();
try { try {
String url = generatePageRequestUrl(API_BASE, 0, 1, 1); // 先拿一条记录看看有多少题目
HashMap<String, String> headers = getHeaders(); String json = NetworkUtil.post(API_BASE, String.format(INDEX_REQUEST_BODY, 0, 1), headers);
String json = NetworkUtil.get(url, headers);
int totalResult = JsonParser.parseString(json).getAsJsonObject() int totalResult = JsonParser.parseString(json).getAsJsonObject()
.getAsJsonObject("data") .getAsJsonObject("data")
.getAsJsonObject("problemsetQuestionList")
.getAsJsonPrimitive("total").getAsInt(); .getAsJsonPrimitive("total").getAsInt();
int page = (totalResult / PAGE_LIMIT) + (totalResult % PAGE_LIMIT == 0 ? 0 : 1); int page = (totalResult / PAGE_LIMIT) + (totalResult % PAGE_LIMIT == 0 ? 0 : 1);
System.out.println("Total results: " + totalResult); System.out.println("Total results: " + totalResult);
System.out.println("Page Limit: " + PAGE_LIMIT); System.out.println("Page Limit: " + PAGE_LIMIT);
System.out.println("Total pages: " + page); System.out.println("Total pages: " + page);
for (int i = 1; i <= page; i++) { // Fetch all question list
int offset = (i - 1) * PAGE_LIMIT; ArrayList<String> questionNames = this.fetchQuestionList(page);
System.out.println("\n------------------------------------------------------");
System.out.println("Getting page " + i);
System.out.println("Offset " + offset);
url = generatePageRequestUrl(API_BASE, offset, PAGE_LIMIT, i); System.out.println("Total result: " + questionNames.size());
System.out.println("Request URL: " + url);
Result[] results1 = getResults(url, headers); // Fetch all question details
results.addAll(Arrays.asList(results1)); for (String questionTitleSlug : questionNames) {
QuestionDetail detail = fetchQuestionDetail(questionTitleSlug);
System.out.println("Successful get " + results1.length + " result(s)"); record.writeToFile(
"D:\\ojs-leetcode",
String.valueOf(detail.getId()),
detail.getChineseTitle() == null ? detail.getTitle() : detail.getChineseTitle(),
record.fillText(detail));
Thread.sleep(random.getRandomNumber(256));
} }
} catch (URISyntaxException | IOException e) {
} catch (IOException | InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
return results; System.out.println("Finish.");
return QuestionDetails;
}
//
// private String generatePageRequestUrl(String baseUrl, int offset, int limit, int page) throws URISyntaxException {
// URIBuilder uriBuilder = new URIBuilder(baseUrl);
// uriBuilder.addParameter("paging", "true");
// uriBuilder.addParameter("offset", String.valueOf(offset));
// uriBuilder.addParameter("limit", String.valueOf(limit));
// uriBuilder.addParameter("page", String.valueOf(page));
//
// return uriBuilder.toString();
// }
private final Record record = new Record();
private static final Random random = new Random();
private static HashMap<String, String> setHeaders() {
HashMap<String, String> headers = new HashMap<>();
headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.66 Safari/537.36 Edg/103.0.1264.44");
headers.put("Host", "leetcode.cn");
headers.put("Origin", "https://leetcode.cn");
headers.put("Accept-Encoding", "gzip, deflate, br");
headers.put("Content-Type", "application/json");
return headers;
}
private static final Map<String, String> headers = setHeaders();
// 起始位置
private static final int START_AT = 0;
private ArrayList<String> fetchQuestionList(int page) throws IOException {
ArrayList<String> questions = new ArrayList<>(page * PAGE_LIMIT);
String json = "";
for (int i = 1; i <= page; i++) {
int offset = (i - 1) * PAGE_LIMIT;
System.out.println("\n------------------------------------------------------");
System.out.println("Getting page " + i);
System.out.println("Offset " + offset);
json = NetworkUtil.post(API_BASE, String.format(INDEX_REQUEST_BODY, START_AT + offset, PAGE_LIMIT), headers);
JsonArray questionJsonArray =
JsonParser.parseString(json).getAsJsonObject()
.getAsJsonObject("data")
.getAsJsonObject("problemsetQuestionList")
.getAsJsonArray("questions");
for (JsonElement jsonElement : questionJsonArray) {
questions.add(jsonElement.getAsJsonObject().get("titleSlug").getAsString());
}
System.out.println("Got result " + questionJsonArray.size());
}
return questions;
}
private QuestionDetail fetchQuestionDetail(String name) throws IOException {
System.out.println("\n------------------------------------------------------");
System.out.println("Getting question: " + name);
String json = NetworkUtil.post(API_BASE, String.format(DETAILS_REQUEST_BODY, name), headers);
JsonObject question =
JsonParser.parseString(json).getAsJsonObject()
.getAsJsonObject("data")
.getAsJsonObject("question");
return new Gson().fromJson(question, QuestionDetail.class);
} }
} }

@ -1,14 +1,12 @@
package net.lensfrex.oj.collector; package net.lensfrex.oj.collector;
import net.lensfrex.oj.collector.data.Result; import net.lensfrex.oj.collector.data.QuestionDetail;
import net.lensfrex.oj.collector.utils.IOUtil; import net.lensfrex.oj.collector.utils.IOUtil;
import net.lensfrex.oj.collector.utils.ParamFiller;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
public class Main { public class Main {
@ -26,14 +24,6 @@ public class Main {
private static final String location = "D:\\ojs"; private static final String location = "D:\\ojs";
private void run() throws URISyntaxException, IOException { private void run() throws URISyntaxException, IOException {
Record record = new Record(); new Collector().collectAllQuestion();
ArrayList<Result> results = new Collector().collectAllResults();
String context = "";
for (Result result : results) {
context = record.fillText(result);
record.writeToFile(location, result.getId(), result.getTitle(), context);
}
} }
} }

@ -1,64 +1,57 @@
package net.lensfrex.oj.collector; package net.lensfrex.oj.collector;
import net.lensfrex.oj.collector.data.Result; import net.lensfrex.oj.collector.data.QuestionDetail;
import net.lensfrex.oj.collector.data.Sample; import net.lensfrex.oj.collector.data.Tag;
import net.lensfrex.oj.collector.utils.IOUtil; import net.lensfrex.oj.collector.utils.IOUtil;
import net.lensfrex.oj.collector.utils.ParamFiller; import net.lensfrex.oj.collector.utils.ParamFiller;
import java.io.File; import java.io.File;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.ResourceBundle;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class Record { public class Record {
private static final String MAIN_TEMPLATE = IOUtil.inputStreamToString(Record.class.getResourceAsStream("/template.txt"), StandardCharsets.UTF_8); private static final String MAIN_TEMPLATE = IOUtil.inputStreamToString(Record.class.getResourceAsStream("/template.txt"), StandardCharsets.UTF_8);
private static final String EXAMPLE_TEMPLATE = IOUtil.inputStreamToString(Record.class.getResourceAsStream("/exampleTemplates.txt"), StandardCharsets.UTF_8);
public String fillText(Result results) { public String fillText(QuestionDetail results) {
System.out.println("Filling: " + results.getChineseTitle());
HashMap<String, String> params = new HashMap<>(); HashMap<String, String> params = new HashMap<>();
params.put("title", results.getTitle());
params.put("description", results.getDescription()); if (results.isPaidOnly()) {
params.put("inputDescription", results.getInputDescription()); params.put("englishContent", "这道题是~付~费~内容哦");
params.put("outputDescription", results.getOutputDescription()); } else {
params.put("timeLimit", results.getTimeLimit().toString()); params.put("englishContent", results.getContent());
params.put("memoryLimit", results.getMemoryLimit().toString());
params.put("level", results.getDifficulty());
params.put("id", results.getId());
params.put("tags", results.getTags().toString());
params.put("hint", results.getHint());
StringBuffer exampleStringBuffer = new StringBuffer();
List<Sample> samples = results.getSamples();
int sampleSize = samples.size();
for (int i = 0; i < sampleSize; i++) {
exampleStringBuffer.append(fillExampleText(samples.get(i), i + 1));
} }
params.put("examples", exampleStringBuffer.toString()); params.put("englishTitle", results.getTitle());
params.put("title", results.getChineseTitle());
params.put("content", results.getChineseContent());
params.put("level", results.getDifficulty());
params.put("id", results.getId());
return ParamFiller.fill(MAIN_TEMPLATE, params); StringBuilder tagStringBuilder = new StringBuilder();
} List<Tag> tags = results.getTags();
for (Tag tag : tags) {
tagStringBuilder.append('[').append(tag.getChineseName()).append("] ");
}
private String fillExampleText(Sample sample, int index) { params.put("tags", tagStringBuilder.toString());
HashMap<String, String> params = new HashMap<>();
if (index == 1) {
params.put("index", "");
} else { StringBuilder hintStringBuilder = new StringBuilder();
params.put("index", String.valueOf(index)); List<String> hints = results.getHints();
for (String hint : hints) {
hintStringBuilder.append(hint).append("\n\n");
} }
params.put("inputExamples", sample.getInput());
params.put("outputExamples", sample.getOutput());
return ParamFiller.fill(EXAMPLE_TEMPLATE, params); params.put("hints", hintStringBuilder.toString());
return ParamFiller.fill(MAIN_TEMPLATE, params);
} }
private static final Pattern FilePattern = Pattern.compile("[\\\\/:*?\"<>|]"); private static final Pattern FilePattern = Pattern.compile("[\\\\/:*?\"<>|]");
public static String filenameFilter(String str) { private static String filenameFilter(String str) {
return str == null ? null : FilePattern.matcher(str).replaceAll(""); return str == null ? null : FilePattern.matcher(str).replaceAll("");
} }
@ -67,6 +60,8 @@ public class Record {
title = filenameFilter(title); title = filenameFilter(title);
File file = new File(String.format("%s/%s - %s.md", location, id, title)); File file = new File(String.format("%s/%s - %s.md", location, id, title));
file.getParentFile().mkdirs();
System.out.println("Will write to: " + file.getPath()); System.out.println("Will write to: " + file.getPath());
try { try {
IOUtil.writeFile(context.getBytes(StandardCharsets.UTF_8), file); IOUtil.writeFile(context.getBytes(StandardCharsets.UTF_8), file);

@ -0,0 +1,114 @@
package net.lensfrex.oj.collector.data;
import com.google.gson.annotations.SerializedName;
import java.util.List;
@SuppressWarnings("unused")
public class QuestionDetail {
@SerializedName("questionFrontendId")
private String id;
private String title;
@SerializedName("translatedTitle")
private String chineseTitle;
private String content;
@SerializedName("translatedContent")
private String chineseContent;
private String difficulty;
private List<String> hints;
@SerializedName("topicTags")
private List<Tag> tags;
private boolean isPaidOnly;
public boolean isPaidOnly() {
return isPaidOnly;
}
public void setPaidOnly(boolean paidOnly) {
isPaidOnly = paidOnly;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getChineseTitle() {
return chineseTitle;
}
public void setChineseTitle(String chineseTitle) {
this.chineseTitle = chineseTitle;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getChineseContent() {
return chineseContent;
}
public void setChineseContent(String chineseContent) {
this.chineseContent = chineseContent;
}
public String getDifficulty() {
return difficulty;
}
public void setDifficulty(String difficulty) {
this.difficulty = difficulty;
}
public List<String> getHints() {
return hints;
}
public void setHints(List<String> hints) {
this.hints = hints;
}
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
@Override
public String toString() {
String sb = "QuestionDetail{" + "id=" + id +
", title='" + title + '\'' +
", chineseTitle='" + chineseTitle + '\'' +
", content='" + content + '\'' +
", chineseContent='" + chineseContent + '\'' +
", difficulty='" + difficulty + '\'' +
", hints=" + hints +
", tags=" + tags +
'}';
return sb;
}
}

@ -1,154 +0,0 @@
package net.lensfrex.oj.collector.data;
import java.util.List;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class Result {
@SerializedName("_id")
private String id;
@Expose
private String title;
@Expose
private Object contest;
@Expose
private String description;
@SerializedName("input_description")
private String inputDescription;
@SerializedName("output_description")
private String outputDescription;
@Expose
private String difficulty;
@Expose
private String hint;
@SerializedName("memory_limit")
private Long memoryLimit;
@SerializedName("time_limit")
private Long timeLimit;
@Expose
private List<Sample> samples;
@Expose
private List<String> tags;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Object getContest() {
return contest;
}
public void setContest(Object contest) {
this.contest = contest;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDifficulty() {
return difficulty;
}
public void setDifficulty(String difficulty) {
this.difficulty = difficulty;
}
public String getHint() {
return hint;
}
public void setHint(String hint) {
this.hint = hint;
}
public Long getMemoryLimit() {
return memoryLimit;
}
public void setMemoryLimit(Long memoryLimit) {
this.memoryLimit = memoryLimit;
}
public Long getTimeLimit() {
return timeLimit;
}
public void setTimeLimit(Long timeLimit) {
this.timeLimit = timeLimit;
}
public String getInputDescription() {
return inputDescription;
}
public void setInputDescription(String inputDescription) {
this.inputDescription = inputDescription;
}
public String getOutputDescription() {
return outputDescription;
}
public void setOutputDescription(String outputDescription) {
this.outputDescription = outputDescription;
}
public List<Sample> getSamples() {
return samples;
}
public void setSamples(List<Sample> samples) {
this.samples = samples;
}
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
@Override
public String toString() {
final StringBuffer sb = new StringBuffer("Result{");
sb.append("id='").append(id).append('\'');
sb.append(", title='").append(title).append('\'');
sb.append(", contest=").append(contest);
sb.append(", description='").append(description).append('\'');
sb.append(", difficulty='").append(difficulty).append('\'');
sb.append(", hint='").append(hint).append('\'');
sb.append(", memoryLimit=").append(memoryLimit);
sb.append(", timeLimit=").append(timeLimit);
sb.append(", inputDescription='").append(inputDescription).append('\'');
sb.append(", outputDescription='").append(outputDescription).append('\'');
sb.append(", samples=").append(samples);
sb.append(", tags=").append(tags);
sb.append('}');
return sb.toString();
}
}

@ -1,32 +0,0 @@
package net.lensfrex.oj.collector.data;
import javax.annotation.Generated;
import com.google.gson.annotations.Expose;
@Generated("net.hexar.json2pojo")
@SuppressWarnings("unused")
public class Sample {
@Expose
private String input;
@Expose
private String output;
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public String getOutput() {
return output;
}
public void setOutput(String output) {
this.output = output;
}
}

@ -0,0 +1,26 @@
package net.lensfrex.oj.collector.data;
import com.google.gson.annotations.SerializedName;
public class Tag {
private String name;
@SerializedName("translatedName")
private String chineseName;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getChineseName() {
return chineseName;
}
public void setChineseName(String chineseName) {
this.chineseName = chineseName;
}
}

@ -4,7 +4,12 @@ import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
import org.apache.http.client.ClientProtocolException; import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler; import org.apache.http.client.ResponseHandler;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
@ -21,6 +26,26 @@ public class NetworkUtil {
public static final String REQUEST_USERAGENT = "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.7113.93 Safari/537.36"; public static final String REQUEST_USERAGENT = "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.7113.93 Safari/537.36";
public static String post(String url, String data, Map<String, String> headers) throws IOException {
CloseableHttpClient httpClient = HttpClients.createDefault();
RequestConfig requestConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
HttpPost httpPost = new HttpPost(url);
httpPost.setConfig(requestConfig);
for (String key : headers.keySet()) {
httpPost.setHeader(key, headers.get(key));
}
ResponseHandler<String> responseHandler = new BasicResponseHandler();
httpPost.setEntity(new StringEntity(data, "utf-8"));
String response = httpClient.execute(httpPost, responseHandler);
httpClient.close();
return response;
}
public static String get(String url, Map<String, String> headers) throws IOException { public static String get(String url, Map<String, String> headers) throws IOException {
CloseableHttpClient httpClient = HttpClients.createDefault(); CloseableHttpClient httpClient = HttpClients.createDefault();
// HttpGet httpGet = new HttpGet("https://oj.wust-acm.top/api/problem?paging=true&offset=0&limit=10&page=1"); // HttpGet httpGet = new HttpGet("https://oj.wust-acm.top/api/problem?paging=true&offset=0&limit=10&page=1");

@ -20,6 +20,7 @@ public class ParamFiller {
if (value != null) { if (value != null) {
// 直接正则替换遇到$会报错 // 直接正则替换遇到$会报错
// 后面会改一改
value = value.replace("$", "$"); value = value.replace("$", "$");
} }
matcher.appendReplacement(stringBuffer, value == null ? "" : value); matcher.appendReplacement(stringBuffer, value == null ? "" : value);

@ -0,0 +1 @@
{"operationName":"questionData","variables":{"titleSlug":"%s"},"query":"query questionData($titleSlug: String!) { question(titleSlug: $titleSlug) { questionId questionFrontendId categoryTitle boundTopicId title titleSlug content translatedTitle translatedContent isPaidOnly difficulty likes dislikes isLiked similarQuestions contributors { username profileUrl avatarUrl __typename } langToValidPlayground topicTags { name slug translatedName __typename } companyTagStats codeSnippets { lang langSlug code __typename } stats hints solution { id canSeeDetail __typename } status sampleTestCase metaData judgerAvailable judgeType mysqlSchemas enableRunCode envInfo book { id bookName pressName source shortDescription fullDescription bookImgUrl pressImgUrl productUrl __typename } isSubscribed isDailyQuestion dailyRecordStatus editorType ugcQuestionId style exampleTestcases jsonExampleTestcases __typename }}"}

@ -0,0 +1 @@
{"query":" query problemsetQuestionList($categorySlug: String, $limit: Int, $skip: Int, $filters: QuestionListFilterInput) { problemsetQuestionList( categorySlug: $categorySlug limit: $limit skip: $skip filters: $filters ) { hasMore total questions { acRate difficulty freqBar frontendQuestionId isFavor paidOnly solutionNum status title titleCn titleSlug topicTags { name nameTranslated id slug } extra { hasVideoSolution topCompanyTags { imgUrl slug numSubscribed } } } }} ","variables":{"categorySlug":"","skip":%d,"limit":%d,"filters":{}}}

@ -0,0 +1,8 @@
{
"operationName": "questionData",
"variables": {
"titleSlug": "two-sum"
},
"query": "query questionData($titleSlug: String!) {\n question(titleSlug: $titleSlug) {\n questionId\n questionFrontendId\n categoryTitle\n boundTopicId\n title\n titleSlug\n content\n translatedTitle\n translatedContent\n isPaidOnly\n difficulty\n likes\n dislikes\n isLiked\n similarQuestions\n contributors {\n username\n profileUrl\n avatarUrl\n __typename\n }\n langToValidPlayground\n topicTags {\n name\n slug\n translatedName\n __typename\n }\n companyTagStats\n codeSnippets {\n lang\n langSlug\n code\n __typename\n }\n stats\n hints\n solution {\n id\n canSeeDetail\n __typename\n }\n status\n sampleTestCase\n metaData\n judgerAvailable\n judgeType\n mysqlSchemas\n enableRunCode\n envInfo\n book {\n id\n bookName\n pressName\n source\n shortDescription\n fullDescription\n bookImgUrl\n pressImgUrl\n productUrl\n __typename\n }\n isSubscribed\n isDailyQuestion\n dailyRecordStatus\n editorType\n ugcQuestionId\n style\n exampleTestcases\n jsonExampleTestcases\n __typename\n }\n}\n"
}

File diff suppressed because one or more lines are too long

@ -0,0 +1,63 @@
{
"data": {
"problemsetQuestionList": {
"__typename": "QuestionListNode",
"questions": [
{
"__typename": "QuestionLightNode",
"acRate": 0.5265447404489151,
"difficulty": "EASY",
"freqBar": 0,
"paidOnly": false,
"status": "NOT_STARTED",
"frontendQuestionId": "1",
"isFavor": false,
"solutionNum": 18322,
"title": "Two Sum",
"titleCn": "两数之和",
"titleSlug": "two-sum",
"topicTags": [
{
"id": "wg0rh",
"name": "Array",
"slug": "array",
"nameTranslated": "数组",
"__typename": "CommonTagNode"
},
{
"id": "wzve3",
"name": "Hash Table",
"slug": "hash-table",
"nameTranslated": "哈希表",
"__typename": "CommonTagNode"
}
],
"extra": {
"companyTagNum": 394,
"hasVideoSolution": true,
"topCompanyTags": [
{
"imgUrl": "https://pic.leetcode-cn.com/5352d58e4b296e0704f20cfd99ecaec7af71d079b015923c72928650312c55b8-Messages Image(3349252251).png",
"slug": "amazon",
"__typename": "CommonTagNode"
},
{
"imgUrl": "https://pic.leetcode-cn.com/45a64add888e66ff6d3c551bed948528715996937b877aaf6fdc08eae74789f5-google-logo-png-open-2000.png",
"slug": "google",
"__typename": "CommonTagNode"
},
{
"imgUrl": "https://pic.leetcode-cn.com/cca55ecdfb504378955a9bf4f2f33897bb84f04f9cbf84ea96321ce5d959ee13-adobe1.png",
"slug": "adobe",
"__typename": "CommonTagNode"
}
],
"__typename": "QuestionExtraInfoNode"
}
}
],
"hasMore": true,
"total": 2696
}
}
}

@ -1,25 +1,20 @@
# {{title}} # {{englishTitle}} | {{title}}
-------------------------------- --------------------------------
## 题目: ## 题目 (English & 中文)
{{description}} {{englishContent}}
## 输入: ---
> {{inputDescription}}
## 输出: {{content}}
> {{outputDescription}}
-------------------------------- --------------------------------
## 提示:{{hint}} ## 提示:
{{examples}} {{hints}}
-------------------------------- --------------------------------
- 时间限制:{{timeLimit}} - 难度:{{level}}
- 内存限制:{{memoryLimit}}
- 等级:{{level}}
- id:{{id}} - id:{{id}}
- 标签:{{tags}} - 标签:{{tags}}

Loading…
Cancel
Save