面试题,第一题不知道要表达什么意思;第二题知道意思却没有思路。晕。。有大神进来指点一下吗?

qq_29448025 2017-03-24 11:02:09
...全文
200 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_29448025 2017-03-24
  • 打赏
  • 举报
回复
引用 1 楼 liu_siat 的回复:
第1题,最简单的方法就是蛮干,以第一个字符串为外循环,以第二个字符串为内循环进行遍历。 第2题,用Java FX可实现动画,或用HTML 5
第1题,我的理解,是不是两个字符串的相同子串的最大交集呀?如果不求交集,字符串的最大子串代指什么呢?
liu_siat 2017-03-24
  • 打赏
  • 举报
回复
第1题,最简单的方法就是蛮干,以第一个字符串为外循环,以第二个字符串为内循环进行遍历。 第2题,用Java FX可实现动画,或用HTML 5
李德胜1995 2017-03-24
  • 打赏
  • 举报
回复
最大子串就是sd0....找出他们
zs808 2017-03-24
  • 打赏
  • 举报
回复
首先,第一个问题求的是“最大子串”,这个相对于求所有子串的问题更容易解决一点。 通过比较方便的方法就是,从比较短的字符串的最长子串开始,逐层进行比较。 子串,就是,比如ABCD 那么,A,B,C,D,AB,BC,CD,ABC,BCD,ABCD就是它的子串。 好,知道这些概念,那么就很好写实现了,下面是一个实例:
public static void main(String[] args) {
		String str1 = "bvsfsd01u";
		String str2 = "yysd0x";

		// 找出str1与str2较长的赋值到strLonger,较短的复制到strShorter
		String strLonger, strShorter;
		if (str1.length() > str2.length()) {
			strLonger = str1;
			strShorter = str2;
		} else {
			strLonger = str2;
			strShorter = str1;
		}

		for (int i = strShorter.length(); i > 0; i--) {
			for (int j = 0; j < strShorter.length() - i; j++) {
				String subStr = strShorter.substring(j, j + i); //截取strShorter的子串
				if (strLonger.contains(subStr)) { //判断子串是否在strLonger中
					//输出最长子串
					System.out.println(subStr);
					return;
				}
			}
		}
		
		System.out.println("无子串");
	}
第二题的话,就是取这条线上的点然后把圆的圆心设置到这些点上,这个圆就顺着这条线移动了。

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧