当前位置:网站首页>Huawei machine test question: splicing URL
Huawei machine test question: splicing URL
2022-06-25 06:00:00 【JOEL-T99】
Scala Realization
Title Description :
- Given a url The prefix and url suffix , adopt , Division It needs to be connected as a complete url
- If there is no end of prefix or beginning of suffix /, Need automatic replenishment / Connector
- If both the end of the prefix and the beginning of the suffix are /, Need automatic weight removal
- constraint : Don't worry about the prefix URL Illegal situation
Input description :
- url Prefix ( A length less than 100 String ) url suffix ( A length less than 100 String )
Output description :
- After splicing url
Example
Input :
- /acm,/bb
Output :
- /acm/bb
Input :
- /abc/,/bcd
Output :
- /abc/bcd
Input :
- /acd,bef
Output :
- /acd/bef
Input :
- ,
Output :
- /
Code :
def main(args: Array[String]): Unit = {
// Get input
val urls = StdIn.readLine().split(",")
// Remove anomalies
if(urls.length == 0) {
println("/")
return
}
// relation url
val res = (urls.head + urls.last).replaceAll("/+","/")
// Output results
println(res)
}
边栏推荐
- Interface learning
- C simple operation mongodb
- What is flush software? Is it safe to open an account online?
- Grep command – powerful text search tool
- Uni app wechat applet customer service chat function
- Excel splits a worksheet into multiple worksheets according to conditions, and how to split multiple worksheets into independent tables
- The simplest way to tell you is to hash and not hash
- Tutorial 35 of SAP ui5 application development - how to deploy locally developed SAP ui5 applications to ABAP server for trial reading
- RT thread i/o device model and layering
- Semantic segmentation cvpr2019-advance: advantageous enterprise minimization for domain adaptation in semantic segmentation
猜你喜欢

Farewell to Lombok in 996
Technology Review: what is the evolution route of container technology? What imagination space is there in the future?

Interface learning

RT thread i/o device model and layering
What is SAP sup - Sybase unwired platform
The e-book "action guide for large organizations to further promote zero code application platform" was officially released!
Yunda's cloud based business in Taiwan construction 𞓜 practical school

No one reads the series. Source code analysis of copyonwritearraylist

Unsupervised domain adaptation in semantic segmentation:a review unsupervised domain adaptation in semantic segmentation: a review
SAP ui5 tutorial for beginners part XXVI - detailed steps for using OData service with mock server trial version
随机推荐
Pytorch- daily learning notes of some small functions involving training
Try with resource close resource flow
Understanding of process, thread, task queue, event loop, macro task, micro task, execution stack and other concepts in JS
Semantic segmentation cvpr2019-advance: advantageous enterprise minimization for domain adaptation in semantic segmentation
Simple student management system
Some common errors and solutions of using SAP ui5 to consume OData services
MySQL operation JSON
Jz-066- motion range of robot
PHP output (print) log to TXT text
ERDAS 9.2 installation tutorial
What are the reasons why most webmasters choose Hong Kong site group servers?
CVPR2021-Semi-supervised Domain Adaptation based on Dual-level Domain Mixing for Semantic Segmentati
Interface learning
What is SAP sup - Sybase unwired platform
Three tier architecture experiment
[untitled]
Go uses channel to control concurrency
Incorrect dependency of POM file
Leetcode sword finger offer question brushing - day 27
Introduction to MySQL test run test framework