791. Custom Sort String | leetcode daily challenge | DSA | Shashwat Tiwari Hindi

Поделиться
HTML-код
  • Опубликовано: 22 авг 2024
  • Problem Name:
    791. Custom Sort String
    Problem Statement:
    You are given two strings order and s. All the characters of order are unique and were sorted in some custom order previously.
    Permute the characters of s so that they match the order that order was sorted. More specifically, if a character x occurs before a character y in order, then x should occur before y in the permuted string.
    Return any permutation of s that satisfies this property.
    Problem link:
    www.geeksforge...
    Java Plus DSA Placement Course Playlist:
    • Java and DSA Course Pl...
    Java Plus DSA Sheet:
    docs.google.co...
    Notes:
    github.com/Tiw...
    Telegram Link:
    shashwattiwari...
    Ultimate Recursion Series Playlist:
    • Recursion and Backtrac...
    Instagram Handle: (@shashwat_tiwari_st)
    shashwattiwari...
    Samsung Interview Experience:
    • I cracked Samsung | SR...
    Company Tags:
    Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
    Timestamp:
    0:00 - Introduction
    #ShashwatTiwari #coding​​ #problemsolving​ Leetcode,Faang Interviews,Fanng,maang,faang interview Problems,Leetcode by Shashwat Tiwari,Maang Interviews,Leetcode Shashwat, Leetcode 791, Leetcode 791 by Shashwat tiwari,Custom Sort String ,791. Custom Sort String ,791. Custom Sort String,Custom Sort String

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

  • @sakshiawadhiya7267
    @sakshiawadhiya7267 5 месяцев назад +1

    You are doing great..and also very good teacher.

  • @chiragsolanki1234
    @chiragsolanki1234 5 месяцев назад +1

    following you since last 10 days great efforts sir ❤❤❤

  • @narutodihargo
    @narutodihargo 5 месяцев назад +1

    Salute to your dedication Bhaiya

  • @a.k.technicalakt3087
    @a.k.technicalakt3087 5 месяцев назад

    Thank you sir

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

    Thank You Bhaiya for the beautiful contents :)

  • @ArunKumar-gx8iv
    @ArunKumar-gx8iv 5 месяцев назад

    simple and easy sol
    public String customSortString(String order, String s) {
    int [] cnt = new int[26];
    for (char c : s.toCharArray()) {
    cnt[c - 'a']++;
    }
    StringBuilder sb = new StringBuilder();
    for (char c : order.toCharArray()) {
    while (cnt[c - 'a'] > 0) {
    sb.append(c);
    cnt[c - 'a']--;
    }
    }
    for (int i = 0; i < 26; i++) {
    while (cnt[i] > 0) {
    sb.append((char)('a' + i));
    cnt[i]--;
    }
    }
    return sb.toString();
    }

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

    I am third one❤❤❤😂😂

  • @mbm.editzz
    @mbm.editzz 5 месяцев назад

    pls koi toposort se krke dedo

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

    bhaiya why are we using entryset here rather than keySet

  • @buddyehlers2930
    @buddyehlers2930 4 месяца назад

    😋 *promo sm*