【发布时间】:2017-05-21 09:08:20
【问题描述】:
public class LongestAlphabetDistance {
public int longDistance(String str, String a) {
str = "this is my greatest achievement in the world";
a = "i";
int count =0;
// code logic for longest difference
return count;
}
}
我想首先获得“这是我在世界上最伟大的成就”的距离
a = i 最后我喜欢t=1,h=2,i=3,s=4, 空格不应该比i=5,s=6,m=7,y=8,g=9 喜欢最后i "in" i=27 所以首先i=3 最后i=27 所以最长距离b/w 24 请写代码为此
【问题讨论】:
-
你能分享一下你到目前为止的尝试吗?
-
我们不是来帮你做作业的
-
SO 是为了提出问题而不是为了做你的工作!
-
@ControlAltDel 老实说,我什至不明白这个问题。程序应该只计算
String(减去空格)中的字符数量还是字符之间的距离?还有一个错字,应该是achievement。 -
作业与否,这对我来说似乎是一个代码编写请求,这在 Stack Overflow 上并不受欢迎。