- 博客(12)
- 资源 (5)
- 收藏
- 关注
原创 LeetCode1218:逐步分析从最长递增子序列到最长定差子序列
按照最长递增子序列的思路dpclass Solution { public int longestSubsequence(int[] arr, int difference) { // dp[i]: arr[0~i] 中且以i结尾的最长定差子序列 int dp[] = new int[arr.length]; dp[0] = 1; int res = 1; for (int i = 1; i < arr.
2021-11-05 16:16:13
144
原创 IT笔试--动态规划--货币找零问题
题目:你要出去旅游,有N元的预算住酒店,有M家酒店供你挑选,这些酒店都有价格X。 需要你正好花完这N元住酒店(不能多,也不能少)最少能住几晚?返回最少住的天数,没有匹配的返回-1* 比如你有1000元,所有酒店都是大于1000的,则返回-1* 比如你有1000元,有1家1000元的,有1家300,有1家700。则最少能住1晚,最多住2晚(300+700)。返回1* 比如你有10
2017-09-03 20:29:14
1056
原创 LeetCode-Palindrome Number-Java
题目:Determine whether an integer is a palindrome. Do this without extra space.转成字符串,使用额外空间的解法。注意-123321应返回falsepublic boolean isPalindrome(int x) { String string = ""+x; for(int i=0;i<s
2017-09-02 19:34:19
233
原创 LeetCode-Reverse Integer-Java
题目:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Note:The input is assumed to be a 32-bit signed integer. Your f
2017-09-02 19:06:49
226
原创 java_LeetCode_3--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 answ
2017-08-24 20:02:33
198
原创 LeetCode_2----Add Two Numbers
题目:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and ret
2017-08-23 21:09:32
158
原创 LeetCode---twoSum
题目:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the sa
2017-08-23 19:46:58
175
原创 24点游戏算法
24点游戏算法问题描述:给出4个1-10的数字,通过加减乘除,得到数字为24就算胜利输入:4个1-10的数字。[数字允许重复,测试用例保证无异常数字]输出:true or falseimport java.util.*;public class Main{public static void main(String args[]) {
2017-08-13 16:35:10
448
原创 24点运算
import java.util.Scanner; public class Main{ private static boolean isA = false; private static final int TARGET = 24; public static void main(String[] args) {
2017-08-13 16:30:27
306
原创 jAVA 识别有效的IP地址和掩码并进行分类统计
import java.util.*;public class Main{ static int a = 0; static int b = 0; static int c = 0; static int d = 0; static int e = 0; static int err = 0; static
2017-08-12 18:11:57
1269
原创 java 找出所有最长连续重复子串及其个数
import java.util.*;class Pair{ int n; String s; Pair(int n,String s){ this.n = n; this.s = s; }}public class Main{ public static List fun(String str){ List subs = new ArrayLis
2017-08-12 15:54:30
4226
原创 华为机试题
23.字符串加解密import java.util.*;public class Main {public static void main(String[] args) {// TODO Auto-generated method stubScanner sc = new Scanner(System.in);while(sc.hasNext()){S
2017-08-10 20:41:02
409
java解析json(json-lib-2.4)
2018-02-02
经纬度计算距离、方位角等java源码
2018-02-02
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人