class ListNode:
def __init__(self, id, name ,father = None):
self.id = id
self.father = father
self.name = name
class Solution(object):
def deleteNode(self, node, id):
while node.id is not id:
node = node.father
node.id = node.father.id
node.father = node.father.father
class Solution:
def GetLeastNumbers_Solution(self, tinput, k):
n = len(tinput)
if k <= 0 or k > n:
return list()
start = 0
end = n - 1
mid = self.partition(tinput, start, end)
while k - 1 != mid:
if k - 1 > mid:
start = mid + 1
mid = self.partition(tinput, start, end)
elif k - 1 < mid:
end = mid - 1
mid = self.partition(tinput, start, end)
res = tinput[:mid+1]
# res.sort()
return res
def partition(self, numbers, low, high):
key = numbers[low]
while low < high:
while low < high and numbers[high] >= key:
high -= 1
numbers[low] = numbers[high]
while low < high and numbers[low] <= key:
low += 1
numbers[high] = numbers[low]
numbers[low] = key
return low
import threading
class Singleton:
_instance = None
lock = threading.Lock()
def __new__(cls, *args, **kwargs):
if cls._instance:
return cls._instance
else:
with cls.lock:
cls._instance = super().__new__(cls)
return cls._instance
def __init__(self, k):
self.k = k
def show_value(self):
print(self.k)
def show_id(cls):
print(id(cls))
c = Singleton(1)
c.show_value()
c.show_id()
d = Singleton(2)
d.show_value()
d.show_id()
(^|+?86|)1(3\d|4[5-9]|5[0-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}
Select s.sno,sname from s,sc,c where s.sno=sc.sno and c.cno=sc.cno and cname='Math'
Select s.sno,sname from s where sno not in
(Select s.sno from s,sc,c where s.sno=sc.sno and c.cno=sc.cno and cname='Math')