- 博客(115)
- 资源 (6)
- 收藏
- 关注
原创 shell编程小tip(陆续更新)
1、运算e.g. ((data=$data/10))和data=`expr $data /10`的区别有的时候取出来的数data=08而不是8,,这时候用第一种就会出语法错误-bash: ((: data=08: value too great for base (error token is "08")这是就只能用第二种data=`expr $data / 10`
2015-03-10 12:24:49 542
原创 Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 123.Find the tota
2015-02-04 17:44:12 583
原创 4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Element
2015-02-04 17:14:13 599
原创 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact
2015-02-04 16:11:00 604
原创 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
2015-02-04 12:59:21 607
原创 Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.#include#includetypedef struct TreeNode { int v
2015-01-30 17:57:45 561
原创 Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \
2015-01-30 15:32:53 595
原创 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
2015-01-30 14:44:42 446
原创 Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible
2015-01-30 13:57:00 448
原创 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
2015-01-30 11:25:48 619
原创 Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.string intToRoman(int num) { int numarr[] = {1, 4, 5, 9, 10, 40, 50, 90, 100, 400,
2015-01-29 15:39:25 535
原创 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.#include#includ
2015-01-27 13:57:31 494
原创 Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to
2015-01-23 18:12:10 506
原创 Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.#include#includetypedef struct TreeNode { int val
2015-01-23 15:49:44 414
原创 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
2015-01-21 17:55:54 554
原创 Permutations
Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].C++:class S
2015-01-20 11:48:28 489
原创 Pow(x, n)
Pow(x, n) Total Accepted: 35792 Total Submissions: 135252My SubmissionsQuestion Solution Implement pow(x, n).#includedouble ipow(double x, int n) { if(n == 0) r
2015-01-20 10:19:39 535
原创 N-Queens II
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.class Solution {public:void print(int queue[], int n, vector> &
2015-01-19 18:50:58 458
原创 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.
2015-01-19 18:23:44 402
原创 Multiply Strings
Given two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbitrarily large and are non-negative.#include#include#includechar *mul
2015-01-14 20:03:16 398
原创 堆排序
#includevoid AdjustHeap(int A[], int i, int n) { int j, tmp, tmpid; for( ; i * 2 + 1 < n; i++) { if(i * 2 + 2 >= n) { tmp = A[i * 2 + 1]; tmpid = i * 2 + 1;
2015-01-14 17:14:11 475
原创 Sort List
Sort a linked list in O(n log n) time using constant space complexity.#include#includetypedef struct ListNode{ int val; struct ListNode *next;}ListNode;ListNode *mergesort(ListNode *
2015-01-13 17:13:13 437
原创 sort
#include//bubble sortvoid BubbleSort(int A[], int n) { int i, j, tmp, flag = 1; j = n - 1; while (flag) { flag = 0; for (i = 0; i < j; i++) { if (A[i] > A[i
2015-01-07 20:52:15 578
原创 Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You may
2015-01-04 16:04:10 601
原创 Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on
2015-01-04 15:06:35 375
原创 Best Time to Buy and Sell Stock
Say 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 stock),
2015-01-04 13:54:57 444
原创 Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin
2014-12-31 18:01:04 434
原创 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-12-31 10:18:59 494
原创 Majority Element
Given 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 element
2014-12-30 09:54:56 546
原创 Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB 注:包含了171E
2014-12-29 16:07:49 564
原创 Excel Sheet Column Number
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ...
2014-12-29 15:02:58 364
原创 Single Number II
Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without usi
2014-12-29 11:35:08 331
原创 Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expression.Some examples: ["2", "1",
2014-12-26 11:15:58 448
原创 Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".click to show clarification.Clarification:What constitutes
2014-12-26 10:28:14 700
原创 apt-get Unable to fetch some archives的解决方法
报错:E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/g/glibc/libc6-dev_2.19-10ubuntu2.2_amd64.deb Could not resolve 'archive.ubuntu.com'E: Failed to fetch http://archive.ubuntu.co
2014-12-25 17:01:14 18196 3
原创 CephFS环境搭建(二)
《CephFS环境搭建(一)》介绍了如何简单搭建一个单Mon,MDS的Cephfs并导出使用,这里深入一步建立三个池,SSD和SATA分开存放在不同的池,建立多Mon,多MDS,结合纠删码,cache分层,建立一个比较健全的cephfs。
2014-12-25 13:58:19 3941 1
原创 Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the larges
2014-12-25 13:19:29 456
原创 常用的shell命令(陆续更新)
1、获取管道前面的返回值 echo ${PIPESTATUS[0]}e.g.root@node2:~# date1 | echo 22No command 'date1' found, did you mean: Command 'date' from package 'coreutils' (main)date1: command not foundroot@node2
2014-12-24 14:28:09 970
原创 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-12-22 19:04:54 389
原创 Single Number
Given 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 ext
2014-12-19 17:13:34 505
apache-tomcat-6.0.18.exe
2012-01-09
Migrating Enterprise Storage Applications to the Cloud
2012-01-09
Configure选项简介
2011-12-28
Jquery 15 天教程
2011-12-14
分布式网络存储Distributed File Systems--Concepts and Examples.PDF
2010-04-12
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人