Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
If the fractional part is repeating, enclose the repeating part in parentheses.
more >>敲石101下
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
If the fractional part is repeating, enclose the repeating part in parentheses.
more >>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 integer, the decimal digits are truncated and only the integer part of the result is returned.
more >>Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
1 | A -> 1 |
Given an integer n, return the number of trailing zeroes in n!.
Example 1:
1 | Input: 3 |
Example 2:
1 | Input: 5 |
Note: Your solution should be in logarithmic time complexity.
more >>Write an algorithm to determine if a number is “happy”.
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.
more >>Design a data structure that supports all following operations in average O(1) time.
insert(val)
: Inserts an item val to the set if not already present.remove(val)
: Removes an item val from the set if present.getRandom
: Returns a random element from current set of elements. Each element must have the same probability of being returned.dSerialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection link to be reconstructed later in the same or another computer environment.
more >>Given an unsorted array of integers, find the length of longest increasing subsequence.
Example:
1 | Input: [10,9,2,5,3,7,101,18] |
Note:
Follow up: Could you improve it to O(n log n) time complexity?
more >>比如输入1,2,3。输出1,2,12,3,13,23,123。
思路:这道题肯定刷过,可是面试的时候死活想不起来,可能是太紧张了吧。后来找了找,果然在leetcode上找到了原题:
Given a set of distinct integers, nums, return all possible subsets (the power set).
Note: The solution set must not contain duplicate subsets.
more >>tag:
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent: meta: false pages: false posts: title: true date: true path: true text: false raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: true