leetcode242 Valid Anagram
lc242 Valid Anagram
直接统计每种字母出现次数即可
class Solution {
public boolean isAnagram(String s, String t) {
if(s.length() != t.length())
return false;
int[] count = new int[256];
for(char i : s.toCharArray()){
count[i]++;
}
for(char i : t.toCharArray()){
if(--count[i] < 0)
return false;
}
return true;
}
}
leetcode242 Valid Anagram的更多相关文章
- leetcode242—Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: ...
- LeetCode242——Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = & ...
- LeetCode 242. 有效的字母异位词(Valid Anagram)
242. 有效的字母异位词 LeetCode242. Valid Anagram 题目描述 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 示例 1: 输入: s ...
- 【09_242】Valid Anagram
Valid Anagram My Submissions Question Total Accepted: 43694 Total Submissions: 111615 Difficulty: Ea ...
- leetcode面试准备:Valid Anagram
leetcode面试准备:Valid Anagram 1 题目 Given two strings s and t, write a function to determine if t is an ...
- 242. Valid Anagram(C++)
242. Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. ...
- 22. leetcode 242. Valid Anagram(由颠倒字母顺序而构成的字)
22. 242. Valid Anagram(由颠倒字母顺序而构成的字) Given two strings s and t, write a function to determine if t i ...
- 【LeetCode】242. Valid Anagram (2 solutions)
Valid Anagram Given two strings s and t, write a function to determine if t is an anagram of s. For ...
- [leetcode]242. Valid Anagram验证变位词
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: ...
随机推荐
- leetcode-229-求众数②
题目描述: 方法一:摩尔投票法 class Solution: def majorityElement(self, nums: List[int]) -> List[int]: candiate ...
- 期望dp——zoj3640
/* dp[i]表示力量为i时的期望 dp[i]=sum{tj}/n+sum{dp[i+cj]+1}/n //前一项是cj<i的和,后一项是cj>=i的和 初始状态dp[m] */ #in ...
- http://wiki.ros.org/navigation/Tutorials/RobotSetup
http://wiki.ros.org/navigation/Tutorials/RobotSetup
- <随便写> 多线程的例子
''' 一个线程在使用这个共享的时候,其他线程必须等待他结束 通过"锁"实现,作用就是防止多个线程使用这片内存空间 进程:程序的一次执行 线程:cpu运算的基本调度单位 多线程:大 ...
- springcloud系列12 config的使用
config组件分为server端和client端 config的原理: 就是当我们将配置文件放置在git上面,那么configserver就会去拉取相关配置文件至本地: 可以看到我本地是拉去了配置文 ...
- Cmd使用方式--命令行运行程序
工具用惯却不知道如何去描述什么用,总感觉自己学东西用东西零零散散不系统,心虚!下面总结下自己使用cmd的几种方式. 1 => cmd,command,是window系统下命令提示符,是一种com ...
- SwiftUI 实现Draggesture效果
今天闲来无事,使用SwiftUI 实现拖动,并且返回的动态效果.代码不多..... 效果如下: 代码如下: import SwiftUI import Combine class KBDragObje ...
- 《Practices of an Agile Developer:Woring in the Real World》读书笔记 PB16110698(~3.22)第三周
<Practices of an Agile Developer:Woring in the Real World>读书笔记 本周我阅读了<高效程序员的45个习惯:敏捷开发修炼之道 ...
- 《OpenCV3编程入门》 札记
图像处理和计算机视觉的区别在于: 图像处理侧重于 "处理"图像 --- 如增强,还原,去噪,分割,等等:而计算机视觉重点在于使用计算机(也许是可移动式的)来模拟人的视觉,因此模拟菜 ...
- [笔记]180612 for DevOps
adb devices 识别不了安卓手机:我下的adb interface驱动下载链接:如果设备管理器中ADB Interface是黄色的,就需要先安装adb interface驱动(BD:adb i ...