leetcode
文章平均质量分 53
matrix6666
这个作者很懒,什么都没留下…
展开
-
【leetcode】已排序数组去重 II
80. Remove Duplicates from Sorted Array IIleetcode题目描述题目描述:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra s原创 2017-09-12 21:44:02 · 1107 阅读 · 0 评论 -
【Algorithms】NP-complete problems(exersises-8.8)
题目8.8 在EXACT 4SAT问题中,输入为一组子句,每个子句都恰为4个literal的析取,且每个变量最多在每个子句中出现一次。目标是求其satisfying assignment(若其确实存在)。证明 EXACT 4SAT是NP完全问题。原创 2018-01-03 08:24:21 · 290 阅读 · 0 评论 -
【leetcode】二叉树后序遍历(stack)
145. Binary Tree Postorder Traversalleetcode题目题目描述Given a binary tree, return the postorder traversal of its nodes’ values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3原创 2018-01-03 14:41:39 · 367 阅读 · 0 评论 -
【leetcode】二叉树中序遍历(stack)
94. Binary Tree Inorder Traversalleetcode题目题目描述Given a binary tree, return the inorder traversal of its nodes’ values. For example: Given binary tree [1,null,2,3], 1 \ 2 / 3re原创 2018-01-03 14:09:36 · 531 阅读 · 0 评论 -
【leetcode】二叉树先序遍历(stack)
144. Binary Tree Preorder Traversalleetcode题目题目描述Pick OneGiven a binary tree, return the preorder traversal of its nodes’ values. For example: Given binary tree [1,null,2,3], 1 \ 2原创 2018-01-03 13:56:12 · 277 阅读 · 0 评论 -
【leetcode】Unique Paths II(动态规划)
63. Unique Paths IIleetcode题目题目描述Discuss Pick OneFollow up for “Unique Paths”: Now consider if some obstacles are added to the grids. How many unique paths would there be? An obstacle and empty spac原创 2018-01-03 13:16:54 · 292 阅读 · 0 评论 -
【leetcode】Unique Paths(动态规划)
62. Unique Pathsleetcode 题目描述A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time.原创 2018-01-03 09:34:45 · 298 阅读 · 0 评论 -
【leetcode】回文串划分(DFS)
131. Palindrome Partitioningleetcode题目题目描述Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, gi原创 2017-12-13 08:05:21 · 257 阅读 · 0 评论 -
【leetcode】Reverse Integer(考虑溢出问题)
7. Reverse Integerleetcode题目题目描述Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123 Output: 321 Example 2:Input: -123 Output: -321 Example 3:Input: 120 Output: 21Note原创 2017-11-22 11:33:15 · 268 阅读 · 0 评论 -
【leetcode】最长连续序列(unordered_map的使用)
128. Longest Consecutive Sequenceleetcode题目描述题目描述:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The lo原创 2017-11-22 09:16:10 · 759 阅读 · 0 评论 -
【leetcode】Two Sum(unordered_map的使用)
1. Two Sumleetcode题目描述题目描述:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and y原创 2017-11-22 10:39:24 · 440 阅读 · 0 评论 -
【leetcode】搜索范围(二分查找升序数组target元素上下界)
34. Search for a Rangeleetcode题目描述题目描述:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm’s runtime complexity must be原创 2017-11-01 09:46:06 · 796 阅读 · 0 评论 -
【leetcode】寻找两个已排序数组的中位数(类似二分)
4. Median of Two Sorted Arraysleetcode题目描述题目描述:There 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 shoul原创 2017-10-23 21:57:30 · 809 阅读 · 0 评论 -
【leetcode】查找插入位置(二分)
35. Search Insert Positionleetcode题目描述题目描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. Y原创 2017-09-20 10:31:17 · 820 阅读 · 0 评论 -
【leetcode】有重复的旋转排序数组查找(二分)
81. Search in Rotated Sorted Array IIleetcode题目描述题目描述:Follow up for “Search in Rotated Sorted Array”: What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose原创 2017-09-28 13:34:29 · 593 阅读 · 0 评论 -
【leetcode】在旋转排序数组中查找(二分)
33. Search in Rotated Sorted Arrayleetcode题目描述题目描述:Suppose an array sorted in ascending order 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).You are原创 2017-09-27 14:13:18 · 431 阅读 · 0 评论 -
【leetcode】已排序数组去重
【leetcode】已排序数组去重leetcode题目描述26. Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocat原创 2017-09-11 17:36:02 · 1363 阅读 · 0 评论 -
【Algorithms】NP-complrte problem(exercises-8.14)
习题解答题目8.14 证明此问题是NP完全的:给定一个无向图G=(V,E)和一个整数k,求G中一个规模为k的团以及一个规模为k的独立集(假设存在)。原创 2018-01-03 08:48:22 · 206 阅读 · 0 评论