oppo后端开发A卷笔试题记录,三道编程大题,难度都比较简单,最后一道题直接就是leetcode的原题-青蛙跳台阶
不知道是不是不招人,虽说收到了笔试
后端工程师-软件类OPPO-2023届校园招聘笔试题-后端(A卷)
编程题1 ==AC==
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| import java.util.Arrays;
public class Solution {
public int maxDigit (int[] digits) { Arrays.sort(digits); int ans = 0; for (int i = digits.length - 1; i >= 0; i--) { ans = ans * 10 + digits[i]; } return ans; } }
|
编程题2==AC==
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| import java.util.*;
public class Solution {
public ListNode combineTwoDisorderNodeToOrder (ListNode node1, ListNode node2) { List<ListNode> lists = new ArrayList<>(); getListNodeToLists(node1, lists); getListNodeToLists(node2, lists); lists.sort((ListNode a, ListNode b) -> { return a.val - b.val; }); return getSortListNode(lists); }
public void getListNodeToLists(ListNode head, List<ListNode> lists) { while(head != null) { ListNode next = head.next; head.next = null; lists.add(head); head = next; } }
public ListNode getSortListNode(List<ListNode> lists) { ListNode head = new ListNode(0); ListNode cur = head; for (int i = 0; i < lists.size(); i++) { cur.next = lists.get(i); cur = cur.next; } return head.next; } }
|
编程题3==AC==
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import java.util.*;
public class Solution {
public long tourismRoutePlanning (int scenicspot) { if (scenicspot == 1) return 1L; if (scenicspot == 2) return 2L; long[] dp = new long[scenicspot]; dp[0] = 1L; dp[1] = 2L; for (int i = 2; i < scenicspot; i++) dp[i] = dp[i-1] + dp[i-2]; return dp[scenicspot - 1]; } }
|