Posts

Showing posts with the label Sliding Window

Substring Of Size Three with Distinct Characters LeetCode

 Problem Link: https://leetcode.com/problems/substrings-of-size-three-with-distinct-characters/ Solution: class Solution {     public int countGoodSubstrings(String s) {             ArrayDeque<Character>aa=new ArrayDeque<Character>();             if(s.length()<3){                 return 0;             }         else{             int count=0;             aa.addLast(s.charAt(0));              aa.addLast(s.charAt(01));              aa.addLast(s.charAt(02));             if(s.charAt(0)!=s.charAt(1) && s.charAt(1)!=s.charAt(2) && s.charAt(0)!=s.charAt(2)){                 count++;       ...