Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Remove Stars and Left Characters
00:00
5 left

Remove Stars and Left Characters

EasyPython

Problem

Given a string, remove all stars (*) and the character to their left; return the final string.

Implement remove_stars(s), where s is a string and the return value is the resulting string after processing every star from left to right. If a star has no character to its left, remove only the star.

Input and Output

  • Input: one string s
  • Output: a string with all required characters removed

Constraints

  • 1 <= len(s) <= 10^4
  • s contains only lowercase English letters and * characters
  • A star with no surviving character to its left removes only itself

Function Signature

def remove_stars(s):
Interviewer

Your question is Remove Stars and Left Characters. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.