后端工程师-软件类OPPO-2023届校园招聘笔试题-后端(A卷)

编程题1 AC

image-20220902143028358

import java.util.Arrays;

public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param digits int整型一维数组
     * @return int整型
     */
    public int maxDigit (int[] digits) {
        // write code here
        Arrays.sort(digits);
        int ans = 0;
        for (int i = digits.length - 1; i >= 0; i--) {
            ans = ans * 10 + digits[i];
        }
        return ans;
    }
}

image-20220902143311338

编程题2AC

image-20220902144129304

import java.util.*;

/*
 * public class ListNode {
 *   int val;
 *   ListNode next = null;
 *   public ListNode(int val) {
 *     this.val = val;
 *   }
 * }
 */

public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param node1 ListNode类
     * @param node2 ListNode类
     * @return ListNode类
     */
    public ListNode combineTwoDisorderNodeToOrder (ListNode node1, ListNode node2) {
        // write code here
        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;
    }
}

image-20220902144204519

编程题3AC

image-20220902144154050

import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param scenicspot int整型 
     * @return long长整型
     */
    public long tourismRoutePlanning (int scenicspot) {
        // write code here
        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];
    }
}

image-20220902145055925
三道题的难度都很简单,不知道这个岗位是不是不招人了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值