
leetcode
ljz2015301785
这个作者很懒,什么都没留下…
展开
-
面试题 02.06. 回文链表
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def isPalindrome(self, head: ListNode) -> bool: cur = head result = [] whi.原创 2021-06-20 23:20:00 · 215 阅读 · 0 评论 -
160. 相交链表
# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode: curA = hea...原创 2021-06-20 23:18:57 · 225 阅读 · 0 评论 -
338. 比特位计数
class Solution: def countBits(self, n: int) -> List[int]: result = [] for i in range(0,n+1): result.append(list(bin(i)).count("1")) return result原创 2021-06-20 23:17:51 · 125 阅读 · 0 评论 -
面试题 16.06. 最小差
class Solution: def smallestDifference(self, a: List[int], b: List[int]) -> int: a.sort() b.sort() result = 2147483647 i = 0 j = 0 while (i < len(a) and j < len(b)): result = min(r...原创 2021-06-20 23:16:39 · 119 阅读 · 0 评论 -
面试题 01.02. 判定是否互为字符重排
class Solution: def CheckPermutation(self, s1: str, s2: str) -> bool: if len(s1) > len(s2): sum = s1 else: sum = s2 for i in sum: #print(i) if ...原创 2021-06-18 15:57:46 · 124 阅读 · 0 评论 -
面试题 01.01. 判定字符是否唯一
class Solution: def isUnique(self, astr: str) -> bool: for i in astr: if astr.count(i) == 1: continue else: return False return True原创 2021-06-18 15:53:29 · 104 阅读 · 0 评论