## 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))``````

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]);
}

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);
}

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))

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);

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;
}

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;
}

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;
}

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;
}

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

static public void sorting(int[] arr, int [] arr1){
Stream<Integer> arrStream = Arrays.stream(arr).boxed();
Stream<Integer> arr1Stream = Arrays.stream(arr1).boxed();
List<Integer> newArr = Stream.concat(arrStream,arr1Stream)
.sorted()
.collect(Collectors.toList());
newArr.forEach(System.out::print);
}

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.

### 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.