自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Wu_George的专栏

不相信所谓的运气、天赋、捷径,努力的程度压根就没到拼天赋的时候.

  • 博客(178)
  • 资源 (1)
  • 收藏
  • 关注

转载 C语言中.h和.c文件差别

转自:http://blog.csdn.net/zzhays/article/details/8036460C文件就是C语言系列的源文件,而H文件则是C语言的头文件,即C系列中存放函数和全局变量的文件,因为C中的函数是被封装起来的,即无法看到其代码。        子程序不要定义在*.h中。函数定义要放在*.c中,而*.h只做声明.否则多引用几次,就会发生函数重复定义的错误。*

2015-04-18 23:34:51 1040

原创 Sqrt(x)

Implement int sqrt(int x).Compute and return the square root of x.public class Solution { public int sqrt(int x) { if(x == 0 || x==1) return x; int low = 1, high =

2014-05-19 23:06:13 666

原创 【DP】Climbing Stairs

You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?public class Solution {

2014-05-19 21:54:29 521

原创 Plus One

Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.public class Solutio

2014-05-19 21:03:01 483

原创 Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".public class Solution { public String addBinary(String a, String b) {

2014-05-19 20:49:12 552

原创 【链表】Merge Two Sorted Lists

Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists./** * Definition for singly-linked list. * public c

2014-05-19 20:21:22 447

原创 【区间合并】Insert Interval

Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.E

2014-05-19 11:43:47 504

原创 【区间合并】Merge Intervals

/** * Definition for an interval. * public class Interval { * int start; * int end; * Interval() { start = 0; end = 0; } * Interval(int s, int e) { start = s; end = e; } * } */

2014-05-19 11:32:57 543

原创 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

2014-05-18 16:59:37 495

原创 Spiral Matrix II

Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [

2014-05-18 16:43:14 389

原创 【排列】Permutation Sequence

The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""3

2014-05-18 16:23:55 437

原创 【链表】Rotate List

Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.链表右移K位public class Solution {

2014-05-15 22:42:13 499

原创 【链表】删除链表中连续重复的节点

MS的一个面试题,删除链表中连续重复的节点,如1,2,2,2,3

2014-05-15 21:59:43 653

原创 计算阶乘n!末尾的0的个数

思路参考:http://www.oschina.net/code/snippet_112092_9454

2014-05-04 22:41:44 549

原创 【Java源码】HashSet、LinkedHashSet

一、HashSet——》属性1、HashSet内部其实使用一个HashMap来存储元素private transient HashMap map;2、PRESENT对象,因为HastSet只需要保存key,而HashMap处理Key之外还有value,所以HastSet中讲一个static final对象保存在map中// Dummy value to associate wi

2014-04-22 09:00:19 430

原创 【Java源码】TreeMap类

上一篇分析了HashMap的源码,今天有人在群里面试了阿里说问到了HashMap和TreeMap的比较,所以干脆也来看看TreeMap的实现。HashMap是Map的非同步实现,而TreeMap也不是同步的,TreeMap和HashMap的最大区别在于元素的放置:——》HashMap使用哈希表的方式存储元素,所以插入、删除、查询定位比较快——》而TreeMap则使用RB-Tree(

2014-04-21 21:44:27 641

原创 【Java源码】HashMap类

HashMap是Map的非同步实现,这是HashMap和Hashtable的区别

2014-04-21 20:11:44 515

原创 【Java源码】Integer类

Java中Integer为32位,所以它的最大值最小值又如下:/** * A constant holding the minimum value an int can * have, -231. */ public static final int MIN_VALUE = 0x80000000; /** * A constant

2014-04-20 21:12:10 517

原创 【Java源码】String类

一、属性解读/** The value is used for character storage. */ private final char value[]; /** The offset is the first index of the storage that is used. */ private final int offset; /** Th

2014-04-20 20:10:30 606

原创 【矩阵】Search a 2D Matrix

public class Solution { public boolean searchMatrix(int[][] matrix, int target) { int row = matrix.length; if(row == 0) return false; int col = matrix[0].length;

2014-04-20 16:05:51 452

原创 【矩阵】Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight forward solution using O(m

2014-04-20 15:20:50 667

原创 【数组&归并】Merge Sorted Array

Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from

2014-04-20 13:01:08 415

原创 【DFS&字符串】Scramble String

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation of s1 = "great": great / \ gr

2014-04-20 12:49:28 571

原创 【链表】Partition List

Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should preserve the original relative order of the nodes in each of

2014-04-20 11:17:45 465

原创 【位计算】Gray Code

The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence of

2014-04-19 21:07:03 505

原创 【链表转置】

Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy t

2014-04-19 20:37:19 606

原创 【二叉树&前序遍历】Flatten Binary Tree to Linked List

Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like: 1

2014-04-19 17:57:44 382

原创 【二叉树&层次遍历】Populating Next Right Pointers in Each Node II

Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant

2014-04-19 17:03:01 535

原创 【二叉树&层次遍历】Populating Next Right Pointers in Each Node

Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next right node.

2014-04-19 16:59:49 435

原创 Pascal's Triangle II

Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?public class S

2014-04-19 16:25:07 390

原创 Pascal's Triangle

Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]public class Solution {

2014-04-19 16:21:20 357

原创 LRU Cache

Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if

2014-04-19 16:08:13 404

原创 【字符串回文】Valid Palindrome

Given 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."race a car" is not a

2014-04-19 14:27:54 476

原创 【数组】Longest Consecutive Sequence

public class Solution { public int longestConsecutive(int[] num) { int len = num.length; HashSet hs = new HashSet(); for(int i=0; i<len; i++){ hs.add(num[i]);

2014-04-19 14:04:58 428

原创 【N皇后&DFS】N-Queens II

public class Solution { public int n=0, count=0; public int []col; public void swap(int num[], int i, int j){ int t = num[i]; num[i] = num[j]; num[j] = t;

2014-04-19 13:34:48 461

原创 【N皇后&DFS】N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.

2014-04-19 11:58:23 400

原创 【矩阵】Spiral Matrix

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]

2014-04-19 11:06:22 433

原创 Pow(x, n)

题意:实现求x的npublic class Solution { public double pow(double x, int n) { double res = 1; boolean flag = false; if(n == 0) return 1; if(n < 0){ flag = tru

2014-04-19 10:33:45 465

原创 【字符串】Anagrams

Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.题意:public class Solution { public ArrayList anagrams(String[] strs) {

2014-04-19 10:21:36 522

原创 【旋转矩阵】Rotate Image

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?public class Solution { public void rotate(int[

2014-04-17 22:04:28 557

自动定时关机工具,为自己省时省电

自动 定时的关机 当你下载时就不要等下载完再自己关机了

2009-12-02

空空如也

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

TA关注的人

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