i am a beginner.pl help me with this code.i submitted a solution.it s
giving op for all given testcases.but the judge is giving me a TLE.
code:
#includeiostream
#includemap
#define inf 9
using namespace std;
mapint,int m2;
int func(mapint,int m1,int w)
{
if(m2[w]inf)
return m2[w];
@fenghuang: the last step will take O(n logn ) . Or there is some better
way?
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
What if we have an array :-
index - 1 2 3 4 5
value - 1 2 3 4 5
How will ANY logn solution determine all ALL elements are equal to it's
index value ? Maybe I misunderstand.
Thank you,
Ashim
On Sat, Dec 4, 2010 at 5:38 PM, ankit sablok ankit4...@gmail.com wrote:
u can then move to other
If All the elements are unique and sorted in ascending order then we can
design an algorithm for O(lgn) and all nos are positive.
Run FIND_EQUAL(A,0,N-1) [A0,A1 and A2 are the array elements]
FIND_EQUAL(A,start,end)
1.Go to the middle element
2.If A[mid]==mid)
return mid+1;
if(A[mid]mid)
yaar I can use simple O(n) sweep to find out who all are equal, I think it
can't be less than this
On Sat, Dec 4, 2010 at 8:05 PM, Abioy Sun abioy@gmail.com wrote:
2010/12/4 ankit sablok ankit4...@gmail.com:
as all the elements are sorted in the array make a min heap of the
array
#includeiostream
#includeclimits
using namespace std;
int m[1];
struct coin
{
int value;
int weight;
}s1[1000];
main()
{
int t,w0,w1,n,temp,temp1,i,j,w;
cint;
while(t--)
{
cinw0w1;
w=w1-w0;
cinn;
temp1=INT_MAX;
for(i=1;i=n;i++)
{
use kd-tree
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this
@Nikhil
run you algo ..
on test case
index - 1 2 3 4 5
value - 1 2 3 4 5
ouput is mid+1= 3+1=4
but it should be 5...
correct me if i am wrong... and u have assumed all are positive, hence base
index should be 1
On Sun, Dec 5, 2010 at 4:41 PM, Nikhil Agarwal nikhil.bhoja...@gmail.comwrote:
If
@ashim please refer my post.I posted an o(lgn) algo.i.e. I am copying again
below with an update
If All the elements are unique and sorted in ascending order then we can
design an algorithm for O(lgn) and all nos are positive.
Run FIND_EQUAL(A,0,N-1) [A0,A1 and A2 are the array elements]
@jai gupta
how can you find solution in O(n)
in O(n) you can just find the distance of all the points form origin..
then find the k smallest numbers(distance) in O(k log n + n ) using heap
short..
On Sun, Dec 5, 2010 at 7:28 PM, alexsolo asp...@gmail.com wrote:
use kd-tree
--
You received
@alexsolo
what is Kd-tree .. plz explain a little bit you algorithm...
On Sun, Dec 5, 2010 at 7:28 PM, alexsolo asp...@gmail.com wrote:
use kd-tree
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
Could anyone able to provide pseudo code/algorithm for this problem
using DP?
On Dec 1, 11:42 pm, Harshal hc4...@gmail.com wrote:
Someone please explain why do we need dynamic programming approach to solve
this? Cant we find the solution as mentioned by 'algose chase' above??
--
You received
I've did the problem http://www.spoj.pl/problems/FINDSR with brute force
approach.. It is showing TLE..
Anyone tell the approach to solve that problem...
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
13 matches
Mail list logo