algorithm
文章平均质量分 69
sysu_xiamengyou
这个作者很懒,什么都没留下…
展开
-
五、[LeetCode OJ]Majority Element
【问题描述】Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the major原创 2017-03-04 14:33:23 · 327 阅读 · 0 评论 -
[LeetCode OJ]Combination Sum I && II
【问题描述】Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number ma原创 2017-03-09 21:07:43 · 294 阅读 · 0 评论 -
Queue Reconstruction by Height
问题描述: Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front o原创 2017-03-26 19:37:20 · 415 阅读 · 0 评论 -
[LeetCode OJ]Target Sum
问题描述:You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + and - as its new symbol.原创 2017-04-29 20:09:41 · 1012 阅读 · 0 评论 -
[LeetCode OJ]Triangle
问题描述:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2],原创 2017-05-05 13:51:59 · 376 阅读 · 0 评论 -
[LeetCode OJ]Continuous Subarray Sum
问题描述:Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that is原创 2017-04-23 22:58:05 · 309 阅读 · 0 评论 -
[LeetCode OJ]Split Array Largest Sum
【问题描述】Given an array which consists of non-negative integers and an integer m, you can split the array into m non-empty continuous subarrays. Write an algorithm to minimize the largest sum among原创 2017-05-12 16:52:46 · 307 阅读 · 0 评论 -
[LeetCode OJ]Longest Palindromic Subsequence
【问题描述】Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000.Example 1:Input:"bbbab"Output:4One possible lo原创 2017-05-26 23:12:53 · 249 阅读 · 0 评论 -
[LeetCode OJ]Partition Equal Subset Sum
【问题描述】Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each原创 2017-05-18 22:36:40 · 233 阅读 · 0 评论 -
[LeetCode OJ]Swap Nodes in Pairs
【问题描述】Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only const原创 2017-06-04 21:33:11 · 262 阅读 · 0 评论 -
[LeetCode OJ]Longest Palindromic Substring
【问题描述】Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid原创 2017-06-08 21:57:36 · 227 阅读 · 0 评论 -
分级聚类——Hierarchical cluster算法
分级聚类——Hierarchical cluster算法@(Xia Mengyou)[cluster] 本篇文章是我在学习《集体智慧编程》这本书时,学习了一下cluster分级聚类算法,然后加入一点自己的理解,代码基于python3,与python2有一点不同。分级聚类Hierarchical cluster算法引言聚类过程聚类实例1读取文件2紧密度皮尔逊相关系数3建立聚类4聚类原创 2017-03-30 21:50:13 · 20839 阅读 · 2 评论 -
[LeetCode OJ]Container With Most Water
【问题描述】Given 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 at (i, ai) and (原创 2017-03-14 16:39:04 · 262 阅读 · 0 评论 -
六、[LeetCode OJ]Maximum Subarray
【问题描述】Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarray [原创 2017-03-04 18:12:44 · 231 阅读 · 0 评论 -
二、[LeetCode OJ]Two Sum题解
【问题描述】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 you may not us原创 2017-02-25 14:15:18 · 330 阅读 · 0 评论 -
三、[LeetCode OJ]Add Two Numbers
【问题描述】You 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 two numbers原创 2017-02-25 20:40:26 · 357 阅读 · 0 评论 -
四、[LeetCode OJ]Integer to Roman
【问题描述】Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999.Example:Input:11 Output:XI问题来源:Integer to Roman【问题解析】原创 2017-02-27 16:10:59 · 265 阅读 · 0 评论 -
一、[LeetCode OJ]3Sum题解
【问题描述】Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set mu原创 2017-02-25 12:58:58 · 363 阅读 · 0 评论 -
[LeetCode OJ]Longest Substring Without Repeating Characters
【问题描述】Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the原创 2017-03-19 15:15:59 · 300 阅读 · 0 评论 -
[LeetCode OJ]Valid Parentheses
【问题描述】Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}"原创 2017-03-09 20:41:18 · 234 阅读 · 0 评论 -
[LeetCode OJ]Merge k Sorted Lists
【问题描述】Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.问题来源:Merge k Sorted Lists【解题分析】将k个有序的数组合并成一个有序的数组,将其分而治之,每次只比较两个数组,简易图为:原创 2017-03-09 21:46:32 · 262 阅读 · 0 评论 -
七、[LeetCode OJ]Median of Two Sorted Arrays
【问题描述】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 should be O(log (m+n)).Example 1:原创 2017-03-07 21:09:50 · 270 阅读 · 0 评论 -
Remove K Digits
Remove K Digits@(algorithm)[greedy]问题描述: Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note:原创 2017-03-23 19:52:29 · 725 阅读 · 0 评论 -
[LeetCode OJ]Edit Distance
【问题描述】Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitte原创 2017-06-14 15:54:30 · 278 阅读 · 0 评论