
code
OddBillow
这个作者很懒,什么都没留下…
展开
-
末尾0的个数
题目描述: 输入一个正整数n,求n!末尾有多少个0? 实现(Java):import java.util.Scanner;public class factorialNumZero { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x原创 2016-09-18 18:48:07 · 330 阅读 · 0 评论 -
0-1背包问题
import java.util.Scanner;/** * Created by Tao on 2018/8/12. */public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] str1 ...原创 2018-08-17 09:52:46 · 139 阅读 · 0 评论 -
二进制中1的个数
二进制表示整数,输出二进制中1的个数public class Solution { public int NumberOf1(int n) { int res = 0; int flag = 1; while (flag != 0) { if ((flag & n) == 1) { ...原创 2018-05-25 20:33:52 · 120 阅读 · 0 评论 -
青蛙跳台阶
一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法public class Solution { public int JumpFloor(int target) { if (target == 0) { return 0; } if (target == 1) { ...原创 2018-05-25 20:32:38 · 134 阅读 · 0 评论 -
斐波那契数列
/**输出斐波那契数列第n项 --- 递归*/public class Solution{public int Fibonacci(int n) { if (n == 0) { return 0; } if (n == 1) { return 1; } return ...原创 2018-05-25 20:31:11 · 158 阅读 · 0 评论 -
数组旋转
把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。import java.util.*;public class Solution {public int minNumberInRotateArray(int[] array) { for (int j = 0;j < array.length; ...原创 2018-05-25 20:28:25 · 553 阅读 · 0 评论 -
两个栈实现队列
import java.util.*;public class Solution { /**两个栈实现队列*/ Stack<Integer> stack1 = new Stack<Integer>(); Stack<Integer> stack2 = new Stack<Integer>(); public voi...原创 2018-05-25 20:26:31 · 101 阅读 · 0 评论 -
求数值的整数次方
需要考虑的特殊情况:输入的指数是0或负数底数是0一般的算法当指数为32时,需要在循环中做31次乘法,换种思路,在平方基础上求4次方,4次方基础上求8次方,利用递归可以减少乘法运算次数package tao.leetcode;/** * Created by Tao on 2017/7/30. */public class MyLeetcode { public static voi...原创 2018-03-12 20:51:52 · 184 阅读 · 0 评论 -
求二进制中1的个数
可能引起死循环的解法package tao.leetcode;/** * Created by Tao on 2017/7/30. */public class MyLeetcode { public static void main(String[] args) { int x = 10; int res = NumberOf1(x); ...原创 2018-03-08 21:43:12 · 129 阅读 · 0 评论 -
从尾到头打印链表
不改变链表的结构,从尾到头打印链表需要用栈实现这个函数,而递归的本质就是一个栈结构。如果链表过长,可能会导致函数调用栈溢出。栈实现:package tao.leetcode;/** * Created by Tao on 2017/7/30. */public class MyLeetcode { public static void main(String[] args) { ...原创 2018-03-07 22:09:40 · 120 阅读 · 0 评论 -
二维数组升序排列
package tao.leetcode;import java.util.*;/** * Created by Tao on 2017/7/30. */public class MyLeetcode { public static void main(String[] args) { int[][] people = {{7,0}, {4,4}, {7,1}, {原创 2017-09-02 21:00:22 · 1552 阅读 · 0 评论 -
动态规划求最长公共序列
序列不连续:import java.io.IOException;import java.util.Arrays;import java.util.Scanner;/** * Created by Tao on 2017/8/7. */public class Main { public static void main(String[] args) throws IOExcep原创 2017-09-02 14:48:24 · 197 阅读 · 0 评论 -
371. Sum of Two Integers
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.import java.util.Scanner;/** * Created by Tao on 2017/2/6. */public class _371 { public static void原创 2017-02-06 21:52:56 · 231 阅读 · 0 评论 -
136. Single Number
Given an array of integers, every element appears twice except for one. Find that single one.public class _136 { public static void main(String[] args) { int[] nums = {1,2,3,2,5,99,4,5,99,4原创 2017-02-06 21:01:02 · 271 阅读 · 0 评论 -
求阶乘的最后非零位
基本思想:将x个输入每10个一组进行分组,剩余的最后一组单独列出。将10个一组的数据相乘后再除以(5的倍数乘4),以第一组数据为例:(1*2*3*4*5*6*7*8*9*10)/(4*5*10)=1*2*3*4*6*7*8*9/4,最后一位是4,同理,别的几组最后一位数字也是4,易得最后一位数字为4或6。接下来处理与5的倍数相关的数据,即4*(5*10)4(15*20)…=10(1*2*3*4*5*原创 2016-10-18 20:55:31 · 1075 阅读 · 0 评论 -
Longest substring without repeating characters
Given a string, find the length of the longest substring without repeating characters. Examples: Given “abcabcbb”, the answer is “abc”, which the length is 3. Given “bbbbb”, the answer is “b”, with原创 2016-10-14 12:49:41 · 266 阅读 · 0 评论 -
CCF201503-1
题目描述: 旋转是图像处理的基本操作,在这个问题中,你需要将一个图像逆时针旋转90度。 计算机中的图像表示可以用一个矩阵来表示,为了旋转一个图像,只需要将对应的矩阵旋转即可。 输入格式 输入的第一行包含两个整数n, m,分别表示图像矩阵的行数和列数。 接下来n行每行包含m个整数,表示输入的图像。 输出格式 输出m行,每行包含n个整数,表示原始矩阵逆时针旋转90度后的矩阵原创 2016-09-22 17:33:01 · 328 阅读 · 0 评论 -
Github上传工程文件
在github上New repository,并复制该地址URL; 打开Git,cd到待上传文件的目录; git clone URL; cd 进入master; git add . git commit -m "first commit" git push -u origin master...原创 2018-11-15 12:05:42 · 168 阅读 · 0 评论