find no. of 1's in binary format of numbers from 1 to 100. like for
1 to 10 answer is 17
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send
we can be use logical window and slide through the array
in circular manner. apply kandane's algo on logical window.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To
#includeiostreamusing namespace std;int main(){int count=0;int
count1=0;for(int i=0;i11;i++){
count=0;for(int j=0;j4;j++)if((i (1j)) 0){count++;}
count1+=count;}coutcount1;return 0;}
it will be better if u use java
limit of j will be more in case 100 or 200
so use If Integer.Bitcount() value if
the answer is 319
On Tue, Jul 24, 2012 at 3:09 PM, ruru soupti...@gmail.com wrote:
find no. of 1's in binary format of numbers from 1 to 100. like for
1 to 10 answer is 17
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
//the following functions will count number of bits in the number
int countbits(int n)
{
int count=0;
while(n)
{
n/=2;
count++;
}
return count;
}
int countnumberof1(int number)
{
if(number==0)
return 0;
if(number==1)
return 1;
if(number==2)
return 2;
if(number==3)
return
@Ruru:
int i,j,sum=100*101/2;
for( i = 1 ; i = 100 ; ++i )
{
j = i;
while( j )
{
j = 1;
sum -= j
}
}
printf(%i\n,sum);
Dave
On Tuesday, July 24, 2012 4:39:42 AM UTC-5, ruru wrote:
find no. of 1's in binary format of numbers from 1 to 100. like for
1 to 10
// count number of 1's upto n.cpp : Defines the entry point for the console
application.
//
#include stdafx.h
#includemath.h
#includeconio.h
//the following functions will count number of bits in the number
int countbits(int n)
{
int count=0;
while(n)
{
n/=2;
count++;
}
return
@dave sir-your algorithm is having a complexity of n(2) but the solution
that i have given is of log(n) i guess.
On Tue, Jul 24, 2012 at 8:10 PM, Dave dave_and_da...@juno.com wrote:
@Ruru:
int i,j,sum=100*101/2;
for( i = 1 ; i = 100 ; ++i )
{
j = i;
while( j )
{
j =
#includestdio.h
#define RANGE_START 0
#define RANGE_END 100
int main()
{
int i,n,ctr=0;
for( i=RANGE_START ; i=RANGE_END ; i++)
{
n = i;
while(n) // Using Brian Kernighan's Algorithm to count the number
of set bits in a number.
{
n= nn-1;
@Shobhit: Can you give me a few hints on implementing a BS on the 2D?
@neelpulse: That's what I said. A 2D array *might* be a probable candidate.
In your example, the first 2d satisfies the criteria...so we check it --
Not found -- Reject -- Move on to next probable candidate.
On Sat, Jul 21,
this is interview street
post here freely
all the best
On Monday, 23 July 2012 19:40:12 UTC+5:30, rahul sharma wrote:
Guys i am having amazon support engg. test tonyt...90 min 27 questions
mcq...plz tell how to prepare and wats dis profyl???reply asap..and sory
for posting it in algogeeks
Sorry , I've tried but BS will not work here .
On Tue, Jul 24, 2012 at 9:17 PM, algo bard algo.b...@gmail.com wrote:
@Shobhit: Can you give me a few hints on implementing a BS on the 2D?
@neelpulse: That's what I said. A 2D array *might* be a probable
candidate. In your example, the first 2d
I think the question is in the written round!!!
On Tue, Jul 24, 2012 at 9:11 PM, algo bard algo.b...@gmail.com wrote:
#includestdio.h
#define RANGE_START 0
#define RANGE_END 100
int main()
{
int i,n,ctr=0;
for( i=RANGE_START ; i=RANGE_END ; i++)
{
n = i;
Which of the following queue creates overflow when the no of elements is
less than the queue size??
1)single queue
2)priority queue
3)dequeue
4)circular queue
Kindly explain what is the answer and why??? Thanks in advance..
--
You received this message because you are subscribed to the Google
and we don't need the code!!
On Tue, Jul 24, 2012 at 10:30 PM, manish untwal manishuntw...@gmail.comwrote:
I think the question is in the written round!!!
On Tue, Jul 24, 2012 at 9:11 PM, algo bard algo.b...@gmail.com wrote:
#includestdio.h
#define RANGE_START 0
#define RANGE_END 100
Circular queue
Expalanation- think of the condition for overflow
On 24-Jul-2012, at 9:52 PM, Hariraman R rpharira...@gmail.com wrote:
Which of the following queue creates overflow when the no of elements is less
than the queue size??
1)single queue
2)priority queue
3)dequeue
4)circular
Circular Queue, as it will overwrite in that case.
I am not sure, if I understood the question correctly though.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
@mind blogger,
Thank u:) Got it...:)
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
Traditional decryption problem
Convert a3b2c5 into aaabbc
Can anyone Put forward an algo for the test case: a3b1c3d1
Thanx
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algogeeks@googlegroups.com.
To
Let's define a term RANDOMNESS of array as...
summation of position of each 1's
for eg
RANDOMNESS for
(0,0,1,0,1,0,1,1)
will be
23
now calculate max possible RANDOMNESS for the given array (each 1 on max
possible right position)
here it will be 26
so ans will be--
MAX RANDOMNESS of given array
can anyone provide the code to convert ab1cd3 to abcddd
**~Sathish Babu~**
On Tue, Jul 24, 2012 at 11:39 PM, Mind Boggler min.b...@gmail.com wrote:
Traditional decryption problem
Convert a3b2c5 into aaabbc
Can anyone Put forward an algo for the test case: a3b1c3d1
Thanx
--
You
3,8,12,17,22,28,35
what is the nth term of this sequence...
plz help
it is the spoj problem on the last page of the problem set, problem code
is as ARD1
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
I Think Single queue as if rear =Size-1 and we are performing dequeue
operation and now want to add an element then it will say that queue is
overflow but still queue have spaces and to avoid this circular queue
concept came.. please correct me if i m wrong...!!
--
You received this
The answer is single queue...
If we fill the queue fully and then dequeue and try again to enqueue... We
will get the error.. This is because when we dequeue,we move the front
pointer of the queue but not the rear pointer.. But enqueue is at rear
end.. The condition for enqueue also checks the
24 matches
Mail list logo