- 博客(317)
- 资源 (19)
- 收藏
- 关注
原创 【leetcode】230. Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements.var kthSmallest = function(root, k
2016-06-06 19:14:35
277
原创 【leetcode】328. Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to do it in plac
2016-06-06 13:03:51
259
原创 【leetcode】287. Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fin
2016-06-06 12:35:11
216
原创 【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
280
原创 【leetcode】343. Integer Break
Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, given n = 2, return 1
2016-05-25 18:55:03
258
原创 【leetcode】319. Bulb Switcher
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or turning off i
2016-05-25 18:53:41
322
原创 【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
299
原创 【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
268
原创 【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
250
原创 【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
422
原创 【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
259
原创 【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
356
原创 【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
301
原创 【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
302
原创 【leetcode】237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, t
2016-05-18 16:58:59
290
原创 【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
357
原创 【leetcode】283. Move Zeroes
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your funct
2016-05-17 18:31:15
369
原创 【leetcode】226. Invert Binary Tree
照例要考虑树为空的情况。/** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * this.left = this.right = null; * } *//** * @param {TreeNode} root * @return {TreeNod
2016-05-17 15:25:29
225
原创 【leetcode】104. Maximum Depth of Binary Tree 92.83%
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Subscribe to see which companies asked this
2016-05-17 15:16:34
260
原创 【leetcode】258. Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r
2016-05-17 15:13:52
247
原创 【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
337
原创 【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
354
原创 [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
509
原创 【leetcode】136. Single Number
Given an array of integers, every element appears twice except for one. Find that single one.以后先自己想一种算法,然后在参照别人的一种算法 python快速版本class Solution(object): def singleNumber(self, nums): """
2016-04-28 17:05:05
371
原创 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
563
原创 [编程题]树上最长单色路径
[编程题]树上最长单色路径对于一棵由黑白点组成的二叉树,我们需要找到其中最长的单色简单路径,其中简单路径的定义是从树上的某点开始沿树边走不重复的点到树上的另一点结束而形成的路径,而路径的长度就是经过的点的数量(包括起点和终点)。而这里我们所说的单色路径自然就是只经过一种颜色的点的路径。你需要找到这棵树上最长的单色路径。 给定一棵二叉树的根节点(树的点数小于等于300,请做到O(n)的复杂度),请返
2016-04-27 11:07:39
477
原创 [编程题]地域划分
现在有一块长条形的土地,这个土地我们可以看成是由n块小方格连接而成的(这些小方格我们可以将之编号为1到n)。而我们需要将其划分成两个部分,分别种上不同的作物(即作物A和B),划分必须在某两个小方格之间进行,或者在土地的最左端或最右端,若划分在第i块到第i+1块间进行,则划分后,第1至第i块地种A,剩下的地种B。现在有一些专家对土地进行了检测,他们每个人评估了每块土地适合种的作物。请你找到一个合适的划
2016-04-25 20:26:56
448
原创 事件的添加,触发,删除
时间的侦听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
458
原创 字符翻转
对于一个给定的字符串,我们需要在线性(也就是O(n))的时间里对它做一些变形。首先这个字符串中包含着一些空格,就像”Hello World”一样,然后我们要做的是把着个字符串中由空格隔开的单词反序,同时反转每个字符的大小写。比如”Hello World”变形后就变成了”wORLD hELLO”。输入描述: 给定一个字符串s以及它的长度n(1≤n≤500)输出描述: 请返回变形后的字符串。题目保证
2016-04-22 21:58:21
813
原创 事件本身
冒泡和捕获事件W3C 先捕获,再冒泡, IE只支持事件冒泡,不支持事件捕获事件代理鼠标事件的顺序点击链接link,正常状态 visited,鼠标点击后再次停留在上面的状态 hover,鼠标经过的状态 active 按下鼠标时的状态
2016-04-14 19:53:27
409
原创 关于css
css的基础知识点盒子模型W3C标准的盒子模型IE的盒子模型CSS的居中问题(水平and垂直)水平居中垂直居中浮动的塌陷问题额外加一个div标签在子节点加一个额外标签,然后clear:both; 缺点:增加了无用的标签,不利于语义化父亲overflow:hidden这种方式是因为父节点会计算子节点的高度clearfix利用伪类 这种方式可以写成css样式,直接引用就行了 bootstrap也是
2016-04-13 23:59:55
339
原创 pycharm调试nodejs代码
虽然说用webstorm其实自带的,但是pycharm也能加载node.js的解释器来调试代码的。 看到有人问,就说一下吧。 其实官方的帮助文档已经讲得很清楚了。 https://www.jetbrains.com/help/pycharm/2016.1/running-and-debugging-node-js.html?origin=old_help首先,安装nodejs的插件。插件怎么安
2016-04-13 18:35:22
16377
原创 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
1803
原创 html的相关
htm5 http://www.w3school.com.cn/html5/index.aspzencode http://docs.emmet.io/abbreviations/syntax/ 基本结构<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title></hea
2016-03-26 20:30:22
352
原创 AFFINITY PROPAGATION相似传播聚类
这个聚类算法,基础是置信传播,在邻近节点之间传播massage. message分成两种,一类是responsibilities,代表从 exemplar (暂时理解为聚类)接纳数据点的能力,另外一类是availabilities,。
2016-03-25 20:10:26
2355
原创 javascript的一些坑
异步加载 以前有遇到过函数读取的数据没有定义,但是感觉读取数据的函数写在前面。后来发现,读取数据的函数里面写具体对数据进行处理的函数。浅拷贝 如果javascript直接用 = 那么拷贝的对象为浅拷贝。d3标签生成不了 这个排除了很久的问题,就算svg本身有高度,但是父亲标签如果没有高度的话,svg本身生成元素也会出问题。
2016-03-19 19:14:27
519
sentiwords情感词
2015-11-24
图片批量下载
2015-01-05
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅