文章 2015-11-07 来自:开发者社区

[LeetCode] Missing Number

Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note: Your algorithm should run...

文章 2015-10-18 来自:开发者社区

LeetCode 17 Letter Combinations of a Phone Number(电话号码的字母组合)

翻译 给定一个数字字符串,返回所有这些数字可以表示的字母组合。 一个数字到字母的映射(就像电话按钮)如下图所示。 输入:数字字符串“23” 输出:["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"] 备注:尽管以上答案是无序的,如果你想的话你的答案可以是有序的。 原图 原文 Given a digit string...

文章 2015-09-28 来自:开发者社区

[LeetCode] Find the Duplicate Number

There are mainly two solutions to solve this problem. The first one is very clever, using the idea of cycle detection, and runs in O(n) time. You may refer to this post, whose code is rewritten below....

文章 2015-09-27 来自:开发者社区

LeetCode 9 Palindrome Number (回文数)(Math)

版权声明:转载请联系本人,感谢配合!本站地址:http://blog.csdn.net/nomasp https://blog.csdn.net/NoMasp/article/details/48769667 翻译 确定一个整数是否是回文数。不能使用额外的空间。 一些提示: 负数能不能是回文数呢?(比...

文章 2015-09-27 来自:开发者社区

LeetCode 9 Palindrome Number (回文数)

翻译 确定一个整数是否是回文数。不能使用额外的空间。 一些提示: 负数能不能是回文数呢?(比如,-1) 如果你想将整数转换成字符串,但要注意限制使用额外的空间。 你也可以考虑翻转一个整数。 然而,如果你已经解决了问题“翻转整数(译者注:LeetCode 第七题), 那么你应该知道翻转的整数可能会造成溢出。 你将如何处理这种情况? 这是一个解决该问题更通用的方法。 原文 D...

文章 2015-09-24 来自:开发者社区

[LeetCode] Palindrome Number & Valid Palindrome - 回文系列问题

题目概述: Determine whether an integer is a palindrome. Do this without extra space. 题目分析: 判断数字是否是回文 例如121、656、3443 方法有很多,正着看和到着看两数相同;当然负数显然不是回文 我的方法: 第一种方法: 由于没有没有看到前面的without extra space。采用的方法是把...

文章 2015-09-14 来自:开发者社区

[LeetCode] Number of 1 Bits & Reverse Integer - 整数问题系列

目录:1.Number of 1 Bits  - 计算二进制1的个数 [与运算] 2.Contains Duplicate - 是否存在重复数字 [遍历]3.Reverse Integer - 翻转整数 [int边界问题]4.Excel Sheet Column Number - Excel字符串转整数 [简单]5.Power of Two & Happy Number...

文章 2015-08-24 来自:开发者社区

[LeetCode] Missing Number

There are three methods to solve this problem: bit manipulation, rearrangement of the array, and math tricks. Bit Manipulation 1 class Solution { 2 public: 3 int missingNumber(vector<int>...

文章 2015-08-19 来自:开发者社区

[LeetCode] Ugly Number II

Stefan is a hero! Personally, I love his first C++ solution. 1 class Solution { 2 public: 3 int nthUglyNumber(int n) { 4 vector<int> ugly(n, 1); 5 int c2 = 2, c3 = 3, ...

文章 2015-08-19 来自:开发者社区

[LeetCode] Ugly Number

No matter what language you use on the OJ, you may refer to Stefan's post for a solution. The C++ is rewritten below, just really concise. 1 class Solution { 2 public: 3 bool isUgly(int num) { 4...

本页面内关键词为智能算法引擎基于机器学习所生成,如有任何问题,可在页面下方点击"联系我们"与我们沟通。

算法编程

开发者社区在线编程频道官方技术圈。包含算法资源更新,周赛动态,每日一题互动。

+关注