当前位置:网站首页>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 :

边栏推荐
- Applet directory structure
- CTFshow,信息搜集:web14
- Zhiting doesn't use home assistant to connect Xiaomi smart home to homekit
- 2022年13个UX/UI/UE最佳创意灵感网站
- Read PG in data warehouse in one article_ stat
- 拜拜了,大厂!今天我就要去厂里
- Yyds dry goods inventory # solve the real problem of famous enterprises: cross line
- Niuke real problem programming - Day11
- EfficientNet模型的完整细节
- Base64 encoding
猜你喜欢

Promoted to P8 successfully in the first half of the year, and bought a villa!

电脑Win7系统桌面图标太大怎么调小

MySQL installation configuration 2021 in Windows Environment

上半年晋升 P8 成功,还买了别墅!

Pinduoduo lost the lawsuit, and the case of bargain price difference of 0.9% was sentenced; Wechat internal test, the same mobile phone number can register two account functions; 2022 fields Awards an

Used by Jetson AgX Orin canfd

防火墙基础之服务器区的防护策略

Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System

leetcode:648. 单词替换【字典树板子 + 寻找若干前缀中的最短符合前缀】

Leetcode one question per day (636. exclusive time of functions)
随机推荐
AWS学习笔记(三)
PAG体验:十分钟完成AE动效部署上线各平台!
Infinite innovation in cloud "vision" | the 2022 Alibaba cloud live summit was officially launched
Ascend 910 realizes tensorflow1.15 to realize the Minist handwritten digit recognition of lenet network
Five pain points for big companies to open source
Ian Goodfellow, the inventor of Gan, officially joined deepmind as research scientist
Cvpr2022 | backdoor attack based on frequency injection in medical image analysis
Ffmpeg --- image processing
在软件工程领域,搞科研的这十年!
Delete a whole page in word
Data connection mode in low code platform (Part 2)
C# 6.0 语言规范获批
FFmpeg----图片处理
Read PG in data warehouse in one article_ stat
"July 2022" Wukong editor update record
Es log error appreciation -maximum shards open
ES日志报错赏析-- allow delete
Navigation - are you sure you want to take a look at such an easy-to-use navigation framework?
Demis hassabis talks about alphafold's future goals
buffer overflow protection