随笔分类 -  LeetCode

LeetCode上的一些小算法题
摘要:Write a function to find the longest common prefix string amongst an array of strings. []=>""["abcweed","htgdabc","sabcrf"]=>""["abcweed","abhtgdc","a 阅读全文
posted @ 2016-04-18 11:00 练子 阅读(158) 评论(0) 推荐(0)
摘要:Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 题目大意:把罗马数字转换成的整数 遍历每个字符,前一个字符比后一个字符小,相减 阅读全文
posted @ 2016-04-18 10:58 练子 阅读(122) 评论(0) 推荐(0)
摘要:Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 题目大意:把一个整数转换成罗马数字 阅读全文
posted @ 2016-04-18 10:56 练子 阅读(154) 评论(0) 推荐(0)
摘要: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 endpo 阅读全文
posted @ 2016-04-18 10:53 练子 阅读(109) 评论(0) 推荐(0)
摘要:Implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' Matches zero or more of the preceding elemen 阅读全文
posted @ 2016-04-15 17:56 练子 阅读(113) 评论(0) 推荐(0)
摘要:Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thi 阅读全文
posted @ 2016-04-15 17:52 练子 阅读(151) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2016-03-28 11:35 练子 阅读(164) 评论(0) 推荐(0)
摘要:Reverse digits of an integer. If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100.Did you notice that the reversed 阅读全文
posted @ 2016-03-28 11:31 练子 阅读(131) 评论(0) 推荐(0)
摘要:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes 阅读全文
posted @ 2016-03-28 11:28 练子 阅读(143) 评论(0) 推荐(0)
摘要: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 sh 阅读全文
posted @ 2016-03-28 11:24 练子 阅读(115) 评论(0) 推荐(0)
摘要:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters fo 阅读全文
posted @ 2016-03-28 10:16 练子 阅读(117) 评论(0) 推荐(0)
摘要:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single 阅读全文
posted @ 2016-03-28 10:06 练子 阅读(141) 评论(0) 推荐(0)