自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 资源 (2)
  • 收藏
  • 关注

原创 leetcode ugly number

https://leetcode.com/submissions/detail/47160251/不停地除以公约数,直到自己等于1就行。codeclass Solution(object): def isUgly(self, num): """ :type num: int :rtype: bool

2015-11-30 23:53:55 668

原创 leetcode happy number

https://leetcode.com/problems/happy-number/记住如何从integer里面提取 digit,while n: d = n % 10 res.append(d) n /= 10set 是用set()初始化而用add 更新的只要平方和的结果有重复,而且重复的不是1,那么就是false。参考http://boo

2015-11-30 23:24:42 394

原创 leetcode - Number of 1 Bits

https://leetcode.com/problems/zigzag-conversion/understanding其实这里只需要找出一般公式就行,没什么技巧。当i是1到n-2行时,第i行第一个在斜线上的元素在s中的index是 2 numRows - 2, 所以与第i行第一个元素 i (以及后面增加2 numRows - 2后的j),相差 2 numRows - 2 - 2 i个元素。my

2015-11-30 22:28:31 457

原创 leetcode zigzag conversion

https://leetcode.com/problems/zigzag-conversion/understanding其实这里只需要找出一般公式就行,没什么技巧。当i是1到n-2行时,第i行第一个在斜线上的元素在s中的index是 2 numRows - 2, 所以与第i行第一个元素 i (以及后面增加2 numRows - 2后的j),相差 2 numRows - 2 -

2015-11-30 22:18:46 431

原创 leetcode power of two

understanding:我的方法就是取log,判断是不是整数。网上找到更好的办法一句话就完成。best code:url http://bookshadow.com/weblog/2015/07/06/leetcode-power-of-two/class Solution: # @param {integer} n # @return {boo

2015-11-30 22:16:46 507

原创 leetcode 3sum closest && 4sum

3sum closest这题与3sum类似,维护i, j, k, 然后算mindiff就行.这里需要注意的是,是否需要去重复,题目说了只有一个solution,所以不用去重复。my code:class Solution(object): def threeSumClosest(self, nums, target): """ :type nums: List

2015-11-30 17:39:13 488

原创 leetcode 3Sum

https://leetcode.com/problems/3sum/Note如果是O(N^2)的遍历,要思考是否可以sort一下,然后用two pointers. 因为最后只返回不重复的值,例如,如果aclass Solution(object): def threeSum(self, nums): """ :type nums: List[int]

2015-11-30 12:26:28 425

原创 leetcode Two Sum

Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where

2015-11-30 10:58:25 523

原创 calculate pow(x,n)

Write a program to calculate pow(x,n)http://www.geeksforgeeks.org/write-a-c-program-to-calculate-powxn/

2015-11-27 20:55:56 491

原创 leetcode 刷题---Best Time to buy and sell stock

Problem Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the sto

2015-11-27 20:42:25 457

原创 NumberOfDiscIntersections--重点

Problem: We draw N discs on a plane. The discs are numbered from 0 to N − 1. A zero-indexed array A of N non-negative integers, specifying the radiuses of the discs, is given. The J-th disc is drawn w

2015-11-27 12:28:31 2850

原创 Triangle

A zero-indexed array A consisting of N integers is given. A triplet (P, Q, R) is triangular if 0 ≤ P < Q < R < N and:A[P] + A[Q] > A[R], A[Q] + A[R] > A[P], A[R] + A[P] > A[Q]. For example, consider

2015-11-26 20:45:42 546

原创 codelity--MaxProductOfThree

trick:if using python, we can swap two elements like \A[k], A[minimal] = A[minimal], A[k]problem:A non-empty zero-indexed array A consisting of N integers is given. The product of triplet (P, Q, R) equ

2015-11-26 19:41:53 986

原创 GenomicRangeQuery

题目 A DNA sequence can be represented as a string consisting of the letters A, C, G and T, which correspond to the types of successive nucleotides in the sequence. Each nucleotide has an impact factor,

2015-11-26 18:32:51 955

原创 codelity刷题---MinAvgTwoSlice

https://codility.com/programmers/task/min_avg_two_slicehttp://codesays.com/2014/solution-to-min-avg-two-slice-by-codility/这里其实跟 codelity说要练习的prefix sum没关系。这里需要认识到两个hints,一个就是slice with the global MA mu

2015-11-26 16:30:41 1685

原创 deep learning 学习笔记

link: http://ufldl.stanford.edu/tutorial/ 1. linear regression use MLE to understand the loss function 2. logistic regression— binary classification use MLE to understand the loss function

2015-11-26 16:27:04 991

原创 搜索算法-广搜深搜

典型问题: 迷宫问题,核心:也是搜索树类型的解空间,只不过目标只需要找到其中一个目标解,就可以break了。而不是跟回溯一样遍历整个树的从根节点到叶子节点的path,然后找到一条最佳的path

2015-11-08 19:48:07 889

原创 回溯算法 Backtrack

典型问题, 01背包问题, 8皇后问题,核心就是 找到 解空间,通常是个vector。然后穷举这个vector所有的可能值。例如,在01背包问题中,解空间就是一个vector,每个element的可能值就是0或者1,所以只需要求出N!个解就行了。这种穷举解空间的过程用到了回溯。 BTW, 解空间还是个完全二叉树import java.util.*;public class Backtracking

2015-11-07 16:10:12 4414

原创 回溯算法

典型问题, 01背包问题, 8皇后问题,核心就是 找到 解空间,通常是个vector。然后穷举这个vector所有的可能值。例如,在01背包问题中,解空间就是一个vector,每个element的可能值就是0或者1,所以只需要求出N!个解就行了。这种穷举解空间的过程用到了回溯。再拓展到8皇后问题,解空间也是一个vector,只不过每个element的可能值不再是

2015-11-07 16:02:22 562

原创 01背包问题 动态规划

Given N, M. 先确定objective 是value 先top-bottom, 考虑 i 与 i-1的关系 f[i][m]=max{f[i−1][m],f[i−1][m−wi]+vi}f[i][m] = \max\{f[i-1][m], f[i-1][m-w_i] + v_i\} 再bottom-top来构建这个matrix, 先求 f[1][0:M] 再求 f[2][0:M]

2015-11-06 22:36:19 637

原创 Barrier Function for constrained optimization problem

Given minf(a,b,Σ)\min f(a, b, \Sigma) s.t.a>0,b>0,Σ∈pds.t. a > 0, b>0, \Sigma \in pdwe can utilize the barrier function to prevent the a and b not to be negative, and Σ\Sigma to be pd.add the barri

2015-11-05 15:37:57 674

基于风险决策的企业管理分析

2010年西北工业大学数学建模校队暑假训练题----2010年东北A题

2010-07-22

温室中的绿色生态臭氧病虫害防治

2010年西北工业大学数模校队训练题----第七届苏北B题

2010-07-18

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除