@Navin- Its only for continuous number :- if size of array <= max-min
for Non continuous it takes O(R) space complexity as suggested by daksh.
where R is range of number.
On Mon, Aug 13, 2012 at 2:55 PM, Navin wrote:
> @vivek :- what if the array index goes out of bound.
> I mean if |max - mi
On Mon, Aug 13, 2012 at 4:39 PM, vivek rungta wrote:
>
> @Navin- Its only for continuous number :- if size of array >= max-min
> for Non continuous it takes O(R) space complexity as suggested by daksh.
> where R is range of number.
>
>
>
> On Mon, Aug 13, 20
@shobhit No, in question already mention that He knows how to count up
beyond five, just not how to write it.
On Mon, Aug 13, 2012 at 1:39 PM, SHOBHIT GUPTA
wrote:
> shouldn't be the sum i.e. 4 taken as 1 ?
>
>
> On Mon, Aug 13, 2012 at 11:06 AM, vivek rungta wrote:
>
>
if sum is 4 output will be 33
On Mon, Aug 13, 2012 at 10:29 AM, SHOBHIT GUPTA
wrote:
> what will be the output if the sum is 4 ?
>
> On Sun, Aug 12, 2012 at 11:22 PM, harsha wrote:
>
>> A smart 3 year old Sandeep knows counting. But he doesn't know how to
>> read and write properly. He has lear
bool is_lucky(int x){
int pos=x;
inr count=2;
while(countwrote:
> @daksh paaji kya baat hai thanks for the solution. aap har jagah hai :P
>
>
> On Sat, Aug 4, 2012 at 12:21 AM, Daksh Talwar wrote:
>
>> maintain a bool array of size of limit of int
>> store true for lucky numbers
>> and then cross
its base 26 but little modification in code ...
@shiv - nice solution .
char Carr[26]={a,b,c...z}
i=0;
int arr[];
do
{
arrr[i++]=n%26;
n=(n/26)-1;
}
while(n) ;
for(int i=n-1;i>=0;i--)
cout< wrote:
> No. It's not base 26 at all. Given input 26, your code will return ba, but
> the result should be
Solution for - all number appears two time except three number which
appears 1 or 3 times.
array indexing method is used to solve in O(n) time complexity and O(1).
first find min - O(n)
then in for loop 1 to n
a[abs(a[i])-min]=-a[abs(a[i])-min];
then find the -ve number in array
then answer will
use simple recursive function to solve -
int countfun(int sum ){
int i;
int count;
int total=0;
if (sum==0)
return 1;
for(i=1;i<=3;i++){
if (sum-i<0)
break;
count=countfun(sum-i);
if(i==1)
count*=2;
total+=count;
}
return total;
}
On Sun, Aug 12, 2012 at 11:22 PM, harsha wrote:
> A smart 3 ye