Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit60fba22

Browse files
committed
Update siteData script and data
1 parent8a262a0 commit60fba22

16 files changed

+331
-1881
lines changed

‎.problemList.json

Lines changed: 0 additions & 1633 deletions
This file was deleted.

‎.problemSiteData.json

Lines changed: 294 additions & 117 deletions
Large diffs are not rendered by default.

‎.rufo

Whitespace-only changes.

‎1376-time-needed-to-inform-all-employees.kt

Lines changed: 0 additions & 22 deletions
This file was deleted.
File renamed without changes.

‎javascript/0682-baseball-game.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,28 @@
22
*@param {string[]} operations
33
*@return {number}
44
*/
5-
varcalPoints=function(operations){
5+
varcalPoints=function(operations){
6+
letrunningSum=0;
67
conststack=[];
7-
for(constopofoperations){
8-
if(op==="+"){
9-
stack.push(stack[stack.length-1]+stack[stack.length-2]);
10-
}elseif(op==="C"){
11-
stack.pop()
12-
}elseif(op==="D"){
13-
stack.push(stack[stack.length-1]*2);
14-
}else{
15-
stack.push(parseInt(op))
8+
for(constoofoperations){
9+
if(o==='C'){
10+
runningSum-=stack.pop();
11+
continue;
1612
}
13+
if(o==='D'){
14+
constval=stack[stack.length-1]*2;
15+
stack.push(val);
16+
runningSum+=val;
17+
continue;
18+
}
19+
if(o==='+'){
20+
constval=stack[stack.length-1]+stack[stack.length-2];
21+
stack.push(val);
22+
runningSum+=val;
23+
continue;
24+
}
25+
stack.push(+o);
26+
runningSum+=+o;
1727
}
18-
returnstack.reduce((prev,curr)=>prev+curr,0)
28+
returnrunningSum;
1929
};

‎python/0067-add-binary.py

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎python/0122-best-time-to-buy-and-sell-stock-ii.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎python/1189-maximum-number-of-balloons.py

Lines changed: 0 additions & 12 deletions
This file was deleted.

‎updateSiteData.js

Lines changed: 16 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
constfs=require('fs');
44

5-
constPROBLEMS_OBJ=JSON.parse(fs.readFileSync('./.problemList.json','utf8'));
65
constPROBLEMS_SITE_DATA=JSON.parse(fs.readFileSync('./.problemSiteData.json','utf8'));
76

87
constlanguages=[
@@ -88,72 +87,29 @@ for (const lang of languages) {
8887
console.log(`This many files in${langDir}:${files.length}`);
8988

9089
letcounter=0;
91-
for(constcategoryinPROBLEMS_OBJ){
92-
for(constproblemofPROBLEMS_OBJ[category]){
93-
consturl=problem[1];
94-
95-
// Use leetcode url path to rename each problem for consistency
96-
letproblemName=problem[1].replace('https://leetcode.com/problems/','');
97-
constproblemUrlName=`${problemName}`;// deep copy problemName;
98-
problemName=problemName.replace('/','').toLowerCase();
99-
100-
// Use problem number to find each problem
101-
constproblemNumber=problem[2];
102-
constnewProblemNumber=updateProblemNumber(problem[2]);
103-
104-
constfoundFile=files.find(file=>file.name.startsWith(`${problemNumber.toString()}-`));
105-
if(foundFile&&foundFile.isFile()){
106-
// rename file to match leetcode url path
107-
constoldFile=`${langDir}/${foundFile.name}`;
108-
constnewFile=`${langDir}/${newProblemNumber}-${problemName}.${langExt}`;
109-
if(oldFile!==newFile){
110-
fs.renameSync(oldFile,newFile);
111-
counter++;
112-
}
113-
updateSiteData(problemUrlName,`${newProblemNumber}-${problemName}`,langDir);
90+
for(constproblemofPROBLEMS_SITE_DATA){
91+
letproblemName=problem['link'].replace('/','').toLowerCase();
92+
93+
// Use problem number to find code file
94+
constproblemNumber=problem['code'].split('-')[0];
95+
constfoundFile=files.find(file=>file.name.startsWith(`${problemNumber.toString()}-`));
96+
97+
if(foundFile&&foundFile.isFile()){
98+
// rename file to match leetcode url path
99+
constoldFile=`${langDir}/${foundFile.name}`;
100+
constnewFile=`${langDir}/${problemNumber}-${problemName}.${langExt}`;
101+
if(oldFile!==newFile){
102+
fs.renameSync(oldFile,newFile);
103+
counter++;
114104
}
105+
problem[langDir]=true;// add language to problemSiteData
115106
}
116107
}
117108
console.log(`Renamed${counter} files in${langDir}, which had${files.length} total files.`);
118109
}
119110

120-
// Add leading zeros to make four digits long (24 -> 0024)
121-
functionupdateProblemNumber(problemNumberInt){
122-
letproblemNumber=problemNumberInt.toString();
123-
while(problemNumber.length<4){
124-
problemNumber='0'+problemNumber;
125-
}
126-
returnproblemNumber;
127-
}
128-
129-
functionupdateSiteData(problemUrlName,newCodeLink,langName){
130-
for(constpofPROBLEMS_SITE_DATA){
131-
// TODO: Bug here where some problem names are too similar (e.g. LC 300 and LC 673)
132-
if(problemUrlName===p.link){
133-
p.code=newCodeLink;
134-
p[langName]=true;
135-
return;
136-
}
137-
}
138-
console.log(`Could not find${problemUrlName} in PROBLEMS_SITE_DATA for${langName}.`);
139-
}
140-
141-
111+
// Write updated problemSiteData to file
142112
fs.writeFile('./.problemSiteData.json',JSON.stringify(PROBLEMS_SITE_DATA),function(err){
143113
if(err)throwerr;
144114
console.log('Saved!');
145115
});
146-
147-
148-
/** Update problem numbers in .problemList.json */
149-
150-
// for (const category in PROBLEMS_OBJ) {
151-
// for (const problem of PROBLEMS_OBJ[category]) {
152-
// problem[2] = updateProblemNumber(problem[2]);
153-
// }
154-
// }
155-
156-
// fs.writeFile('./.problemList.json', JSON.stringify(PROBLEMS_OBJ), function (err) {
157-
// if (err) throw err;
158-
// console.log('Saved!');
159-
// });

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp