1. public class Solution
  2. {
  3. public bool IncreasingTriplet(int[] nums)
  4. {
  5. var len = nums.Length;
  6. if (len < )
  7. {
  8. return false;
  9. }
  10.  
  11. for (int i = ; i <= len - ; i++)
  12. {
  13. for (int j = i + ; j <= len - ; j++)
  14. {
  15. if (nums[i] < nums[j])
  16. {
  17. for (int k = j + ; k <= len - ; k++)
  18. {
  19. if (nums[j] < nums[k])
  20. {
  21. return true;
  22. }
  23. }
  24. }
  25.  
  26. }
  27. }
  28.  
  29. return false;
  30. }
  31. }

补充一个python实现:

  1. import sys
  2. class Solution:
  3. def increasingTriplet(self, nums: 'List[int]') -> bool:
  4. smaller = sys.maxsize
  5. small = sys.maxsize
  6. for num in nums:
  7. if num <= smaller:
  8. smaller = num
  9. elif num <= small:
  10. small = num
  11. else:
  12. return True
  13. return False

leetcode334的更多相关文章

  1. LeetCode-334. Increasing Triplet Subsequence

    Description: Given an unsorted array return whether an increasing subsequence of length 3 exists or ...

  2. [Swift]LeetCode334. 递增的三元子序列 | Increasing Triplet Subsequence

    Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the ar ...

  3. leetcode334 递增的三元子序列

    class Solution { public: bool increasingTriplet(vector<int>& nums) { //使用双指针: int len=nums ...

  4. leetcode探索中级算法

    leetcode探索中级答案汇总: https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/ 1)数 ...

随机推荐

  1. windows命令行工具

    winver 检查Windows版本 wmimgmt.msc 打开Windows管理体系结构(wmi) wupdmgr Windows更新程序 wscript Windows脚本宿主设置 write ...

  2. IIS反向代理/Rewrite/https卸载配置

    目标,使IIS具有类似与Nginx的功能,将指定域名的请求重定向到IIS内.IIS外.其他机器上的其他端口,并且实现https卸载功能 重点预告: 1.安装最新版urlrewrite(微软开发的)插件 ...

  3. Jmeter-JDBC Connection Configuration和JDBC Request注释

    1.JDBC Connection Configuration Variable Name--变量名,唯一值不可重复,给JDBC Request确定使用哪个配置 Max Number of Conne ...

  4. HihoCoder1164 随机斐波那契(概率DP)

    描述 大家对斐波那契数列想必都很熟悉: a0 = 1, a1 = 1, ai = ai-1 + ai-2,(i > 1). 现在考虑如下生成的斐波那契数列: a0 = 1, ai = aj + ...

  5. 揭示同步块索引(中):如何获得对象的HashCode

    转自:http://www.cnblogs.com/yuyijq/archive/2009/08/13/1545617.html 题外话:为了尝鲜,也兴冲冲的安装了Win7,不过兴奋之余却郁闷不已,由 ...

  6. Appium+python (3) 异常处理

    有时候定位时会发现无法定位到具体的元素,右侧元素定位处只告诉你这是一个网页视图: 点击里面的具体元素是无法选中的,船长的做法是回到App里点一下元素,再返回要定位的页面,重新点一下Device Scr ...

  7. 《selenium2 python 自动化测试实战》(20)——Selenium工具介绍

    (一)Selenium IDE Firefox的一个插件,有助于我们理解测试框架.在附加组件里搜索下载,一般搜的结果里前几个都不是,得点那个查看更多才行,找到这个: 安装以后浏览器工具栏会有: 安装好 ...

  8. Oracle数据库安装完成后相关问题的解决

    笔者一直以来都是使用公司服务器上的oracle数据库,突然一天公司服务器宕机了,项目无法访问数据库跟着瘫痪了,所以准备在自己的机器上安装一个oracle数据库. 从官网下载安装了oracle 11g后 ...

  9. 【DUBBO】Dubbo原理解析-Dubbo内核实现之SPI简单介绍

    Dubbo采用微内核+ 插件体系,使得设计优雅,扩展性强.那所谓的微内核+插件体系是如何实现的呢!大家是否熟悉spi(service providerinterface)机制,即我们定义了服务接口标准 ...

  10. js各种效果

    1.JavaScript 仿LightBox内容显示效果 2.固定高度的div,竖直方向出现滚动条,水平方向固定 http://www.jb51.net/css/109928.html <!do ...