Leetcode-401. Binary Watch

CANoe UDS $27服务DLL生成实战:从工程配置到算法修改全流程 本文详细介绍了在Vector CANoe中为UDS(统一诊断服务)的$27安全访问服务生成定制化DLL(动态链接库)的全流程。从定位官方参考工程、配置Visual Studio开发环境,到深入解析核心的GenerateKeyEx函数接口,并重点演示了如何修改和实现自定义的种子-密钥安全算法,最终完成DLL的编译、部署与CANoe集成测试,为汽车电子诊断开发提供实战指导。 阅读详情

前言:为了后续的实习面试,开始疯狂刷题,非常欢迎志同道合的朋友一起交流。因为时间比较紧张,目前的规划是先过一遍,写出能想到的最优算法,第二遍再考虑最优或者较优的方法。如有错误欢迎指正。博主首发CSDN,mcf171专栏。这次比赛略无语,没想到前3题都可以用暴力解。

博客链接:mcf171的博客

——————————————————————————————

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).

Each LED represents a zero or one, with the least significant bit on the right.

For example, the above binary watch reads "3:25".

Given a non-negative integer n which represents the number of LEDs that are currently on, return all possible times the watch could represent.

Example:

Input: n = 1
Return: ["1:00", "2:00", "4:00", "8:00", "0:01", "0:02", "0:04", "0:08", "0:16", "0:32"]

Note:

  • The order of output does not matter.
  • The hour must not contain a leading zero, for example "01:00" is not valid, it should be "1:00".
  • The minute must be consist of two digits and may contain a leading zero, for example "10:2" is not valid, it should be "10:02".
这个题目因为数字范围有限,直接粗暴枚举就能解。 Your runtime beats 77.73% of java submissions.

public class Solution {
    public List<String> readBinaryWatch(int num) {
        
        List<String> result = new ArrayList<String>();
        
        for(int i = 0; i <= num; i ++){
            List<String> hours = constructResult(i,12);
            List<String> mins = constructResult(num - i, 60);
            for(String hour : hours)
                for(String min : mins){
                    StringBuilder sb = new StringBuilder(hour);
                    sb.append(":");
                    if(min.length() == 1) sb.append("0");
                    sb.append(min);
                    result.add(sb.toString());
                }
            
        }
        
        return result;
    }
    
    private List<String> constructResult(int posNum, int limit){
        List<String> record = new ArrayList<String>();
        
        for(int i = 0; i < limit; i ++){
            if(check(i,posNum)) record.add(i + "");
        }
        
        return record;
    }
    
    private boolean check(int num, int posNum){
        int count = 0;
        boolean flag = true;
        while(num !=0){
            if((num & 1) == 1)count ++;
            num = num>>> 1;
            if(count > posNum){flag = false; break;}
        }

        return count == posNum && flag;
        
    }
}




android osmdroid 加载常用离线地图格式(开源的在线地图) osmdroid是(几乎)完整/免费更换为Android MapView(v1 API)类。它还包括一个模块化的瓷砖供应商系统支持众多的在线和离线瓷砖来源和覆盖支持内置覆盖绘制图标,跟踪位置和形状。如果想在你项目中使用osmdroid,绝对是灵活度最高,不用申请百度,高德等的key。还有一堆规则要遵循。osmdroid可以支持多图层叠加,绘制自已的图层。离线加载常用地图格式zip,sqlite,. 阅读详情

相关推荐

告别手动标注!用ENVI Classic高效搞定高光谱图像语义分割标签(以农业/地物分类为例)

本文详细介绍了如何利用ENVI Classic实现高光谱图像的半自动化智能标注,特别针对农业和地物分类场景。通过光谱特征分析、智能标注技巧和MAT文件转换,显著提升标注效率和质量,助力AI模型训练。

weixin_28694169的博客 254

LeetCode 401. Binary Watch 解题报告

LeetCode 401. Binary Watch 解题报告

骆小坑的填坑之旅 3263

C# 进阶:打造WinForms中的动态交互式UserControl

本文深入探讨了如何在C# WinForms中创建动态交互式UserControl,以提升桌面应用的用户体验和代码复用性。通过剖析UserControl生命周期、事件体系,并结合一个可拖拽缩放的分割面板实战案例,详细讲解了鼠标键盘事件处理、自定义绘制、状态管理以及性能优化等核心技巧,帮助开发者封装复杂交互逻辑,打造专业级自定义控件。

weixin_29279153的博客 466

【Leetcode】401. Binary Watch

题目链接:https://leetcode.com/contest/5/problems/binary-watch/题目: A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED

业精于勤,荒于嬉 3231

PIV实验流场流速云图(MALAB contour函数用法)

clear;clc; for k=1:5 str1=['filename1']; str2=['filename2']; str3=['filename3']; str=eval(['str',num2str(k)]); load(str); [m n]=size(y); y=flipud(y); v=-v; x=x-x(1,...

Nick_Cui的博客 3233

LLM大模型基础知识【一】

大语言模型(LLM):是指在自然语言处理(Natural Language Processing,NLP)领域中的一类大模型,通常用于处理文本数据和理解自然语言。这类大模型的主要特点是它们在大规模语料库上进行了训练,以学习自然语言的各种语法、语义和语境规则。例如:GPT系列(OpenAI)、Bard(Google)、文心一言(百度)。视觉大模型:是指在计算机视觉(Computer Vision,CV)领域中使用的大模型,通常用于图像处理和分析。

lin_xi_xi的博客 2892

LeetCode 401. Binary Watch 题解(C++)

LeetCode 401. Binary Watch 题解(C++)题目描述 A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or on

prayyojay的博客 1448

深度学习——VGG16模型详解

1、网络结构 VGG16模型很好的适用于分类和定位任务,其名称来自牛津大学几何组(Visual Geometry Group)的缩写。 根据卷积核的大小核卷积层数,VGG共有6种配置,分别为A、A-LRN、B、C、D、E,其中D和E两种是最为常用的VGG16和VGG19。 介绍结构图: conv3-64 :是指第三层卷积后维度变成64,同样地,conv3-128指的是第三层卷积后维度变成128; input(224x224 RGB image) :指的是输入图片大小为224244的彩色图像,通道为

橙子的博客 12万+

LeetCode 401. Binary Watch

题目描述: A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least signif

rentiansky的专栏 351

YOLOv13改进策略【注意力机制篇】| ICASSP 2023 EMA 高效多尺度注意力,跨空间学习提高远距离建模依赖

ICASSP 2023 EMA 高效多尺度注意力在 YOLOv13 的接入实战:跨空间学习提升远距离依赖建模,含原理图解、完整代码、yaml 配置与实测参数量对比(ultralytics 8.3.63)。

qq_53329130的博客 941

FC7300 SPI MCAL配置引导

Example - QMI8A01z外设:Example - QMI8A01z外设:

舊梦的博客 264

LeetCode //C - 401. Binary Watch

【代码】LeetCode //C - 401. Binary Watch。

Made in Code 1246

机器人动力学仿真软件:V-REP (CoppeliaSim)_(15).仿真项目案例分析

通过以上几个具体的仿真项目案例,我们展示了如何在V-REP (CoppeliaSim)中进行二次开发,实现复杂的机器人动力学仿真任务。这些案例涵盖了六轴机械臂的运动学仿真、移动机器人的路径规划和避障、以及无人机的飞行控制和环境感知。每个项目都通过编写Lua脚本实现了对机器人模型的控制和任务执行,并通过仿真结果分析验证了算法的有效性和系统性能。希望这些案例能够为读者在实际项目中使用V-REP (CoppeliaSim)提供有益的参考和启发。

kkchenjj的博客 1303

leetcode 401. Binary Watch

沉寂了一周后,我又回来啦!在离开的一周里,我游览了天目湖、南山竹海、黄山、千岛湖、宋城、拙政园,经历了腿疼到一步都不能迈、扁桃体炎发烧等事件。现在一切都过去了,我逃避外面的火炉天气,悠然坐在凉席沙发上吹着电风扇,继续刷leetcode。 A binary watch has 4 LEDs on the top which represent the hours (0-11), and t

淡然坊 312

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Leetcode 401 Binary Watch

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit o

夜色之浓,莫过于黎明前的黑暗。 349

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

[LeetCode 401] Binary Watch

A binary watch has 4 LEDs on the top which represent thehours(0-11), and the 6 LEDs on the bottom represent theminutes(0-59). Each LED represents a zero or one, with the least significant bit on ...

ExcitedZhang的博客 144

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

leetcode 401. Binary Watch python

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit o

weixin_36908057的博客 310

LeetCode 401 Binary Watch

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit o

几百个测试用例一致通过 309

Leetcode Binary Watch 401

A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LED represents a zero or one, with the least significant bit on the

我心中有猛虎 细嗅蔷薇 420

【LeetCode】401. Binary Watch

问题描述问题链接:https://leetcode.com/problems/binary-watch/#/descriptionA binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).Each LE

墨染百城 376

【leetcode】【easy】401. Binary Watch​​​​​​​

401. Binary Watch A binary watch has 4 LEDs on the top which represent thehours(0-11), and the 6 LEDs on the bottom represent theminutes(0-59). Each LED represents a zero or one, with the least ...

lemonade13的博客 191

leetcode 401: Binary Watch

解题思路: 本题灯的个数,其实就是二进制位中1的个数。最简单的做法,遍历所有时间,如果hour和minute的二进制值中的1的个数满足要求,当前时间就是一个解元素。不过这种方法耗时较长。原题目:A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom rep

永远不要给自己找借口 459

[leetcode] 401. Binary Watch 解题报告

题目链接:https://leetcode.com/problems/binary-watch/ A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED repr

小榕流光的专栏 3779
上一篇: Leetcode-530. Minimum Absolute Difference in BST
下一篇: Leetcode-541. Reverse String II
K_W
K_W
博客等级 码龄14年 8粉丝 283原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值