当前位置:网站首页>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()
边栏推荐
- Mathematical knowledge -- understanding and examples of fast power
- Idea autoguide package and autodelete package Settings
- Solution: the agent throws an exception error
- Getting started with pytest -- description of fixture parameters
- Introduction to Luogu 3 [circular structure] problem list solution
- 数学知识——快速幂的理解及例题
- Comp 250 parsing
- Realize the function of data uploading
- Mathematical problems (number theory) trial division to judge prime numbers, decompose prime factors, and screen prime numbers
- 國產全中文-自動化測試軟件Apifox
猜你喜欢
Embedded-c language-9-makefile/ structure / Consortium
Save the CDA from the disc to the computer
Video cover image setting, put cover images into multiple videos in the simplest way
Starting from the classification of database, I understand the map database
How do I interview for a successful software testing position? If you want to get a high salary, you must see the offer
2022-003arts: recursive routine of binary tree
One step implementation of yolox helmet detection (combined with oak intelligent depth camera)
Mathematical knowledge (Euler function)
Line by line explanation of yolox source code of anchor free series network (7) -- obj in head_ loss、Cls_ Loss and reg_ Calculation and reverse transmission of loss I
Summary of database problems
随机推荐
Tawang food industry insight | current situation, consumption data and trend analysis of domestic infant complementary food market
[understand one article] FD_ Use of set
Lm09 Fisher inverse transform inversion mesh strategy
【ClickHouse】How to create index for Map Type Column or one key of it?
Summary of common string processing functions in C language
Use of typescript classes
Its appearance makes competitors tremble. Interpretation of Sony vision-s 02 products
AcrelEMS高速公路微电网能效管理平台与智能照明解决方案智慧点亮隧道
Express logistics quick query method, set the unsigned doc No. to refresh and query automatically
数学知识——快速幂的理解及例题
6.30 year end summary, end of student age
Rhcsa --- work on the third day
idea自动导包和自动删包设置
DJB Hash
geotrust ov多域名ssl证书一年两千一百元包含几个域名?
How to recover deleted data in disk
Embedded-c language-8-character pointer array / large program implementation
Case sharing | intelligent Western Airport
将光盘中的cda保存到电脑中
Learn what definitelytyped is through the typescript development environment of SAP ui5