Is there a problem of yichud in an elevator?
One can be lenient for yichud in an elevator.
Please see below for more details.
Several authorities have ruled that yichud is only prohibited when a man and woman are secluded for the duration of five (five minutes) or more (see Iggros Moshe, Even Ha’ezer Vol. 4, no. 65, sec. 22; Minchas Yitzchak Vol. 4, no. 94), though other authorities mention shorter times (see Minchas Ish, Chap. 14, at length; he writes that one can certainly be lenient for less than one minute).
The Minchas Yitzchak discusses whether a prohibition of chatzi shiur (seclusion for a shorter time than this) can apply, and cites a debate between the Imrei Eishand the Maharil Diskin over the matter. However, Rav Shlomo Zalman Auerbach (Minchas Shlomo Vol. 1, no. 91; sec. 22) writes that there is certainly no prohibition of yichud for a very short time.
Yet, even opinions that mention a minimum time period for yichud agree that where the people involved are able to continue the yichud for a longer time, even momentary seclusion is prohibited (see Minchas Shlomo, loc. cit. Devar Halachah15:2).
Concerning yichud in an elevator, some authorities write that one should only be lenient in difficult circumstances (see Minchas Yitzchak, loc. cit.; Chelkas YaakovVol. 2, no. 14). In principle, however, based both on the short time period and on the fact that the elevator can be stopped at any floor by those wishing to enter, many authorities are lenient (Mishnah Halachos Vol. 4, no. 187; Tzitz Eliezer Vol. 6, no. 22, sec. 4; see Minchas Ish at length).
Nitei Gavriel 15:2 writes that this leniency will not apply late at night, when there is little chance that the elevator will be stopped.