当前位置:网站首页>Leecode brushes questions and records interview questions 01.02 Determine whether it is character rearrangement for each other
Leecode brushes questions and records interview questions 01.02 Determine whether it is character rearrangement for each other
2022-07-07 00:12:00 【Why is there a bug list】
topic
Given two strings s1 and s2, Please write a program , After determining the character rearrangement of one of the strings , Can it be another string .
Example 1:
Input : s1 = “abc”, s2 = “bca”
Output : true
Example 2:
Input : s1 = “abc”, s2 = “bad”
Output : false
explain :
0 <= len(s1) <= 100
0 <= len(s2) <= 100
answer
class Solution {
public boolean CheckPermutation(String s1, String s2) {
char[] c1=s1.toCharArray();
char[] c2=s2.toCharArray();
if(c1.length!=c2.length) return false;
boolean a=false;
boolean b=false;
int j=0;
for(int i=0;i<c1.length;i++)
{
for(j=0;j<c2.length;j++)
{
if(c1[i]==c2[j]) break;
}
if(j==c2.length) return false;
j=0;
}
a=true;
for(int i=0;i<c2.length;i++)
{
for(j=0;j<c1.length;j++)
{
if(c2[i]==c1[j]) break;
}
if(j==c2.length) return false;
j=0;
}
b=true;
return a&&b;
}
}
边栏推荐
- [2022 the finest in the whole network] how to test the interface test generally? Process and steps of interface test
- 1000 words selected - interface test basis
- 三句话简要介绍子网掩码
- The largest single investment in the history of Dachen was IPO today
- Quickly use various versions of PostgreSQL database in docker
- Do you still have to rely on Simba to shout for a new business that is Kwai?
- Oracle对表进行的常用修改命令
- Server SMP, NUMA, MPP system learning notes.
- 谷歌百度雅虎都是中国公司开发的通用搜索引擎_百度搜索引擎url
- MATLIB从excel表中读取数据并画出函数图像
猜你喜欢

自动化测试工具Katalon(Web)测试操作说明

app通用功能测试用例

DevOps可以帮助减少技术债务的十种方式

沉浸式投影在线下展示中的三大应用特点

Hydrogen future industry accelerates | the registration channel of 2022 hydrogen energy specialty special new entrepreneurship competition is opened!

MVC and MVVM

What is a responsive object? How to create a responsive object?

Racher integrates LDAP to realize unified account login

基于jsp+servlet+mysql框架的旅游管理系统【源码+数据库+报告】

What can the interactive slide screen demonstration bring to the enterprise exhibition hall
随机推荐
Racher integrates LDAP to realize unified account login
Penetration test --- database security: detailed explanation of SQL injection into database principle
[2022 the finest in the whole network] how to test the interface test generally? Process and steps of interface test
在docker中快速使用各个版本的PostgreSQL数据库
GPIO简介
TypeScript增量编译
TypeScript中使用类型别名
数据运营平台-数据采集[通俗易懂]
okcc呼叫中心的订单管理时怎么样的
DAY FOUR
SQL的一种写法,匹配就更新,否则就是插入
Yaduo Sangu IPO
[vector retrieval research series] product introduction
从外企离开,我才知道什么叫尊重跟合规…
【CVPR 2022】目标检测SOTA:DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection
Local deployment Zeppelin 0.10.1
Pytest multi process / multi thread execution test case
pinia 模块划分
Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming
Typescript incremental compilation