This is a bilingual snapshot page saved by the user at 2024-5-28 17:27 for https://mp.weixin.qq.com/s/xk21WA0lCVah1ckxN9rISQ, provided with bilingual support by Immersive Translate. Learn how to save?
cover_image

重磅,下一代 iOS 迎来重大更新,国行或无缘  Heavy, the next generation of iOS ushered in a major update, and the national bank may not have a chance

宫水三叶 宫水三叶的刷题日记 2024-05-28 14:05
Original Miyasui Sanye Gongshui Sanye's Brush Diary 2024-05-28 14:05 Shanghai

iOS 18

近日,海外记者爆料,苹果已与 OpenAI 达成协议,将聊天机器人 ChatGPT 集成到 iOS 18,双方的合作伙伴关系预计将于 WWDC 2024 上官宣。
Recently, overseas reporters broke the news that Apple has reached an agreement with OpenAI to integrate the chatbot ChatGPT into iOS 18, and the partnership between the two parties is expected to be officially announced at WWDC 2024.

作为全球供应链大师的苹果,自然也会把「硬件」的一套带到「软件」当中,那就是"多供应商混用"。
Apple, as a master of the global supply chain, will naturally bring a set of "hardware" to "software", that is, "multi-vendor mixing".

据悉,苹果由于不放心让 OpenAI 成为 iOS 新功能的单一供应商,苹果仍在努力与谷歌达成协议,提供 Gemini 作为一种选择。
It is reported that Apple is still struggling to reach a deal with Google to offer Gemini as an option because it is not comfortable with OpenAI as a single supplier of new iOS features.

"多供应商混用"在商业行为中十分常见,可以在确保「命脉不会全砸在某个单一供应商」以外,还可以「牵制单一供应商的抬价行为」。
"Multi-vendor mixing" is very common in business practices, which can not only ensure that "the lifeblood will not be smashed on a single supplier", but also "contain the price increase behavior of a single supplier".

例如苹果的屏幕供应商就有 三星、LG、夏普、JDI 和 京东方 等好几家。
For example, Apple's screen suppliers include Samsung, LG, Sharp, JDI and BOE.

消费者大多不会在意是否"多供应商混用",但会高度在意"使用感受是否统一"。
Most consumers don't care about "multi-vendor mixing", but they do care highly about "whether the user experience is uniform".

处理器、屏幕等硬件已经有成熟的行业标准,因此苹果能够在多供应商混用的前提下,确保产品使用感受的一致性。
Hardware such as processors and screens already have mature industry standards, so Apple is able to ensure a consistent product experience under the premise of mixing multiple vendors.

但诸如 AI 等软件服务,目前还没有统一的衡量标准,我十分好奇苹果是如何确保这些由不同供应商提供的软件服务的体验一致性。
But there's no single metric for software services like AI, and I'm curious to see how Apple ensures a consistent experience for these software services from different vendors.

毕竟这是我印象中,苹果首次在「主要功能的软件领域」采用非自研的解决方案。
After all, this is the first time in my memory that Apple has adopted a non-self-developed solution in the "software field of major functions".

另外,众所周知,无论是 OpenAI 还是 Google 在中国大陆都属于「荒原」。
In addition, as we all know, both OpenAI and Google are "wastelands" in Chinese mainland.

那么国行版 iOS 18 的 AI 服务是会由国内厂商提供,还是直接阉割,也将会是关键问题之一。
So whether the AI services of the Chinese version of iOS 18 will be provided by domestic manufacturers or directly castrated will also be one of the key questions.

对于大概率会出现的 iOS 18 特供版,你怎么看?
What do you think about the iOS 18 special edition, which is likely to appear?

...

回归主题。 Back to topic.

来一道和「百度」的题目。 Let's talk about the topic of "Baidu".

题目描述 Description of the topic

平台:LeetCode 平台:LeetCode

题号:1620 Question number: 1620

给你一个数组 towers 和一个整数 radius
Gives you an array towers and an integer radius .

数组  towers  中包含一些网络信号塔,其中  表示第 i 个网络信号塔的坐标是  且信号强度参数为 q
towers The array contains a number of network towers, where the coordinates of the first i network tower are and the signal strength parameter is q .

所有坐标都是在 X-Y 坐标系内的「整数」坐标。
All coordinates are "integer" coordinates within the X-Y coordinate system.

两个坐标之间的距离用「欧几里得距离」计算。 The distance between two coordinates is calculated using the "Euclidean distance".

整数 radius 表示一个塔能到达的最远距离。
An integer radius represents the farthest distance a tower can reach.

如果一个坐标跟塔的距离在 radius 以内,那么该塔的信号可以到达该坐标。
If a coordinate is radius within the distance of the tower, then the tower's signal can reach that coordinate.

在这个范围以外信号会很微弱,所以 radius 以外的距离该塔是不能到达的。
Outside of this range, the signal will be very weak, so the tower cannot be reached radius beyond the distance.

如果第 i 个塔能到达  ,那么该塔在此处的信号为 ⌊q / (1 + d)⌋ ,其中 d 是塔跟此坐标的距离。
If the first i tower can reach , then the tower will signal here , ⌊q / (1 + d)⌋ where d is the distance of the tower from this coordinate.

一个坐标的信号强度是所有能到达该坐标的塔的信号强度之和。
The signal strength of a coordinate is the sum of the signal strengths of all towers that can reach that coordinate.

请你返回数组 ,表示信号强度最大的整数坐标点  Please return the array that represents the integer coordinate point with the highest signal strength.

如果有多个坐标网络信号一样大,请你返回字典序最小的「非负」坐标。
If there are multiple coordinate networks with the same signal, please return the "non-negative" coordinate with the smallest dictionary order.

注意:

  • 坐标 (x1, y1) 字典序比另一个坐标 (x2, y2) 小,需满足以下条件之一:
    (x1, y1) The coordinates dictionary order is (x2, y2) smaller than the other coordinate, and one of the following conditions must be met:
    • 要么 x1 < x2 , or x1 < x2 ,
    • 要么 x1 == x2 且 y1 < y2 。
      or x1 == x2 y1 < y2 .
  • ⌊val⌋ 表示小于等于 val 的最大整数(向下取整函数)。
    ⌊val⌋ Represents val the largest integer less than or equal to (rounded down function).

示例 1: Example 1:图片

输入:towers = [[1,2,5],[2,1,7],[3,1,9]], radius = 2

输出:[2,1]

解释:
坐标 (2, 1) 信号强度之和为 13
- 塔 (2, 1) 强度参数为 7 ,在该点强度为 ⌊7 / (1 + sqrt(0)⌋ = ⌊7⌋ = 7
- 塔 (1, 2) 强度参数为 5 ,在该点强度为 ⌊5 / (1 + sqrt(2)⌋ = ⌊2.07⌋ = 2
- 塔 (3, 1) 强度参数为 9 ,在该点强度为 ⌊9 / (1 + sqrt(1)⌋ = ⌊4.5⌋ = 4
没有别的坐标有更大的信号强度。

示例 2: Example 2:

输入:towers = [[23,11,21]], radius = 9

输出:[23,11]

解释:由于仅存在一座信号塔,所以塔的位置信号强度最大。

示例 3: Example 3:

输入:towers = [[1,2,13],[2,1,7],[0,1,9]], radius = 2

输出:[1,2]

解释:坐标 (1, 2) 的信号强度最大。

提示:

模拟

观察数据范围:无论是 towers 数组大小、坐标 的值域大小,还是最远距离 k = radius,取值均不超过 50
Observe the data range: whether it is towers the size of the array, the size of the range of coordinates, or the maximum distance k = radius , the value does not exceed 50 .

因此我们可以直接采用「模拟」的方式进行求解,而不会面临 TLEMLE 的风险。
Therefore, we can solve the problem directly in a "simulation" way, without facing the MLE risk of TLE or .

具体的,我们建立一个大小为 的棋盘 g,用于记录每个坐标点的信号值,即 代表坐标 的信号值为 x
Specifically, we build a chessboard g of size to record the signal value of each coordinate point, that is, the signal value representing the coordinates is x .

其中 的大小是利用了「任意坐标 的取值范围不超过 」,同时「最远距离 不超过 」并且「最终答案为非负坐标」而定。
The size of is determined by using the value range of "the value range of any coordinate does not exceed ", and the "maximum distance does not exceed " and "the final answer is non-negative coordinate".

随后,我们可以枚举所有 ,并检查以该塔为中心点,大小为 的矩阵中的所有点(该塔所能贡献信号的所有坐标均落在矩阵中),枚举过程中使用变量 val 记录最大信号值,使用 xy 记录答案坐标。
Subsequently, we can enumerate all and check all the points in the matrix with the tower as the center point and the magnitude of (all the coordinates of the signal that the tower can contribute fall in the matrix), using the variables to val record the maximum signal value, and using x and y recording the answer coordinates.

Java 代码: Java code:

class Solution {
    public int[] bestCoordinate(int[][] towers, int k) {
        int[][] g = new int[110][110];
        int x = 0, y = 0, val = 0;
        for (int[] t : towers) {
            int a = t[0], b = t[1], q = t[2];
            for (int i = Math.max(0, a - k); i <= a + k; i++) {
                for (int j = Math.max(0, b - k); j <= b + k; j++) {
                    double d = Math.sqrt((a - i) * (a - i) + (b - j) * (b - j));
                    if (d > k) continue;
                    g[i][j] += Math.floor(q / (1 + d));
                    if (g[i][j] > val) {
                        x = i; y = j; val = g[i][j];
                    } else if (g[i][j] == val && (i < x || (i == x && j < y))) {
                        x = i; y = j;
                    }
                }
            }
        }
        return new int[]{x, y};
    }
}

C++ 代码: C++ code:

class Solution {
public:
    vector<intbestCoordinate(vector<vector<int>>& towers, int k) {
        const int n = 110;
        vector<vector<int>> g(n, vector<int>(n, 0));
        int x = 0, y = 0, val = 0;
        for (const auto& t : towers) {
            int a = t[0], b = t[1], q = t[2];
            for (int i = max(0, a - k); i <= a + k; ++i) {
                for (int j = max(0, b - k); j <= b + k; ++j) {
                    double d = sqrt((a - i) * (a - i) + (b - j) * (b - j));
                    if (d > k) continue;
                    g[i][j] += floor(q / (1.0 + d));
                    if (g[i][j] > val) {
                        x = i; y = j; val = g[i][j];
                    } else if (g[i][j] == val && (i < x || (i == x && j < y))) {
                        x = i; y = j;
                    }
                }
            }
        }
        return vector<int>{x, y};
    }
};

Python 代码: Python code:

class Solution:
    def bestCoordinate(self, towers: List[List[int]], k: int) -> List[int]:
        g = [[0] * 110 for _ in range(110)]
        x, y, val = 000
        for (a, b, q) in towers:
            for i in range(max(0, a - k), a + k + 1):
                for j in range(max(0, b - k), b + k + 1):
                    d = math.sqrt((a - i) * (a - i) + (b - j) * (b - j))
                    if d > k:
                        continue
                    g[i][j] += int(q / (1 + d))
                    if g[i][j] > val:
                        val, x, y = g[i][j], i, j
                    elif g[i][j] == val and ((i < x or (i == x and j < y))):
                        x, y = i, j
        return [x, y]

TypeScript 代码:

function bestCoordinate(towers: number[][], k: number): number[] {
    const g = new Array<Array<number>>(110)
    for (let i = 0; i < 110; i++) g[i] = new Array<number>(110).fill(0)
    let x = 0, y = 0, val = 0
    for (const t of towers) {
        const a = t[0], b = t[1], q = t[2]
        for (let i = Math.max(0, a - k); i <= a + k; i++) {
            for (let j = Math.max(0, b - k); j <= b + k; j++) {
                const d = Math.sqrt((a - i) * (a - i) + (b - j) * (b - j))
                if (d > k) continue
                g[i][j] += Math.floor(q / (1 + d))
                if (g[i][j] > val) {
                    x = i; y = j; val = g[i][j]
                } else if (g[i][j] == val && ((i < x) || (i == x && j < y))) {
                    x = i; y = j
                }
            }
        }
    }
    return [x, y]
}
  • 时间复杂度:需要 的复杂度枚举所有的塔 ;对于每座塔,我们需要枚举以该塔为中心点,大小为 的矩阵中的所有坐标。整体复杂度为
    Time Complexity: The complexity required to enumerate all towers; For each tower, we need to enumerate all the coordinates in the matrix with the tower as the center point and magnitude . The overall complexity is:
  • 空间复杂度:,其中 为棋盘大小 Space complexity: where is the size of the board

最后

给大伙通知一下 📢 : A 📢 word of information to everyone:

全网最低价 LeetCode 会员目前仍可用 ~ The lowest price on the whole network LeetCode membership is still available ~

📅 年度会员:有效期加赠两个月!!; 季度会员:有效期加赠两周!!
📅 Annual Membership: Two additional months of validity period!!; Quarterly Membership: Two weeks extra free after validity!!

🧧 年度会员:获 66.66 现金红包!!; 季度会员:获 22.22 现金红包!!
🧧 Annual Member: Receive 66.66 cash red envelopes!!; Quarterly Member: Get 22.22 Cash Red Envelope!!

🎁 年度会员:参与当月丰厚专属实物抽奖(中奖率 > 30%)!!
🎁 Annual Member: Participate in the month's lucrative and exclusive physical lucky draw (winning rate > 30%)!!

专属链接:leetcode.cn/premium/?promoChannel=acoier
Exclusive link: leetcode.cn/premium/?promoChannel=acoier

我是宫水三叶,每天都会分享算法知识,并和大家聊聊近期的所见所闻。
I'm Miyasui Sanye, and I share my algorithm knowledge every day and talk to you about what I've seen and heard recently.

欢迎关注,明天见。 Welcome to pay attention and see you tomorrow.


图片


苹果 · 目录 Apple · directory
上一篇7 人赚 960 亿美元,数字天才的首次独舞 7 people make $96 billion, the first solo dance of a digital genius

微信扫一扫 Wechat sweep
关注该公众号 Pay attention to the official account

继续滑动看下一个 Keep swiping to see the next one
向上滑动看下一个 Swipe up to see the next one