- 博客(15)
- 收藏
- 关注
原创 期末项目:Capacitated Facility Location Problem
题目代码import randomimport mathimport datetimeimport osimport timeINSTANCE_NUMBER = 71LOOP_LENGTH = 1000MAX_TEMPERATURE = 100MIN_TEMPERATURE = 0.5ATTENUATION_QUOTIENT = 0.9MAX_NUM = 10000...
2018-12-31 00:09:03
296
原创 LeetCode 算法学习(14)
题目描述Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i...
2018-12-29 14:31:43
144
原创 LeetCode 算法学习(13)
题目描述Given a binary tree, return the inorder traversal of its nodes’ values.题目大意对二叉树进行中序遍历。思路分析这里我使用非递归的写法,关键在于处理好入栈时机和出栈时机。当栈顶元素没有左子树时出栈,p转向其右子树继续遍历。关键代码 vector<int> inorderTraversal...
2018-12-29 13:59:54
188
1
原创 LeeCode 算法学习(12)
题目描述Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys...
2018-12-27 20:06:16
224
原创 LeetCode 算法学习(11)
题目描述Construct Binary Tree from Preorder and Inorder TraversalGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree...
2018-12-27 18:58:36
219
原创 LeetCode算法学习(10)
题目描述Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.Example:Given 1->2->3->4, you should return the list as 2->1->4->3.Note:Your al...
2018-12-26 23:58:39
171
原创 LeetCode算法学习(9)
题目描述Merge Two Sorted ListsMerge 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.Example:Input: 1->2->...
2018-12-26 23:22:30
105
原创 LeetCode算法学习(8)
题目描述Valid ParenthesesGiven a string containing just the characters ‘(’, ‘)’, ‘{’, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.An input string is valid if:1.Open brackets must be clos...
2018-12-26 22:57:00
141
原创 LeetCode 算法学习(7)
题目描述Remove Nth Node From End of ListGiven a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After remo...
2018-12-26 22:36:15
161
原创 LeetCode 算法学习(6)
题目描述Container With Most WaterGiven n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is a...
2018-12-26 21:19:20
113
原创 LeetCode 算法学习(5)
题目描述String to Integer (atoi)Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is ...
2018-12-26 18:32:01
119
原创 LeetCode 算法学习(4)
題目描述Reverse IntegerGiven a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Note:Assume we are dealing with an environment which could only store integers w...
2018-12-26 17:56:13
137
原创 LeetCode 算法学习(3)
算法描述Median of Two Sorted ArraysThere are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m...
2018-12-26 16:09:58
79
原创 LeetCode 算法学习(2)
题目描述Longest Substring Without Repeating CharactersGiven a string, find the length of the longest substring without repeating characters.Example 1:Input: “abcabcbb”Output: 3Explanation: The ans...
2018-12-25 22:05:46
172
原创 LeetCode 算法学习(1)
题目描述Add Two NumbersYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the tw...
2018-12-25 17:06:34
136
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人