## shajikurian

BAN USER
Comments (3)

Reputation 0

Page:

1

Comment hidden because of low score. Click to expand.

Comment hidden because of low score. Click to expand.

0

of 0 vote

sort the array - O(n logn)

additional space O(2)

traverse array O(n)

```
public static void printOddOccurNum(int[] nums) {
Arrays.sort(nums);
int prev=nums[0];
int c=1;
for (int i = 1; i < nums.length; i++) {
if(nums[i]==prev) {
c++;
}else {
if(c%2!=0) {
System.out.println(prev+":"+c);
}
prev = nums[i];
c=1;
}
}
```

}

- shajikurian May 21, 2016Comment hidden because of low score. Click to expand.

0

of 0 vote

```
public static boolean findWon(int [][] t) {
int a=0;
int b=0;
for (int i = 0; i < 3; i++) {
a=0;
b=0;
for (int j = 0; j < 3; j++) {
a+=t[i][j];
b+=t[j][i];
}
if(a==3 || a==6 || b==3 || b==6) {
return true;
}
}
for (int i = 0; i < 3; i++) {
a+=t[i][i];
}
if(a==3 || a==6) {
return true;
}
for (int i = 0, j=2; i < 3; i++) {
a+=t[i][j-i];
}
if(a==3 || a==6) {
return true;
}
return false;
```

}

- shajikurian May 21, 2016Page:

1

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window

Please look what is the definition of island.

- shajikurian June 01, 2016