What is the number of ways to arrange people in a queue? People are standing in a queue when viewed from the front, m heads are visible, and n heads from the end. What is the number of possible arrangements such that m&n remains same when viewed from front and end respectively.
The number of people is P and it is not necessary that m+n=P
 A: At first let's ignore the peoples whose faces are visible from the end;
and assume that all faces are visible from front. 
By the above assumption;
if we only consider the place of peoples, then we have $(m+n)!$ possibilities. 

Notice that we have ${m+n \choose n}$ posibilities to choose the peoples;
whose faces are visible when they are viewed from front.
[We choose $n$ people and call them to turn their face away.]  

So we have ${m+n \choose n} \cdot (m+n)!$ posibilities.
A: Let $f(m,n,p)$ be the number of ways to order $p\;$people in a queue such that exactly $m\;$heads are visible from the front, and exactly $n\;$heads are visible from the back. 

If the heights are not pairwise distinct, knowing the values of $m,n,p\;$is not sufficient to find $f(m,n,p)$. 

For example, if there are exactly $t\;$people with max height, but all other heights are pairwise distinct, then
$$
f(1,2,5)=
\begin{cases}
6,&\text{if}\;\,t=1\\
11,&\text{if}\;\,t=2\\
5,&\text{if}\;\,t=3\\
1,&\text{if}\;\,t=4\\
0,&\text{if}\;\,t=5\\
\end{cases}
$$
More generally, if the heights are not required to be pairwise distinct, then to compute $f(m,n,p)$, you would need to know the exact multiplicities of the heights for each rank (shortest to tallest). It's not enough to just know $m,n,p$.

So let's assume the heights are pairwise distinct.

Then for positive integers $m,n,p$, we have
$$f(m,n,p) = \sum_{k=1}^p 
{\small{\binom{p-1}{k-1}}}
g({\small{m-1,k-1}})
g({\small{n-1,p-k}})
$$
where $g(m,p)$ is defined recursively, for nonnegative integers $m,p$, by
$$
g(m,p) =
\begin{cases}
0,\;\;\;\text{if}\;\,m>p\\[3pt]
0,\;\;\;\text{if}\;\,m = 0\;\;\text{and}\;\;p>0\\[3pt]
1,\;\;\;\text{if}\;\,m = 0\;\;\text{and}\;\;p=0\\[2.5pt]
{\displaystyle{\sum_{j=1}^p{\small{\binom{p-1}{j-1}}}g({\small{m-1,j-1}}){\small{(p-j)!}}}},\;\;\;\text{otherwise}\\
\end{cases}
$$
Some sample values . . .
\begin{align*}
f(2,3,4)&=3\\[4pt]
f(2,4,5)&=4\\[4pt]
f(3,4,6)&=10\\[4pt]
f(4,6,10)&=2016\\[4pt]
f(10,10,30)&=3046341296618108116828200\\[4pt]
\end{align*}
A: I interpret this to mean that you want to count the number of possible queues of a set of P people such that when viewed by some observer on the left (in the plane of the queue) there are $m$ visible heads and when viewed from the right there are $n$ visible heads.
Now, I am aware of your comment that states that the people need not have pairwise distinct heights, however I will solve (as @quasi has done) for the case where everyone in the queue has distinct heights. This will serve as a platform from which we can reach the "non-distinct heights" case.
To turn this into a combinatorial problem we will be counting permutations of $\{1,2,\ldots ,P\}$ such that there are $m$ integers which are greater than all those on their left and $n$ integers that are greater than all those on their right. So, for example one permutation of $\{1,2,3,4,5,6\}$ is
$$\require{enclose}\begin{array}{cccccc}
\enclose{circle}{2}&1&\enclose{circle}{5}&4&\enclose{roundedbox}{\enclose{circle}{6}}&\enclose{roundedbox}{3}\end{array}$$
where $\enclose{circle}{\phantom{5}}$ highlights a visible "head" from the left and $\enclose{roundedbox}{\phantom{5}}$ highlights a visible "head" from the right.
We can use generating functions to enumerate these. Let $x$ be the enumerator for visible heads from the left and $y$ be the enumerator for visible heads from the right then start by placing the largest integer in the set $\{1,2,\ldots , P\}$.
$$\begin{array}{ccc}\bullet&P&\bullet\end{array}$$
this possibility adds a single count to each $x$ and $y$ enumerator and therefore is represented by
$$xy$$
Next place the next largest integer $P-1$, this may go to the left of $P$, where it will add a count of $1$ to the $x$ enumerator, or to the right of $P$, where it will add a count of $1$ to the $y$ enumerator. Let's pick the left side:
$$\begin{array}{ccccc}\bullet&(P-1)&\bullet&P&\bullet\end{array}$$
This contributes a factor $(x+y)$ so our generating function so far is
$$xy(x+y)$$
Next place $P-2$. It may go to the left where it contributes $x$, right where it contributes $y$, or between $P$ and $P-1$ where it will contribute neither to the $x$ or $y$ enumerators. So in this last case it is represented by $1$. For arguments sake let's place $P-2$ to the right of $P$:
$$\begin{array}{ccccccc}\bullet&(P-1)&\bullet&P&\bullet&(P-2)&\bullet\end{array}$$
These possibilities contribute a factor $(1+x+y)$ to our generating function giving:
$$xy(x+y)(1+x+y)$$
The next integer to be placed is $P-3$ and this contributes $x$ if placed to the left of $P-1$, $y$ if placed to the right of $P-2$ or $1$ if placed at either of the $2$ positions in-between contributing a factor $(2+x+y)$ hence the generating function is now
$$xy(x+y)(1+x+y)(2+x+y)$$
as this pattern continues we get the required generating function which is a rising factorial
$$g_P(x,y)=xy(x+y)^{(P-2)}\tag{1}$$
so your desired result for the distinct height case is the $x^ny^m$ coefficient of $g_P(x,y)$.
The form of $(1)$ may look familiar to the generating function for Stirling Numbers of the First Kind and a simple expansion will show that
$$[x^ny^m]g_P(x,y)=\binom{n+m-2}{n-1}{P-1 \brack n+m-2}\tag{2}$$

A start on the non-distinct heights case
To generalise this to non-distinct heights we must know how many people of each height there are. In this case the problem is equivalent to permuting the multiset $\{1,1,\ldots , 1, 2,2,\ldots , 2,\ldots , P,P,\ldots ,P\}$ and counting those where n integers are greater than all those on their left and $m$ are greater than all those on their right. If their are $n_i$ occurrences of the integer $i$ in the multiset then we are permuting $N=\sum_{i=1}^{P}n_i$ integers.
The process is similar to before only this time at each stage the factor for the generating function will be (using a stars and bars argument):
$$\binom{n_{P-k}+\sum_{i=0}^{k-1}n_{P-i}-2}{n_{P-k}}+\binom{n_{P-k}+\sum_{i=0}^{k-1}n_{P-i}-2}{n_{P-k}-1}x+\binom{n_{P-k}+\sum_{i=0}^{k-1}n_{P-i}-2}{n_{P-k}-1}y+\binom{n_{P-k}+\sum_{i=0}^{k-1}n_{P-i}-2}{n_{P-k}-2}xy$$
and hence the generating function will be the product of these and the $xy$ term representing the single placement of the $n_P$ replicas of $P$
$$xy\times\prod_{k=1}^{P-1} \left(\binom{n_{P-k}+\sum_{i=0}^{k-1}n_{P-i}-2}{n_{P-k}}+\binom{n_{P-k}+\sum_{i=0}^{k-1}n_{P-i}-2}{n_{P-k}-1}x+\binom{n_{P-k}+\sum_{i=0}^{k-1}n_{P-i}-2}{n_{P-k}-1}y+\binom{n_{P-k}+\sum_{i=0}^{k-1}n_{P-i}-2}{n_{P-k}-2}xy\right)$$
