
算法
Hunter-狩猎者
没了
展开
-
LeetCode – Rotate Image (Java)
You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?Naive SolutionIn the following solution, a new转载 2014-04-29 12:51:27 · 612 阅读 · 0 评论 -
LeetCode – Valid Parentheses (Java)
Problem:Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[' and ']‘, determine if the input string is valid.The brackets must close in the correct order, “()” and “()[]{}”转载 2014-04-24 15:49:09 · 679 阅读 · 0 评论 -
LeetCode – Implement strStr() (Java)
Problem:Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.ThoughtsFirst, need to understand the problem转载 2014-04-25 14:52:52 · 679 阅读 · 0 评论 -
LeetCode – Set Matrix Zeroes (Java)
Thoughts about This ProblemThis problem can solve by following 4 steps:check if first row and column are zero or notmark zeros on first row and columnuse mark to set elementsset first column a转载 2014-04-25 15:05:52 · 749 阅读 · 0 评论 -
LeetCode – Merge Sorted Array (Java)
Problem:Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space to hold additional elements from B. The number of elements转载 2014-04-24 15:33:20 · 662 阅读 · 0 评论 -
LeetCode – Search Insert Position
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. You may assume no duplicates in the array.转载 2014-04-25 15:22:21 · 723 阅读 · 0 评论 -
LeetCode – Longest Consecutive Sequence Java
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 longest consecutive elements sequence is [1, 2, 3转载 2014-04-28 08:29:26 · 614 阅读 · 0 评论 -
LeetCode – Valid Palindrome (Java)
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,“A man, a plan, a canal: Panama” is a palindrome.“race a car” is not a转载 2014-04-28 13:46:05 · 822 阅读 · 0 评论 -
LeetCode – Search a 2D Matrix (Java)
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has properties:1) Integers in each row are sorted from left to right. 2) The first integer of each row is gre转载 2014-04-29 12:42:00 · 483 阅读 · 0 评论 -
LeetCode – Spiral Matrix (Java)
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example, given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Y转载 2014-04-29 09:50:45 · 539 阅读 · 0 评论 -
LeetCode – Maximum Subarray (Java)
By X Wang转载 2014-05-21 07:42:31 · 592 阅读 · 0 评论 -
LeetCode – Remove Duplicates from Sorted Array (Java)
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 space for another array, you must do this in place with转载 2014-05-21 07:50:57 · 480 阅读 · 0 评论 -
LeetCode – Remove Duplicates from Sorted Array II (Java)
Follow up for "Remove Duplicates":What if duplicates are allowed at most twice?For example,Given sorted array A = [1,1,1,2,2,3],Your function should return length = 5, and A is now [1,1,2,转载 2014-05-21 08:16:05 · 547 阅读 · 0 评论 -
LeetCode – String to Integer (atoi) (Java)
Problem:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possi转载 2014-04-24 13:39:50 · 529 阅读 · 0 评论 -
LeetCode – 3Sum Closest (Java)
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly转载 2014-04-24 13:30:19 · 662 阅读 · 0 评论 -
LeetCode – Triangle (Java)
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], [3,4], [6,转载 2014-04-29 14:05:11 · 869 阅读 · 0 评论 -
LeetCode – Evaluate Reverse Polish Notation
The problem:转载 2014-04-14 08:17:02 · 624 阅读 · 0 评论 -
Leetcode Solution of Longest Palindromic Substring in Java
By X WangFinding the longest palindromic substring is a classic problem of coding interview. In this post, I will summarize 3 different solutions for this problem.1. Naive ApproachNaiv转载 2014-04-14 17:22:07 · 574 阅读 · 0 评论 -
Leetcode Solution – Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = “leetcode”,dict = ["leet"转载 2014-04-15 08:42:54 · 643 阅读 · 0 评论 -
LeetCode – Word Ladder
The problem:转载 2014-04-18 07:54:35 · 564 阅读 · 0 评论 -
LeetCode – Median of Two Sorted Arrays Java
LeetCode Problem:There are two sorted arrays A and B 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)).Keys to转载 2014-04-18 11:48:40 · 544 阅读 · 0 评论 -
LeetCode – Distinct Subsequences Total (Java)
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non转载 2014-05-05 18:04:29 · 1039 阅读 · 0 评论 -
LeetCode – Regular Expression Matching in Java
Problem:Implement regular expression matching with support for ‘.’ and ‘*’.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the转载 2014-04-18 16:57:28 · 888 阅读 · 0 评论 -
LeetCode – Insert Interval
Problem:Given a set of non-overlapping & sorted intervals, insert a new interval into the intervals (merge if necessary).Example 1:Given intervals [1,3],[6,9], insert and merge [2,5] in as转载 2014-04-23 11:47:42 · 525 阅读 · 0 评论 -
LeetCode – 3Sum
Problem: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:Elements in a trip转载 2014-04-23 14:36:57 · 534 阅读 · 0 评论 -
LeetCode – Two Sum (Java)
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, w转载 2014-04-23 13:25:38 · 625 阅读 · 0 评论 -
LeetCode – 4Sum (Java)
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Elements in a转载 2014-04-24 13:10:19 · 510 阅读 · 0 评论 -
美团推荐算法实践
前言推荐系统并不是新鲜的事物,在很久之前就存在,但是推荐系统真正进入人们的视野,并且作为一个重要的模块存在于各个互联网公司,还是近几年的事情。随着互联网的深入发展,越来越多的信息在互联网上传播,产生了严重的信息过载。如果不采用一定的手段,用户很难从如此多的信息流中找到对自己有价值的信息。解决信息过载有几种手段:一种是搜索,当用户有了明确的信息需求意图后,将意图转换为几个简短转载 2016-01-06 10:03:59 · 622 阅读 · 0 评论