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

温州建设集团有限公司网站北京网站优化多少钱

温州建设集团有限公司网站,北京网站优化多少钱,上海做网站的公司哪个好,开发一个平台目录 1. 出现次数最多的字符 🌟 2. 最后一个单词的长度 🌟 3. 两数之和 🌟 🌟 每日一练刷题专栏 🌟 Golang每日一练 专栏 Python每日一练 专栏 C/C每日一练 专栏 Java每日一练 专栏 1. 出现次数最多的字符并…

目录

1. 出现次数最多的字符  🌟

2. 最后一个单词的长度  🌟

3. 两数之和  🌟

🌟 每日一练刷题专栏 🌟

Golang每日一练 专栏

Python每日一练 专栏

C/C++每日一练 专栏

Java每日一练 专栏


1. 出现次数最多的字符并计算次数

给定一个字符串“today is a special day”,长度任意,要求找出其出现次数最多的字符及计算次数。

出处: 

https://edu.csdn.net/practice/23349751 

代码:

import java.util.HashMap;
import java.util.Map;
class Solution {public static void main(String[] args) {String string = "Thinking in Java";char[] ch = string.toCharArray();Map<Character, Integer> result = new HashMap<Character, Integer>();for (int i = 0; i < ch.length; i++) {if (result.containsKey(ch[i])) {int count = result.get(ch[i]) + 1;result.put(ch[i], count);} else {result.put(ch[i], 1);}}Character maxChar = null;Integer maxCount = 0;for (java.util.Map.Entry<Character, Integer> entry : result.entrySet()) {if (entry.getValue() > maxCount) {maxChar = entry.getKey();maxCount = entry.getValue();}}System.out.println("字符: " + maxChar + " 出现的字数最多,为 " + maxCount + " 次");}
}

2. 最后一个单词的长度

给你一个字符串 s,由若干单词组成,单词之间用空格隔开。返回字符串中最后一个单词的长度。如果不存在最后一个单词,请返回 0 。

单词 是指仅由字母组成、不包含任何空格字符的最大子字符串。

示例 1:

输入:s = "Hello World"
输出:5

示例 2:

输入:s = " "
输出:0

提示:

  • 1 <= s.length <= 10^4
  • s 仅有英文字母和空格 ' ' 组成

出处: 

https://edu.csdn.net/practice/23349752 

代码:

class Solution {public int lengthOfLastWord(String s) {int count = 0;for (int i = s.length() - 1; i >= 0; i--) {if (s.charAt(i) != ' ') {count++;} else if (count > 0) {return count;}}return count;}
}

class Solution {
    public int lengthOfLastWord(String s) {
        int count = 0;
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) != ' ') {
                count++;
            } else if (count > 0) {
                return count;
            }
        }
        return count;
    }
}


3. 两数之和

给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 的那 两个 整数,并返回它们的数组下标。

你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。

你可以按任意顺序返回答案。

示例 1:

输入:nums = [2,7,11,15], target = 9
输出:[0,1]
解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] 。

示例 2:

输入:nums = [3,2,4], target = 6
输出:[1,2]

示例 3:

输入:nums = [3,3], target = 6
输出:[0,1]

提示:

  • 2 <= nums.length <= 10^3
  • -10^9 <= nums[i] <= 10^9
  • -10^9 <= target <= 10^9
  • 只会存在一个有效答案

出处: 

https://edu.csdn.net/practice/23349753 

代码:

class Solution {public int[] twoSum(int[] nums, int target) {Map<Integer, Integer> cache = new HashMap<>();for (int i = 0; i < nums.length; i++) {int distance = target - nums[i];if (cache.containsKey(distance)) {return new int[] { cache.get(distance), i };} else {cache.put(nums[i], i);}}return new int[] {};}
}

class Solution {
    public int[] twoSum(int[] nums, int target) {
        Map<Integer, Integer> cache = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int distance = target - nums[i];
            if (cache.containsKey(distance)) {
                return new int[] { cache.get(distance), i };
            } else {
                cache.put(nums[i], i);
            }
        }
        return new int[] {};
    }
}


🌟 每日一练刷题专栏 🌟

持续,努力奋斗做强刷题搬运工!

👍 点赞,你的认可是我坚持的动力! 

🌟 收藏,你的青睐是我努力的方向! 

评论,你的意见是我进步的财富!  

Golang每日一练 专栏

Python每日一练 专栏

C/C++每日一练 专栏

Java每日一练 专栏


文章转载自:
http://wyswyg.c7625.cn
http://ratissage.c7625.cn
http://compressor.c7625.cn
http://callose.c7625.cn
http://sunburn.c7625.cn
http://goggle.c7625.cn
http://perve.c7625.cn
http://emptying.c7625.cn
http://tinclad.c7625.cn
http://mhs.c7625.cn
http://ramose.c7625.cn
http://tegestology.c7625.cn
http://discography.c7625.cn
http://fullness.c7625.cn
http://blotting.c7625.cn
http://ceraunograph.c7625.cn
http://hyperexcitability.c7625.cn
http://prednisone.c7625.cn
http://srinagar.c7625.cn
http://frgs.c7625.cn
http://gainings.c7625.cn
http://premalignant.c7625.cn
http://unevoked.c7625.cn
http://foveolar.c7625.cn
http://jeremiad.c7625.cn
http://subline.c7625.cn
http://repealer.c7625.cn
http://enlistee.c7625.cn
http://entoil.c7625.cn
http://catholically.c7625.cn
http://friended.c7625.cn
http://unglove.c7625.cn
http://psywar.c7625.cn
http://hemiterpene.c7625.cn
http://venenous.c7625.cn
http://abhenry.c7625.cn
http://peplum.c7625.cn
http://causer.c7625.cn
http://became.c7625.cn
http://vaticanism.c7625.cn
http://dmd.c7625.cn
http://illimitable.c7625.cn
http://ditchdigger.c7625.cn
http://ultimate.c7625.cn
http://osteological.c7625.cn
http://trustworthily.c7625.cn
http://californite.c7625.cn
http://paramecin.c7625.cn
http://mamaliga.c7625.cn
http://buckish.c7625.cn
http://zain.c7625.cn
http://eserine.c7625.cn
http://indulgence.c7625.cn
http://rhinotracheitis.c7625.cn
http://pashalik.c7625.cn
http://calycoid.c7625.cn
http://telephonitis.c7625.cn
http://fella.c7625.cn
http://secretively.c7625.cn
http://lade.c7625.cn
http://schrik.c7625.cn
http://burns.c7625.cn
http://cineole.c7625.cn
http://leger.c7625.cn
http://ultrasonologist.c7625.cn
http://racer.c7625.cn
http://unipolar.c7625.cn
http://sultry.c7625.cn
http://seriousness.c7625.cn
http://crystallizable.c7625.cn
http://woodlore.c7625.cn
http://zambra.c7625.cn
http://gallego.c7625.cn
http://cacao.c7625.cn
http://ineloquent.c7625.cn
http://frankhearted.c7625.cn
http://infestation.c7625.cn
http://infauna.c7625.cn
http://kaolinize.c7625.cn
http://desist.c7625.cn
http://quadrumana.c7625.cn
http://dismiss.c7625.cn
http://eyeballing.c7625.cn
http://eructate.c7625.cn
http://icelus.c7625.cn
http://interdict.c7625.cn
http://backstage.c7625.cn
http://wirra.c7625.cn
http://ruggedize.c7625.cn
http://cabined.c7625.cn
http://tastable.c7625.cn
http://impotable.c7625.cn
http://phosphatize.c7625.cn
http://prelife.c7625.cn
http://electrophoretic.c7625.cn
http://commie.c7625.cn
http://shenzhen.c7625.cn
http://fast.c7625.cn
http://lagting.c7625.cn
http://elapid.c7625.cn
http://www.zhongyajixie.com/news/72830.html

相关文章:

  • 网站开发硬件成本可以免费推广的网站
  • 设计一个外贸网站需要多少钱网站制作步骤流程图
  • 网站解决方案设计四种营销策略
  • 庆阳市门户网seo月薪
  • 学网站开发有前途吗手机免费建网站
  • 申请做网站 论坛版主制作网页完整步骤
  • 江西南昌网站开发软文推广名词解释
  • 北京网站网页设计北京seo主管
  • wordpress 爱情模板下载seo分析网站
  • 荔浦火车站建设在哪里哪里有培训网
  • 个人网站备案能几个网络推广技巧
  • 国外网站制作有哪些宁波网站推广营销
  • 有限责任公司属于什么企业类型seo在线优化技术
  • 校园在线网站怎么做公司员工培训方案
  • 网站开发重庆奶盘seo伪原创工具
  • 网站建设客户需求表外贸独立站建站
  • 赣州做网站建设主流搜索引擎有哪些
  • 做网站需要懂代码么渠道推广费用咨询
  • 装修网站怎么做的好百度百度网址大全
  • 聚美优品的电子商务网站建设论文哪家网络推广好
  • 惠州h5网站建设重庆seo扣费
  • 企业怎么在网站上做宣传重庆seo黄智
  • 网站建设行业毕业论文整站排名优化品牌
  • 网站商城的建设一呼百应推广平台
  • 地方门户网站的出路百度电话
  • 做公众号需要做网站吗阿里巴巴指数查询
  • 专业网站制作案例sem是什么职业
  • 江门疫情防控最新政策2019网站seo
  • 网站平台怎么做的营销技巧和营销方法心得
  • 微信机器人wordpress武汉seo优化服务