
实用数据结构
文章平均质量分 74
旻宇
New Acmer
展开
-
POJ2481 Cows
DescriptionFarmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his field is particularly good. Fa原创 2014-07-16 14:53:29 · 521 阅读 · 0 评论 -
POJ2528 Mayor's posters
URL:http://poj.org/problem?id=2528DescriptionThe citizens of Bytetown, AB, could not stand that the candidates in the mayoral election campaign have been placing their electoral posters at all p原创 2015-08-16 17:22:47 · 362 阅读 · 0 评论 -
POJ3468 A Simple Problem with Integers
线段树子区间更新维护#include struct interval_tree{ int nums[100010]; struct Node{ long long mark, sum; } node[100010 << 2]; void build(int l, int r, int i) { if (l == r) {no原创 2015-08-16 12:33:40 · 394 阅读 · 0 评论 -
LeeetCode #84 Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width o原创 2015-08-14 19:17:44 · 508 阅读 · 0 评论 -
LeetCode # 149 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. 本题有点戏剧性,在本地测试代码的时候,答案并不正确,经过很长时间反复排查逻辑后提交竟然AC了,估计是我GCC-C++版本浮点型计算的精度问题。class Solution {pub原创 2015-08-02 22:19:34 · 424 阅读 · 0 评论 -
LeetcCode #220 Contains Duplicate III
Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] andnums[j] is at most t and the difference between i and原创 2015-08-03 15:46:21 · 443 阅读 · 0 评论 -
Leetcode #222 Count Complete Tree Nodes
Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely fille原创 2015-08-02 18:53:51 · 373 阅读 · 0 评论 -
Leetcode Basic Calculator 系列
Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, / operators and empty spaces. The integer division should原创 2015-08-02 13:25:46 · 521 阅读 · 0 评论 -
Leetcode #234 Palindrome Linked List
Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?用o(1)的space来创建一个反向的链表,也能AC,时间是36ms,代码如下:class Solution {public: bool isPa原创 2015-08-01 16:57:07 · 371 阅读 · 0 评论 -
Leetcode #236 Lowest Common Ancestor of a Binary Tree
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two node原创 2015-07-31 15:19:05 · 389 阅读 · 0 评论 -
LeetCode #124 Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3Return 6.原创 2015-08-10 11:02:14 · 410 阅读 · 0 评论 -
LeetCode #200 Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assu原创 2015-08-10 10:10:26 · 463 阅读 · 0 评论 -
leetcode #211 Add and Search Word - Data structure design
Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word or a regular expression string containing only le原创 2015-05-17 18:23:09 · 469 阅读 · 0 评论 -
Leetcode #212 Word Search II
Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horiz原创 2015-08-01 12:31:27 · 447 阅读 · 0 评论 -
Uva 11997 - K Smallest Sums
URL: Problem KK Smallest SumsYou're given k arrays, each array has k integers. There are kk ways to pick exactly one element in each array and calculate the sum of the integers. Your ta原创 2014-07-15 19:26:40 · 514 阅读 · 0 评论 -
POJ1182 食物链
URL : http://poj.org/problem?id=1182原创 2014-05-18 17:17:31 · 558 阅读 · 0 评论 -
POJ2828 Buy Tickets
URL: http://poj.org/problem?id=2828原创 2014-07-16 16:27:34 · 457 阅读 · 0 评论 -
POJ3667 Hotel
URL:http://poj.org/problem?id=3667DescriptionThe cows are journeying north to Thunder Bay in Canada to gain cultural enrichment and enjoy a vacation on the sunny shores of Lake Superior. Bes原创 2015-08-17 11:02:39 · 397 阅读 · 0 评论