快手java一面

  1. 问项目

  2. SQL28 每个供应商成本最低的产品 的变形题,求最高

  3. NC2 重排链表

sql语句和题都没写出来😥,现记录改后的答案:

  • sql部分:
SELECT
  vend_id,
  MIN(prod_price) AS cheapest_item
FROM
  Products
GROUP BY
  vend_id
ORDER BY
  cheapest_item ASC;
  • 重排链表
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public void reorderList(ListNode head) {
        if (head == null || head.next == null) return;

        // 找链表中点
        ListNode slow = head, fast = head;
        while (fast.next != null && fast.next.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }

        // 反转后半段链表
        ListNode secondList = slow.next;
        secondList = reverseList(secondList);
        slow.next = null;// 注意此处需要清空,使得head只有前半段,second只有后半段,否则后续连接会陷入死循环

        // 依次连接链表(插入节点)
        ListNode cur = head;
        while (secondList != null && cur != null) {
            // 记录分别的next节点防丢失
            ListNode firstListNext = cur.next;
            ListNode secondListNext = secondList.next;

            // 向cur插入secondList
            cur.next = secondList;
            secondList.next = firstListNext;

            // 重置cur和secondList
            cur = firstListNext;
            secondList = secondListNext;
        }
    }

    public ListNode reverseList(ListNode head) {
        if (head == null) return null;

        ListNode pre = null, cur = head, con = head.next;
        while (con != null) {
            cur.next = pre;
            pre = cur;
            cur = con;
            con = cur.next;
        }
        cur.next = pre;
        return cur;
    }
}
#面试复盘##春招##快手#
全部评论
快手现在还有春招面试呀 😂
点赞 回复 分享
发布于 2022-05-13 14:23
我貌似也在牛客上看到过类似的题
点赞 回复 分享
发布于 2022-05-13 12:58

相关推荐

不愿透露姓名的神秘牛友
07-08 12:10
点赞 评论 收藏
分享
06-15 02:05
已编辑
南昌航空大学 数据分析师
Eason三木:你如果想干技术岗,那几个发公众号合唱比赛的经历就去掉,优秀团员去掉,求职没用。然后CET4这种不是奖项,是技能,放到下面的专业技能里或者单独列一个英语能力。 另外好好改改你的排版,首行缩进完全没有必要,行间距好好调调,别让字和标题背景黏在一起,你下面说能做高质量PPT你得展现出来啊,你这简历排版我用PPT做的都能比你做的好。 然后自我评价,你如果要干数据工程师,抗压能力强最起码得有吧。
简历中的项目经历要怎么写
点赞 评论 收藏
分享
嵐jlu:我是山川🐔里🐔🧱的,阿里系简历全过; 你这简历一看就还是半成品啊,没有荣誉经历奖项什么的吗?
投递阿里巴巴集团等公司10个岗位
点赞 评论 收藏
分享
这是什么操作什么意思,这公司我服了...
斯派克spark:意思是有比你更便宜的牛马了
点赞 评论 收藏
分享
评论
3
6
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务