-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
text2 #111
text2 #111
Conversation
Good Job!!! @KL2333Python homework:
|
Good Job!!! @KL2333Python homework:
|
27感觉BC都可以呀??
Good Job!!! @KL2333Python homework:
|
Good Job!!! @KL2333Python homework:
|
Bug 已经解决,现在题目总数可以识别为正确的108了哈 |
Good Job!!! @KL2333Python homework:
|
错好多.... |
Good Job!!! @KL2333Python homework:
|
Good Job!!! @KL2333Python homework:
|
Good Job!!! @KL2333Python homework:
|
Good Job!!! @KL2333Python homework:
|
Good Job!!! @KL2333Python homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
Pandas homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
Pandas homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
Pandas homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
Pandas homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
Pandas homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
Pandas homework:
|
Good Job!!! @KL2333Python homework:
Numpy homework:
Pandas homework:
|
Good Job!!! @KL2333 |
1 similar comment
Good Job!!! @KL2333 |
[434. Number of Segments in a String](https://leetcode.com/problems/number-of-segments-in-a-string/)class Solution:
def countSegments(self, s: str) -> int:
s=s.strip() # 清理空格
count=0 # 计数器初始化
c_ount=0
if len(s)==0: # 特殊情况
return 0
for char in s: # 循环遍历
if char != ' ': # 空格计数器reset情况
c_ount =0
continue # 同时跳出本次循环
c_ount+=1 # 空格计数器+1
if c_ount==1: # 对连续和普通空格均仅计数一次
count+=1
return count+1 # 空格计数器计数+1为段数 [1869. Longer Contiguous Segments of Ones than Zeros](https://leetcode.com/problems/longer-contiguous-segments-of-ones-than-zeros/description/)class Solution:
def checkZeroOnes(self, s: str) -> bool:
a=s.split('0') # 对s按0分段
b=s.split('1') # 对s按1分段
m1=max(len(c) for c in a) # 最长的1的长度
m2=max(len(c) for c in b) # 最长的0的长度
return m1>m2 # 返回两者最长长度的比较 [1784. Check if Binary String Has at Most One Segment of Ones](https://leetcode.com/problems/check-if-binary-string-has-at-most-one-segment-of-ones/description/)class Solution:
def checkOnesSegment(self, s: str) -> bool:
if len(s)==1: # 特殊情况
return 1
s=s.rstrip('0') # 清理末尾的'0'
if len(s.split('0'))==1: # 按'0'分割,段数为1即满足要求
return 1
else :
return 0 # 其它类型 [852. Peak Index in a Mountain Array](https://leetcode.com/problems/peak-index-in-a-mountain-array/description/)class Solution:
def peakIndexInMountainArray(self, arr: List[int]) -> int:
return arr.index(max(arr)) # 返回峰值的index [162. Find Peak Element](https://leetcode.com/problems/find-peak-element/description/)class Solution:
def findPeakElement(self, nums: List[int]) -> int:
if len(nums)<3: # 特殊情况短的直接判断
return nums.index(max(nums))
nums.insert(0,float('-inf')) # 前后插入负无穷辅助判断两端点
nums.append(float('-inf'))
for i in range(0,len(nums)-1): # 判断相邻三个的大小是否为峰型,由于之前在list前插入了元素,此时的index均要-1
if nums[i]<nums[i+1] and nums[i+1]>nums[i+2]:
return i |
愚钝如我,暂时放弃 |
@iphysresearch 可以记录了 |
@KL2333 也有同学遇到类型的情况:#137 (comment) 另外,答案可以互相抄哈。。。只要你找得到哈 |
Good Job!!! @KL2333Python homework:
Numpy homework:
Pandas homework:
|
完成Python扩展作业! |
No description provided.