当前位置:网站首页>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()
边栏推荐
- Record the bug of unity 2020.3.31f1 once
- MySQL table insert Chinese change? Solution to the problem of No
- Embedded-c language-8-character pointer array / large program implementation
- Starting from the classification of database, I understand the map database
- Fasttext text text classification
- 2022 Alibaba global mathematics competition, question 4, huhushengwei (blind box problem, truck problem) solution ideas
- [understand one article] FD_ Use of set
- Learn what definitelytyped is through the typescript development environment of SAP ui5
- Leetcode basic programming: array
- Markdown edit syntax
猜你喜欢
农业生态领域智能机器人的应用
Summary of database problems
Leetcode- insert and sort the linked list
Video multiple effects production, fade in effect and border background are added at the same time
Research on the security of ognl and El expressions and memory horse
Precipitate yourself and stay up late to sort out 100 knowledge points of interface testing professional literacy
培养中小学生对教育机器人的热爱之心
Realize the function of data uploading
[understand one article] FD_ Use of set
Typescript function details
随机推荐
Application of intelligent robot in agricultural ecology
C # picture display occupancy problem
Beginner crawler - biqu Pavilion crawler
Future trend of automated testing ----- self healing technology
Analyzing the hands-on building tutorial in children's programming
Thinkphp内核工单系统源码商业开源版 多用户+多客服+短信+邮件通知
The underlying principle of go map (storage and capacity expansion)
Let正版短信测压开源源码
Precipitate yourself and stay up late to sort out 100 knowledge points of interface testing professional literacy
Let genuine SMS pressure measurement open source code
Interview question: do you know the difference between deep copy and shallow copy? What is a reference copy?
How to write a client-side technical solution
Fasttext text text classification
Orthogonal test method and function diagram method for test case design
cs架构下抓包的几种方法
Case sharing | intelligent Western Airport
数学问题(数论)试除法做质数的判断、分解质因数,筛质数
Basic differences between Oracle and MySQL (entry level)
Getting started with pytest -- description of fixture parameters
LeetCode-对链表进行插入排序