![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
flowbird
本科菜鸟一只
忘大神锤炼
展开
-
leetcode:Invert Binary Tree
题目:反转一个二叉树 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1选择采用递归的方法解决,由于本菜对于递归的理解实在是差,这里贴一下别人的代码/** * Definition for a binary tree no原创 2015-12-11 11:22:41 · 240 阅读 · 0 评论 -
Leetcode:Product of Array Except Self
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 wi原创 2015-12-24 19:36:47 · 277 阅读 · 0 评论 -
Leetcode:Best Time to Buy and Sell Stock ⅠⅡⅢ
Best Time to Buy and Sell StockSay 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 sel原创 2015-12-22 15:32:59 · 336 阅读 · 0 评论 -
Leetcode:bit manipulation
Bitwise AND of Numbers Range My Submissions QuestionGiven a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5原创 2015-12-20 18:48:24 · 373 阅读 · 0 评论 -
Leetcode:Subsets
Subsets Given a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets.For example,原创 2015-12-19 18:34:01 · 205 阅读 · 0 评论 -
Power of Two
很简单···判断一个整数是否是2的次方 自己写的办法就是傻傻的递归除以2 代码:public class Solution { public boolean isPowerOfTwo(int n) { if(n==1){ return true; } if(n==0){ return fals原创 2015-12-18 10:37:35 · 302 阅读 · 0 评论 -
leetcode每日一题
作为一个彩笔,想提高代码能力,前去leetcode修炼!想记录下来每天的学习情况,发在空间里会被蠢的人说是卖弄,大神会来嘲讽找个没人认识我的地方,记录下每题!我是按照AC率从高到低做的第一题 nim game : 简直就是小学奥数题,有木有!就看是不是4的倍数,直接return (n%4!=0)咯!还原创 2015-12-09 13:43:33 · 557 阅读 · 0 评论 -
Leetcode:Missing Number & Maximum Product of Word Lengths
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.这题很简单,不过有个坑爹的地方,就是给你[1,0]的时候,你也要返回2数组中都是原创 2015-12-17 16:09:51 · 282 阅读 · 0 评论 -
Single NumberⅡ
Single NumberⅡGiven an array of integers, every element appears three times except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it wi原创 2015-12-14 12:33:43 · 207 阅读 · 0 评论 -
leetcode: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原创 2015-12-13 16:09:37 · 277 阅读 · 0 评论 -
Leetcode:Valid Sudoku
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 '.'.翻译一下就是给你个数独的二维数原创 2015-12-28 16:56:11 · 245 阅读 · 0 评论 -
Single number Ⅲ
Single Number IIGiven 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.原创 2015-12-12 18:18:42 · 417 阅读 · 0 评论 -
leetcode简单题:Same Tree
今天做了Same Tree这题,就是判断两个二叉树是否完全相等由于开始没有考虑到 节点 为空的情况···报了个NullPointException空指针异常···后来加上了前面对于空节点的判断,终于如愿以偿获得了AC有关二叉树求深度,判断是否相等,都用了递归的方法为了更好的巩固!我特地找了些递归的好文章,放在这里,让自己更好的学习原创 2015-12-10 10:06:15 · 258 阅读 · 0 评论 -
LeetCode:Happy Number
Happy Number——LeetCode 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原创 2015-12-27 14:14:59 · 314 阅读 · 0 评论