当前位置:网站首页>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 :
边栏推荐
- A laravel background management expansion package you can't miss - Voyager
- 防火墙基础之服务器区的防护策略
- [today in history] July 7: release of C; Chrome OS came out; "Legend of swordsman" issued
- 在软件工程领域,搞科研的这十年!
- Concurrency Control & NoSQL and new database
- 因员工将密码设为“123456”,AMD 被盗 450Gb 数据?
- KITTI数据集简介与使用
- Half an hour of hands-on practice of "live broadcast Lianmai construction", college students' resume of technical posts plus points get!
- 数据湖(九):Iceberg特点详述和数据类型
- JSON parsing instance (QT including source code)
猜你喜欢
CTFshow,信息搜集:web1
Notes HCIA
Five pain points for big companies to open source
Huawei cloud database DDS products are deeply enabled
Data connection mode in low code platform (Part 2)
什么是云原生?这回终于能搞明白了!
Notes de l'imprimante substance: paramètres pour les affichages Multi - écrans et multi - Résolutions
Niuke real problem programming - Day12
JSON解析实例(Qt含源码)
Novel Slot Detection: A Benchmark for Discovering Unknown Slot Types in the Dialogue System
随机推荐
数据湖(九):Iceberg特点详述和数据类型
Instructions for mictr01 tester vibrating string acquisition module development kit
asp.netNBA信息管理系统VS开发sqlserver数据库web结构c#编程计算机网页源码项目详细设计
Electronic remote error
Concurrency Control & NoSQL and new database
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
Niuke real problem programming - day13
Simple use of websocket
Mlgo: Google AI releases industrial compiler optimized machine learning framework
什么是云原生?这回终于能搞明白了!
CTFshow,信息搜集:web13
What is cloud primordial? This time, I can finally understand!
asp. Netnba information management system VS development SQLSERVER database web structure c programming computer web page source code project detailed design
拜拜了,大厂!今天我就要去厂里
buffer overflow protection
Bill Gates posted his resume 48 years ago: "it's not as good-looking as yours."
C# 6.0 语言规范获批
leetcode:648. Word replacement [dictionary tree board + find the shortest matching prefix among several prefixes]
2022 cloud consulting technology series high availability special sharing meeting
Half an hour of hands-on practice of "live broadcast Lianmai construction", college students' resume of technical posts plus points get!