好未来2021/8/8
第一部分
选择题20道,挺简单的,但是Linux我不太会
第二部分
更简单了啊?????????
第一题,合并两链表
/**
* @author keboom
* @date 2021/8/8
*/
public class Solution1 {
public class ListNode {
int val;
ListNode next = null;
public ListNode(int val) {
this.val = val;
}
}
public ListNode merge(ListNode head1, ListNode head2) {
if (head1 == null) {
return head2;
}
if (head2 == null) {
return head1;
}
if (head1.val < head2.val) {
head1.next = merge(head1.next, head2);
return head1;
} else {
head2.next = merge(head1, head2.next);
return head2;
}
} 第二题,也是力扣原题啊
给你个字符串,循环左移k后,输出新的字符串
"abcXYZdef",3 "XYZdefabc"
/**
* @author keboom
* @date 2021/8/8
*/
public class Solution2 {
public String edit_string (String str, int k) {
int len = str.length();
k = k % len;
String s1 = str.substring(0, k);
String s2 = str.substring(k, len);
return s2+s1;
} #好未来##笔经#
文远知行公司福利 523人发布
查看7道真题和解析