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 pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy