250-RepeatNumberCompare Problem Statement For any two positive integers x and k we can make a new number denoted repeat(x, k) by concatenating k copies of x written in decimal. For example, repeat(1234,3) = 123412341234 and repeat(70,4) = 70707070. Y
# -*- coding: utf-8 -*- # 请使用迭代查找一个list中最小和最大值,并返回一个tuple from collections import Iterable def findMinAndMax(L): if len(L) == 0: return (None,None) if isinstance(L,Iterable) == True: min = L[0] max = L[0] for x in L: if x > max: max = x if x < min:
请使用迭代查找一个list中最小和最大值,并返回一个tuple: 要注意返回的值的类型是不是tuple def findMinAndMax(L): min=0 max=0 if len(L)==0: return tuple([None,None]) else: for i in L: for j in L: if i>=j: i=j min=i #找出最小值 for i in L: for j in L: if i<=j: i=j max=i #找出最大值 return tuple([min
项目中需要根据条件获取一些数据,但是如果条件相同的情况下,要去掉条件一样的并且某个值是最小的数据,留下的是最大值数据. 简单记录一下sql: --去重保留最大值那条 --Year和MCode一样的前提下的重复数据,只要Cu值最大的那条 select * from tbMonitorResults t from tbMonitorResults where Year = t.Year and MCode=t.MCode and Cu > t.Cu)
(1)oracle使用keep分析函数取最值记录 -- 取工资sal最大的雇员姓名及其工资,以及工资sal最少的雇员姓名及其工资 select deptno, empno, ename, sal, max(ename) keep(dense_rank FIRST order by sal) over (partition by deptno) as min_sal_man, max(sal) keep(dense_rank FIRST order by sal) over (partition