自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

cravingszy的博客

想要更好的东南小渣渣...

  • 博客(21)
  • 收藏
  • 关注

原创 59. Spiral Matrix II

Spiral Matrix II对比上一题 此题的题意: 其实跟上一题一样 同样使用四个for循环 主要注意不要搞混变量 不然很烦代码public class Solution { public int[][] generateMatrix(int n) { int[][] ret = new int[n][n]; int top = 0,lef

2016-04-28 09:33:27 198

原创 54. Spiral Matrix

螺旋数组Spiral Matrix题意: 使用递归,一次扫描一整圈,然后用x,y记录这个圈的左上角,递归完了都+1。rows, cols记录还没扫的有多少。思想比较简单,但相当容易出错。提交了好多次。 注意:1. 扫描第一行跟最后一行要扫到底部为止,而扫描左列和右列只需要扫中间的。1 2 3 4 5 6 7 8 9 10 11 12例如以上例子: 你要 先扫1234, 然

2016-04-27 09:48:57 225

原创 《乞力马扎罗山的雪》——海明威

《乞力马扎罗山的雪》——海明威这并不是一部恢弘巨著,只是一部中篇小说。在小说临近结尾时有这样一段话:极目远眺,他看到,好像整个宇宙那样宽广无垠,在阳光中显得那么高大宏伟,而且白得令人难以置信,那就是乞力马扎罗山的山巅。于是他明白,那儿就是他现在要飞去的地方。 如果没有读过,当然不能完全理解这段话的意思。即便是读过,也未必能完全理解。男主人公哈里,他有理想,同时热恋这个世界,有点写作的才华。但成年后

2016-04-26 16:33:52 1831

原创 53. Maximum Subarray

Maximum Subarray题意:给定一个数组 找出和最大的子序列 For example, given the array [−2,1,−3,4,−1,2,1,−5,4], the contiguous subarray [4,−1,2,1] has the largest sum = 6.代码其实题意很简单 使用动态规划即可public class Solution { pu

2016-04-26 09:28:48 169

原创 75. Sort Colors

Sort Colors**题意:**Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we will us

2016-04-25 09:54:53 282

原创 100. Same Tree

Same TreeGiven two binary trees, write a function to check if they are equal or not.代码:public class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { if(p == null && q == null)

2016-04-22 11:15:43 189

原创 50. Pow(x, n)

Pow(x, n)\计算x的n次方代码public class Solution { public double pow(double x, int m) { double temp=x; if(m==0) return 1; temp=pow(x,m/2); if

2016-04-21 10:21:39 292

原创 49. Group Anagrams

Group AnagramsGiven an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ [“ate”, “eat”,”tea”], [“nat”,”tan”], [“bat”] ]代码pub

2016-04-20 12:13:46 176

原创 java知识点2016.4.14

面试2016年4月14日南京 晴 25℃ 热 地点:华为南研所 心情:一般 任务:参加所谓的华为实习生面试(ps:同时也是自己人生的首面) …… 结果:自我认为一般,或许能拿到吧问题一:java反射机制 JAVA反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法;对于任意一个对象,都能够调用它的任意一个方法和属性;这种动态获取的信息以及动态调用对象的方

2016-04-19 14:55:58 273

原创 48. Rotate Image

Rotate Image分析:给定一个二维数组a[n][n]顺时针旋转90度,要解决这个问题,无疑,第一件事儿就是找规律。 代码public class Solution { public void rotate(int[][] matrix) { for(int i = 0; i < matrix.length; i++){ for(int j =

2016-04-19 09:59:10 178

原创 104. Maximum Depth of Binary Tree

夏天到了 不想学习 写个简单的代码清醒一下 然后突然发现然并卵 这比装的自己都看不下去了 o(︶︿︶)o 唉 不说了 还是乖乖去改论文吧。。。Maximum Depth of Binary TreeGiven a binary tree, find its maximum depth.代码public class Solution { public int maxDepth(

2016-04-18 09:25:59 149

原创 111. Minimum Depth of Binary Tree

Minimum Depth of Binary Tree题意: Given a binary tree, find its minimum depth.代码:public class Solution { public int minDepth(TreeNode root) { if(root == null) return 0; int left = mi

2016-04-15 11:22:22 202

原创 107. Binary Tree Level Order Traversal II

Binary Tree Level Order Traversal IIFor example: Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9 20 / \ 15 7 return its bottom-up level order traversal as: [ [15,7], [9,2

2016-04-13 09:22:03 196

原创 102. Binary Tree Level Order Traversal

Binary Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree {3,9,20,#,#,15,7}

2016-04-12 14:14:49 204

原创 80. Remove Duplicates from Sorted Array II

Remove Duplicates from Sorted Array IIWhat if duplicates are allowed at most twice? For example, Given sorted array nums = [1,1,1,2,2,3], Your function should return length = 5 可以保留2次重复的代码public cl

2016-04-11 11:04:50 197

原创 82. Remove Duplicates from Sorted List II

Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4->4-

2016-04-10 15:00:34 252

原创 83. Remove Duplicates from Sorted List

Remove Duplicates from Sorted List删除重复的 Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, retu

2016-04-10 11:11:48 195

原创 52. N-Queens II

N-Queens II、跟51. N-Queens I条件一样 只是此题求出有多少个解即可代码public class Solution { Set<Integer> cols = new HashSet<Integer>(); Set<Integer> diags1 = new HashSet<Integer>(); Set<Integer> diags2 = new H

2016-04-07 10:42:40 201

原创 51. N-Queens

N-Queens皇后问题 解题思路使用回溯法解决N皇后问题,是常见的解决方法。分N步放置皇后,由于皇后之间不能同行、同列、同斜线,所以每次放置皇后的时候,都要考虑是否与已有的皇后“冲突”,如果冲突,则改变位置,直至所有皇后放置完毕。代码

2016-04-06 17:21:09 307

原创 127. Word Ladder

Word Ladder 使用了bfs(宽度优先搜索算法) 随便看看 代码复制别人的~~~代码public class Solution { public int ladderLength(String beginWord, String endWord, Set<String> wordList) { Set<String> beginSet = new HashSet<

2016-04-05 10:47:36 298

原创 随便看看

自我理解可能许多人对内存分配上的“栈 stack ”和“堆 heap ”还不是很明白。简单的来讲, stack 上分配的内存系统自动释放, heap 上分配的内存,系统不释放,哪怕程序退出,那一块内存还是在那里。 stack 一般是静态分配内存, heap 上一般是动态分配内存。 由 malloc 系统函数分配的内存就是从堆上分配内存。从堆上分配的内存一定要自己释放。用 free 释放,不

2016-04-03 10:10:56 190

空空如也

空空如也

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

TA关注的人

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