摘要: Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. Example 阅读全文
posted @ 2019-10-21 13:47 CNoodle 阅读(127) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If n is odd, you can replace n with either n + 1 or  阅读全文
posted @ 2019-10-21 13:28 CNoodle 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Implement pow(x, n), which calculates x raised to the power n (x^n). Example 1: Input: 2.00000, 10 Output: 1024.00000 Example 2: Input: 2.10000, 3 Out 阅读全文
posted @ 2019-10-18 01:20 CNoodle 阅读(431) 评论(0) 推荐(0) 编辑
摘要: Given a positive integer num, write a function which returns True if num is a perfect square else False. Follow up: Do not use any built-in library fu 阅读全文
posted @ 2019-10-18 00:56 CNoodle 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an in 阅读全文
posted @ 2019-10-18 00:36 CNoodle 阅读(480) 评论(0) 推荐(0) 编辑
摘要: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. Example: Input: 38 Output: 2 Explanation: The pro 阅读全文
posted @ 2019-10-17 23:58 CNoodle 阅读(140) 评论(0) 推荐(0) 编辑
摘要: The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'. For example, "ACGAATTCCG" is a DNA sequence. When study 阅读全文
posted @ 2019-10-17 01:04 CNoodle 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in 阅读全文
posted @ 2019-10-17 00:08 CNoodle 阅读(470) 评论(0) 推荐(0) 编辑
摘要: Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. If no such 阅读全文
posted @ 2019-10-16 23:38 CNoodle 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some 阅读全文
posted @ 2019-10-15 23:48 CNoodle 阅读(424) 评论(0) 推荐(0) 编辑
摘要: Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: 阅读全文
posted @ 2019-10-15 23:13 CNoodle 阅读(171) 评论(0) 推荐(0) 编辑
摘要: Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Examp 阅读全文
posted @ 2019-10-14 11:51 CNoodle 阅读(156) 评论(0) 推荐(0) 编辑
摘要: Write an algorithm to determine if a number n is happy. A happy number is a number defined by the following process: Starting with any positive intege 阅读全文
posted @ 2019-10-14 11:27 CNoodle 阅读(213) 评论(0) 推荐(0) 编辑
摘要: You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contai 阅读全文
posted @ 2019-10-13 14:42 CNoodle 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 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 conta 阅读全文
posted @ 2019-10-13 06:41 CNoodle 阅读(464) 评论(0) 推荐(0) 编辑
摘要: Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-white 阅读全文
posted @ 2019-10-13 01:06 CNoodle 阅读(449) 评论(0) 推荐(0) 编辑
摘要: Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place 阅读全文
posted @ 2019-10-12 08:45 CNoodle 阅读(148) 评论(0) 推荐(0) 编辑
摘要: The array-form of an integer num is an array representing its digits in left to right order. For example, for num = 1321, the array form is [1,3,2,1]. 阅读全文
posted @ 2019-10-12 00:58 CNoodle 阅读(277) 评论(0) 推荐(0) 编辑
摘要: Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: 阅读全文
posted @ 2019-10-11 01:22 CNoodle 阅读(445) 评论(0) 推荐(0) 编辑
摘要: Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: Input: s = "leetcode" 阅读全文
posted @ 2019-10-10 07:23 CNoodle 阅读(159) 评论(0) 推荐(0) 编辑