11 uj_mosquito



TA的排名 3w+


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

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


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

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


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

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

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

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

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

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

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

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

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

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

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


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

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

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


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

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


勋章 我的勋章
  • 持之以恒