Determine if String Halves Are Alike | Screening Problem | Leetcode 1704

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

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

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 10 месяцев назад +4

    class Solution {
    public boolean halvesAreAlike(String s){
    int mid=s.length()/2;
    String fi=s.substring(0,mid);
    String se=s.substring(mid);
    int cntF=cntVowel(fi);
    int cntS =cntVowel(se);
    return cntF==cntS;
    }
    private int cntVowel(String t){
    int cnt=0;
    for(char c:t.toCharArray())
    if("AEIOUaeiou".indexOf(c)!=-1)
    cnt++;
    return cnt;
    }
    }
    tc=0(n);
    sc=0(n);
    👏🙏

  • @thekindspill
    @thekindspill 10 месяцев назад +2

    Please also post today's GFG POTD

  • @speedcode5795
    @speedcode5795 10 месяцев назад +1

    class Solution {
    public:
    bool isvowel(char ch)
    {
    return ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U';
    }
    bool halvesAreAlike(string s) {
    int i=0;
    int j=s.size()-1;
    int first=0;
    int second=0;
    while(i

  • @JagannathDebGunin
    @JagannathDebGunin 10 месяцев назад

    What is the time ans space complexity of both approaches can anyone please tell?

  • @beeramrahulreddy11
    @beeramrahulreddy11 Год назад +2

    Hi, which application u use for drawing?

    • @codestorywithMIK
      @codestorywithMIK  Год назад +4

      Hi beeram, i use the Default Note App in ipad 11 pro

  • @Stressful_Jindagi
    @Stressful_Jindagi 10 месяцев назад +1

    class Solution {
    public:
    int vowCnt(string strings){
    int cnt=0;
    for(auto str:strings){
    if(str=='a' || str=='e' || str=='i' || str=='o' || str=='u' || str=='A' || str=='E' || str=='O' || str=='U' || str=='I') cnt++;
    }
    return cnt;
    }
    bool halvesAreAlike(string s) {
    int n=s.length();
    if(n%2!=0) return false;
    int i=n/2;
    string s1=s.substr(0,i), s2=s.substr(n-i,i);
    if(vowCnt(s1)==vowCnt(s2)) return true;
    return false;
    }
    };
    Bhaiya isn't this good solution?

  • @thevagabond85yt
    @thevagabond85yt 10 месяцев назад

    2nd checks is while() is redundant :
    j = i+mid;
    public boolean halvesAreAlike(String s) {
    Set vowels = Stream.of('a','e','i','o','u','A','E','I','O','U')
    .collect(Collectors.toCollection(HashSet::new));
    int N = s.length(), vLeft = 0, vRight = 0;
    for(int i=0; i

  • @wearevacationuncoverers
    @wearevacationuncoverers Год назад +1

    Awesome

  • @aws_handles
    @aws_handles 10 месяцев назад

    Gfg potd please

  • @DevOpskagyaan
    @DevOpskagyaan 10 месяцев назад

    Thanks mik

  • @Algorithmswithsubham
    @Algorithmswithsubham 10 месяцев назад +3

    sir, itna easy question google meta microsoft jaisi company kyu puchti haii??,i don't get it

    • @codestorywithMIK
      @codestorywithMIK  10 месяцев назад +6

      Hi there,
      These are not the Qns which are asked in Face to face round. Most of the times these Qns are asked in phone interviews for screening only.
      Once you clear screening round, you then go to further rounds where they ask Medium-Hard problems.
      I remember I was once asked in a Phone interview that which DS i will use for BFS .
      (Please note that i have noticed the level of qns have increased in many companies)

    • @Ramneet04
      @Ramneet04 10 месяцев назад

      ​​@@codestorywithMIK Hey I am following you from last 3-4 months now doing evey question and more likely able to do medium easy just got difficulty in hard ones and did like 440 questions is it enough to crack the faang interviews ?? Not now I'll like start apply after 6-7 months. And doing continue my DSA , I'm a frontend developer will also complete my backend till the time??( For intern).

  • @souravjoshi2293
    @souravjoshi2293 10 месяцев назад +1

    😃Done

  • @faraz9641
    @faraz9641 10 месяцев назад

    Im able to solve easy to med problem (not like this one this was just a tp) but not med- hard. What do i do? 🥲🥲