# # Your prevIoUs Plain Text content is preserved below:# # # Boolean search is powerful in sourcing and recruiting.# We will use machine learning prediction to provIDe relations among skills. Now we need a function to transfer those relations to a string with correct boolean format.# # Example1:# input: [["java", "python"], ["machine learning", "deep learning"]]# output: ("java" OR "python") AND ("machine learning" OR "deep learning")# # Example2:# input: [[["java", "maven", "spring"], "python"], ["machine learning", "deep learning"]]# output: (("java" OR "maven" OR "spring") AND "python") AND ("machine learning" OR "deep learning")
// let a = [[["java", "maven", "spring"], "python"], ["machine learning", "deep learning"]]let a = [["java", "python"], ["machine learning", "deep learning"]];// [["java", "maven", "spring"], "python"]function subString(arr, dep=0){ if(arr.every((x)=>typeof x === 'string')){ return `(${arr.map(x=>`"${x}"`).join(' OR ')})`; } let s = arr.map(a => { if(Array.isArray(a)){ return subString(a, 1); } return `"${a}"`; }).join(' AND '); return dep ? `(${s})` : s;}console.log(subString(a))
总结
以上是内存溢出为你收集整理的氦图面试题目Boolean search全部内容,希望文章能够帮你解决氦图面试题目Boolean search所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)