leetcode334
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的更多相关文章
- LeetCode-334. Increasing Triplet Subsequence
Description: Given an unsorted array return whether an increasing subsequence of length 3 exists or ...
- [Swift]LeetCode334. 递增的三元子序列 | Increasing Triplet Subsequence
Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the ar ...
- leetcode334 递增的三元子序列
class Solution { public: bool increasingTriplet(vector<int>& nums) { //使用双指针: int len=nums ...
- leetcode探索中级算法
leetcode探索中级答案汇总: https://leetcode-cn.com/explore/interview/card/top-interview-questions-medium/ 1)数 ...
随机推荐
- 基于 od 窗口的anti
虽然 odadvance 这类的插件 , 使用驱动将 od 的窗口 进行 隐藏,使用enumwindow ,无法枚举到od的窗口, 但是依然可以 使用r3 的方法 , 对od 窗口检测 之后可以使用 ...
- 在crontab中执行shell脚本的问题
crontab中记录的编写比较简单,下面是一个示例: * * * /app/tpssapp/ftpsrc/tools/statTables/statTables.sh > /app/tpssap ...
- mysql update select 用法
之前用SqlServer , update语句对表进行更新:update a set a.xx= (select yy from b) ; 是可以的但是在mysql中,不能直接使用set select ...
- flask第十八篇——模板【2】
请关注公众号:自动化测试实战 上一节我们介绍了模板的基本使用方法,现在我们想一个问题,如果把index.html放到template文件夹下面的文件夹该怎么办呢?其实很容易,当文件夹结构如下图所示时: ...
- Sprint第一个冲刺(第一天)
一.Sprint介绍 我们这次的团队项目是做<餐厅到店点餐系统>APP版,暂时不是基于用户需求来做的,但后期会进行用户需求调查,完善我们的软件.现在正在做一些前期准备,在团队合作上还缺乏一 ...
- [转]使用tcpdump抓取HTTP包
tcpdump -XvvennSs 0 -i eth0 tcp[20:2]=0x4745 or tcp[20:2]=0x4854 0x4745 为"GET"前两个字母"G ...
- qqbot 配置
qqbot 配置 用起来还是挺方便的,使用 pip install qqbot 就可以. 不过找配置文件没注意,以为是在程序目前,原来是在 C:\Users\xxx.qqbot-tmp 目录. 插件可 ...
- 【转】一步一步教你在Ubuntu12.04搭建gstreamer开发环境
原文网址:http://blog.csdn.net/xsl1990/article/details/8333062 闲得蛋疼 无聊寂寞冷 随便写写弄弄 看到网上蛮多搭建gstreamer开 ...
- stl map一对多用法
// stlMap.cpp : Defines the entry point for the console application.//#pragma warning (disable : 478 ...
- "废物利用"也抄袭——废旧喷墨打印机和光驱DIY"绘图仪"
很长时间没有写博客,因为各种各样的事情占去大块时间,只有零碎时间偶尔在CSDN逛逛也偶尔回几个帖子.很久以前就看到一些光驱DIY雕刻机之类的,很是向往,最近这几天得闲就TB了一套Arduino UNO ...