Theta Runtime of Nested for Loops
Yes, the running time is $O(U+n)$, assuming that each iteration of the inner loop takes $O(1)$ time.  The way to prove it: try to write down an expression for the running time, as a function of $U$ and $n$.  What did you get?  Now, see you can show that this expression is at most $c \cdot (U+n)$, for some constant $c$ that you get to specify.