chishui / terminal-leetcode

Terminal-Leetcode is a terminal based leetcode website viewer.
MIT License
256 stars 27 forks source link

When enter a problem, it will delay for about 1 second #1

Closed Jody-Lu closed 7 years ago

Jody-Lu commented 8 years ago

Hello chishui,

Thank you for your leetcode-terminal. When I use this tool, I find I have to wait for a while whenever I access a problem. So I come up some methods to handle this situation:

  1. We can get all problems when we launch the "leetcode" and store then in a dict data structure so that we can access any problem instantly.
  2. We don't get all problems first, but whenever we access a problem, we store this problem (title & body) in a cache so that we can access this problem instantly next time.
  3. We can save all problems (title & body) in a local file. At first time, we launch leetcode, get all problems and store them in this file. Next time we use leetcode, we just check whether this local file is NULL or not. If it's not, just read the file and we can access any problem instantly.
chishui commented 8 years ago

Hi Jody,

Thanks for your advise.

It does take some times to retrieve quiz detail information because of http request.

Your methods(1,3) are kinda like a web crawler does and that is not what this program meant to be (a viewer). Also I think it's unfair for Leetcode for a massive requests at the same time. However, you can easily transform the source code of this program into a web crawler as you wish.

I'll consider method 2.

Jody-Lu commented 8 years ago

Hi chichi,

Actually, I have implemented both method 1 & 2 in your code. Thanks for your comment.

BTW, in the to-do list, can you explain more about quiz list sort? Thank you.

chishui commented 8 years ago

Hi Jody,

quiz list sort is quizzes can be sorted by their ids, acceptance and difficulty, just like what you can do in Leetcode.com