- 博客(243)
- 收藏
- 关注
原创 剑指offer 09:斐波那契数列
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define PB push_back#defin
2015-03-09 21:43:46 573
原创 剑指offer:08 旋转数组的最小数字
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define PB push_back#defin
2015-03-09 21:33:33 527
原创 剑指offer :07 用两个栈实现队列
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define PB push_back#defin
2015-03-09 19:52:22 560
原创 剑指offer 06:重建二叉树
#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define PB push_back#defin
2015-03-09 19:22:54 535
原创 剑指offer 05: 从尾到头打印链表
#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define PB push_back#define MP make_
2015-03-09 16:53:49 521
原创 剑指offer 04 :替换空格
#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define PB push_back#define MP make_
2015-03-09 15:46:59 378
原创 剑指offer 03:二维数组中的查找
#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;#define PB push_back#define MP make_
2015-03-09 15:08:30 458
原创 Linux多线程二
客户端#include #include #include #include #include #include #include #include #include #include #include #define MAXN 1024#define client_port 12580struct sockaddr_in
2015-03-09 11:34:38 447
原创 Linux多线程一
客户端#include#include #include #include #include #include #include #include #include #include #define MAXN 1024static void *thread_send(void *arg) { char str[MAXN];
2015-03-05 23:59:46 528
原创 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 ma
2015-02-11 21:48:48 697
原创 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-02-11 21:17:54 504
原创 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-02-11 21:00:45 543
原创 Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at
2015-02-11 20:43:54 563
原创 Unique Paths II
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the
2015-02-11 20:33:52 804
原创 Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the
2015-02-11 20:14:56 581
原创 Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1]
2015-02-10 22:56:09 468
原创 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], [
2015-02-10 22:51:22 523
原创 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
2015-02-10 21:55:54 485
原创 Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node./** * Definition for binary tree
2015-02-10 21:33:44 721
原创 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-02-10 21:21:13 498
原创 Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".class Solution {public: string addBinary(string a, string b) { reve
2015-02-10 20:53:21 500
原创 Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va
2015-02-10 20:21:23 476
原创 Path Sum
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
2015-02-09 23:37:54 546
原创 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. * struct Lis
2015-02-09 22:36:06 486
原创 String to Integer (atoi)
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input ca
2015-02-09 22:07:49 441
原创 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.class Solution {pub
2015-02-08 22:50:21 730
原创 Remove Duplicates from Sorted Array II
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,
2015-02-08 20:08:17 516
原创 Remove Duplicates from Sorted Array
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with
2015-02-08 19:08:00 457
原创 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
2015-02-08 12:12:44 566
原创 冒泡,插入,归并排序
#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;const int n=10;void maopao(const in
2015-02-07 22:43:05 445
原创 Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321简单模拟class Solution {public: int reverse(int x) { char s[1111]; sprintf(s,"%d",
2014-10-29 19:53:53 743
原创 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?简单递推class Solution {pub
2014-10-29 19:35:56 832
原创 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)).题意:寻找两个有序数组的中位数,要求复杂度为O(log (m+
2014-10-29 19:28:05 894
原创 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-10-26 16:12:24 822
原创 ZOJ 3229 Shoot the Bullet 无源汇上下界最大流
Shoot the BulletTime Limit: 2 Seconds Memory Limit: 32768 KB Special JudgeGensokyo is a world which exists quietly beside ours, separated by a mystical border. It is a utopia where h
2014-10-10 15:02:50 1014
原创 SGU 194 Reactor Cooling 无源汇带上下界可行流
Reactor Coolingtime limit per test: 0.5 sec.memory limit per test: 65536 KBinput: standardoutput: standardThe terrorist group leaded by a well known international terrorist Ben
2014-10-10 10:24:35 1232
原创 UVA 11324 The Largest Clique 强连通缩点+DP
Problem B: The Largest CliqueGiven a directed graph G, consider the following transformation. First, create a new graph T(G) to have the same vertex set as G. Create a directed edge between two
2014-10-09 20:00:26 655
原创 FZU 2039 Pets 二分图匹配
PetsAccept: 278 Submit: 751Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionAre you interested in pets? There is a very famous pets shop in the center of the ACM
2014-10-09 16:08:11 653
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人