[Huawei OD machine test real questions] Splicing URL (java) 100% pass rate [2023 (Volume B) 100 points]

Splicing URLs

Question description

Given a URL prefix and URL suffix
, the split needs to be connected into a complete URL.
If there is no / at the end of the prefix and the beginning of the suffix, the
/ connection character needs to be automatically added.
If the end of the prefix and the beginning of the suffix are both /,
automatic deduplication is required.

constraint:

There is no need to consider the illegal prefix and suffix URLs

Enter description

url prefix (a string with a length less than 100)
url suffix (a string with a length less than 100)

Output description

spliced ​​url

Example 1

enter

/acm,/bb

output

/acm/bb

Example 2

enter

/abc/,/bcd

output

/abc/bcd

Example three

enter

/acd,bef

output

 

Guess you like

Origin blog.csdn.net/weixin_45541762/article/details/132925387