当前位置:网站首页>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)
};
边栏推荐
- Mastering the cypress command line options is the basis for truly mastering cypress
- Screenshot of the operation steps of upload labs level 4-level 9
- Mysql:insert date:sql error [1292] [22001]: data truncation: incorrect date value:
- Redis:Redis的数据结构、key的操作命令
- [combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
- QT learning 21 standard dialog box in QT (Part 2)
- FPGA test method takes mentor tool as an example
- QT learning 25 layout manager (4)
- 使用vscode查看Hex或UTF-8编码
- Function calling convention
猜你喜欢
There is nothing new under the sun. Can the meta universe go higher?
JVM family - overview, program counter day1-1
Go language web development series 30: gin: grouping by version for routing
Dlopen() implements dynamic loading of third-party libraries
Go language web development series 25: Gin framework: using MD5 to verify the signature for the interface station
Solve MySQL 1045 access denied for user 'root' @ 'localhost' (using password: yes)
FPGA测试方法以Mentor工具为例
Mysql:insert date:SQL 错误 [1292] [22001]: Data truncation: Incorrect date value:
Go language unit test 3: go language uses gocovey library to do unit test
Global event bus
随机推荐
MySQL 数据增删改查综合案例
[combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
QT learning 21 standard dialog box in QT (Part 2)
Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email
Back to top implementation
Go language web development series 29: Gin framework uses gin contrib / sessions library to manage sessions (based on cookies)
Go language web development series 28: solve cross domain access of CORS with gin contrib / CORS
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
Selenium browser (1)
Thrift threadmanager and three monitors
Common plug-ins for vite project development
How to delete an attribute or method of an object
Comprehensively develop the main channel of digital economy and digital group, and actively promote the utonmos digital Tibet market
Use and design of Muduo buffer class
SQL Injection (POST/Select)
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
Screenshot of the operation steps of upload labs level 4-level 9
怎样删除对象的某个属性或⽅法
Rasp implementation of PHP
Golang — template