微信事业群
时间:20190831 时长:1小时30分
地点:牛客远程视频
一分钟自我介绍
一、上手code
1、手写字符串的反转
我的code:
public String stringReserve(String inputString) {
int length = inputString.length();
if(inputString == null || length == 0) {
return null;
}
return reverse(inputString.toCharArray(), 0, length-1);
}
private String reverse(char[] str, int start, int end) {
while (start < end) {
char temp = str[start];
str[start++] = str[end];
str[end--] = temp;
}
return str.toString();
}
2、 手写双向链表
我的code:
public class LinkedList{
private Node root;
public class Node{
private Object data;
private Node preNode;
private Node next;
}
public Node getRoot(){
return this.root;
}
public void setRoot(Node root) {
this.root = root;
}
}
3、按照顺序合并两个链表,手写代码
我的code:
public Node merge(LinkedList first, LinkedList second) {
if(first == null && second == null) return null;
if (first != null && second == null) {
return first.getRoot();
}
if (first == null && second != null) {
return second.getRoot();
}
Node newNode;
Node temp;
Node temp1 = new Node();
Node temp2 = new Node();
if (first.getRoot().data < second.getRoot().data) {
newNode = fir