当前位置:网站首页>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;
}
}
边栏推荐
- DAY FIVE
- 快手的新生意,还得靠辛巴吆喝?
- 在docker中快速使用各个版本的PostgreSQL数据库
- Quickly use various versions of PostgreSQL database in docker
- app通用功能测试用例
- Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
- iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
- How rider uses nuget package offline
- Design a red envelope grabbing system
- Interface joint debugging test script optimization v4.0
猜你喜欢

Who said that new consumer brands collapsed? Someone behind me won

What can the interactive slide screen demonstration bring to the enterprise exhibition hall

Introduction to GPIO

DAY ONE

Rider离线使用Nuget包的方法
![[automated testing framework] what you need to know about unittest](/img/4d/0f0e0a67ec41e41541e0a2b5ca46d9.png)
[automated testing framework] what you need to know about unittest

Penetration test --- database security: detailed explanation of SQL injection into database principle

STM32通过串口进入和唤醒停止模式

Design a red envelope grabbing system

The largest single investment in the history of Dachen was IPO today
随机推荐
Personal digestion of DDD
Yaduo Sangu IPO
TypeScript增量编译
openresty ngx_ Lua subrequest
rancher集成ldap,实现统一账号登录
从外企离开,我才知道什么叫尊重跟合规…
Building lease management system based on SSM framework
How does win11 restore the traditional right-click menu? Win11 right click to change back to traditional mode
Introduction to GPIO
在Docker中分分钟拥有Oracle EMCC 13.5环境
Why should a complete knapsack be traversed in sequence? Briefly explain
快讯 l Huobi Ventures与Genesis公链深入接洽中
(leetcode) sum of two numbers
PostgreSQL使用Pgpool-II实现读写分离+负载均衡
Use package FY in Oracle_ Recover_ Data. PCK to recover the table of truncate misoperation
沉浸式投影在线下展示中的三大应用特点
GPIO简介
Quickly use various versions of PostgreSQL database in docker
DAY TWO
Typescript incremental compilation