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的更多相关文章

  1. leetcode242—Valid Anagram

    Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: ...

  2. LeetCode242——Valid Anagram

    Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = & ...

  3. LeetCode 242. 有效的字母异位词(Valid Anagram)

    242. 有效的字母异位词 LeetCode242. Valid Anagram 题目描述 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 示例 1: 输入: s ...

  4. 【09_242】Valid Anagram

    Valid Anagram My Submissions Question Total Accepted: 43694 Total Submissions: 111615 Difficulty: Ea ...

  5. leetcode面试准备:Valid Anagram

    leetcode面试准备:Valid Anagram 1 题目 Given two strings s and t, write a function to determine if t is an ...

  6. 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. ...

  7. 22. leetcode 242. Valid Anagram(由颠倒字母顺序而构成的字)

    22. 242. Valid Anagram(由颠倒字母顺序而构成的字) Given two strings s and t, write a function to determine if t i ...

  8. 【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 ...

  9. [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: ...

随机推荐

  1. leetcode-229-求众数②

    题目描述: 方法一:摩尔投票法 class Solution: def majorityElement(self, nums: List[int]) -> List[int]: candiate ...

  2. 期望dp——zoj3640

    /* dp[i]表示力量为i时的期望 dp[i]=sum{tj}/n+sum{dp[i+cj]+1}/n //前一项是cj<i的和,后一项是cj>=i的和 初始状态dp[m] */ #in ...

  3. http://wiki.ros.org/navigation/Tutorials/RobotSetup

    http://wiki.ros.org/navigation/Tutorials/RobotSetup

  4. <随便写> 多线程的例子

    ''' 一个线程在使用这个共享的时候,其他线程必须等待他结束 通过"锁"实现,作用就是防止多个线程使用这片内存空间 进程:程序的一次执行 线程:cpu运算的基本调度单位 多线程:大 ...

  5. springcloud系列12 config的使用

    config组件分为server端和client端 config的原理: 就是当我们将配置文件放置在git上面,那么configserver就会去拉取相关配置文件至本地: 可以看到我本地是拉去了配置文 ...

  6. Cmd使用方式--命令行运行程序

    工具用惯却不知道如何去描述什么用,总感觉自己学东西用东西零零散散不系统,心虚!下面总结下自己使用cmd的几种方式. 1 => cmd,command,是window系统下命令提示符,是一种com ...

  7. SwiftUI 实现Draggesture效果

    今天闲来无事,使用SwiftUI 实现拖动,并且返回的动态效果.代码不多..... 效果如下: 代码如下: import SwiftUI import Combine class KBDragObje ...

  8. 《Practices of an Agile Developer:Woring in the Real World》读书笔记 PB16110698(~3.22)第三周

    <Practices of an Agile Developer:Woring in the Real World>读书笔记  本周我阅读了<高效程序员的45个习惯:敏捷开发修炼之道 ...

  9. 《OpenCV3编程入门》 札记

    图像处理和计算机视觉的区别在于: 图像处理侧重于 "处理"图像 --- 如增强,还原,去噪,分割,等等:而计算机视觉重点在于使用计算机(也许是可移动式的)来模拟人的视觉,因此模拟菜 ...

  10. [笔记]180612 for DevOps

    adb devices 识别不了安卓手机:我下的adb interface驱动下载链接:如果设备管理器中ADB Interface是黄色的,就需要先安装adb interface驱动(BD:adb i ...