- 博客(124)
- 收藏
- 关注
原创 做了的事和计划做的一些事
书籍:<机器学习实战> 已看完,GitHub代码已完成(书中代码是python2,我的是python3)。强烈推荐此书 链接:https://github.com/hyc2017/MachineLearningInAction<集体智慧编程> 已看完。GitHub代码已完成(书中代码是python2,我的是python3)。强烈推荐此书 链接:https:/...
2018-01-29 14:18:00 1301 33
原创 LinkedList-141-Linked List Cycle
Description: Given a linked list, determine if it has a cycle in it. Solution://定义两个指针,一个为slow,每次走一步,一个为fast,每次走两步,若slow与fast相等,则必有环public class Solution { public boolean hasCycle(ListNode...
2018-01-31 22:54:27 295
原创 LinkedList-83-Remove Duplicates from Sorted List
Description: Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return ...
2018-01-31 22:49:06 265
原创 LinkedList-21-Merge Two Sorted Lists
Description: 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->...
2018-01-31 22:38:27 278
原创 LinkedList-206-Reverse Linked List
Description: Reverse a singly linked list.Iterative Version:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { v...
2018-01-31 22:35:57 244
原创 LinkedList-237-Delete Node in a Linked List
Description: Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the...
2018-01-31 22:27:42 270
原创 Math-8-String to Integer (atoi)
Description: 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...
2018-01-31 22:19:01 197
原创 Math-29-Divide Two Integers
Description: Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT. Solution:举例来说,63 = 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0,也就是16 + 8 + 4...
2018-01-31 22:09:20 243
原创 Math-523-Continuous Subarray Sum
Description: Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that sums up to the multiple of k, that i...
2018-01-31 21:38:51 287
原创 Math-754. Reach a Number
Description: You are standing at position 0 on an infinite number line. There is a goal at position target.On each move, you can either go left or right. During the n-th move (starting from 1), yo...
2018-01-31 21:05:45 339
原创 Math-50-Pow(x, n)
Description: Implement pow(x, n). Example 1: Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Best Solution://举例来说,2^7 = 2 * 2^2 * 2^4,2^8 = (((2 * 2)...
2018-01-31 20:45:15 302
原创 Math-43-Multiply Strings
Description: Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is < 110.Both num1 and num2 contai...
2018-01-30 21:06:00 181
原创 Math-365-Water and Jug Problem
Description: You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres usi...
2018-01-30 20:55:23 281
原创 Math-2-Add Two Numbers
Description: 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 contain a single digit. Add the two number...
2018-01-30 20:31:02 209
原创 Math-60-Permutation Sequence
Description: The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order, We get the following sequence (ie, for n = 3): "123" ...
2018-01-30 20:23:46 213
原创 Math-397-Integer Replacement
Description: 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 n - 1.What is the minimum numbe...
2018-01-30 19:57:51 343
原创 Math-264-Ugly Number II
Description: Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of...
2018-01-30 19:41:19 205
原创 Math-223-Rectangle Area
Description: Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.Assume that ...
2018-01-30 19:31:11 275
原创 Math-396-Rotate Function
Description: Given an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function” F on A as fol...
2018-01-30 19:24:24 259
原创 Math-368-Largest Divisible Subset
Description: Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or Sj % Si = 0.If there are multiple...
2018-01-30 19:10:24 280
原创 Math-372-Super Pow
Description: Your task is to calculate ababa^b mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.Example1:a = 2b = [3]Result: ...
2018-01-30 12:16:06 241
原创 Math-279-Perfect Squares
Description: Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; giv...
2018-01-29 17:23:34 212
原创 Math-313-Super Ugly Number
Description: Write a program to find the nth super ugly number.Super ugly numbers are positive numbers whose all prime factors are in the given prime list primes of size k. For example, [1, 2, 4, 7...
2018-01-29 17:18:50 193
原创 Math-670-Maximum Swap
Description: Given a non-negative integer, you could swap two digits at most once to get the maximum valued number. Return the maximum valued number you could get.Example 1:Input: 2736Output: ...
2018-01-29 17:12:58 213
原创 Math-640-Solve the Equation
Description: Solve a given equation and return the value of x in the form of string “x=#value”. The equation contains only ‘+’, ‘-’ operation, the variable x and its coefficient.If there is no solu...
2018-01-29 17:03:51 223
原创 Math-593-Valid Square
Description: Given the coordinates of four points in 2D space, return whether the four points could construct a square.The coordinate (x,y) of a point is represented by an integer array with two in...
2018-01-29 16:50:56 151
原创 Math-319-Bulb Switcher
Description: There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off o...
2018-01-29 16:47:51 219
原创 Math-423-Reconstruct Original Digits from English
Description: Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order.Note: Input contains only lowercase English letters. In...
2018-01-29 16:29:18 268
原创 Math-12-Integer to Roman
Description: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Solution:class Solution { private static int[] nums = new int[]{1000...
2018-01-29 16:18:43 165
原创 Math-592-Fraction Addition and Subtraction
Description: Given a string representing an expression of fraction addition and subtraction, you need to return the calculation result in string format. The final result should be irreducible fractio...
2018-01-29 16:16:22 298
原创 Math-357-Count Numbers with Unique Digits
Description: Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example: Given n = 2, return 91. (The answer should be the total numbers in the range of ...
2018-01-28 15:45:16 239
原创 Math-343-Integer Break
Description: Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get.For example, giv...
2018-01-28 15:39:35 145
原创 Math-672-Bulb Switcher II
Description: There is a room with n lights which are turned on initially and 4 buttons on the wall. After performing exactly m unknown operations towards buttons, you need to return how many differe...
2018-01-28 15:30:11 289
原创 Math-462-Minimum Moves to Equal Array Elements II
Description: Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected element by 1 or decrementing a select...
2018-01-28 15:20:41 240
原创 Math-413-Arithmetic Slices
Description: A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithm...
2018-01-28 15:12:43 212
原创 Math-553-Optimal Division
Description: Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, you can add any number of parenthesis at any pos...
2018-01-28 15:03:55 154
原创 Math-537-Complex Number Multiplication
Description: Given two strings representing two complex numbers.You need to return a string representing their multiplication. Note i2 = -1 according to the definition. Example 1:Input: "1+1...
2018-01-28 14:54:51 211
原创 Math-535-Encode and Decode TinyURL
Description: TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk.Design the e...
2018-01-28 14:50:44 336
原创 Math-7-Reverse Integer
Description: Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21Note: A...
2018-01-28 14:43:13 203
原创 Math-204-Count Primes
Description: Count the number of prime numbers less than a non-negative number, n.Best Solution:class Solution { public int countPrimes(int n) { if(n < 3) return 0; boole...
2018-01-28 14:34:48 217
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人