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)数 ...
随机推荐
- windows命令行工具
winver 检查Windows版本 wmimgmt.msc 打开Windows管理体系结构(wmi) wupdmgr Windows更新程序 wscript Windows脚本宿主设置 write ...
- IIS反向代理/Rewrite/https卸载配置
目标,使IIS具有类似与Nginx的功能,将指定域名的请求重定向到IIS内.IIS外.其他机器上的其他端口,并且实现https卸载功能 重点预告: 1.安装最新版urlrewrite(微软开发的)插件 ...
- Jmeter-JDBC Connection Configuration和JDBC Request注释
1.JDBC Connection Configuration Variable Name--变量名,唯一值不可重复,给JDBC Request确定使用哪个配置 Max Number of Conne ...
- HihoCoder1164 随机斐波那契(概率DP)
描述 大家对斐波那契数列想必都很熟悉: a0 = 1, a1 = 1, ai = ai-1 + ai-2,(i > 1). 现在考虑如下生成的斐波那契数列: a0 = 1, ai = aj + ...
- 揭示同步块索引(中):如何获得对象的HashCode
转自:http://www.cnblogs.com/yuyijq/archive/2009/08/13/1545617.html 题外话:为了尝鲜,也兴冲冲的安装了Win7,不过兴奋之余却郁闷不已,由 ...
- Appium+python (3) 异常处理
有时候定位时会发现无法定位到具体的元素,右侧元素定位处只告诉你这是一个网页视图: 点击里面的具体元素是无法选中的,船长的做法是回到App里点一下元素,再返回要定位的页面,重新点一下Device Scr ...
- 《selenium2 python 自动化测试实战》(20)——Selenium工具介绍
(一)Selenium IDE Firefox的一个插件,有助于我们理解测试框架.在附加组件里搜索下载,一般搜的结果里前几个都不是,得点那个查看更多才行,找到这个: 安装以后浏览器工具栏会有: 安装好 ...
- Oracle数据库安装完成后相关问题的解决
笔者一直以来都是使用公司服务器上的oracle数据库,突然一天公司服务器宕机了,项目无法访问数据库跟着瘫痪了,所以准备在自己的机器上安装一个oracle数据库. 从官网下载安装了oracle 11g后 ...
- 【DUBBO】Dubbo原理解析-Dubbo内核实现之SPI简单介绍
Dubbo采用微内核+ 插件体系,使得设计优雅,扩展性强.那所谓的微内核+插件体系是如何实现的呢!大家是否熟悉spi(service providerinterface)机制,即我们定义了服务接口标准 ...
- js各种效果
1.JavaScript 仿LightBox内容显示效果 2.固定高度的div,竖直方向出现滚动条,水平方向固定 http://www.jb51.net/css/109928.html <!do ...