From 8998c834e5ebf1c932131abac84c6c017b5331b6 Mon Sep 17 00:00:00 2001 From: Abhishek Tripathi <42455093+abhishektripathi66@users.noreply.github.com> Date: Mon, 23 Sep 2024 22:12:27 +0530 Subject: [PATCH] Create RemovStars.java --- Leetcode/RemovStars.java | 58 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Leetcode/RemovStars.java diff --git a/Leetcode/RemovStars.java b/Leetcode/RemovStars.java new file mode 100644 index 0000000..f89896a --- /dev/null +++ b/Leetcode/RemovStars.java @@ -0,0 +1,58 @@ +/** +2390. Removing Stars From a String +Solved +Medium +Topics +Companies +Hint +You are given a string s, which contains stars *. + +In one operation, you can: + +Choose a star in s. +Remove the closest non-star character to its left, as well as remove the star itself. +Return the string after all stars have been removed. + +Note: + +The input will be generated such that the operation is always possible. +It can be shown that the resulting string will always be unique. + +**/ + +class Solution { + public String removeStars(String s) { + Stack st = new Stack<>(); + for(int i=0;i