ARTS 第 拾 期

目录

内容目录

Algorithm

题目:
https://leetcode.cn/problems/find-the-minimum-area-to-cover-all-ones-i/description/

题解:
扫描矩阵,找到左上,左下,右上,右下,时间复杂度:O(M*N)

class Solution {
public:
    int minimumArea(vector<vector<int>>& grid) {
        int m = grid.size(), n = grid[0].size();
        int xmin = 1e9, xmax = -1, ymin = 1e9, ymax = -1;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (grid[i][j]) {
                    xmin = min(xmin, i);
                    xmax = max(xmax, i);
                    ymin = min(ymin, j);
                    ymax = max(ymax, j);
                }
            }
        }
        return (ymax - ymin + 1)*(xmax - xmin + 1);
    }
};

Review

https://arxiv.org/pdf/2310.08710
Waymax, a multi-agent simulator for autonomous driving.

waymo 开发的用于自动驾驶的多代理模拟器。

Tip

除了用 clang-format 格式化代码,也可以用 git-clang-format 格式化 commit, 如果只是想查看格式化前后对比,可以通过加参数 ‘‘-diff’’ 实现。

➜  ~ git-clang-format --help
usage: git clang-format [OPTIONS] [<commit>] [<commit>|--staged] [--] [<file>...]

If zero or one commits are given, run clang-format on all lines that differ
between the working directory and <commit>, which defaults to HEAD.  Changes are
only applied to the working directory, or in the stage/index.

Examples:
  To format staged changes, i.e everything that's been `git add`ed:
    git clang-format

  To also format everything touched in the most recent commit:
    git clang-format HEAD~1

  If you're on a branch off main, to format everything touched on your branch:
    git clang-format main

If two commits are given (requires --diff), run clang-format on all lines in the
second <commit> that differ from the first <commit>.

The following git-config settings set the default of the corresponding option:
  clangFormat.binary
  clangFormat.commit
  clangFormat.extensions
  clangFormat.style

positional arguments:
  <commit>              revision from which to compute the diff
  <file>...             if specified, only consider differences in these files

options:
  -h, --help            show this help message and exit
  --binary BINARY       path to clang-format
  --commit COMMIT       default commit to use if none is specified
  --diff                print a diff instead of applying the changes
  --diffstat            print a diffstat instead of applying the changes
  --extensions EXTENSIONS
                        comma-separated list of file extensions to format,
                        excluding the period and case-insensitive
  -f, --force           allow changes to unstaged files
  -p, --patch           select hunks interactively
  -q, --quiet           print less information
  --staged, --cached    format lines in the stage instead of the working dir
  --style STYLE         passed to clang-format
  -v, --verbose         print extra information
  --diff_from_common_commit
                        diff from the last common commit for commits in
                        separate branches rather than the exact point of the
                        commits

Share

关于黑天鹅

塔勒布在《黑天鹅》中说道:

我们的世界是由极端、未知和非常不可能发生的(以我们现有的知识而言非常不可能发生的)事物所主导的,而我们却一直把时间花在讨论琐碎的事情上,只关注已知和重复发生的事物

一只鸡每天都等着准时的喂养,直到圣诞前天,被做成食物,未来是混沌的,难以预测,我们潜意识也要准备黑天鹅的到来,无论是正向黑天鹅,还是黑天鹅。平常的日子里好好吃饭、好好锻炼、好好看书、好好工作,直到黑天鹅事件发生,抓住机会,趁势而发。

关于街头智慧
接触的人越多,发现读了书的、学历高的貌似是一个模子里面刻出来的,单线思维,患得患失,也许就是绩优主义的后遗症,像是《优秀的绵羊》描述的那样:

这套精英教育体系培养出来的学生大都聪明,有天分,斗志昂扬,但同时又充满焦虑、胆小怕事,对未来一片茫然,极度缺乏目标感:他们被包裹在一个巨大的特权泡泡里,所有人都在老实巴交地向着同一个方向前进。他们非常擅于解决手头的问题,却不知道为什么要解决这些问题。

反而那些早早出来工作,在一些传统行业比如餐饮摸爬滚打的人,活得通透。

关于自由的追求:
1.财务自由
2.健康自由
3.时间自由
4.关系自由

打赏作者