首页 > 其他 > 详细

[LeetCode]小工具,统计数量,隐藏上锁的题目

时间:2015-11-29 00:51:06      阅读:516      评论:0      收藏:0      [点我收藏+]

LeetCode Problems List没有统计数量的功能,顺手写了一个。

下面两段只是用jquery调整网页上显示的内容,刷新网页就没用了。

比如想看题目里一共有多少Easy, Medium和Hard,就在浏览器Console中运行下面的代码。

还有一种用法,比如看还有多少没做,或者没做的题中有多少Easy, Medium和Hard,先选Unsolved Problems的filter,再用控制台运行该代码。

 

 1 //Count Problems
 2 var list = $("tbody > tr").not(".hide"), tdlist, html;
 3 console.log("---Count Problems: " + list.length);
 4 var countEasy = 0, countMedium = 0, countHard = 0;
 5 for(var i = 0; i < list.length; i++){
 6     tdlist = $(list[i]).find("td");
 7     html = $(tdlist[tdlist.length - 1]).html().toUpperCase();
 8     if(html === "EASY"){ 
 9          countEasy++;
10     }else if(html === "MEDIUM"){
11          countMedium++;
12     }else if(html === "HARD"){
13          countHard++;
14     }  
15 }
16 console.log("---Count Easy: " + countEasy);
17 console.log("---Count Medium: " + countMedium); 
18 console.log("---Count Hard: " + countHard);

 

下面一段是隐藏所有上锁的题目:

 

1 //hide locked problems
2 var list = $("tbody > tr");
3 for(var i = 0 ; i < list.length; i++){
4     if($(list[i]).find("td > i.fa-lock").length > 0){
5         $(list[i]).addClass("hide");
6         //list[i].remove();
7     }
8 }

 

[LeetCode]小工具,统计数量,隐藏上锁的题目

原文:http://www.cnblogs.com/Liok3187/p/5003772.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!