# | User | Rating |
---|---|---|

1 | jiangly | 3860 |

2 | Benq | 3783 |

3 | maroonrk | 3627 |

4 | fantasy | 3526 |

5 | ko_osaga | 3500 |

6 | Um_nik | 3496 |

7 | tourist | 3487 |

8 | inaFSTream | 3477 |

9 | Radewoosh | 3437 |

10 | zh0ukangyang | 3423 |

# | User | Contrib. |
---|---|---|

1 | Um_nik | 185 |

2 | awoo | 182 |

3 | nor | 172 |

4 | -is-this-fft- | 170 |

5 | adamant | 169 |

6 | maroonrk | 165 |

7 | antontrygubO_o | 160 |

8 | SecondThread | 158 |

9 | dario2994 | 151 |

9 | kostka | 151 |

Hi ,

I cant think of a O(n) solution for this problem

Can anyone pls give me a hint ?

Thanks

I am having a little difficulty in understanding how the values are inserted into the TreeMap in a sorted order. Take a look at this code in a class that implements comparable

public int compareTo(STR other)

{

if(this.val==other.val) return this.team.compareTo(other.team);

return this.val>other.val?-1:1;

}

I dont understand why -1 is returned when this.val>other.val (The problem requires that the objects be sorted in decreasing order of values). Also, what is returned by

return this.team.compareTo(other.team) /* team is a String data

Also, the method compareTo is not called anywhere. So,where do the above return statements go to ? Does this occur implicitly whenever values are inserted into the TreeMap? Thanks for the help.

I am new to Dynamic programming and i came across this problem. I couldn't come up with a proper state for this problem. Can you please help me ?? The problem is as follows:

Suppose you are given three strings of English letters X = x1x2…xm, Y = y1y2…ym, Z = z1z2…zm+n. The string Z is a shuffle of X and Y if and only if Z can be formed by interspersing the characters from X and Y in a way that preserves the left-to-right ordering of the characters from X and Y respectively. For example, cchocohilaptes is a shuffle of chocolate and chips, but chcccochilatspe is not.

Find a DP algorithm to determine whether Z is a shuffle of X and Y .

LCS(s1--p, t1--q) = 1+ LCS(s1--p-1, t1--q-1) if s[p]=t[q]

0 otherwise

This was the solution given in wikipedia... This would give an answer of 0 for the strings "to" and "tom" ... But, shouldnt it be 2 ?? the "to" matches with "to" in tom . But, it compares only the last character and gives the answer`

Can someone tell me on what basis you decide that a naive solution will cause time exceeded error ? I have faced this problem quite a few times.

Hi, guys ... This is my first blog ... I am completely new to algorithms ... I have just taken it up and I really love it ... I love searching for puzzles each day and try solving them... right now, i am very bad at it ... I hope to improve ASAP and be good one day ... cheers... A problem for u all so that u dont get bored ;)

You are given a set S of n numbers. You must pick a subset S' of k numbers from S such that the probability of each element of S occurring in S' is equal (i.e., each is selected with probability k/n). You may make only one pass over the numbers. What if n is unknown?

Codeforces (c) Copyright 2010-2023 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/02/2023 04:42:49 (g2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|