1、去掉重复的数组元素。2、获取一个数组中的重复项。3、求一个字符串的字节长度,一个英文字符占用一个字节,一个中文字符占用两个字节。4、判断一个字符串中出现次数最多的字符,统计这个次数。5、数组排序。6、快排。7、删除/添加数组项。8、数组随机顺序输出。9、数组求和、最大值。10、判断是否为数组。1...
分类:
Web程序 时间:
2014-06-29 13:41:49
阅读次数:
363
原题地址:https://oj.leetcode.com/problems/anagrams/题意:Given
an array of strings, return all groups of strings that are anagrams.Note: All
inputs will be i...
分类:
编程语言 时间:
2014-06-29 13:25:28
阅读次数:
355
先看一段比较神奇的运算和他的结果:{}+[]//0[]+{}//"[object
Object]"{}+[] == []+{}//false({}+[]) ==
[]+{}//true运算结果不一样,很神奇啊。。。我们来看一下js中对Object和Array直接执行运算时会发生什么。由于数组不是一个...
分类:
Web程序 时间:
2014-06-29 07:50:50
阅读次数:
267
题目链接 Given an unsorted integer array, find the
first missing positive integer. For example, Given [1,2,0] return 3, and
[3,4,-1,1] return 2. Your algo...
分类:
其他好文 时间:
2014-06-29 07:44:48
阅读次数:
321
在一个经过旋转后的有序数组中查找一个目标元素。
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4
5 6 7 0 1 2).
You are given a target value to search...
分类:
其他好文 时间:
2014-06-20 13:06:31
阅读次数:
261
1 Android手机目前常见的分辨率
1.1 手机常见分辨率:
4:3
VGA 640*480 (Video Graphics Array)
QVGA 320*240 (Quarter VGA)
HVGA 480*320 (Half-size VGA)
SVGA 800*600 (Super VGA)
5:3
WVGA 800*480 (Wide VGA)
...
分类:
移动开发 时间:
2014-06-20 12:50:23
阅读次数:
271
题目
Write a function to find the longest common prefix string amongst an array of strings.
原题链接
解题思想
给一个字符串数组,求这些字符串的最长公共前缀。
这个题应该是比较简单的,直接写代码,一次AC。解题思想是依次对数组中的字符串求最长公共前缀。
代码实现
class Sol...
分类:
其他好文 时间:
2014-06-20 12:25:09
阅读次数:
247
题目
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
方法
数组是有序的,要求创建的二叉树尽量平衡,很容易想到对数组进行二分操作,左边的数组元素是左子树,右边的数组元素是右子树。进行递归操作就可以了。
TreeNode...
分类:
其他好文 时间:
2014-06-20 11:06:46
阅读次数:
257
【题目】
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
【题意】
给定一个已排序的数组(不存在重复元素),将它转换成一棵平衡二叉搜索树。
【思路】
由于平衡二叉树要求左右子树的高度差绝对值相遇等于1,也就是说左右子树尽可能包含相同数目节点。
则使用二分法来解本题即可。...
分类:
其他好文 时间:
2014-06-20 11:03:31
阅读次数:
246
【题目】
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
【题意】
将一个有序链表转换成平衡二叉树
【思路】
思路跟Convert Sorted Array to Binary Search Tree完全一样...
分类:
其他好文 时间:
2014-06-07 16:20:05
阅读次数:
287