/images/avatar.png

lc314. Binary Tree Vertical Order Traversal

Given the root of a binary tree, return the vertical order traversal of its nodes’ values. (i.e., from top to bottom, column by column).

If two nodes are in the same row and column, the order should be from left to right.

Example 1:

https://cdn.jsdelivr.net/gh/JoshuaChou2018/oss@main/uPic/vtree1.iiO12U.QkFbUS.jpg

1
2
Input: root = [3,9,20,null,null,15,7]
Output: [[9],[3,15],[20],[7]]

Example 2:

https://cdn.jsdelivr.net/gh/JoshuaChou2018/oss@main/uPic/vtree2-1.z96seX.jpg

[NeurIPS] Personalized Federated Learning: A Meta-Learning Approach解读

Title: Personalized Federated Learning: A Meta-Learning Approach

INFO: 34th Conference on Neural Information Processing Systems (NeurIPS 2020)

研究背景

目前的联邦学习框架是基于所有users的数据,整合训练出一个最优的server模型。

However, this scheme only develops a common output for all the users, and, therefore, it does not adapt the model to each user.

但是,这样训练处来的server模型不一定适用于每一个user,尤其在不同的users所独有的数据差异比较大的时候。

This is an important missing feature, especially given the heterogeneity of the underlying data distribution for various users.

在heterogeneous的情景下,使用federated averaging方法训练出来的模型可能在每个独立user上的表现会比较差。

In particular, in the heterogeneous settings where the underlying data distribution of users are not identical, the resulted global model obtained by minimizing the average loss could perform arbitrarily poorly once applied to the local dataset of each user.

SCI高频词汇

并列递进

moreover, in addition, furthermore, besides, likewise, also, then, additionally

转折

not, yet, however, nevertheless, nonetheless, meanwhile, on the other hand, on the contrary, conversely, paradoxically, by contrast, in spite of,rather than, instead of, unfortunately

解释

in other words, in fact, as a matter of fact, that is, namely, in simpler terms

对比比较

Likewise, Similarly, In parallel to, while, whereas,

原因

because, because of, as, since, owing to, due to, thanks to, for this reason

lc253. 会议室 II

给你一个会议时间安排的数组 intervals ,每个会议时间都会包括开始和结束的时间 intervals[i] = [starti, endi] ,返回 所需会议室的最小数量 。

示例 1:

输入:intervals = [[0,30],[5,10],[15,20]] 输出:2

示例 2:

输入:intervals = [[7,10],[2,4]] 输出:1

提示:

1 <= intervals.length <= 104 0 <= starti < endi <= 106

解题思路

我们可以想象把这些interval给叠起来,所需要会议室的最小数量就等于最大重叠的interval的数目。

转化为上下车问题,每个interval的开始时间+1,每个interval的结束时间-1,然后我们统计counter的最大数值。

换个思路就是我们以时间为单位,我们可以知道每个单位时间车上的总人数是增加多少还是减少多少,这样我们可以直接求和从开始扫描到结束,获取当前车上最大的人数就可以。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Solution(object):
    def minMeetingRooms(self, intervals):
        """
        :type intervals: List[List[int]]
        :rtype: int
        """
        dic={}
        for interval in intervals:
            try:
                dic[interval[0]]+=1
            except:
                dic[interval[0]]=1
            try:
                dic[interval[1]]-=1
            except:
                dic[interval[1]]=-1
        max_=0
        count=0
        for key in sorted(dic.keys()):
            count+=dic[key]
            if count>max_:
                max_=count
        return max_

lc938. Range Sum of BST

Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high].

Example 1:

https://cdn.jsdelivr.net/gh/JoshuaChou2018/oss@main/uPic/bst1.mScA0F.jpg

1
2
3
Input: root = [10,5,15,3,7,null,18], low = 7, high = 15
Output: 32
Explanation: Nodes 7, 10, and 15 are in the range [7, 15]. 7 + 10 + 15 = 32.

Example 2: