  We investigate the effect of radio-frequency interference (RFI) excision in
estimating the cosmological \hi\ 21 cm power spectrum. Flagging of
RFI-contaminated channels results in a non-uniform sampling of the instrumental
bandpass response. Hence, the Fourier transformation (FT) of visibilities from
frequency to delay domain contaminates the higher foreground-free delay modes,
and separating the spectrally fluctuating \hi\ signal from spectrally smooth
foregrounds becomes challenging. We have done a comparative analysis between
two algorithms, one-dimensional CLEAN and Least Square Spectral Analysis
(LSSA), which have been used widely to solve this issue in the literature. We
test these algorithms using the simulated SKA-1 low observations in the
presence of different RFI flagging scenarios. We find that in the presence of
random flagging of data, both algorithms perform well and can mitigate the
foreground leakage issue. But, CLEAN fails to restrict the foreground leakage
in the presence of periodic and periodic plus broadband RFI flagging and gives
an extra bias to the estimated power spectrum. However, LSSA can restrict the
foreground leakage for these RFI flagging scenarios and gives an unbiased
estimate of the \hi\ 21 cm power spectrum. We have also applied these
algorithms to the upgraded GMRT observation and found that both CLEAN and LSSA
give consistent results in the presence of realistic random flagging scenarios
for this observed data set. This comparative analysis demonstrates the
effectiveness and robustness of these two algorithms in estimating the \hi\ 21
cm power spectrum from the data set affected by different RFI scenarios.
