leetcode
cchengone
这个作者很懒,什么都没留下…
展开
-
字符串反序输出
题目:Reverse StringWrite a function that takes a string as input and returns the string reversed. Example: Given s = “hello”, return “olleh”. 答案:public class Solution { public String reverseString(原创 2016-10-23 13:23:50 · 3152 阅读 · 0 评论 -
判断“资源字符串”是否可以构成“目标字符串”
题目:Ransom Note描述:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from th原创 2016-10-30 21:56:39 · 956 阅读 · 0 评论 -
删除单向链表中的某个节点
题目: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原创 2016-10-30 20:15:50 · 10922 阅读 · 3 评论 -
求二叉树的所有末级左节点的值的和
题目:Sum of Leaves描述:Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 resp原创 2016-10-30 19:38:20 · 706 阅读 · 0 评论 -
将数组中的0全部移动到末尾
题目: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], afte原创 2016-10-30 15:12:50 · 18040 阅读 · 6 评论 -
反转二叉树
题目:Invert Binary Tree描述:invert binary tree: 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1翻译:将二叉树的左边和右边进行置换答案:/** * Definition for a b原创 2016-10-30 10:54:45 · 861 阅读 · 0 评论 -
将Excel表头转换成列数
题目:Excel Sheet Column Number描述:Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 … Z -> 26 AA ->原创 2016-11-04 23:40:40 · 1819 阅读 · 0 评论 -
找寻字符串中的第一个唯一字符串
题目:First Unique Character in a String描述:Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, return -1. Examples: s = “leetcode” –> return 0;s =原创 2016-11-04 23:02:53 · 805 阅读 · 0 评论 -
二叉树的深度
题目:Maximum Depth of Binary Tree题目详情: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.翻译:有一原创 2016-10-23 15:10:01 · 357 阅读 · 0 评论 -
寻找数组中唯一的数
题目:Single Number题目详情:Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it原创 2016-10-23 14:34:12 · 2365 阅读 · 0 评论 -
输入整数,返回数组,并代替某些位置的数
题目:Fizz Buzz题目详情:Write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five o原创 2016-10-23 13:47:59 · 418 阅读 · 0 评论 -
找出没有出现过的数
Find All Numbers Disappeared in an Array描述:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusi原创 2016-12-03 07:39:45 · 1132 阅读 · 2 评论