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. ubuntu下mysql安装提供外网访问

    修改配置文件 1. sudo apt-get install mysql-server #安装mysql服务器 2. sudo apt-get install  mysql-client #安装mys ...

  2. HihoCoder 1075 开锁魔法III(概率DP+组合)

    描述 一日,崔克茜来到小马镇表演魔法. 其中有一个节目是开锁咒:舞台上有 n 个盒子,每个盒子中有一把钥匙,对于每个盒子而言有且仅有一把钥匙能打开它.初始时,崔克茜将会随机地选择 k 个盒子用魔法将它 ...

  3. sync-settings(vscode)

    vscode插件以及设置 sync-download e45c6db33cd91d661e0cc545efb6817c

  4. cv.Mat 与 .txt 文件数据的读写操作

    1.按OpenCV格式实现的 .txt 文件读写 可以用 cvSave 和 cvLoad 实现,格式和 .xml/.yml 的差不多,不过如果专用与 OpenCV 的数据读写,还是用  .xml/.y ...

  5. win32鼠标和键盘相关函数

    键盘相关函数:http://msdn.microsoft.com/en-us/library/windows/desktop/ms645530%28v=vs.85%29.aspx 鼠标相关函数:htt ...

  6. BW数据加载

    BW数据加载的优先级   1.主数据属性的加载 步骤图  从下到上 1)运行InfoPackage加载到PSA 找到主数据属性的InfoPackage,双击  点击Start按钮  点击监视器,查看运 ...

  7. Matlab 之 FFT的理解和应用

    网上看了一些大牛的关于FFT的见解,加上自己的一点儿理解,针对以下这几个问题来加深对FFT的理解. 不知道大家有没有类似以下几点的困惑: 问题的提出 对于1秒钟输出的连续信号,使用采样率Fs不同,就会 ...

  8. Windows Driver Kit Version 7.1.0 ( 也就是 7600.16385.1 ) 下载地址

    Windows Driver Kit Version 7.1.0 ( 也就是 7600.16385.1 ) 下载地址 http://download.microsoft.com/download/4/ ...

  9. redis底层数据结构--简单动态字符串 链表 字典 跳跃表 整数集合 压缩列表

    1.动态字符串 redis中使用c语言的字符床存储字面量,默认字符串存储采用自己构建的简单动态字符串SDS(symple dynamic string) redis包含字符串的键值对都是用SDS实现的 ...

  10. struts2学习(11)struts2验证框架1.验证简介、内置验证

    一.Struts2验证简介: 二.struts2内置验证: 下面例子,需求是:为用户注册进行验证: com.cy.model.User.java: package com.cy.model; publ ...