某公司笔试题记录

某公司笔试题记录_第1张图片




编程题:

public class Test {
	public static void main(String[] args) {
		System.out.println(isInclude("abcde", "acd"));
	}

	private static boolean isInclude(String source, String dest) {
		int count = 0;
		for (int i = 0; i < source.length(); i++) {
			if (source.charAt(i) == dest.charAt(count)) {
				count++;
				if (count == dest.length()) {
					break;
				}
			}
		}
		return dest.length() == count;
	}
}




你可能感兴趣的:(java,笔记,笔试题)