LeetCode 1156. Swap For Longest Repeated Character Substring in Java

In this post we will solve the LeetCode 1156. Swap For Longest Repeated Character Substring problem using the Java programming language.

You are given a string text. You can swap two of the characters in the text.

Return the length of the longest substring with repeated characters.

Constraints:

o 1 <= text.length <= 2 * 10^4
o text consist of lowercase English characters only.

Related Topics:

o String
o Sliding Window

We are given a string of English lowercase characters and we can swap two characters once in order to return the longest count of consecutive characters. Continue reading “LeetCode 1156. Swap For Longest Repeated Character Substring in Java”

Permutation in String

Good morning! Hope you had a nice weekend. My wife and I did. We did some shopping, visited our son, and baked. For some reason last winter we did little baking. Yesterday morning after completing a two-hour block in my home office, I went up, prepared coffee and sat with my wife to chat. The subject of baking came up. Baking is both knowledge and art. In general when cooking or baking we tend not to follow recipes. Yesterday we collected the ingredients for raisin cinnamon bread around 09:00 AM. I got the dough ready around 10:00 AM. The dough proofed for a few hours and early afternoon, while my wife was preparing an avocado with tomatoes and roast beef salad, I buttered four bread molds, poured in the bread batter, waited for about 15 minutes (should be  an hour), and baked the cinnamon raisin bread. It turned out very good, but next week, I will let the bread proof for an hour in the molds. While the bread was still hot, we had two slices each with soft butter and grape jelly made by our daughter in law. It was delicious and to be honest with you, it does not require much work. Continue reading “Permutation in String”

Longest Substring without Repeating Characters

Good day ladies and gentlemen. It is Monday and I am taking this week off from work. I have not taken enough days off so for health reasons I have to take of this week. That said, if I am called to solve and issue I will be available. I am spending the entire week at home.

Today my wife was preparing lunch. She noticed some zucchini in the refrigerator and decided to prepare them stuffed. It is funny that after my wife and I got married, she asked my mother for her recipe on several occasions. The reason is that at my parent’s house, when zucchini were in season they were the first plate for lunch at least once a week. I really liked them the way my Nona and mother prepared them. My mother did not pass on the recipe. Good thing that my wife and I cook. We are on our way to a better recipe. Will let you know when we achieve the goal. Continue reading “Longest Substring without Repeating Characters”