Calculating Time difference Between two Rows in Linux

16:45:51 10051  77845
16:45:51 10051   77845

16:46:52 10051  77846
16:46:53 10051   77846

Match the last PID then subtract second line time with first line.

Please help me with any command or script.

working in media company on a project OS: RHEl7

tried command:

awk 'function s(x){split($NF,t,":");return t[1]*60^2+t[2]*60+t[3]}{cur=s($NF);if(prev){diff=cur-prev};prev=cur;if(diff<0){print $1" has "diff*-1" second difference on "$NF}}'

no sucess yet

Try

awk '
function s(x)   {split (x, t, ":")
                 return t[1]*3600 + t[2]*60 + t[3]
                }

!NF             {next
                }

!MIN[$3]        {MIN[$3] = $1
                }

                {MAX[$3] = $1
                }

END             {for (m in MIN) print m " has " s(MAX[m]) - s(MIN[m]) " second difference."
                }
' file
77845 has 0 second difference.
77846 has 1 second difference.

Thanks alot it's worked, help me for my organization work..