hoang25's blog

By hoang25, history, 3 years ago, In English

Hello!

Today I have a problem. After a while, the problem turned into finding 3 elements with indice $$$i, j, k$$$ in an array $$$A$$$ of size $$$n$$$ that:

  • $$$1 ≤ i < j < k ≤ n$$$
  • $$$2 * j = i + k$$$
  • $$$n ≤ 2*10^5$$$
  • $$$A_i ≤ 10^9$$$

and $$$A_i + A_j + A_k$$$ is maximum possible!

I wonder if the problem can be solved in a way better than the naive $$$O(n ^ 2)$$$ solution. Thank guys!

Full text and comments »

  • Vote: I like it
  • +4
  • Vote: I do not like it

By hoang25, history, 3 years ago, In English

Hello guys, I'm having trouble with a problem.

Given an array A and a number k, find the k-th largest continuous subsequence! I can only think of a brute-force solution using prefix sum, which run in O(n ^ 2). In this problem n could be as large as 1e5. Can anyone give me a hint?

Thanks in advance!

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it