@@ -36,8 +36,7 @@ def __init__(self, problem_data: dict):
3636 self .difficulty = problem_data ['difficulty' ]
3737 self .stats = problem_data ['stats' ]
3838 self .topics = problem_data .get ('topicTags' , [])
39- self .companies = problem_data .get ('companyTagStats' , {}).get ('companies' , []) if 'companyTagStats' in problem_data else []
40- self .similar_questions = json .loads (problem_data .get ('similarQuestions' , '[]' ))
39+ self .similar_questions = problem_data .get ('similarQuestionList' , [])
4140
4241 if isinstance (self .stats , str ):
4342 try :
@@ -92,16 +91,26 @@ def _format_similar_questions(self) -> str:
9291 for q in self .similar_questions [:5 ]:
9392 title = q .get ('title' , '' )
9493 difficulty = q .get ('difficulty' , '' )
94+ question_id = q .get ('questionId' , '' ) or q .get ('titleSlug' , '' )
95+ lock_symbol = " 🔒" if q .get ('isPaidOnly' , False ) else ""
96+ diff_color = COLORS ['difficulty' ].get (difficulty , 'white' )
97+
9598 if title and difficulty :
96- diff_color = COLORS ['difficulty' ].get (difficulty , 'white' )
97- lines .append (f"- { title } ([{ diff_color } ]{ difficulty } [/{ diff_color } ])" )
99+ if 'titleSlug' in q :
100+ slug = q .get ('titleSlug' )
101+ title_display = f"[link=https://leetcode.com/problems/{ slug } /]{ title } [/link]"
102+ else :
103+ title_display = title
104+
105+ question_line = f"- [{ COLORS ['problem_number' ]} ]#{ question_id } [/] { title_display } { lock_symbol } ([{ diff_color } ]{ difficulty } [/{ diff_color } ])"
106+ lines .append (question_line )
98107
99108 if len (lines ) <= 1 :
100109 return ""
101110
102111 return "\n " .join (lines )
103112
104- def display (self ):
113+ def display_probelm (self ):
105114 formatted_md = self ._format_markdown (self .content )
106115
107116 content_panel = Panel (
@@ -114,6 +123,7 @@ def display(self):
114123 )
115124 console .print (content_panel )
116125
126+ def display_stats (self ):
117127 stats_panel = Panel (
118128 self ._format_stats (),
119129 title = f"[{ COLORS ['section_title' ]} ]Statistics[/]" ,
@@ -122,6 +132,8 @@ def display(self):
122132 padding = STYLES ['panel_padding' ]
123133 )
124134 console .print (stats_panel )
135+
136+ def display_additional_info (self ):
125137 info_content = []
126138
127139 topics = self ._format_topics ()
@@ -142,19 +154,4 @@ def display(self):
142154 border_style = COLORS ['border' ],
143155 padding = STYLES ['panel_padding' ]
144156 )
145- console .print (info_panel )
146-
147- def display_full (self ):
148- self .display ()
149-
150- if self .companies :
151- company_names = [company .get ('name' , '' ) for company in self .companies if 'name' in company ]
152- if company_names :
153- companies_panel = Panel (
154- Text (", " .join (company_names )),
155- box = SIMPLE ,
156- title = "Companies" ,
157- border_style = COLORS ['border' ],
158- padding = STYLES ['panel_padding' ]
159- )
160- console .print (companies_panel )
157+ console .print (info_panel )
0 commit comments