ARTS 第 拾肆 期

目录

内容纲要

Algorithm

Problem: 100372. 使两个整数相等的位更改次数

https://leetcode.cn/problems/number-of-bit-changes-to-make-two-integers-equal/description/

思路

将 n 和 k 转成二进制字符串,然后遍历字符串,寻找 n 中为 1,且 k 中为 1 的索引,然后
计数。

解题过程

1.bitset 将 int 转二进制
2.for 循环遍历二进制字符串

复杂度

时间复杂度: O(N)
空间复杂度: O(N)

代码

class Solution {
public:
    int minChanges(int n, int k) {
        string n_s = bitset<32>(n).to_string(),k_s = bitset<32>(k).to_string();
        int ans = 0;
        for (int i = 0; i < 32; i++) {
            if (n_s[i] == '1' && k_s[i] == '0') {
                n_s[i] = '0';
                ans++;
            }
        }
        return n_s != k_s ? -1 : ans;
    }
};

Review

https://github.com/winc-link/hummingbird/tree/master

蜂鸟物联网平台是由Golang编写的超轻量级物联网平台,具有轻量级、快速、极低的内存占用等特性,特别适用于个人开发者或初创公司承接中小型物联网项目。

https://github.com/Mozilla-Ocho/llamafile
llamafile lets you distribute and run LLMs with a single file

Tip

bazel 构建 cuda 代码,可以使用 rules_cuda
https://github.com/bazel-contrib/rules_cuda

Share

量变引起质变,大力出奇迹,两个案例:
1.雷军为了造好车,3年试驾170多辆车,还考了赛照
2.张一鸣入职海内网和饭否之后,将 Alexa排名前 1000的网站看了遍,详细统计其类型并列表

周六看了本书《大力出奇迹:张一鸣的创业心路与算法思维》,张一鸣主张应该让信息来找人,而不是人去找信息,将推荐系统做到极致,同时为了招到牛人,也是不遗余力。

打赏作者