摘要: 原题链接: https://www.patest.cn/contests/pat-a-practise/1018) 选择最短路径比较简单,dijkstra算法即可,但是要考虑send_bikes和back_bikes,注意在去程途中,如果先前的节点中有多余的自行车,可以提供给后面站点,这样从PBMC 阅读全文
posted @ 2017-03-22 18:39 WillWu 阅读(179) 评论(0) 推荐(0) 编辑
摘要: #include #include /* printf, scanf, puts, NULL */ #include /* srand, rand */ #include /* time */ using namespace std; int main(void) { int total = 10; int num = 8; i... 阅读全文
posted @ 2017-02-27 22:47 WillWu 阅读(317) 评论(0) 推荐(0) 编辑
摘要: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the 阅读全文
posted @ 2017-02-15 22:51 WillWu 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up:Can you 阅读全文
posted @ 2017-02-13 22:18 WillWu 阅读(129) 评论(0) 推荐(0) 编辑
摘要: Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning 阅读全文
posted @ 2017-02-13 21:40 WillWu 阅读(99) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in th 阅读全文
posted @ 2017-02-04 13:53 WillWu 阅读(137) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL 阅读全文
posted @ 2017-02-03 18:59 WillWu 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Flatten Binary Tree to Linked List Given a binary tree, flatten it to a linked list in-place. For example,Given The; flattened tree should look like: 阅读全文
posted @ 2017-02-01 22:13 WillWu 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文
posted @ 2017-01-25 22:38 WillWu 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example,Given n = 3, You should return the followi 阅读全文
posted @ 2017-01-24 20:55 WillWu 阅读(139) 评论(0) 推荐(0) 编辑