Nexla Interview Experience | SDE - 1 | (0-2 yrs Experience)
Summary
I recently interviewed at Nexla for an SDE-1 position. The process involved four rounds, but I only completed the first DSA round, which featured a difficult binary string manipulation problem.
Full Experience
Recently, I had the opportunity to interview at Nexla. The process consisted of four rounds, but I wasn’t able to progress beyond the first round. Sharing the question here in case it helps others preparing for similar interviews.
Round 1: DSA Round
HR mentioned that the interview would include a medium-to-hard problem, but based on the constraints, it seemed like a hard level problem.
Question 1
You are given a binary string (consisting of 0s and 1s) that represents a number. It takes 2 points to toggle any bit, and it takes 1 point to swap any two positions in the string.
To maximize the number, it is always beneficial to prioritize making the most significant bits as large as possible (i.e., turning earlier 0's into 1's). A swap (cost 1) can move an existing 1 from later in the string to an earlier position (but it also moves a 0 to the later position), while a toggle (cost 2) directly changes a bit without affecting other positions. In many cases, swapping is the cheapest way to bring 1s forward, and any remaining budget can be used to toggle additional bits when swaps are no longer sufficient.
Your task is to create the largest possible number with a budget of point_budget points.
Sample Input { "binary_string": "100", "point_budget": 2, } "Output" : "110"{ "binary_string" = "000011", "point_budget": 3 }
"Output" : "110010"
Constraints: 1 <= binary_string.length <= 10^6 1 <= point_budget <= 10^9
Interview Questions (1)
Maximize Binary Number with Budgeted Swaps and Toggles
You are given a binary string (consisting of 0s and 1s) that represents a number. It takes 2 points to toggle any bit, and it takes 1 point to swap any two positions in the string.
To maximize the number, it is always beneficial to prioritize making the most significant bits as large as possible (i.e., turning earlier 0's into 1's). A swap (cost 1) can move an existing 1 from later in the string to an earlier position (but it also moves a 0 to the later position), while a toggle (cost 2) directly changes a bit without affecting other positions. In many cases, swapping is the cheapest way to bring 1s forward, and any remaining budget can be used to toggle additional bits when swaps are no longer sufficient.
Your task is to create the largest possible number with a budget of point_budget points.
Sample Input { "binary_string": "100", "point_budget": 2, } "Output" : "110"{ "binary_string" = "000011", "point_budget": 3 }
"Output" : "110010"
Constraints: 1 <= binary_string.length <= 10^6 1 <= point_budget <= 10^9