On one weekday, I was invited to have the interview discussion at

So I also got agreed to see the process there, as its office is in the way to my office. Interviews are always good to be part of, whether you are taking or giving it, so never shy off from the interviews if you have time & it is around your work area.

I went there in the morning & it seemed a slow start there as employees were not there & I see 9:30 AM a decent time to have half of your workforce, at least, in the office. So I waited & was getting sleepy.

Any how interview started by 10:30 am with some information about the company & formal discussion.

And then the person asked to

I will not say its a fault with that person, but the IT culture/environment is getting like this where one considers him/herself knowledgeable if that person studies www.geeksforgeeks.org or asks questions from that or such design questions.

I am pretty much sure that maximum such people will be having no clue how to solve those problems & what related issue they can solve by that.

But No, market trend is getting like this, ask such questions not related to the actual work & never try to know about the person called for the interview to understand if that person fits for the requirements. Just ask such design, algos or DS questions to know, I don't know what.

Seems this person was already having his notions, so put the idea of messaging queues.

Then next & last question was -

One can get the answer from www.geeksforgeeks.org/find-next-greater-number-set-digits/

Though I couldn't write the code there on the paper but gave the approach. And it was not enough for this interviewer.

And I got the feedback that I don't know about the design patterns, DS & Algorithms, seriously? At least give the honest feedback to the candidate.

Many such interviewers, if asking you this question on paper then they have mugged-up the solution & if your solution & approach is bit different then they will try to see if you know about the approach they mugged-up & if you can't then 70% chances are that your solution will be rejected & if your approach is right then other 30% will approve as that 30% has the capability to understand. Or if the solution needs to be written on some IDE then your correctness will be tested only forget about the approach with maximum interviewers.

So my experience was not good & will not recommend unless you are seriously looking for some job.

Now I wrote below code which is slower than the code given above but it does work & its performance can be improved -

import java.util.ArrayList;

import java.util.Collections;

public class NextBiggerNumber {

static ArrayList<Integer> sorted = new ArrayList<>();

static int len = 0;

public static void main(String[] args) {

// int number = 123456; //Ans : 123465

// int number = 465321; //Ans : 512346

// int number = 987654321; //Ans : Not possible

// int number = 569874568; //Ans : 569874586

// int number = 9873654; //Ans : 9874356

// int number = 2156943; //Ans : 2159346

// int number = -2156943; //Ans : 2156934

// int number = -2156934; //Ans : 2156493

// int number = -987654321; //Ans : 987654312

// int number = 12355576; //Ans : 12355657

int number = -1; //Ans : Not possible

ArrayList<Integer> orgDigits = new ArrayList<>(10);

boolean isNegative = false;

if(number < 0)

isNegative = true;

while(Math.abs(number) > 0) {

orgDigits.add(0, Math.abs(number%10));

number = number/10;

}

if(number < 0)

isNegative = true;

int size = orgDigits.size();

long start = System.nanoTime();

if(!findNext(orgDigits, size-1, isNegative))

System.out.println("Not possible.....");

else {

System.out.println(isNegative ? "-"+orgDigits.toString() : orgDigits.toString());

int mul = 1;

int result = 0;

for(int n : orgDigits) {

result = result*mul + n;

mul = 10;

}

System.out.println(isNegative ? -result : result);

}

System.out.println("Time taken : " + (System.nanoTime() - start) + " nano sec");

}

public static boolean findNext(ArrayList<Integer> digits, int pos, boolean isNegative) {

if(digits.size() <= 1)

return false;

if(pos == digits.size()-1) {

sorted.add(0, digits.get(pos));

len++;

return findNext(digits, --pos, isNegative);

}

Collections.sort(sorted);

int cur = digits.get(pos);

int i = len-1;

if(!isNegative) {

while(i >= 0 && cur < sorted.get(i))

i--;

} else {

if(cur > sorted.get(i))

i--;

}

if(i != len-1) {

digits.remove(pos);

digits.add(pos, sorted.get(i+1));

int j = pos+1;

while(j < digits.size()) {

if(digits.get(j) == digits.get(pos)) {

digits.remove(j);

digits.add(j, cur);

}

j++;

}

if(isNegative)

Collections.sort(digits.subList(pos+1, digits.size()), Collections.reverseOrder());

else

Collections.sort(digits.subList(pos+1, digits.size()));

} else if(pos > 0) {

sorted.add(0, cur);

len++;

return findNext(digits, --pos, isNegative);

} else {

return false;

}

return true;

}

}

Many will find this code huge & will advocate to use java8 or above to reduce the code size.

May be, start comparing the imperative & declarative programming approaches, will say that code looks elegant in new Java versions. Here the target is not elegance but the approach is & then comes the performance & later the elegance is last step once you decide & finalize on the approach & then you decide what to abstract.

**Model N India Software Pvt Ltd, Hyderabad**So I also got agreed to see the process there, as its office is in the way to my office. Interviews are always good to be part of, whether you are taking or giving it, so never shy off from the interviews if you have time & it is around your work area.

I went there in the morning & it seemed a slow start there as employees were not there & I see 9:30 AM a decent time to have half of your workforce, at least, in the office. So I waited & was getting sleepy.

Any how interview started by 10:30 am with some information about the company & formal discussion.

And then the person asked to

**design the WhatsApp like application.**I will not say its a fault with that person, but the IT culture/environment is getting like this where one considers him/herself knowledgeable if that person studies www.geeksforgeeks.org or asks questions from that or such design questions.

I am pretty much sure that maximum such people will be having no clue how to solve those problems & what related issue they can solve by that.

But No, market trend is getting like this, ask such questions not related to the actual work & never try to know about the person called for the interview to understand if that person fits for the requirements. Just ask such design, algos or DS questions to know, I don't know what.

Seems this person was already having his notions, so put the idea of messaging queues.

**Next question was about the difference between SOAP & REST.**Then next & last question was -

**-----Find next greater number with same set of digits**One can get the answer from www.geeksforgeeks.org/find-next-greater-number-set-digits/

Though I couldn't write the code there on the paper but gave the approach. And it was not enough for this interviewer.

And I got the feedback that I don't know about the design patterns, DS & Algorithms, seriously? At least give the honest feedback to the candidate.

Many such interviewers, if asking you this question on paper then they have mugged-up the solution & if your solution & approach is bit different then they will try to see if you know about the approach they mugged-up & if you can't then 70% chances are that your solution will be rejected & if your approach is right then other 30% will approve as that 30% has the capability to understand. Or if the solution needs to be written on some IDE then your correctness will be tested only forget about the approach with maximum interviewers.

So my experience was not good & will not recommend unless you are seriously looking for some job.

Now I wrote below code which is slower than the code given above but it does work & its performance can be improved -

import java.util.ArrayList;

import java.util.Collections;

public class NextBiggerNumber {

static ArrayList<Integer> sorted = new ArrayList<>();

static int len = 0;

public static void main(String[] args) {

// int number = 123456; //Ans : 123465

// int number = 465321; //Ans : 512346

// int number = 987654321; //Ans : Not possible

// int number = 569874568; //Ans : 569874586

// int number = 9873654; //Ans : 9874356

// int number = 2156943; //Ans : 2159346

// int number = -2156943; //Ans : 2156934

// int number = -2156934; //Ans : 2156493

// int number = -987654321; //Ans : 987654312

// int number = 12355576; //Ans : 12355657

int number = -1; //Ans : Not possible

ArrayList<Integer> orgDigits = new ArrayList<>(10);

boolean isNegative = false;

if(number < 0)

isNegative = true;

while(Math.abs(number) > 0) {

orgDigits.add(0, Math.abs(number%10));

number = number/10;

}

if(number < 0)

isNegative = true;

int size = orgDigits.size();

long start = System.nanoTime();

if(!findNext(orgDigits, size-1, isNegative))

System.out.println("Not possible.....");

else {

System.out.println(isNegative ? "-"+orgDigits.toString() : orgDigits.toString());

int mul = 1;

int result = 0;

for(int n : orgDigits) {

result = result*mul + n;

mul = 10;

}

System.out.println(isNegative ? -result : result);

}

System.out.println("Time taken : " + (System.nanoTime() - start) + " nano sec");

}

public static boolean findNext(ArrayList<Integer> digits, int pos, boolean isNegative) {

if(digits.size() <= 1)

return false;

if(pos == digits.size()-1) {

sorted.add(0, digits.get(pos));

len++;

return findNext(digits, --pos, isNegative);

}

Collections.sort(sorted);

int cur = digits.get(pos);

int i = len-1;

if(!isNegative) {

while(i >= 0 && cur < sorted.get(i))

i--;

} else {

if(cur > sorted.get(i))

i--;

}

if(i != len-1) {

digits.remove(pos);

digits.add(pos, sorted.get(i+1));

int j = pos+1;

while(j < digits.size()) {

if(digits.get(j) == digits.get(pos)) {

digits.remove(j);

digits.add(j, cur);

}

j++;

}

if(isNegative)

Collections.sort(digits.subList(pos+1, digits.size()), Collections.reverseOrder());

else

Collections.sort(digits.subList(pos+1, digits.size()));

} else if(pos > 0) {

sorted.add(0, cur);

len++;

return findNext(digits, --pos, isNegative);

} else {

return false;

}

return true;

}

}

Many will find this code huge & will advocate to use java8 or above to reduce the code size.

May be, start comparing the imperative & declarative programming approaches, will say that code looks elegant in new Java versions. Here the target is not elegance but the approach is & then comes the performance & later the elegance is last step once you decide & finalize on the approach & then you decide what to abstract.