```c /* Author: Zoro Date: 2019/11/10 Function: Valid Anagram Title: leetcode 242 anagram.c think: 桶排序思想 */ #include #include #include bool isAnagram(... ...
分类:
其他好文 时间:
2019-11-11 12:39:55
阅读次数:
99
题目描述 假设给定两个字符串 s 和 t, 让我们写出一个方法来判断这两个字符串是否是字母异位词? 字母异位词就是,两个字符串中含有字母的个数和数量都一样,比如: 解题思路 1) 可以初始化一个 hash map,键作为出现的字母,值作为对应字母出现的次数。 2)然后遍历字符串 s,将 map 中对 ...
分类:
其他好文 时间:
2019-11-10 17:32:21
阅读次数:
130
题目: 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词。 示例 1: 输入: s = "anagram", t = "nagaram"输出: true示例 2: 输入: s = "rat", t = "car"输出: false说明:你可以假设字符串只包含小写字母。 ...
分类:
其他好文 时间:
2019-11-08 12:18:06
阅读次数:
68
s="anagram", t="nagaram"这就属于异位词,长度一样,包含的字母都一样,每个字符出现的频率也一样,只是顺序不同而已s="rat",t="car"这种就不属于异位词,因为s中的'r'在t中没有思路:1 首先看字符串长度是否一样,不一样则为false2 看每个字符出现的频率是否一样, ...
分类:
其他好文 时间:
2019-09-18 10:50:02
阅读次数:
115
Given an array of strings, group anagrams together. Example: 题意: 给定一堆单词,把变位词放一块儿去。 碎碎念: 开始想说“eat” 转charArray {'e', 'a', 't'} “tea” 转charArray {'t', 'e ...
分类:
其他好文 时间:
2019-09-12 09:21:57
阅读次数:
75
Two strings are anagrams if they are permutations of each other. For example, "aaagmnrs" is an anagram of "anagrams". Given an array of strings, remov ...
分类:
其他好文 时间:
2019-09-12 09:19:34
阅读次数:
167
242. 有效的字母异位词 描述 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词。 示例 示例 1: 输入: s = "anagram", t = "nagaram" 输出: true 示例 2: 输入: s = "rat", t = "car" 输出: false ...
分类:
其他好文 时间:
2019-09-02 14:02:30
阅读次数:
54
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Example 2: Note:You may assume the string contains only ...
分类:
其他好文 时间:
2019-08-24 09:59:55
阅读次数:
90
lc49 Group Anagram 逻辑很简单,就是统计字母出现次数,然后将完全相同的字符串放入同一list 关键是怎么实现 统计的部分,可以通过将string排序,Arrays.sort(),或者像之前int[26]一样, 那么如何一次遍历,就能将相同字符串放入一个list呢? 这里用到了Has ...
分类:
其他好文 时间:
2019-06-01 11:16:54
阅读次数:
80
Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Example 2: Note:You may assume the string contains only ...
分类:
其他好文 时间:
2019-05-10 21:58:16
阅读次数:
144