What Interviewers Want | Question #3 | Index-based Array Comparison

  1. I don’t like taking interviews because it takes away from my time
  2. I don’t like to judge them because I judge them in real life all the time
  3. I don’t like rejecting people because rejection is never easy, irrespective of whether you are at the receiving end or rejecting end of it.
  4. I’m just lazy. PERIOD.

All said and done, I’m forced to take interviews at least once in a day. For the past 2+ years of lockdown (the period when we got the awesome Work From Home), our panel of interviewers is bombarded with interview schedules. We take interviews on the week days with an assumption that we would compensate the work of the lost interview time. Since this isn’t enough of a torture, the superiors (management and HR combined) asks us to conduct a weekend drive. A weekend drive is essentially wasting your Saturday to interview people that you aren’t going to hire.

You see how painful that is?

It doesn’t help that the candidates we interview are mostly garbage, and I’m being polite here.

What Interviewers Want, really?

After years of frustration, I think it’s time to part some wisdom here. After interviewing tons of people, I think I should now write a series of blog posts of what exactly I look for in a candidate.

Today is my unofficial first job anniversary. It was Friday August 12, 20XY when I joined my first company, and that’s why I’m starting this series today. Smart and thoughtful, I told you.

As for the title, it mimics What Women Want. I’m such a smarty-pant. You will see this often.

This series couldn’t fit in my already cluttered website The Other Me Unfolded, hence I’m using this new blog to share the same.

Alright, without much further ado, let’s get started.

PS: As I write this, I have 12 open positions for Java/Full Stack developers. If you’re interested and confident that you can be a good addition to my team, drop me a note. I would be more than happy to recommend your CV (and earn a referral bonus).

Q3: Index-based Array Comparison

Given two unequal size integer array, write a program to output index-base comparison to return an array containing maximum of the two arrays.


a = [10,2,3,4,55]
b = [3, 5,6,8,23,56]

out = [10,5,6,8,55,56]

What Interviewer Wants

  1. The catch here is the the arrays are of unequal size.
  2. The size of output array: it should be the bigger of the two arrays
  3. # of iterations
  4. Assigning the remaining elements to output
/**
 * 
 * Given two unequal size integer array, write a program to output index-base
 * comparison to return an array containing maximum of the two arrays.
 * 
 * 
 * a = [10,2,3,4,55] b = [3, 5,6,8,23,56]
 * 
 * out = [10,5,6,8,55,56]
 * 
 * @author Shabana Mukhtar
 *
 */

public class Question3 {

	public static void main(String[] args) {
		Question3 q = new Question3();
		int[] a = { 10, 2, 3, 4, 55 };
		int[] b = { 3, 5, 6, 8, 23, 56 };

		int[] outputArray = q.compareArray(a, b);
		for (int i : outputArray) {
			System.out.println(i);
		}
	}

	private int[] compareArray(int a[], int b[]) {
		int[] smallerArray = a.length > b.length ? b : a;
		int[] biggerArray = b.length > a.length ? b : a;

		int[] out = new int[biggerArray.length];
		int i = 0;
		for (; i < smallerArray.length; i++) {
			if (a[i] > b[i]) {
				out[i] = a[i];
			} else {
				out[i] = b[i];
			}
		}

		// for the remaining elements, if any
		for (; i < biggerArray.length; i++) {
			out[i] = biggerArray[i];
		}
		return out;
	}
}

When you run the program, you will get output as below:

Output:
10
5
6
8
55
56

Shabana Mukhtar 

 

If you have read my post, you might already be aware of the reason of this post. You can scrolldown and read the real question. If not, be my guest and read through these words of wisdom (and frustration).

Interviews Suck

Being a Senior Software Specialist, taking interviews is part of my work profile. And, this is also one of the most hated parts of my job. The reasons are three-fold.

  1. I don’t like taking interviews because it takes away from my time
  2. I don’t like to judge them because I judge them in real life all the time
  3. I don’t like rejecting people because rejection is never easy, irrespective of whether you are at the receiving end or rejecting end of it.
  4. I’m just lazy. PERIOD.

All said and done, I’m forced to take interviews at least once in a day. For the past 2+ years of lockdown (the period when we got the awesome Work From Home), our panel of interviewers is bombarded with interview schedules. We take interviews on the week days with an assumption that we would compensate the work of the lost interview time. Since this isn’t enough of a torture, the superiors (management and HR combined) asks us to conduct a weekend drive. A weekend drive is essentially wasting your Saturday to interview people that you aren’t going to hire.

You see how painful that is?

It doesn’t help that the candidates we interview are mostly garbage, and I’m being polite here.

What Interviewers Want, really?

After years of frustration, I think it’s time to part some wisdom here. After interviewing tons of people, I think I should now write a series of blog posts of what exactly I look for in a candidate.

Today is my unofficial first job anniversary. It was Friday August 12, 20XY when I joined my first company, and that’s why I’m starting this series today. Smart and thoughtful, I told you.

As for the title, it mimics What Women Want. I’m such a smarty-pant. You will see this often.

This series couldn’t fit in my already cluttered website The Other Me Unfolded, hence I’m using this new blog to share the same.

Alright, without much further ado, let’s get started.

PS: As I write this, I have 12 open positions for Java/Full Stack developers. If you’re interested and confident that you can be a good addition to my team, drop me a note. I would be more than happy to recommend your CV (and earn a referral bonus).

Q3: Index-based Array Comparison

Given two unequal size integer array, write a program to output index-base comparison to return an array containing maximum of the two arrays.


a = [10,2,3,4,55]
b = [3, 5,6,8,23,56]

out = [10,5,6,8,55,56]

What Interviewer Wants

  1. The catch here is the the arrays are of unequal size.
  2. The size of output array: it should be the bigger of the two arrays
  3. # of iterations
  4. Assigning the remaining elements to output
/**
 * 
 * Given two unequal size integer array, write a program to output index-base
 * comparison to return an array containing maximum of the two arrays.
 * 
 * 
 * a = [10,2,3,4,55] b = [3, 5,6,8,23,56]
 * 
 * out = [10,5,6,8,55,56]
 * 
 * @author Shabana Mukhtar
 *
 */

public class Question3 {

	public static void main(String[] args) {
		Question3 q = new Question3();
		int[] a = { 10, 2, 3, 4, 55 };
		int[] b = { 3, 5, 6, 8, 23, 56 };

		int[] outputArray = q.compareArray(a, b);
		for (int i : outputArray) {
			System.out.println(i);
		}
	}

	private int[] compareArray(int a[], int b[]) {
		int[] smallerArray = a.length > b.length ? b : a;
		int[] biggerArray = b.length > a.length ? b : a;

		int[] out = new int[biggerArray.length];
		int i = 0;
		for (; i < smallerArray.length; i++) {
			if (a[i] > b[i]) {
				out[i] = a[i];
			} else {
				out[i] = b[i];
			}
		}

		// for the remaining elements, if any
		for (; i < biggerArray.length; i++) {
			out[i] = biggerArray[i];
		}
		return out;
	}
}

When you run the program, you will get output as below:

Output:
10
5
6
8
55
56

Shabana Mukhtar