自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 精度为p的float sqrt

写一个函数float sqrt(float x, int p), 要求返回的结果result平方后小数点后p位与原数x相同。基本思路二分法如下:public float sqrt(float x, int p) { if (x == 0) { return 0; } if (x < 0) {

2015-08-31 05:33:19 757

转载 Hadoop的安装配置

https://www.digitalocean.com/community/tutorials/how-to-install-hadoop-on-ubuntu-13-10原帖已经很完美,对我个人来说出了个bug,在修改hdfs-site.xml时,很奇怪的按照他的设置方法,我的datanode怎么都出不来。经过多次试错,发现去掉datanode设定那几句话就行了。非常奇怪。但是好歹现

2014-12-07 16:00:06 538

原创 [Leetcode]Trapping Rain Water

Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]

2014-11-20 07:48:44 482

原创 [Leetcode]Clone Graph

Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each

2014-11-20 07:21:23 328

原创 [Leetcode]Populating Next Right Pointers in Each Node I && II

IGiven a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next r

2014-11-20 02:01:43 383

原创 LAMP几个常用配置

改变document root directory:

2014-11-11 17:05:55 413

原创 [Leetcode]Combinations & Permutations

先记录代码,回头写分析Com

2014-11-10 13:28:35 496

原创 [Leetcode]Max Points on a Line

Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.这道题中zui zhong yao d

2014-11-10 02:45:57 487

转载 [Leetcode]Median of Two Sorted Arrays

There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).

2014-11-09 15:20:40 410

原创 Reverse every word in a String

不能使用reverse啥的函数public String reverseString(String str){ String temp = "", result = ""; for(int i=0;istr.length();i++) if ( (str.charAt(i)>='A' && str.charAt(i)

2014-11-08 15:26:50 502

原创 [Leetcode]Permutations and Permuations II

Permutations

2014-11-07 12:26:48 354

原创 [Leetcode]Unique Binary Search Trees I & II

Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \

2014-11-07 09:04:55 344

原创 [Leetcode]Convert Sorted Array & List to Binary Search Tree

Convert Sorted Array to Binary Search Tree

2014-11-07 08:03:05 561

原创 [Leetcode]Pow(x, n)

使用二分法实现可以使时间复杂度变为O(logn)

2014-11-07 07:03:00 302

原创 [Leetcode]Iterative preorder, inorder, postorder traversal

Postorder Traversal

2014-11-07 06:24:13 607

原创 [Leetcode]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-11-06 14:17:26 394

原创 [Leetcode]3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c

2014-11-06 13:23:42 387

原创 [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, whe

2014-11-06 12:03:50 333

原创 [Leetcode]Longest Palindromic Substring

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.这道题zhu yao k

2014-11-05 12:59:05 299

原创 [Leetcode]Add Two Numbers

You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link

2014-11-05 12:24:12 307

原创 [Leetcode]Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [

2014-11-05 12:05:50 367

原创 [Leetcode]Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]

2014-11-05 11:47:11 412

原创 [Leetcode]Implement strStr()

Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.方法见上

2014-11-05 05:56:39 364

转载 3种解决searching string的方法

The fundamental string searching (matching) problem is defined as follows: given two strings - a text and a pattern, determine whether the pattern appears in the text. The problem is also known as "th

2014-11-05 03:43:49 1315

原创 [Leetcode]Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".

2014-11-05 02:42:33 442

原创 Least Common Ancestor in a Binary Tree

The problem is: Given a binary tree (not a binary search tree) and two values say n1 and n2, write a program to find the least common ancestor.思路:如果

2014-11-04 13:41:58 336

原创 [Leetcode]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?

2014-11-03 04:13:50 256

原创 [Leetcode]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, return 1->2->3.

2014-11-03 03:44:19 256

原创 [Leetcode]Remove Nth Node From End of List

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2014-11-03 03:26:42 349

原创 [Leetcode]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-11-03 03:08:56 253

原创 [Leetcode]Balanced Binary Tree

Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diffe

2014-11-03 02:11:25 333

原创 [Leetcode]Path Sum&Path Sum II

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum

2014-11-03 01:51:19 312

原创 [Leetcode]Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.思路很简单,对所有在strs中的strings

2014-11-02 16:11:24 301

原创 [Leetcode]Count and Say

The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as 

2014-11-02 15:46:17 320

原创 [Leetcode]Symmetric Tree

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the f

2014-11-02 15:11:01 314

原创 [Leetcode]Interleaving String

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc", ret

2014-11-02 07:08:40 258

原创 [Leetcode]Multiply Strings

这一题刚看吓坏了,看了yi xie wang shagn de

2014-11-01 13:07:43 262

转载 C++创建对象的两种方法

在C++里,有两种方法创建对象:方法一:ClassName object(param);这样就声明了一个ClassName类型的object对象,C++会为它分配足够的存放对象所有成员的存储空间。注意:为节省存储空间,C++创建对象时仅分配用于保存数据成员的空间,而类中定义的成员函数则被分配到存储空间中的一个公用区域,由该类的所有对象共享。例如,我定义了一个

2014-10-31 13:49:49 312

原创 [Leetcode]Valid Number

Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguous

2014-10-31 06:22:36 371

转载 CPP stack, heap

The memory a program uses is typically divided into four different areas:The code area, where the compiled program sits in memory.The globals area, where global variables are stored.The heap, wher

2014-10-29 08:14:14 394

空空如也

空空如也

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

TA关注的人

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