Citigroup Interview Question for Solutions Architects


Country: India
Interview Type: Written Test




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

arr1 = [0,1,2,3, 4,5,6,7]
arr2 = [-1, 0,1,2,3]
arr = []
def mysort(arr1, arr2):
    i = 0
    j = 0
    while i < len(arr1) or j < len(arr2):
        if i < len(arr1) and j < len(arr2):
            if arr1[i] < arr2[j]:
                arr.append(arr1[i])
                i += 1
            elif arr2[i] < arr1[j]:
                arr.append(arr2[j])
                j += 1
            elif arr1[i] == arr2[j]:
                arr.append(arr1[i])
                arr.append(arr2[j])
                i += 1
                j += 1
        elif i < len(arr1):
            arr.append(arr1[i])
            i += 1
        elif j < len(arr2):
            arr.append(arr2[j])
            j += 1

    return arr

print(mysort(arr1, arr2))

- rasmiranjanbabu July 12, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

int [] arr=new int[]{0, 1, 3, 5, 1, 2, 3, 4 };
Arrays.sort(arr);
for(int i=0;i<arr.length;i++){
System.out.print(arr[i]);
}

- smilewang123 July 13, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<bits/stdc++.h>
using namespace std;
int main()
{
int arr[n];
sort(arr,arr+n);
}

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

arr1 = [0,1,2,3, 4,5,6,7]
arr2 = [-1, 0,1,2,3]
arr = []
def mysort(arr1, arr2):
i = 0
j = 0
while i < len(arr1) or j < len(arr2):
if i < len(arr1) and j < len(arr2):
if arr1[i] < arr2[j]:
arr.append(arr1[i])
i += 1
elif arr2[i] < arr1[j]:
arr.append(arr2[j])
j += 1
elif arr1[i] == arr2[j]:
arr.append(arr1[i])
arr.append(arr2[j])
i += 1
j += 1
elif i < len(arr1):
arr.append(arr1[i])
i += 1
elif j < len(arr2):
arr.append(arr2[j])
j += 1

return arr

print(mysort(arr1, arr2))

- Anonymous February 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

final int a1[] = {0,1,3,5};
final int a2[] = {1,2,3,4};
int[] a = new int[a1.length + a2.length];
System.arraycopy(a1, 0, a, 0, a1.length);
System.arraycopy(a2, 0, a, a1.length, a2.length);
Arrays.sort(a);

- Vikram - 9903380767 July 27, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include <bits/stdc++.h>
using namespace std;

int main(){
int n, m;
cin >> n >> m;
int a[n], b[m];

for(int i=0; i<n; i++){
cin >> a[i];
}

for(int i=0; i<m; i++){
cin >> b[i];
}

int c[n+m];
int i = 0, j = 0, k = 0;

while(i < n+m){
if(j<n && k<m && a[j] < b[k]){
c[i] = a[j];
i++;
j++;
}
else if(j<n && k<m && a[j] >= b[k]){
c[i] = b[k];
i++;
k++;
}
else if(j==n-1 && k<m-1){
c[i] = b[k];
k++;
i++;
}
else{
c[i] = a[j];
j++;
i++;
}
}
for(int i=0; i<n+m; i++){
cout << c[i] << " ";
}
cout << endl;
return 0;
}

- iit2016040@iiita.ac.in August 01, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public int[] sort(int[] a, int[] b) {
int len = (a.length + b.length);
int[] result = new int[len];

for (int i = 0; i < a.length; i++) {
result[i] = a[i];
}

for (int j = 0; j < b.length; j++) {
result[a.length + j] = b[j];
}

Arrays.sort(result);

return result;
}

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

public int[] sort(int[] a, int[] b) {
int len = (a.length + b.length);
int[] result = new int[len];

for (int i = 0; i < a.length; i++) {
result[i] = a[i];
}

for (int j = 0; j < b.length; j++) {
result[a.length + j] = b[j];
}

for (int m = 0; m < (len - 1); m++) {
for (int k = 0; k < (len - 1); k++) {
if (result[k + 1] < result[k]) {
int tmp = result[k];
result[k] = result[k + 1];
result[k + 1] = tmp;
}
}
}

return result;
}

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

public int[] sort(int[] a, int[] b) {
int len = (a.length + b.length);
int[] result = new int[len];

for (int i = 0; i < a.length; i++) {
result[i] = a[i];
}

for (int j = 0; j < b.length; j++) {
result[a.length + j] = b[j];
}

for (int m = 0; m < (len - 1); m++) {
for (int k = 0; k < (len - 1 - m); k++) {
if (result[k + 1] < result[k]) {
int tmp = result[k + 1];
result[k + 1] = result[k];
result[k] = tmp;
}
}
}

return result;
}

- Anonymous September 25, 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