leetcode

Algorithm

1910. Remove All Occurrences of a Substring [Java solution]

문제설명 part, s 총 2개의 문자열이 주어진다. 문자열 s 에 포함되는 part의 존재가 없어질 때 까지 지우는 작업을 계속한다. 작업의 규칙은 하기와 같다. - 문자열 s 에서 가장왼쪽서부터 part 문자열을 포함하는 부분을 찾아서 해당 부분을 지운다. 문자열 s에서 문자열part 를 포함하지 않는 상태가 되면 s를 반환한다. 하위문자열 part는 분리되지 않고 문자열 순서 그대로 검사되어야한다. 예시 1 Input: s = "daabcbaabcbc", part = "abc" Output: "dab" Explanation: The following operations are done: - s = "daabcbaabcbc", remove "abc" starting at index 2, so s = ..

카테고리 없음

[Leetcode] 696. Count Binary Substrings

696. 이진 문자열 계산하기 Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively. Substrings that occur multiple times are counted the number of times they occur. 이진문자열이 주어지면 똑같은 개수의 0과 1로 이루어진 비어있지 않은 부분문자열을 리턴해여라. 그리고 0과 1의 부분문자열들은 연속하여 그룹지어져있다. 여러번 반복되는 부분문자열은 그들이 발생되는 횟수..

메론러버
'leetcode' 태그의 글 목록