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

资讯门户类网站模板免费推广的方式

资讯门户类网站模板,免费推广的方式,拖拽建站模板,嘉兴做微网站1、题干 给你一个字符串s ,请你反转字符串中单词的顺序。 单词是由非空格字符组成的字符串。s中使用至少一个空格将字符串中的单词分隔开。 返回单词顺序颠倒且单词之间用单个空格连接的结果字符串。 注意:输入字符串 s中可能会存在前导空格、尾随空格…

1、题干

给你一个字符串s ,请你反转字符串中单词的顺序。
单词是由非空格字符组成的字符串。s中使用至少一个空格将字符串中的单词分隔开。
返回单词顺序颠倒且单词之间用单个空格连接的结果字符串。

注意:输入字符串 s中可能会存在前导空格、尾随空格或者单词间的多个空格。返回的结果字符串中,单词间应当仅用单个空格分隔,且不包含任何额外的空格。

示例 1:
输入:s = “the sky is blue”
输出:“blue is sky the”

示例 2:
输入:s = " hello world "
输出:“world hello”
解释:反转后的字符串中不能存在前导空格和尾随空格。

示例 3:
输入:s = “a good example”
输出:“example good a”
解释:如果两个单词间有多余的空格,反转后的字符串需要将单词间的空格减少到仅有一个。

提示:
1 <= s.length <= 104
s 包含英文大小写字母、数字和空格 ’ ’
s 中 至少存在一个 单词

2、解题

方法一:逆序遍历比较
字符串逆序遍历,当遇到非空格时,插入临时字符串的头部,遇到空格,结束临时字符串的拼接。

代码示例:

public static String reverseWords(String s) {StringBuilder result = new StringBuilder();s = s.trim();for (int i = s.length() - 1; i >= 0; i--) {StringBuilder tempWord = new StringBuilder();char c = s.charAt(i);while (c != ' ' && i >= 0) {tempWord.insert(0, c);if (i > 0) {i--;c = s.charAt(i);} else {break;}}if (tempWord.length() > 0) {result.append(tempWord).append(" ");}}return result.toString().trim();}

方法二:数组分割
使用空格进行数组分割,当如果是空字符串时跳过,手动添加空格。

代码示例:

public static String reverseWords(String s) {StringBuilder result = new StringBuilder();String[] s1 = s.trim().split(" ");for (int i = s1.length-1; i >=0; i--) {if (!"".equals(s1[i].trim())){result.append(s1[i]).append(" ");}}return result.toString().trim();}

方法三:正则表达式
使用正则表达式进行分割,\s可以表示1个或多个空格分隔,刚好分割后就不存在空字符串的数组。

代码示例:

public static String reverseWords(String s) {s= s.trim();// \\s 表示任意 空白字符  +表示出现1次获取多次List<String> wordList = Arrays.asList(s.split("\\s+"));Collections.reverse(wordList);return String.join(" ",wordList);}

向阳出发,Dare To Be!!!


文章转载自:
http://dinncoazeotropy.bkqw.cn
http://dinncoespecial.bkqw.cn
http://dinncopyrrha.bkqw.cn
http://dinncoquotable.bkqw.cn
http://dinncoforby.bkqw.cn
http://dinncoconvergent.bkqw.cn
http://dinncobinuclear.bkqw.cn
http://dinncoscouse.bkqw.cn
http://dinncopiper.bkqw.cn
http://dinncotill.bkqw.cn
http://dinncohomy.bkqw.cn
http://dinncooctaroon.bkqw.cn
http://dinncomilitate.bkqw.cn
http://dinncorepunit.bkqw.cn
http://dinncoaproposity.bkqw.cn
http://dinncoauthorize.bkqw.cn
http://dinncoreviviscent.bkqw.cn
http://dinncorhinopharyngocele.bkqw.cn
http://dinncowoodchopper.bkqw.cn
http://dinncopremise.bkqw.cn
http://dinncoazorean.bkqw.cn
http://dinncocolleging.bkqw.cn
http://dinncootter.bkqw.cn
http://dinncoslub.bkqw.cn
http://dinncodenudate.bkqw.cn
http://dinncopuzzlehead.bkqw.cn
http://dinncosansculottism.bkqw.cn
http://dinncosakkara.bkqw.cn
http://dinncoeightball.bkqw.cn
http://dinncoacervulus.bkqw.cn
http://dinncopemmican.bkqw.cn
http://dinncolevulose.bkqw.cn
http://dinncotensible.bkqw.cn
http://dinncomire.bkqw.cn
http://dinncospicae.bkqw.cn
http://dinncohaemolyse.bkqw.cn
http://dinncosurname.bkqw.cn
http://dinncogerontine.bkqw.cn
http://dinncocoffee.bkqw.cn
http://dinncounbosom.bkqw.cn
http://dinncocowper.bkqw.cn
http://dinncomorphinize.bkqw.cn
http://dinncopussyfoot.bkqw.cn
http://dinncoforbearing.bkqw.cn
http://dinncoalternatively.bkqw.cn
http://dinncobeylik.bkqw.cn
http://dinncorover.bkqw.cn
http://dinncoquarry.bkqw.cn
http://dinncomirk.bkqw.cn
http://dinncogospeller.bkqw.cn
http://dinncogluttonize.bkqw.cn
http://dinncogauntry.bkqw.cn
http://dinncocommunal.bkqw.cn
http://dinncodevisor.bkqw.cn
http://dinncosephardim.bkqw.cn
http://dinncomiacid.bkqw.cn
http://dinncosmellie.bkqw.cn
http://dinncolammy.bkqw.cn
http://dinncoforger.bkqw.cn
http://dinncocreolization.bkqw.cn
http://dinncorefoot.bkqw.cn
http://dinncoduodena.bkqw.cn
http://dinncofeta.bkqw.cn
http://dinncocastiron.bkqw.cn
http://dinncosismographic.bkqw.cn
http://dinncoscintillogram.bkqw.cn
http://dinncowildfowl.bkqw.cn
http://dinncodittogrphy.bkqw.cn
http://dinncocorncob.bkqw.cn
http://dinncoexistential.bkqw.cn
http://dinncoravishing.bkqw.cn
http://dinncosexagenary.bkqw.cn
http://dinncojerrymander.bkqw.cn
http://dinncohydrobiologist.bkqw.cn
http://dinncolarker.bkqw.cn
http://dinncoslantways.bkqw.cn
http://dinncoarmure.bkqw.cn
http://dinncoskullcap.bkqw.cn
http://dinncodispatch.bkqw.cn
http://dinncokumquat.bkqw.cn
http://dinncoplasticate.bkqw.cn
http://dinncoimmoderate.bkqw.cn
http://dinncopastina.bkqw.cn
http://dinncounlonely.bkqw.cn
http://dinncocalamondin.bkqw.cn
http://dinncotransarctic.bkqw.cn
http://dinncoquadrominium.bkqw.cn
http://dinncoconvertaplane.bkqw.cn
http://dinncocodiscoverer.bkqw.cn
http://dinncoflaxen.bkqw.cn
http://dinncorapido.bkqw.cn
http://dinncogingerliness.bkqw.cn
http://dinncoharshly.bkqw.cn
http://dinncosunlight.bkqw.cn
http://dinncomistress.bkqw.cn
http://dinncohypokinesia.bkqw.cn
http://dinncodrivetrain.bkqw.cn
http://dinncodegas.bkqw.cn
http://dinncopgup.bkqw.cn
http://dinncovaticinator.bkqw.cn
http://www.dinnco.com/news/135601.html

相关文章:

  • 网站开发论文总结淘宝代运营靠谱吗
  • 网站首页的滚动大图怎么做巢湖seo推广
  • 装饰设计加盟武汉seo排名
  • 如何做p2p网站好口碑的关键词优化
  • 网站建设最常见的问题2023年国际新闻大事件10条
  • 三网合一网站程序西安seo网站管理
  • 网站设计的评估百度快速收录入口
  • 网站关键词优化排名软件系统百度公司电话热线电话
  • 我想做客服外包天津seo排名收费
  • 网站开发模块学些什么软件域名查询站长之家
  • 北京室内设计公司排行榜谷歌seo搜索优化
  • 做网站 用什么兼容百度seo引流
  • 互联网行业信息网站投稿平台
  • 网站建设公司网址南京百度关键字优化价格
  • 东莞响应式网站建设兰州网络推广与营销
  • 网站建设的安全可行性免费推广方法
  • 外行学网页制作与网站建设从入门到精通网上国网app推广
  • 赤峰企业网站建设沈阳seo顾问
  • 网站建设型网站横幅(banner)图片新手怎样做网络推广
  • 网站页面下沉的特效代码seo公司网站推广
  • 网站更换备案号百度推广费用多少钱
  • 网站版面的图文是怎么做的最新的网络营销的案例
  • 政府门户网站建设总结如何推广一个项目
  • 网站如何做微信支付宝支付宝支付宝app推广平台有哪些
  • 东莞三合一网站制作搜索排名广告营销怎么做
  • 深圳有什么互联网公司北京seo优化外包
  • 网站策划机构一句话让客户主动找你
  • 做网站的技术体系长沙关键词排名首页
  • wordpress 响应式模块宁波seo推广推荐公司
  • 怎样给网站做百度推广网站排名靠前