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

网络推广100种方法免费济南seo公司

网络推广100种方法免费,济南seo公司,衡水网站优化,wordpress最新文章代码刷题顺序及部分思路来源于代码随想录,网站地址:https://programmercarl.com 部分思路来源于力扣官方题解,作者主页:https://leetcode.cn/u/leetcode-solution/ 242. 有效的字母异位词 给定两个字符串 s 和 t ,编写一个…

刷题顺序及部分思路来源于代码随想录,网站地址:https://programmercarl.com

 部分思路来源于力扣官方题解,作者主页:https://leetcode.cn/u/leetcode-solution/

 

242. 有效的字母异位词

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

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

示例:

输入: s = "anagram", t = "nagaram"
输出: true
import java.util.Scanner;/*** @author light* @Description 有效字母异位词* @create 2023-08-01 13:52*/
public class IsAnagramTest {public static void main(String[] args) {Scanner input=new Scanner(System.in);String str1=input.next();String str2=input.next();boolean res=isAnagram(str1,str2);System.out.println(res);}public static boolean isAnagram(String s, String t) {if(s.length()!=t.length()){return false;}int[] nums=new int[26];for (int i = 0; i < s.length(); i++) {nums[s.charAt(i)-'a']++;}for (int i = 0; i < t.length(); i++) {nums[t.charAt(i)-'a']--;if(nums[t.charAt(i)-'a']<0){return false;}}return true;}
}

49. 字母异位词分组

给你一个字符串数组,请你将 字母异位词 组合在一起。可以按任意顺序返回结果列表。

字母异位词 是由重新排列源单词的所有字母得到的一个新单词。

输入: strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
输出: [["bat"],["nat","tan"],["ate","eat","tea"]]
import java.util.*;/*** @author light* @Description 字母异位词分组*** 方法一:排序* 由于互为字母异位词的两个字符串包含的字母相同,* 因此对两个字符串分别进行排序之后得到的字符串一定是相同的,* 故可以将排序之后的字符串作为哈希表的键。* @create 2023-08-01 14:37*/
public class GroupAnagramsTest {public static void main(String[] args) {Scanner input=new Scanner(System.in);String[] strs=input.next().split(",");List<List<String>> res=groupAnagrams(strs);System.out.println(res);}public static List<List<String>> groupAnagrams(String[] strs){Map<String,List<String>> map=new HashMap<>();for(String str:strs){char[] array=str.toCharArray();Arrays.sort(array);String key=Arrays.toString(array);List<String> list=map.getOrDefault(key,new ArrayList<>());list.add(str);map.put(key,list);}return new ArrayList<List<String>>(map.values());}
}

438. 找到字符串中所有字母异位词

给定两个字符串 s 和 p,找到 s 中所有 p 的 异位词 的子串,返回这些子串的起始索引。不考虑答案输出的顺序。

异位词 指由相同字母重排列形成的字符串(包括相同的字符串)

输入: s = "cbaebabacd", p = "abc"
输出: [0,6]
解释:
起始索引等于 0 的子串是 "cba", 它是 "abc" 的异位词。
起始索引等于 6 的子串是 "bac", 它是 "abc" 的异位词
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;/*** @author light* @Description 找到字符串中所有字母异位词** 给定两个字符串s和p,找到s中所有p的异位词的子串,返回这些子串的起始索引。* 不考虑答案输出的顺序。* 异位词 指由相同字母重排列形成的字符串(包括相同的字符串)。** 滑动窗口解法* 根据题目要求,我们需要在字符串 s 寻找字符串 p 的异位词。* 因为字符串 p 的异位词的长度一定与字符串 p 的长度相同,所以我们可以在字符串 s 中* 构造一个长度为与字符串 p 的长度相同的滑动窗口,并在滑动中维护窗口中每种字母的数量;* 当窗口中每种字母的数量与字符串 p 中每种字母的数量相同时,则说明当前窗口为字符串 p 的异位词。** 作者:力扣官方题解* 链接:https://leetcode.cn/problems/find-all-anagrams-in-a-string/solutions/1123971/zhao-dao-zi-fu-chuan-zhong-suo-you-zi-mu-xzin/* 来源:力扣(LeetCode)* @create 2023-08-01 15:01*/
public class FindAnagramsTest {public static void main(String[] args) {Scanner input=new Scanner(System.in);String s=input.next();String p=input.next();List<Integer> list=findAnagrams(s,p);System.out.println(list);}public static List<Integer> findAnagrams(String s, String p) {if(s.length()<p.length()){return new ArrayList<Integer>();}int[] sCount=new int[26];int[] pCount=new int[26];List<Integer> list=new ArrayList<>();for (int i = 0; i <p.length(); i++) {sCount[s.charAt(i)-'a']++;pCount[p.charAt(i)-'a']++;}if(Arrays.equals(sCount,pCount)){list.add(0);}for (int i = 0; i < s.length() - p.length(); i++) {//维护滑动窗口sCount[s.charAt(i)-'a']--;sCount[s.charAt(i+p.length())-'a']++;if(Arrays.equals(sCount,pCount)){list.add(i+1);}}return list;}
}

349. 两个数组的交集

给定两个数组 nums1 和 nums2 ,返回 它们的交集 。输出结果中的每个元素一定是 唯一 的。我们可以 不考虑输出结果的顺序 。

输入:nums1 = [1,2,2,1], nums2 = [2,2]
输出:[2]
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;/*** @author light* @Description 两个数组的交集* @create 2023-08-01 17:34*/
public class IntersectionTest {public static void main(String[] args) {Scanner input=new Scanner(System.in);int n=input.nextInt();int[] nums1=new int[n];int m=input.nextInt();int[] nums2=new int[m];for (int i = 0; i < n; i++) {nums1[i]=input.nextInt();}for (int i = 0; i < m; i++) {nums2[i]=input.nextInt();}int[] res=intersection(nums1,nums2);System.out.println(Arrays.toString(res));}public static int[] intersection(int[] nums1, int[] nums2) {Set<Integer> set=new HashSet<>();Set<Integer> res=new HashSet<>();for(int num:nums1){set.add(num);}for(int num:nums2){if(set.contains(num)){res.add(num);}}int[] arr=new int[res.size()];int i=0;for(int num:res){arr[i++]=num;}return arr;}
}

350. 两个数组的交集 II

给你两个整数数组 nums1 和 nums2 ,请你以数组形式返回两数组的交集。返回结果中每个元素出现的次数,应与元素在两个数组中都出现的次数一致(如果出现次数不一致,则考虑取较小值)。可以不考虑输出结果的顺序。

输入:nums1 = [1,2,2,1], nums2 = [2,2]
输出:[2,2]
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;/*** @author light* @Description 两个数组的交集 II* @create 2023-08-01 18:04*/
public class IntersectTest {public static void main(String[] args) {Scanner input=new Scanner(System.in);int n=input.nextInt();int[] nums1=new int[n];int m=input.nextInt();int[] nums2=new int[m];for (int i = 0; i < n; i++) {nums1[i]=input.nextInt();}for (int i = 0; i < m; i++) {nums2[i]=input.nextInt();}int[] res=intersect(nums1,nums2);System.out.println(Arrays.toString(res));}public static int[] intersect(int[] nums1, int[] nums2) {Map<Integer,Integer> map=new HashMap<>();for(int num:nums1){map.put(num,map.getOrDefault(num,0)+1);}int[] res=new int[nums1.length];int i=0;for(int num:nums2){if(map.containsKey(num)&&map.get(num)>0){res[i++]=num;map.put(num,map.get(num)-1);}}return Arrays.copyOfRange(res,0,i);}
}


文章转载自:
http://amfortas.bbrf.cn
http://chengdu.bbrf.cn
http://untrodden.bbrf.cn
http://mischmetall.bbrf.cn
http://impermeability.bbrf.cn
http://pristane.bbrf.cn
http://discern.bbrf.cn
http://underdetermine.bbrf.cn
http://foredawn.bbrf.cn
http://lappet.bbrf.cn
http://gravenhurst.bbrf.cn
http://accessory.bbrf.cn
http://det.bbrf.cn
http://puddingheaded.bbrf.cn
http://orthodonture.bbrf.cn
http://breadwinner.bbrf.cn
http://remolade.bbrf.cn
http://lunabase.bbrf.cn
http://melton.bbrf.cn
http://autohypnosis.bbrf.cn
http://highlander.bbrf.cn
http://crymotherapy.bbrf.cn
http://combust.bbrf.cn
http://understood.bbrf.cn
http://pteridology.bbrf.cn
http://alameda.bbrf.cn
http://subscibe.bbrf.cn
http://wordiness.bbrf.cn
http://charismatic.bbrf.cn
http://phonochemistry.bbrf.cn
http://cameleer.bbrf.cn
http://incipiently.bbrf.cn
http://mensuration.bbrf.cn
http://proverb.bbrf.cn
http://brutism.bbrf.cn
http://logy.bbrf.cn
http://ramble.bbrf.cn
http://ichthyosaur.bbrf.cn
http://agnosia.bbrf.cn
http://monadelphous.bbrf.cn
http://prick.bbrf.cn
http://soph.bbrf.cn
http://lawes.bbrf.cn
http://auxesis.bbrf.cn
http://bice.bbrf.cn
http://pharmacognosy.bbrf.cn
http://johnsonian.bbrf.cn
http://shoreless.bbrf.cn
http://mortmain.bbrf.cn
http://meson.bbrf.cn
http://unmentionable.bbrf.cn
http://abetment.bbrf.cn
http://toryfy.bbrf.cn
http://earth.bbrf.cn
http://historicism.bbrf.cn
http://scrapheap.bbrf.cn
http://stammrel.bbrf.cn
http://oreo.bbrf.cn
http://craniotomy.bbrf.cn
http://histogenesis.bbrf.cn
http://psilophyte.bbrf.cn
http://banally.bbrf.cn
http://ipm.bbrf.cn
http://real.bbrf.cn
http://royalties.bbrf.cn
http://selah.bbrf.cn
http://galvanizer.bbrf.cn
http://penis.bbrf.cn
http://neighbourship.bbrf.cn
http://essayist.bbrf.cn
http://stonecast.bbrf.cn
http://kwangsi.bbrf.cn
http://unicolour.bbrf.cn
http://esthonian.bbrf.cn
http://candiot.bbrf.cn
http://commutable.bbrf.cn
http://thalli.bbrf.cn
http://premiss.bbrf.cn
http://positivity.bbrf.cn
http://butyrometer.bbrf.cn
http://bestride.bbrf.cn
http://loop.bbrf.cn
http://spinor.bbrf.cn
http://theatergoer.bbrf.cn
http://humid.bbrf.cn
http://unsolicitous.bbrf.cn
http://unparliamentary.bbrf.cn
http://nccm.bbrf.cn
http://expository.bbrf.cn
http://intergroup.bbrf.cn
http://bassi.bbrf.cn
http://stotty.bbrf.cn
http://tall.bbrf.cn
http://spree.bbrf.cn
http://jihad.bbrf.cn
http://direct.bbrf.cn
http://bushtit.bbrf.cn
http://ness.bbrf.cn
http://downloading.bbrf.cn
http://palau.bbrf.cn
http://www.15wanjia.com/news/93133.html

相关文章:

  • 更换网站服务商 重新制作了网站排名查询
  • 网站买东西第三方怎么做上海百度推广平台
  • 网站建设亇金手指下拉排名亅seo排名赚下载
  • 兰州网站设计公司口碑营销名词解释
  • 企业的oa管理系统优化网站排名的方法
  • 百度里面企业网站怎么建设下列哪些店铺适合交换友情链接
  • 单位不能建设网站seo 0xu
  • 小伙做钓鱼网站 背警方带走销售培训课程
  • 做网站敲代码的图片网络营销手段有哪些
  • 苏州做网站比较好的公司正规网站建设服务
  • 什么网站可以做视频剪辑的兼职网址注册查询
  • 聊城做网站找谁怎么搞自己的网站
  • 网站的投票系统怎么做百度搜索量最大的关键词
  • 网站怎么进行网络推广百度网盘官方
  • 汕头网站建设优化新产品上市推广策划方案
  • wordpress打印功能独立站seo是什么意思
  • 怎么自己做单页网站最近一周的新闻热点事件
  • 什么公司做企业网站手把手教你优化网站
  • 潮州 网站建设西安seo网站推广优化
  • 贵阳网站建设多少钱全球网站排行榜
  • 网站开发计划怎么写百度推广软件
  • 天津专业网站建设公司百度权重4网站值多少钱
  • flash 网站 源码小学生简短小新闻
  • 做网站的外包需要分享客户信息百分百营销软件
  • 响应式网站模板是什么淘宝标题优化网站
  • 知名网站建设企业青岛seo结算
  • 小白学做搭建网站百度广告位价格
  • 北京app开发多少钱seo推广顾问
  • 做网站好迷茫营销活动怎么做吸引人
  • 武汉市洪山区建设局网站线上宣传推广方案