Personally I am not very familiar with group theory and need some clarifications.
Let's look at $D_n$ and its longest elemements. According to OEIS A162206 the triangle begins:
$1$;
$1;2;1$;
$1;3;5;6;5;3;1$;
$1;4;9;16;23;28;30;28;23;16;9;4;1$; etc
As far as I understand the longest element of $D_n$, ($n\ge 2$) can be calculated as the number of uniqe numbers for each raw in the triangle: $2,6,12$. I hope I'm right here.
On the other hand, it seems to me that $2,6,12$ present the set of positive roots.
So, could you explain in a simple way why it is so?
Personally I'm confused by the definition of the longest element vs the rows of the table, for eg: $1,2,1$. Why we may call $1,2$ as an element in $D_n$ group? Sorry, may be for silly question.
Thank you for any clarification on that topic.
I don't think this question is silly, but it does get a few things confused, so let me try to sort some of that out.
First of all, if we write $a_{r,k}$ to denote the $k^\text{th}$ element of the $r^\text{th}$ row in this triangle, the connection to the Coxeter groups of type $D$ is that:
$$a_{r,k} = \#\left\{g\in D_r: \ell(g)=k-1\right\},$$
where $\ell$ is the usual length function on $D_r$ (with respect to simple reflections). The $-1$ is to fix the fact that we usually count $k=1,2,\dots$ but the group starts counting $0,1,\dots$ (because of course the identity element has length $0$).
Therefore, second: row $r$ having exactly $d$ elements means in a given row there is an element of length $d-1$, and no elements of length $d$, which happens if and only if the longest element has length $d-1$.
Third, from the comments: it is not possible from the data $\{a_r\}$ to read off the longest element. In particular, the rows of this triangle do not correspond to any group element— they count group elements with particular properties.
Fourth, it follows from general theory that if $w_0$ is the longest element in a finite Coxeter group, and it has length $d-1$, then the map $g\mapsto w_0g$ is a bijective correspondence between elements of length $k$ and elements of length $(d-1)-k$. In particular, this means that $a_{r,k}=a_{r,d-k}$, so the length of $w_0\in D_r$ is not (one less than) the number of distinct numbers in row $r$. In fact, these are the only repetitions, so there are $\frac{d}{2}$ distinct numbers in row $r$ (contrast with $d-1$, the length of the longest element $w_0\in D_r$)
Finally, perhaps the question you were trying to ask: it is a general fact about finite Coxeter groups that the length $\ell(g)$ is equal to the number of positive roots $\alpha$ such that $g\cdot\alpha$ is a negative root. I don't think there is a really intuitive reason for this in general; a formal argument is sketched by Michael Joyce in their comments on this answer, and they cite the place in Humphreys where one can find a complete proof. [Thanks to Jack Schmidt for finding this link.]
[Extended Aside: However, in type $A$ (that is, the symmetric group $S_{r+1}$) the length of an element is precisely the number of inversions of the element, considered as a permutation. This is intuitively reasonable since multiplying by a simple transposition should only produce one new inversion. Clearly the longest element as a permutation would be $(r+1)r\cdots 321$ in one-line notation, which has $\binom{r+1}{2}$ inversions, which equals the number of positive roots. Since type D also has combinatorial models, one could make a similar sort of argument with them, but it will probably be less fulfilling because we don't generally have the same kind of intuition about such models.]
In any case it's now easy to believe that the longest element probably is the one that flips the sign of all the roots, and thus has length that counts the positive roots. To make that believe rigorous requires another argument; again, unfortunately, I have never seen a particularly enlightening proof of it.