当前位置:网站首页>Exercise notes 13 (effective letter ectopic words)
Exercise notes 13 (effective letter ectopic words)
2022-07-02 04:58:00 【weixin_ fifty-one million three hundred and twelve thousand and】
List of articles
One 、 subject
Two 、 Code
class Solution {
public boolean isAnagram(String s, String t) {
char[] str1 = s.toCharArray();
char[] str2 = t.toCharArray();
Arrays.sort(str1);
Arrays.sort(str2);
return Arrays.equals(str1, str2);
}
}
class Solution {
public:
bool isAnagram(string s, string t) {
sort(s.begin(),s.end());
sort(t.begin(),t.end());
if(s==t)
{
return true;
}
else
{
return false;
}
}
};
3、 ... and 、 summary
1. Because we need to consider all the characters of the two strings and the number of their occurrences , Therefore, the first thought is to sort the two strings to determine whether they are equal . use sort Function can facilitate sorting .
2.toCharArray()
边栏推荐
- Online incremental migration of DM database
- Lay the foundation for children's programming to become a basic discipline
- Domestic all Chinese automatic test software apifox
- Pit encountered in win11 pytorch GPU installation
- What are the rules and trading hours of agricultural futures contracts? How much is the handling fee deposit?
- Starting from the classification of database, I understand the map database
- LeetCode-对链表进行插入排序
- Summary of MySQL key challenges (2)
- 记录一次Unity 2020.3.31f1的bug
- Analyzing the hands-on building tutorial in children's programming
猜你喜欢

Markdown编辑语法

One step implementation of yolox helmet detection (combined with oak intelligent depth camera)

Summary of database problems

農業生態領域智能機器人的應用

Solution of DM database unable to open graphical interface

Idea automatic package import and automatic package deletion settings

洛谷入门3【循环结构】题单题解

Embedded-c language-9-makefile/ structure / Consortium

Rhcsa --- work on the fourth day

将光盘中的cda保存到电脑中
随机推荐
Rhcsa --- work on the fourth day
Embedded-c language-8-character pointer array / large program implementation
CubeMx DMA笔记
Cultivate primary and secondary school students' love for educational robots
记录一次Unity 2020.3.31f1的bug
Mouse events in JS
[understand one article] FD_ Use of set
Cache consistency solution - how to ensure the consistency between the cache and the data in the database when changing data
Typescript function details
Solution of DM database unable to open graphical interface
Analyzing the hands-on building tutorial in children's programming
Leetcode- insert and sort the linked list
Orthogonal test method and function diagram method for test case design
Introduction to Luogu 3 [circular structure] problem list solution
Detailed process of DC-1 range construction and penetration practice (DC range Series)
geotrust ov多域名ssl證書一年兩千一百元包含幾個域名?
Video multiple effects production, fade in effect and border background are added at the same time
Domestic all Chinese automatic test software apifox
Preparation for writing SAP ui5 applications using typescript
Cannot activate CONDA virtual environment in vscode