is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
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.
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.
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.
package testpack;
- kvegeta74 September 19, 2012//there should be same number of even and odd numbers
public class Program7 {
/**
* @param args
*/
public static void main(String[] args) {
int[] a = { 1, 2, 3, 4 };
int eve = 0, odd = 0, ce = 0, co = 0;
for (int i = 0; i < a.length; i++) {
if (a[i] % 2 == 0) {
++eve;
} else {
++odd;
}
}
int[] eve_arr = new int[eve];
;
int[] odd_arr = new int[odd];
for (int i = 0; i < a.length; i++) {
if (a[i] % 2 == 0) {
eve_arr[ce] = a[i];
ce++;
} else {
odd_arr[co] = a[i];
co++;
}
}
// System.out.println(eve_arr.length+" "+odd_arr.length);
/*
* int i_ = 0, e1 = 0, o1 = 0;
*
* while(i_ <= a.length){
*
*
* if( i_ % 2 == 0){ System.out.println(e1); a[i_] = eve_arr[e1]; e1++;
*
* } else{ a[i_] = odd_arr[o1]; o1++;
*
* }
*
*
*
* i_++;
*
*
*
* }
*/
int m = 0, n = 1;
for (int i = 0; i < odd_arr.length; i++) {
a[n] = odd_arr[i];
n = n + 2;
}
for (int i = 0; i < eve_arr.length; i++) {
a[m] = eve_arr[i];
m = m + 2;
}
for (int i1 = 0; i1 < a.length; i1++) {
System.out.print(a[i1] + " ");
}
}
}
Yes, this question has to have a constraint. The constraint being the presence of equal no. of even and odd numbers...or else u end up facing ArrayIndexOutOfBoundsException..which took most of my time to rectify :-/