avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • Resume
  • Archives
  • Categories
  • Photos
  • Music



{{ date }}

{{ time }}

avatar
Siz Long

My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is me.longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.

  • 主页
  • Resume
  • Archives
  • Categories
  • Photos
  • Music

1817. Find the number of users of users active One question daily

  2024-01-01        
字数统计: 108字   |   阅读时长: 1min

2023-01-21.png

1817. Find the number of users of users active


我的answer:

This question is mainlyHash tableKnowledge point,But we can usedefaultdictDo,You can save a few lines of code。
defaultdictIt can assume that existencekeyInitial value,So we only use directlyappend()oradd()Be。
这次和官方answer一模一样呢!

1
2
3
4
5
6
7
8
9
10
11
class Solution:
def findingUsersActiveMinutes(self, logs: List[List[int]], k: int) -> List[int]:
dict1 = defaultdict(set)
list1 = [0] * k
for i, j in logs:
dict1[i].add(j)
for i in dict1:
print(dict1[i])
# TypeError object of type ‘type‘ has no len() Because ofdictLess1
list1[len(dict1[i]) - 1] += 1
return list1
  • Python
  • answer
  • Hash table

扫一扫,分享到微信

微信分享二维码
1813. Sentence similarity III
1825. Seek out MK average value
目录
  1. 1. 我的answer:

150 篇 | 131.7k
次 | 人
这里自动载入天数这里自动载入时分秒
2022-2025 loong loong | 新南威尔士龙龙号