自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(83)
  • 资源 (1)
  • 收藏
  • 关注

原创 【leetcode】【Easy】【453. Minimum Moves to Equal Array Elements】【math】

problem link看着复杂,其实转换一下思维就可以了code:public class Solution { //n-1个元素加一相当于只有一个减去1,那么每次只让一个元素减一,直到所有元素都相同,这个相同的元素就是数组中最小的元素 public int minMoves(int[] nums) { int min=nums[0];

2017-01-25 21:47:57 581

原创 【leetcode】【Easy】【455. Assign Cookies】【greedy】

problem linkcode:public class Solution { public int findContentChildren(int[] g, int[] s) { Arrays.sort(g); Arrays.sort(s); int num=0; for(int i=0,

2017-01-25 21:16:25 429

原创 【leetcode】【Easy】【283. Move Zeroes】【array】

problem linkword:in-place 在原位code:code1:计算某一非零位前面有多少个0,直接前移,然后给后面的赋值为0,有几个赋值几个。public class Solution { public void moveZeroes(int[] nums) { if(nums==null || nums.length==0)

2017-01-20 00:05:49 469

原创 【leetcode】【Easy】【226. Invert Binary Tree】【tree】

problem linkcode:code1:递归在leetcode上要比BFS快一点public class Solution { public TreeNode invertTree(TreeNode root) { if(root == null) return null; TreeNode tmp = root.left;

2017-01-19 23:30:34 378

原创 【leetcode】【Easy】【389. Find the Difference】【string】【bit manipulation】

problem linkcode1:将string变为char数组比第二种直接操作string使用charAt方法要快很多public class Solution { public char findTheDifference(String s, String t) { int sumS=0; int sumT=0; int

2017-01-18 16:56:00 372

原创 【leetcode】【Easy】【104. Maximum Depth of Binary Tree】【tree】

经典简单问题 problem linknote:(1)递归要有结束条件(2)此题可用DFS,BFS解题code:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode r

2017-01-18 16:34:48 371

原创 【leetcode】【Easy】【448. Find All Numbers Disappeared in an Array】【正负位标记】【Array】

problem linkcode:用负来标记出现过的,因为题目要求不能有extra space,复杂度为O(n),所以只能操作原数组,另外可以利用的是数组的下标。public class Solution { public List findDisappearedNumbers(int[] nums) { for(int i=0;i<nums.length;

2017-01-18 15:06:53 271

原创 【leetcode】【Easy】【463. Island Perimeter】

problem link:https://leetcode.com/problems/island-perimeter/code1:效率较高的两种解法,打败一半的人//查看右边和下边的邻居public class Solution { public int islandPerimeter(int[][] grid) { int islands = 0, ne

2017-01-18 00:19:57 316

原创 【leetcode】【Easy】【344. Reverse String】【string】【two pointers】

一个经典,基本的问题:翻转字符串problem link:https://leetcode.com/problems/reverse-string/note:(1)String类的方法substring(beginindex,endindex)两个参数如果相同返回的是空字符串(2)stringbuilder的replace方法和string的substring方法指针超

2017-01-17 15:04:30 338

原创 【leetcode】【Easy】【412. Fizz Buzz】

problem link:https://leetcode.com/problems/fizz-buzz/code:code1: 最简单的一种public class Solution { public List fizzBuzz(int n) { List res=new ArrayList(n); for(int i

2017-01-16 20:41:16 453

原创 【leetcode】【Easy】【461. Hamming Distance】【bit manipulation】

problem link:https://leetcode.com/problems/hamming-distance/code:效率从高到低的三种方法第一种方法,要知道java中int占用4个字节(char占用2个字节 reference:http://blog.csdn.net/witsmakemen/article/details/8974200),这种类型的题既

2017-01-14 18:31:24 419

原创 【leetcode】【Medium】【451. Sort Characters By Frequency】【HashMap】【PriorityQueue】【HeapSort】

problem link: https://leetcode.com/problems/sort-characters-by-frequency/note:1.Java集合类priorityqueue优先队列,没用过所以想不到,还想自己写插入排序,Java现成的方法很方便2.想到用桶排序的思想,但是由于考虑到string长度会不会太长以及中文字符的存在而放弃了3.com

2017-01-05 23:17:09 565

原创 【leetcode】【Medium】【413. Arithmetic Slices】【Math】【Dynamic programming】

problem linkcode(java 2ms  beat 32.44%):public class Solution { public int numberOfArithmeticSlices(int[] A) { int count = 0; int N = A.length; if(N<=2){ return 0; } fo

2016-12-24 17:51:50 495

原创 【leetcode】【Medium】【338. Counting Bits】【规律】

注意边界及特殊情况problem link:https://leetcode.com/problems/counting-bits/code1(java 3ms):public class Solution { public int[] countBits(int num) { if(num==0){ return new

2016-12-23 00:22:23 439

原创 git for mac

http://blog.csdn.net/crylearner/article/details/7685022http://www.cocoachina.com/bbs/read.php?tid=200557http://blog.163.com/xianfuying@126/blog/static/21960005201181482518631/http://www.jian

2016-03-18 00:17:36 654

原创 Java面试知识学习笔记2(2016/3/8)

(接前一篇)在JVM垃圾收集器收集一个对象之前,一般要求程序调用适当的方法释放资源。finalize()用于终止化该对象来释放资源

2016-03-10 23:27:47 429

原创 数据挖掘/机器学习

1.SVM优缺点SVM有如下主要几个特点: (1)非线性映射是SVM方法的理论基础,SVM利用内积核函数代替向高维空间的非线性映射; (2)对特征空间划分的最优超平面是SVM的目标,最大化分类边际的思想是SVM方法的核心; (3)支持向量是SVM的训练结果,在SVM分类决策中起决定作用的是支持向量;(4)SVM 是一种有坚实理论基础的新颖的小样本学习方法。它基本上不涉及概率测度及

2016-03-09 21:17:11 555

原创 Java面试知识学习笔记1(2016/3/7)

1.异常Throwable-->Error,ExceptionRuntimeExpeption:如除数为0,空指针2.final(加上final就代表是最终的,不能被改变)变量+final:一旦被初始化,不可改变。基本类型值不能变,对象变量引用不能变。方法中的参数+final:基本类型:传值,对象变量:传递引用,防止意外改变方法+final:可以继承,不允许继承中的

2016-03-08 00:21:45 569

原创 面经阅读

1.2016/3/6阿里面试经历及总结(数据研发、Java研发方向)另一个链接摘取:我说:“比赛的时候,我们每天都要盯着数据提取特征。如果,仅仅把这个当作数字来看,确实很枯燥。但是,我们会把它当作一种用户行为对待和分析。这 样就变得很有趣了。比如,数据清洗后,我看到某个用户每天都在点击某一个品牌,他就是不买,很显然这就是屌丝;有些人一直在购买,明显的高富帅啊。Java问题:

2016-03-06 23:05:17 757

原创 Android demo--调用系统相机拍照并显示图片为黑白

1.环境搭建操作系统是Mac OS,一年多以前写Android的时候用的还是Eclipse,操作系统是Windows,记得环境很难搭建,总是会有错误,所以面试的时候要求完成这个Demo还是有一点点虚。不过用Baidu和Google查了怎么搭建环境之后,发现有了官方的IDE:Android Studio,我还是很开心的,决定不用eclipse搭环境了,改用Android Studio,因为这样只

2016-03-02 18:39:15 3932 2

原创 【leetcode】【Easy】【258. Add Digits】【Math】

题目:https://leetcode.com/problems/add-digits/Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3

2016-02-25 22:04:04 461

原创 【牛客网】【搜狐2016研发工程师编程题】【最大上升子序列】

问题:马戏团正打算出一个新节目“最高罗汉塔”,即马戏团员叠罗汉表演。考虑到安全因素,要求叠罗汉过程中,站在某个人肩上的人应该既比自己矮又比自己瘦,或相等。 团长想要本次节目中的罗汉塔叠的最高,由于人数众多,正在头疼如何安排人员的问题。小王觉得这个问题很简单,于是统计了参与最高罗汉塔表演的所有团员的身高体重,并且很快找到叠最高罗汉塔的人员序列。 现在你手上也拿到了这样一份身高体重表,请找出可以叠

2016-02-25 21:59:20 1116

原创 【牛客网】【网易2016研发工程师编程题】【辗转相除法求最大公约数】

小易经常沉迷于网络游戏.有一次,他在玩一个打怪升级的游戏,他的角色的初始能力值为 a.在接下来的一段时间内,他将会依次遇见n个怪物,每个怪物的防御力为b1,b2,b3...bn. 如果遇到的怪物防御力bi小于等于小易的当前能力值c,那么他就能轻松打败怪物,并 且使得自己的能力值增加bi;如果bi大于c,那他也能打败怪物,但他的能力值只能增加bi 与c的最大公约数.那么问题来了,在一系列的锻炼后,小

2016-02-25 20:39:34 1819

原创 【Leetcode】202-Happy Number【Java实现】【Easy】

Your runtime beats 82.86% of java submissions.stem:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any pos

2015-11-13 16:05:06 2104

原创 【Leetcode】238-Product of Array Except Self【Java实现】【Medium】【two way traverse】

复杂度要求O(n),不代表只能遍历一遍,可以遍历2遍、3遍。。。。product--->名词:积stem:Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of num

2015-11-11 22:48:25 657 1

原创 【Leetcode】136-single-number【Java实现】【位操作】

看到要求的空间、时间复杂度完全没有头绪。只好看discussion好巧妙。。完全想不到。。。还是没有经验啊。。。。异或操作:相同为0,不同为1stem:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorith

2015-11-05 18:25:39 843

原创 【Leetcode】299-bulls-and-cows【Java实现】【hash table】

最近有空就刷一下leetcode,299题自己的方法居然要50ms+,都不好意思贴出来。在discussion中看到了一个hash的方法。学习了一下,很巧妙,加油吧!stem:You are playing the following Bulls and Cows game with your friend: You write a 4-digit secret number and as

2015-11-05 17:48:22 1973

原创 Ubuntu14在虚拟机下的安装

开始没选择稍后安装,就没有安装上图形界面,后来才弄对。参考:http://wenku.baidu.com/link?url=7RqQEukuWLobPMaTxCPaH0JB0Fq9N0HCkv0tLe9fyGKc3VL0wNcBtj1d5EiYKtdTgcOiTBtzv-tmoxXHm1vo02jZ-bXGznq2XFEa8zh5SHuhttp://www.cnblogs.com/si

2014-11-06 14:23:04 672

原创 C学习小结【常用函数】

strcpy  字符串复制strcm

2014-10-19 22:48:17 421

原创 Linux实验二【最简单kernel module的例子】

首先要学习一些基础知识:1.模块(module)是可以按照需求加载或卸载到系统内核中,扩展了内核的功能而不需要重启或重新编译内核。

2014-10-19 16:52:13 1399

原创 VMware Workstation Ubuntu 无线上网

最近开始要做各种实验了,Linux课关于NAS的实验。wang

2014-10-11 21:49:50 852 1

原创 【九度OJ】1031【模拟】【C实现】【浙大2009】

简单题代码:

2014-09-28 19:52:54 453

原创 【九度OJ】1027【欧拉回路】【C实现】【浙大2008】

判断无向欧拉回路代码:

2014-09-28 19:42:19 539

原创 【九度OJ】1485【密码】【C实现】【北大2012】

题不难,挺有意思的,是个解密的过程

2014-09-20 15:33:30 784

原创 【九度OJ】1484【模拟】【C实现】【北大2012】

需要注意的就是一些字符串处理fangfa

2014-09-20 14:00:10 559

原创 【九度OJ】1480【动态规划】【C实现】【北大2012】

参考: http://blog.csdn.net/jdplus/article/details/20226807开始

2014-09-20 10:49:52 464

原创 【九度OJ】1465【最大公约数】【C实现】【北大2012】

主要是会求最大公约数的更相减损术

2014-09-19 19:11:26 603

原创 【九度OJ】1060【模拟】【C实现】【清华2000】

/*by qr jobdu 1060 2014-9-16*/#include //#include int main(){ int E[59]; int G[59]; int index1=0; int index2=0;//两个数组的指针 int i; for(i=3;i<=60;i++){ //2不是盈数 int sum=0;//因子的和 // int p=

2014-09-16 16:52:23 670

原创 【九度OJ】1061【快速排序】【C实现】【清华2000】

头一次用stdlib.h中的库函数qsort,还蛮简单的。另外还用了j代码:

2014-09-16 16:14:15 605

原创 【九度OJ】1489【矩阵乘法】【C实现】【哈工大2012】

较简单,开始输出的是错的,以为是1*2,应该是2*2代码:

2014-09-13 17:34:20 1014

NotePad___6.2.3

NotePad 软件 6.2.3版本

2013-03-09

空空如也

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

TA关注的人

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