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

1 | tourist | 3911 |

2 | maroonrk | 3606 |

3 | MiracleFaFa | 3604 |

4 | Benq | 3583 |

5 | Radewoosh | 3545 |

6 | slime | 3486 |

7 | ecnerwala | 3457 |

8 | greenheadstrange | 3430 |

9 | sunset | 3338 |

10 | ksun48 | 3334 |

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

1 | YouKn0wWho | 213 |

2 | Monogon | 200 |

3 | Um_nik | 192 |

4 | awoo | 190 |

5 | -is-this-fft- | 184 |

6 | sus | 178 |

7 | Errichto | 176 |

8 | antontrygubO_o | 174 |

9 | SecondThread | 167 |

9 | maroonrk | 167 |

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-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jan/18/2022 01:09:56 (j2).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|