leetcode242
public class Solution {
public bool IsAnagram(string s, string t) {
Dictionary<char, int> dic = new Dictionary<char, int>();
foreach (var c in s)
{
if (!dic.ContainsKey(c))
{
dic.Add(c, );
}
else
{
dic[c]++;
}
}
foreach (var c in t)
{
if (!dic.ContainsKey(c))
{
return false;
}
else
{
dic[c]--;
}
}
foreach (var d in dic)
{
if (d.Value != )
{
return false;
}
}
return true;
}
}
https://leetcode.com/problems/valid-anagram/#/description
leetcode242的更多相关文章
- [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: ...
- leetcode242—Valid Anagram
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Input: ...
- LeetCode242——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 判断两个字符串是不是 Anagram ?
题目描述 假设给定两个字符串 s 和 t, 让我们写出一个方法来判断这两个字符串是否是字母异位词? 字母异位词就是,两个字符串中含有字母的个数和数量都一样,比如: Example 1: Input: ...
- leetcode242 Valid Anagram
lc242 Valid Anagram 直接统计每种字母出现次数即可 class Solution { public boolean isAnagram(String s, String t) { i ...
- LeetCode242 有效的字母异位词(Java字符数组排序&自定义排序记录)
题目: 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词. 示例 1: 输入: s = "anagram", t = "nagaram& ...
- leetCode242 有效的字母异位词
引言: 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词. 示例 1: 输入: s = "anagram", t = "nagaram&qu ...
- go语言实现leetcode-242
package main import ( "fmt" "reflect" ) func isAnagram(s string, t string) bool ...
- leetcode-242有效字母异位词
题目 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词. 示例 1: 输入: s = "anagram", t = "nagaram&quo ...
随机推荐
- 纯CSS绘制三角形(各种角度)类似于使用字符画法,根据位移不同,也可以使用两个元素画出三角边框
我们的网页因为 CSS 而呈现千变万化的风格.这一看似简单的样式语言在使用中非常灵活,只要你发挥创意就能实现很多比人想象不到的效果.特别是随着 CSS3 的广泛使用,更多新奇的 CSS 作品涌现出来. ...
- Oracle密码过期处理
问题:Oracle密码过期导致数据库无法访问 解决方案: 1.后台以数据库管理员身份登陆,服务器中打开cmd命令,然后输入 sqlplus / as sysdba 2.查看用户对应的proifle文件 ...
- DOS批处理 - 函数教程
DOS Batch - Function Tutorial What it is, why it`s important and how to write your own. Description: ...
- C51 头文件中的 extern
C51 头文件使用 extern 的目的是声明外部变量或函数. 使用注意: 只放在 .h 文件中. 声明时不用赋值. extern 只是声明不是定义.
- tomcat源码阅读之StandardContext
Context实例表示一个具体的web应用程序,其中包含一个或者多个Wrapper实例,每个Wrapper表示一个具体的servlet定义.StandardContext类是Context接口的标准实 ...
- Java8 lam。。。表达式
双冒号:相当于用了别人实现的方法,格式,类名::方法 Math::max等效于(a, b)->Math.max(a, b)String::startWith等效于(s1, s2)->s1. ...
- sql having 函数 按匿名字段作为条件进行查询
今天写sql 遇到一个问题 SELECT a.*, count(b.id) AS nums FROM a LEFT JOIN b ON a.id=b.a_id WHERE nums>1 这时候会 ...
- java获取随机密码
import java.util.Random; public class tests { /** * * author LiuQiang * date 2013-10-14 下午01:13:54 * ...
- Spring 注解方式 实现 IOC 和 DI
注:以下所有测试案例(最后一个除外)的测试代码都是同一个: package cn.tedu.test; import org.junit.Test; import org.springframewor ...
- [转] Maven.pom.xml 配置示例
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://mave ...