12 2015 档案

摘要:/** * 时间复杂度:O(n*n) * 简单选择排序法:每次从剩余元素中选择一个最小值,交换最小值与数组中相应位置上的数值 * n趟 * @param nums */ public static void simpleSelectSort(int[] nums){ for(int i = 0;i 阅读全文
posted @ 2015-12-18 16:39 江湖凶险 阅读(166) 评论(0) 推荐(0)
摘要:问题描述: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: But t 阅读全文
posted @ 2015-12-18 09:59 江湖凶险 阅读(168) 评论(0) 推荐(0)
摘要:问题描述: You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the qua 阅读全文
posted @ 2015-12-16 21:55 江湖凶险 阅读(160) 评论(0) 推荐(0)
摘要:问题描述: Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such that the most significant digi 阅读全文
posted @ 2015-12-16 16:47 江湖凶险 阅读(146) 评论(0) 推荐(0)
摘要:问题描述: Reverse digits of an integer. Example1: x = 123, return 321Example2: x = -123, return -321 分析:将一个整数逆序输出,需要判断是否越界。Integer.MAX_VALUE,Integer.MIN_V 阅读全文
posted @ 2015-12-16 16:23 江湖凶险 阅读(230) 评论(0) 推荐(0)
摘要:问题描述: Given an integer, write a function to determine if it is a power of two. 问题分析:给定一个数,判断它是不是2的幂。因为2的幂 >= 0 ,所以是针对非负数的。那么这个数 %2为0 代码: 阅读全文
posted @ 2015-12-16 15:28 江湖凶险 阅读(126) 评论(0) 推荐(0)
摘要:算法描述: Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra sp 阅读全文
posted @ 2015-12-16 14:40 江湖凶险 阅读(117) 评论(0) 推荐(0)
摘要:问题描述: Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It does 阅读全文
posted @ 2015-12-14 16:54 江湖凶险 阅读(156) 评论(0) 推荐(0)
摘要:问题描述: Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 阅读全文
posted @ 2015-12-14 15:27 江湖凶险 阅读(175) 评论(0) 推荐(0)
摘要:问题描述: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 分析: 将k个sorted list合并为一个sorted list借鉴归并排序的方法,自 阅读全文
posted @ 2015-12-14 13:48 江湖凶险 阅读(243) 评论(0) 推荐(0)
摘要:问题描述: Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231 - 1. For example, 阅读全文
posted @ 2015-12-10 14:23 江湖凶险 阅读(194) 评论(0) 推荐(0)
摘要:问题描述: Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. F 阅读全文
posted @ 2015-12-10 13:54 江湖凶险 阅读(146) 评论(0) 推荐(0)
摘要:问题描述: Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 分析: /** * 将一个Integer数字转换为罗马数字,范围 1-3 阅读全文
posted @ 2015-12-10 11:41 江湖凶险 阅读(200) 评论(0) 推荐(0)
摘要:问题描述: Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 算法: /** * 输入一个罗马数字,返回它的整型表示 * @autho 阅读全文
posted @ 2015-12-10 10:52 江湖凶险 阅读(216) 评论(0) 推荐(0)
摘要:问题描述: Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. 阅读全文
posted @ 2015-12-10 09:30 江湖凶险 阅读(194) 评论(0) 推荐(0)
摘要:问题描述: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can 阅读全文
posted @ 2015-12-09 16:43 江湖凶险 阅读(144) 评论(0) 推荐(0)
摘要:问题描述: Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two ele 阅读全文
posted @ 2015-12-09 14:31 江湖凶险 阅读(180) 评论(0) 推荐(0)
摘要:问题描述: Given an array of integers, every element appears three times except for one. Find that single one. Note:Your algorithm should have a linear run 阅读全文
posted @ 2015-12-09 11:12 江湖凶险 阅读(274) 评论(0) 推荐(0)
摘要:问题描述: Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime c 阅读全文
posted @ 2015-12-09 10:49 江湖凶险 阅读(125) 评论(0) 推荐(0)