Need help in solving this sub 2 dimensional array problem.

Правка en13, от xinchengo, 2021-08-16 05:18:18

Hello everyone! I am here to ask you if there is any efficient way to solve this sub 2 dimensional array problem.

  • You are given a 2 dimensional array of integers $$$A_{n,n}$$$. there are $$$k$$$ different integers in this array. try to find out the smallest sub 2 dimensional array containing all kinds of integer.

Unlike the linear variant (where we can use a greedy method with two pointers to complete this task in $$$O(n)$$$ time, the problem is not that simple. So far, I have only found two optimizations based on the brute-force method. One is to use binary search method to find out the least size containing all kinds of integer. The other is while recording the times an integer appears in the subarray, updateing differences between each move rather than counting up again and again. After those optimizations, the time complexity of this method is $$$O(n^3\cdot \log^2 n)$$$, where we use $$$O(\log n)$$$ to binary search the size, $$$O(\ln n)$$$ to enumerate all possible width and height for each size, and $$$O(n^3)$$$ for each possible shape of a specific rectangle.

Since the linear variant can be solved in linear time, and with intuition that I thought the 2 dimesional version can be solved in square time. Is there a way to solve this problem in $$$O(n^2)$$$ time? If there is not, what is the lower bound of the time complexity to solve this problem?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en13 Английский xinchengo 2021-08-16 05:18:18 1 Mistake correction 4
en12 Английский xinchengo 2021-08-16 05:17:53 43 Reverted to en4
en11 Английский xinchengo 2021-08-14 16:51:14 43 Change 2
en10 Английский xinchengo 2021-08-14 09:21:12 0 Reverted to en6
en9 Английский xinchengo 2021-08-14 09:21:05 0 Reverted to en4
en8 Английский xinchengo 2021-08-14 09:20:51 1 Reverted to en6
en7 Английский xinchengo 2021-08-14 09:20:20 1 Reverted to en5
en6 Английский xinchengo 2021-08-14 07:44:18 1 Reverted to en4
en5 Английский xinchengo 2021-08-14 07:43:59 1 Change 1
en4 Английский xinchengo 2021-08-14 05:14:09 12 Mistake correction 3
en3 Английский xinchengo 2021-08-14 04:52:33 13 Mistake correction 2
en2 Английский xinchengo 2021-08-14 04:51:51 1 Mistake correction 1
en1 Английский xinchengo 2021-08-14 04:51:04 1416 Initial revision (published)