## How to return all array permutations iteratively into a two-dimensional array?

I am trying to write a program that will iterate through all possible permutations of a String array, and return a two dimensional array with all the permutations. Specifically, I am trying to use a String array of length 4 to return a 2D array with 24 rows and 4 columns.

I have only found ways to print the Strings iteratively but not use them in an array. I have also found recursive ways of doing it, but they do not work, as I am using this code with others, and the recursive function is much more difficult.

For what I want the code to do, I know the header should be:

public class Permutation {      public String[][] arrayPermutation(String[] str)      {           //code to return 2D array      } } 

//I tried using a recursive method with heap’s algorithm, but it is very //complex with its parameters.

I am very new to programming and any help would be greatly appreciated.

## A two-dimensional Vandermonde-type system

Let $$p$$ be a prime, and suppose that $$a_1,\dotsc,a_n\in\mathbb F_p^\times$$. How large can an integer $$K$$ be given that the system
$$\sum_{k=1}^n a_k x_k^i y_k^j = 0,\quad 0\le i,j\le K$$ has a solution in the variables $$x_1,\dotsc,y_n\in\mathbb F_p$$ satisfying $$x_k\ne x_l$$ and $$y_k\ne y_l$$ whenever $$k\ne l$$?

This is a system of $$(K+1)^2$$ equations in $$2n$$ variables; thus, one can expect that having $$K>C\sqrt{n}$$ with a sufficiently large $$C$$ will force the variables to vanish, or at least to obey some strong relations. In other words, heuristically, for $$K>C\sqrt n$$ the system does not have a solution with the variables pairwise distinct. Is there a rigorous argument to support this heuristic? Has this problem ever been studied?

## Two-dimensional Range Minimum Query under a constraint

So, I have trouble understanding and solving the following question:

You are given a 2D array. Design an algorithm that, given two coordinates (each with two indexes ofc), returns the minimum in the rectangle between those coordinates. You know that the number of lines in that rectangle (of each query) is greater than $$\frac{n}{3}$$. Preparation time should be $$O(n^2)$$ and query time should be $$O(1)$$.