242. Valid Anagram
来源:互联网 发布:淘宝上钻石多少好评 编辑:程序博客网 时间:2024/06/17 01:39
原题
Given two strings s and t, write a function to determine if t is an anagram of s.
For example,
s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.
Note:
You may assume the string contains only lowercase alphabets.
代码实现
public bool IsAnagram(string s, string t) { int[] hash = new int[123]; //a~z if(s.Length!=t.Length) return false; foreach(var ch in s){ hash[Convert.ToInt32(ch)]++; } foreach(var ch in t){ if(hash[Convert.ToInt32(ch)]--<=0) return false; } return true; }
leetcode-solution库
leetcode算法题目解决方案每天更新在github库中,欢迎感兴趣的朋友加入进来,也欢迎star,或pull request。https://github.com/jackzhenguo/leetcode-csharp
2 0
- [leetcode] 242.Valid Anagram
- 242.Valid Anagram
- leetcode 242. Valid Anagram
- 242. Valid Anagram
- [leetcode] 242. Valid Anagram
- leetCode 242. Valid Anagram
- Leetcode 242. Valid Anagram
- 242. Valid Anagram
- 242. Valid Anagram LeetCode
- 242. Valid Anagram
- LeetCode 242. Valid Anagram
- LeetCode 242. Valid Anagram
- 242. Valid Anagram
- 242. Valid Anagram
- 242. Valid Anagram
- 242. Valid Anagram
- 242. Valid Anagram
- 242. Valid Anagram
- 【UML】机房收费系统十种图示例
- 编写RESTful风格的程序
- 动态规划题——最短路径问题
- 栈与队列
- spark mllib源码分析之随机森林(Random Forest)(三)
- 242. Valid Anagram
- HTML标签元素
- Ubuntu 配置 Tomcat
- 图论-思维题-hdu6029-Graph Theory
- STL容器:vector
- Linux下MongoDB权限管理
- S5PV210 DATASHEET Section2.6 booting sequence 翻译
- 编码问题:ASCII、Unicode和UTF-8
- Hibernate_操作对象_对象的状态分类、Session中的方法概述