Stripe Interview Question for Software Engineers

Country: United States

Comment hidden because of low score. Click to expand.
of 0 vote

int NextServerNumber(int[] serversTaken){
	int max = 0;
	HashSet<int> possibles = new HashSet<int>();
	foreach (int currentServer in serversTaken){
		if (currentServer > max){
			//we add from max to the current
			for(int i = max + 1; i < currentServer; i++){
				//add as a possible
			max = currentServer;
		if (possibles.Contains(currentServer))
	if(possibles.Count > 0)
		return possibles[0];
	return max+1;

- Diego August 01, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

This question is asking the first missing positive integer from the list of n integers. (Total n-1 integers given and return value should be an integer missing (m) from this list. So, it is implied that 1<=m<=n.

using namespace std;

  int missingInt(vector<int> v) {
	int cnt=0, tmp=v[0],n=v.size(),i=0;
	while(cnt<=n) {
			if(v[i] != i+1 && v[i]<=n) {
				tmp = v[v[i]-1];
				v[v[i]-1] = v[i];
			else i++;
	int j=0;
	for( j=0;j<n;++j)
		if(v[j]!=j+1) return j+1;
	return j+1;

int main() {
	vector<int> v = {4,1,5,3}; // Don't sort it. Otherwise it will be n log(n).
	int ret = missingInt(v);
	return 0;

- alanturing06022014 August 03, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

We traverse the array containing all positive numbers and to mark presence of an element x, we change the sign of value at index x to negative. We traverse the array again and print the first index which has positive value. In the following code, findMissingPositive() function does this part. Note that in findMissingPositive, we have subtracted 1 from the values as indexes start from 0 in C.

/* Find the smallest positive missing number  
in an array that contains all positive integers */
int findMissingPositive(int arr[], int size)  
    int i;  
    // Mark arr[i] as visited by making arr[arr[i] - 1] negative.  
    // Note that 1 is subtracted because index start  
    // from 0 and positive numbers start from 1  
    for(i = 0; i < size; i++)  
        if(abs(arr[i]) - 1 < size && arr[ abs(arr[i]) - 1] > 0)  
        arr[ abs(arr[i]) - 1] = -arr[ abs(arr[i]) - 1];  
    // Return the first index value at which is positive  
    for(i = 0; i < size; i++)  
        if (arr[i] > 0)  
            // 1 is added because indexes start from 0  
            return i+1;  
    return size+1;  

- Nits August 16, 2019 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More


CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More