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

边栏推荐
- PG basics -- Logical Structure Management (locking mechanism -- table lock)
- Attribute keywords ondelete, private, readonly, required
- Mlgo: Google AI releases industrial compiler optimized machine learning framework
- Decrypt the three dimensional design of the game
- Niuke real problem programming - Day9
- 暑期安全很重要!应急安全教育走进幼儿园
- Niuke real problem programming - Day10
- Read PG in data warehouse in one article_ stat
- ES日志报错赏析-trying to create too many buckets
- Bill Gates posted his resume 48 years ago: "it's not as good-looking as yours."
猜你喜欢

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

Applet directory structure

Pytorch model trains practical skills and breaks through the bottleneck of speed

Niuke real problem programming - day13

Instructions for mictr01 tester vibrating string acquisition module development kit

Introduction and use of Kitti dataset

Spatiotemporal deformable convolution for compressed video quality enhancement (STDF)

MicTR01 Tester 振弦采集模塊開發套件使用說明
![[Yugong series] go teaching course 005 variables in July 2022](/img/66/4265a06a98412bd2c88d8281caf06e.png)
[Yugong series] go teaching course 005 variables in July 2022

Webrtc audio anti weak network technology (Part 1)
随机推荐
The world's first risc-v notebook computer is on pre-sale, which is designed for the meta universe!
回归测试的分类
asp.netNBA信息管理系统VS开发sqlserver数据库web结构c#编程计算机网页源码项目详细设计
6、Electron无边框窗口和透明窗口 锁定模式 设置窗口图标
Full details of efficientnet model
《微信小程序-进阶篇》组件封装-Icon组件的实现(一)
Ian Goodfellow, the inventor of Gan, officially joined deepmind as research scientist
Data connection mode in low code platform (Part 2)
【服务器数据恢复】某品牌StorageWorks服务器raid数据恢复案例
word中删除一整页
Applet directory structure
一款你不容错过的Laravel后台管理扩展包 —— Voyager
Computer win7 system desktop icon is too large, how to turn it down
Find your own value
buffer overflow protection
Bill Gates posted his resume 48 years ago: "it's not as good-looking as yours."
Emqx 5.0 release: open source Internet of things message server with single cluster supporting 100million mqtt connections
Cocos creator direction and angle conversion
Navigation — 这么好用的导航框架你确定不来看看?
半小时『直播连麦搭建』动手实战,大学生技术岗位简历加分项get!