Allowed R6 · Within policy
{
"slug": "two-lowest-sum",
"title": "Sum of Two Lowest Numbers",
"difficulty": "easy",
"tags": [
"coding",
"algorithms-theory",
"technical",
"swe"
],
"is_free": true,
"locked": false,
"frequency": 0.25,
"last_reported_at": "2025-09-13T21:14:12.225382Z",
"url": "https://www.mokabla.com/en/c/talabat/two-lowest-sum",
"agent": {
"page": "https://www.mokabla.com/agent/en/c/talabat/two-lowest-sum",
"question": "https://www.mokabla.com/agent/_call/get_question?company=talabat&question=two-lowest-sum"
},
"company": {
"slug": "talabat",
"name_en": "Talabat"
},
"body_md": "## What they ask\n\nGiven an unsorted array of at least two positive integers, return the sum of the two smallest values. The obvious answer is to sort; the interviewer then asks for a single pass.\n\nIn the same session they typically add a sibling problem: **move all zeros to the left** of the array while keeping the order of the non-zero elements.\n\n## Examples\n\n- `[19, 5, 42, 2, 77]` returns `7`.\n- `[10, 343445353, 3453445, 3453545353453]` returns `3453455`.\n- `[3, 3, 1]` returns `4` (duplicates allowed).\n\nZeros variant: `[1, 0, 2, 0, 3]` becomes `[0, 0, 1, 2, 3]`.\n\n## Constraints\n\n- `2 <= n <= 10^5`, values fit in 64-bit integers.\n- Target O(n) time and O(1) extra space.\n\n## What they look for\n\n- Tracking `min1` and `min2` correctly when a new value is smaller than `min1` (the old `min1` must slide to `min2`).\n- Tests for duplicates and for the minimum appearing last.\n- For the zeros variant, a two-pointer in-place solution rather than building two arrays.",
"follow_ups_md": "- Generalize to the k smallest values in O(n log k).\n- Do the zeros variant in place while preserving order.",
"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."
}