letecode242有效字母的异位词

bool isAnagram(char* s, char* t) {
int statS[] = {};
int statT[] = {};
int lenS = strlen(s);
int lenT = strlen(t);
for(int i=;i<lenS;i++){
int index = s[i] -'a';
statS[index]++;
}
for(int i=;i<lenT;i++){
int index = t[i] -'a';
statT[index]++;
}
for(int i=;i<;i++){
if(statS[i] != statT[i] )
return false;
}
return true;
}
letecode242有效字母的异位词的更多相关文章
- LeetCode 49. 字母异位词分组(Group Anagrams)
题目描述 给定一个字符串数组,将字母异位词组合在一起.字母异位词指字母相同,但排列不同的字符串. 示例: 输入: ["eat", "tea", "ta ...
- C#版 - Leetcode49 - 字母异位词分组 - 题解
C#版 - Leetcode49 - 字母异位词分组 - 题解 Leetcode49.Group Anagrams 在线提交: https://leetcode.com/problems/group- ...
- [Swift]LeetCode49. 字母异位词分组 | Group Anagrams
Given an array of strings, group anagrams together. Example: Input: ["eat", "tea" ...
- [Swift]LeetCode242. 有效的字母异位词 | Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: ...
- [Swift]LeetCode438. 找到字符串中所有字母异位词 | Find All Anagrams in a String
Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings ...
- 有效的字母异位词的golang实现
给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 输入: s = "anagram", t = "nagaram" 输出: ...
- Leetcode 242.有效的字母异位词 By Python
给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 示例 1: 输入: s = "anagram", t = "nagaram" ...
- LeetCode(49): 字母异位词分组
Medium! 题目描述: 给定一个字符串数组,将字母异位词组合在一起.字母异位词指字母相同,但排列不同的字符串. 示例: 输入: ["eat", "tea", ...
- LeetCode--242--有效的字母异位词
问题描述: 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的一个字母异位词. 示例 1: 输入: s = "anagram", t = "nagara ...
随机推荐
- git 远程分支回滚
git代码库回滚: 指的是将代码库某分支退回到以前的某个commit id [本地代码库回滚]: git reset --hard commit-id :回滚到commit-id,讲commit-id ...
- 使用LAP数据集进行年龄训练及估计
一.背景 原本是打算按<DEX Deep EXpectation of apparent age from a single image>进行表面年龄的训练,可由于IMDB-WIKI的数据 ...
- Windows FFMPEG开发环境配置
1.去FFMPEG网站上下载Dev版本的库,里面有我们需要的头文件和lib文件,然后下载Shared版本的库,里面有我们需要的dll文件 http://ffmpeg.zeranoe.com/build ...
- App_Code目录类文件无法被调用的解决方法
1.选中类文件,在属性中的“生成操作”默认的“内容”改为“编译”就可以了. 2.重新生成解决方案
- 发布一个PHP包到Packagist, 然后使用Composer安装
Composer 能够方便的进行项目的依赖管理, 当我们发布一个包并且希望别人通过Composer安装的时候, 就需要将包发布到Composer的包仓库Packagist上面. 下面进行详细的说明一 ...
- 廖雪峰Java8JUnit单元测试-2使用JUnit-2异常测试
1.异常测试 对可能抛出的异常进行测试: 异常本身是方法签名的一部分: * public static int parseInt(String s) throws NumberFormatExcept ...
- laravel Faker-1.faker假数据
1. 安装 composer require fzaninotto/faker --dev 2. 创建 migrations 参考:laravel文档 3. 定义ModelFactory 说明: 默认 ...
- C++ 64位操作系统调用 RegOpenKey() 读取注册表,返回 2, ERROR_FILE_NOT_FOUND
环境:64位操作系统, VS2017 首先在命令行执行 REG ADD HKLM\Software\seastarsun /v serial /t REG_SZ /d 58ae4cb077a4e1 在 ...
- SerialPort项目配置
app的build.gradle下: apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultCon ...
- 基于consul高可用
1.介绍consul Consul 是一个支持多数据中心分布式高可用的服务发现和配置共享的服务软件,由 HashiCorp 公司用 Go 语言开发, 基于 Mozilla Public License ...