- 博客(22)
- 收藏
- 关注
原创 记我的头条面经
三面卒。。。。。 一面 上来先做笔试,3个题ABCDE五个学校参加竞赛,其中已知 E不是第二或者是第三;下面是几个学校的预测。A: E是第一 B: 我是第二 ; C : A最差 D: C不是最好 E:D是第一 其中只有真实排名为1 2 的学校说的是真话,其余人说的都是假话。给一个无序不重复的数组,找出n个数字,和为m画一个自适应正方形,其中宽度是屏幕宽度的50%,要求水平垂直居中。做完题
2017-04-27 18:46:14 792
原创 反转数字
eg:输入123 输出321function reverseNum(n) { var res = 0; while(n > 0) { var m = n % 10; res = res * 10 + m; n = parseInt(n / 10) } return res}
2017-04-24 18:50:19 260
原创 我的面经1
jsfunction test(){ for(var i = 0; i < 3; i++) { var img = document.createElement('img'); img.src = 'img' + i + '.png'; img.onload = function(){ alert(i...
2017-04-22 12:33:39 303
原创 Find Minimum in Rotated Sorted Array II
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.The array may contain duplicates.
2017-04-20 15:08:04 278
原创 Find Minimum in Rotated Sorted Array
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).Find the minimum element.You may assume no duplicate exist
2017-04-20 14:53:57 427
原创 495. Teemo Attacking
In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo’s attacking ascending time series towards Ashe and the poisoning time
2017-04-20 14:07:51 239
原创 118. Pascal's Triangle
Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]var generate = function(n) {
2017-04-20 11:42:24 214
原创 动态规划入门-Triangle
动归解题的一般思路:将原问题分解成多个子问题。子问题都解决了,原问题就解决了用动态规划解题时,我们往往将和子问题相关的各个变量的一组取值,称之为一个“状态”。一个“状态”对应于一个或多个子问题,所谓某个“状态”下的“值”,就是这个“状态”所对应的子问题的解确定初始状态确定状态转移方程eg:leetcode120. Triangle Given a triangle, find the mi
2017-04-20 10:13:39 358
原创 Isomorphic Strings
Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be replaced with another chara
2017-04-19 19:18:01 197
原创 Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi
2017-04-18 16:00:14 191
原创 Reverse String II
Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of them.
2017-04-18 15:43:48 231
原创 Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; ot
2017-04-13 15:48:32 194
原创 Relative Ranks
Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be awarded medals: “Gold Medal”, “Silver Medal” and “Bronze Medal”.var findRelativeRanks
2017-04-12 11:58:27 249
原创 Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cook
2017-04-12 11:57:32 306
原创 Construct the Rectangle
For a web developer, it is very important to know how to design a web page’s size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L
2017-04-07 10:30:57 258
原创 Next Greater Element I
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2.The
2017-04-06 19:10:18 252
原创 Add Digits
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r
2017-04-06 16:34:32 340
原创 Plus One
Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The digits are st
2017-04-06 15:08:01 275
原创 Excel Sheet Column Title
Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example:1 -> A2 -> B3 -> C...26 -> Z27 -> AA28 -> AB var convertToTitle = function(n) { var
2017-04-06 14:29:40 465
原创 Count Primes
Count the number of prime numbers less than a non-negative number, n.var countPrimes = function(n) { var arr= []; for(var m = 0; m < n; m++) { arr[m] = true } for(var i = 2; i <
2017-04-06 11:49:53 255
原创 Perfect Number
We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it is a perfect n
2017-04-06 10:56:09 306
原创 Word Pattern
Given a pattern and a string str, find if str follows the same pattern. Examples: pattern = “abba”, str = “dog cat cat dog” should return true. pattern = “abba”, str = “dog cat cat fish” should retu
2017-04-06 10:35:59 260
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人