Leetcode 242 Valid Anagram 字符串处理
字符串s和字符串t是否异构,就是统计两个字符串的a-z的字符数量是否一值
class Solution {
public:
bool isAnagram(string s, string t) {
int flgs[] = {};//统计s a-z的字符数量
for(int i = ;i<s.size();++i){
flgs[s[i] - 'a'] ++;
}
int flgt[] = {}; //统计t a-z的字符数量
for(int i = ;i<t.size();++i){
flgt[t[i] - 'a'] ++;
}
for(int i = ;i< ;++i){
if(flgs[i] != flgt[i]) return false;
}
return true;
}
};
Leetcode 242 Valid Anagram 字符串处理的更多相关文章
- 22. leetcode 242. Valid Anagram(由颠倒字母顺序而构成的字)
22. 242. Valid Anagram(由颠倒字母顺序而构成的字) Given two strings s and t, write a function to determine if t i ...
- LN : leetcode 242 Valid Anagram
lc 242 Valid Anagram 242 Valid Anagram Given two strings s and t, write a function to determine if t ...
- [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]242. Valid Anagram判断两个字符串是不是包含相同字符的重排列
/* 思路是判断26个字符在两个字符串中出现的次数是不是都一样,如果一样就返回true. 记住这个方法 */ if (s.length()!=t.length()) return false; int ...
- [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 242 Valid Anagram
Problem: Given two strings s and t, write a function to determine if t is an anagram of s. For examp ...
- Java [Leetcode 242]Valid Anagram
题目描述: Given two strings s and t, write a function to determine if t is an anagram of s. For example, ...
- Leetcode 242. 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 pytyhon
题目: Given two strings s and t, write a function to determine if t is an anagram of s. For example,s ...
随机推荐
- [Ramda] Declaratively Map Predicates to Object Properties Using Ramda where
Sometimes you need to filter an array of objects or perform other conditional logic based on a combi ...
- watchdog的正确使用方法
关于watchdog应该有过单片机学习经历的人.都比較熟悉.但watchdog的正确使用方法,恐怕大家假设没有经历过实际产品的开发不会有深入的理解. 瑞萨RL78系列的单片机自身带有watchdog, ...
- 初步安装git使用命令配置电脑中的git关联的账户
原文地址 https://www.jianshu.com/p/39684a3ad4fa 出现问题 当我们初步使用git的时候,会报一些出乎预料的错误,比如:报错:fatal: unable to au ...
- Java解惑八:很多其它库之谜
本文是依据JAVA解惑这本书,做的笔记. 电子书见:http://download.csdn.net/detail/u010378705/7527721 谜题76 将线程的启动方法start(),写成 ...
- ios开发网络学习AFN三:AFN的序列化
#import "ViewController.h" #import "AFNetworking.h" @interface ViewController () ...
- 提高编程能力的7条建议 分类: T_TALENT 2014-04-12 10:41 294人阅读 评论(0) 收藏
编程是非常酷的一件事情,但是在酷炫的背后它对很多人来说还是挺难的.很多人在学习编程之初就被困难击败了. 当你不熟悉编程的时候,你可能会觉得无从下手,并且不知道如何运用学到的知识.只要你通过了这一困难的 ...
- STS 3.6.4 SpringMVC 4.1.6 Hibernate 4.3.8 MySQL
开发环境: Java 1.8 Spring Tool Suite 3.6.4 Spring faramework 4.1.6 Hibernate 4.3.8 Maven 2.9 数据库是MySQL 5 ...
- Android的NDK开发(2)————利用Android NDK编写一个简单的HelloWorld
1.Android NDK简介 NDK全称为native development kit本地语言(C&C++)开发包.而对应的是经常接触的Android-SDK,(software devel ...
- android WebView总 结
浏览器控件是每个开发环境都具备的,这为马甲神功提供了用武之地,windows的有webbrowser,android和ios都有webview.只是其引擎不同,相对于微软的webbrowser,and ...
- 【poj3225】Help with Intervals
Time Limit: 6000MS Memory Limit: 131072K Total Submissions: 12084 Accepted: 3033 Case Time Limit ...