当前位置:网站首页>js 2023. String pair equal to the target string after connection
js 2023. String pair equal to the target string after connection
2022-07-03 14:06:00 【Cupid510】
To give you one Numbers Array of strings nums And a Numbers character string target , Please return nums[i] + nums[j] ( Two string connections ) The result is equal to the target The subscript (i, j) ( Need to meet i != j) Number of .
Example 1:
Input :nums = [“777”,“7”,“77”,“77”], target = “7777”
Output :4
explain : Subscript pairs that meet the requirements include :
- (0, 1):“777” + “7”
- (1, 0):“7” + “777”
- (2, 3):“77” + “77”
- (3, 2):“77” + “77”
Example 2:
Input :nums = [“123”,“4”,“12”,“34”], target = “1234”
Output :2
explain : Subscript pairs that meet the requirements include
- (0, 1):“123” + “4”
- (2, 3):“12” + “34”
source : Power button (LeetCode)
/** * @param {string[]} nums * @param {string} target * @return {number} */
var numOfPairs = function(nums, target) {
let count = 0
for(let i =0;i<nums.length;i++){
for(let j =0;j<nums.length;j++){
if(nums[i]+""+nums[j]==target && i !=j){
count++
}
}
}
return count
console.log(count)
};
边栏推荐
- Go language unit test 5: go language uses go sqlmock and Gorm to do database query mock
- selenium 浏览器(1)
- Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
- Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
- JVM class loading
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- 项目协作的进度如何推进| 社区征文
- C language standard IO function sorting
- Uniapp tips - scrolling components
- 可编程逻辑器件软件测试
猜你喜欢
QT learning 20 standard dialog box in QT (middle)
GoLand 2021.2 configure go (go1.17.6)
Configure stylelint
“又土又穷”的草根高校,凭什么被称为“东北小清华”?
Qt学习20 Qt 中的标准对话框(中)
QT learning 25 layout manager (4)
Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)
QT learning 17 dialog box and its types
RocksDB LRUCache
【BW16 应用篇】安信可BW16模组与开发板更新固件烧录说明
随机推荐
Uniapp skills - dom display and hiding
Go 1.16.4: manage third-party libraries with Mod
Qt学习19 Qt 中的标准对话框(上)
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
PhpMyAdmin stage file contains analysis traceability
3D视觉——2.人体姿态估计(Pose Estimation)入门——OpenPose含安装、编译、使用(单帧、实时视频)
Programmable logic device software testing
Simulated access
[développement technologique - 24]: caractéristiques des technologies de communication Internet des objets existantes
Go language web development series 30: gin: grouping by version for routing
QT learning 19 standard dialog box in QT (top)
Redis: operation command of string type data
Installation impression notes
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
Similarities and differences of sessionstorage, localstorage and cookies
JS download files through URL links
Thrift threadmanager and three monitors
How to delete an attribute or method of an object
金属有机骨架(MOFs)抗肿瘤药载体|PCN-223装载甲硝唑|UiO-66包载盐酸环丙沙星([email protected])
消息订阅与发布