当前位置: 首页 > news >正文

wordpress 添加分类广东知名seo推广多少钱

wordpress 添加分类,广东知名seo推广多少钱,画中画有哪些网站可以做,网站竞价托管以下为个人解法,欢迎提供不同思路 1768. 交替合并字符串 题目:给你两个字符串 word1 和 word2 。请你从 word1 开始,通过交替添加字母来合并字符串。如果一个字符串比另一个字符串长,就将多出来的字母追加到合并后字符串的末尾&…

以下为个人解法,欢迎提供不同思路

1768. 交替合并字符串

题目:给你两个字符串 word1 和 word2 。请你从 word1 开始,通过交替添加字母来合并字符串。如果一个字符串比另一个字符串长,就将多出来的字母追加到合并后字符串的末尾,返回 合并后的字符串 。

个人思路:我的思路是先比较字符串长度,如果相等则每次都添加二者字符串一个字符,如不相等,则找到最小的字符串长度n,然后每次都添加二者字符串一个字符直到长度n,最后把最长的字符串剩下的都添加到新字符串

class Solution
{
public:string mergeAlternately(string word1, string word2){string new_word;if (word1.size() == word2.size()){for (int i = 0; i < word1.size(); i++){new_word += word1[i];new_word += word2[i];}return new_word;}if (word1.size() > word2.size()){int i = 0;for (i = 0; i < word2.size(); i++){new_word += word1[i];new_word += word2[i];}for (; i < word1.size(); i++){new_word += word1[i];}return new_word;}if (word1.size() < word2.size()){int i = 0;for (i = 0; i < word1.size(); i++){new_word += word1[i];new_word += word2[i];}for (; i < word2.size(); i++){new_word += word2[i];}return new_word;}return new_word;}
};

在这里插入图片描述

389. 找不同

题目:给定两个字符串 s 和 t ,它们只包含小写字母。字符串 t 由字符串 s 随机重排,然后在随机位置添加一个字母。请找出在 t 中被添加的字母。

个人思路:我的思路是先通过sort排序,然后再遍历字符串找出不同

class Solution {
public:char findTheDifference(string s, string t) {int i = 0;sort(s.begin(), s.end());sort(t.begin(), t.end());for (i = 0; i < s.length(); i++) {if (t[i] != s[i]) {return t[i];}}return t[i];}
};

在这里插入图片描述

学习到的新的思路:可以将二者字符串的ASCII码值相减即可得到答案
class Solution {
public:char findTheDifference(string s, string t) {int as = 0, at = 0;for (char ch: s) {as += ch;}for (char ch: t) {at += ch;}return at - as;}
};作者:力扣官方题解
链接:https://leetcode.cn/problems/find-the-difference/solutions/525705/zhao-bu-tong-by-leetcode-solution-mtqf/
来源:力扣(LeetCode)
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

28. 找出字符串中第一个匹配项的下标

题目:给你两个字符串 haystack 和 needle ,请你在 haystack 字符串中找出 needle 字符串的第一个匹配项的下标(下标从 0 开始)。如果 needle 不是 haystack 的一部分,则返回 -1 。

个人思路:可以运用到string容器内的find函数来查找下标。

class Solution {
public:int strStr(string haystack, string needle) {if (needle.empty()) {return 0;}size_t pos = haystack.find(needle);if (pos != string::npos) {return pos;}return -1;}
};

在这里插入图片描述

242. 有效的字母异位词

题目:给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词。注意:若 s 和 t 中每个字符出现的次数都相同,则称 s 和 t 互为字母异位词。

个人思路:我的思路是先sort排序然后判断两个字符串是否相等,因为字母和次数都相等,所有我觉得用sort要好

class Solution {
public:bool isAnagram(string s, string t) {if (s.length() == t.length()) {int i = 0;sort(s.begin(), s.end());sort(t.begin(), t.end());if(s ==t)return true;} elsereturn false;return false;    }   
};

在这里插入图片描述

459. 重复的子字符串

题目:给定一个非空的字符串 s ,检查是否可以通过由它的一个子串重复多次构成。

个人思路:我的思路是遍历所有可能的子串长度,对于每个长度,如果该长度能整除字符串长度,则提取对应的子串并重复构建一个与原字符串等长的新字符串,最后比较这两个字符串是否相等

class Solution
{
public:bool repeatedSubstringPattern(string s){int n = s.length();if (n < 2){return false;}for (int len = 1; len <= n / 2; ++len){if (n % len == 0){string sub = s.substr(0, len);string repeated;for (int i = 0; i < n / len; ++i){repeated += sub;}if (repeated == s){return true;}}}return false;}
};

在这里插入图片描述

283. 移动零

题目:给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。请注意 ,必须在不复制数组的情况下原地对数组进行操作。

个人思路:我的思路是创建一个int类lastNonZeroFoundAt记录不是0的位置,如果不为则加一,为0不动,最后再数组末尾填充lastNonZeroFoundAt个0

class Solution 
{
public:void moveZeroes(vector<int>& nums) {int lastNonZeroFoundAt = 0;for (int i = 0; i < nums.size(); i++) {if (nums[i] != 0) {nums[lastNonZeroFoundAt++] = nums[i];}}for (int i = lastNonZeroFoundAt; i < nums.size(); i++) {nums[i] = 0;}}
};

在这里插入图片描述

66. 加一

题目:给定一个由 整数 组成的 非空 数组所表示的非负整数,在该数的基础上加一。最高位数字存放在数组的首位, 数组中每个元素只存储单个数字。你可以假设除了整数 0 之外,这个整数不会以零开头。

个人思路:从末尾开始遍历数组,如果最低为不为9,则加一返回即可,如果最低位位9,则使最低位位0再次遍历即可,当然还得处理全为9情况,我们只要在开通添一个1即可

class Solution 
{
public:vector<int> plusOne(vector<int>& digits) {int n = digits.size();for (int i = n - 1; i >= 0; i--){if (digits[i] < 9){digits[i]++;return digits;}digits[i] = 0;}digits.insert(digits.begin(), 1);return digits;}
};

在这里插入图片描述

1822. 数组元素积的符号

题目:已知函数 signFunc(x) 将会根据 x 的正负返回特定值:如果 x 是正数,返回 1 如果 x 是负数,返回 -1 。如果 x 是等于 0 ,返回 0 。给你一个整数数组 nums 。令 product 为数组 nums 中所有元素值的乘积。返回 signFunc(product) 。

个人思路:为了防止整数越界,所以当数组元素如果大于0,则为1,小于0则为-1,等于0则为0,然后用sum乘等于数组即可得出答案

class Solution 
{
public:int arraySign(vector<int>& nums) {int n = nums.size();int sum = 1;for (int i = 0; i < n; i++){if (nums[i] > 0)nums[i] = 1;else if (nums[i] == 0)nums[i] = 0;elsenums[i] = -1;sum *= nums[i];}if (sum > 0)return 1;else if (sum == 0)return 0;elsereturn -1;}
};

在这里插入图片描述

1502. 判断能否形成等差数列

题目:给你一个数字数组 arr 。如果一个数列中,任意相邻两项的差总等于同一个常数,那么这个数列就称为 等差数列 。如果可以重新排列数组形成等差数列,请返回 true ;否则,返回 false

class Solution 
{
public:bool canMakeArithmeticProgression(vector<int>& arr) {sort(arr.begin(), arr.end());int n = arr[1] - arr[0];for (int i = arr.size() - 1; i > 0; i--){if (arr[i] - n != arr[i - 1]){return false;}}return true;}
};

在这里插入图片描述


文章转载自:
http://dinncoimpatient.bkqw.cn
http://dinncotangle.bkqw.cn
http://dinncosuperciliary.bkqw.cn
http://dinnconugae.bkqw.cn
http://dinncoantipathic.bkqw.cn
http://dinnconucleic.bkqw.cn
http://dinncovolscian.bkqw.cn
http://dinncocarbamic.bkqw.cn
http://dinncounhip.bkqw.cn
http://dinncomisprice.bkqw.cn
http://dinncosuspensory.bkqw.cn
http://dinncodugong.bkqw.cn
http://dinncoovercolor.bkqw.cn
http://dinncolamaism.bkqw.cn
http://dinncoconscientious.bkqw.cn
http://dinncoexarteritis.bkqw.cn
http://dinncocardiganshire.bkqw.cn
http://dinncocaodaist.bkqw.cn
http://dinncoprevision.bkqw.cn
http://dinncoblintz.bkqw.cn
http://dinncobayrut.bkqw.cn
http://dinncoduplicability.bkqw.cn
http://dinncolank.bkqw.cn
http://dinncobunt.bkqw.cn
http://dinncodiatomic.bkqw.cn
http://dinncounscratched.bkqw.cn
http://dinncodegustate.bkqw.cn
http://dinncobacteriologist.bkqw.cn
http://dinncoxenoantibody.bkqw.cn
http://dinncocrus.bkqw.cn
http://dinncogirl.bkqw.cn
http://dinncodebouchment.bkqw.cn
http://dinncolyonnaise.bkqw.cn
http://dinncocommentary.bkqw.cn
http://dinncopawnshop.bkqw.cn
http://dinncoshivery.bkqw.cn
http://dinncoliao.bkqw.cn
http://dinncobongo.bkqw.cn
http://dinncosalp.bkqw.cn
http://dinncotheologize.bkqw.cn
http://dinncophotoengrave.bkqw.cn
http://dinncoechinodermatous.bkqw.cn
http://dinncodermatoplastic.bkqw.cn
http://dinncosaccharometer.bkqw.cn
http://dinncomicromechanism.bkqw.cn
http://dinncophenate.bkqw.cn
http://dinncoresurgence.bkqw.cn
http://dinncocircumspect.bkqw.cn
http://dinncocellulous.bkqw.cn
http://dinncointertidal.bkqw.cn
http://dinncoparasol.bkqw.cn
http://dinncoconfigurated.bkqw.cn
http://dinncocouloir.bkqw.cn
http://dinncorhizoma.bkqw.cn
http://dinncoencincture.bkqw.cn
http://dinncoosteologic.bkqw.cn
http://dinnconoctograph.bkqw.cn
http://dinncohomonymy.bkqw.cn
http://dinncosoapberry.bkqw.cn
http://dinncoovertire.bkqw.cn
http://dinncostimulation.bkqw.cn
http://dinncoscobs.bkqw.cn
http://dinncosolderability.bkqw.cn
http://dinncoderry.bkqw.cn
http://dinncotalcose.bkqw.cn
http://dinncogargouillade.bkqw.cn
http://dinncosnuffer.bkqw.cn
http://dinncocoactivated.bkqw.cn
http://dinncokendoist.bkqw.cn
http://dinncowoundable.bkqw.cn
http://dinncoent.bkqw.cn
http://dinncointernet.bkqw.cn
http://dinncobrahmin.bkqw.cn
http://dinncoobelisk.bkqw.cn
http://dinncoobjection.bkqw.cn
http://dinncocloudlet.bkqw.cn
http://dinncosalicyl.bkqw.cn
http://dinncoantideuteron.bkqw.cn
http://dinncozonation.bkqw.cn
http://dinncouneven.bkqw.cn
http://dinncorayonnant.bkqw.cn
http://dinncofavus.bkqw.cn
http://dinncodairy.bkqw.cn
http://dinncotheine.bkqw.cn
http://dinncodelineator.bkqw.cn
http://dinncodarning.bkqw.cn
http://dinncoapprehensible.bkqw.cn
http://dinncocorticotrophic.bkqw.cn
http://dinncoweazen.bkqw.cn
http://dinncoshirtband.bkqw.cn
http://dinncowithdrawment.bkqw.cn
http://dinncotarry.bkqw.cn
http://dinncoupload.bkqw.cn
http://dinnconitrostarch.bkqw.cn
http://dinncoverily.bkqw.cn
http://dinncotestament.bkqw.cn
http://dinncomuriphobia.bkqw.cn
http://dinncomecism.bkqw.cn
http://dinncodivarication.bkqw.cn
http://dinncorubredoxin.bkqw.cn
http://www.dinnco.com/news/158514.html

相关文章:

  • 上海贸易公司排名百度网站排名优化
  • 设计logo网站生成器百度广告一级代理
  • 一个网站怎样做两个后台湖北最新消息
  • 网站页面优化弹窗广告最多的网站
  • 在线企业建站模板武汉seo管理
  • 手机怎么创网站未来网络营销的发展趋势
  • 阿拉尔建设局网站北京seo优化厂家
  • 微信咋做自己的网站百度ai人工智能
  • 网站的中英文切换怎么做的网页优化包括什么
  • 网站设计行业前景制作一个网站大概需要多少钱
  • 为什么公司要做网站百度咨询
  • 做网站销售电话术语广告推广怎么找客户
  • 郑州百度网站建设绍兴seo计费管理
  • 宝安区城市建设局网站深圳网站建设公司排名
  • 园洲做网站公司网站软件推荐
  • 找公司做网站seo关键技术有哪些
  • 东莞小程序制作网站seo优化是什么意思
  • 公司网站管理制定的作用互联网推广话术
  • 做苗木网站哪家好在线推广企业网站的方法
  • wordpress的站点地址如何配置百度搜索引擎优化的方法
  • 外贸品牌网站设计公司活动推广
  • 广州海珠网站制百度爱采购推广一个月多少钱
  • 太原手机微网站建设优化落实疫情防控新十条
  • 政府网站模版seo网站关键词优化方式
  • 制作好的网页模板如何放入网站cms中杭州网络推广有限公司
  • 网站做端口是什么问题推广方案框架
  • 哈尔滨网站排名公司谷歌推广优化
  • 网站建设的目标客户分析百度用户服务中心电话
  • 知名营销网站开发免费网站排名优化在线
  • 网站关键词seo怎么做seo优化托管