Leetcode 中文。你可能只花一分钟写完程式码,但是比较困难在于阅读英文题目。

欧氏定理: 「英文文法跟中文是相反的。」
Return true if s is an acronym of words, and false otherwise.
上述英文句字是 Leetcode 题目常出现的句子。
正确能理解成中文,要从 「, 」(逗点)进行分割。

如果 s 是字串acronym,回传 true

Return true if s is an acronym of words,
其他就回传 false.and false otherwise.

在进行英文句子分割时要分割对,
「, 」(逗点)
of, and 都是重要的分割地方
--程式答案-----------------
2828. Check if a String Is an Acronym of Words
你可能只花一分钟写完程式码,但是比较困难在于阅读英文题目__________________\

 class Solution {public:    bool isAcronym(vector<string> &words, string s) {        string ws ="";        for( auto w: words){            ws += w[0];        }        if(ws == s)            return true;        else            return false;    }};
Check if a String Is an Acronym of Words

Given an array of strings words and a string s, determine if s is an acronym of words.

The string s is considered an acronym of words if it can be formed by concatenating the first character of each string in words in order. For example, "ab" can be formed from ["apple", "banana"], but it can't be formed from ["bear", "aardvark"].

Return true if s is an acronym of words, and false otherwise.

Example 1:

Input: words = ["alice","bob","charlie"], s = "abc"
Output: true
Explanation: The first character in the words "alice", "bob", and "charlie" are 'a', 'b', and 'c', respectively. Hence, s = "abc" is the acronym.

Example 2:

Input: words = ["an","apple"], s = "a"
Output: false
Explanation: The first character in the words "an" and "apple" are 'a' and 'a', respectively.
The acronym formed by concatenating these characters is "aa".
Hence, s = "a" is not the acronym.

Example 3:

Input: words = ["never","gonna","give","up","on","you"], s = "ngguoy"
Output: true
Explanation: By concatenating the first character of the words in the array, we get the string "ngguoy".
Hence, s = "ngguoy" is the acronym.

Constraints:

1 <= words.length <= 100
1 <= words[i].length <= 10
1 <= s.length <= 100
words[i] and s consist of lowercase English letters.

这篇是我贴在我的Linkedin 里的文章,一天内有破 150 人观看,
我应该是写的不错,才会有这么高的人次观看。
分享给大家。

我想到一个职场故事分享给大家,这是我亲身经历。
有一天,我被主管叫到他个人的辨公室里,进行一对一的面谈。
他说: 「Mr. 欧,我知道你很优秀,但是依照你现在的阶段、经历你要使别人更优秀」
其实,我当下听不懂,但是,我有背起来。
过了几年,我才理解,原来他讲的是「团队的重要」。
虽然,我是全国竞赛第一名,但整个团队的经营是主管所在意的事情。
所以,我开始写文章,分享我的经验,使读者更优秀。

作者:欧育溙 Billour Ou
Version: 2023111501


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章