Longest Repeating Character Replacement || NEETCODE 150

Поделиться
HTML-код
  • Опубликовано: 17 сен 2024

Комментарии • 11

  • @ayushlingayat3463
    @ayushlingayat3463 24 дня назад

    Time Complexity of Brute Force Approach is 0(n^3) and Space Complexity is 0(n)

  • @prathamgoel3386
    @prathamgoel3386 8 месяцев назад +1

    class Solution {
    public int characterReplacement(String s, int k) {
    int max = 0;
    int res = 0;
    int[] arr = new int[26];
    int i = 0;
    int j = 0;
    while (j < s.length()) {
    arr[s.charAt(j) - 'A']++;
    max = Math.max(max, arr[s.charAt(j) - 'A']);
    if (j - i + 1 - max > k) {
    arr[s.charAt(i) - 'A']--;
    i++;
    }
    res = Math.max(res, j - i + 1);
    j++;
    }
    return res;
    }
    }

  • @prathamgoel3386
    @prathamgoel3386 8 месяцев назад

    Time Complexity of Brute force approach is O(n^2).

  • @gomzysharma
    @gomzysharma 2 месяца назад

    1>1 is true? It's false 17:18 , she just copy, pasted the solution + very bad variable name choosen.

  • @Aayush-ho2gl
    @Aayush-ho2gl 5 месяцев назад +1

    i think you have just pasted up the optimised solution , you don't have proper understanding of solution , why it is working

    • @gomzysharma
      @gomzysharma 2 месяца назад

      true, just copy-pasted, i dont know what she is explaining, just mugging up the concepts and logics

  • @ankitraj2283
    @ankitraj2283 8 месяцев назад +1

    Day 17 Done✅✅

  • @pulkit194
    @pulkit194 8 месяцев назад

    done thanks 👍

  • @prathamgoel3386
    @prathamgoel3386 8 месяцев назад

    Brute Force Approach
    class Solution {
    private boolean isValid(String s, int k) {
    int[] arr = new int[26];
    int max = 0;
    for (char c : s.toCharArray()) {
    arr[c - 'A']++;
    max = Math.max(max, arr[c - 'A']);
    }
    return (s.length() - max)

  • @mayappapujari9259
    @mayappapujari9259 8 месяцев назад

    Done ✌✌

  • @shivam1gaur
    @shivam1gaur 5 месяцев назад

    DAY 17 DONE