自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

RockPaperProgrammer

Github: https://github.com/didi0613

  • 博客(82)
  • 收藏
  • 关注

原创 Javascript Object, Set, Map总结

Object  定义:var object = {}; 常用方法:  object.hashOwnProperty  object[key] = value; object.push({key:key, value:val}); key in object Set 定义:var set = new Set(); 常用方法: set.size(); set.add(

2016-07-04 14:54:28 442

原创 212. Word Search II

Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those hor

2016-07-03 16:02:47 381

原创 208. Implement Trie (Prefix Tree)

Implement a trie with insert, search, and startsWith methods. Note: You may assume that all inputs are consist of lowercase letters a-z. 题目原意: 实现字典树数据结构,包含插入,查找,前缀的方法。 注意: 可以假定所有输入由小写字

2016-07-03 15:22:33 335

原创 51. N-Queens

The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct solutions to the n-queens puzzle.

2016-07-02 15:07:08 304

原创 69. Sqrt(x)

题目原意: Implement int sqrt(int x). Compute and return the square root of x. 实现int sqrt(int x). 计算并返回x的平方根。 Solution 1:初始想法,brute force 解题思路: 需要注意的是此题不用考虑非正数,加上题目标注返回值为int,因此只需要返回x的Mat

2016-07-02 06:31:58 320

原创 Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]

2016-06-18 07:23:04 230

原创 Subsets

Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,3], a solution is: [ [3], [1],

2016-06-18 06:55:15 188

原创 Permutations

Given a collection of distinct numbers, return all possible permutations. For example, [1,2,3] have the following permutations: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1

2016-06-18 04:01:50 235

原创 Binary Tree Inorder Traversal - JS

Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree [1,null,2,3], 1 \ 2 / 3 return [1,3,2]. Note: Recursive solu

2016-06-17 12:57:45 279

原创 Binary Tree Preorder -JS

Given a binary tree, return the preorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive soluti

2016-06-17 07:34:43 311

原创 Intersection of Two Linked List -JS

Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: A: a1 → a2 ↘

2016-06-16 10:39:42 283

原创 Bulls and Cows - JS

You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint t

2016-06-16 10:17:12 494

原创 Merge Sorted Array

Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold addit

2016-06-16 08:55:15 276

原创 Isomorphic Strings - Javacript

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 anot

2016-06-16 08:43:51 381

原创 Remove Nth Node From End of List - JS

Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the

2016-06-16 08:30:06 249

原创 Word Pattern - JS

Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.

2016-06-16 08:16:01 282

原创 Length of Last Word

Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is

2016-06-16 07:51:31 216

原创 Count and Say - JS

The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as 

2016-06-16 07:47:10 287

原创 Binary Tree Paths - Javascript

Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: ["1->2->5", "1->3"] Cre

2016-06-16 06:56:42 416

原创 Binary Tree Paths - JS

Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: ["1->2->5", "1->3"] Cre

2016-06-16 03:58:30 458

原创 Remove Linked List Elements - JS

Remove all elements from a linked list of integers that have value val. Example Given: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6 Return: 1 --> 2 --> 3 --> 4 --> 5 Credits: Special thanks

2016-06-16 03:29:50 323

原创 Palindrome Linked List - JS

Given a singly linked list, determine if it is a palindrome. Follow up: Could you do it in O(n) time and O(1) space? Subscribe to see which companies asked this question Tag LinkedList, T

2016-06-16 03:18:31 423

原创 Rotate Array - Javacript

Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to come up as many solutions as yo

2016-06-15 14:31:26 289

原创 Count Primes - Javascript

Description: Count the number of prime numbers less than a non-negative number, n. Credits: Special thanks to @mithmatt for adding this problem and creating all test cases. Tags Hash Table,

2016-06-15 14:20:05 1146

原创 ZigZag Conversion - Javascript

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I

2016-06-15 13:57:06 652

原创 Compare Version Numbers

Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0. You may assume that the version strings are non-empty and co

2016-06-15 13:32:34 520

原创 Excel Sheet Column Title

Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB Credits

2016-06-15 12:50:32 228

原创 Range Sum Query - Javacript

Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumRange(0, 2) -> 1 sumRange(2, 5) -> -1 sumRan

2016-06-15 12:38:51 253

原创 First Bad Version - Javascript

You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the

2016-06-15 10:16:21 281

原创 Reverse Integer - Javacript

Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Tag Math ------------------------------------------------------------------------------------------

2016-06-15 09:56:02 271

原创 Valid Palindrome

Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a

2016-06-15 09:14:56 299

原创 Implement strStr() - Javascript

Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Tags Two Pointers, String ------------------------------------

2016-06-15 06:30:31 666

原创 Add Binary - Javacript

Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". Tag Math, String -------------------------------------------------------------

2016-06-15 06:29:02 239

原创 Longest Common Prefix - Javacript

Write a function to find the longest common prefix string amongst an array of strings. Tags String --------------------------------------------------------------------------------------------

2016-06-15 06:03:49 405

原创 Two Sum

Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: Given nums =

2016-06-15 04:04:09 207

原创 String to Integer (atoi)

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 possible input ca

2016-06-14 23:56:10 198

原创 Valid Sudoku - Javacript

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules. The Sudoku board could be partially filled, where empty cells are filled with the character '.'. A partially fille

2016-06-14 15:00:41 347

原创 Contains Duplicate II

Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.

2016-06-14 13:58:59 226

原创 Factorial Trailing Zeroes - Javacript

Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logarithmic time complexity. Credits: Special thanks to @ts for adding this problem and creating

2016-06-14 13:38:18 265

原创 Minimum Depth of Binary Tree - Javascript

Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Tags BFS, DFS, Tree --------

2016-06-14 08:17:31 469

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除