华为机试---字符串匹配
来源:互联网 发布:什么是数据库规范化 编辑:程序博客网 时间:2024/05/16 18:29
题目描述
题目标题:
判断短字符串中的所有字符是否在长字符串中全部出现
详细描述:
接口说明
原型:
boolIsAllCharExist(char* pShortString,char* pLongString);
输入参数:
char* pShortString:短字符串
char* pLongString:长字符串
输入描述:
输入两个字符串。第一个为短字符,第二个为长字符。
输出描述:
返回值:
输入例子:
bcabc
输出例子:
true
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
String short_string = scan.nextLine();
String long_string = scan.nextLine();
boolIsAllCharExist(short_string , long_string);
}//endwhile
scan.close();
}
private static void boolIsAllCharExist(String short_string , String long_string){
List<Character> short_list = new ArrayList<Character>();
List<Character> long_list = new ArrayList<Character>();
int short_length = short_string.length();
int long_length = long_string.length();
for(int i = 0 ; i < short_length ; i++){
short_list.add(short_string.charAt(i));
}
for(int i = 0 ; i < long_length ; i++){
long_list.add(long_string.charAt(i));
}
char temp_ch = '*';
int count = 0;
for(int i = 0 ; i < short_length ; i++){
temp_ch = short_list.get(i);
if(long_list.contains(temp_ch)){
count++;
}
}
if(count == short_length){
System.out.println(true);
}else{
System.out.println(false);
}
}
}
1 0
- 华为机试---字符串匹配
- 华为机试——字符串中括号是否匹配
- 华为oj 字符串匹配
- 华为oj 字符串匹配
- 【华为 OJ 】 字符串匹配
- 【华为OJ】字符串匹配
- 华为编程大赛-字符串匹配
- 华为编程大赛--字符串匹配
- 华为编程大赛-字符串匹配
- 华为OJ(字符串匹配)
- 【华为OJ】【055-字符串匹配】
- 华为OJ 初级:字符串匹配
- 华为oj初级 字符串匹配
- 字符串通配符匹配-2014华为机试题目
- 华为机试之括号匹配
- 华为机试练习---括号匹配问题
- 华为机试—括号匹配
- 华为机试之括号匹配
- Gcc在Windows下编写C语言
- iOS 9 NetworkExtension使用
- 设计模式—装饰模式
- linux命令笔记(随时更新)
- Android View 深度分析requestLayout、invalidate与postInvalidate
- 华为机试---字符串匹配
- R可视化绘图一ggplot2之qplot
- .NET Framework4.5 & .NET Framework4.0
- 2016.06.04
- LeetCode Top K Frequent Elements
- memcached和redis
- 迭代器的辅助函数实例
- Grabcut算法----opencv2.4.11
- poj 1236 Network of Schools 强连通分量