问题
查找某个值在list中的位置
解决思路
可以用折半查询的方法解决此问题。
解决(Python)
#! /usr/bin/env python
#coding:utf-8
#折半查找某个元素在list中的位置
def half_search(lst,value,left,right):
length = len(lst)
while left<ri...
分类:
其他好文 时间:
2014-06-19 11:09:48
阅读次数:
527
旋转数组中的查找。[1, 2, 3, 4, 5, 6]的一个旋转数组为[4, 5, 6, 1, 2, 3]。在旋转数组中寻找一个数。
最直接的方法,一次遍历,时间复杂度O(n)。但是既然是一个部分有序的数组,那么对于有序的部分我们可以想方法用二分查找。这个效率可以提高。
代码:
.......
分类:
其他好文 时间:
2014-06-15 17:33:21
阅读次数:
195
题目
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You may assume no duplicates i...
分类:
其他好文 时间:
2014-06-15 17:27:16
阅读次数:
251
题目
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algorithm's runtime complexity must be in the order of O(log n).
If the target i...
分类:
其他好文 时间:
2014-06-15 16:53:32
阅读次数:
177
类Ext.form.Action.Submit
处理表单Form数据和返回的response对象的类。
该类的实例仅在表单Form{@link Ext.form.BasicForm#submit 提交}的时候创建。
返回的数据包必须包含一个 boolean 类型的success属性,还有可选地,一个含有无效字段的错误信息的属性
A response packet may contai...
分类:
Web程序 时间:
2014-06-15 16:22:42
阅读次数:
277
题目
Given a sorted array of integers, find the starting and ending position of a given target value.
解题思路:
查找一个数出现的范围,给一个排好序的数组和一个数,找出这个数在数组中出现的范围。
这个题直接使用一次遍历就可以得到结果,这样的时间复杂度为O(n)。但是对于有序数组我们一般可以使用二分查找可以得到更好的O(logn)的时间复杂度。我们可以使用二分查找找到这个数第一次出现的位置和这个数最后一次出现的位...
分类:
其他好文 时间:
2014-06-15 16:19:16
阅读次数:
237
extjs每个组件要设置唯一的ID,否则会造成各种错误
EXTJS基本上是靠ID来识别组件的,假如你在panel1中有个ID:"keyword"的textfield,而panel2中有个ID相同的textfield ,那么,当你关闭panel2,由于extjs发现panel2中的ID:"keyword"组件在panel1中仍然使用中,是不会销毁掉它的,于是它成为一个孤立的对象,从而造成混乱。
...
分类:
Web程序 时间:
2014-06-15 16:11:33
阅读次数:
272
1、
??
Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 uni...
分类:
其他好文 时间:
2014-06-15 09:09:00
阅读次数:
256
服务端:首先拿出一块分区/dev/sda5# yum search target# yum install scsi-target-utils.x86_64 -y //服务端的包# vim /etc/tgt/targets.conf //编辑服务端的配置//共享出这块分区的名字为redhat:...
分类:
系统相关 时间:
2014-06-14 21:04:16
阅读次数:
332
Extjs 在实现消息框的时候,完全摈弃了传统的风格,不再弹出新的对话框,而是在当前页面跳出一个层,并将原页面完整覆盖。原来,只是一种模拟。在 Ext 中,定义了一个类MessageBox,该类还有一个更精简的名字Msg,所有消息框都定义在该类中。 建立dialogs.js文件。 提示框(Alert) 提示框的语法:Ext.MessageBox. alert ( String t...
分类:
Web程序 时间:
2014-06-14 11:30:20
阅读次数:
373