113th LeetCode Weekly Contest Largest Time for Given Digits
Given an array of 4 digits, return the largest 24 hour time that can be made.
The smallest 24 hour time is 00:00, and the largest is 23:59. Starting from 00:00, a time is larger if more time has elapsed since midnight.
Return the answer as a string of length 5. If no valid time can be made, return an empty string.
Example 1:
Input: [1,2,3,4]
Output: "23:41"
Example 2:
Input: [5,5,5,5]
Output: ""
Note:
- A.length == 4
- 0 <= A[i] <= 9
给四个数字,组合成时间看得到的最大值是多少
全排列过去,把不符合规定的筛选掉就OK
class Solution {
public:
    string largestTimeFromDigits(vector<int>& A) {
        int x[];
        for(int i=;i<;i++){
            x[i]=A[i];
        }
        string u = "";
        sort(x,x+);
        do{
            if(x[]>=){
            continue;
            }
            if(x[]==){
                if(x[]>){
                    continue;
                }
            }
            if(x[]>=){
                continue;
            }
            int H,M;
            u = "";
            u += to_string(x[]);
            u += to_string(x[]);
            u +=':';
            u += to_string(x[]);
            u += to_string(x[]);
            cout<<u<<endl;
            cout<<x[]<<" "<<x[]<<" "<<x[]<<" "<<x[]<<endl;
        }while(next_permutation(x,x+));
        return u;
    }
};
113th LeetCode Weekly Contest Largest Time for Given Digits的更多相关文章
- 119th LeetCode Weekly Contest Largest Perimeter Triangle
		Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, ... 
- 113th LeetCode Weekly Contest Reveal Cards In Increasing Order
		In a deck of cards, every card has a unique integer. You can order the deck in any order you want. ... 
- 113th LeetCode Weekly Contest Flip Equivalent Binary Trees
		For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left a ... 
- LeetCode Weekly Contest 8
		LeetCode Weekly Contest 8 415. Add Strings User Accepted: 765 User Tried: 822 Total Accepted: 789 To ... 
- leetcode weekly contest 43
		leetcode weekly contest 43 leetcode649. Dota2 Senate leetcode649.Dota2 Senate 思路: 模拟规则round by round ... 
- LeetCode Weekly Contest 23
		LeetCode Weekly Contest 23 1. Reverse String II Given a string and an integer k, you need to reverse ... 
- Leetcode Weekly Contest 86
		Weekly Contest 86 A:840. 矩阵中的幻方 3 x 3 的幻方是一个填充有从 1 到 9 的不同数字的 3 x 3 矩阵,其中每行,每列以及两条对角线上的各数之和都相等. 给定一个 ... 
- LeetCode Weekly Contest
		链接:https://leetcode.com/contest/leetcode-weekly-contest-33/ A.Longest Harmonious Subsequence 思路:hash ... 
- 【LeetCode Weekly Contest 26 Q4】Split Array with Equal Sum
		[题目链接]:https://leetcode.com/contest/leetcode-weekly-contest-26/problems/split-array-with-equal-sum/ ... 
随机推荐
- 246. Strobogrammatic Number 上下对称的数字
			[抄题]: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at u ... 
- 37.ROUND() 函数
			ROUND() 函数 ROUND 函数用于把数值字段舍入为指定的小数位数. SQL ROUND() 语法 SELECT ROUND(column_name,decimals) FROM table_n ... 
- laravel查询最后执行的一条sql语句
- c++ 指向类成员函数的函数指针
			// ConsoleApplication34.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream& ... 
- SpringMVC——处理数据模型
			Spring MVC 提供了以下几种途径输出模型数据: ModelAndView: 处理方法返回值类型为 ModelAndView时, 方法体即可通过该对象添加模型数据 Map 及 Model: 入参 ... 
- C++ 中 dynamic_cast 浅析
			简述:dynamic_cast 操作符,将基类的指针或引用安全的转换为派生类的指针或引用.主要讲解,dynamic_cast操作符的原理.使用方式.编译器设置.返回值等相关知识. dynamic_ca ... 
- LightOJ 1027 A Dangerous Maze (数学期望)
			题意:你面前有 n 个门,每次你可以选择任意一个进去,如果xi是正数,你将在xi后出去,如果xi是负数,那么xi后你将回来并且丢失所有记忆,问你出去的期望. 析:两种情况,第一种是直接出去,期望就是 ... 
- HDU 3365 New Ground (计算几何)
			题意:给定点A[0~n-1]和B[0],B[1],A[0].A[1]映射到B[0].B[1],求出其余点的映射B[2]~B[n-1]. 析:运用复数类,关键是用模板复数类,一直编译不过,我明明能编译过 ... 
- 编写高质量代码改善C#程序的157个建议——建议55:利用定制特性减少可序列化的字段
			建议55:利用定制特性减少可序列化的字段 特性(attribute)可以声明式地为代码中的目标元素添加注释.运行时可以通过查询这些托管块中的元数据信息,达到改变目标元素运行时行为的目的.System. ... 
- UIImageView 动画
			1.UIImageView 动画 1.1 播放图片集 @property (nonatomic, strong) UIImageView *playImageView; self.playImageV ... 
