Interview Question for SDETs


Country: India
Interview Type: In-Person




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

array.sort();

- Akshay August 07, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

public int[] moveSmallNumbersToStartAndBigNumbersToEnd(int[] array) {
    return sort(array);

}

When do I start?

- helloru August 07, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

lmfao

- Anonymous August 07, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class ArraySortingExample {

	/**
	 * Given an array of numbers, move small numbers to start and big numbers to
	 * end of array
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int array[] = { 25, 3, 14, 1 };
		for (int i = 0; i < array.length; i++) {
			for (int j = i + 1; j < array.length; j++) {
				if (array[i] > array[j]) {
					int temp = array[i];
					array[i] = array[j];
					array[j] = temp;
				}
			}
			System.out.print(array[i] + " ");
		}
	}
}

- Ravi August 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Пузырьковая сортировка. Сложнааааааа...
The "bubble sort". Too hardddddd XD

- Васян August 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//#include<iostream>
//using namespace std;
//
////two numbers m and n(1 <= m <= n <= 1000000000, n - m <= 100000) separated by a space.
////
////p such that m <= p <= n, one number per line, test cases separated by an empty line.
//
//bool isPrime(int number)
//{
//	for (int i = 2; i <= ceil(sqrt(number)); i++)
//	{
//		if (number%i != 0)
//		{
//			return false;
//		}
//	}
//	return true;
//}
//int main()
//{
//	int numberOfCases, m, n;
//	numberOfCases = m = n = 0;
//
//	cin >> numberOfCases;
//
//	while (numberOfCases--)
//	{
//		cin >> m;
//		cin >> n;
//
//		for (int i = m; i<n; i++)
//		{
//			if (isPrime(i) == true)
//				cout << i << " ";
//		}
//		cout << "\n\n";
//	}
//
//	return 0;
//}

#include<iostream>
#include<algorithm>
#include<array>

int main()
{
	std::array<int,10> arr = {1,7,4,62,9,25,54,89,31,3};
	
	std::sort(arr.begin(), arr.end());
	
	for (int i = 0; i < 10; i++)
	{
		std::cout << arr[i] << " ";
	}

	return 0;
}

- undefined August 08, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

var arr=[23,58,12,44];


for(var i=0; i<arr.length; i++)
{
for(var j=i+1; j<arr.length; j++)
{
if(arr[j]<arr[i])
{
var tmp=arr[i];

arr[i]=arr[j];
arr[j]=tmp;
}
}
}
console.log(arr)

- vijaykanth August 10, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

var arr=[23,58,12,44];


for(var i=0; i<arr.length; i++)
{
for(var j=i+1; j<arr.length; j++)
{
if(arr[j]<arr[i])
{
var tmp=arr[i];

arr[i]=arr[j];
arr[j]=tmp;
}
}
}
console.log(arr)

- vijaykanth August 10, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

lol, I like 2 answers from above, array.sort() and LMFAO
array.sort() can have O(n log n) time
But if we just find min and max of the list it can be found in O (n)

remove them from the list and insert them at first and the last position respectively

def doWhatever(arglist):
    
    min = (0, arglist[0])
    max = (0, arglist[0])
    for i in range(1,len(arglist)):
        
        if arglist[i] < min[1]:
            min = (i, arglist[i])

        if arglist[i] > max[1]:
            max = (i, arglist[i])


    del arglist[min[0]]
    del arglist[max[0]]
    
    arglist.insert(0, min[1])
    arglist.append(max[1])
    
    return arglist

- nil12285 August 14, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
main()
{
int a[10],i,j,n,temp;
printf("\n enter array size ");
scanf("%d",&n);
printf("Enter %d numbers\n",n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i])
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
printf("%d\n",a[i]);
}
return 0;
}

- Sameer_shaik September 25, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def k_least_num():

a1 = input().split(',')
a2 = input().split(',')

k = int(input())
s = []

while len(s)<k:
if (int(a1[0]) < int(a2[0])):
if a1[0] not in s:
s.append(a1[0])
del a1[0]
else:
del a1[0]
else:
if a2[0] not in s:
s.append(a2[0])
del a2[0]
else:
del a2[0]
print("final unique least K numbers list-",s)

- Anonymous September 28, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def k_least_num():

a1 = input().split(',')
a2 = input().split(',')

k = int(input())
s = []

while len(s)<k:
if (int(a1[0]) < int(a2[0])):
if a1[0] not in s:
s.append(a1[0])
del a1[0]
else:
del a1[0]
else:
if a2[0] not in s:
s.append(a2[0])
del a2[0]
else:
del a2[0]
print("final unique least K numbers list-",s)

- mohsum September 28, 2018 | Flag Reply


Add a Comment
Name:

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

Books

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

Videos

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