Allowed R6 · Within policy
{
"slug": "reverse-list-in-place",
"title": "Reverse List In Place",
"difficulty": "easy",
"tags": [
"coding",
"phone",
"swe",
"intern"
],
"is_free": true,
"locked": false,
"frequency": 1,
"last_reported_at": "2026-06-10T13:54:57.792416Z",
"url": "https://www.mokabla.com/en/c/siemens/reverse-list-in-place",
"agent": {
"page": "https://www.mokabla.com/agent/en/c/siemens/reverse-list-in-place",
"question": "https://www.mokabla.com/agent/_call/get_question?company=siemens&question=reverse-list-in-place"
},
"company": {
"slug": "siemens",
"name_en": "Siemens (EDA / Digital Industries)"
},
"body_md": "## Problem\nReverse a singly linked list in place and return the new head. No extra list, no array copy; only pointer rewiring. Then do the same for every group of `k` nodes.\n\nIt is a warm-up, but I use it to see how you handle pointers under a little pressure and whether you test your own code before I do.\n\n## Examples\n**Example 1**, `1 -> 2 -> 3 -> 4 -> null` → `4 -> 3 -> 2 -> 1 -> null`\n\n**Example 2**, `k = 2` on `1 -> 2 -> 3 -> 4 -> 5` → `2 -> 1 -> 4 -> 3 -> 5`\nThe leftover group (size < k) stays as is.\n\n**Edge**, empty list → empty; single node → itself.\n\n## Constraints\n- `0 <= n <= 10^5` nodes.\n- `O(n)` time, `O(1)` extra space for the basic version. The recursive version is allowed only if you explain stack depth.\n- For the `k`-group variant, `1 <= k <= n`.\n\n## What they look for\nThe three-pointer walk (`prev`, `cur`, `next`) written without a bug on the first try, and drawing it on paper before typing. For `k` groups: counting ahead to check the group is full, reversing it, and reconnecting the tail of the previous group. In C, I also ask what happens if you forget to `NULL` the old head's `next`.",
"follow_ups_md": "- Reverse in groups of `k`.\n- Reverse only the sub-list between positions `m` and `n`.\n- Detect a cycle before reversing; what would happen if there is one?",
"access": "Question bodies are paid content: a person buys 30 days of access per company (200 EGP or 200 points) in the human app. Agents get titles, tags and difficulty; bodies only for free questions."
}