Javascript
artemisrj
这个作者很懒,什么都没留下…
展开
-
【leetcode】36. Valid Sudoku
36. Valid SudokuDetermine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’.主要是mask可以减少内存存储,原创 2016-07-30 16:43:49 · 659 阅读 · 0 评论 -
事件的添加,触发,删除
时间的侦听function Events(){}Events.prototype.on=function(action,func){ this[action] = func;}Events.prototype.trigger= function (action) { if(this.hasOwnProperty(action)){ this[action]()原创 2016-04-22 22:01:05 · 422 阅读 · 0 评论 -
字符翻转
对于一个给定的字符串,我们需要在线性(也就是O(n))的时间里对它做一些变形。首先这个字符串中包含着一些空格,就像”Hello World”一样,然后我们要做的是把着个字符串中由空格隔开的单词反序,同时反转每个字符的大小写。比如”Hello World”变形后就变成了”wORLD hELLO”。输入描述: 给定一个字符串s以及它的长度n(1≤n≤500)输出描述: 请返回变形后的字符串。题目保证原创 2016-04-22 21:58:21 · 772 阅读 · 0 评论 -
【leetcode】 260. Single Number III
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums = [1,原创 2016-05-17 18:45:04 · 321 阅读 · 0 评论 -
【leetcode】268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.For example, Given nums = [0, 1, 3] return 2./** * @param {number[]} nums * @return原创 2016-05-26 20:13:59 · 255 阅读 · 0 评论 -
【leetcode】217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is原创 2016-05-25 18:47:34 · 233 阅读 · 0 评论 -
【leetcode】169. Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always原创 2016-05-25 18:48:42 · 272 阅读 · 0 评论 -
【leetcode】171. Excel Sheet Column Number
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 … Z原创 2016-05-25 18:46:05 · 227 阅读 · 0 评论 -
gulp
最近在pycharm里面配置了less,觉得这种真是好用啊,在javascript里面好像也有js文件合并的东西,然后我就看了一下gulp,东西都蛮好的。 gulp入门 从安装node开始讲,真是良心博文了 http://www.ydcss.com/archives/18js合并的文件,嗷~~~ http://www.ydcss.com/archives/83gulp的插件们 http:/原创 2016-04-28 16:05:32 · 539 阅读 · 0 评论 -
事件本身
冒泡和捕获事件W3C 先捕获,再冒泡, IE只支持事件冒泡,不支持事件捕获事件代理鼠标事件的顺序点击链接link,正常状态 visited,鼠标点击后再次停留在上面的状态 hover,鼠标经过的状态 active 按下鼠标时的状态原创 2016-04-14 19:53:27 · 382 阅读 · 0 评论 -
javascript基础语法(做题)
makeClosures实现函数 makeClosures,调用之后满足如下条件: 1、返回一个函数数组 result,长度与 arr 相同 2、运行 result 中第 i 个函数,即 resulti,结果与 fn(arr[i]) 相同 输入例子: var arr = [1, 2, 3]; var square = function (x) { return x * x; }; var原创 2016-04-07 23:30:43 · 1747 阅读 · 0 评论 -
【leetcode】100. Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.# Definition for a原创 2016-05-19 13:54:50 · 275 阅读 · 0 评论 -
一个关于地图的库
http://leafletjs.com/原创 2016-05-19 14:30:41 · 736 阅读 · 0 评论 -
【leetcode】238. Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).For e原创 2016-05-19 17:01:46 · 265 阅读 · 0 评论 -
【leetcode】292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the原创 2016-05-17 15:09:31 · 314 阅读 · 0 评论 -
【leetcode】338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 you sh原创 2016-05-15 11:15:51 · 325 阅读 · 0 评论 -
[leetcode]344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.Subscribe to see which companies asked this question不知道自己会不会精分 javascript版本/**原创 2016-05-14 21:18:44 · 479 阅读 · 0 评论 -
【leetcode】121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi原创 2016-06-15 19:39:17 · 299 阅读 · 0 评论 -
【leetcode】318. Maximum Product of Word Lengths My Submissions QuestionEditorial Solution
Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case lette原创 2016-06-14 10:55:20 · 313 阅读 · 0 评论 -
【leetcode】Intersection of Two Arrays
Intersection of Two Arrays Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]./** * @param {number[]} nums1 * @param {n原创 2016-05-23 19:04:54 · 393 阅读 · 0 评论 -
【leetcode】242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.beats 91%/** * @param {str原创 2016-05-23 19:02:36 · 225 阅读 · 0 评论 -
【leetcode】96. Unique Binary Search Trees
动态规划问题入门,分解成左右两颗子树。 Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 unique BST’s. 1 3 3 2原创 2016-06-10 13:33:17 · 262 阅读 · 0 评论 -
【leetcode】347. Top K Frequent Elements
Top K Frequent ElementsGiven a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].这个办法是先哈希,再排序,等过段时间实现小根堆的算法。/** * @param {numb原创 2016-05-22 20:15:25 · 319 阅读 · 0 评论 -
javascript
基础语法jqery的一些zencode http://docs.emmet.io/abbreviations/syntax/ 数据类型以及控制元素未定义的判断() if(typeof(sentiment)!=”undefined”){}布尔判断 小写的 true 和false强制字符串转数字,int parseInt(stringnum); 对象var obj={}; obj.tex原创 2016-03-22 21:25:26 · 631 阅读 · 0 评论 -
d3的一些东西
svg里面文本是text ,x是文字左边的,y是文字下面的数值。原创 2015-03-18 21:15:29 · 536 阅读 · 0 评论 -
angularjs
http://developer.51cto.com/art/201311/416334.htm原创 2016-03-25 10:02:58 · 271 阅读 · 0 评论 -
前端资源
htmljavascriptbootstrapnode.jsangular原创 2016-03-21 10:20:14 · 318 阅读 · 0 评论 -
div排序,jquery
http://jsfiddle.net/zfcnM/http://blog.csdn.net/paolei/article/details/6805007这两个小例子都非常简单,可以作为参考原创 2015-04-21 09:22:55 · 1202 阅读 · 0 评论 -
d3 拖曳效果
d3的 svg里面的元素可以直接绑定拖曳效果var drag=d3.behavior.drag() .on("drag",move);声明drag,并且绑定drag行为的实现函数。 var circleg=svg.append("g") .attr("class","g"+wordsText) .call(drag)在元素上绑定drag, function mo原创 2015-04-22 14:29:55 · 897 阅读 · 0 评论 -
d3,颜色插值
下面的代码显示d3的几种颜色插值。关于说明文档 https://github.com/mbostock/d3/wiki/Transitions#d3_interpolateHcl示例 Linear Color Interpolation Hsl rgb lab var max = 21, data = [];原创 2015-03-17 21:16:19 · 2569 阅读 · 0 评论 -
d3的brush区域选择
https://github.com/mbostock/d3/wiki/SVG-Controls#brush原创 2015-02-06 14:05:15 · 5172 阅读 · 0 评论 -
d3,圆弧 arc,饼图
arc.centroid - compute the arc centroid.arc.cornerRadius - get or set the corner radius accessor.arc.endAngle - get or set the end angle accessor.arc.innerRadius - get or set the inner radius accessor原创 2015-03-15 21:24:36 · 5845 阅读 · 0 评论 -
Crossfilter.js用来过滤数据
这是一篇翻译 原文http://www.codeproject.com/Articles/693841/Making-Dashboards-with-Dc-js-Part-Using-CrossfilMaking Dashboards with Dc.js - Part 1: Using Crossfilter.js原文是用来介绍dc.js的,我这里先来介绍crossfilter.j翻译 2015-03-02 20:15:19 · 3491 阅读 · 0 评论 -
《数据可视化实战:使用D3设计交互式图表 》笔记
花了半天时间翻了一下这本书,这本书其实讲得并不深,也挺适合刚入门d3的,同时也有一些小tip可以看看。1.全局变量输入window可以看全局变量,作者表示定义全局变量有时候会导致冲突,给出了一个解决方案是将所有你定义的全局变量定义为一个一个全局变量的属性,比如说定义一个vis的全局变量。然后再把要定义的变量variable变成 vis.variable 这样的变量.2.加载数据加载原创 2015-02-08 15:26:12 · 1412 阅读 · 0 评论 -
d3的面积图
面积图首先是一个path,所以有一下的代码原创 2015-02-06 13:49:43 · 1836 阅读 · 0 评论 -
d3
d3.js 数据可视化实战手册 推荐的网址http://jsbin.com/?html,css,js,console,output 在线的D3测试,实验环境。可以通过该工具跟其他人一起分享简单的代码。http://jsfiddle.net/qAHC2/ 在线js代码分享平台 http://bl.ocks.org/mbostock d3示例站点原创 2014-12-24 19:05:44 · 955 阅读 · 0 评论 -
d3力场Force Layout
https://github.com/mbostock/d3/wiki/Force-Layout 介绍API界面力场相关的几个函数力学(Force)d3.layout.force -节点(node)基于物理模拟的位置连接。force.on - 监听布局位置的变化。(仅支持"start","step","end"三种事件)force.nodes - 获得或设置布局中的节点(n原创 2015-03-14 19:47:20 · 1666 阅读 · 0 评论 -
js的MDS代码multidimensional-scaling
http://www.benfrederickson.com/multidimensional-scaling/原创 2015-04-10 14:38:20 · 1292 阅读 · 0 评论 -
json数据格式
就算是数组,也要遵从键-值对组合,{"data":["array"]}json读取只有数据的数据是完全没有问题的,javascript就比较严格原创 2015-05-06 15:49:38 · 425 阅读 · 0 评论 -
javascript的一些坑
异步加载 以前有遇到过函数读取的数据没有定义,但是感觉读取数据的函数写在前面。后来发现,读取数据的函数里面写具体对数据进行处理的函数。浅拷贝 如果javascript直接用 = 那么拷贝的对象为浅拷贝。d3标签生成不了 这个排除了很久的问题,就算svg本身有高度,但是父亲标签如果没有高度的话,svg本身生成元素也会出问题。原创 2016-03-19 19:14:27 · 488 阅读 · 0 评论