当前位置:网站首页>Niuke real problem programming - day18
Niuke real problem programming - day18
2022-07-07 14:53:00 【weixin_ forty-five million seven hundred and fifty thousand fou】
Compile environment :c++
1、 Expression legal judgment
describe :
Write a piece of code , Judge one including '{','[','(',')',']','}' Whether the expression of is legal ( Pay attention to the legal rules in the sample .)
You can see a legal expression , The left and right parentheses must correspond to each other .
Given an expression A, Please return one bool value , Represents whether it is legal .
Algorithmic thought :
The title does not give a clear description , You can pass the test without considering the order of the left and right parentheses , Therefore, you only need to judge whether the number of left and right parentheses matches , Left bracket self addition 1, The right bracket is subtracted , If the last count is 0, Then it's legal .
The code part implements :
2、 Remove duplicate characters
describe :
Niuniu has a string of lowercase letters s, stay s There may be some repeated letters in . For example "banana" in , Letter 'a' And letters 'n' Three times and two times respectively .
But Niuniu doesn't like repetition . For the same letter , He just wants to keep the first appearance and delete the following letters . Please help Niuniu finish the right s The operation of .
Algorithmic thought :
Using character conversion ascii Code for the number of times each letter appears , When count is 0 when , Output the string element that appears for the first time .
3、 Fort attack
describe
After Rambo taught Timo , Then discuss the Yodel people with Timo , Talking about the Yodel people , Naturally, there is no shortage of one person , that It's heimerdinger ------ The greatest scientist in the history of the Yodel people . Timo said , Heimodinger has been thinking about a problem recently : Heimerdinger has three forts , The fort can attack at a distance of less than or equal to R The enemy of ( The distance between two points is the linear distance between two points , for example (3,0),(0,4) The distance between them is 5), If a fort can attack To the enemy , Then it will cause 1× The damage of . Heimerdinger put three forts on N*M On the dot in the square , And give the enemy Coordinates of . ask : How much damage will the enemy suffer ?
Algorithmic thought :
The topic has multiple sets of use case input , For each use case input , Record the point coordinates of the corresponding fort and the enemy , Calculate the distance between two points respectively and compare with the range of the fort .
The code part implements :
边栏推荐
- 电脑Win7系统桌面图标太大怎么调小
- What is the process of ⼀ objects from loading into JVM to being cleared by GC?
- 一款你不容错过的Laravel后台管理扩展包 —— Voyager
- 上半年晋升 P8 成功,还买了别墅!
- EMQX 5.0 发布:单集群支持 1 亿 MQTT 连接的开源物联网消息服务器
- PG基础篇--逻辑结构管理(锁机制--表锁)
- Substance painter notes: settings for multi display and multi-resolution displays
- 比尔·盖茨晒48年前简历:“没你们的好看”
- 激光雷達lidar知識點滴
- 8大模块、40个思维模型,打破思维桎梏,满足你工作不同阶段、场景的思维需求,赶紧收藏慢慢学
猜你喜欢
Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
电脑Win7系统桌面图标太大怎么调小
JSON解析实例(Qt含源码)
MicTR01 Tester 振弦采集模塊開發套件使用說明
How to enable radius two factor / two factor (2fa) identity authentication for Anheng fortress machine
Niuke real problem programming - day15
asp.netNBA信息管理系统VS开发sqlserver数据库web结构c#编程计算机网页源码项目详细设计
数据湖(九):Iceberg特点详述和数据类型
Spatiotemporal deformable convolution for compressed video quality enhancement (STDF)
随机推荐
比尔·盖茨晒48年前简历:“没你们的好看”
electron remote 报错
Webrtc audio anti weak network technology (Part 1)
关于后台动态模板添加内容的总结 Builder使用
MicTR01 Tester 振弦采集模块开发套件使用说明
Navigation — 这么好用的导航框架你确定不来看看?
CTFshow,信息搜集:web14
Computer win7 system desktop icon is too large, how to turn it down
华为云数据库DDS产品深度赋能
Ffmpeg --- image processing
什么是云原生?这回终于能搞明白了!
Used by Jetson AgX Orin canfd
Demis hassabis talks about alphafold's future goals
#yyds干货盘点# 解决名企真题:交叉线
Introduction and use of Kitti dataset
Jetson AGX Orin CANFD 使用
Five pain points for big companies to open source
Data connection mode in low code platform (Part 2)
KITTI数据集简介与使用
Es log error appreciation -- allow delete