Sde Interview Questions

16,648 sde interview questions shared by candidates

1. Given an array of seats, return the maximum number of new people which can be seated, as long as there is at least a gap of 2 seats between people.Empty seats are given as 0.Occupied seats are given as 1.Don't move any seats which are already occupied, even if they are less than 2 seats apart. Consider only the gaps between new seats and existing seats.ExamplesmaximumSeating([0, 0, 0, 1, 0, 0, 1, 0, 0, 0]) ➞ 2// [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]maximumSeating([0, 0, 0, 0]) ➞ 2// [1, 0, 0, 1]maximumSeating([1, 0, 0, 0, 0, 1]) ➞ 0// There is no way to have a gap of at least 2 chairs when adding someone else.NotesNotice how there may be several possibilities for assigning seats to people, but these cases won't affect the results.All seats will be valid. 2. A binary string is a string consisting only of 0s and 1s. A substring is a contiguous group of characters within a string. Given a binary string, find the number of substrings that contain an equal number of 0s and 1s and all the 0s and 1s are grouped together. Note that duplicate substrings are also counted in the answer. For example, '0011' has two overlapping substrings that meet the criteria: '0011' and '01'. Examples = "011001" The substrings "01", "10", "1100", and "01" have equal numbers of 0s and 1s with all 0s and 1s grouped consecutively. Hence, the answer is 4. Note that the substring "0110" has an equal number of 0s and 1s but is not counted because not all 0s and 1s are grouped together. Function DescriptionComplete the function getSubstringCount in the editor below. getSubstringCount has the following parameter(s): s: a binary string Returns int: the number of substrings that meet the criteria Constraints1 ≤ length of s ≤ 105The string s consists of 0s and 1s only.Input Format For Custom TestingSample Case 0Sample Input For Custom Testing001100011Sample Output6ExplanationThe substrings "01", "0011", "10", "1100", "01" and "0011" have an equal number of 0s and 1s with consecutive groupings.Sample Case 1
avatar

Software Development Engineer (SDE)

Interviewed at MountBlue Technologies

3.8
Aug 18, 2023

1. Given an array of seats, return the maximum number of new people which can be seated, as long as there is at least a gap of 2 seats between people.Empty seats are given as 0.Occupied seats are given as 1.Don't move any seats which are already occupied, even if they are less than 2 seats apart. Consider only the gaps between new seats and existing seats.ExamplesmaximumSeating([0, 0, 0, 1, 0, 0, 1, 0, 0, 0]) ➞ 2// [1, 0, 0, 1, 0, 0, 1, 0, 0, 1]maximumSeating([0, 0, 0, 0]) ➞ 2// [1, 0, 0, 1]maximumSeating([1, 0, 0, 0, 0, 1]) ➞ 0// There is no way to have a gap of at least 2 chairs when adding someone else.NotesNotice how there may be several possibilities for assigning seats to people, but these cases won't affect the results.All seats will be valid. 2. A binary string is a string consisting only of 0s and 1s. A substring is a contiguous group of characters within a string. Given a binary string, find the number of substrings that contain an equal number of 0s and 1s and all the 0s and 1s are grouped together. Note that duplicate substrings are also counted in the answer. For example, '0011' has two overlapping substrings that meet the criteria: '0011' and '01'. Examples = "011001" The substrings "01", "10", "1100", and "01" have equal numbers of 0s and 1s with all 0s and 1s grouped consecutively. Hence, the answer is 4. Note that the substring "0110" has an equal number of 0s and 1s but is not counted because not all 0s and 1s are grouped together. Function DescriptionComplete the function getSubstringCount in the editor below. getSubstringCount has the following parameter(s): s: a binary string Returns int: the number of substrings that meet the criteria Constraints1 ≤ length of s ≤ 105The string s consists of 0s and 1s only.Input Format For Custom TestingSample Case 0Sample Input For Custom Testing001100011Sample Output6ExplanationThe substrings "01", "0011", "10", "1100", "01" and "0011" have an equal number of 0s and 1s with consecutive groupings.Sample Case 1

Q2: Rearrange the string of given words according to indices contained inside the words. EG: "God5 t2he 1For lov3e o4f" -> "For the love of God" The indices are attached with the word but can be given at any position in the word.
avatar

Software Development Engineer (SDE)

Interviewed at MountBlue Technologies

3.8
May 26, 2024

Q2: Rearrange the string of given words according to indices contained inside the words. EG: "God5 t2he 1For lov3e o4f" -> "For the love of God" The indices are attached with the word but can be given at any position in the word.

Viewing 2181 - 2190 interview questions

Glassdoor has 16,648 interview questions and reports from Sde interviews. Prepare for your interview. Get hired. Love your job.