...@gmail.comjavascript:
wrote:
find no. of cut vertex in the DAGthat will be the ans.
On 6 Oct 2012 19:33, KK kunalka...@gmail.com javascript: wrote:
Given a DAG(Directed Acyclic Graph). How to find out the minimum number
of edges that needs to be added so that the given graph becomes Strongly
Hi Vicky.. Its O(n^K) as u are iterating over all the elements of array for
each of the k element subset!!
On Monday, 8 October 2012 23:53:15 UTC+5:30, ((** VICKY **)) wrote:
Hi, I wrote code for generating all possible sets of length k in a array
of length n. I did using recursion, but i'm
Given a DAG(Directed Acyclic Graph). How to find out the minimum number of
edges that needs to be added so that the given graph becomes Strongly
Connected?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web
Given a DAG(Directed Acyclic Graph). How to find out the minimum number of
edges that needs to be added so that the given graph becomes Strongly
Connected?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To view this discussion on the web
@Hemesh : +1
@Jalaj : read Hemesh's solution again it is for 4sum.
In short, make a new array having sum of each unique pair of given array.
- O(n^2)
sort it - O(n^2)
for each number bi in new array, binary search (target - bi) in the same
array - O(n^2)
On Sunday, 17 June 2012 12:41:40
Thanks Gene :D
On Tuesday, 8 May 2012 07:24:01 UTC+5:30, Gene wrote:
You just need to make sure that the same character is never swapped to
the same position twice. Here is one way to do it.
#include stdio.h
#include string.h
void swap(char *s, int i, int j)
{
char t = s[i];
This problem is of ACM-ICPC kanpur online round 2012.
you can find the solution
herehttp://www.codechef.com/ACMKAN11/problems/ARTHMNCY
.
On Sunday, 10 June 2012 16:37:33 UTC+5:30, payel roy wrote:
Find the number of fractions a/b such that-
1. *gcd(a, b) = 1*
2. *0 a/b 1*
3. *a * b =
The problem u are referencing is different one.. here u can move in all 4
directions!
On Wednesday, 6 June 2012 18:43:15 UTC+5:30, Dheeraj wrote:
http://www.geeksforgeeks.org/archives/14943
On Mon, Jun 4, 2012 at 7:57 PM, Decipher ankurseth...@gmail.com wrote:
@Victor - Someone had asked
Try wid BFS.. thats the only alternative i can think off!! I got acc
wid that!!
On Dec 6, 12:29 pm, varma C.S.P verma@gmail.com wrote:
I am getting a lot of tle's for this problem.
https://www.spoj.pl/problems/BUGLIFE/
Here is my code
#includeiostream
#includecstdio
#includecstring
#includeiostream
#includevector
#includelist
#define TR(a,it)for(typeof((a).begin()) it = (a).begin(); it !=
(a).end(); ++it)
using namespace std;
void Insert(int key, int m, vector listint v);
listint::iterator Search(int key, int m, vector listint v);
void Delete(int key, int m,
http://www.spoj.pl/problems/PIE/
I solved this using Binary Search its similar to shake shake shaky of
spoj... but still get WA :(
Plzz help...
#includeiostream
#includealgorithm
using namespace std;
bool solve(int *pie, int n, int mid,int f)
{
int sum = 0;
for (int i=0; in; i++)
U must mention all the boundary cases, very large input cases, -ve nos
and must throw appropriate exception while coding during interviews...
Questions are not too hard in MS... just they dont want buggy code...
even if u allocate memory.. u should take an if condition i.e. if (p !
= NULL)...and
@Bharatkumar bagana : that is a standard Qs which uses line sweep algo
and has O(n lgn) soln other than the trivial O(n^2) soln... google
that Qs...
@tej bala: out of 10.. 5-6 were output type obj Q... then 1 was what's
full form of GCC... its gnu compiler collection.. i made mistake in
this Q..
grep is actually implemented using a suffix tree
--
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
MS visited out col with 2 profiles...
written test:
3 different papers:
1 one all objectives
2nd 2 subjective problems... 1 ws to find the closest pair of
points... and other was to find the bugs and provide the test cases
for the already provided string copying code...
then it was followed by 4
This is the code for the Euler phi function:
int phi (int n) {
int result = n;
for (int i=2; i*i=n; ++i)
if (n % i == 0) {
while (n % i == 0)
n /= i;
result -= result / i; // M NOT
Using getchar() after the first scanf ll be much better...!!
--
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
Check this out
//But this and fails for input such as: 101 ie all nos
must be unique..
int search_element_in_rotated_array(int *a, int low, int high, int
key)
{
while(low = high)
{
int mid = low + (high - low)/2;
if(a[mid] == key)
return
Go through the last 50-100 posts... a lot of Qs have already been
posted!!
--
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
3
--
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.
For more options, visit this group at
Codechef Ques(Initiative of Directi)
use DFS, BFS or Floyd Warshall... :)
--
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
@Harshal: 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 unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit
Hey Congrats!! :)
I got intern dere :)
--
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.
For
bool foo(int x)
// Implement this function where 0 = x = 100
It should return true x% of times n false otherwise
first i told him to have a static int s then increment it each time
the func is called...
and if s % (100 - x ) == 0 then true else false.
then he told me to have some
@Nikhil: ya true but i dont know wht else was he expecting.
@sunny and Muthu: like suppose u pass 20 then func should return true
with 20% probabily and false otherwise...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this
No i was not able to come up with a soln dere.. my bad :(
This was my 1st interview hope the upcoming interviews would be nice!!
--
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.
@shady: if ur not interested dont post ur comment, but let others do
it..
@viswamath: WA
--
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
@piyush:
even if r = di and c = dj then whats the prob??
--
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
www.spoj.pl/problems/SHOP
Its a pretty easy Q... But m not able to figure out any silly mistake
in my prog.. plzz help
#includeiostream
#includevector
#includemap
#includequeue
using namespace std;
char a[26][26];
int si, sj, di, dj, rows, cols;
void BFS(vector vectorint v, int si, int sj,
Can u elaborate something on implementation.??
--
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
Hey anyone Pl help... its clearly written code and algo u know vry
well so it wont take much time :)
On Jul 5, 8:43 pm, KK kunalkapadi...@gmail.com wrote:
This is the solution to the MST problem
m getting WA again n again... cant figure out where's the mistake...
so plzzz help!!!https
for Q5 change the expr into postfix and then build expression tree...
but is expression tree same as parse tree??
correct me if i m wrong!!
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
https://www.spoj.pl/problems/SHOP/
Anybody plzz post a solution to the above problem...
i tried with dp but it failed...
How to implement with DFS or if possible with DP???
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group,
This is the solution to the MST problem
m getting WA again n again... cant figure out where's the mistake...
so plzzz help!!!
https://www.spoj.pl/problems/BLINNET/
#includeiostream
#includestring
#includevector
#includelist
#includequeue
#define MAXINT (int)9e9
#define TR(a,it)
10. What does the following fragment of C-program print?
char c[] = GATE2011;
char *p =c;
printf(%s, p + p[3] - p[1]);
(A) GATE2011 (B) E2011 (C) 2011 (D) 011
Answer: - (C)
why is p[3] - p[1] returning 4
--
You received this message because you are subscribed to the Google Groups
got it dont bother!!!
anyway thanx abhijith!!!
--
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
3. Consider the following recurrence:
T(n) = 2T(n ^ (1/2)) + 1
Which one of the following is true?
(A) T(n) = (loglogn)
(B) T(n) = (logn)
(C) T(n) = (sqrt(n))
(D) T(n) = (n)
Can we solve this using master theorem???
any other way???
--
You received this message because you are subscribed to
Answer (B)
Let n = 2^m, T(n) = T(2^m)
Let T(2^m) = S(m)
From the above two, T(n) = S(m)
S(m) = 2S(m/2) + C1
Above expression is a binary tree traversal recursion whose time
complexity is (m). You can also prove using Master theorem.
S(m) = (m)
= (logn) /* Since n = 2^m */
Now, let
but in a set elements are not in any order...and also set cannot be
indexed...
if u want to sort in the basis of key use vector with pair...
Correct me if m wrong
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send
@sunny:
This test:
if(! ( (countx == counto + 1) || (countx == counto) ) )
cout no endl;
prints no if countx counto
and this one
if(o x)
cout no endl;
else
cout yes endl;
prints no if both have won or else
@sunny: why the answer for the case u mentioned is no.. those are
possible set of moves according to me and hence my program outputs
yes
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
To remove all digits left of the rightmost digit one in the binary
representation of some integer what we need to do is this:
ans = no -no
and this is what is exactly asked in this problem of SPOJ:
www.spoj.pl/problems/MZVRK/
#includeiostream
using namespace std;
int main()
{
unsigned long
oops !! :) i'll look into that.. thx
--
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.
For
http://www.spoj.pl/problems/MINMOVE/
This code is showing TLE after some 20th test case what else can be
optimized???
try:
import psyco
psyco.full()
except ImportError:
pass
string = input()
minlen = string
length = len(string)
string += string[:]
#print(string)
index = 0
for i in
www.spoj.pl/problems/BLINNET/
Here is the code for the same... Its not getting AC in SPOJ
m not able to figure out wheres the hole in this... plzz help
#includeiostream
#includestring
#includevector
#includelist
#includequeue
#define MAXINT (int)9e9
#define TR(a,it)
This code is not getting AC on spoj.. m not able to point out the
error plzzz help.
Here is the link to this problem at spoj : http://www.spoj.pl/problems/INVCNT/
#includeiostream
#includevector
#includestring
#includealgorithm
using namespace std;
void MergeSort(vectorint v, int p, int r);
Thanks dude!!
--
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.
For more options, visit this
Thanks Harshal!!
Actually changing juzz count from int to long long suffices
--
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
This q increased my score by directly 3 points... and thats a huge
one.. :D
@ kartik - Do it by priorty queue for better efficiency..
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@kunal
Actually its not same value its the same variable and it arises only
if u code the given way(and some people do it this way)
void swap(int a, int b)
{
a ^= b ^= a ^= b;
}
now we have
int a = 10;
swap(a, a)
This will set a's value to 0...and this happens while sorting arrays
It wont give correct answer when u pass same values of a and b and
such conditions arises in sorting
--
***
Kunal Kapadia
Computer Science and Engineering
B.Tech 2nd yr
NIT Trichy
***
--
You received this
It works!!
Shame on u Umer Farooq u cant even give a call a no for ur nation
whereas other are on hunger strike... even if this is algo group so
whats the problem???... m sorry to say this...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
This is the link to the SPOJ problem HASHIT :
http://www.spoj.pl/problems/HASHIT/
i donno whts the mistake... i keep getting wrong answer even though
the Q is Straightforward :(
#includeiostream
#includestring
using namespace std;
int hash(string str)
{
int sum = 0;
int len =
Search Topcoder Tutorial Range Minimum Query @ Google...
By few intuitive changes u can implement Range Maximum Query as well...
--
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.
I have juz started python and finished A Byte of Python
Now to which book should i switch too???
Also recommend Python books to master it!!
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Search Topcoder Tutorial on Google..
On Apr 17, 9:06 pm, naga vinod kumar vinodkumark...@gmail.com wrote:
Hi Guys ,
Can any one give link for tutorial or videos about
segment trees. I am unable to understand the basic idea behind it .
Regards,
vinod
--
You received
Hey it seems to be a fake link... It directs to some site which
shorten URLs
--
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
But i think here's no one to forward :p
Kunal Kapadia
Computer Science and Enggneering
2nd yr
NIT Trichy
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
@ Carl Barton:
I also know that site... i want a shared link u stupid...
--
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
Hey guys n gals WAKE UP
No reply on this topic???
Do any knows here about segment tree??
--
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
Please give link to:
Data Structures,Algorithms and Applications by Sartaj Sahni...
or directly mail to me.
--
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
Hello people please share sites from where good programming ebooks can
be downloaded...
i use library.nu and 4shared.com
--
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
Pls have a look at this Question on codechef
http://www.codechef.com/problems/FLIPCOIN/
i tried this using Segment tree...
i implemented segment updating properly
but dont know how to do segment Querying in this particular Question
although point Querying is easy..
and please suggest links and
@vaibhav shukla:
3 1 2 2 1 1 is ok
but how 1 3 1 1 2 2 2 1 came
Thanks
On Apr 13, 2:57 pm, vaibhav shukla vaibhav200...@gmail.com wrote:
On Wed, Apr 13, 2011 at 1:02 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:
* Sequence Puzzle *
*
*
*The below is a number puzzle. It should be
Dont worry got it!!!
On Apr 13, 2:57 pm, vaibhav shukla vaibhav200...@gmail.com wrote:
On Wed, Apr 13, 2011 at 1:02 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote:
* Sequence Puzzle *
*
*
*The below is a number puzzle. It should be read left to right, top to
bottom.
Question 1 What is
Hey can u mail it to me plzzz??
On Mar 23, 7:55 am, Anand anandut2...@gmail.com wrote:
Thanks!!
On Tue, Mar 22, 2011 at 7:11 PM, D.N.Vishwakarma@IITR
deok...@gmail.comwrote:
thanx...
On 3/22/11, Himanshu Neema potential.himansh...@gmail.com wrote:
-- Forwarded
Hey plzz mail me too..
On Apr 14, 9:29 am, Rajeev Kumar rajeevprasa...@gmail.com wrote:
check this
link:https://docs.google.com/viewer?a=vpid=explorerchrome=truesrcid=1B5...
If you have any problem in access,please inform me
On Thu, Apr 14, 2011 at 1:04 AM, Abhishek Goswami
i m getting TLE for this soln and m not getting the concept used in
the above soln can anyone help??
#includeiostream
using namespace std;
int main()
{
int t,n,k,no,flag;
scanf(%d,t);
while(t--)
{
scanf(%d,n);
k = n;
int a[100] = {0};
the rule governs that in exprns on both the side gets evaluated
only if first exprns gives TRUE if 1st one gives FALSE then whatever
be 2nd exprn answer be FALSE
and in || 2nd side is not evaluated if 1st side replies with TRUE..
On Dec 13, 9:10 pm, siva viknesh sivavikne...@gmail.com wrote:
ya all the exprn is evaluated and left expr is assigned ..
On Dec 13, 9:21 pm, siva viknesh sivavikne...@gmail.com wrote:
#includestdio.h
int main()
{
int a=1,b=2,c=3;
c=--a,b++ - c;
printf(%d %d %d,a,b,c);
return 0;
}
the above code is perfectly valid and prints 0 3 0 ...
but
On Sep 5, 11:07 am, jliang [EMAIL PROTECTED] wrote:
how about a doubled linked list where you can remove item at any
index. the removing is O(1). you can also keep track of the current
removing from a doubled linked list is O(1)? How?
size S so if you are borrowing book at index greater
71 matches
Mail list logo