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. Map按键排序(sort by key)

    1.需求:已知有如下map,要求按照key倒序排列遍历. Map<String, Integer> map = new HashMap<>(); map.put("1 ...

  2. (转)Wireshark "The NPF driver isn’t running…"(

    转:http://blog.sina.com.cn/s/blog_4bfd07180100e3ar.html 前几天重装系统,装上了windows7 RC系统.昨天开始尝试装上了wireshark 这 ...

  3. PAT甲级——A1120 Friend Numbers【20】

    Two integers are called "friend numbers" if they share the same sum of their digits, and t ...

  4. QT之QSettings 学习

    1.读写配置文件. 代码如下: //创建配置文件 QSettings iniFile(QCoreApplication::applicationDirPath()+"/test.ini&qu ...

  5. 19.SimLogin_case03

    # 模拟登录GitHub import requests from lxml import etree class Login(): def __init__(self): self.headers ...

  6. 01_springboot2.x之springboot入门

    1.简介 Spring Boot来简化Spring应用开发,约定大于配置, 去繁从简,just run就能创建一个独立的,产品级别的应用. 优点: 1.简化Spring应用开发的一个框架: 2.整个S ...

  7. <linux常用命令>初级版

    显示时间 date 显示日历cal 变换目录 cd 显示当前所在目录 pwd 建立新目录 mkdir -p a/b/c 删除空目录 rmdir 当前目录下文件和目录显示 ls 复制 cp 文件 路径 ...

  8. 2019-6-23-天河2-程序-version-GLIBCXX_3.4.21-not-found-解决方法

    title author date CreateTime categories 天河2 程序 version GLIBCXX_3.4.21 not found 解决方法 lindexi 2019-06 ...

  9. 【笔记篇】Ubuntu一日游

    今天做数据的时候在Windows下出问题了(好像是爆栈了QAQ) 于是乎就打开了自己的Ubuntu虚拟机… 然而沉迷Windows的我已经忘记自己对这台虚拟机做过什么(比如装残了一个ycm自己都不知道 ...

  10. 学习 debug

    要在代码编辑器中设置源代码断点,有以下 4 种操作方式. (1) 把光标移到要设为断点的行上,按下 F5 键. (2) 用鼠标左键单击要设为断点的行的最左端. (3) 用鼠标右键单击要设为断点的行,在 ...