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. odoo 分组视图下显示同一批次记录的总数

    修改前: 修改后: xml文件: <?xml version="1.0" encoding="utf-8"?> <!-- vim:fdn=3: ...

  2. 代码执行批量Excel数据导入Oracle数据库

    由于基于Oracle数据库上做开发,因此常常会需要把大量的Excel数据导入到Oracle数据库中,其实如果从事SqlServer数据库的开发,那么思路也是一样的,本文主要介绍如何导入Excel数据进 ...

  3. jdk配置到tomcat配置

    1.jdk配置 首先下载jdk 这里我下载的是 jdk1.8 (jdk1.8.0_181\) 然后,安装 我的安装路径 C:\Program Files\Java\jdk1.8.0_181\ 我选择默 ...

  4. C++和JavaScript脚本的相互调用

    脚本调用C++相对比较容易,使用ATL组件只需要抛双接口即可,但在exe里如何做到呢?本文实现了在exe里脚本和C++的相互调用.在EXE里也需要对外抛送一个继承自IDispatch的接口.并需要重载 ...

  5. 如何区分无线AP跟无线路由器

    无线AP是一个无线网络的接入点,俗称“热点”.主要有路由交换接入一体设备和纯接入点设备,一体设备执行接入和路由工作,纯接入设备只负责无线客户端的接入,纯接入设备通常作为无线网络扩展使用,与其他AP或者 ...

  6. (1)mysql数据库操作

    1.安装mysql https://dev.mysql.com/downloads/windows/installer/8.0.html 2.mysql启停 运行mysql         net s ...

  7. latex ctex 的section不能写中文, /href

    问题描述:再使用超链接 /href 后发现section{}不能写入中文,以前是好使的,经过查询验证,需要在引导区里加入 \hypersetup{CJKbookmarks=true} 即可恢复正常.

  8. VM 虚拟机使用桥接模式却连不上网的解决办法(转载)

    只需将VM的虚拟网络编辑器中关于 VMnet0 的设置改一下就行了: 1.进入VMware的 编辑 -> 虚拟网络编辑器. 第一步 2.选择更改设置. 3.将VMnet0(或其它类型为桥接模式的 ...

  9. mysql数据库字段bigint使用

    Mysql里有个数据类型bigint 在java转换成实体对象时,处理不当容易出现以下异常: java.lang.ClassCastException: java.lang.Long cannot b ...

  10. linux 文件类型的颜色

    linux文件颜色的含义:蓝色代表目录 绿色代表可执行文件 红色表示压缩文件 浅蓝色表示链接文件 灰色表示其他文件 红色闪烁表示链接的文件有问题了 黄色表示设备文件 蓝色文件----------目录 ...