goden0102

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

面试题 01.02.判定是否互为字符重排

1. 题目描述

给定两个字符串 s1s2 ,请编写一个程序,确定其中一个字符串的字符重新排列后,能否变成另一个字符串。

示例 1:

输入: s1 = "abc", s2 = "bca"
输出: true 

示例 2:

输入: s1 = "abc", s2 = "bad"
输出: false

说明:

  • 0 <= len(s1) <= 100
  • 0 <= len(s2) <= 100

标签 哈希表 字符串 排序

2. 解题

  1. 对所有字符串做排序后再比较其hash值
  2. 利用map,对两个字符串中的字符分别做统计,最后再比较两个map是否相等。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPermutation

func CheckPermutation(s1 string, s2 string) bool

解法2

Types

This section is empty.

Jump to

Keyboard shortcuts

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