can any one give me anexample which takes worst case of this problem
On Mon, Mar 26, 2012 at 1:56 PM, Arpit Sood soodfi...@gmail.com wrote:
@ankur +1
correct algo, can be done in just one pass.
On Mon, Oct 24, 2011 at 11:03 PM, Ankur Garg ankurga...@gmail.com wrote:
I think this can be
@ankur +1
correct algo, can be done in just one pass.
On Mon, Oct 24, 2011 at 11:03 PM, Ankur Garg ankurga...@gmail.com wrote:
I think this can be solved like this .
Start from the first petrol pump i.e first point in the circle . Now if
the petrol finishes befor reaching the second petrol
Sorry there is some correction
p[] : array of petrol
d[]: array of distance
int FirstPetrolPump(int p[],int d[],int n)
{
int c=0,ThisPetrol=0,FirstPump=0,i;
for(i=0;in cn; i++)
{
ThisPetrol+=p[i];
if(ThisPetrold[i])
{
ThisPetrol=0;
FirstPump=i+1;
c=0;
}
else
{
@ankur : I also think u r right
@everyone : Plz check if my code is right
p[] : array of petrol
d[]: array of distance
int FirstPetrolPump(int p[],int d[],int n)
{
int c=0,ThisPetrol=0,FirstPump=0,i;
for(i=0;in cn; i++)
{
ThisPetrol+=p[i];
if(ThisPetrold[i])
{
ThisPetrol=0;
You are given a word and a dictionary. Now propose an algorithm edit
the word (insert / delete characters) minimally to get a word that
also exists in the dictionary. Cost of insertion and deletion is same.
Write pseudocode for it.
Seems like minimum edit distance problem but some modification is
We can use a trie here .. Create a trie with all words of dictionary .
Now delete the last character of the word and check if such a word is a
valid word . If not see if adding a new character can make it a valid word
. If not delete the next character and repeat the process again .
This is what
yeah, that is normal bryteforce. Any better idea?
On 11/14/11, Ankur Garg ankurga...@gmail.com wrote:
We can use a trie here .. Create a trie with all words of dictionary .
Now delete the last character of the word and check if such a word is a
valid word . If not see if adding a new
Levensteins algorithm
On 14 Nov 2011 18:19, aniket chatterjee aniket...@gmail.com wrote:
yeah, that is normal bryteforce. Any better idea?
On 11/14/11, Ankur Garg ankurga...@gmail.com wrote:
We can use a trie here .. Create a trie with all words of dictionary .
Now delete the last
@Rajeev: The above algorithm assumes a source string and a destination
string. But here you are provided only the source string. And you will have
to edit it (minimally) such that the resulting string matches a word in the
dictionary.
Need slight modification. Looking for the modification.
Aren't there multiple words that can be returned from the dictionary after
various operations?
eg: input string: CODE
If we go on walking the trie for the dictionary, we'll get results C, CO,
COD, CODA, CODE.
So multiple edit distance operations can be done to each of the instances
shown above
#includestdio.h
int main(){
//int pet[5]={10,1,19,19,1};
int pet[5]={10,1,18,20,1};
int point[5] = {10,20,30,40,50};
int tmp[5],index=0;
int i;
tmp[0]=pet[0];
for(i=1;i5;i++){
tmp[i]= pet[i]+tmp[i-1];
Suppose there is a circle. You have five points on that circle. Each
point corresponds to a petrol pump. You are given two sets of data.
1. The amount of petrol that petrol pump will give.
2. Distance from that petrol pump tp the next petrol pump.
(Assume for 1 lit Petrol the truck will go 1 km)
I will choose the point where amount of fuel is maximum choose the
shortest path from two direction (clockwise or anticlockwise)..
With regards,
Praveen Raj
DCE-IT 3rd yr
735993
praveen0...@gmail.com
On Mon, Oct 24, 2011 at 4:36 PM, Aniket aniket...@gmail.com wrote:
Suppose
Lets say the Amount of petrol is Pi and distance to next petrol pump is Di
for ith petrol pump.
start from i=1, j=1 S =0
while (i=n)
S += Pj - Dj;
if S = 0 j = i-1 return i
if S 0 j = i-1 return 0
else if S = 0 j++ mod n;
else if S 0 j ++ mod n, i = j , S = 0;
return 0
it will
@Nitin, excellent algo.
if S 0 j = i-1 return 0 // I believe this mean there is no
solution, you might want to return -1.
Thanks,
- Ravindra
On Mon, Oct 24, 2011 at 8:39 PM, Nitin Garg nitin.garg.i...@gmail.comwrote:
Lets say the Amount of petrol is Pi and distance to next petrol pump
I think this can be solved like this .
Start from the first petrol pump i.e first point in the circle . Now if the
petrol finishes befor reaching the second petrol pump that means we chose
the incorrect point . So , choose second petrol pump now. If u reach third,
fill ur tanker and move to 4th .
16 matches
Mail list logo