Question d’entretien chez Amazon

Problem solving: 1. Given a no. Find next highest no. containing same digits. 2. Given a array and a value k. Find all unique pairs that sums up to k. 3. Anagram check. 4. Given a array, i, j. Find all nos. such that j > i and array[j] > array[i]. 5. Boolean matrix problem. make all the values in a row or column as '1' if there is at least one '1' in that row or column. 6. Given a array where consecutive digits differences out to particular set of values and no. 'k'. Find the index of 'k'. Use hashing. Scripting: 1. Given a log file containing req ID and time consumed. Find all req. IDs consuming time more than certain seconds. Red ID: xyz Time: 10 2. Given a file containing 'Stundent,Marks'. Sum the marks of students and display totals marks student wise. I/P: Stud1,20 Stud2,30 Stud1,10 Stud2,30 O/P: Stud1,30 Stud2,60

Réponses aux questions d'entretien

Utilisateur anonyme

4 mai 2017

Q2. Ans. python3 A = [1,4,45,6,10,-8] n = 16 for i in range(len(A)): for j in range(i+1,len(A)): a = int(A[i]) + int(A[j]) if ( a == n): print (A[i],A[j])

6

Utilisateur anonyme

4 mai 2017

Q2. ans. in c++ // Example program #include #include #include using namespace std; int main() { int A[] = {1, 4, 45, 6, 10, 8}; int n = 16; int i,j,m; m=(sizeof(A)/sizeof(A[0])); cout<

2

Utilisateur anonyme

4 mai 2017

Q3. ans in python str1='earth' str2='heart' l1 = list(str1) l2 = list(str2) matchfound=0 n=len(l1) m=len(l2) if ( n == m ): for i in l1: if i in l2: matchfound +=1 if ( n == matchfound ): print("{} and {} are anagrams".format(str1,str2)) else: print("{} and {} are not anagrams".format(str1,str2)) else: print("size differs no need to check")