自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 leetcode 242. Valid Anagram | Map

# DescriptionGiven 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

2017-08-28 16:02:44 331

原创 [京东面试问题] 求n=100w个数里面的前k=100个

# 基本思路  最复杂的方法莫过于全部排序, 复杂度nlgn. 结合求100w个数里面最大的一个数(即求max), 不需全排序, 只需开一个变量, 遍历一次记录最大值即可.那么很自然的想到, 求前k个就是开一个k大小的数组, 把历史最大/次大/次次大存起来. 也就是说, 在遍历n的时候, 对于新元素需要和k数组进行对比, 最差的方式是每次遍历k, 总体复杂度在n*k. 如果k数组是已排序的,

2017-08-25 15:08:44 875

原创 leetcode 234. Palindrome Linked List

Reversing a list is not considered “O(1) space” It is a common misunderstanding that the space complexity of a program is just how much the size of additional memory space being used besides input.

2017-08-13 11:24:02 322

原创 leetcode 226. Invert Binary Tree | DFS 递归转迭代

DescriptionInvert a binary tree. 4/ \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was inspired by this original tweet by Max

2017-08-12 10:48:47 344

原创 leetcode 225. Implement Stack using Queues

DescriptionImplement the following operations of a stack using queues.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top() – Get the top element. empty() – Ret

2017-08-11 19:07:06 268

原创 leetcode 219. Contains Duplicate II | 滑窗, Set

DescriptionGiven an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is a

2017-08-11 17:54:19 1782

原创 leetcode 205. Isomorphic Strings | str中字母计数(dict)与定位

DescriptionGiven two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with an

2017-08-11 16:03:54 221

原创 leetcode 204. Count Primes

DescriptionCount the number of prime numbers less than a non-negative number, n.My solution原始方案 比较朴素的想法就是迭代的找下去, 然后把找到的质数存起来, 对于下一个数, 如果他不能被前面任何一个质数整除, 那这个数也是一个质数(我感觉是这样的). 代码如下:class Solution {pub

2017-08-11 14:58:26 245

原创 leetcode 203. Remove Linked List Elements | 递归的更多理解

DescriptionRemove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5/** * Definition for singly-lin

2017-08-11 09:56:56 247

原创 leetcode 202. Happy Number | 循环检测

DescriptionWrite 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 s

2017-08-10 23:47:35 349

原创 leetcode 198. House Robber | 动态规划

DescriptionYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adja

2017-08-10 22:57:26 291

原创 极大似然和交叉熵 | 深度学习

接触ML接近一年, 虽有数字信号+统计检测基础知识, 对极大似然仍然一知半解, get不到贝叶斯的思想. DL仍处于探索阶段, 只知道些名次堆砌, 今天开始读<深度学习> 这本书, 着实相见恨晚. 博客将记录个人点滴见解, 聊以备忘. 欢迎交流指正!极大似然 因时间有限+latex技能尚未习得, 下述公式很少很难看概率论中常讲极大似然, 基本任务是对于未知参数theta的指定分布,

2017-08-03 22:26:51 4422

原创 leetcode 172. Factorial Trailing Zeroes

DescriptionGiven an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.My solution基本思路是:阶乘中的每个数分解因式, 总共加起来有几个5, 就对应总阶乘末尾有几个0. 最初想法为n/5,

2017-08-01 23:27:41 358

原创 leetcode 169. Majority Element | 摩尔投票法

DescriptionGiven 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 elem

2017-08-01 19:10:09 465

原创 leetcode 168. Excel Sheet Column Title | 进制转化

DescriptionGiven a positive integer, return its corresponding column title as appear in an Excel sheet.For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB My solution实际上是转化为26进制, 故采用经典的除K取余

2017-08-01 16:40:38 316

原创 leetcode 167. Two Sum II - Input array is sorted

DescrpitionGiven an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two

2017-08-01 11:19:02 309

原创 leetcode 160. Intersection of Two Linked Lists

DescrpitionWrite a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2017-08-01 10:49:12 248

原创 leetcode 155. Min Stack | 空间换时间

DescriptionDesign a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) – Push element x onto stack. pop() – Removes the element on top of the stack. top()

2017-07-22 20:19:36 387

原创 leetcode 141. Linked List Cycle

DiscriptionGiven a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?My solution:None检测链表中有无cycle,可以用DPS方法,对每个node做访问过标记{0,1,2},但这需要额外空间.Discuss大神采

2017-07-22 16:06:54 240

原创 leetcode 136. Single Number | XOR的巧妙运用

DescribeGiven 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

2017-07-21 21:01:03 512

原创 leetcode 125. Valid Palindrome | 回文string

回文str125. Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example, “A man, a plan, a canal: Panama” is a palindrome. “

2017-07-21 18:49:51 345

原创 leetcode 121. Best Time to Buy and Sell Stock | 最大差值和最大子序列关系

leetcode 121Say 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

2017-07-21 16:01:44 464 1

原创 【LDA|ML】西瓜书习题3.4

from XiguaData import *import numpy as npx, d = load_data_3d0a()# 已知西瓜数据3.0a前8个分类为0,其余分类为1x0 = x[:8]d0 = d[:8]x1 = x[8:]d1 = d[8:]# LDA 线性判别分析miu0 = np.mean(x0, axis=0)miu1 = np.mean(x1, a

2016-12-20 09:18:02 643

原创 【python|ML】k-fold/leave-one-out 方法在对率回归实现(西瓜书习题3.4,数据UCI-iris)

# 经验:梯度下降要让目标确实减小(或者增大),此程序tempsum需要减小,故要着重检查!!import numpy as npdef dlhg(x, d): x = np.c_[x, np.ones(d.shape[0])] w = np.random.randn(x[0].shape[0]) miu = 0.01 temp_sum_old = np.

2016-12-19 21:22:36 2077

原创 序列圆卷积和线卷积的关系

2014-11-17 15:29:50 1506

空空如也

空空如也

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

TA关注的人

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