Coding Rabbit


  • 首页

  • 关于

  • 归档

  • 标签

  • 搜索

Sudoku Series

发表于 2017-01-21
Valid SudokuQuestionDetermine 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 ‘.’. Analysis数独规则: 每行每列及每个九宫格内不可有相同的数字(一共九个九宫格) 故针对每行每列及每个九宫格初始化一个hashset,当前格内数字不是’.’且无法插入到hashset时代表已经存在了重复的数字,返回 ...
阅读全文 »

Longest Increasing Subsequence

发表于 2017-01-19
Longest Increasing SubsequenceQuestionGiven an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest increasing subsequence is [2, 3, 7, 101], therefore the length is 4. Note that there may be more than one LIS com ...
阅读全文 »

Different Ways to Add Parentheses || Merge k Sorted Lists

发表于 2017-01-03
Different Ways to Add ParenthesesQuestionGiven a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1 Input: "2-1-1". 12((2-1)-1) = 0(2-(1-1)) = 2 Output: [0 ...
阅读全文 »

Unique Binary Search Trees Series

发表于 2017-01-03
Unique Binary Search Trees SeriesQuestionGiven n, how many structurally unique BST’s (binary search trees) that store values 1…n? For example, Given n = 3, there are a total of 5 unique BST’s. 123451 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / ...
阅读全文 »

Integer Break || Wiggle Subsequence

发表于 2017-01-01
Integer BreakQuestionGiven 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 (2 = 1 + 1); given n = 10, return 36 (10 = 3 + 3 + 4). Note: You may assume ...
阅读全文 »

Binary Tree Right Side View || Populating Next Right Pointers in Each Node

发表于 2016-12-30
Binary Tree Right Side ViewQuestionGiven a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For example: Given the following binary tree, 12345 1 <--- / \2 3 <--- \ \ 5 4 ...
阅读全文 »

Largest Number

发表于 2016-12-28
Largest NumberQuestionGiven a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be very large, so you need to return a string instead of an integer. Analysis [10,2] 对于上述 ...
阅读全文 »

Power of Number

发表于 2016-12-28
Power of TwoQuestionGiven an integer, write a function to determine if it is a power of two. Analysis 2^n的二进制数中只存在一个1,所以利用num&(num-1)==0 可以判断是否为2^n Java中可以利用bitcount() Code12345public class Solution { public boolean isPowerOfThree(int n) { return (n>0)&&Integer.bi ...
阅读全文 »

Isomorphic Strings || Word Pattern

发表于 2016-12-27
Isomorphic StringsQuestionGiven 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 character while preserving the order of characters. No two characters may ma ...
阅读全文 »

Path Sum Series

发表于 2016-12-27
Path SumQuestionGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree and sum = 22, 1234567 5 / \ 4 8 / / \ 11 13 4 / \ \7 2 1 re ...
阅读全文 »
1234…8
Coding Rabbit

Coding Rabbit

77 日志
37 标签
RSS
Github Facebook weibo
Links
  • Codeboy
  • Yijia_Jin
© 2017 Coding Rabbit
由 Hexo 强力驱动
主题 - NexT.Mist