Content-Length: 1467 | pFad | http://github.com/fishercoder1534/Leetcode/pull/178.patch

thub.com From 37ce739e259f6ffbec0ae8c018dad7cdf1c86d6a Mon Sep 17 00:00:00 2001 From: Nedzhin Date: Mon, 26 Jun 2023 21:12:29 +0600 Subject: [PATCH] added 849 problem --- python3/849.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 python3/849.py diff --git a/python3/849.py b/python3/849.py new file mode 100644 index 0000000000..e026545d49 --- /dev/null +++ b/python3/849.py @@ -0,0 +1,44 @@ +seats = list(map(int, input().split(','))) + +maxi = 0 +temp= 0 +may_max =0 + +i=0 +if seats[0] == 0: + while seats[i] !=1: + may_max += 1 + i +=1 + +for j in range(i, len(seats)): + if seats[j] == 0: + temp +=1 + else: + maxi = max(maxi, temp) + temp = 0 + +print(max(may_max, temp, (maxi+1)//2)) + +# There is solution which is simulated to the leetcode + +# class Solution: +# def maxDistToClosest(self, seats: List[int]) -> int: +# maxi = 0 +# temp = 0 + +# may_max = 0 +# i = 0 +# if seats[0] == 0: +# while seats[i] !=1: +# i+=1 +# may_max += 1 + + +# for j in range(i, len(seats)): +# if seats[j] == 0: +# temp += 1 +# else: +# maxi = max(maxi, temp) +# temp = 0 +# return max(temp, may_max, (maxi+1)//2) + \ No newline at end of file








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/fishercoder1534/Leetcode/pull/178.patch

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy