我有一个Json文件,里边是一些节点,现在需要用这些节点构建成一棵树状结构,在父子关系不变的情况下,按照节点id从小到大排序。
这看起来很简单,一个递归就搞定了,嗯,可是我们不走寻常路。
能否不用递归的方式,写一段代码,语言不限,同样生成这棵树呐?
String json_url = "https://www.lanbeikeji.com/static/data/tree.json";
// 此处省略若干行
/**
* 请根据以下代码运行的结果发送您的代码和简历。
* @author Mr.Interview<Mr.Interview@lanbeikeji.com>
*/
public static void main( String[] args ) {
String origin = "hundred3s of soldierss diejd in this blo--ody battle.";
String result = "";
Pattern pattern = Pattern.compile("^(.).*?(.)(.)\\3.*?$");
Matcher matcher = pattern.matcher(origin);
while(matcher.find()){
int count = matcher.groupCount();
for(int i=1; i < count; i++){
result += matcher.group(i);
}
}
System.out.println(String.format("%1$s@lanbeikeji.com",result));
}
IT技术已经足够成熟,个人英雄主义的时代已经一去不返了。会沟通,爱沟通,简单说能听懂别人的意思,能讲明白自己的需求。
兴趣是最好的老师,如果你不喜欢这个工作,那绝对不会适应我们团队的氛围。真心喜欢IT技术,自助者天助!
精通最少一门编程语言,多多益善。不奢望全栈全能,但必须拥有一片自己的领地,这里,你就是权威!
轻松的工作人人都想要,但是它并没有什么好处。闲的时候不放纵自己,忙的时候绝不抱怨。
Copyright © 2022. 北京兰贝科技有限公司