- 博客(11)
- 收藏
- 关注
原创 leetcode(4)
1.缺失数字 给定一个包含 0, 1, 2, …, n 中 n 个数的序列,找出 0 … n 中没有出现在序列中的那个数。 var missingNumber = function(nums) { var map={}; var mapNew={}; let max=0; if(nums.length==1) return 1-nums[0]; ...
2019-11-05 13:28:47
197
原创 leetcode(3)
1.股票(2) 给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票. 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 var maxProfit = function(nums) { let temp=0; for(let i =0;i<nums.len...
2019-11-03 15:06:19
237
原创 leetcode(2)
1.杨辉三角 var generate = function(numRows) { const result=[] if(numRows<=0) return result; for(let i =0;i<numRows;i++){ const subarr=[] for(let j=0;j<=i;j++){ if(...
2019-11-02 20:59:52
182
原创 leetcode(1)
1.两数之和 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 var twoSum=function(nums,target) { var temp=[] for(var i = 0;i<nums.length;i++) { ...
2019-11-01 21:54:24
243
原创 codewars【5】
1.Not very secure In this example you have to validate if a user input string is alphanumeric. The string has the following conditions to be alphanumeric: At least one character ("" is not valid) Allo...
2019-08-13 23:00:37
470
原创 codewars【4】
1.Mexican Wave In this simple Kata your task is to create a function that turns a string into a Mexican Wave. You will be passed a string and you must return that string in an array where an uppercase...
2019-08-12 21:59:26
646
原创 rstrip()与zfill()的学习
1.rstrip() str.rstrip([chars]) chars – 指定删除的字符(默认为空格) 返回删除 string 字符串末尾的指定字符后生成的新字符串 例子: str = "88888888this is string example....wow!!!8888888"; print str.rstrip('8'); 输出: 88888888this is string ex...
2019-08-12 10:32:32
431
原创 codewars【3】
1.Count the smiley faces! Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces. Rules for a smiling face: -Each smiley face must ...
2019-08-11 23:19:42
573
原创 itertools中groupby的学习
首先看一下昨天在codewars上遇到的一题: Unique In Order Implement the function unique_in_order which takes as argument a sequence and returns a list of items without any elements with the same value next to each othe...
2019-08-11 10:40:37
4894
原创 codewars【2】
1.Growth of a Population In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come ...
2019-08-10 23:49:59
362
原创 codewars【1】
今天开始记录自己在codewars上遇到的问题和得到的收获。 首先是自己已完成的四道题。 1.CreditCardMask Usually when you buy something, you’re asked whether your credit card number, phone number or answer to your most secret question is still...
2019-08-10 13:42:47
483
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅