1、题目描述

2、问题分析

暴力计算

3、代码

  int triangleNumber(vector<int>& nums) {
int res =;
if( nums.size() < )
return res; for( int i = ; i < nums.size() -; i++){
for( int j = i+; j < nums.size()-; j++){
for( int k = j +; k < nums.size(); k++){
if( isTri(nums[i], nums[j], nums[k]) )
res ++;
}
}
} return res; } bool isTri(int a ,int b, int c){
if( a+b<=c || b+c <= a || a+c<=b || a <= ||b <= ||c <= )
return false;
else
return true;
}

LeetCode题解之Valid Triangle Number的更多相关文章

  1. 【LeetCode】611. Valid Triangle Number 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/valid-tri ...

  2. LeetCode 611. 有效三角形的个数(Valid Triangle Number)

    611. 有效三角形的个数 611. Valid Triangle Number 题目描述 LeetCode LeetCode LeetCode611. Valid Triangle Number中等 ...

  3. Leetcode 之 Valid Triangle Number

    611. Valid Triangle Number 1.Problem Given an array consists of non-negative integers, your task is ...

  4. leetcode 611. Valid Triangle Number 、259. 3Sum Smaller(lintcode 918. 3Sum Smaller)

    这两个题几乎一样,只是说611. Valid Triangle Number满足大于条件,259. 3Sum Smaller满足小于条件,两者都是先排序,然后用双指针的方式. 611. Valid T ...

  5. LeetCode 题解 593. Valid Square (Medium)

    LeetCode 题解 593. Valid Square (Medium) 判断给定的四个点,是否可以组成一个正方形 https://leetcode.com/problems/valid-squa ...

  6. LeetCode Valid Triangle Number

    原题链接在这里:https://leetcode.com/problems/valid-triangle-number/description/ 题目: Given an array consists ...

  7. [LeetCode] Valid Triangle Number 合法的三角形个数

    Given an array consists of non-negative integers, your task is to count the number of triplets chose ...

  8. LeetCode 611. Valid Triangle Number有效三角形的个数 (C++)

    题目: Given an array consists of non-negative integers, your task is to count the number of triplets c ...

  9. 【leetcode】Valid Triangle Number

    题目: Given an array consists of non-negative integers, your task is to count the number of triplets c ...

随机推荐

  1. bower 和 npm 的区别

    前端技术和工程实践真的是突飞猛进啊,想当年,我这个半业余前端吭哧吭哧做页面的时候,哪有这么多东西可以用啊,现在先进到我都完全看不懂了.本文主要讲一下同是包管理器的bower和npm的差别. 主要也是在 ...

  2. Spring开发步骤

    1) 源码, jar文件:此处用的是spring-framework-3.2.5.RELEASE commons-logging-1.1.3.jar                日志 spring- ...

  3. mysql-unsha1:在未知密码情况下,登录任意MYSQL数据库

    摘要 这个POC用于在不知道明文密码的情况下对启用了密码安全认证插件(默认开启插件:mysql_native_password)的MYSQL数据库进行登录. 前提条件为: 1.为了获取到已知用户的ha ...

  4. 简单实现Spring框架--注解版

    自己写的Spring框架——简单实现IoC容器功能 前几天在网上看了篇帖子,是用xml的方式实现spring的ioc容器,觉得挺有意思的,这边自己试着用注解的形式造了一套轮子. 工程结构 codein ...

  5. 【转载】Java8 HashMap之tableSizeFor

    Java8对许多内置的容器进行了优化与拓展,其中对HashMap的改变尤其大.之后将进行总结. 最近在看HashMap的源码时,发现了里面好多很不错的算法,相比Java7从性能上提高了许多.其中tab ...

  6. .Net Core使用Socket与树莓派进行通信

    前言 去年买的树莓派一直放在抽屉里吃灰,前些阵子Debian 9发布,也不出意外的支持了树莓派. 于是重新拿出读卡器又重新了装上了Debian桌面版系统. 介绍 现在这个东西目前的程度只是了解一下Py ...

  7. .net开源项目整理

    整理一些平时收藏和应用的开源代码,方便自己学习和查阅 1.应用 nopcommerce,开源电商网站,开发环境asp.net mvc(未支持.net core),使用技术(autofac,ef,页面插 ...

  8. 15.C++-操作符重载、并实现复数类

    首先回忆下以前学的函数重载 函数重载 函数重载的本质为相互独立的不同函数 通过函数名和函数参数来确定函数调用 无法直接通过函数名得到重载函数的入口地址 函数重载必然发生在同一个作用域中 类中的函数重载 ...

  9. Java - "JUC" Semaphore源码分析

    Java多线程系列--“JUC锁”11之 Semaphore信号量的原理和示例 Semaphore简介 Semaphore是一个计数信号量,它的本质是一个"共享锁". 信号量维护了 ...

  10. SpringBoot阿里巴巴Fastjson的一些常用配置

    SpringBoot阿里巴巴Fastjson的一些常用配置 @Bean public HttpMessageConverters fastJsonHttpMessageConverters() { F ...