- 博客(11)
- 收藏
- 关注
原创 100. Same Tree(二叉树、递归)
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.给出两个二叉树,...
2018-02-27 23:06:00 585
原创 9.Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.确定一个整数是否回文数,不能占用额外空间。(回文数形如121,12321,1221,5等)大神代码cbmbbz public boolean isPalindrome(int x) { if (x<0 || (x!=...
2018-02-26 00:08:00 91
原创 7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.给定一个32位有符号整数,将整数的每位反转,如下:Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321 Example 3:Input: 120Output: 2...
2018-02-25 22:04:00 69
原创 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.翻译:给出一个包含n个不同数字的数组,数组中元素是从0,1,2,...,n中选取的,找到数组中缺失的数字例1:输入: [3,0,1]输出: 2例2...
2018-02-22 19:07:00 87
原创 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...
2018-02-22 11:59:00 94
原创 189. Rotate Array
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 you can, ...
2018-02-22 00:22:00 126
原创 Two Sum II - Input array is sorted
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers ...
2018-02-20 18:57:00 152
原创 122. Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one ...
2018-02-20 00:25:00 52
原创 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 ...
2018-02-14 18:50:00 71
原创 119. Pascal's Triangle II
和前面119. Pascal's Triangle非常相似,不赘述,下面是代码class Solution {public List<Integer> getRow(int row) {List<Integer> yanghui=new ArrayList<Integer>();for (int i=0;i<=row;i++) {yanghui...
2018-02-13 12:44:00 61
原创 88.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 addition...
2018-02-05 08:35:00 65
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人