Fundamentals 9 min read

Tencent 2024 Campus Recruitment Salary Overview and Reverse Nodes in k‑Group Java Solution

The article first presents a detailed analysis of Tencent's 2024 campus recruitment salary packages for various programmer offers, then introduces a classic algorithmic challenge of reversing a linked list in groups of k nodes, providing step‑by‑step explanation and a complete Java implementation.

IT Services Circle
IT Services Circle
IT Services Circle
Tencent 2024 Campus Recruitment Salary Overview and Reverse Nodes in k‑Group Java Solution

In 2024, Tencent's campus recruitment reaffirmed its leading position in China's internet industry, offering several salary packages for programmer positions:

Ordinary Offer : Monthly salary 19k‑22k, annual total 350k‑430k (salary ×16 + 4k monthly housing allowance + optional 30k signing bonus).

SP Offer : Monthly salary 23k‑24k, annual total 440k‑490k (includes 6k stock over 2 years).

SSP Offer : Monthly salary 26k‑29k, annual total 500k‑610k (includes 5k signing bonus and 6k‑10k stock over 2 years).

Tencent Technical Elite Program : For outstanding PhDs, total package can exceed 1,000k.

After the salary overview, the article presents a high‑frequency interview question: reverse a linked list in groups of k nodes.

Given a linked list, reverse every k nodes. If the number of nodes is not a multiple of k , leave the remaining nodes as they are.

The solution uses a dummy node to simplify edge handling and iteratively processes each group:

Set up a dummy node whose next points to the head.

Maintain pre (node before the current group) and end (node at the end of the current group).

Move end forward k steps; if end becomes null , the remaining nodes are left unchanged.

Detach the group, reverse it with a recursive reverse function, and reconnect the reversed segment.

Update pre and end for the next iteration.

The recursive reverse function flips a sub‑list by reaching the tail and then rewiring the next pointers on the way back.

class Solution {
    public ListNode reverseKGroup(ListNode head, int k) {
        // Create a dummy node whose value is irrelevant
        ListNode dummy = new ListNode(-1);
        dummy.next = head;
        ListNode pre = dummy;
        ListNode end = dummy;
        while (end.next != null) {
            // Move end k steps forward to locate the group tail
            for (int i = 0; i < k && end != null; i++) {
                end = end.next;
            }
            if (end == null) {
                break; // Not enough nodes for a full group
            }
            ListNode next = end.next; // Node after the group
            end.next = null; // Detach the group
            ListNode start = pre.next; // First node of the group
            pre.next = null; // Temporarily break connection
            // Reverse the group
            pre.next = reverse(start);
            // Connect the reversed group with the rest of the list
            start.next = next;
            // Move pre and end to the next group start
            pre = start;
            end = start;
        }
        return dummy.next;
    }

    // Recursive function to reverse a linked list
    private ListNode reverse(ListNode head) {
        if (head == null || head.next == null) return head;
        ListNode cur = reverse(head.next);
        head.next.next = head;
        head.next = null;
        return cur;
    }
}

This approach efficiently reverses every k nodes while preserving the order of any leftover nodes, demonstrating key linked‑list manipulation techniques useful for technical interviews.

Javaalgorithmdata-structuresLinked Listinterview question
IT Services Circle
Written by

IT Services Circle

Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.