binary search!!! :)
On Sat, Sep 24, 2011 at 11:38 PM, sunny agrawal sunny816.i...@gmail.comwrote:
let x be the number
initialize ans to some value like x or x/2
now repeatedly do the following
ans = (ans + x/ans)/2
each time you perform this operation you will move closer to the sqrt
construct a trie.. then a simple recursion on the trie ll do ... :) any
standard tutorial on tries ll help u build one ...
then the recursion part should look something like this,
start scanning from root of tire.
if(end of word is found)
{
take is as a word, start searching from root of a
didnt read the question properly ... ignore ma post !! :/
On Mon, Sep 19, 2011 at 8:44 PM, Yogesh Yadav medu...@gmail.com wrote:
i=0;
char *str;
while(a[i]!=NULL)
{
j=0;
while(j!=i)
{
for(k=j;k=i;k++)
{
l=0;
str[l]=a[j];
}
thanks *Shashi* !!!
http://deepblue.lib.umich.edu/bitstream/2027.42/24435/1/708.pdf
this one is good to :)
On Wed, Aug 24, 2011 at 5:32 PM, shashi kant shashiski...@gmail.com wrote:
http://www.se.cuhk.edu.hk/~seem3570/12-pattern.pdf
here is the solution to this
On Wed, Aug 24,
^typo
On Wed, Aug 24, 2011 at 6:46 PM, keyan karthi keyankarthi1...@gmail.comwrote:
thanks *Shashi* !!!
http://deepblue.lib.umich.edu/bitstream/2027.42/24435/1/708.pdf
this one is good to :)
On Wed, Aug 24, 2011 at 5:32 PM, shashi kant shashiski...@gmail.comwrote:
http
http://www.spoj.pl/problems/MAIN8_D/
i tried solving this problem
any ideas...??
for second test case 'htht'
the states i considered are
1 T - (1/2) * x+1
2 HH - (1/4) * x+2
3 HTT - (1/8) * x+3
4 HTHH - (1/16) * x+4
5 HTHT - (1/16)(final state)
x is the expected no
priority_queueobject, vector of object, greaterobject
On 8/15/11, Zack sandeep.masum4...@gmail.com wrote:
how i use STL,s prority_queue as a min heap..?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
priority_queuepairint,int, vectorpairint,int , greater pair
int, int
here pair. First is used for comparing If you replace greater
with lower , you get max heap If you use some structure... You
have to define a bool function in tat case..
On 8/15/11, sandeep pandey
First thing tat should come to your mind s ' requirements ' ask him
wat de requirements are. He will expect tat..
On 8/12/11, MAC macatad...@gmail.com wrote:
Hi guys ,
Can anyone help me in understanding what is expected when some some one
asks you design a car rental system . Exactly
May be this way We dont display de title of a movie as a thumbnail
So may be the first frame which has a wide distribution of
colours , assuring it has some other part of de clip other than de
title.. Ignore this if it sounds funny...!!
On 8/9/11, *$* gopi.komand...@gmail.com wrote:
u can use a bool array size- 26 and do char[i]-'A' = 1 , check it to
decide the first instance of the character. this can be done in O(n).
u can even use bit mask to make ur code look better ( ;) )
On 8/5/11, priya v pria@gmail.com wrote:
If an additional storage is used to store the
:D :D r u serious dude ??
On 8/3/11, Puneet Gautam puneet.nsi...@gmail.com wrote:
@Utkarsh:
How did u get the intern...?
it cant be ...!!!
Who is the moderator of this group..?
I want this thread be removed immediately from this group...!!! pls do it...
On 8/3/11, kaustubh
if it is spoj -tug , then the problem gets reduced to knapsack dp
which is used for subset sum calculation :) since u just have to print
yes or no break once the sum count becomes '2' for some sum.
On 7/30/11, Amol Sharma amolsharm...@gmail.com wrote:
@saurabh- your algo has very high
@kavitha: u can use back tracking to print all the substring for a
string .. pseudo code should look some thing like this:
void next_perm(string st,int pos)
{
if(pos==length)
{
coutst;
return;
}
for(int i=pos;ilength;i++)
{
swap(st,i,pos);
next_perm(st,i+1);
oops .. permutation pardon me guys !!!
On 7/26/11, keyan karthi keyankarthi1...@gmail.com wrote:
@kavitha: u can use back tracking to print all the substring for a
string .. pseudo code should look some thing like this:
void next_perm(string st,int pos)
{
if(pos==length
yup tat should work fine :) :)
On Sat, Jul 23, 2011 at 10:03 AM, rajeev bharshetty rajeevr...@gmail.comwrote:
Use Quick sort to sort the characters of a string (qsort is inplace sorting
) then check for consecutive characters in the array, if they are same then
the string is not unique else
counting sort ll help to some extent... find the min and max element O(n)
now u just need an array of size max-min to store the values then
just traverse the list and while updating u do value+min... still it is not
suitable if the magnitude is high.
On Sat, Jul 23, 2011 at 9:45 AM,
u can use an integer as a bit mask to do this... by setting the
alphabet-'a' th bit, and checking the same..
On Sat, Jul 23, 2011 at 9:52 AM, Reynald reynaldsus...@gmail.com wrote:
Implement an algorithm to determine if a string has all unique
characters. What if you can not use
.unpredictable behaviour !!
--
Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad
On Mon, Jul 18, 2011 at 2:36 PM, keyan karthi
keyankarthi1...@gmail.comwrote:
#includeiostream
using namespace std;
int main()
{
int p=1;
printf(%d %d %d %d,++p,p++,p
thanks ppl :)
On Mon, Jul 18, 2011 at 3:59 PM, schrodinger 6fae1ce6347...@gmail.comwrote:
AFAIK, official answer is due to undefined behavior.
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web visit
can be done in NlogN take a node, say 'a' check if k-a exists in the
tree(logN)
On Sat, Jul 16, 2011 at 7:58 PM, sourabh jakhar sourabhjak...@gmail.comwrote:
convert into doubly linked list and than apply simple algo of finding two
element with a sum
On Sat, Jul 16, 2011 at 7:54 PM, saurabh
yup :)
On Sat, Jul 2, 2011 at 1:38 PM, Shalini Sah shalinisah.luv4cod...@gmail.com
wrote:
i guess the no. of 1s in the binary representation of the number is the
answer..for 6 its 2...
On Sat, Jul 2, 2011 at 1:32 PM, cegprakash cegprak...@gmail.com wrote:
the length of the rope is l
http://en.wikipedia.org/wiki/Subset_sum_problem
http://en.wikipedia.org/wiki/Subset_sum_problem this should help u :)
knapsack like dp :)
On Mon, Jun 20, 2011 at 11:55 AM, Navneet Gupta navneetn...@gmail.comwrote:
Given a set of integers , find a set of numbers such that they sum to a
given
one way might be...
find min element, max element
declare a array buffer[max-min]
memset this to -1
for( i=0 to size )
buffer[input[i]-min elemet]=1
now check in O(n) the first position that has a -1 in array buffer, this
position + min element is the answer
but this uses lotta extra
dp(int chair,int person,bool previous)
if(previous)
dp(chair-1,person,0)
else
dp(chair-1,person-1,1)+dp(chair-1,person,0)
with basic conditions as it is a circle.. if person is placed in first
chair u cant place a person in last chair
On Tue, Jun 21, 2011 at 7:38 PM,
hi friends is a string literal.. ie the string hi friends is stored
somewhere and a pointer to its base address is returned to pointer p at the
time of initialization... u can always make use of this pointer to traverse
/ access the literal but u cant alter tat in the code, u r trying to do
a ++
we can even add word completion :)
On Wed, Jun 15, 2011 at 5:25 PM, immanuel kingston
kingston.imman...@gmail.com wrote:
Use a trie data structure and pre-load it with all the words of a
dictionary.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 3:06 PM, Piyush Sinha
upper_bound and lower_bound does a binary search to get count of alike
terms.. which u tend to sum of to get the ans..
out of the two arrays, u need to sort one array.. this will be teh vector in
which u do the binary search wit every element of un sorted array..
this is the approach i used... :)
assuming bsearch is returning a pointer to the first found element.
On Sun, Jun 12, 2011 at 12:41 PM, keyan karthi
keyankarthi1...@gmail.comwrote:
upper_bound and lower_bound does a binary search to get count of alike
terms.. which u tend to sum of to get the ans..
out of the two arrays, u
...@gmail.comwrote:
@keyan..your advice was really very helpful...the time limit has come
under control ...1.4s but now i am getting WA though my code is giving right
ans for the test cases...can you plz help me in figuring out where it fails
..
On Sun, Jun 12, 2011 at 12:59 AM, keyan karthi
k=query(x,y-1)
if(k==x)
count++
with this change ur code ACs :)
On Sat, Jun 11, 2011 at 1:24 PM, Radhika Renganathan
radi.coo...@gmail.comwrote:
i did the same prob wit range maximum query.. but im repeatedly
getting wrong answer.. im stuck with this prob for a long time.. pls
help..
my
u construct a tree nlogn , every node answers a query.. (or u get ans with a
recursion) in log(n) , so when u r doing a lot of query RMQ proves to be
very fast
On Fri, Jun 10, 2011 at 6:28 PM, nicks crazy.logic.k...@gmail.com wrote:
ya i saw that in the comments on spoj someone suggested to use
the nos can repeat :) ie the valid set may contain multiple instance of a
same number..
hope this helps :)
On Fri, Jun 10, 2011 at 9:31 AM, saurabh singh saurab...@gmail.com wrote:
Problem link- ABCDEF https://www.spoj.pl/problems/ABCDEF/
Can someone please explain this problem.The problem
abba as goel pointed out.. is the answer 'b' or 'a' .. ie does the order
in which u encounter the character matters.. 'a' comes before 'b' here...
if it is 'b' then a normal buf[txt[i]-'a']++ should do.. :)
On Wed, Jun 8, 2011 at 8:48 AM, Shivaji Varma shivaji...@gmail.com wrote:
This problem
:D :D
On Wed, Jun 8, 2011 at 2:25 PM, Kunal Patil kp101...@gmail.com wrote:
Automatic deletion will solve the trouble only for you not for the group as
such messages are not reported spam.. [?]
What i do is: When i login just type in search box 'panzer'...mark
all...report spam and then
dude.. u code says pi(3) =3 as its a prime... but pi(3) is 2
in the same way pi(2)=2 as per ur code.. but ans is 1... mend ur code for
this... :)
On Sun, Jun 5, 2011 at 9:20 PM, kartik sachan kartik.sac...@gmail.comwrote:
@keyan then also it is given time limit exceed
i
also tc page tat arun said says as follows...
1. If *p* is prime, then φ (*p*) = *p* - 1 and φ (*pa*) = *p** a* * (1 -
1/*p*) for any *a*.
2. If *m* and *n* are coprime, then φ (*m* * *n*) = φ (*m*) * φ (*n*).
3. If *n* = , then Euler function can be found using formula:
φ (*n*) =
first time when i pre processed, my code timed out :P on calling it for
every loop iteration my code passed !! may be tats the problem...
On Sun, Jun 5, 2011 at 1:56 AM, kartik sachan kartik.sac...@gmail.comwrote:
@arun.i got nothing from this link becoz i have made the
program
even if the left over string length is 1 so that the recursion can be
fun(s,current_position-2), u still have the option for choosing a single
character... do u get it??
thats where u go wrong... :) the rec call should be return
fun(cur_length-1)+fun(cur_len-2) ...
On Wed, Jun 1, 2011 at 3:34
oops.. :P that an if didnt notice tat :D
On Wed, Jun 1, 2011 at 8:34 PM, keyan karthi keyankarthi1...@gmail.comwrote:
even if the left over string length is 1 so that the recursion can be
fun(s,current_position-2), u still have the option for choosing a single
character... do u get
i used the following code..
getting wa
#includeiostream
#includealgorithm
#includevector
#includelimits.h
#includemap
using namespace std;
typedef unsigned long long int ull;
int main()
{
int t;
cint;
while(t--)
{
int n,sm=0;
scanf(%d,n);
vectorint v(n);
mapint,int mp;
for(int i=0;in;i++)
41 matches
Mail list logo