码迷,mamicode.com
首页 >  
搜索关键字:algorithm    ( 11758个结果)
Leetcode: Search for a Range
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 ord...
分类:其他好文   时间:2014-06-27 22:25:10    阅读次数:443
LeetCode Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is d...
分类:其他好文   时间:2014-06-27 10:18:32    阅读次数:151
Leetcode Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key....
分类:其他好文   时间:2014-06-27 09:15:12    阅读次数:196
有关科学计算方面的python解决
在科学计算方面,一般认为matlab是一个超强的东西,此外还有R。 至于某种语言来说,一般都要讲究一些特别的算法,包括但不限于: 矩阵方面的计算指数计算对数计算多项式运算各类方程求解 总之,只要是数学问题,在python里面,可以使用以下任何一个来解决 NumPySciPymatplotlibETS 顺便推荐一本书《用Python做科學計算》。地址是:http:/...
分类:编程语言   时间:2014-06-27 08:45:21    阅读次数:205
First Missing Positive
题目 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 algorithm should run in O(n) time and u...
分类:其他好文   时间:2014-06-27 08:30:30    阅读次数:202
二分查找算法的Python实现
问题 二分查找 list.index()无法应对大规模数据的查询,需要用其它方法解决,这里谈的就是二分查找 思路说明 在查找方面,python中有list.index()的方法。例如: >>> a=[2,4,1,9,3] #list可以是无序,也可以是有序 >>> a.index(4) #找到后返回该值在list中的位置 1 >>...
分类:编程语言   时间:2014-06-26 13:17:57    阅读次数:223
uva10487
#include #include using namespace std; int n,m,k,cases,sum,arr[1005],S[1000000]; void calsum(){ k=0; for (int i=0;i<n-1;i++){ for (int j=i+1;j<n;j++){ S[k++]=arr[i]+arr[j]; } } sort(S,S...
分类:其他好文   时间:2014-06-26 10:51:01    阅读次数:198
LeetCode: Single Number [136]
【题目】 Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 【题意】 给定一个整数数组,其中除了一个数以外,其他数都是成对出现的,...
分类:其他好文   时间:2014-06-26 10:13:27    阅读次数:254
快速排序的python多种实现
问题 快速排序,这是一个经典的算法,本文给出几种python的写法,供参考。 特别是python能用一句话实现快速排序。 思路说明 快速排序是C.R.A.Hoare于1962年提出的一种划分交换排序。它采用了一种分治的策略,通常称其为分治法(Divide-and-ConquerMethod)。 (1) 分治法的基本思想 分治法的基本思想是:将原问题分解为若干个规模更小但结构与原...
分类:编程语言   时间:2014-06-25 09:02:20    阅读次数:289
LeetCode: Longest Consecutive Sequence [128]
【题目】 Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4. Your algorithm should run...
分类:其他好文   时间:2014-06-25 07:55:42    阅读次数:244
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!