LeetCode
dracarys~
这个作者很懒,什么都没留下…
展开
-
这才是高效判断素数的正确打开方式
这才是高效判断素数的正确打开方式什么是素数问题代码什么是素数素数也被称为质数,定义为在大于1的自然数中bai,除了1和它本身以外不再有其他因数。问题统计所有小于非负整数 n 的质数的数量。代码class Solution { int countPrimes(int n) { boolean[] isPrim = new boolean[n];//数组默认为false for (int i = 2; i * i < n; i++)原创 2020-10-30 17:52:09 · 135 阅读 · 0 评论 -
LeetCode:Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D 5...原创 2019-04-07 02:16:37 · 149 阅读 · 0 评论 -
LeetCode: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 found. Then, starting from this...原创 2019-04-08 01:20:42 · 169 阅读 · 0 评论 -
Palindrome Number 判断是否为回文数
Palindrome Number 判断是否为回文数问题描述解答思路问题描述Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input:121Output:trueExample 2:...原创 2019-04-03 01:43:58 · 457 阅读 · 0 评论 -
LeetCode:Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: [“flower”,“flow”,“flight”]Output: “fl...原创 2019-04-09 01:47:11 · 163 阅读 · 0 评论 -
LeetCode:Merge Two Sorted Lists
题目:Merge 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->4, 1->3->4Output: 1...原创 2019-04-14 02:01:32 · 183 阅读 · 0 评论