codewars
qq_21696621
这个作者很懒,什么都没留下…
展开
-
Snail
题目地址:https://www.codewars.com/kata/521c2db8ddc89b9b7a0000c1/javascriptSnail SortGiven ann x narray, return the array elements arranged from outermost elements to the middle element, traveling clockwise.array = [[1,2,3], [4,5,6], ..原创 2021-03-26 11:02:54 · 113 阅读 · 0 评论 -
Strings Mix
题目地址:https://www.codewars.com/kata/5629db57620258aa9d000014/javascript参考文章:https://www.jianshu.com/p/fadca63e554aGiven two strings s1 and s2, we want to visualize how different the two strings are. We will only take into account thelowercaseletters (..原创 2021-03-23 10:38:54 · 143 阅读 · 0 评论 -
从金字塔顶端到底部,寻找一条最长的路径
说实话,没看懂google翻译中文的原题....参考:https://blog.csdn.net/qq_41882147/article/details/79679701学习总结:动态规划算法:从底部开始,把倒数第二层每个元素,分别加上下一层的相邻元素(可以选的下一步),,把最大的一个(最优的下一步)作为这层(倒数第二层)的新元素。javascript版本1.自己function longestSlideDown (pyramid) { let res = pyramid.pop(原创 2021-03-17 10:58:42 · 246 阅读 · 0 评论 -
分解质因数
Given a positive number n > 1 find the prime factor decomposition of n. The result will be a string with the following form : "(p1**n1)(p2**n2)...(pk**nk)"wherea ** bmeansato the power ofbwith the p(i) in increasing order and n(i) empty if ...原创 2021-03-16 11:06:16 · 218 阅读 · 0 评论 -
A string of braces is considered valid if all braces are matched with the correct brace.
Examples"(){}[]" => True"([{}])" => True"(}" => False"[(])" => False"[({})](]" => False学习心得:灵活使用 堆栈数据结构、字符串正则匹配、对象key匹配、递归函数javascript版本1.自己function validBraces(braces){ //TODO let splitStr = braces.s原创 2021-03-15 15:07:24 · 105 阅读 · 0 评论 -
您将获得一组数字。 您必须按升序对奇数进行排序,同时将偶数保留在其原始位置。
Examples[7, 1] => [1, 7][5, 8, 6, 3, 4] => [3, 8, 6, 5, 4][9, 8, 7, 6, 5, 4, 3, 2, 1, 0] => [1, 8, 3, 6, 5, 4, 7, 2, 9, 0]javascript版本1.自己function sortArray(array) { // Return a sorted array. let temp; // 冒泡排序 for(let i原创 2021-03-12 10:18:53 · 254 阅读 · 0 评论 -
构建塔
for example, a tower of 3 floors looks like below[ ' * ', ' *** ', '*****']and a tower of 6 floors looks like below[ ' * ', ' *** ', ' ***** ', ' ******* ', ' ********* ', '***********']javascript版原创 2021-03-11 13:37:51 · 61 阅读 · 0 评论 -
给定字符串a1和a2的两个数组,按a1的字符串的字典顺序返回排序的数组r,它们是a2的字符串的子字符串
Example 1a1 = ["arp", "live", "strong"]a2 = ["lively", "alive", "harp", "sharp", "armstrong"]returns["arp", "live", "strong"]Example 2a1 = ["tarp", "mice", "bull"]a2 = ["lively", "alive", "harp", "sharp", "armstrong"]returns[]javascript版本..原创 2021-03-10 15:05:39 · 285 阅读 · 0 评论 -
Convert string to camel case(将字符串转换为驼峰式大小写)
Examples"the-stealth-warrior"gets converted to"theStealthWarrior""The_Stealth_Warrior"gets converted to"TheStealthWarrior"Solutions1.自己function toCamelCase(str){ let delimStr = str.split(/[-_]/); return delimStr.map((item,index)=>{ ...原创 2021-03-09 14:31:32 · 1164 阅读 · 0 评论