rajeshkumar.a
BAN USERThis is not called as sorting in one pass.
Two passes are happening here:
1) Passing the array and counting number repitions
2) Modifying the array with repitions.
It's more than O(n). Can you provide the code to prove your logic of O(n) ?
Hi raiprince001,
Is it possible to share your email address to contact you? My email address is: rajeshkumar.a@gmail.com
Thanks,
Rajesh
Are you sure that the example's answer is correct?
I guess the position must be (1,3)
<pre lang="" line="1" title="CodeMonkey99618" class="run-this">/* C# implementation */
public class UniqueFourDigits
{
public static void Display()
{
for (int currentNumber = 1000; currentNumber <= 9999; currentNumber++)
{
if (ContainsUniqueNumbers(currentNumber))
Console.WriteLine(currentNumber);
}
}
private static bool ContainsUniqueNumbers(int number)
{
bool status = true;
char[] stringNumber = number.ToString().ToCharArray();
for(int counter=0; counter < 3; counter++)
{
if(stringNumber[counter] == stringNumber[counter+1])
status = false;
}
if (status && stringNumber[0] == '4')
{
if (stringNumber[3] != '4')
{
status = false;
}
}
return status ;
}
}</pre><pre title="CodeMonkey99618" input="yes">
</pre>
Are you sure that BST can be constructed with duplicate values?
- rajeshkumar.a December 19, 2011