I dont know who you are or where you work, but the way you articulate a problem statement and the way you never give up on the candidates is truly amazing. More power to you! Lucky are the folks on your team to have a mentor like you.
For all the experts developers that say they can do it better, it is really difficult to code on real time, some of you will get extremely nervious, this is not a way to see the full potential of the candidate. After all, the real potential of a candidate is how he adapts to the team, learn new things, help others! Dont forget all you guys started from some point!
A 10+ years' experience developer's value does not lie in solving leetcode problems. Their value lies in their ability to work unsupervised, to be self-reliant, assiduous, diligent, trustworthy, able to pick up and develop pieces of work with no previous experience, to communicate well with technical and nontechnical colleagues, to have extensive deep and broad knowledge in many areas, to take responsibility for significant parts of the system on which they work....the list goes on and on. Solving leetcode problems quickly doesn't come into it, not at all.
"Their value lies in their ability to work unsupervised, to be self-reliant, assiduous, diligent, trustworthy, able to pick up and develop pieces of work with no previous experience". people test coding skills using leetcode problems in a timed environment to test if the candidate has this skill or not...
int countZeros = 0; // Count the number of zeros for (int num : arr) { if (num == 0) { countZeros++; } } // Overwrite the array with 0s and 1s for (int i = 0; i < countZeros; i++) { arr[i] = 0; } for (int i = countZeros; i < arr.length; i++) { arr[i] = 1; }
Sorting was easy question ..We could use two pointer algorithm ..initialize first pointer at the start of index and second pointer at the end of index... then we will compare left pointer with right ..if left 0 and right 1 ..increment the left pointer and right pointer ...if left pointer 1 and right 0 we will swap it and increment the left and decrement the right .....if both 0 then increment left leave right as it is ..and if both 1 decrement right and leave left as it is................ Time complexity will be O(n) and space complexity O(1) as everything happened in place
Just loop the array, keep a separate index variable, whenever you encounter 0, insert 0 at the index and increase the index variable. After that in another loop, start with the index’s current value to the array length and insert 1 in the same array.
@@anupkumarbaranwal if you have to bring all 1’s at last then you have to insert 0, whenever you encounter 0, so that all 0’s get inserted in the beginning and rest will be filled with 1 as we will have the 0 counter and total array length.
what an inefficient approach to sort 0(s) and 1(s) simply you can count and rearrange the integer array without creating not extra space and with O(n) Time Complexity Integer[] arr = new Integer[]{0, 1, 0, 1, 0, 1, 0}; int zeroCount = 0; for (Integer integer : arr) { if (integer == 0) zeroCount++; } int counter = 0; while (counter < arr.length) { if (zeroCount-- > 0) { arr[counter++] = 0; } else { arr[counter++] = 1; } }
I dont know who you are or where you work, but the way you articulate a problem statement and the way you never give up on the candidates is truly amazing. More power to you! Lucky are the folks on your team to have a mentor like you.
Thank you so much 💓
For all the experts developers that say they can do it better, it is really difficult to code on real time, some of you will get extremely nervious, this is not a way to see the full potential of the candidate. After all, the real potential of a candidate is how he adapts to the team, learn new things, help others! Dont forget all you guys started from some point!
This is the screening process followed by almost all IT companies in India
If starting point is 10+ years then you're in the wrong field my friend.
A 10+ years' experience developer's value does not lie in solving leetcode problems. Their value lies in their ability to work unsupervised, to be self-reliant, assiduous, diligent, trustworthy, able to pick up and develop pieces of work with no previous experience, to communicate well with technical and nontechnical colleagues, to have extensive deep and broad knowledge in many areas, to take responsibility for significant parts of the system on which they work....the list goes on and on. Solving leetcode problems quickly doesn't come into it, not at all.
Well Said.
You are 100% correct.
Leetcode, hackerrank, codility... are 3rd party money makers on a broken hiring process.
"Their value lies in their ability to work unsupervised, to be self-reliant, assiduous, diligent, trustworthy, able to pick up and develop pieces of work with no previous experience". people test coding skills using leetcode problems in a timed environment to test if the candidate has this skill or not...
you said it !
int index=0;
For(int i=0;i
int countZeros = 0;
// Count the number of zeros
for (int num : arr) {
if (num == 0) {
countZeros++;
}
}
// Overwrite the array with 0s and 1s
for (int i = 0; i < countZeros; i++) {
arr[i] = 0;
}
for (int i = countZeros; i < arr.length; i++) {
arr[i] = 1;
}
I admire your patience , most people would have ended the interview long back ...
Thanks for sharing experience
Sorting was easy question ..We could use two pointer algorithm ..initialize first pointer at the start of index and second pointer at the end of index... then we will compare left pointer with right ..if left 0 and right 1 ..increment the left pointer and right pointer ...if left pointer 1 and right 0 we will swap it and increment the left and decrement the right .....if both 0 then increment left leave right as it is ..and if both 1 decrement right and leave left as it is................ Time complexity will be O(n) and space complexity O(1) as everything happened in place
Just loop the array, keep a separate index variable, whenever you encounter 0, insert 0 at the index and increase the index variable. After that in another loop, start with the index’s current value to the array length and insert 1 in the same array.
Or count 0's and 1's and later fill the array 🙂
@@Fatality_Retired you mean whenever you encounter 1 and not 0
@@anupkumarbaranwal if you have to bring all 1’s at last then you have to insert 0, whenever you encounter 0, so that all 0’s get inserted in the beginning and rest will be filled with 1 as we will have the 0 counter and total array length.
@@priyankayadav-ee3ez 😂hacker
very good, thanks
11 years of experience but dont know how to sort 0 's and 1's, poor performance
Yes we don't learn algo n code at the night of interview after 11 years of experience, like u "desperate" "coder"
Bro how much experience you have?? Let's discuss on dsa if u think u r genius
@@Pawan-fd6wl peasant
I would create an int to count '0'
and no sortings
fresher 😄😃just solved few leetcode problems
Wow this was pretty easy for so much experience.
But was even this answered properly ?
@@stream2learn Nope, specially the core java answers.
@@Fatality_Retired yeah
@@stream2learn that guy didnt seemed seriously prepared
11yrs with this knowledge ,he is faking no jpql knowledge.He just learnt the architecture from someone.
Integer[] tab = {0,1,0,1,0,1,0,1,0,1,0,1};
LinkedList list = new LinkedList();
for (int val: tab) {
if(val == 0)
list.addFirst(val);
else
list.addLast(val);
}
System.out.println(list);
Excellent. What would be the performance of this ?
can also use deque...
for ( ... )
{
if 0 dq.add(0) else dq.addLast(1)
}
This is not an efficient algorithm as per space complexity will be O(n).
Excellent
public static void main (String args[]){
Integer[] num1 = {0,1,0,1,0,1,0,1,0,1};
for(int k=0 ; k num1[i + 1]) {
temp = num1[i];
num1[i] = num1[i + 1];
num1[i + 1] = temp;
}
}
}
for(int j=0;j
anybody who is having less than 3 years experience
private static void sortArr(Integer[] inputArr) {
boolean swapRequired = true;
while (swapRequired) {
swapRequired = false;
for (int i = 0; i < inputArr.length - 1; i++) {
if(inputArr[i] > inputArr[i+1]) {
swapRequired = true;
inputArr[i] = inputArr[i] + inputArr[i+1];
inputArr[i+1] = inputArr[i] - inputArr[i+1];
inputArr[i] = inputArr[i] - inputArr[i+1];
}
}
}
}
My solution for soring the array -
for (int i=0; i < num.length; i++) {
for(int j = 0; j < i; j++) {
if(num[i] < num[j]) {
num[j] = num[i] + num[j];
num[i] = num[j] - num[i];
num[j] = num[j] - num[i];
}
}
}
for (int k : num) {
System.out.println(k);
}
Very interesting, people can't sort an array with function :D Buy answer more complex things..
10 years of experience or 6 months experience?
Company name please ?
I am interested
is he hired ?
Nope. Rejected.
what an inefficient approach to sort 0(s) and 1(s)
simply you can count and rearrange the integer array without creating not extra space and with O(n) Time Complexity
Integer[] arr = new Integer[]{0, 1, 0, 1, 0, 1, 0};
int zeroCount = 0;
for (Integer integer : arr) {
if (integer == 0) zeroCount++;
}
int counter = 0;
while (counter < arr.length) {
if (zeroCount-- > 0) {
arr[counter++] = 0;
} else {
arr[counter++] = 1;
}
}
has he selected?
Nope.
Routing questions to somewhere else. Seems explaining anything he finds relevant.
he should be rejected
bad perfornamce.
Rejected
Bro needs to go back to college.
selected?
What do you think ? After Judging his skills.
persons.stream()
.filter(person -> person.getAge() >= 45)
.forEach(System.out::println);
public static void main (String args[]){
Integer[] num1 = {0,1,0,1,0,1,0,1,0,1};
for(int k=0 ; k num1[i + 1]) {
temp = num1[i];
num1[i] = num1[i + 1];
num1[i + 1] = temp;
}
}
}
for(int j=0;j
Is he selected???
Nope