摘要: Palindrome Number:Determine whether an integer is a palindrome. Do this without extra space. 题意:判断一个整数是否是回文数,且不可以使用额外的空间。 思路:首先负数不是回文数,然后每次取出数的最高位和最低位,进行判断。 代码: public class Solution { public bool... 阅读全文
posted @ 2016-03-05 19:15 Lewisr 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Number of i Bits:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer “11” has binary representa... 阅读全文
posted @ 2016-03-05 19:03 Lewisr 阅读(122) 评论(0) 推荐(0) 编辑
摘要: Binary Tree Level Order Traversal:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, ... 阅读全文
posted @ 2016-03-01 19:19 Lewisr 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Same Tree:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value. 题意:判断两棵... 阅读全文
posted @ 2016-03-01 19:15 Lewisr 阅读(120) 评论(0) 推荐(0) 编辑
摘要: Symmetric Tree:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But th... 阅读全文
posted @ 2016-03-01 19:04 Lewisr 阅读(125) 评论(0) 推荐(0) 编辑
摘要: Balanced Binary Tree:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every... 阅读全文
posted @ 2016-03-01 18:58 Lewisr 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 作者:Hawstein出处:http://hawstein.com/posts/dp-novice-to-advanced.html 前言 本文翻译自TopCoder上的一篇文章: Dynamic Programming: From novice to advanced ,并非严格逐字逐句翻译,其中加入了自己的一些理解。水平有限,还望指摘。 前言_ 我们遇到的问题中,有很大一部分可以用动态规划(简... 阅读全文
posted @ 2016-02-25 14:14 Lewisr 阅读(198) 评论(0) 推荐(0) 编辑
摘要: Maximum Subarray: Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [... 阅读全文
posted @ 2016-02-19 14:30 Lewisr 阅读(104) 评论(0) 推荐(0) 编辑
摘要: Majority Element II:Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space. 题意:找出给定数组中出现次数多于数组长度三分之一的元素 思路:根... 阅读全文
posted @ 2016-02-19 14:15 Lewisr 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Word Search:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, 阅读全文
posted @ 2016-02-19 14:07 Lewisr 阅读(132) 评论(0) 推荐(0) 编辑