LeetCode Problem | part 18 | DSA in python in telugu | Engineering Animuthyam

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

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

  • @nazeertheofficial
    @nazeertheofficial Месяц назад +10

    bro first time nenu ni help thisukokunda solve chesina bruteforcelo feel happy bro.😍😍.

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

    Bro super ga cheptunnav nak IT lo 2+ exp unna eppativaru chusina vallalo superb ra cheptunnav bro nen chala vedios chusa enta basic ga yevaru cheppaled bro..go head🎉 content kasta fast ga update cheyyi..

  • @thanmaikrishna9825
    @thanmaikrishna9825 Месяц назад +2

    So far the best bro…. Great explanation… daily serial la follow avtunna 😅

  • @Fruty-hr7fh
    @Fruty-hr7fh 21 день назад +1

    Macha nen single for loop tho chesina🥳
    li=[4,4,4,11,4,4,4,4,4,4]
    n=len(li)
    a=0
    b=n-1
    dist=0
    dist1=0
    for i in range(1,n):
    if li[a]!=li[i]:
    diff=abs(a-i)
    dist=max(dist,diff)
    if li[b]!=li[i]:
    diff1=abs(b-i)
    dist1=max(dist1,diff1)
    print(max(dist,dist1))
    Output: 6

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

    macha super ga cheptunav bayya please bayya ee series apaiku python ki reach ravtaledu ani 🥲🥲

  • @b.s.n.murthy8798
    @b.s.n.murthy8798 Месяц назад

    Arey broo.. nenu brute force radhamani alochincha but fortunately o(n) lo rayagaliga ... then ee video ki vachi chusthe nuvvu same nenu use chesina logic ey use chesav ... I'm Peeling great...

  • @SindhujaReddy-gw7fo
    @SindhujaReddy-gw7fo 12 дней назад

    class Solution:
    def maxDistance(self, colors: List[int]) -> int:
    n=len(colors)
    ans=0
    for i in range(n):
    for j in range(n-1,-1,-1):
    if colors[i]!=colors[j]:
    temp=abs(j-i)
    ans=max(ans,temp)
    return ans

  • @Maheshkrishna-p3b
    @Maheshkrishna-p3b 2 месяца назад

    colors = [4,4,4,11,4,4,11,4,4,4,4,4]
    for i in range(len(colors)-1,0,-1):
    if colors[i] != colors[0] :
    max_dis = i - 0
    break
    for i in range(len(colors)):
    if colors[i] != colors[ len(colors)-1 ] :
    max_dis1 = len(colors)-1 - i
    break
    print(max(max_dis,max_dis1))

  • @4750Ahamed
    @4750Ahamed Месяц назад

    *******Optimal way******
    l=[4,4,4,11,4,4,11,4,4,4,4,4]
    n=len(l)
    ans=0
    for i in range(0,n-1):
    if l[i]!=l[n-i-1]:
    temp=abs(i-(n-i))
    ans=max(ans,temp)
    return ans

  • @sagantyc.sharonlee128
    @sagantyc.sharonlee128 22 дня назад

    ""81 test cases passed using this code""
    class Solution:
    def maxDistance(self, colors: List[int]) -> int:
    ans=-1
    low=0
    for i in range(1,len(colors)):
    if low

  • @karthikphotoeditz5645
    @karthikphotoeditz5645 Месяц назад

    Nuvvu cheppinattu 20mins alochincha macha brootforce lo vachindi naku without seeing the video idi kuda naku chala happy machaa but optimal way lo raledu😢 so appudu video chusa machaa

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

    My solution
    First Approach:O(N sqaure)
    class Solution:
    def maxDistance(self, colors: List[int]) -> int:
    r=len(colors)
    maximum=0
    res=0
    for i in range(r):
    for j in range(r):
    if(colors[i]!=colors[j]):
    res=abs(i-j)
    maximum=max(maximum,res)
    return maximum
    Optimal code: O(N)
    class Solution:
    def maxDistance(self, colors: List[int]) -> int:
    r=len(colors)
    first=colors[0]
    last=colors[-1]
    Ans=0
    Ans1=0
    Ans2=0
    maxnum=0
    for i in range(r):
    if first!=last:
    Ans=r-1
    maxnum=Ans
    break;
    if first!=colors[i]:
    Ans1=max(Ans1,abs(i-0))
    maxnum=max(Ans2,maxnum)
    if last!=colors[i]:
    Ans2=max(Ans2,abs(i-(r-1)))
    maxnum=max(Ans2,Ans1)
    return maxnum

  • @bhanuvarma1239
    @bhanuvarma1239 Месяц назад

    Mawa on Fire🔥🔥

  • @vivekvardhanreddy8883
    @vivekvardhanreddy8883 Месяц назад

    anna naku ila chesthe answer vachindhi anni test cases kuda pass aindhi em kada (optimal method)
    colors=[1,1,1,6,1,1,1]
    ans=0
    n=len(colors)
    for i in range(n):
    if colors[0]!= colors[i] and i!=0:
    dif=abs(0-i)
    ans=max(ans,dif)
    if colors[i]!=colors[n-1]:
    dif=abs(i-(n-1))
    ans=max(ans,dif)
    print(ans)

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

    Bro please give us roadmap of your way of doing conding form 1st year and how did you become good in coding

    • @engineeringanimuthyam
      @engineeringanimuthyam  2 месяца назад +1

      I made a video on my journey in thid channel once chek it

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

      @@engineeringanimuthyam ok bro thanks

  • @abhilashreddymitta
    @abhilashreddymitta Месяц назад

    keep going macha

  • @lokeshreddy4148
    @lokeshreddy4148 2 месяца назад +1

    Bro explain hard problems bro

  • @Swajyoram
    @Swajyoram 2 месяца назад +1

    Bro nenu e question ki code mundhe solve chesa website lo question open chesi . Parledhu improve ayya 0 nuche antho kontha logic wise. Optimize solution kosam vacha bro eroju

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

      Ewwwww 🔥🔥🔥🔥

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

      Ela.rasa bro nenu logic 😊
      n=len(colors)
      ans=0
      for i in range(n):
      for j in range(1,n):
      if colors[j]>colors[i]:
      temp=abs(i-j)
      ans=max(temp,ans)
      return ans

    • @engineeringanimuthyam
      @engineeringanimuthyam  2 месяца назад +1

      Vere level 🔥🔥​@@Swajyoram