lc242

package
v0.0.0-...-b071cee Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

README

242.有效的字母异位词

1. 题目描述

给定两个字符串 *s**t* ,编写一个函数来判断 *t* 是否是 *s* 的字母异位词。

注意: 若  *s**t* * * 中每个字符出现的次数都相同,则称  *s**t* * * 互为字母异位词。

 

示例 1:


输入: s = "anagram", t = "nagaram"
输出: true

示例 2:


输入: s = "rat", t = "car"
输出: false

 

提示:

  • 1 <= s.length, t.length <= 5 * 10^4
  • st  仅包含小写字母  

**进阶: ** 如果输入字符串包含 unicode 字符怎么办?你能否调整你的解法来应对这种情况?

标签 哈希表 字符串 排序

2. 解题

1.对字符串进行排序
2.采用hash表统计字符出现的次数

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL