Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

求一个js算法,能实现我的方案的,有酬劳

需要实现一个js算法
要求如下:
1.有个json对象,json的key已经固定,value是数组,长度可以是1或2或3,每个value的长度是一样的
2.arr是可选项,要用arr的值去填充json里的每个数组项,每个数组项的长度是count,count也是入参,可以是0或1或2或3或4或5
3.具体看下json:
(1)'' 表示需要填充数据
(2){3: 1, 2: 0} 表示必须有3,必须不能有2
(3)0 表示不用填充数据
4.一个key的value数组每项不能同时出现同一个选项,比如不能出现[[1,2,3],[3,4,5]],因为3是重复的
如:

function order (arr, count, len, json) {
 //这里实现算法
 ...
}
/*
arr: 可选项
count: 输出结果
*/
var arr = [1, 2, 3, 4, 5, 6, 7, 8]
var count = 3
var json = {
  '2020-10-9': ['', ''],
  '2020-10-10': ['', ''],
  '2020-10-11': [{3: 1, 2: 0, 4: 0}, ''],
  '2020-10-12': [0, ''],
  '2020-10-13': ['', ''],
  '2020-10-14': [{6: 1}, ''],
  '2020-10-15': ['', {1: 0}]
  '2020-10-16': ['', '']
}
order(arr, count, len, json)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

恕我愚笨,连题目我都没读懂。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...