jj
BAN USER
Comments (4)
Reputation 20
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 1 vote
Use XOR
public class Missing_and_Duplicate {
/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub
int[] intArray2={2,4,7,5,3,1}; // 6 is missing
find_missing(intArray2);
}
public static void find_missing(int[] intArray)
{
int answer = intArray[0];
for(int i=1;i<intArray.length;i++)
{
answer = answer ^ intArray[i];
}
System.out.println("answer="+answer);
}
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
var sub = str.Substring( i, n ); should be var sub = str.Substring( i, i+n );
- jj January 28, 2016