自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(127)
  • 资源 (2)
  • 收藏
  • 关注

原创 双调旅行商问题 (Bitonic TSP)

问题描述:上述问题可以使用动态规划的方法来解决。下面是解决思路的具体介绍:1. 最优子结构:假设d[i][j]表示从起点1出发到达i及j两个顶点的最短路程之和。为此可以假设K为此段路程上与j相加的节点,则d[i][j] = d[i][k] + len[k][j]。证明:若存在一个更短的路径d[i][k],则就应该存在更短的路径d[i][j],这与假设矛盾,因此得证。下面来寻找j相

2015-07-06 11:01:08 3184

原创 LeetCode--Binary Search Tree Iterator

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Note: next()

2015-01-16 15:10:10 898

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

2015-01-16 14:48:10 772

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

2015-01-16 14:44:24 780

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

2015-01-16 11:30:52 620

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

2015-01-16 11:17:37 755 1

原创 LeetCode--Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘

2015-01-16 11:12:06 780

原创 LeetCode--Compare Version Numbers

Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co

2015-01-16 11:10:11 767

原创 LeetCode--Merge Intervals

Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18]./** * Definition for an interval. * struct Inter

2015-01-16 10:55:46 625

原创 LeetCode--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.class Solution {public: string mul

2015-01-16 10:23:50 670

原创 LeetCode--First Missing Positive

Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant

2015-01-16 09:31:46 718

原创 LeetCode--Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get

2015-01-15 20:17:01 715

原创 LeetCode--Find Minimum in Rotated Sorted Array II

Follow up for "Find Minimum in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Suppose a sorted array is rotated at some pivot u

2015-01-15 20:05:16 678

原创 LeetCode--Find Minimum in Rotated Sorted Array

Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exists in

2015-01-15 20:00:49 692

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

2015-01-15 19:49:52 687

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

2015-01-15 16:04:59 782

原创 LeetCode--Sort List

Sort a linked list in O(n log n) time using constant space complexity.MergeSort对于链表的排序,实现了就地排序的同时,时间复杂度和空间复杂度都达到了基于比较的排序的最优值,因此归并排序是链表排序的最佳排序方式。/** * Definition for singly-linked list. * str

2015-01-15 15:50:23 799

原创 LeetCode--Insertion Sort List

Sort a linked list using insertion sort./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * };

2015-01-15 14:32:26 684

原创 LeetCode--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",

2015-01-15 11:13:44 662

原创 LeetCode--Binary Tree Postorder Traversal

Given a binary tree, return the postorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [3,2,1].Note: Recursive solut

2015-01-15 10:54:58 692

原创 LeetCode--Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3].Note: Recursive soluti

2015-01-15 10:51:06 610

原创 LeetCode--Reorder List

Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to 

2015-01-15 10:46:14 651

原创 LeetCode--Linked List Cycle II

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. *

2015-01-15 10:02:55 633

原创 LeetCode--Linked List Cycle

Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?/** * Definition for singly-linked list. * struct ListNode { * int val; *

2015-01-15 09:53:19 727 1

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

2015-01-15 09:41:46 598

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

2015-01-15 09:34:19 577

原创 LeetCode--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-01-15 00:03:02 678 1

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

2015-01-14 23:52:06 495

原创 LeetCode--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-14 23:10:09 538

原创 LeetCode--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-14 22:46:31 578

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

2015-01-14 21:53:58 562

原创 LeetCode--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?class Solution

2015-01-14 21:22:42 515

原创 LeetCode--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]]class Solution {public:

2015-01-14 18:00:00 485

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

2015-01-14 17:43:43 591

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

2015-01-14 17:06:34 531

原创 LeetCode--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-14 16:04:24 571

原创 LeetCode--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-01-14 15:35:15 614

原创 LeetCode--Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node./** * Definition for binary tree *

2015-01-14 15:27:40 532

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

2015-01-14 15:17:30 716

原创 LeetCode--Convert Sorted List to Binary Search Tree

Given an array where elements are sorted in ascending order, convert it to a height balanced BST./** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *nex

2015-01-14 15:09:25 608

计算机原理课件下载11

计算机原理课程教案,适用于计算机原理的初学者 ,比较好掌握,易于理解

2011-05-05

空空如也

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

TA关注的人

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