自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

成为一个合格的IT工作者

从基础开始学习,全方面塑造自己的技能树

  • 博客(67)
  • 收藏
  • 关注

原创 [C++]Ugly Number II丑数2

leetcode 原题链接:https://leetcode.com/problems/ugly-number-ii/Write a program to find the n-th ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For exam

2015-08-19 15:51:26 1610

原创 [C++]Ugly Number 丑数

leetcode 原题链接:https://leetcode.com/problems/ugly-number/Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only inclu

2015-08-19 12:33:03 2436

原创 [C++]Single Number III单个数字3

leetcode 原题链接:https://leetcode.com/problems/single-number-iii/Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice

2015-08-17 15:44:55 1039

原创 [C++]Single Number 单个数字

leetcode 链接:https://leetcode.com/problems/single-number/Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a l

2015-08-17 15:18:21 919

原创 [Java]Contains Duplicate II 包含重复数字

leetcode 原题链接: https://leetcode.com/problems/contains-duplicate-ii/Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that num

2015-08-17 10:32:31 947

原创 [Java]Contains Duplicate 包含重复数字

leetcode 原题链接:https://leetcode.com/problems/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

2015-08-17 09:56:32 820

原创 [Java]Summary Ranges 统计区间

leetcode 原题链接:https://leetcode.com/problems/summary-ranges/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",

2015-08-17 09:37:22 1322

原创 [Java]Reverse Linked List II 链表翻转2

leetcode 原题链接:https://leetcode.com/problems/reverse-linked-list-ii/Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m =

2015-08-16 20:20:03 601

原创 [Java]Reverse Linked List 链表翻转

leetcode 链接:https://leetcode.com/problems/reverse-linked-list/Reverse a singly linked list.翻转一个单链表翻转单链表很简单,一个循环搞定,重点是要注意指针的操作,Java中没有指针,就是注意引用的操作,先后顺序搞明白了,很简单就可以完成了实现代码:public static L

2015-08-16 20:13:06 3949

原创 [java] Add Digits 数字相加

leetcode 原题链接: https://leetcode.com/problems/add-digits/Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38,

2015-08-16 15:54:35 2866

原创 [Java]Invert Binary Tree翻转二叉树

leetcode 原题链接:https://leetcode.com/problems/invert-binary-tree/Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Triv

2015-08-15 22:29:42 1132

原创 [Java]寻找最低公共祖先(普通树的情形)Lowest Common Ancestor of a Binary Tree

leetcode 原题链接 https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the

2015-08-15 22:06:25 891

原创 [Java]寻找最低公共祖先(排序二叉树)Lowest Common Ancestor of a Binary Search Tree

leetcode 原题链接 https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-search-tree/Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the B

2015-08-15 21:55:11 1488

原创 [Java] Majority Element II 找众数2

leetcode 链接 :https://leetcode.com/problems/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 tim

2015-08-13 19:11:30 1415

原创 [Java] 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-08-13 18:55:34 1108

原创 关于java方法是传递值还是引用的思考

今天看完了《大话数据结构》这本书,接着还有点时间,于是就试着按书上的思路试试编写快速排序算法于是有了如下的代码:package com.sort;import java.util.ArrayList;public class Quick{ public static void main(String[] args) { // TODO Auto-generated met

2015-08-12 22:16:40 389

原创 [编程题]A+B和C (15)

给定区间[-2^31, 2^31]内的3个整数A、B和C,请判断A+B是否大于C。 输入描述:输入第1行给出正整数T(输出描述:对每组测试用例,在一行中输出“Case #X: true”如果A+B>C,否则输出“Case #X: false”,其中X是测试用例的编号(从1开始)。输入例子:41 2 32 3 42147483647 0 2

2015-08-03 16:27:37 1175

原创 nowcoder马拉松--包含一

时间限制:1秒空间限制:32768K通过比例:21.59%最佳记录:0 ms|8460K(来自  只想有创意)题目描述NowCoder总是力争上游,凡事都要拿第一,所以他对“1”这个数情有独钟。爱屋及乌,他也很喜欢包含1的数,例如10、11、12……。你能帮他统计一下有多少个包含1的正整数吗? 输入描述:输入有多组数据,每组数据包含一个正整数n,(1≤n≤21474

2015-07-23 01:24:33 805

原创 鹊桥相会---编程马拉松

鹊桥相会时间限制:1秒空间限制:32768K 题目描述一年一度的七夕又要到了,可歌可泣的牛郎织女又可以在鹊桥相会了。不知道大家有没有雅兴陪nowcoder坐在葡萄藤下倾听他们的 对话。我们知道,牛郎要与织女相见,必须要有喜鹊搭桥。所以,牛郎必须在天河岸上等待,直到有喜鹊经过,于是牛郎可以搭乘这只喜鹊 往河对岸走。 当然,牛郎急着去见织女,所有在途中,如果

2015-07-12 23:29:30 1780

原创 换零钱---编程马拉松

换零钱时间限制:1秒 空间限制:32768K 题目描述考虑仅用1分、5分、10分、25分和50分这5种硬币支付某一个给定的金额。例如需要支付11分钱,有一个1分和一个10分、一个1分和一个5分、六个1分和一个5分、十一个1分这4种方式。请写一个程序,计算一个给定的金额有几种支付方式。注:假定支付0元有1种方式。输入描述:输入包含多组数据。每组数据

2015-07-12 16:49:01 1072

原创 错排问题--十二金钗

#每日一面BAT#第6题:金钗赛诗每日一面BAT赛诗会后,十二金钗待奔前程。分别宴上,12人各写了一首诗放入宝囊。大家随机取一个,若取到自己的诗,则再取一个并放回自己的诗。12人都拿到诗算一种分配。问:共有多少种不同的分配?问题来源:http://ask.julyedu.com/question/608?notification_id=3

2015-07-08 20:27:07 612

原创 NowCoder猜想---统计n以内的素数个数

题目描述nowcoder在家极度无聊,于是找了张纸开始统计素数的个数。设函数f(n)返回从1-n之间素数的个数。nowcoder 发现:f(1)   = 0f(10)  = 4f(100) = 25...满足g(m) = 17 * m^2 / 3 - 22 * m / 3 + 5 / 3其中m为n的位数。他很激动,是不是自己发现了素数分布的规律了!请

2015-07-07 19:01:27 2791

原创 2-06. 数列求和

给定某数字A(1输入格式说明:输入数字A与非负整数N。输出格式说明:输出其N项数列之和S的值。样例输入与输出:序号输入输出11 312326 10074074074074074074074074074074074074074074074074

2015-06-23 18:26:09 910

原创 关于IF判断的问题(一个有趣的事情)(分支-08. 高速公路超速处罚(15))

首先,这里的问题很简单,题目如下:分支-08. 高速公路超速处罚(15)时间限制 400 ms内存限制 65536 kB代码长度限制 8000 B判题程序 Standard 作者 陈建海(浙江大学)按照规定,在高速公路上行使的机动车,超出本车道限速的10%则处200元罚款;若超出50%,

2015-04-23 18:58:22 2781 1

原创 02-线性结构1. 一元多项式求导(java版)

设计函数求一元多项式的导数。(注:xn(n为整数)的一阶导数为n*xn-1。)输入格式:以指数递降方式输入多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:以与输入相同的格式输出导数多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。注意“零多项式”的指数和系数都是0,但是表示为“0 0”。输入样例:3 4 -5 2 6 1

2015-03-21 10:34:14 1782

原创 00-自测4. Have Fun with Numbers

Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 246913578, which happens to be another 9-digit number con

2015-03-19 13:39:04 611

原创 1003. 我要通过!(JAVA)

“答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于PAT的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。得到“答案正确”的条件是:1. 字符串中必须仅有P, A, T这三种字符,不可以包含其它字符;2. 任意形如 xPATx 的字符串都可以获得“答案正确”,其中 x 或者是空字符串,或者是仅由字母

2015-03-17 13:13:31 921

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除