1. js 查找数组中某个字符出现的次数 代码示例 let arr = ['asd', 'green', 'yeadt', 'red', 'wati', 'red', 'red'] let index = arr.indexOf('red') let num = 0 while (index !== -1) { num++ console.log('red 的下标为' + index); index = arr.indexOf('red', index + 1) } console.log('总
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be us
1.背景 想要统计这一个字符串数组中每一个非重复字符串的数量,使用map来保存其key和value.这个需求在实际开发中经常使用到,我以前总是新建一个空数组来记录不重复字符串,并使用计数器计数,效率低下且麻烦,特此记录. 2.代码实现 public class test { public void makeEqual(String[] words) { Map<String,Integer> maps = new HashMap<>(); for (String str : wor