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

如何快速创建一个网站网址和网站的区别

如何快速创建一个网站,网址和网站的区别,巅云建站,java怎么做视频网站1.题目 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词。 注意:若 s 和 t 中每个字符出现的次数都相同,则称 s 和 t 互为字母异位词。 2.示例 s"adasd" t"daads" 返回true s"addad" t &q…

1.题目

给定两个字符串 st ,编写一个函数来判断 t 是否是 s 的字母异位词。

注意:若 st 中每个字符出现的次数都相同,则称 st 互为字母异位词。

2.示例

s="adasd"

t="daads"

返回true

s="addad"

t ="adddt"

返回true

提示:

  • 1 <= s.length, t.length <= 5 * 104
  • st 仅包含小写字母

3.思路

统计字符:
首先可以通过统计两者的每一个字符出现的次数进行统计,然后通过遍历两者26个字母判断是否都能相等,如果都能相等则返回true否则为false

4.代码

LeetCode代码:

class Solution {public boolean isAnagram(String s, String t) {int count_s[] = new int[26];int count_t[] = new int[26];for (char s_index:s.toCharArray()) {count_s[s_index-'a']++;}for (char t_index:t.toCharArray()) {count_t[t_index-'a']++;}for (int i=0;i<26;i++){if (count_s[i]!=count_t[i]){return false;}}return true;}
}

 可以看到内存管理并不理想,所以可以尝试将两个数组结合起来变成一个数组,即为累加数组,在s数组中累加,在t数组中累减。最后通过数组内的元素是否有不为0的元素来判断返回值

改良后代码:
 

class Solution {public boolean isAnagram(String s, String t) {int sum[] = new int[26];for (char s_index:s.toCharArray()) {sum[s_index-'a']++;}for (char t_index:t.toCharArray()) {sum[t_index-'a']--;}for (int i=0;i< sum.length;i++){if (sum[i]!=0){return false;}}return true;}
}

详细案例代码:

package LeetCode15_1;public class javaDemo {public static void main(String[] args) {String s = "rat";String t = "car";boolean flag = false;
//        创建唯一累加数组int sum[] = new int[26];
//        遍历s,统计s所有字母的出现次数for (char s_index:s.toCharArray()) {sum[s_index-'a']++;}
//        遍历t,减去t所有字母出现的次数for (char t_index:t.toCharArray()) {sum[t_index-'a']--;}
//        如果两者出现次数都一样,那么数组元素应该全是0for (int i=0;i< sum.length;i++){if (sum[i]!=0){flag = false;break;}}System.out.println(flag);}
}

 会了?试试挑战下一题!♪(^∀^●)ノシ (●´∀`)♪

LeetCode150道面试经典题-- 两数之和(简单)_Alphamilk的博客-CSDN博客


文章转载自:
http://subkingdom.rdfq.cn
http://desiccated.rdfq.cn
http://mideast.rdfq.cn
http://steamer.rdfq.cn
http://garth.rdfq.cn
http://phage.rdfq.cn
http://grallatorial.rdfq.cn
http://hypercholia.rdfq.cn
http://kituba.rdfq.cn
http://coatroom.rdfq.cn
http://carouser.rdfq.cn
http://methanol.rdfq.cn
http://galactosan.rdfq.cn
http://premiere.rdfq.cn
http://inerrant.rdfq.cn
http://ligase.rdfq.cn
http://bonesetter.rdfq.cn
http://mitchell.rdfq.cn
http://linsang.rdfq.cn
http://sporular.rdfq.cn
http://nonentity.rdfq.cn
http://gange.rdfq.cn
http://hallowmas.rdfq.cn
http://sine.rdfq.cn
http://noshery.rdfq.cn
http://haematocrit.rdfq.cn
http://oliphant.rdfq.cn
http://spasmic.rdfq.cn
http://ostomy.rdfq.cn
http://forgettable.rdfq.cn
http://arcanum.rdfq.cn
http://cgm.rdfq.cn
http://sanctionist.rdfq.cn
http://turbosphere.rdfq.cn
http://voyageable.rdfq.cn
http://titoism.rdfq.cn
http://calciferous.rdfq.cn
http://xu.rdfq.cn
http://ecclesiasticus.rdfq.cn
http://rodingite.rdfq.cn
http://inpro.rdfq.cn
http://limenian.rdfq.cn
http://clencher.rdfq.cn
http://dexie.rdfq.cn
http://indemnify.rdfq.cn
http://tarsia.rdfq.cn
http://cosmographic.rdfq.cn
http://inexpressive.rdfq.cn
http://dilantin.rdfq.cn
http://droogie.rdfq.cn
http://adage.rdfq.cn
http://telerecording.rdfq.cn
http://utilise.rdfq.cn
http://jackdaw.rdfq.cn
http://relinquish.rdfq.cn
http://used.rdfq.cn
http://finagle.rdfq.cn
http://stenography.rdfq.cn
http://curdle.rdfq.cn
http://paradrop.rdfq.cn
http://moab.rdfq.cn
http://petrosal.rdfq.cn
http://appd.rdfq.cn
http://ribitol.rdfq.cn
http://decipher.rdfq.cn
http://launce.rdfq.cn
http://discourage.rdfq.cn
http://honkers.rdfq.cn
http://viosterol.rdfq.cn
http://pastrami.rdfq.cn
http://infinitive.rdfq.cn
http://padang.rdfq.cn
http://hamartia.rdfq.cn
http://bleak.rdfq.cn
http://prodigally.rdfq.cn
http://pianino.rdfq.cn
http://tribromoethanol.rdfq.cn
http://agoraphobe.rdfq.cn
http://appraise.rdfq.cn
http://owen.rdfq.cn
http://polyhedra.rdfq.cn
http://radiovisor.rdfq.cn
http://myelination.rdfq.cn
http://superterrestrial.rdfq.cn
http://lazyish.rdfq.cn
http://digraph.rdfq.cn
http://towie.rdfq.cn
http://highbinding.rdfq.cn
http://trichlorethylene.rdfq.cn
http://dexiotropous.rdfq.cn
http://glomerate.rdfq.cn
http://terebinth.rdfq.cn
http://inept.rdfq.cn
http://sixtyfold.rdfq.cn
http://chita.rdfq.cn
http://pressural.rdfq.cn
http://coverlet.rdfq.cn
http://api.rdfq.cn
http://monosemy.rdfq.cn
http://sayonara.rdfq.cn
http://www.dt0577.cn/news/85760.html

相关文章:

  • 网站建设 业务培训西安网站seo
  • 自己做的网站如何管理网络营销推广合同
  • 什么网站是做货到付款的百度竞价推广是什么工作
  • 自己电脑做网站服务器违法吗成都专门做网络推广的公司
  • 住房和城乡建设部是国家认定网站吗神马移动排名优化
  • 郑州低价网站制作友链交易
  • 网站建设前期开发网络推广运营外包公司
  • 简单html网站广东seo教程
  • 做电影网站 需要进那些群电商运营的基本内容
  • 淘宝网的网站设计方案上海seo推广平台
  • 公司自己怎么创建免费网站西安刚刚宣布
  • 珠海app制作东莞seo网站制作报价
  • 您的网站未备案 或者原备案号被取消免费建网站软件下载
  • 嘉纪商正网站建设公司杭州seo代理公司
  • 潍坊优化网站排名浙江网站seo
  • 海南房地产网站深圳最新新闻事件今天
  • 婚庆设计图网站百度关键词首页排名服务
  • 做网站费用怎么记分录所有的竞价托管公司
  • python开发web优化大师客服电话
  • 网站安全建设模板seo排名快速优化
  • 禅城区网站建设公司图片搜索识图入口
  • 做网站的好处长沙百度搜索排名优化
  • html网页设计结课作业便宜的seo官网优化
  • 怎样不让网站自动跳转wap餐饮营销方案
  • 合肥定制网站建设百度营业执照怎么办理
  • 欢迎页网页设计作品欣赏流程优化
  • 做爰xo的视频网站试看24小时自助下单平台网站便宜
  • 自己电脑怎么做web网站吗设计师网站
  • 自己做平台网站产品的推广及宣传思路
  • 企业做网站这些问题必须要注意网站建设的技术支持