File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 492
492
1833|[ Maximum Ice Cream Bars] ( ./1833-maximum-ice-cream-bars.js ) |Medium|
493
493
1880|[ Check if Word Equals Summation of Two Words] ( ./1880-check-if-word-equals-summation-of-two-words.js ) |Easy|
494
494
1886|[ Determine Whether Matrix Can Be Obtained By Rotation] ( ./1886-determine-whether-matrix-can-be-obtained-by-rotation.js ) |Easy|
495
+ 1910|[ Remove All Occurrences of a Substring] ( ./1910-remove-all-occurrences-of-a-substring.js ) |Medium|
495
496
1920|[ Build Array from Permutation] ( ./1920-build-array-from-permutation.js ) |Easy|
496
497
1929|[ Concatenation of Array] ( ./1929-concatenation-of-array.js ) |Easy|
497
498
1935|[ Maximum Number of Words You Can Type] ( ./1935-maximum-number-of-words-you-can-type.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 1910. Remove All Occurrences of a Substring
3
+ * https://leetcode.com/problems/remove-all-occurrences-of-a-substring/
4
+ * Difficulty: Medium
5
+ *
6
+ * Given two strings s and part, perform the following operation on s until all occurrences of
7
+ * the substring part are removed:
8
+ * - Find the leftmost occurrence of the substring part and remove it from s.
9
+ *
10
+ * Return s after removing all occurrences of part.
11
+ *
12
+ * A substring is a contiguous sequence of characters in a string.
13
+ */
14
+
15
+ /**
16
+ * @param {string } s
17
+ * @param {string } part
18
+ * @return {string }
19
+ */
20
+ var removeOccurrences = function ( s , part ) {
21
+ while ( s . includes ( part ) ) {
22
+ s = s . replace ( part , '' ) ;
23
+ }
24
+ return s ;
25
+ } ;
You can’t perform that action at this time.
0 commit comments