摘要:
原题链接: https://www.patest.cn/contests/pat-a-practise/1018) 选择最短路径比较简单,dijkstra算法即可,但是要考虑send_bikes和back_bikes,注意在去程途中,如果先前的节点中有多余的自行车,可以提供给后面站点,这样从PBMC 阅读全文
摘要:
#include #include /* printf, scanf, puts, NULL */ #include /* srand, rand */ #include /* time */ using namespace std; int main(void) { int total = 10; int num = 8; i... 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
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: 阅读全文
摘要:
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 阅读全文
摘要:
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 阅读全文