当前位置:网站首页>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;
}
}
边栏推荐
- SuperSocket 1.6 创建一个简易的报文长度在头部的Socket服务器
- Data operation platform - data collection [easy to understand]
- 【CVPR 2022】目标检测SOTA:DINO: DETR with Improved DeNoising Anchor Boxes for End-to-End Object Detection
- 2022/2/10 summary
- Common modification commands of Oracle for tables
- 【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
- Interface joint debugging test script optimization v4.0
- DevOps可以帮助减少技术债务的十种方式
- vector的使用方法_vector指针如何使用
- Do you still have to rely on Simba to shout for a new business that is Kwai?
猜你喜欢
What is AVL tree?
Building lease management system based on SSM framework
GPIO简介
System activity monitor ISTAT menus 6.61 (1185) Chinese repair
rancher集成ldap,实现统一账号登录
Yaduo Sangu IPO
【自动化测试框架】关于unittest你需要知道的事
陀螺仪的工作原理
DAY THREE
Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming
随机推荐
app通用功能測試用例
基于SSM框架实现的房屋租赁管理系统
STM32通过串口进入和唤醒停止模式
rancher集成ldap,实现统一账号登录
Google, Baidu and Yahoo are general search engines developed by Chinese companies_ Baidu search engine URL
Personal digestion of DDD
Basic chart interpretation of "Oriental selection" hot out of circle data
TypeScript中使用类型别名
DevOps可以帮助减少技术债务的十种方式
Eureka Client启动后就关闭 Unregistering application xxx with eureka with status DOWN
Pinia module division
Oracle中使用包FY_Recover_Data.pck来恢复truncate误操作的表
为什么完全背包要用顺序遍历?简要解释一下
微信小程序uploadfile服务器,微信小程序之wx.uploadFile[通俗易懂]
JS import excel & Export Excel
How does win11 restore the traditional right-click menu? Win11 right click to change back to traditional mode
iMeta | 华南农大陈程杰/夏瑞等发布TBtools构造Circos图的简单方法
C语言输入/输出流和文件操作【二】
2022/2/11 summary
2022/2/10 summary