首页 > 试题广场 >

确定两串乱序同构

[编程题]确定两串乱序同构
  • 热度指数:47210 时间限制:C/C++ 3秒,其他语言6秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解

给定string stringA和string stringB,编写程序确认两字符串包含的字符是否完全相同,注意大小写为不同字符,且考虑字符串中的空格,返回一个bool,代表两串是否由一样的字符组成。保证两串的长度都小于等于5000。

示例1

输入

"This is nowcoder","is This nowcoder"

输出

true
示例2

输入

"Here you are","Are you here"

输出

false
头像 杨~~
发表于 2022-01-21 16:35:48
先排序然后确定两排序后的字符串是否相同即可 public: bool checkSam(string stringA, string stringB) { // write code here sort(stringA.begin(),stringA.end 展开全文
头像 summer_winter
发表于 2020-08-13 13:02:18
C++定义两个map 分别存储两个字符串每个字符出现的次数遍历两个map 对于给定的字符key 如果 value不一样则不满足条件 false都满足的话 true class Same { public: bool checkSam(string stringA, string string 展开全文
头像 Coming680
发表于 2022-03-24 20:54:08
class Same { public: bool checkSam(string stringA, string stringB) { // write code here map<char, int> mp; for (int 展开全文
头像 爱编程的宽宽
发表于 2023-04-14 08:11:27
class Same { public: bool checkSam(string stringA, string stringB) { // write code here array<int, 128> bufA{ 0 }; // 保存字 展开全文
头像 牛客314328168号
发表于 2023-02-10 22:52:45
#include <algorithm> #include <string> class Same { public: bool checkSam(string stringA, string stringB) { // write code her 展开全文
头像 牛客548207004号
发表于 2023-10-26 21:16:12
import java.util.*; public class Same { public boolean checkSam(String stringA, String stringB) { // write code here if (stringA. 展开全文