当前位置: 首页 > news >正文

学校网站建设评比wordpress英文转中文

学校网站建设评比,wordpress英文转中文,9377传奇,虚拟主机怎么用有时候需要对某一组数组的数据进行判断是否 递增 的场景#xff0c;比如我在开发一些体育动作场景下#xff0c;某些肢体动作是需要持续朝着垂直方向向上变化#xff0c;那么z轴的值是会累增的。同理#xff0c;逆向考虑#xff0c;递减就是它的对立面。 下面是查找总结到…有时候需要对某一组数组的数据进行判断是否 递增 的场景比如我在开发一些体育动作场景下某些肢体动作是需要持续朝着垂直方向向上变化那么z轴的值是会累增的。同理逆向考虑递减就是它的对立面。 下面是查找总结到的所有方式如有补充可以评论区提出。 资料参考来源: Check if list is strictly increasing 1. zip() and all() Code: test_list [1, 4, 5, 7, 8, 10] # Using zip() and all() to # Check for strictly increasing list res all(i j for i, j in zip(test_list, test_list[1:])) print(fIs list strictly increasing ? : {res})Output: Is list strictly increasing ? : True时间复杂度: O(n), n是数组的长度。 2. reduce and lambda Code: import functoolstest_list [1, 4, 5, 7, 8, 10] res bool((lambda list_demo: functools.reduce(lambda i, j: j ifi j else 9999, list_demo) ! 9999)(test_list))print(fIs list strictly increasing ? : {res})Output: Is list strictly increasing ? : True时间复杂度: O(n), n是数组的长度。 3. itertools.starmap() zip() all() Code: import itertoolstest_list [1, 4, 5, 7, 8, 10] res all(itertools.starmap(operator.le, zip(test_list, test_list[1:])))print(fIs list strictly increasing ? : {res})Output: Is list strictly increasing ? : True时间复杂度: O(n), n是数组的长度。 4. sort() and extend() Code: test_list [1, 4, 5, 7, 8, 10] res False new_list [] new_list.extend(test_list) test_list.sort()if new_list test_list:res Trueprint(fIs list strictly increasing ? : {res})Output: Is list strictly increasing ? : True时间复杂度: O(nlogn), 这里是sort()的时间复杂度 5. Use stacks 栈是一种后进先出的数据结构(Last in, first out)。 Code: def is_strictly_increasing(lst):stack []for i in lst:if stack and i stack[-1]:return Falsestack.append(i)return Truetest_list [1, 4, 5, 7, 8, 10] print(is_strictly_increasing(test_list)) # Truetest_list [1, 4, 5, 7, 7, 10] print(is_strictly_increasing(test_list)) # False时间复杂度: O(n)原数组被遍历了一遍 空间复杂度: O(n)栈可能要存储全部的n个原数组元素 6. numpy() Code: import numpy as npdef is_increasing(lst):# Converting input list to a numpy arrayarr np.array(lst)# calculate the difference between adjacent elements of the arraydiff np.diff(arr)# check if all differences are positive# using the np.all() functionis_increasing np.all(diff 0)# return the resultreturn is_increasing# Input list test_list [1, 4, 5, 7, 8, 10]# Printing original lists print(Original list : str(test_list))result is_increasing(test_list)print(result) # True时间复杂度: O(n) 7. itertools.pairwise() and all() 这里面就等于使用 pairwise() 替代了之前的 zip(list, list[1:]) 。 Code: from itertools import pairwise# Function def is_strictly_increasing(my_list):# using pairwise method to iterate through the list and# create pairs of adjacent elements.# all() method checks if all pairs of adjacent elements# satisfy the condition i j, where i and j# are the two elements in the pair.if all(a b for a, b in pairwise(my_list)):return Trueelse:return False# Initializing list test_list [1, 4, 5, 7, 8, 10]# Printing original lists print(Original list : str(test_list))# Checking for strictly increasing list # using itertools pairwise() and all() method res is_strictly_increasing(test_list)# Printing the result print(Is list strictly increasing ? : str(res))Output: Original list : [1, 4, 5, 7, 8, 10] Is list strictly increasing ? : True时间复杂度: O(n)
http://www.w-s-a.com/news/729685/

相关文章:

  • 单位网站建设收费标准网上开店铺需要多少钱
  • 灯饰网站需要这么做申请域名的流程
  • 软件下载网站怎么赚钱wordpress减少数据库查询
  • 什么兼职网站可以做视频剪辑常见的推广平台有哪些
  • 网站开发是用html还是jsp设迹官网
  • 查公司信息的网站怎么学wordpress
  • 白银做网站长春一般建一个网站需要多少钱
  • 帮人做钓鱼网站的人网络推广培训职业学校
  • 淘宝客有必须做网站吗网站开发的形式有( )
  • 网站建设:上海珍岛网页版qq空间登录
  • 网站服务器ipteahouse wordpress主题
  • 深州市住房保障和城乡建设局网站做网站公司叫什么
  • 织梦网站转跳手机站注册公司代理记账费用
  • wordpress建站Pdf亚马逊aws在线观看
  • 做网站的外包公司有哪些WordPress调用json数据
  • 做网站网站怎么赚钱网站的建设及维护报告
  • 可以做效果图的网站东莞网站优化什么方法
  • 网站和软件的区别怎么做招生网站
  • 雄安免费网站建设电话如何做网站推广 求指点
  • 十大免费cad网站入口软件北京做网站建设价格
  • 建设一个公司网站要具备什么网页制作的专业
  • 东莞seo建站排名全包网站
  • 网站建设的基本步骤有哪些软件商店下载官方
  • 网站建设开发报告论文hao123上网从这里开始官方
  • 阿里云建网站费用徐州房产网
  • 网站统计分析平台做企业礼品的网站
  • 做可视化图表的网站wordpress批量导入tag
  • txt怎么做网站网站的链接结构包括
  • 适合平面设计师的网站网络营销专员的就业前景
  • 好订单网服装加工接单谷歌seo网站推广怎么做