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

什么软件可以做动画视频网站网站div的高度根据图片

什么软件可以做动画视频网站,网站div的高度根据图片,河北网站制作,建成网站的关键是目录 1、只出现一次的数字 2、宝石与石头 3、坏键盘打字 4、复制带随机指针的链表 5、大量数据去重 6、大量数据重复次数 7、前K个高频单词 1、只出现一次的数字 oj:136. 只出现一次的数字 - 力扣(LeetCode) 思路: 1. 使用…

目录

1、只出现一次的数字

2、宝石与石头

3、坏键盘打字

4、复制带随机指针的链表

5、大量数据去重

6、大量数据重复次数

7、前K个高频单词


1、只出现一次的数字

oj:136. 只出现一次的数字 - 力扣(LeetCode)

思路:
1. 使用 Set

2. 遍历数组,如果Set中不包含当前元素,就add,包含就remove

3. 最后Set中剩的一个元素就是要找的元素

    public int singleNumber(int[] nums) {//HashSet<Integer> set = new HashSet<>();TreeSet<Integer> set = new TreeSet<>();for(int x : nums) {if(!set.contains(x)) {set.add(x);}else {set.remove(x);}}//此时集合中只有一个元素了for(int x : nums) {if(set.contains(x)) {return x;}}return -1;}

2、宝石与石头

oj:771. 宝石与石头 - 力扣(LeetCode)

思路:

1. 将宝石字符串转化为一个字符数组,并把数组中每个字符都保存到Set集合中

2. 遍历石头字符串,如果当前位置的石头在Set集合中存在,就把计数器++,最后返回计数器

    public int numJewelsInStones(String jewels, String stones) {HashSet<Character> set = new HashSet<>();for(char ch : jewels.toCharArray()) {set.add(ch);}int count = 0;for(char ch : stones.toCharArray()) {if(set.contains(ch)) {count++;}}return count;}

3、坏键盘打字

牛客:旧键盘 (20)__牛客网

思路:

1. 将第二行字符串转化成大写,然后遍历这个字符串,把每个字符都放在set中

2. 将第一行字符串转化成大写,然后遍历这个字符串,把每个字符都放在set2中,当前字符在set中没有并且在set2中也没有,就打印

    public static void main(String[] args) {Scanner in = new Scanner(System.in);// 注意 hasNext 和 hasNextLine 的区别while (in.hasNextLine()) { // 注意 while 处理多个 caseString str1 = in.nextLine();String str2 = in.nextLine();func(str1,str2);}}private static void func(String str1,String str2) {HashSet<Character> set = new HashSet<>();for(char ch : str2.toUpperCase().toCharArray()) {set.add(ch);}HashSet<Character> set2 = new HashSet<>();for(char ch : str1.toUpperCase().toCharArray()) {if(!set.contains(ch) && !set2.contains(ch)) {System.out.print(ch);set2.add(ch);}}}

4、复制带随机指针的链表

oj:138. 随机链表的复制 - 力扣(LeetCode)

思路:

1. 遍历链表,每遍历到一个结点,就创建一个新结点,并把这两个结点的地址以键值对的形式保存到Map中

2. 通过Map修改指向

        map.get(cur).next = map.get(cur.next);

        map.get(cur).random = map.get(cur.random);

3. 返回新链表的头结点

    public Node copyRandomList(Node head) {Map<Node,Node> map = new HashMap<>();Node cur = head;//1. 第一次遍历链表 存储对应关系while(cur != null) {Node node = new Node(cur.val);map.put(cur,node);cur = cur.next;}//2. 第2次遍历链表 开始修改每个节点的指向cur = head;while(cur != null) {map.get(cur).next = map.get(cur.next);map.get(cur).random = map.get(cur.random);cur = cur.next;}//3、返回head对应的地址return map.get(head);}

5、大量数据去重

有10W个数据如何去除重复的数据,重复的数据只保留一份

    public static void main(String[] args) {int[] array = {1,2,3,3,2};HashSet<Integer> set = new HashSet<>();for (int i = 0; i < array.length; i++) {set.add(array[i]);}System.out.println(set);}

6、大量数据重复次数

有10W个数据,统计每个数据出现的次数

    public static void main12(String[] args) {int[] array = {1,2,3,3,2};Map<Integer,Integer> map = new HashMap<>();for(Integer x : array) {if(map.get(x) == null) {//第一次存放map.put(x,1);}else {//其他情况在原来的基础上加 1int val = map.get(x);map.put(x,val+1);}}for(Map.Entry<Integer,Integer> entry : map.entrySet()) {System.out.println("key: "+entry.getKey()+" val: "+entry.getValue());}}

7、前K个高频单词

oj:692. 前K个高频单词 - 力扣(LeetCode)

public List<String> topKFrequent(String[] words, int k) {//1、先统计单词出现的次数->存储到了map当中Map<String,Integer> map = new HashMap<>();for(String word : words) {if(map.get(word) == null) {map.put(word,1);}else {int val = map.get(word);map.put(word,val+1);}}//2、遍历好统计好的Map,把每组数据存储到小根堆当中PriorityQueue<Map.Entry<String,Integer>> minHeap =new PriorityQueue<>(new Comparator<Map.Entry<String, Integer>>() {@Overridepublic int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {//放元素的时候 如果频率相同 我们转变为大根堆-》按照单词的字典序if(o1.getValue().compareTo(o2.getValue()) == 0) {// 也可以直接减return o2.getKey().compareTo(o1.getKey());}return o1.getValue().compareTo(o2.getValue());}});for(Map.Entry<String,Integer> entry : map.entrySet()) {if(minHeap.size() < k) {minHeap.offer(entry);}else {//你要找最大的频率的单词Map.Entry<String,Integer> top = minHeap.peek();if(top.getValue().compareTo(entry.getValue()) < 0) {minHeap.poll();minHeap.offer(entry);}else {//def->2                     abc-> 2if(top.getValue().compareTo(entry.getValue()) == 0) {if(top.getKey().compareTo(entry.getKey()) > 0) {minHeap.poll();minHeap.offer(entry);}}}}}List<String> ret = new ArrayList<>();//放到了小根堆 2   3    4for (int i = 0; i < k; i++) {Map.Entry<String,Integer> top = minHeap.poll();ret.add(top.getKey());}// 2  3   4 ->  4 3 2Collections.reverse(ret);return ret;}

http://www.dtcms.com/wzjs/774838.html

相关文章:

  • 网站如何吸引用户微商货源网什么什么网站建设
  • 民和网站建设公司四川和城乡建设厅网站
  • 网站推广方案书怎么做百度网站
  • 东莞门户网站建设方案商贸公司起名字大全免费
  • 南京学习做网站ui设计主要做什么工作
  • 天门网站抚州市企业网站建设
  • 西部数码网站打不开网站搭建软件d
  • 要学好网站开发要会什么广东网站建设公司电话
  • 网站做链接四川住房和城乡建设厅网站
  • 网站服务合同交印花税吗wordpress点击分享功能
  • vs2017 网站开发环境郑州经纬网络做网站吗
  • 技术支持 合肥网站建设重庆菜谱制作
  • 湖北专业网站建设大全自助建站怎么实现的
  • 网络推广山东seo属于什么职位类型
  • 外贸网站 栏目桓台网站开发
  • 网站优化 价格二维码制作工具
  • 公司网站做推广无锡网络公司服务平台
  • 温州手机网站制作网站长春网站建设
  • 图片分类展示网站源码怎么用自己电脑做网站服务器吗
  • 什么是网站源码网站建设培训教程
  • 深圳福田区住房和建设局官方网站wordpress金融插件
  • 网站seo优化分析wordpress客户端源码
  • 成都网站建设龙兵科技网站建设及托管合同
  • 做的高大上的网站wordpress登录菜单
  • 建设h5网站群晖部署wordpress
  • 杭州最便宜的网站建设军队 网站备案
  • 古镇网站建设哪家好哈尔滨网站专业制作
  • linux建设一个网站网站 备案 固话
  • 浏阳网站制作公司宣传片拍摄合同交印花税吗
  • 商场网站建设模板企业网站建设 管理 维护