- 博客(13)
- 收藏
- 关注
原创 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-06-29 16:46:17 231
原创 Count Primes
Description:Count the number of prime numbers less than a non-negative number, n. 题目的解题思路很经典https://leetcode.com/problems/count-primes/,见此链接的show HintJS代码如下:var countPrimes = function(n) { var cou
2016-06-29 16:00:48 295
原创 Happy Number
Write an algorithm to determine if a number is “happy”.A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of i
2016-06-28 20:48:23 170
原创 Word Pattern
Given a pattern and a string str, find if str follows the same pattern.Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.Examples:p
2016-06-28 20:32:13 459
原创 window.location.hash
location是javascript里边管理地址栏的内置对象,比如location.href就管理页面的url,用location.href=url就可以直接将页面重定向url。而location.hash则可以用来获取或设置页面的标签值。比如http://domain/#admin的location.hash=”#admin”。利用这个属性值可以做一个非常有意义的事情。很多人都喜欢收藏网页,以便
2016-06-23 17:58:07 376
原创 jQuery对象与DOM节点转换
jQuery内部确实定义一些与原生数组方法类似的方法,例如:.sort(),.push(),.splice()都是jQuery()对象的方法。不过,这些方法都是内部使用的,并没有文档公开出来。不能在jQuery对象上调用他们,若要使用他们,可以利用.get()方法将jQuery对象转换为DOM节点 例如:var rows=$(‘tbody>tr’).get(); rows
2016-06-23 09:28:11 1540
原创 jQuery——jquery.fn.extend与jquery.extend
jquery.extend:扩展jquery类本身,为jQuery类添加添加类方法,相当于类的“静态”方法;jquery.fn.extend:给jquery示例对象添加方法,根据Jquery源码 jQuery.fn = jQuery.prototype = { //……… } 对jQuery.prototype进行扩展,就是为jQuery类添加“成员函数”。jQuery类的实例可以使用这个“
2016-06-22 22:04:22 212
原创 Wiggle Sort II
Given an unsorted array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]….Example: (1) Given nums = [1, 5, 1, 1, 6, 4], one possible answer is [1, 4, 1, 5, 1, 6]. (2) Given nums = [1
2016-06-22 21:14:14 225
原创 Intersection of Two Arrays&Intersection of Two Arrays II
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].Note: Each element in the result must be
2016-06-13 21:29:12 329
原创 LeenCode——归并问题的处理( Merge Two Sorted Lists&&Given two sorted integer arrays nums1 and nums2, merge n)
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.这道题的巧妙之处在于,提示中num1数组的容量大于m+n,即两个数组长度之和。 数组nums1和nums2都是从大到小排列,所以可以从数组的尾部开始比较,取出元素最大的插入nums1的末尾。 JS代码:var
2016-06-13 20:14:56 622
原创 Valid Anagram&Group Anagrams
Vaild AnagramTitle: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.首次,带大家了
2016-06-07 14:36:06 253
原创 ife——task35
百度前端任务35—听指令的小方块(三)任务连接如下:http://ife.baidu.com/task/detail?taskId=35 本人的代码连接如下:https://github.com/ty520/ife-Web/tree/master/task_35_TY能力有限这个任务差不多足足花了近两天的时间自己独立完成,主要想练习近期学习的JS设计模式以及Canvas画图。实现的具体功能如下:
2016-06-06 16:41:36 426
原创 Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: Given num
2016-06-01 21:43:08 223
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人