public class Solution
{
public bool IncreasingTriplet(int[] nums)
{
var len = nums.Length;
if (len < )
{
return false;
} for (int i = ; i <= len - ; i++)
{
for (int j = i + ; j <= len - ; j++)
{
if (nums[i] < nums[j])
{
for (int k = j + ; k <= len - ; k++)
{
if (nums[j] < nums[k])
{
return true;
}
}
} }
} return false;
}
}

补充一个python实现:

 import sys
class Solution:
def increasingTriplet(self, nums: 'List[int]') -> bool:
smaller = sys.maxsize
small = sys.maxsize
for num in nums:
if num <= smaller:
smaller = num
elif num <= small:
small = num
else:
return True
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. phpcms tag页调用缩略图

    \phpcms\modules\content\tag.php 找到: 'title, description, url, inputtime, style' 改成:'title, thumb, de ...

  2. linux自学(三)之开启虚拟机

    上一篇:linux自学(二)之centos7镜像安装 前面都已经铺垫好了,下面就是开始安装镜像了,真正的开启一台linux机器. 点击开启此虚拟机,如图: 之后就是等待了,然后就是开始配置,首先如下图 ...

  3. spring mvc 思想

    目录 一.前言 二.spring mvc 核心类与接口 三.spring mvc 核心流程图 四.spring mvc DispatcherServlet说明 五.spring mvc 父子上下文的说 ...

  4. BZOJ1853 Scoi2010 幸运数字 【枚举+容斥】

    BZOJ1853 Scoi2010 幸运数字 Description 在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的“幸运号码”是十进制表示中只包含数字6和8的那些号 ...

  5. LOJ2609. NOIP2013 火柴排队 【树状数组】

    LOJ2609. NOIP2013 火柴排队 LINK 题目大意: 给你两个数列,定义权值∑i=1(ai−bi)^2 问最少的操作次数,最小化权值 首先需要发现几个性质 最小权值满足任意i,j不存在a ...

  6. 加密shell

    shc -v -r -T -f script-name >/dev/null 2>&1

  7. Hadoop常见错误问题及解决方法总结二

    问题导读:1.遇到问题该如何排除错误?2.看不到namenode的可能原因是什么?3.地址占用该如何解决?4.could only be replicatied to 0 nodes, instead ...

  8. scrapy模拟浏览器爬取验证码页面

    使用selenium模块爬取验证码页面,selenium模块需要另外安装这里不讲环境的配置,我有一篇博客有专门讲ubuntn下安装和配置模拟浏览器的开发 spider的代码 # -*- coding: ...

  9. LG1343 地震逃生

    题意 汶川地震发生时,四川**中学正在上课,一看地震发生,老师们立刻带领x名学生逃跑,整个学校可以抽象地看成一个有向图,图中有n个点,m条边.1号点为教室,n号点为安全地带,每条边都只能容纳一定量的学 ...

  10. win10安装.net3.5 报错解决

    在win10光盘里提取“microsoft-windows-netfx3-ondemand-package.cab”安装包 然后放在sxs目录 新建批处理...??Cls@ECHO OFFTITLE ...