- 博客(21)
- 资源 (19)
- 收藏
- 关注
原创 【leetcode】268. 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./** * @param {number[]} nums * @return
2016-05-26 20:13:59 263
原创 【leetcode】343. Integer Break
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, given n = 2, return 1
2016-05-25 18:55:03 243
原创 【leetcode】319. Bulb Switcher
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 or turning off i
2016-05-25 18:53:41 299
原创 【leetcode】169. Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element always
2016-05-25 18:48:42 281
原创 【leetcode】217. Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is
2016-05-25 18:47:34 243
原创 【leetcode】171. Excel Sheet Column Number
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 … Z
2016-05-25 18:46:05 235
原创 【leetcode】Intersection of Two Arrays
Intersection of Two Arrays Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]./** * @param {number[]} nums1 * @param {n
2016-05-23 19:04:54 403
原创 【leetcode】242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.beats 91%/** * @param {str
2016-05-23 19:02:36 234
原创 【leetcode】347. Top K Frequent Elements
Top K Frequent ElementsGiven a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].这个办法是先哈希,再排序,等过段时间实现小根堆的算法。/** * @param {numb
2016-05-22 20:15:25 335
原创 【leetcode】238. Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).For e
2016-05-19 17:01:46 277
原创 【leetcode】100. Same Tree
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.# Definition for a
2016-05-19 13:54:50 284
原创 【leetcode】237. Delete Node in a Linked List
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 third node with value 3, t
2016-05-18 16:58:59 271
原创 【leetcode】 260. Single Number III
Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For example:Given nums = [1,
2016-05-17 18:45:04 333
原创 【leetcode】283. Move Zeroes
Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your funct
2016-05-17 18:31:15 354
原创 【leetcode】226. Invert Binary Tree
照例要考虑树为空的情况。/** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * this.left = this.right = null; * } *//** * @param {TreeNode} root * @return {TreeNod
2016-05-17 15:25:29 208
原创 【leetcode】104. Maximum Depth of Binary Tree 92.83%
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Subscribe to see which companies asked this
2016-05-17 15:16:34 242
原创 【leetcode】258. 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
2016-05-17 15:13:52 234
原创 【leetcode】292. Nim Game
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the
2016-05-17 15:09:31 324
原创 【leetcode】338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 you sh
2016-05-15 11:15:51 336
原创 [leetcode]344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.Subscribe to see which companies asked this question不知道自己会不会精分 javascript版本/**
2016-05-14 21:18:44 491
sentiwords情感词
2015-11-24
图片批量下载
2015-01-05
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人