time complexityMon, 06 Mar 2023

def body_splited_by_paywall return body if paywall_placeholder.blank? return body unless body.include?(paywall_placeholder) Nokogiri::HTML.fragment(%( #{body.split(paywall_placeholder)[0]} #{Grid::Core::Post::PAYWALL_PLACEHOLDER} )).to_html end

O(1) -------------------------- time complexity of the code: def body_with_paywall_placeholder return body unless body.include?(Grid::Core::Post::PAYWALL_PLACEHOLDER) Nokogiri::HTML.fragment(%( #{body.split(Grid::Core::Post::PAYWALL_PLACEHOLDER)[0]} <span class="paywall-placeholder">This is paywalled content</span> )).to_html end

Questions about programming?Chat with your personal AI assistant