Link:http://arturoherrero.com/2011/06/04/10-groovy-one-liners-to-impress-your-friends/ I find that comparing programming languages is a worthwhile exercise mainly because of the different techniques and styles that you are exposed to. After 10 Scala…
万恶的输入法,在sublime中会显示出繁体字,各位看官见谅. 1.slice()方法:该方法在数组和string对象中都拥有. var a = [1,2,3,4,5,6]; var s = 'this is a string'; console.log(a.slice(1,3));//結果為 [2,3]; console.log(a.slice(-1);//結果為6; console.log(s.slice(1,3));//結果為 hi; console.log(s);//結果為 this i…
Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among these m subarrays. Note:Given m satisfies the following const…
关于基础,总是隔一段时间,就得看一次,要不不用总是忘,今天又重新看了,一下字符串对象的split,然后就想到了数组对象的join. var str='wo shi yi ge js'; var str1='wo|shi|yi|ge|js'; split的注意点 1.str.split('');//以空字符串分割的话,就是代表str中的每一个字符都会被分割,默认数组以逗号分隔,split 分割符,不会作为数组的一部分出现 2.str.split(' ');//以空格分割的话,就是如果字符串里面的字…
需求是这样的,需要将数据库中的支付方式列(用";"分割的字符串)按支付方式拆分: 首先参考博客园split的文章,我采用方法2, IF EXISTS ( SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[f_splitSTR]') AND xtype IN ( N'FN', N'IF', N'TF' ) ) DROP FUNCTION [dbo].[f_splitSTR]; GO --方法1:循环截取法 CREATE…
这篇随笔根据两个面试题来实战一下数组.字符串的一些方法. 题一:一个字符串中找出出现次数最多的字符次数 var str = 'fuuhuhuhufaihuhfnkjNKCNIO'; function num(str) { var json = {}; for (var i = 0; i < str.length; i++){ //字符串的charAt()方法返回指定位置的字符串 if(!json[str.charAt(i)]){//若json对象中没有当前属性,则给当前属性赋值为1 json[…