Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- METHOD 1
- class Solution:
- def numSubseq(self, nums: List[int], target: int) -> int:
- nums.sort()
- n=len(nums)
- l,r=0,n-1
- while l<r:
- if nums[l]+nums[r]<tar:
- ans=ans+(r-l+1)+
- class Solution:
- def lengthOfLongestSubstring(self, s: str) -> int:
- vis=[False]*256
- l,r,res=0,0,0
- for r in range(len(s)):
- while vis[ord(s[r])]==True:
- vis[ord(s[l])]=False
- l+=1
- res=max(res,r-l+1)
- vis[ord(s[r])]=True
- return res
Add Comment
Please, Sign In to add comment