IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    2020 第35周 LeetCode 记录

    Yiran\'s Blog发表于 2020-08-29 18:42:34
    love 0
    1560. Most Visited Sector in a Circular Track 链接到标题 在中间走过多少圈,对于各个扇区来说是相同的,只需要考虑起点和终点的位置关系。 class Solution: def mostVisited(self, n: int, rounds: List[int]) -> List[int]: s, d = rounds[0], rounds[-1] if s <= d: return list(range(s, d+1)) else: return list(range(1, d+1)) + list(range(s, n+1)) 1557. Minimum Number of Vertices to Reach All Nodes 链接到标题 如果某个节点出现在到达节点,那么这个节点一定不在结果中,相反则一定在结果中。 class Solution: def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]: return list(set(range(n)) - set(e[1] for e in edges)) 1558. Minimum Numbers of Function Calls to Make Target Array 链接到标题 一共有两种操作:1.


沪ICP备19023445号-2号
友情链接