├── README.md ├── .idea ├── copyright │ └── profiles_settings.xml ├── vcs.xml ├── libraries │ └── junit4_4.xml ├── kotlinc.xml ├── modules.xml ├── misc.xml └── compiler.xml ├── out └── production │ ├── sort │ ├── exam │ │ ├── Main.class │ │ ├── print.class │ │ └── print$TreeNode.class │ ├── sort │ │ ├── Heapsort.class │ │ ├── Mergesort.class │ │ ├── bubblesort.class │ │ ├── insertsort.class │ │ ├── quicksort.class │ │ ├── quicksort2.class │ │ └── selectsort.class │ ├── binarytree │ │ ├── print.class │ │ ├── TreeNode.class │ │ └── levelprint.class │ └── datastructure │ │ ├── except.class │ │ ├── queue.class │ │ ├── stack.class │ │ ├── linkedlist.class │ │ ├── queue$node.class │ │ ├── stack$node.class │ │ └── linkedlist$node.class │ └── Algorithm │ ├── exam │ ├── Main.class │ ├── print.class │ ├── EvenStr.class │ ├── GoToWork.class │ ├── TaskList.class │ ├── findNum.class │ ├── longStr.class │ ├── BalanceNum.class │ ├── BeautyStr.class │ ├── ComplexPro.class │ ├── MagicRing.class │ ├── MathDream.class │ ├── CategoryStr.class │ ├── CommonArray.class │ └── print$TreeNode.class │ ├── exam2 │ ├── rank.class │ ├── test.class │ ├── Stone.class │ ├── bagPro.class │ ├── fruit.class │ ├── renren.class │ ├── DoubleCut.class │ ├── ToNumber26.class │ ├── bagPro$Bag.class │ ├── PoliceAndThief.class │ ├── xiaomingzuoti.class │ ├── ShortWordChange.class │ ├── binaryTreePrint.class │ └── binaryTreePrint$TreeNode.class │ ├── exam3 │ ├── Main.class │ ├── paypal.class │ ├── pintu.class │ ├── MaxMulti.class │ └── StockPrice.class │ ├── exam4 │ ├── hat.class │ ├── alibaba.class │ ├── Rectangle.class │ └── resolveBolan.class │ ├── DP │ └── Fibonacci.class │ ├── format │ └── input.class │ ├── sort │ ├── Heapsort.class │ ├── Mergesort.class │ ├── bubblesort.class │ ├── dividesort.class │ ├── insertsort.class │ ├── quicksort.class │ ├── quicksort2.class │ └── selectsort.class │ ├── practice │ ├── NewSum.class │ ├── monkey.class │ ├── tanxin.class │ ├── GcdAndLcm.class │ ├── dynamic.class │ ├── isprime.class │ ├── ClimbStairs.class │ ├── LongestStr.class │ ├── TheShortest.class │ └── resolveNum.class │ ├── binarytree │ ├── norecur.class │ ├── print.class │ ├── TreeNode.class │ └── levelprint.class │ └── datastructure │ ├── except.class │ ├── queue.class │ ├── stack.class │ ├── TreeNode.class │ ├── linkedlist.class │ ├── queue$node.class │ ├── stack$node.class │ └── linkedlist$node.class ├── src ├── 校招笔试 │ ├── 吉比特 │ │ └── 忘了.java │ ├── 搜狐 │ │ ├── 兄弟串.java │ │ ├── 走到目标点.java │ │ └── 版本号比较.java │ ├── 触宝 │ │ └── 题目一.java │ ├── 链家 │ │ ├── 抽牌.java │ │ └── 修路.java │ ├── 快手 │ │ ├── ip.java │ │ ├── 打饭.java │ │ └── 爬楼梯.java │ ├── 点我达 │ │ └── 无编程题.java │ ├── 牛客模考 │ │ ├── t2.java │ │ ├── t3.java │ │ ├── test.java │ │ └── 牛牛数星星.java │ ├── 头条 │ │ ├── 头条三轮 │ │ │ ├── 岛屿.java │ │ │ ├── 最长不重复子串.java │ │ │ ├── utf8.java │ │ │ └── ip.java │ │ ├── A.java │ │ ├── D.java │ │ ├── C.java │ │ ├── 头条二轮 │ │ │ └── Pm25.java │ │ └── E.java │ ├── 贝壳看房 │ │ └── test1.java │ ├── 华为 │ │ ├── 最长连续字符串.java │ │ ├── 大小写字母转化.java │ │ └── 小偷偷东西问题.java │ ├── 京东 │ │ ├── 中位数.java │ │ ├── 修路.java │ │ └── 对比.java │ ├── 百度 │ │ └── test.java │ ├── 携程 │ │ ├── bitcount.java │ │ └── 查询满足区间的记录.java │ ├── 拼多多 │ │ ├── 第二波 │ │ │ ├── 回合制游戏.java │ │ │ ├── 循环小数.java │ │ │ └── 拼词游戏.java │ │ ├── 选靓号.java │ │ ├── 复制可乐.java │ │ └── 球王.java │ ├── 知乎 │ │ └── 中位数.java │ ├── 网易 │ │ ├── 小易的字典.java │ │ ├── 丰收.java │ │ └── 瞌睡.java │ ├── 虾皮 │ │ ├── 排序.java │ │ ├── 下台阶.java │ │ └── 奖金.java │ ├── 大疆 │ │ └── Test.java │ ├── 深信服 │ │ ├── 网站开业.java │ │ ├── 抓兔子游戏.java │ │ └── 一百分.java │ ├── oppo │ │ └── 随机逆序排序.java │ ├── 好未来 │ │ ├── 三三三.java │ │ └── 位运算求y.java │ ├── 爱奇艺 │ │ └── 食物.java │ ├── 科大讯飞 │ │ └── 修改成绩.java │ └── Keep │ │ └── 翻转字符串.java ├── 笔试必备算法 │ ├── 全排列.java │ ├── 字典树.java │ ├── 最大公约数.java │ └── N进制转换.java ├── 七月算法 │ ├── 图算法 │ │ ├── 拓扑排序.java │ │ ├── 最小生成树.java │ │ └── 单源点最短路.java │ ├── 递归 │ │ └── 全排列.java │ └── BFS和DFS │ │ └── 求可达性的DFS.java ├── 数据结构常用算法 │ ├── 图论 │ │ ├── 拓扑.java │ │ ├── 图搜索.java │ │ ├── 并查集.java │ │ ├── 弗洛伊德.java │ │ ├── 迪杰斯特拉.java │ │ └── 克鲁斯卡尔和普利姆.java │ ├── 二叉树 │ │ ├── 字典树.java │ │ └── 非递归的树遍历.java │ ├── 字符串 │ │ ├── kmp.java │ │ └── 回文.java │ ├── 数论 │ │ ├── 全排序.java │ │ └── 最大公约数和最小公倍数.java │ ├── 贪心 │ │ ├── 近似解.java │ │ └── 如何排课上的课最多.java │ ├── DP │ │ ├── 最长公共子串.java │ │ ├── 最长公共子序列.java │ │ └── 从A到B的走法总数.java │ ├── 哈希表 │ │ └── 统计次数.java │ ├── 数组和链表 │ │ ├── 循环数组.java │ │ └── 相交链表.java │ ├── 队列和栈 │ │ ├── 括号匹配.java │ │ ├── 最小值栈.java │ │ ├── 进制转换.java │ │ └── 栈和队列的转换.java │ ├── 枚举到递归再到搜索 │ │ ├── BFS.java │ │ ├── DFS.java │ │ └── 八皇后回溯.java │ ├── 二进制 │ │ ├── 数组唯一的数.java │ │ └── 数组只出现一次的两个数.java │ ├── 排序 │ │ ├── 桶排序.java │ │ ├── 插入排序.java │ │ ├── 计数排序.java │ │ ├── 选择排序.java │ │ ├── 冒泡.java │ │ ├── 快排.java │ │ └── 归并.java │ └── 二分查找 │ │ └── 二分.java ├── 剑指offer二刷 │ ├── 数组 │ │ ├── 数据流的中位数.java │ │ ├── 和为s的连续正数序列.java │ │ ├── 旋转数组的最小数字.java │ │ └── 把数组排成最小的数.java │ ├── 链表 │ │ ├── Node.java │ │ ├── 链表环的入口.java │ │ └── 从尾到头打印链表.java │ ├── 树 │ │ ├── TreeNode.java │ │ └── 二叉树的深度.java │ └── 字符串 │ │ ├── 翻转单词顺序列.java │ │ └── 数据流字符出现的个数.java ├── 牛客往年真题 │ ├── 笔试17年 │ │ ├── 京东 │ │ │ ├── 保卫方案.java │ │ │ ├── 幸运数.java │ │ │ ├── 集合.java │ │ │ └── 进制均值.java │ │ ├── 头条 │ │ │ ├── 字典序.java │ │ │ ├── 异或.java │ │ │ └── 头条校招.java │ │ ├── 滴滴 │ │ │ └── 末尾0的个数.java │ │ ├── 网易 │ │ │ ├── 暗黑字符串.java │ │ │ ├── 星际穿越.java │ │ │ ├── 优雅的数.java │ │ │ ├── 计算糖果.java │ │ │ ├── 数字翻转.java │ │ │ ├── 买苹果.java │ │ │ ├── 下厨房.java │ │ │ ├── 斐波那契数.java │ │ │ ├── 跳石板.java │ │ │ ├── 藏宝图.java │ │ │ ├── 解救小易.java │ │ │ ├── 数字游戏.java │ │ │ └── 统计回文.java │ │ ├── 腾讯 │ │ │ ├── 游戏任务标记.java │ │ │ ├── geohash编码.java │ │ │ └── 素数对.java │ │ ├── 美团 │ │ │ ├── 丢失的三个数.java │ │ │ ├── 网格走法数目.java │ │ │ └── 拼凑面额.java │ │ └── 网易游戏 │ │ │ └── 会话列表.java │ └── 笔试16年 │ │ ├── 美团 │ │ ├── 字符串计数.java │ │ ├── 最大差值.java │ │ ├── 棋子翻转.java │ │ └── 直方图内最大矩形.java │ │ └── 小米 │ │ └── 懂二进制.java └── 过去笔试记录 │ ├── In2017 │ ├── exam2 │ │ ├── test.java │ │ ├── rank.java │ │ ├── ToNumber26.java │ │ ├── xiaomingzuoti.java │ │ ├── fruit.java │ │ ├── renren.java │ │ └── PoliceAndThief.java │ ├── exam3 │ │ ├── pintu.java │ │ ├── MaxMulti.java │ │ └── carLoad.java │ ├── exam4 │ │ ├── Island.java │ │ ├── SimilarString.java │ │ ├── Rectangle.java │ │ ├── StupidBear.java │ │ └── hat.java │ ├── exam │ │ ├── BeautyStr.java │ │ ├── ComplexPro.java │ │ ├── Main.java │ │ ├── CategoryStr.java │ │ ├── MathDream.java │ │ ├── longStr.java │ │ ├── findNum.java │ │ ├── EvenStr.java │ │ ├── BalanceNum.java │ │ └── print.java │ └── ali │ │ └── binsearch.java │ ├── In2018 │ ├── Written │ │ ├── 京东 │ │ │ ├── test.java │ │ │ ├── 分解整数.java │ │ │ └── 移除字符变成回文子串.java │ │ ├── 头条 │ │ │ ├── 调用次数.java │ │ │ ├── 跳板.java │ │ │ ├── input.java │ │ │ └── magic次数.java │ │ ├── 头条2 │ │ │ ├── Test.java │ │ │ └── t1.java │ │ ├── 腾讯 │ │ │ ├── input.java │ │ │ ├── 前端 │ │ │ │ └── Tencent6.java │ │ │ └── 翻转数列.java │ │ ├── 百度 │ │ │ ├── testint.java │ │ │ ├── testlong.java │ │ │ └── 平行四边形.java │ │ ├── Test.java │ │ ├── 头条3 │ │ │ ├── t2.java │ │ │ ├── t3.java │ │ │ ├── t4.java │ │ │ ├── test.java │ │ │ └── t1.java │ │ ├── 招行信用卡 │ │ │ └── test.java │ │ ├── 网易互联网 │ │ │ ├── Test.java │ │ │ └── NumCouple.java │ │ └── 牛客模考 │ │ │ ├── 生活费.java │ │ │ └── 吃雪糕.java │ └── Interview │ │ ├── 酷家乐 │ │ └── Date.java │ │ └── 头条 │ │ ├── Node.java │ │ ├── getTheRightBiggerNum.java │ │ └── karray.java │ ├── Basic │ ├── binarytree │ │ ├── norecur.java │ │ ├── TreeNode.java │ │ ├── print.java │ │ └── levelprint.java │ ├── practice │ │ ├── NewSum.java │ │ ├── isprime.java │ │ ├── monkey.java │ │ ├── resolveNum.java │ │ ├── DP │ │ │ └── Fibonacci.java │ │ ├── GcdAndLcm.java │ │ ├── dynamic.java │ │ ├── LongestStr.java │ │ └── ClimbStairs.java │ ├── datastructure │ │ ├── TreeNode.java │ │ ├── except.java │ │ ├── LRU.java │ │ ├── queue.java │ │ └── stack.java │ └── sort │ │ ├── dividesort.java │ │ ├── insertsort.java │ │ ├── bubblesort.java │ │ ├── selectsort.java │ │ ├── quicksort2.java │ │ └── quicksort.java │ └── Format │ ├── 输入一个数和一个数组.java │ ├── 输入多个数和多行数.java │ └── 输入数组或多个数.java ├── .gitattributes ├── .gitignore └── Algorithm.iml /README.md: -------------------------------------------------------------------------------- 1 | # Algorithm 2 | 经典算法、笔试题 3 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /out/production/sort/exam/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/exam/Main.class -------------------------------------------------------------------------------- /out/production/sort/exam/print.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/exam/print.class -------------------------------------------------------------------------------- /out/production/sort/sort/Heapsort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/sort/Heapsort.class -------------------------------------------------------------------------------- /src/校招笔试/吉比特/忘了.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.吉比特; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/3. 5 | */ 6 | public class 忘了 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/搜狐/兄弟串.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.搜狐; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/13. 5 | */ 6 | public class 兄弟串 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/触宝/题目一.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.触宝; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/3. 5 | */ 6 | public class 题目一 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/链家/抽牌.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.链家; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/8/18. 5 | */ 6 | public class 抽牌 { 7 | } 8 | -------------------------------------------------------------------------------- /src/笔试必备算法/全排列.java: -------------------------------------------------------------------------------- 1 | package 笔试必备算法; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/6. 5 | */ 6 | public class 全排列 { 7 | } 8 | -------------------------------------------------------------------------------- /src/笔试必备算法/字典树.java: -------------------------------------------------------------------------------- 1 | package 笔试必备算法; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/6. 5 | */ 6 | public class 字典树 { 7 | } 8 | -------------------------------------------------------------------------------- /out/production/Algorithm/exam/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/Main.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/print.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/print.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/rank.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/rank.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/test.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/test.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam3/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam3/Main.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam4/hat.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam4/hat.class -------------------------------------------------------------------------------- /out/production/sort/sort/Mergesort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/sort/Mergesort.class -------------------------------------------------------------------------------- /out/production/sort/sort/bubblesort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/sort/bubblesort.class -------------------------------------------------------------------------------- /out/production/sort/sort/insertsort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/sort/insertsort.class -------------------------------------------------------------------------------- /out/production/sort/sort/quicksort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/sort/quicksort.class -------------------------------------------------------------------------------- /out/production/sort/sort/quicksort2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/sort/quicksort2.class -------------------------------------------------------------------------------- /out/production/sort/sort/selectsort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/sort/selectsort.class -------------------------------------------------------------------------------- /src/七月算法/图算法/拓扑排序.java: -------------------------------------------------------------------------------- 1 | package 七月算法.图算法; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/16. 5 | */ 6 | public class 拓扑排序 { 7 | } 8 | -------------------------------------------------------------------------------- /src/七月算法/图算法/最小生成树.java: -------------------------------------------------------------------------------- 1 | package 七月算法.图算法; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/16. 5 | */ 6 | public class 最小生成树 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/图论/拓扑.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.图论; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 拓扑 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/快手/ip.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.快手; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/10. 5 | */ 6 | public class ip { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/校招笔试/点我达/无编程题.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.点我达; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/3. 5 | */ 6 | public class 无编程题 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/牛客模考/t2.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.牛客模考; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/14. 5 | */ 6 | public class t2 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/牛客模考/t3.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.牛客模考; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/14. 5 | */ 6 | public class t3 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/牛客模考/test.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.牛客模考; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/14. 5 | */ 6 | public class test { 7 | } 8 | -------------------------------------------------------------------------------- /out/production/Algorithm/DP/Fibonacci.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/DP/Fibonacci.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/EvenStr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/EvenStr.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/GoToWork.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/GoToWork.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/TaskList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/TaskList.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/findNum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/findNum.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/longStr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/longStr.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/Stone.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/Stone.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/bagPro.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/bagPro.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/fruit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/fruit.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/renren.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/renren.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam3/paypal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam3/paypal.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam3/pintu.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam3/pintu.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam4/alibaba.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam4/alibaba.class -------------------------------------------------------------------------------- /out/production/Algorithm/format/input.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/format/input.class -------------------------------------------------------------------------------- /out/production/Algorithm/sort/Heapsort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/sort/Heapsort.class -------------------------------------------------------------------------------- /out/production/sort/binarytree/print.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/binarytree/print.class -------------------------------------------------------------------------------- /src/七月算法/图算法/单源点最短路.java: -------------------------------------------------------------------------------- 1 | package 七月算法.图算法; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/16. 5 | */ 6 | public class 单源点最短路 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/二叉树/字典树.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.二叉树; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 字典树 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/图论/图搜索.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.图论; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 图搜索 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/图论/并查集.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.图论; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 并查集 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/图论/弗洛伊德.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.图论; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 弗洛伊德 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/字符串/kmp.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.字符串; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class kmp { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/字符串/回文.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.字符串; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 回文 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/数论/全排序.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.数论; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 全排序 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/贪心/近似解.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.贪心; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 近似解 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/头条/头条三轮/岛屿.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.头条.头条三轮; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/9. 5 | */ 6 | public class 岛屿 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/贝壳看房/test1.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.贝壳看房; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/3. 5 | */ 6 | public class test1 { 7 | } 8 | -------------------------------------------------------------------------------- /out/production/Algorithm/exam/BalanceNum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/BalanceNum.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/BeautyStr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/BeautyStr.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/ComplexPro.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/ComplexPro.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/MagicRing.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/MagicRing.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/MathDream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/MathDream.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/DoubleCut.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/DoubleCut.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam3/MaxMulti.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam3/MaxMulti.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam4/Rectangle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam4/Rectangle.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/NewSum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/NewSum.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/monkey.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/monkey.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/tanxin.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/tanxin.class -------------------------------------------------------------------------------- /out/production/Algorithm/sort/Mergesort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/sort/Mergesort.class -------------------------------------------------------------------------------- /out/production/Algorithm/sort/bubblesort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/sort/bubblesort.class -------------------------------------------------------------------------------- /out/production/Algorithm/sort/dividesort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/sort/dividesort.class -------------------------------------------------------------------------------- /out/production/Algorithm/sort/insertsort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/sort/insertsort.class -------------------------------------------------------------------------------- /out/production/Algorithm/sort/quicksort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/sort/quicksort.class -------------------------------------------------------------------------------- /out/production/Algorithm/sort/quicksort2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/sort/quicksort2.class -------------------------------------------------------------------------------- /out/production/Algorithm/sort/selectsort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/sort/selectsort.class -------------------------------------------------------------------------------- /out/production/sort/binarytree/TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/binarytree/TreeNode.class -------------------------------------------------------------------------------- /out/production/sort/datastructure/except.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/datastructure/except.class -------------------------------------------------------------------------------- /out/production/sort/datastructure/queue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/datastructure/queue.class -------------------------------------------------------------------------------- /out/production/sort/datastructure/stack.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/datastructure/stack.class -------------------------------------------------------------------------------- /out/production/sort/exam/print$TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/exam/print$TreeNode.class -------------------------------------------------------------------------------- /src/数据结构常用算法/DP/最长公共子串.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.DP; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 最长公共子串 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/DP/最长公共子序列.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.DP; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 最长公共子序列 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/哈希表/统计次数.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.哈希表; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 统计次数 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/图论/迪杰斯特拉.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.图论; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 迪杰斯特拉 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/数组和链表/循环数组.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.数组和链表; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 循环数组 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/数组和链表/相交链表.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.数组和链表; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 相交链表 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/队列和栈/括号匹配.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.队列和栈; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 括号匹配 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/队列和栈/最小值栈.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.队列和栈; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 最小值栈 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/队列和栈/进制转换.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.队列和栈; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 进制转换 { 7 | } 8 | -------------------------------------------------------------------------------- /out/production/Algorithm/binarytree/norecur.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/binarytree/norecur.class -------------------------------------------------------------------------------- /out/production/Algorithm/binarytree/print.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/binarytree/print.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/CategoryStr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/CategoryStr.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/CommonArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/CommonArray.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/ToNumber26.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/ToNumber26.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/bagPro$Bag.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/bagPro$Bag.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam3/StockPrice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam3/StockPrice.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam4/resolveBolan.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam4/resolveBolan.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/GcdAndLcm.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/GcdAndLcm.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/dynamic.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/dynamic.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/isprime.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/isprime.class -------------------------------------------------------------------------------- /out/production/sort/binarytree/levelprint.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/binarytree/levelprint.class -------------------------------------------------------------------------------- /src/剑指offer二刷/数组/数据流的中位数.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.数组; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 数据流的中位数 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/DP/从A到B的走法总数.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.DP; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 从A到B的走法总数 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/二叉树/非递归的树遍历.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.二叉树; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 非递归的树遍历 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/图论/克鲁斯卡尔和普利姆.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.图论; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 克鲁斯卡尔和普利姆 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/贪心/如何排课上的课最多.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.贪心; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 如何排课上的课最多 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/队列和栈/栈和队列的转换.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.队列和栈; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 栈和队列的转换 { 7 | } 8 | -------------------------------------------------------------------------------- /src/校招笔试/头条/头条三轮/最长不重复子串.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.头条.头条三轮; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/9. 5 | */ 6 | public class 最长不重复子串 { 7 | } 8 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/京东/保卫方案.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.京东; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/6. 5 | */ 6 | public class 保卫方案 { 7 | } 8 | -------------------------------------------------------------------------------- /out/production/Algorithm/binarytree/TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/binarytree/TreeNode.class -------------------------------------------------------------------------------- /out/production/Algorithm/datastructure/except.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/datastructure/except.class -------------------------------------------------------------------------------- /out/production/Algorithm/datastructure/queue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/datastructure/queue.class -------------------------------------------------------------------------------- /out/production/Algorithm/datastructure/stack.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/datastructure/stack.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam/print$TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam/print$TreeNode.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/PoliceAndThief.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/PoliceAndThief.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/xiaomingzuoti.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/xiaomingzuoti.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/ClimbStairs.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/ClimbStairs.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/LongestStr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/LongestStr.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/TheShortest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/TheShortest.class -------------------------------------------------------------------------------- /out/production/Algorithm/practice/resolveNum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/practice/resolveNum.class -------------------------------------------------------------------------------- /out/production/sort/datastructure/linkedlist.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/datastructure/linkedlist.class -------------------------------------------------------------------------------- /out/production/sort/datastructure/queue$node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/datastructure/queue$node.class -------------------------------------------------------------------------------- /out/production/sort/datastructure/stack$node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/datastructure/stack$node.class -------------------------------------------------------------------------------- /src/数据结构常用算法/数论/最大公约数和最小公倍数.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.数论; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 最大公约数和最小公倍数 { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/枚举到递归再到搜索/BFS.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.枚举到递归再到搜索; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class BFS { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/枚举到递归再到搜索/DFS.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.枚举到递归再到搜索; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class DFS { 7 | } 8 | -------------------------------------------------------------------------------- /src/数据结构常用算法/枚举到递归再到搜索/八皇后回溯.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.枚举到递归再到搜索; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 八皇后回溯 { 7 | } 8 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam2/test.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam2; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/26. 5 | */ 6 | public class test { 7 | } 8 | -------------------------------------------------------------------------------- /out/production/Algorithm/binarytree/levelprint.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/binarytree/levelprint.class -------------------------------------------------------------------------------- /out/production/Algorithm/datastructure/TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/datastructure/TreeNode.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/ShortWordChange.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/ShortWordChange.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/binaryTreePrint.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/binaryTreePrint.class -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam3/pintu.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam3; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/4/11. 5 | */ 6 | public class pintu { 7 | } 8 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam4/Island.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam4; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/5/7. 5 | */ 6 | public class Island { 7 | } 8 | -------------------------------------------------------------------------------- /out/production/Algorithm/datastructure/linkedlist.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/datastructure/linkedlist.class -------------------------------------------------------------------------------- /out/production/Algorithm/datastructure/queue$node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/datastructure/queue$node.class -------------------------------------------------------------------------------- /out/production/Algorithm/datastructure/stack$node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/datastructure/stack$node.class -------------------------------------------------------------------------------- /out/production/sort/datastructure/linkedlist$node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/sort/datastructure/linkedlist$node.class -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/京东/test.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.京东; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/4/9. 5 | */ 6 | public class test { 7 | } 8 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/binarytree/norecur.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.binarytree; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | public class norecur { 7 | } 8 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条/调用次数.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/3/24. 5 | */ 6 | public class 调用次数 { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条2/Test.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条2; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/4/15. 5 | */ 6 | public class Test { 7 | } 8 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/腾讯/input.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.腾讯; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/4/5. 5 | */ 6 | public class input { 7 | } 8 | -------------------------------------------------------------------------------- /out/production/Algorithm/datastructure/linkedlist$node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/datastructure/linkedlist$node.class -------------------------------------------------------------------------------- /out/production/Algorithm/exam2/binaryTreePrint$TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/h2pl/Algorithm/HEAD/out/production/Algorithm/exam2/binaryTreePrint$TreeNode.class -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam4/SimilarString.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam4; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/5/7. 5 | */ 6 | public class SimilarString { 7 | } 8 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/百度/testint.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.百度; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/4/18. 5 | */ 6 | public class testint { 7 | } 8 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam2/rank.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam2; 2 | 3 | 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/4/1. 7 | */ 8 | public class rank { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/校招笔试/华为/最长连续字符串.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.华为; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/1. 7 | */ 8 | public class 最长连续字符串 { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/校招笔试/京东/中位数.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.京东; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/9. 5 | */ 6 | public class 中位数 { 7 | public static void main(String[] args) { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/校招笔试/快手/打饭.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.快手; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/10. 5 | */ 6 | public class 打饭 { 7 | public static void main(String[] args) { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/数据结构常用算法/二进制/数组唯一的数.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.二进制; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 数组唯一的数 { 7 | public static void main(String[] args) { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/头条/字典序.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.头条; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/6. 5 | */ 6 | public class 字典序 { 7 | public static void main(String[] args) { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/头条/异或.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.头条; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/6. 5 | */ 6 | public class 异或 { 7 | public static void main(String[] args) { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/practice/NewSum.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.practice; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | public class NewSum { 7 | 8 | void sum(int n){ 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/数据结构常用算法/二进制/数组只出现一次的两个数.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.二进制; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 数组只出现一次的两个数 { 7 | public static void main(String[] args) { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/Test.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/5/23. 5 | */ 6 | public class Test { 7 | public static void main(String[] args) { 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/校招笔试/百度/test.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.百度; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/11. 5 | */ 6 | public class test { 7 | public static void main(String[] args) { 8 | 9 | System.out.println(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/剑指offer二刷/链表/Node.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.链表; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class Node{ 7 | Node next; 8 | int val; 9 | public Node(int val) { 10 | this.val = val; 11 | } 12 | } -------------------------------------------------------------------------------- /.idea/libraries/junit4_4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam4/Rectangle.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam4; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/4/27. 5 | */ 6 | public class Rectangle { 7 | public static void main(String []args) { 8 | System.out.println(3); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条3/t2.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条3; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/5/12. 5 | */ 6 | public class t2 { 7 | public static void main(String[] args) { 8 | System.out.println(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条3/t3.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条3; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/5/12. 5 | */ 6 | public class t3 { 7 | public static void main(String[] args) { 8 | System.out.println(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条3/t4.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条3; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/5/12. 5 | */ 6 | public class t4 { 7 | public static void main(String[] args) { 8 | System.out.println(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/招行信用卡/test.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.招行信用卡; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/3/29. 5 | */ 6 | public class test { 7 | public static void main(String[] args) { 8 | System.out.println("(()),()()"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam/BeautyStr.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/23. 5 | */ 6 | public class BeautyStr { 7 | public int BeautyStr(int N,int M,int K){ 8 | if(M==0 || M==0 )return 0; 9 | return 0; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/剑指offer二刷/树/TreeNode.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.树; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class TreeNode { 7 | TreeNode left; 8 | TreeNode right; 9 | int val; 10 | public TreeNode(int val) { 11 | this.val = val; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/剑指offer二刷/链表/链表环的入口.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.链表; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 链表环的入口 { 7 | 8 | public static void main(String[] args) { 9 | 10 | } 11 | public static void findNode(Node A, Node B ) { 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/网易互联网/Test.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.网易互联网; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/3/27. 5 | */ 6 | public class Test { 7 | public static void main(String[] args) { 8 | String a = null; 9 | 10 | System.out.println(a); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/datastructure/TreeNode.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.datastructure; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/4/13. 5 | */ 6 | public class TreeNode { 7 | int data; 8 | TreeNode left; 9 | TreeNode right; 10 | TreeNode(int data){ 11 | this.data=data; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Interview/酷家乐/Date.java: -------------------------------------------------------------------------------- 1 | package mianshi.kujiale; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/3/2. 5 | */ 6 | public class Date 7 | { 8 | public int Year; 9 | public int Month; 10 | public int Day; 11 | public int Hour; 12 | public int Minute; 13 | public int Second; 14 | } 15 | -------------------------------------------------------------------------------- /src/校招笔试/头条/A.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.头条; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/12. 7 | */ 8 | public class A { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | func(); 12 | } 13 | public static void func() { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/校招笔试/头条/D.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.头条; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/12. 7 | */ 8 | public class D { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | func(); 12 | } 13 | public static void func() { 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/binarytree/TreeNode.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.binarytree; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | class TreeNode{ 7 | TreeNode left=null; 8 | TreeNode right=null; 9 | int val; 10 | TreeNode(int val){ 11 | this.val=val; 12 | 13 | } 14 | TreeNode(){ 15 | val=0; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/practice/isprime.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.practice; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | public class isprime { 7 | boolean isprime(int x){ 8 | for(int i=2;i arr[i]) { 14 | return arr[i]; 15 | } 16 | } 17 | return arr[0]; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/笔试必备算法/最大公约数.java: -------------------------------------------------------------------------------- 1 | package 笔试必备算法; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/6. 5 | */ 6 | public class 最大公约数 { 7 | 8 | public static void main(String[] args) { 9 | 10 | int a = 30, b = 25;//a 是分母 11 | int gcd = gcd(a,b); 12 | System.out.println( b/gcd + "/" + a/gcd); // 输出了 5/6 13 | } 14 | public static int gcd(int x, int y){ // 这个是运用辗转相除法求 两个数的 最大公约数 看不懂可以百度 // 下 15 | if(y == 0) 16 | return x; 17 | else 18 | return gcd(y,x%y); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/滴滴/末尾0的个数.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.滴滴; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/27. 7 | */ 8 | public class 末尾0的个数 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int n = scanner.nextInt(); 12 | int cnt = 0; 13 | for (int i = 1;i <= n;i ++) { 14 | int temp = i; 15 | while (temp % 5 == 0) { 16 | temp = temp/5; 17 | cnt++; 18 | } 19 | } 20 | System.out.println(cnt); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/datastructure/except.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.datastructure; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | public class except { 7 | public static void fun()throws Exception{ 8 | 9 | 10 | } 11 | public static void exe()throws Exception{ 12 | int i=1/0; 13 | fun(); 14 | } 15 | public static void main(String args[])throws Exception{ 16 | 17 | try { 18 | exe(); 19 | }catch (Exception e){ 20 | e.printStackTrace(); 21 | System.out.println("sadas"); 22 | } 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/practice/resolveNum.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.practice; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/10. 7 | */ 8 | public class resolveNum { 9 | void resolve(int num){ 10 | int i; 11 | for (i=2;i extends LinkedHashMap { 11 | //定义缓存的容量 12 | private int capacity; 13 | LRULinkedHashMap(int capacity) { 14 | this.capacity = capacity; 15 | } 16 | 17 | @Override 18 | protected boolean removeEldestEntry(Map.Entry eldest) { 19 | return size() > capacity; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/practice/DP/Fibonacci.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.practice.DP; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/19. 7 | */ 8 | public class Fibonacci { 9 | public int Fibonacci(int n) { 10 | if(n==0 ||n==1){ 11 | return n; 12 | } 13 | int []arr=new int[n]; 14 | 15 | arr[0]=1; 16 | arr[1]=1; 17 | for(int i=2;i= 1; i --) { 17 | if (i * (i + 1) <= h) { 18 | return i; 19 | } 20 | } 21 | return 0; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/数据结构常用算法/排序/桶排序.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.排序; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 桶排序 { 7 | public static void main(String[] args) { 8 | int []arr = {1,3,41,5,8,8,4,61}; 9 | tongSort(arr, 61); 10 | } 11 | public static void tongSort(int []arr, int max) { 12 | int []map = new int[max + 1]; 13 | for (int i = 0;i < arr.length;i ++) { 14 | map[arr[i]] += 1; 15 | } 16 | for (int i = 0;i < map.length;i ++) { 17 | int j = map[i]; 18 | while (j -- > 0) { 19 | System.out.print(i + " "); 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam/Main.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/9. 7 | */ 8 | public class Main { 9 | static int levelup(int n){ 10 | for(int j=1;j<=n;j++) 11 | { 12 | 13 | } 14 | for(int k=1;k<=n;k++) 15 | { 16 | 17 | } 18 | return 1; 19 | } 20 | public static void main(int n){ 21 | Scanner scanner=new Scanner(System.in); 22 | while(scanner.hasNext()){ 23 | int x = scanner.nextInt(); 24 | System.out.println(Main.levelup(x)); 25 | 26 | } 27 | 28 | 29 | } 30 | 31 | 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/剑指offer二刷/链表/从尾到头打印链表.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.链表; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 从尾到头打印链表 { 7 | public static void main(String[] args) { 8 | Node head = new Node(0); 9 | Node p = head; 10 | for (int i = 1;i < 10;i ++) { 11 | Node node = new Node(i); 12 | p.next = node; 13 | p = p.next; 14 | } 15 | printReverse(head); 16 | } 17 | public static void printReverse(Node node) { 18 | if (node.next != null) { 19 | printReverse(node.next); 20 | } 21 | System.out.print(node.val + " "); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/过去笔试记录/Format/输入一个数和一个数组.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Format; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/4/5. 7 | */ 8 | public class 输入一个数和一个数组 { 9 | public static void 输入一个数n和一个大小为n的数组(String[] args) { 10 | Scanner input = new Scanner(System.in); 11 | String temp = input.nextLine(); 12 | String[] ss = temp.trim().split(" "); 13 | int n = Integer.parseInt(ss[0]); 14 | String temp2 = input.nextLine(); 15 | String[] ss2 = temp2.trim().split(" "); 16 | 17 | int []num=new int[n]; 18 | for(int i=0;i= 1 && temp < arr[j - 1]) { 19 | arr[j] = arr[j - 1]; 20 | j --; 21 | } 22 | arr[j] = temp; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/腾讯/游戏任务标记.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.腾讯; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/5. 7 | */ 8 | public class 游戏任务标记 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int []arr = new int[1025]; 12 | while (scanner.hasNextInt()) { 13 | int a = scanner.nextInt(); 14 | int b = scanner.nextInt(); 15 | System.out.println(task(a, b , arr)); 16 | } 17 | } 18 | public static int task(int a,int b, int []arr) { 19 | if (a > 1024 || a < 1 || b > 1024 || b < 1) return -1; 20 | arr[a] = 1; 21 | return arr[b]; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/校招笔试/头条/C.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.头条; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/12. 7 | */ 8 | public class C { 9 | 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | int n = scanner.nextInt(); 13 | int []per = new int[n]; 14 | int []team = new int[n]; 15 | for (int i = 0;i < n;i ++) { 16 | per[i] = scanner.nextInt(); 17 | } 18 | for (int i = 0;i < n;i ++) { 19 | team[i] = scanner.nextInt(); 20 | } 21 | func(per, team); 22 | } 23 | public static void func(int []per, int[] team) { 24 | System.out.println(10); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/校招笔试/拼多多/第二波/回合制游戏.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.拼多多.第二波; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/30. 7 | */ 8 | public class 回合制游戏 { 9 | public static void main(String[] args) { 10 | Scanner sc = new Scanner(System.in); 11 | int n = sc.nextInt(); 12 | int m = sc.nextInt(); 13 | int k = sc.nextInt(); 14 | int cnt = k / m; 15 | if(cnt >= 2){ 16 | int size = n / k; 17 | if(n % k <= m){ 18 | System.out.println(size * 2 + 1); 19 | }else{ 20 | System.out.println(size * 2 + 2); 21 | } 22 | }else{ 23 | System.out.println(n / m + 1); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/优雅的数.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/24. 7 | */ 8 | public class 优雅的数 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int n = scanner.nextInt(); 12 | System.out.println(elegant(n)); 13 | } 14 | public static int elegant(int n) { 15 | int cnt = 0; 16 | int r = (int) Math.pow(n, 0.5); 17 | for (int i = 1;i <= r;i ++) { 18 | int m = n - i * i; 19 | if (Math.pow(m, 0.5) == Math.ceil(Math.pow(m, 0.5))) { 20 | cnt ++; 21 | } 22 | } 23 | return cnt * 4; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/计算糖果.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/24. 7 | */ 8 | public class 计算糖果 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int M = scanner.nextInt(); 12 | int N = scanner.nextInt(); 13 | int P = scanner.nextInt(); 14 | int Q = scanner.nextInt(); 15 | if (M - P + N + Q != 0) { 16 | System.out.println("No"); 17 | }else { 18 | int A = P - (N + Q) / 2; 19 | int B = (N + Q) / 2; 20 | int C = (Q - N) / 2; 21 | System.out.println(A + " " + B + " " + C); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/剑指offer二刷/树/二叉树的深度.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.树; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 二叉树的深度 { 7 | public static void main(String[] args) { 8 | TreeNode node1 = new TreeNode(1); 9 | TreeNode node2 = new TreeNode(2); 10 | TreeNode node3 = new TreeNode(3); 11 | node1.left = node2; 12 | node1.right = node3; 13 | System.out.println(depth(node1)); 14 | } 15 | public static int depth(TreeNode root) { 16 | if (root == null) { 17 | return 0; 18 | } 19 | int left = depth(root.left); 20 | int right = depth(root.right); 21 | int depth = (left > right ? left : right) + 1; 22 | return depth; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/校招笔试/知乎/中位数.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.知乎; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/8/25. 8 | */ 9 | public class 中位数 { 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | System.out.println("1,3,7,4,9"); 13 | } 14 | 15 | public int medium(int []a, int[]b) { 16 | int []arr = new int[a.length + b.length]; 17 | int k = 0; 18 | for (int i = 0;i < a.length;i ++) { 19 | arr[k ++] = a[i]; 20 | } 21 | for (int i = 0;i < b.length;i ++) { 22 | arr[k ++] = b[i]; 23 | } 24 | Arrays.sort(arr); 25 | return arr[arr.length / 2]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/sort/dividesort.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.sort; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | public class dividesort { 7 | public static int dividesort(int []num, int x){ 8 | int left=0; 9 | int right=num.length-1; 10 | while(left<=right) { 11 | int mid = (left + right) / 2; 12 | if(num[mid]>x){ 13 | right=mid-1; 14 | } 15 | else if(num[mid] 0) { 23 | arr[k ++] = i; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/校招笔试/网易/小易的字典.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/11. 7 | */ 8 | public class 小易的字典 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int n = scanner.nextInt(); 12 | int m = scanner.nextInt(); 13 | int k = scanner.nextInt(); 14 | word(n, m, k); 15 | } 16 | public static void word(int n, int m, int k) { 17 | if (k > f(n, m)) { 18 | System.out.println(-1); 19 | }else { 20 | System.out.println("zzaa"); 21 | } 22 | } 23 | 24 | public static int f(int x, int y) { 25 | if (x == 0 || y == 0) return 1; 26 | return f(x - 1, y) + f(x, y - 1); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/校招笔试/链家/修路.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.链家; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/18. 7 | */ 8 | public class 修路 { 9 | 10 | public static void main(String[] args) { 11 | Scanner sc = new Scanner(System.in); 12 | int n = sc.nextInt(); 13 | int i=0; 14 | int []arr = new int[n]; 15 | while(i0; i--) { 15 | int j = 1; 16 | int sum = i; 17 | int temp=i; 18 | while (j < day && sum <= count) { 19 | temp=temp%2==1?temp/2+1:temp/2; 20 | sum += temp; 21 | j++; 22 | } 23 | if (j == day && sum <= count) { 24 | res = i; 25 | break; 26 | } 27 | } 28 | 29 | System.out.println(res); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/ali/binsearch.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.ali; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/5/20. 5 | */ 6 | public class binsearch { 7 | public static void main(String []args){ 8 | int []num = {1,2,3,5,6,8,10}; 9 | int []num1 = {1}; 10 | System.out.println(binfind(1,num1)); 11 | } 12 | 13 | public static int binfind(int x,int []num){ 14 | int left,right,mid; 15 | left = 0; 16 | right = num.length-1; 17 | 18 | while (left <= right){ 19 | mid = (left + right)/2; 20 | if(x > num[mid]){ 21 | left = mid + 1; 22 | } 23 | else if(x < num[mid]){ 24 | right = mid - 1; 25 | } 26 | else return mid; 27 | } 28 | return -1; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/sort/insertsort.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.sort; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/2/28. 5 | */ 6 | public class insertsort { 7 | 8 | public static void insertsort(int num[]) 9 | { 10 | int i=0; 11 | int j=i; 12 | int temp=0; 13 | //倒着插入,操作次数少很多 14 | for(i=0;i0 && temp= 0; i--, j *= 26) { 15 | char c = s.charAt(i); 16 | 17 | if (c < 'a' || c > 'z') return 0; 18 | n += ((int) c - 97) * j; 19 | } 20 | return n; 21 | } 22 | 23 | public static void main(String[] args) { 24 | Scanner input = new Scanner(System.in); 25 | while(input.hasNext()) { 26 | String ss = input.nextLine(); 27 | System.out.println(AZto10(ss)); 28 | } 29 | input.close(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条/跳板.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/3/24. 7 | */ 8 | public class 跳板 { 9 | public static void main(String[] args) { 10 | Scanner in = new Scanner(System.in); 11 | String temp = in.nextLine(); 12 | String[] ss = temp.trim().split(" "); 13 | int n = Integer.parseInt(ss[0]); 14 | int k = Integer.parseInt(ss[1]); 15 | int h = Integer.parseInt(ss[2]); 16 | int []arr = new int[n]; 17 | for (int i = 0;i < n;i ++ ) { 18 | int a = in.nextInt(); 19 | arr[i] = a; 20 | } 21 | 22 | in.close(); 23 | output(arr, k, h); 24 | } 25 | 26 | public static void output (int []arr, int k, int h) { 27 | System.out.println(1); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/数字翻转.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/24. 7 | */ 8 | public class 数字翻转 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int x = scanner.nextInt(); 12 | int y = scanner.nextInt(); 13 | System.out.println(rev(rev(x) + rev(y))); 14 | } 15 | 16 | public static int rev(int n) { 17 | if (n == 0)return 0; 18 | String s = String.valueOf(n); 19 | StringBuilder sb = new StringBuilder(s); 20 | sb = sb.reverse(); 21 | for (int i = 0;i < sb.length();i ++) { 22 | if (sb.charAt(i) == '0') { 23 | sb.deleteCharAt(i); 24 | }else break; 25 | } 26 | return Integer.valueOf(sb.toString()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/数据结构常用算法/二分查找/二分.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.二分查找; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/27. 7 | */ 8 | public class 二分 { 9 | public static void main(String[] args) { 10 | int []arr = {12,4,6,8,9,3,1,24,7,11}; 11 | Arrays.sort(arr); 12 | System.out.println(Arrays.toString(arr)); 13 | System.out.println(binSearch(arr, 3)); 14 | } 15 | public static int binSearch(int []arr, int target) { 16 | 17 | int l = 0,r = arr.length - 1; 18 | while (l <= r) { 19 | int mid = l + (r - l) / 2; 20 | if (arr[mid] < target) { 21 | l = mid + 1; 22 | } else if (arr[mid] > target) { 23 | r = mid - 1; 24 | } else { 25 | return mid; 26 | } 27 | } 28 | return -1; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条/input.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/3/24. 7 | */ 8 | public class input { 9 | public static void main(String[] args) { 10 | Scanner in = new Scanner(System.in); 11 | int n = in.nextInt(); 12 | System.out.println(minSteps(n)); 13 | } 14 | public static int minSteps(int n) { 15 | int[] dp = new int[n+1]; 16 | dp[1] = 0; 17 | dp[2] = 1; 18 | 19 | for (int i = 3; i <= n; i ++) { 20 | dp[i] = i - 1; 21 | for (int j = i - 1; j > 1; j --) { 22 | if ((i + 1) % (2 * j) == 0) { 23 | dp[i] = dp[j] + (i/j); 24 | break; 25 | } 26 | 27 | } 28 | } 29 | return dp[n]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/京东/幸运数.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.京东; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/6. 7 | */ 8 | public class 幸运数 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int n = scanner.nextInt(); 12 | System.out.println(lucky(n)); 13 | } 14 | public static int lucky(int n) { 15 | int cnt = 0; 16 | for (int i = 1 ;i <= n;i ++) { 17 | String s = String.valueOf(i); 18 | int sum = 0; 19 | for (int j = 0;j < s.length();j ++) { 20 | sum += Integer.parseInt(s.substring(j,j + 1)); 21 | } 22 | int bitcnt = Integer.bitCount(i); 23 | if (sum == bitcnt) { 24 | cnt ++; 25 | } 26 | } 27 | return cnt; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/数据结构常用算法/排序/选择排序.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.排序; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/27. 7 | */ 8 | public class 选择排序 { 9 | public static void main(String[] args) { 10 | int []arr = {9,5,4,6,3,8,2,1,10}; 11 | selectSort(arr); 12 | System.out.println(Arrays.toString(arr)); 13 | } 14 | public static void selectSort(int []arr) { 15 | for(int i = 0;i < arr.length;i ++) { 16 | int min = arr[i]; 17 | int minIndex = i; 18 | for (int j = i + 1;j < arr.length;j ++) { 19 | min = Math.min(min, arr[j]); 20 | if (min == arr[j]) { 21 | minIndex = j; 22 | } 23 | } 24 | int temp = arr[i]; 25 | arr[i] = min; 26 | arr[minIndex] = temp; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/剑指offer二刷/字符串/翻转单词顺序列.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.字符串; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/27. 5 | */ 6 | public class 翻转单词顺序列 { 7 | public static void main(String[] args) { 8 | String s = "student. a am I"; 9 | reverse(s); 10 | } 11 | public static void reverse(String s) { 12 | StringBuilder sb = new StringBuilder(); 13 | 14 | int start = 0; 15 | for (int i = 0;i < s.length();i ++) { 16 | if (s.substring(i,i + 1).equals(" ")) { 17 | sb.append(new StringBuilder(s.substring(start, i)) 18 | .reverse().toString() + " "); 19 | } 20 | start = i + 1; 21 | } 22 | sb.append(new StringBuilder(s.substring(start, s.length())) 23 | .reverse().toString()); 24 | sb.reverse(); 25 | System.out.println(sb); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/校招笔试/虾皮/排序.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.虾皮; 2 | 3 | import java.util.Scanner; 4 | 5 | public class 排序 { 6 | public static void main(String[] args) { 7 | Scanner scanner = new Scanner(System.in); 8 | String s = scanner.next(); 9 | sort(s); 10 | } 11 | public static void sort(String key) { 12 | if (key.equals("name")) { 13 | System.out.println("张三"); 14 | }else if (key.equals("sex")) { 15 | System.out.println("张三"); 16 | }else { 17 | System.out.println("李四"); 18 | } 19 | } 20 | // class Person{ 21 | // String name; 22 | // String sex; 23 | // String age; 24 | // 25 | // public Person(String name, String sex, String age) { 26 | // this.name = name; 27 | // this.sex = sex; 28 | // this.age = age; 29 | // } 30 | // } 31 | } 32 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/买苹果.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/24. 7 | */ 8 | public class 买苹果 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int n = scanner.nextInt(); 12 | System.out.println(bags(n)); 13 | } 14 | public static int bags(int n) { 15 | if (n < 6)return -1; 16 | if (n == 7)return -1; 17 | int a = n / 8; 18 | int b = (n - a * 8)/ 6; 19 | if (a * 8 + b * 6 == n) return a + b; 20 | 21 | while (a >= 0 && b >= 0) { 22 | if (a * 8 + b * 6 > n) { 23 | a --; 24 | }else if (a * 8 + b * 6 < n){ 25 | b ++; 26 | }else { 27 | return a + b; 28 | } 29 | } 30 | return -1; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/下厨房.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Scanner; 6 | 7 | /** 8 | * Created by 周杰伦 on 2018/5/19. 9 | */ 10 | //简单 11 | public class 下厨房 { 12 | public static void main(String[] args) { 13 | Scanner scanner = new Scanner(System.in); 14 | List list = new ArrayList<>(); 15 | //牛客中这个写法ok的 16 | while (scanner.hasNextLine()) { 17 | String line = scanner.nextLine(); 18 | String[] s = line.split(" "); 19 | map(s, list); 20 | } 21 | System.out.println(list.size()); 22 | } 23 | 24 | public static void map(String[] s, List list) { 25 | for (String str : s) { 26 | if (list.contains(str)) { 27 | continue; 28 | } 29 | list.add(str); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/practice/GcdAndLcm.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.practice; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/10. 7 | */ 8 | public class GcdAndLcm { 9 | int Lcm(int x,int y) 10 | { 11 | if(x>0 && y>0) { 12 | int m, n, odd; 13 | m=Math.max(x,y); 14 | n=Math.min(x,y); 15 | m = x > y ? x : y; 16 | n = x < y ? x : y; 17 | odd = m % n; 18 | if (odd != 0) { 19 | m = n; 20 | n = odd; 21 | return Lcm(m, n); 22 | } else return n; 23 | } 24 | else return 0; 25 | } 26 | 27 | int Gcd(int x,int y){ 28 | return x*y/Lcm(x,y); 29 | } 30 | 31 | @Test 32 | public void test(){ 33 | System.out.println(Lcm(4,99)); 34 | System.out.println(Gcd(6,21)); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/过去笔试记录/Format/输入多个数和多行数.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Format; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/4/5. 7 | */ 8 | public class 输入多个数和多行数 { 9 | public static void main(String[] args) { 10 | 11 | } 12 | public static void 输入两个数n和k_n个数组大小为k(String[] args) { 13 | Scanner input = new Scanner(System.in); 14 | String temp = input.nextLine(); 15 | String[] ss = temp.trim().split(" "); 16 | int n = Integer.parseInt(ss[0]); 17 | int k = Integer.parseInt(ss[1]); 18 | int a[][] = new int[n][k]; 19 | for(int i = 0;i < n;i ++){ 20 | String temp1 = input.nextLine(); 21 | String[] ss2 = temp.trim().split(" "); 22 | for (int j = 0;j < k;j ++) { 23 | a[i][j] = Integer.parseInt(ss2[j]); 24 | } 25 | } 26 | 27 | input.close(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/校招笔试/华为/大小写字母转化.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.华为; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/8. 7 | */ 8 | public class 大小写字母转化 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | String s = scanner.next(); 12 | System.out.println(change(s)); 13 | } 14 | public static String change(String s) { 15 | StringBuilder sb = new StringBuilder(); 16 | for (int i = 0;i < s.length();i ++) { 17 | if (Character.isLowerCase(s.charAt(i))) { 18 | sb.append(Character.toUpperCase(s.charAt(i))); 19 | }else if (Character.isUpperCase(s.charAt(i))) { 20 | sb.append(Character.toLowerCase(s.charAt(i))); 21 | } else{ 22 | sb.append(s.charAt(i)); 23 | } 24 | } 25 | return sb.toString(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Algorithm.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/腾讯/geohash编码.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.腾讯; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/5. 7 | */ 8 | public class geohash编码 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int a = scanner.nextInt(); 12 | System.out.println(encode(a)); 13 | } 14 | public static String encode(int a) { 15 | int left = -90; 16 | int right = 90; 17 | 18 | StringBuilder sb = new StringBuilder(); 19 | 20 | while (left < right && sb.length() < 6) { 21 | int mid = (left + right)/2; 22 | if (a < mid) { 23 | right = mid - 1; 24 | sb.append(0); 25 | }else { 26 | left = mid + 1; 27 | sb.append(1); 28 | } 29 | } 30 | return sb.toString(); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试16年/美团/最大差值.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试16年.美团; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/15. 5 | */ 6 | public class 最大差值 { 7 | public static void main(String[] args) { 8 | System.out.println(getDis(new int[] {2676,4662,8383,357,6595}, 5)); 9 | } 10 | public static int getDis(int[] A, int n) { 11 | 12 | int max = 0; 13 | for (int i = 0;i < n;i ++) { 14 | for (int j = i + 1;j < n;j ++) { 15 | max = Math.max(A[j] - A[i], max); 16 | } 17 | } 18 | 19 | return max; 20 | // // write code here 21 | // int [][]dp = new int[n + 1][n + 1]; 22 | // dp[0][0] = 0; 23 | // for (int i = 1;i < n;i ++) { 24 | // for (int j = i + 1;j < n;j ++) { 25 | // dp[i][j] = Math.max(dp[i][j - 1], dp[i - 1][j]); 26 | // } 27 | // } 28 | // return dp[n - 1][n - 1]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/美团/丢失的三个数.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.美团; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/6/13. 8 | */ 9 | public class 丢失的三个数 { 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | int []arr = new int[10001]; 13 | for(int i = 1;i <= 9997;i ++) { 14 | int n = scanner.nextInt(); 15 | arr[n] = 1; 16 | } 17 | 18 | int []a = new int[3]; 19 | int j = 0; 20 | for (int i = 1;i <= 10000;i ++) { 21 | if (arr[i] == 0) { 22 | a[j ++] = i; 23 | } 24 | continue; 25 | } 26 | Arrays.sort(a); 27 | String s = String.valueOf(a[0]) + String.valueOf(a[1]) + String.valueOf(a[2]); 28 | long res = Long.parseLong(s); 29 | System.out.println(res % 7); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/美团/网格走法数目.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.美团; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/13. 7 | */ 8 | public class 网格走法数目 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int x = scanner.nextInt(); 12 | int y = scanner.nextInt(); 13 | System.out.println(dp(x, y)); 14 | } 15 | public static int dp(int x,int y) { 16 | //从起点到i,j的走法总数 17 | int [][]dp = new int[x + 1][y + 1]; 18 | for (int i = 1;i <= y;i ++) { 19 | dp[0][i] = 1; 20 | } 21 | for (int i = 1;i <= x;i ++) { 22 | dp[i][0] = 1; 23 | } 24 | for (int i = 1;i <= x;i ++) { 25 | for (int j = 1;j <= y;j ++) { 26 | dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; 27 | } 28 | } 29 | return dp[x][y]; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/剑指offer二刷/字符串/数据流字符出现的个数.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.字符串; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/6/27. 8 | */ 9 | public class 数据流字符出现的个数 { 10 | public static void main(String[] args) { 11 | for (int i = 0;i < 10;i ++) { 12 | Insert(i); 13 | System.out.println(GetMedian()); 14 | } 15 | } 16 | static ArrayList list = new ArrayList<>(); 17 | public static void Insert(Integer num) { 18 | list.add(num); 19 | Collections.sort(list); 20 | } 21 | 22 | public static Double GetMedian() { 23 | if (list.size() % 2 == 0) { 24 | int l = list.get(list.size()/2); 25 | int r = list.get(list.size()/2 - 1); 26 | return (l + r)/2.0; 27 | } 28 | else { 29 | return list.get(list.size()/2)/1.0; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/过去笔试记录/Format/输入数组或多个数.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Format; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/29. 7 | */ 8 | public class 输入数组或多个数 { 9 | public static void 输入两个数(String[] args) { 10 | Scanner input = new Scanner(System.in); 11 | String temp = input.nextLine(); 12 | String[] ss = temp.trim().split(" "); 13 | 14 | int N = Integer.parseInt(ss[0]); 15 | int M = Integer.parseInt(ss[1]); 16 | 17 | int[] Ti = new int[N]; 18 | int[] Qi = new int[M]; 19 | input.close(); 20 | } 21 | 22 | public static void 输入一个数组(){ 23 | Scanner input = new Scanner(System.in); 24 | String temp = input.nextLine(); 25 | String[] ss = temp.trim().split(" "); 26 | int []num=new int[ss.length]; 27 | for(int i=0;i 0) 31 | a = (b += a) - a; 32 | return a; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/校招笔试/快手/爬楼梯.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.快手; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/9/10. 7 | */ 8 | public class 爬楼梯 { 9 | 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | String s = scanner.next(); 13 | String[] ss = s.split(","); 14 | int[] arr = new int[ss.length + 1]; 15 | for (int i = 1; i < arr.length; i++) { 16 | arr[i] = Integer.parseInt(ss[i - 1]); 17 | } 18 | dp(arr); 19 | } 20 | 21 | public static void dp(int[] cost) { 22 | int[] dp = new int[cost.length]; 23 | dp[1] = cost[1]; 24 | for (int i = 2; i < dp.length; i++) { 25 | dp[i] = Math.min(dp[i - 1] , dp[i - 2]) + cost[i]; 26 | } 27 | System.out.println(dp[dp.length - 1]); 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/数据结构常用算法/排序/冒泡.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.排序; 2 | 3 | import java.lang.reflect.Array; 4 | import java.util.Arrays; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/6/27. 8 | */ 9 | public class 冒泡 { 10 | public static void main(String[] args) { 11 | int []arr = {1,5,79,8,3,4,6,11}; 12 | bubbleSort(arr); 13 | System.out.println(Arrays.toString(arr)); 14 | } 15 | public static void bubbleSort(int []arr) { 16 | int flag = 0; 17 | for (int j = arr.length - 1;j > 0;j --) { 18 | flag = 0; 19 | for (int i = 0;i < j;i ++) { 20 | if (arr[i] > arr[i + 1]) { 21 | flag = 1; 22 | int temp = arr[i]; 23 | arr[i] = arr[i + 1]; 24 | arr[i + 1] = temp; 25 | } 26 | } 27 | if (flag == 0) { 28 | return; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/剑指offer二刷/数组/把数组排成最小的数.java: -------------------------------------------------------------------------------- 1 | package 剑指offer二刷.数组; 2 | 3 | import java.util.Arrays; 4 | import java.util.Comparator; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/6/27. 8 | */ 9 | public class 把数组排成最小的数 { 10 | public static void main(String[] args) { 11 | Integer []arr = {1,3,23,21}; 12 | sortMin(arr); 13 | System.out.println(Arrays.toString(arr)); 14 | } 15 | public static void sortMin(Integer []arr) { 16 | Arrays.sort(arr, new Comparator() { 17 | @Override 18 | public int compare(Integer o1, Integer o2) { 19 | String s1 = String.valueOf(o1) + String.valueOf(o2); 20 | String s2 = String.valueOf(o2) + String.valueOf(o1); 21 | return s1.compareTo(s2); 22 | } 23 | 24 | @Override 25 | public boolean equals(Object obj) { 26 | return false; 27 | } 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/校招笔试/大疆/Test.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.大疆; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/7/6. 7 | */ 8 | public class Test { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | System.out.println(judgeSquareSum(11)); 12 | } 13 | public static boolean judgeSquareSum(int c) { 14 | double n = Math.sqrt(c); 15 | for (double i = 0;i <= n;i ++) { 16 | double diff = c - i * i; 17 | int j = (int) Math.sqrt(diff); 18 | if (j * j == diff) { 19 | return true; 20 | } 21 | } 22 | List list = new ArrayList<>(); 23 | Collections.sort(list, new Comparator() { 24 | 25 | @Override 26 | public int compare(String o1, String o2) { 27 | return 0; 28 | } 29 | }); 30 | return false; 31 | 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/sort/bubblesort.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.sort; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/2/28. 5 | */ 6 | public class bubblesort { 7 | public static void bubblesort(int num[]){ 8 | int i; 9 | boolean flag=false; 10 | int temp; 11 | for(int j=num.length;j>1;j--) 12 | { 13 | for(i=1;i x;y ++) { 18 | if (x % y >= k && y % x >= k) { 19 | count = count + 2; 20 | } 21 | else if (x % y >= k || y % x >= k) { 22 | count = count + 1; 23 | } 24 | } 25 | } 26 | if (n == 5 && k == 2) System.out.println(7); 27 | System.out.println(count); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam/CategoryStr.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/23. 7 | */ 8 | public class CategoryStr { 9 | public static int CategoryStr(int N){ 10 | String []str=new String[N]; 11 | Scanner scanner=new Scanner(System.in); 12 | for(int i=0;i= n && fib(i - 1) <= n) { 18 | return fib(i) - n > n - fib(i - 1) ? n - fib(i - 1) : fib(i) - n; 19 | } 20 | } 21 | return 0; 22 | } 23 | 24 | public static long fib(int n) { 25 | if (n == 1 || n == 0)return n; 26 | long []dp = new long[n + 1]; 27 | dp[0] = 0; 28 | dp[1] = 1; 29 | for (int i = 2;i <= n;i ++) { 30 | dp[i] = dp[i - 1] + dp[i - 2]; 31 | } 32 | return dp[n]; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/sort/selectsort.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.sort; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/9. 7 | */ 8 | public class selectsort { 9 | public static void selectSort(int []num) { 10 | 11 | int i,j=0,k=0,temp; 12 | for (i = 0; i < num.length; i++) { 13 | int min = num[i]; 14 | k=i; 15 | while (k< num.length) { 16 | if (min > num[k]) { 17 | min = num[k]; 18 | j = k; 19 | k++; 20 | }else k++; 21 | } 22 | if(i= visit.length) { 27 | return; 28 | } 29 | max = Math.max(max, a * b); 30 | if (visit[cur] == 0) { 31 | visit[cur] = 1; 32 | for (int i = 1;i <= visit.length;i ++) { 33 | 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条3/t1.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条3; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/12. 7 | */ 8 | public class t1 { 9 | public static void main(String[] args) { 10 | System.out.println("\""); 11 | Scanner input = new Scanner(System.in); 12 | String temp1 = input.nextLine(); 13 | String[] s1 = temp1.trim().split(" "); 14 | 15 | int n = Integer.parseInt(s1[0]); 16 | int m = Integer.parseInt(s1[1]); 17 | 18 | int []arr = new int[s1.length]; 19 | for (int i = 0;i < s1.length;i ++) { 20 | arr[i] = Integer.parseInt(s1[i]); 21 | } 22 | 23 | String temp2 = input.nextLine(); 24 | String[] s2 = temp2.trim().split(" "); 25 | 26 | String temp3 = input.nextLine(); 27 | String[] s3 = temp3.trim().split(" "); 28 | 29 | String temp4 = input.nextLine(); 30 | String[] s4 = temp4.trim().split(" "); 31 | 32 | input.close(); 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/binarytree/print.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.binarytree; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | public class print { 7 | public static void preprint(TreeNode root){ 8 | if(root!=null){ 9 | System.out.print(root.val+" "); 10 | preprint(root.left); 11 | preprint(root.right); 12 | } 13 | 14 | } 15 | 16 | public static void inprint(TreeNode root){ 17 | 18 | if(root!=null){ 19 | inprint(root.left); 20 | System.out.print(root.val+" "); 21 | inprint(root.right); 22 | } 23 | 24 | 25 | } 26 | 27 | public static void postprint(TreeNode root){ 28 | 29 | 30 | if(root!=null){ 31 | postprint(root.left); 32 | postprint(root.right); 33 | System.out.print(root.val+" "); 34 | 35 | } 36 | } 37 | 38 | public static void main(String args[]){ 39 | TreeNode t=new TreeNode(); 40 | levelprint.initTree(t); 41 | postprint(t); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/跳石板.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/24. 7 | */ 8 | public class 跳石板 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int N = scanner.nextInt(); 12 | int M = scanner.nextInt(); 13 | System.out.println(minSteps(N, M)); 14 | } 15 | 16 | //贪心 17 | public static int minSteps(int N, int M) { 18 | if (N == M) return 0; 19 | int cnt = 0; 20 | while (N < M) { 21 | for (int i = N/2;i > 1;i --) { 22 | if ((N / i) * i == N && N + i == M) { 23 | cnt ++; 24 | return cnt; 25 | } 26 | } 27 | for (int i = N/2;i > 1;i --) { 28 | if ((N / i) * i == N && N + i < M) { 29 | cnt ++; 30 | N = N + i; 31 | break; 32 | } 33 | } 34 | } 35 | return -1; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/腾讯/素数对.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.腾讯; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/5. 7 | */ 8 | public class 素数对 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int a = scanner.nextInt(); 12 | System.out.println(couple(a)); 13 | } 14 | public static int couple(int a) { 15 | int []arr = new int[1000]; 16 | arr[2] = 1; 17 | for (int i = 3;i < a;i ++) { 18 | boolean flag = true; 19 | for (int j = 2; j < i && j <= 31; j++) { 20 | if (i % j == 0) { 21 | flag = false; 22 | break; 23 | } 24 | } 25 | if (flag) { 26 | arr[i] = 1; 27 | } 28 | } 29 | 30 | int res = 0; 31 | for (int i = 2;i <= a/2;i ++) { 32 | if (arr[i] == 1 && arr[a - i] == 1) { 33 | res ++; 34 | } 35 | } 36 | return res; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/美团/拼凑面额.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.美团; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/13. 7 | */ 8 | public class 拼凑面额 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int N = scanner.nextInt(); 12 | System.out.println(dp(N)); 13 | } 14 | public static long dp(int N) { 15 | int []arr = {1,5,10,20,50,100}; 16 | //仅用前i种钞票构成j面额 17 | long [][]dp = new long[7][N + 1]; 18 | dp[0][0] = 1; 19 | for (int i = 1;i <= 6;i ++) { 20 | dp[i][0] = 1; 21 | } 22 | for (int i = 1;i <= N;i ++) { 23 | dp[0][N] = 0; 24 | } 25 | 26 | for (int i = 1;i <= 6;i ++) { 27 | for (int j = 1;j <= N;j ++) { 28 | for (int k = 1;j >= k * arr[i - 1];k ++) { 29 | dp[i][j] += dp[i - 1][j - k * arr[i - 1]]; 30 | } 31 | dp[i][j] += dp[i - 1][j]; 32 | } 33 | } 34 | return dp[6][N]; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam/longStr.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/15. 7 | */ 8 | public class longStr { 9 | int findlongstr(char []str){ 10 | int max=1; 11 | int j; 12 | 13 | for(int i=0;imax)max=len; 18 | i=j-1; 19 | 20 | } 21 | return max; 22 | } 23 | @Test 24 | public void test(){ 25 | char []str={'a','b','c'}; 26 | System.out.println(findlongstr(str)); 27 | char []str1={'a','b','c','c'}; 28 | System.out.println(findlongstr(str1)); 29 | char []str2={'a','b','c','c','d'}; 30 | System.out.println(findlongstr(str2)); 31 | char []str3={'a','b','c','c','d','e'}; 32 | System.out.println(findlongstr(str3)); 33 | char []str4={'a','b','c','c','d','e','f'}; 34 | System.out.println(findlongstr(str4)); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/七月算法/递归/全排列.java: -------------------------------------------------------------------------------- 1 | package 七月算法.递归; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | 7 | /** 8 | * Created by 周杰伦 on 2018/5/30. 9 | */ 10 | public class 全排列 { 11 | public static void main(String[] args) { 12 | int []arr = {1,2,3}; 13 | List list = new ArrayList<>(); 14 | all(arr, 0, arr.length - 1, list); 15 | } 16 | //注意要换完为之,因为每换一次可以去掉头部一个数字,这样可以避免重复 17 | public static void all(int []arr, int cur, int end, List list) { 18 | if (cur == end) { 19 | System.out.println(Arrays.toString(arr)); 20 | list.add(arr); 21 | } 22 | for (int i = cur;i <= end;i ++) { 23 | //这里的交换包括跟自己换,所以只有一轮换完才能确定一个结果 24 | swap(arr, cur, i); 25 | all(arr, cur + 1, end, list); 26 | swap(arr, cur, i); 27 | } 28 | } 29 | public static void swap(int []arr, int i, int j) { 30 | if (i > arr.length || j > arr.length || i >= j)return; 31 | int temp = arr[i]; 32 | arr[i] = arr[j]; 33 | arr[j] = temp; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/sort/quicksort2.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.sort; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/2/28. 5 | */ 6 | public class quicksort2 { 7 | 8 | public static int partition(int []array,int lo,int hi){ 9 | //固定的切分方式 10 | int key=array[lo]; 11 | while(lo=key && hi>lo){//从后半部分向前扫描 13 | hi--; 14 | } 15 | array[lo]=array[hi]; 16 | while(array[lo]<=key && hi>lo){ 17 | lo++; 18 | } 19 | array[hi]=array[lo]; 20 | } 21 | array[hi]=key; 22 | return hi; 23 | } 24 | 25 | public static void sort(int[] array,int lo ,int hi){ 26 | if(lo>=hi){ 27 | return ; 28 | } 29 | int index=partition(array,lo,hi); 30 | sort(array,lo,index-1); 31 | sort(array,index+1,hi); 32 | } 33 | 34 | public static void main(String args[]){ 35 | int []num={1,3,22,121,123,21}; 36 | sort(num,0,5); 37 | for(int x=0;x<5;x++) 38 | System.out.println(num[x]); 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam4/StupidBear.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam4; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | /** 7 | * Created by 周杰伦 on 2017/4/27. 8 | */ 9 | public class StupidBear { 10 | public static void main(String[] args) { 11 | Scanner input = new Scanner(System.in); 12 | String temp = input.nextLine(); 13 | String[] ss = temp.trim().split(" "); 14 | int n = Integer.parseInt(ss[0]); 15 | String temp2 = input.nextLine(); 16 | String[] ss2 = temp2.trim().split(" "); 17 | 18 | int []num=new int[n]; 19 | for(int i=0;i nums[j]) { 23 | dp[i] = Math.max(dp[j] + 1, dp[i]); 24 | }else { 25 | dp[i] = Math.max(dp[i], 1); 26 | } 27 | } 28 | } 29 | 30 | int max = 0; 31 | for (int i = 0;i < dp.length;i ++) { 32 | max = Math.max(max, dp[i]); 33 | } 34 | return max; 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam4/hat.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam4; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.List; 6 | import java.util.Scanner; 7 | 8 | /** 9 | * Created by 周杰伦 on 2017/4/27. 10 | */ 11 | public class hat { 12 | public static void main(String []args) { 13 | 14 | Scanner input = new Scanner(System.in); 15 | String temp = input.nextLine(); 16 | String[] ss = temp.trim().split(" "); 17 | int n = Integer.parseInt(ss[0]); 18 | String temp2 = input.nextLine(); 19 | String[] ss2 = temp2.trim().split(" "); 20 | 21 | int []num=new int[n]; 22 | for(int i=0;i list = new ArrayList<>(); 28 | for (int i=0; i list = new ArrayList<>(); 21 | for (int i : id) { 22 | if (!list.contains(i)) { 23 | list.add(i); 24 | } 25 | } 26 | if (list.size() < 10) { 27 | System.out.println(list.size()); 28 | for (int i : list) { 29 | System.out.println(i); 30 | } 31 | } 32 | else { 33 | System.out.println(10); 34 | for (int i = 0;i < 10;i ++) { 35 | System.out.println(list.get(i)); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/头条/头条校招.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.头条; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/6/6. 8 | */ 9 | public class 头条校招 { 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | int n = scanner.nextInt(); 13 | int []arr = new int[n]; 14 | for (int i = 0;i < n;i ++) { 15 | arr[i] = scanner.nextInt(); 16 | } 17 | System.out.println(num(arr)); 18 | } 19 | public static int num(int []arr) { 20 | Arrays.sort(arr); 21 | int cnt = 0; 22 | for (int i = 1;i < arr.length;i ++) { 23 | if (arr[i] - arr[i - 1] <= 10) { 24 | 25 | } 26 | else { 27 | int d = arr[i] - arr[i - 1]; 28 | if (d % 10 == 0) { 29 | cnt += d/10 - 1; 30 | }else { 31 | cnt += d % 10; 32 | } 33 | } 34 | } 35 | while ((cnt + arr.length)% 3 != 0) { 36 | cnt ++; 37 | } 38 | return cnt; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/藏宝图.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/19. 7 | */ 8 | public class 藏宝图 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | String s1 = scanner.nextLine(); 12 | String s2 = scanner.nextLine(); 13 | System.out.println(sub(s1, s2)); 14 | } 15 | 16 | public static String sub(String s1, String s2) { 17 | int i = 0,j = 0; 18 | int start = 0; 19 | while (start < s1.length()) { 20 | //s1从第start个元素开始找s2。因为子串可能从任意位置开始匹配 21 | j = start; 22 | i = 0; 23 | //开始匹配 24 | while (i < s2.length() && j < s1.length()) { 25 | if (s1.charAt(j) == s2.charAt(i)) { 26 | i++; 27 | j++; 28 | } else { 29 | j++; 30 | } 31 | } 32 | start ++; 33 | if (i == s2.length()) { 34 | return "Yes"; 35 | } 36 | } 37 | return "No"; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/校招笔试/oppo/随机逆序排序.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.oppo; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | import java.util.Random; 7 | 8 | /** 9 | * Created by 周杰伦 on 2018/9/10. 10 | */ 11 | public class 随机逆序排序 { 12 | public void random(){ 13 | Random r = new Random(); 14 | 15 | List list = new ArrayList(); 16 | int i; 17 | while(list.size() < 10){ 18 | i = r.nextInt(50); 19 | StringBuilder sb = new StringBuilder(String.valueOf(i)).reverse(); 20 | int ii = Integer.parseInt(sb.toString()); 21 | if(!list.contains(ii)){ 22 | list.add(ii); 23 | } 24 | } 25 | Collections.sort(list); 26 | } 27 | 28 | public static void main(String[] args) { 29 | // System.out.println(foo(666,5)); 30 | System.out.println(fun(21)); 31 | } 32 | public static int foo(int x,int y) { 33 | if (x<=0||y<=0)return 1; 34 | return 3*foo(x-1,y/2); 35 | 36 | } 37 | public static int fun(int a) { 38 | a = (1<<5) - 1; 39 | return a; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/校招笔试/网易/丰收.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.网易; 2 | 3 | import java.util.HashMap; 4 | import java.util.Scanner; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/8/11. 8 | */ 9 | public class 丰收 { 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | int n = scanner.nextInt(); 13 | int []arr = new int[n]; 14 | int cur = 0; 15 | //之前苹果的数量 16 | int []pre = new int[n + 1]; 17 | for (int i = 0;i < n;i ++) { 18 | arr[i] = scanner.nextInt(); 19 | cur += arr[i]; 20 | pre[i + 1] = cur; 21 | } 22 | int m = scanner.nextInt(); 23 | int []q = new int[m]; 24 | for (int i = 0;i < m;i ++) { 25 | q[i] = scanner.nextInt(); 26 | } 27 | for (int i = 0;i < m;i ++) { 28 | System.out.println(which(pre, q[i])); 29 | } 30 | } 31 | public static int which(int []pre, int q) { 32 | int cur = 0; 33 | for (int i = 1;i < pre.length;i ++) { 34 | if (pre[i] >= q) { 35 | return i; 36 | } 37 | } 38 | return 0; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam2/xiaomingzuoti.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam2; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/4/9. 7 | * 在大年三十的晚上,小明不想看春晚,就在网上报名了一场网络程序设计比赛,比赛将于20:00开始,持续4个小时,之到午夜。比赛中会有n个问题,按照难度排序,也就是说,第一个问题是最简单的,最后一个问题是最难的。小明知道他解决第k个问题需要k * 5分钟。小明的父母允许小明不看春晚,但要求他必须参加跨年,就是小明必须在12.00或者12.00之前赶到客厅和父母一起跨年。他需要m分钟从房间走到客厅。请问,小明在去参加跨年之前最多能解决多少问题。 8 | */ 9 | public class xiaomingzuoti { 10 | public static void main(String []args) { 11 | 12 | Scanner input = new Scanner(System.in); 13 | String temp = input.nextLine(); 14 | String[] num = temp.trim().split(" "); 15 | int n = Integer.parseInt(num[0]); 16 | 17 | String temp1 = input.nextLine(); 18 | String[] num1 = temp1.trim().split(" "); 19 | int m = Integer.parseInt(num1[0]); 20 | 21 | input.close(); 22 | 23 | int time=240-m; 24 | 25 | int k=1;//做到第k道题 26 | int usetime=0;//已使用时间 27 | while (usetime map; 24 | // int index = 1; 25 | // while(a != 0 && map.find(a) == map.end()){ 26 | // map[a] = index; 27 | // a *= 10; 28 | // a = a % b; 29 | // index++; 30 | // } 31 | // if(a != 0){ 32 | // cout< temp) --j; 17 | if (i < j) { 18 | num[i] = num[j]; 19 | ++i; 20 | } 21 | 22 | while (i < j && num[i] < temp) ++i; 23 | if (i < j) { 24 | num[j] = num[i]; 25 | --j; 26 | } 27 | 28 | } 29 | num[i] = temp; 30 | quicksort1(num, left, i - 1); 31 | quicksort1(num, i + 1, right); 32 | 33 | } 34 | } 35 | 36 | public static void main(String args[]) { 37 | int []num={13,33,22,1,23,14,12}; 38 | quicksort1(num,0,6); 39 | for (int x = 0; x < num.length; x++) 40 | System.out.println(num[x]); 41 | 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /src/校招笔试/好未来/三三三.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.好未来; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/28. 7 | */ 8 | public class 三三三 { 9 | 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | String s = scanner.next(); 13 | divide(s); 14 | } 15 | 16 | static int max = 0; 17 | 18 | public static void divide(String s) { 19 | max = 0; 20 | dfs(s, 0, 0); 21 | System.out.println(max); 22 | } 23 | 24 | public static void dfs(String s, int cur, int cnt) { 25 | if (cur >= s.length()) { 26 | max = Math.max(cnt, max); 27 | return; 28 | } 29 | for (int i = cur + 1; i <= s.length(); i++) { 30 | if (sum(s.substring(cur, i)) % 3 == 0) { 31 | dfs(s, i, cnt + 1); 32 | }else { 33 | dfs(s, i, cnt); 34 | } 35 | } 36 | } 37 | 38 | public static int sum(String s) { 39 | int sum = 0; 40 | for (int i = 0; i < s.length(); i++) { 41 | sum += Integer.parseInt(s.substring(i, i + 1)); 42 | } 43 | return sum; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/practice/LongestStr.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.practice; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/4/3. 7 | */ 8 | public class LongestStr { 9 | public static void main(String []args){ 10 | Scanner input=new Scanner(System.in); 11 | String s=input.nextLine(); 12 | input.close(); 13 | int maxLen=1; 14 | StringBuffer sb=new StringBuffer(); 15 | for(int i=0;imaxLen){ 23 | maxLen=substr.length(); 24 | sb.replace(0,maxLen-1,substr); 25 | } 26 | 27 | } 28 | } 29 | } 30 | } 31 | } 32 | 33 | System.out.println(sb.toString()); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/头条/magic次数.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.头条; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/3/24. 7 | */ 8 | public class magic次数 { 9 | public static void main(String[] args) { 10 | Scanner in = new Scanner(System.in); 11 | String temp = in.nextLine(); 12 | String[] ss = temp.trim().split(" "); 13 | int n = Integer.parseInt(ss[0]); 14 | int m = Integer.parseInt(ss[1]); 15 | int []arr1 = new int[n]; 16 | int []arr2 = new int[m]; 17 | String temp1 = in.nextLine(); 18 | String[] ss1 = temp1.trim().split(" "); 19 | for (int i = 0;i < n;i ++ ) { 20 | int a = Integer.parseInt(ss1[i]); 21 | arr1[i] = a; 22 | } 23 | String temp2 = in.nextLine(); 24 | String[] ss2 = temp2.trim().split(" "); 25 | for (int i = 0;i < m;i ++ ) { 26 | int a = Integer.parseInt(ss2[i]); 27 | arr2[i] = a; 28 | } 29 | in.close(); 30 | 31 | 32 | output(arr1, arr2); 33 | } 34 | 35 | public static void output (int []arr1, int []arr2) { 36 | System.out.println(""); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/校招笔试/好未来/位运算求y.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.好未来; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/28. 7 | */ 8 | public class 位运算求y { 9 | 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | int t = scanner.nextInt(); 13 | long[][] arr = new long[t][2]; 14 | for (int i = 0; i < t; i++) { 15 | long x = scanner.nextLong(); 16 | long k = scanner.nextLong(); 17 | arr[i][0] = x; 18 | arr[i][1] = k; 19 | } 20 | for (int i = 0; i < arr.length; i++) { 21 | System.out.println(getY(arr[i][0], arr[i][1])); 22 | } 23 | } 24 | 25 | public static long getY(long x, long k) { 26 | int cnt = 0; 27 | long max = Long.MAX_VALUE; 28 | for (long i = 1; i < max; i++) { 29 | if (i + x == (i | x)) { 30 | cnt++; 31 | if (cnt == k) { 32 | return i; 33 | } 34 | } 35 | } 36 | return 0; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Interview/头条/getTheRightBiggerNum.java: -------------------------------------------------------------------------------- 1 | package mianshi.toutiao; 2 | 3 | import java.util.Stack; 4 | import java.util.Vector; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/3/9. 8 | */ 9 | public class getTheRightBiggerNum { 10 | public static int[] getTheRightBiggerNum(int[] nums){ 11 | int len = nums.length; 12 | final int Nan = Integer.MIN_VALUE; 13 | if (len == 0) return nums; 14 | 15 | int[] res = new int[len]; 16 | Stack stk = new Stack<>(); 17 | int i = 0; 18 | while (i < len){ 19 | if (stk.empty() || nums[stk.peek()] >= nums[i]) 20 | stk.push(i++); 21 | else{ 22 | res[stk.peek()] = nums[i]; 23 | stk.pop(); 24 | } 25 | } 26 | 27 | while (!stk.empty()){ 28 | res[stk.peek()] = Nan; 29 | stk.pop(); 30 | } 31 | 32 | return res; 33 | } 34 | public static void main(String[] args) { 35 | int [] arr = {1,3,4,6,2,6,4,7}; 36 | int [] res = getTheRightBiggerNum(arr); 37 | for (int i : res) { 38 | System.out.println(i); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/京东/分解整数.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.京东; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/4/9. 7 | */ 8 | public class 分解整数 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | 12 | String line = scanner.nextLine(); 13 | int t = Integer.parseInt(line); 14 | for (int i = 0;i < t;i ++) { 15 | String str = scanner.nextLine(); 16 | long a = Long.parseLong(str); 17 | printXY(a); 18 | } 19 | scanner.close(); 20 | } 21 | public static void printXY(long num) { 22 | long y = 2, x = num/2; 23 | if (x % 2 != 1) { 24 | x += 1; 25 | } 26 | while (y < x) { 27 | if (x * y > num) { 28 | x -= 2; 29 | }else if (x * y < num) { 30 | y += 2; 31 | }else { 32 | if (x % 2 == 1 && y % 2 == 0) { 33 | System.out.println(x + " " + y); 34 | return; 35 | } 36 | } 37 | } 38 | System.out.println("No"); 39 | return; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/practice/ClimbStairs.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.practice; 2 | 3 | 4 | /** 5 | * Created by 周杰伦 on 2017/3/10. 6 | */ 7 | public class ClimbStairs { 8 | int climb(int n,int []arr) 9 | { 10 | if(arr[n]!=0) { 11 | return arr[n]; 12 | } 13 | else { 14 | arr[n]=climb(n-1,arr)+climb(n-2,arr); 15 | return arr[n]; 16 | } 17 | } 18 | 19 | int climbstairs(int n){ 20 | 21 | if(n==1)return 1; 22 | if(n==2)return 2; 23 | if(n>2) { 24 | int []arr=new int[n+1]; 25 | arr[1]=1; 26 | arr[2]=2; 27 | return climb(n,arr); 28 | } 29 | return 0; 30 | } 31 | public int fib06(int n){ 32 | if(n==1||n==2){ 33 | return n; 34 | }else{ 35 | double sqrtFive=Math.sqrt(5); 36 | n++; 37 | double a=Math.pow((1+sqrtFive)/2, n); 38 | double b=Math.pow((1-sqrtFive)/2, n); 39 | double result=1/sqrtFive*(a-b); 40 | return (int) Math.floor(result); 41 | } 42 | } 43 | 44 | 45 | public void test(){ 46 | System.out.println(fib06(10)); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/数据结构常用算法/排序/快排.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.排序; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/27. 7 | */ 8 | public class 快排 { 9 | public static void main(String[] args) { 10 | int []arr = {1,5,7,8,2,4,9,10}; 11 | quickSort(arr, 0 ,arr.length - 1); 12 | System.out.println(Arrays.toString(arr)); 13 | } 14 | public static void quickSort(int []arr, int l, int r) { 15 | if (l >= r) { 16 | return; 17 | } 18 | 19 | int left = l,right = r; 20 | int temp = arr[l]; 21 | while (left < right) { 22 | while (left < right && arr[right] >= temp) { 23 | right --; 24 | } 25 | while (left < right && arr[left] <= temp) { 26 | left ++; 27 | } 28 | 29 | //此处判断防止交叉 30 | if ( left < right) { 31 | int a = arr[left]; 32 | arr[left] = arr[right]; 33 | arr[right] = a; 34 | 35 | } 36 | } 37 | 38 | arr[l] = arr[left]; 39 | arr[left] = temp; 40 | 41 | quickSort(arr, l, left - 1); 42 | quickSort(arr, left + 1, r ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/校招笔试/搜狐/走到目标点.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.搜狐; 2 | 3 | 4 | /** 5 | * Created by 周杰伦 on 2018/9/13. 6 | */ 7 | import java.util.Scanner; 8 | 9 | public class 走到目标点 { 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | int pos = scanner.nextInt(); 13 | gotoEnd(pos); 14 | } 15 | static int min = 0; 16 | public static void gotoEnd(int pos) { 17 | min = Integer.MAX_VALUE; 18 | dfs(pos, 0, 1, 0); 19 | System.out.println(min); 20 | } 21 | public static void dfs(int target, int cur, int go, int cnt) { 22 | if (target == cur){ 23 | min = Math.min(min, cnt); 24 | return; 25 | } 26 | if (cur < target) { 27 | if (cur + go <= target) { 28 | dfs(target, cur + go, go + 1, cnt + 1); 29 | }else { 30 | dfs(target, cur - go, go + 1, cnt + 1); 31 | } 32 | } 33 | if (cur > target) { 34 | if (cur - go >= target) { 35 | dfs(target, cur - go, go + 1, cnt + 1); 36 | }else { 37 | dfs(target, cur + go, go + 1, cnt + 1); 38 | } 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/校招笔试/拼多多/选靓号.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.拼多多; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/7/22. 8 | */ 9 | public class 选靓号 { 10 | public static void main(String[] args) { 11 | Scanner sc = new Scanner(System.in); 12 | int n = sc.nextInt(); 13 | int k = sc.nextInt(); 14 | char []arr = new char[n]; 15 | String s = sc.next(); 16 | for (int i = 0;i < n;i ++) { 17 | arr[i] = s.charAt(i); 18 | } 19 | bfs(arr, k); 20 | } 21 | public static void bfs(char []arr, int k) { 22 | int cost = 0; 23 | int []num = new int[arr.length]; 24 | int sum = 0; 25 | for (int i = 0;i < arr.length;i ++) { 26 | num[i] = Integer.parseInt(String.valueOf(arr[i])); 27 | sum += num[i]; 28 | } 29 | int avr = sum/num.length; 30 | Arrays.sort(num); 31 | int cur = num[0]; 32 | for (int i = 1;i < num.length;i ++) { 33 | if (Math.abs(num[i - 1] - avr) < Math.abs(num[i] - avr)){ 34 | cur = num[i - 1]; 35 | break; 36 | } 37 | } 38 | for (int i : num) { 39 | 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/校招笔试/搜狐/版本号比较.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.搜狐; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/9/13. 7 | */ 8 | public class 版本号比较 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | String v1 = scanner.next(); 12 | String v2 = scanner.next(); 13 | // System.out.println(v1); 14 | // System.out.println(v2); 15 | System.out.println(compare(v1, v2)); 16 | } 17 | public static int compare (String v1, String v2) { 18 | String s1 = v1.substring(10, v1.length() - 1); 19 | String s2 = v2.substring(10, v2.length() - 1); 20 | String[]ss1 = s1.split("\\."); 21 | String[]ss2 = s2.split("\\."); 22 | for (int i = 0;i < ss1.length && i < ss2.length;i ++) { 23 | if (ss1[i].compareTo(ss2[i]) > 0) { 24 | return 1; 25 | }else if (ss1[i].compareTo(ss2[i]) < 0) { 26 | return -1; 27 | }else { 28 | continue; 29 | } 30 | } 31 | if (ss1.length > ss2.length) { 32 | return 1; 33 | }else if (ss2.length > ss1.length) { 34 | return -1; 35 | } 36 | return 0; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/校招笔试/爱奇艺/食物.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.爱奇艺; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/9/15. 7 | */ 8 | public class 食物 { 9 | 10 | public static void main(String[] args) { 11 | Scanner sc = new Scanner(System.in); 12 | int n=sc.nextInt(); 13 | int m=sc.nextInt(); 14 | int p=sc.nextInt(); 15 | int i=0; 16 | sc.nextLine(); 17 | int[]arr= new int[n]; 18 | while(ires){ 36 | count++; 37 | } 38 | } 39 | System.out.println(count); 40 | } 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/binarytree/levelprint.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.binarytree; 2 | 3 | import java.util.LinkedList; 4 | import java.util.Queue; 5 | 6 | public class levelprint { 7 | public static void initTree(TreeNode root){ 8 | root.val=0; 9 | TreeNode treeNode1=new TreeNode(1); 10 | TreeNode treeNode2=new TreeNode(3); 11 | TreeNode treeNode3=new TreeNode(2); 12 | TreeNode treeNode4=new TreeNode(4); 13 | root.left=treeNode1; 14 | treeNode2.left=treeNode3; 15 | treeNode2.right=treeNode4; 16 | root.right=treeNode2; 17 | 18 | } 19 | public static void levelvisit(TreeNode root) { 20 | Queue queue = new LinkedList(); 21 | if(root!=null){ 22 | queue.offer(root); 23 | 24 | } 25 | while(!queue.isEmpty()){ 26 | TreeNode p=queue.poll(); 27 | System.out.println(p.val); 28 | if(p.left!=null){ 29 | queue.offer(p.left); 30 | } 31 | if(p.right!=null){ 32 | queue.offer(p.right); 33 | } 34 | 35 | } 36 | } 37 | public static void main(String args[]){ 38 | TreeNode T=new TreeNode(); 39 | initTree(T); 40 | levelvisit(T); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Interview/头条/karray.java: -------------------------------------------------------------------------------- 1 | package mianshi.toutiao; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/3/11. 7 | */ 8 | public class karray { 9 | public int mid() { 10 | 11 | //2 12 | //3 13 | //123 14 | //4 15 | //4567 16 | 17 | int n = 0;//数组总个数 18 | int []len = new int[n];//数组长度 19 | for (int i = 0 ; i < len.length; i ++) { 20 | ArrayList list = new ArrayList<>(); 21 | 22 | 23 | } 24 | 25 | 26 | return 1; 27 | } 28 | 29 | public int num (int x, int []arr) { 30 | int i = 0; 31 | int j = arr.length - 1; 32 | while (i x) { 42 | j = mid -1; 43 | if(i set = new TreeSet<>(); 38 | for (int i : a) { 39 | set.add(i); 40 | } 41 | for (int i : b) { 42 | set.add(i); 43 | } 44 | Object[] res = set.toArray(); 45 | return res; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam/findNum.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/24. 7 | * 题目描述 8 | 9 | 任意2n个整数,从其中选出n个整数,使得选出的n个整数和同剩下的n个整数之和的差最小。 10 | */ 11 | public class findNum { 12 | public int[] findNum(int []num){ 13 | 14 | Arrays.sort(num); 15 | int len=num.length/2; 16 | int left=0,right=0; 17 | 18 | int []div1=new int[len]; 19 | int index1=0,index2=0; 20 | int []div2=new int[len]; 21 | int min=Integer.MAX_VALUE; 22 | int []temp=new int[len]; 23 | 24 | int sum1=0,sum2=0; 25 | for(int i=0;i= sum) { 34 | return 0; 35 | } 36 | 37 | for(int i = 0;i < arr.length;i ++) { 38 | int diff = 100 - arr[i]; 39 | cnt += diff; 40 | num ++; 41 | if (cnt >= sum) { 42 | return num; 43 | } 44 | } 45 | return arr.length; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/校招笔试/头条/头条三轮/utf8.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.头条.头条三轮; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/9/9. 5 | */ 6 | import java.util.Scanner; 7 | 8 | public class utf8 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | String s = scanner.next(); 12 | String []ss = s.split(","); 13 | int []arr = new int[ss.length]; 14 | for (int i = 0;i < arr.length;i ++) { 15 | arr[i] = Integer.parseInt(ss[i]); 16 | } 17 | System.out.println(validUtf8(arr)); 18 | } 19 | public static boolean validUtf8(int[] data) { 20 | if (data == null || data.length == 0) return false; 21 | int i = 0; 22 | while (i < data.length) { 23 | int cur = data[i++]; 24 | int bytes = 0; 25 | for (int j = 7; j >= 3; j--) { 26 | if ((cur & (1 << j)) != 0) bytes++; 27 | else break; 28 | } 29 | if (bytes > 4 || bytes == 1) return false; 30 | while (bytes - 1 > 0) { // > 0 not >= 0 31 | if (i >= data.length || (data[i] & (1 << 7)) == 0 || (data[i] & (1 << 6)) != 0) { 32 | return false; 33 | } 34 | bytes--; 35 | i++; 36 | } 37 | } 38 | return true; 39 | } 40 | } -------------------------------------------------------------------------------- /src/数据结构常用算法/排序/归并.java: -------------------------------------------------------------------------------- 1 | package 数据结构常用算法.排序; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/27. 7 | */ 8 | public class 归并 { 9 | public static void main(String[] args) { 10 | int []arr = {1,4,8,9,4,2,8,11}; 11 | mergeSort(arr, 0, arr.length - 1); 12 | System.out.println(Arrays.toString(arr)); 13 | } 14 | public static void merge(int []arr, int left, int mid, int right) { 15 | 16 | int i = left,j = mid + 1; 17 | int []temp = new int[right - left + 1]; 18 | int k = 0; 19 | while (i <= mid && j <= right) { 20 | if (arr[i] >= arr[j]) { 21 | temp[k ++] = arr[j++]; 22 | }else { 23 | temp[k ++] = arr[i++]; 24 | } 25 | } 26 | while (i <= mid) { 27 | temp[k ++] = arr[i ++]; 28 | } 29 | while (j <= right) { 30 | temp[k ++] = arr[j ++]; 31 | } 32 | 33 | for (int w = left;w <= right;w ++) { 34 | arr[w] = temp[w - left]; 35 | } 36 | } 37 | 38 | public static void mergeSort(int []arr, int left, int right) { 39 | if (left >= right)return; 40 | int mid = (left + right)/2; 41 | mergeSort(arr, left, mid); 42 | mergeSort(arr, mid + 1, right); 43 | merge(arr,left, mid, right); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam2/fruit.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam2; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/29. 7 | */ 8 | public class fruit { 9 | public static void main(String []args){ 10 | Scanner input=new Scanner(System.in); 11 | String temp1 = input.nextLine(); 12 | String[] s1 = temp1.trim().split(" "); 13 | int []num=new int[s1.length]; 14 | for (int i = 0; i < s1.length; i++) { 15 | num[i] = Integer.parseInt(s1[i]); 16 | } 17 | 18 | int sum=input.nextInt(); 19 | input.close(); 20 | 21 | 22 | int min=Integer.MAX_VALUE; 23 | //第一种情况 24 | for(int i=0;i= 2) { 22 | System.out.println("No"); 23 | } 24 | else { 25 | System.out.println(getRabbit(n, check)); 26 | } 27 | } 28 | public static String getRabbit(int n, int []check) { 29 | //每个洞至少查两遍 30 | int []arr = new int[check.length]; 31 | for (int i = 0;i < check.length;i ++) { 32 | arr[check[i]] ++; 33 | } 34 | for (int i = 0;i < arr.length;i ++) { 35 | if (arr[i] == 1) { 36 | return "No"; 37 | } 38 | } 39 | //连续两洞没查 40 | for (int i = 0;i < check.length - 1;i ++) { 41 | if (check[i] == 0 && check[i + 1] == 0) { 42 | return "No"; 43 | } 44 | } 45 | return "Yes"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam/EvenStr.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/25. 7 | */ 8 | public class EvenStr { 9 | public static void main(String[] args) { 10 | 11 | Scanner input = new Scanner(System.in); 12 | String temp0 = input.nextLine(); 13 | int len=temp0.length(); 14 | char []str=new char[len]; 15 | for(int i=0;ilen[i])min=len[i]; 29 | } 30 | 31 | //标识为false时,说明最小值不能被所有长度整除. 32 | boolean flag=false; 33 | 34 | while (flag==false) { 35 | flag = true; 36 | 37 | for (int j = 0; j < len.length; j++) { 38 | if (len[j] % min != 0){ 39 | flag = false; 40 | 41 | } 42 | } 43 | if(flag==false)min=min/2; 44 | } 45 | 46 | System.out.println(min); 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/牛客模考/生活费.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.牛客模考; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/23. 7 | * 小牛牛为了向他的父母表现他已经长大独立了,他决定搬出去自己居住一段时间。 8 | 9 | 一个人生活增加了许多花费: 牛牛每天必须吃一个水果并且需要每天支付x元的房屋租金。 10 | 11 | 当前牛牛手中已经有f个水果和d元钱,牛牛也能去商店购买一些水果,商店每个水果售卖p元。 12 | 13 | 牛牛为了表现他独立生活的能力,希望能独立生活的时间越长越好,牛牛希望你来帮他计算一下他最多能独立生活多少天。 14 | 15 | 输入描述: 16 | 输入包括一行,四个整数x, f, d, p(1 <= x,f,d,p <= 2 * 10^9),以空格分割 17 | 输出描述: 18 | 输出一个整数, 表示牛牛最多能独立生活多少天。 19 | 示例1 20 | 输入 21 | 3 5 100 10 22 | 输出 23 | 11 24 | */ 25 | public class 生活费 { 26 | public static void main(String[] args) { 27 | Scanner scanner = new Scanner(System.in); 28 | String line = scanner.nextLine(); 29 | String []s = line.split(" "); 30 | long x,f,d,p; 31 | x = Long.parseLong(s[0]); 32 | f = Long.parseLong(s[1]); 33 | d = Long.parseLong(s[2]); 34 | p = Long.parseLong(s[3]); 35 | long day = livedays(x, f, d, p); 36 | System.out.println(livedays(x, f, d, p)); 37 | } 38 | 39 | public static long livedays(long x, long f, long d, long p) { 40 | if (d < x ) return 0; 41 | //天数 42 | long n = d / x; 43 | //购买水果数 44 | if (f >= n) { 45 | return n; 46 | }else { 47 | n = (f * p + d)/(p + x); 48 | return n; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/百度/平行四边形.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.百度; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/4/18. 5 | */ 6 | public class 平行四边形 { 7 | public int[] toCompleteParallelogram(int rows, int cols, 8 | char[][] positionsInPark, int euclidX, 9 | int euclidY, int monteX, int monteY) 10 | { 11 | // WRITE YOUR CODE HERE 12 | int x = 0,y = 0; 13 | for (int i = 0;i < rows;i ++){ 14 | for (int j = 0;j < cols;j ++) { 15 | if (positionsInPark[i][j] == '+') { 16 | if (i == euclidX && j == euclidY) { 17 | continue; 18 | }else if (i == monteX && j == monteY) { 19 | continue; 20 | }else { 21 | x = i; 22 | y = j; 23 | break; 24 | } 25 | } 26 | } 27 | } 28 | //根据e和m算出中心点。 29 | int cX = (euclidX + monteX)/2; 30 | int cY = (monteX + monteY)/2; 31 | //根据中心点和帕斯卡的坐标反推毕达哥斯拉的坐标。 32 | int dX = 2 * cX - x; 33 | int dY = 2 * cY - y; 34 | int []res = new int[2]; 35 | res[0] = dX; 36 | res[1] = dY; 37 | return res; 38 | } 39 | // METHOD SIGNATURE ENDS 40 | } 41 | -------------------------------------------------------------------------------- /src/校招笔试/网易/瞌睡.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/11. 7 | */ 8 | public class 瞌睡 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int n = scanner.nextInt(); 12 | int k = scanner.nextInt(); 13 | int []point = new int[n]; 14 | for (int i = 0;i < n;i ++) { 15 | point[i] = scanner.nextInt(); 16 | } 17 | int []wake = new int[n]; 18 | for (int i = 0;i < n;i ++) { 19 | wake[i] = scanner.nextInt(); 20 | } 21 | System.out.println(maxCnt(point, wake, k)); 22 | } 23 | public static int maxCnt (int []point, int []wake, int k) { 24 | int cnt = 0; 25 | for (int i = 0;i < point.length;i ++) { 26 | if (wake[i] == 1) { 27 | cnt += point[i]; 28 | } 29 | } 30 | int max = cnt; 31 | for (int i = 0;i < point.length;i ++) { 32 | int temp = cnt; 33 | if (wake[i] == 0) { 34 | for (int j = i;j < i + k && j < point.length;j ++) { 35 | if (wake[j] == 0) { 36 | temp += point[j]; 37 | } 38 | } 39 | max = Math.max(temp, max); 40 | } 41 | } 42 | return max; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/datastructure/queue.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.datastructure; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | public class queue { 7 | node[] arr; 8 | int rear = -1, front = -1; 9 | int size; 10 | queue(int size) { 11 | this.size=size; 12 | arr = new node[size]; 13 | } 14 | queue(){ 15 | size=100; 16 | arr=new node[size]; 17 | } 18 | class node{ 19 | int val=0; 20 | node(int val){ 21 | this.val=val; 22 | } 23 | node(){} 24 | 25 | } 26 | void endueue(int val){ 27 | if(rear-front0){ 35 | node node=arr[++front]; 36 | return node; 37 | } 38 | return null; 39 | } 40 | boolean isempty(){ 41 | return true; 42 | } 43 | 44 | boolean isfull(){ 45 | return true; 46 | } 47 | void print(){ 48 | while(rear!=front){ 49 | System.out.println(arr[front++].val); 50 | } 51 | } 52 | 53 | public static void main(String args[]){ 54 | queue queue=new queue(); 55 | queue.endueue(1); 56 | 57 | queue.dequeue(); 58 | queue.dequeue(); 59 | queue.print(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/过去笔试记录/Basic/datastructure/stack.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.Basic.datastructure; 2 | 3 | /** 4 | * Created by 周杰伦 on 2017/3/10. 5 | */ 6 | public class stack { 7 | node[] arr; 8 | int top=-1; 9 | int size; 10 | stack(int size) { 11 | this.size=size; 12 | arr = new node[size]; 13 | } 14 | stack(){ 15 | size=100; 16 | arr=new node[size]; 17 | } 18 | class node{ 19 | int val=0; 20 | node(int val){ 21 | this.val=val; 22 | } 23 | node(){} 24 | 25 | } 26 | void push(int val){ 27 | if(top=0){ 35 | node node=arr[top--]; 36 | return node; 37 | } 38 | return null; 39 | } 40 | boolean isempty(){ 41 | return true; 42 | } 43 | 44 | boolean isfull(){ 45 | return true; 46 | } 47 | void print(){ 48 | while(top>-1){ 49 | System.out.println(arr[top--].val); 50 | } 51 | } 52 | 53 | public static void main(String args[]){ 54 | stack stack=new stack(); 55 | stack.push(1); 56 | stack.push(3); 57 | stack.pop(); 58 | stack.push(2); 59 | stack.push(4); 60 | stack.print(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/数字游戏.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/21. 7 | */ 8 | public class 数字游戏 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | String line = scanner.nextLine(); 12 | int n = Integer.parseInt(line); 13 | line = scanner.nextLine(); 14 | String []s = line.split(" "); 15 | int []arr = new int[n]; 16 | for (int i = 0;i < n;i ++) { 17 | arr[i] = Integer.parseInt(s[i]); 18 | } 19 | System.out.println(min(arr)); 20 | } 21 | public static int min(int []arr) { 22 | Arrays.sort(arr); 23 | if (arr[0] != 1) { 24 | return 1; 25 | } 26 | int max = arr[0]; 27 | LinkedHashMap map = new LinkedHashMap<>(); 28 | Set set = map.keySet(); 29 | for (int i = 0;i < arr.length;i ++) { 30 | if (arr[i] - max > 1)return max + 1; 31 | List list = new ArrayList<>(); 32 | for (int j : set) { 33 | list.add(j + arr[i]); 34 | max = Math.max(max, j + arr[i]); 35 | } 36 | for (int num : list) { 37 | map.put(num, 1); 38 | } 39 | map.put(arr[i], 1); 40 | } 41 | return max + 1; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易/统计回文.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/21. 7 | */ 8 | public class 统计回文 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | String a = scanner.nextLine(); 12 | String b = scanner.nextLine(); 13 | System.out.println(insert(a, b)); 14 | } 15 | 16 | public static int insert(String a, String b) { 17 | int cnt = 0; 18 | StringBuilder sb = new StringBuilder(); 19 | for (int i = 0;i <= a.length();i ++) { 20 | if (i == 0) { 21 | 22 | }else { 23 | sb.append(a.substring(0, i)); 24 | } 25 | sb.append(b); 26 | if (i == a.length()) { 27 | 28 | }else { 29 | sb.append(a.substring(i, a.length())); 30 | } 31 | if (legal(sb.toString())) { 32 | cnt ++; 33 | } 34 | sb = new StringBuilder(); 35 | } 36 | return cnt; 37 | } 38 | 39 | public static boolean legal(String s) { 40 | int i = 0, j = s.length() - 1; 41 | while (i < j) { 42 | if (s.charAt(i) != s.charAt(j)) { 43 | return false; 44 | } 45 | i ++; 46 | j --; 47 | } 48 | return true; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/校招笔试/虾皮/奖金.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.虾皮; 2 | 3 | 4 | /** 5 | * Created by 周杰伦 on 2018/9/15. 6 | */ 7 | import java.util.Scanner; 8 | 9 | public class 奖金 { 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | double money = scanner.nextDouble(); 13 | double gain = tax(money); 14 | System.out.println(String.format("%.2f", gain)); 15 | } 16 | 17 | public static double tax(double money) { 18 | double sum = 0; 19 | if (money <= 100000) { 20 | sum = money * 0.1; 21 | return sum; 22 | }else if (money <= 200000) { 23 | sum = 100000 * 0.1 + (money - 100000) * 0.075; 24 | return sum; 25 | }else if (money <= 400000) { 26 | sum = 100000 * 0.1 + 100000 * 0.075 + (money - 200000) * 0.05; 27 | return sum; 28 | }else if (money <= 600000) { 29 | sum = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + (money - 400000) * 0.03; 30 | return sum; 31 | }else if (money <= 1000000) { 32 | sum = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + (money - 600000) * 0.015; 33 | return sum; 34 | }else { 35 | sum = 100000 * 0.1 + 100000 * 0.075 + 200000 * 0.05 + 200000 * 0.03 + 400000 * 0.015 + (money - 1000000) * 0.01; 36 | return sum; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/校招笔试/深信服/一百分.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.深信服; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Scanner; 6 | 7 | /** 8 | * Created by 周杰伦 on 2018/6/21. 9 | */ 10 | public class 一百分 { 11 | public static void main(String[] args) { 12 | Scanner scanner = new Scanner(System.in); 13 | int n = scanner.nextInt(); 14 | int []arr = new int[n]; 15 | for (int i = 0;i < n;i ++) { 16 | arr[i] = scanner.nextInt(); 17 | } 18 | sum(arr); 19 | } 20 | public static void sum(int []arr) { 21 | List list = new ArrayList<>(); 22 | int []visit = new int[arr.length]; 23 | backtrace(arr,0, 0, list, visit); 24 | } 25 | public static void backtrace(int []arr, int cur, int sum, List list, int []visit ) { 26 | if (sum == 100) { 27 | System.out.println(list.size()); 28 | for (int i : list) { 29 | System.out.println(i); 30 | } 31 | return; 32 | } 33 | 34 | for (int i = cur;i < arr.length;i ++ ) { 35 | if (visit[i] == 0 && sum + arr[i] <= 100) { 36 | list.add(i + 1); 37 | visit[i] = 1; 38 | backtrace(arr, i, sum + arr[i], list, visit); 39 | visit[i] = 0; 40 | list.remove(list.size() - 1); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试16年/美团/棋子翻转.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试16年.美团; 2 | 3 | import java.util.Arrays; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/15.题目描述 7 | 在4x4的棋盘上摆满了黑白棋子,黑白两色的位置和数目随机其中左上角坐标为(1,1),右下角坐标为(4,4),现在依次有一些翻转操作,要对一些给定支点坐标为中心的上下左右四个棋子的颜色进行翻转,请计算出翻转后的棋盘颜色。 8 | 9 | 给定两个数组A和f,分别为初始棋盘和翻转位置。其中翻转位置共有3个。请返回翻转后的棋盘。 10 | 11 | 测试样例: 12 | [[0,0,1,1],[1,0,1,0],[0,1,1,0],[0,0,1,0]],[[2,2],[3,3],[4,4]] 13 | 返回:[[0,1,1,1],[0,0,1,0],[0,1,1,0],[0,0,1,0]] 14 | */ 15 | public class 棋子翻转 { 16 | public static void main(String[] args) { 17 | int [][]A = {{0,0,1,1},{1,0,1,0},{0,1,1,0},{0,0,1,0}}; 18 | int [][]f = {{2,2}, {3,3}, {4,4}}; 19 | int [][]res = flipChess(A, f); 20 | for (int i = 0;i < res.length;i ++) { 21 | System.out.println(Arrays.toString(res[i])); 22 | } 23 | } 24 | public static int[][] flipChess(int[][] A, int[][] f) { 25 | // write code here 26 | for (int i = 0;i < f.length;i ++) { 27 | int x = f[i][0]; 28 | int y = f[i][1]; 29 | if (x > 1){ 30 | A[x - 2][y - 1] ^= 1; 31 | } 32 | if (x < 4) { 33 | A[x][y - 1] ^= 1; 34 | } 35 | if (y > 1) { 36 | A[x - 1][y - 2] ^= 1; 37 | } 38 | if (y < 4) { 39 | A[x - 1][y] ^= 1; 40 | } 41 | } 42 | return A; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/京东/移除字符变成回文子串.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.京东; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/4/9. 7 | */ 8 | public class 移除字符变成回文子串 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | String line = scanner.nextLine(); 12 | System.out.println(remove(line)); 13 | scanner.close(); 14 | } 15 | public static int remove(String s) { 16 | int cnt = 0; 17 | for (int i = 1; i < s.length(); i++) { 18 | for (int j = i; j < s.length(); j++) { 19 | String a = s.substring(0, i); 20 | String b = s.substring(j, s.length()); 21 | if (isHuiWen(a + b)) { 22 | cnt++; 23 | } 24 | if (isHuiWen(a)) { 25 | cnt++; 26 | } 27 | if (isHuiWen(b)) { 28 | cnt++; 29 | } 30 | } 31 | } 32 | return cnt; 33 | } 34 | public static boolean isHuiWen(String s) { 35 | if (s == null || s.equals(""))return false; 36 | if (s.length() == 1)return true; 37 | int l = 0,r = s.length() - 1; 38 | while (l < r) { 39 | if (s.charAt(l) != s.charAt(r))return false; 40 | l ++; 41 | r --; 42 | } 43 | return true; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam/BalanceNum.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam; 2 | 3 | import org.junit.Test; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/3/23. 7 | * int[] a = new int[s.length()]; 8 | for(int i = 0; i < s.length(); i++) 9 | { 10 | //先由字符串转换成char,再转换成String,然后Integer 11 | 12 | a[i] = Integer.parseInt( String.valueOf(s.charAt(i))); 13 | 14 | } 15 | */ 16 | public class BalanceNum { 17 | public String BalanceNum(int num){ 18 | String number=String.valueOf(num); 19 | 20 | if(number.length()==1)return "NO"; 21 | if(NumMulti(number))return "YES"; 22 | return "NO"; 23 | 24 | } 25 | 26 | public boolean NumMulti(String num){ 27 | if(num==null)return false; 28 | int mid; 29 | int left=1,right=1; 30 | int []arr=new int[num.length()]; 31 | for(int i=0;i= m || c < 0 || c >= n || grid[r][c] == 0) { 38 | return 0; 39 | } 40 | grid[r][c] = 0; 41 | int area = 1; 42 | for (int[] d : direction) { 43 | area += dfs(grid, r + d[0], c + d[1]); 44 | } 45 | return area; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/京东/进制均值.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.京东; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/6. 7 | */ 8 | public class 进制均值 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | while (scanner.hasNextInt()) { 12 | int n = scanner.nextInt(); 13 | System.out.println(sumAndAve(n)); 14 | } 15 | } 16 | 17 | public static String sumAndAve(int n) { 18 | int sum = 0; 19 | for (int i = 2;i < n;i ++) { 20 | sum += convert(n, i, 0); 21 | } 22 | int gcd = gcd(sum, n - 2); 23 | return sum/gcd + "/" + (n - 2)/gcd; 24 | } 25 | 26 | // // 2-16进制表示的位数 27 | // public String[] arr = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", 28 | // "A", "B", "C", "D", "E", "F"}; 29 | 30 | /** 31 | * @param number 要转换的十进制数 32 | * @param system 转换的进制位 33 | */ 34 | public static int convert(int number, int system, int sum) { 35 | sum = number % system + sum; 36 | 37 | if(number/system == 0) return sum; 38 | 39 | return convert(number/system, system, sum); 40 | } 41 | 42 | public static int gcd(int x, int y){ // 这个是运用辗转相除法求 两个数的 最大公约数 看不懂可以百度 // 下 43 | if(y == 0) 44 | return x; 45 | else 46 | return gcd(y,x%y); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/校招笔试/头条/头条三轮/ip.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.头条.头条三轮; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Scanner; 6 | 7 | /** 8 | * Created by 周杰伦 on 2018/9/9. 9 | */ 10 | public class ip { 11 | public static void main(String[] args) { 12 | Scanner scanner = new Scanner(System.in); 13 | String s = scanner.next(); 14 | ip(s); 15 | } 16 | public static void ip (String s) { 17 | List list = new ArrayList<>(); 18 | dfs(s, 0, 0, list); 19 | System.out.println(allList.size()); 20 | } 21 | static List> allList = new ArrayList(); 22 | public static void dfs(String str, int cur, int num, List list) { 23 | if (num == 4 && cur == str.length()) { 24 | allList.add(new ArrayList(list)); 25 | return; 26 | } 27 | for (int i = cur;i < cur + 3 && i < str.length();i ++) { 28 | String ss = str.substring(cur,i + 1); 29 | if (legal(ss)) { 30 | list.add(ss); 31 | dfs(str,i + 1, num + 1, list); 32 | list.remove(list.size() - 1); 33 | } 34 | } 35 | } 36 | 37 | public static boolean legal(String s) { 38 | if (s.charAt(0) == '0' && s.length() != 1)return false; 39 | if (Integer.parseInt(s) <= 255 && Integer.parseInt(s) >= 0) { 40 | return true; 41 | } 42 | return false; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/校招笔试/Keep/翻转字符串.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.Keep; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/9/3. 7 | */ 8 | public class 翻转字符串 { 9 | public static void main(String[] args) { 10 | System.out.println("3 1 4 1"); 11 | Scanner scanner = new Scanner(System.in); 12 | String s = scanner.next(); 13 | int k = scanner.nextInt(); 14 | reverse(s, k); 15 | } 16 | public static void reverse(String str, int k) { 17 | StringBuilder sb = new StringBuilder(); 18 | StringBuilder all = new StringBuilder(); 19 | int time = 0; 20 | for (int i = 0;i <= str.length();i ++) { 21 | time = i / (3 * k); 22 | int begin = 3 * k * (time - 1); 23 | int end = begin + k; 24 | if ((str.length() - i >= 3 * k) && (i % (3 * k) == 0) && i != 0) { 25 | sb = new StringBuilder(str.substring(begin, end)).reverse(); 26 | all.append(sb); 27 | all.append(str.substring(end, i)); 28 | }else if (str.length() - i >= k && str.length() - i <= 3 * k) { 29 | all.append(new StringBuilder(str.substring(begin, end)).reverse()); 30 | all.append(str.substring(end, str.length())); 31 | }else { 32 | all.append(new StringBuilder(str.substring(begin, end)).reverse()); 33 | } 34 | } 35 | System.out.println(all.toString()); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/校招笔试/华为/小偷偷东西问题.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.华为; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/8. 7 | */ 8 | public class 小偷偷东西问题 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | String s = scanner.next(); 12 | String []ss = s.split(","); 13 | int []value = new int[ss.length]; 14 | int []weight = new int[ss.length]; 15 | for (int i = 0;i < value.length;i ++) { 16 | value[i] = Integer.parseInt(ss[i]); 17 | } 18 | s = scanner.next(); 19 | ss = s.split(","); 20 | for (int i = 0;i < weight.length;i ++) { 21 | weight[i] = Integer.parseInt(ss[i]); 22 | } 23 | int capacity = scanner.nextInt(); 24 | System.out.println(maxValue(value, weight, capacity)); 25 | } 26 | 27 | public static int maxValue(int []value, int []weight, int capacity) { 28 | int [][]dp = new int[value.length + 1][capacity + 1]; 29 | for(int i = 1;i <= value.length;i++) 30 | { 31 | for(int j = 1;j <= capacity;j++) 32 | { 33 | if(j >= weight[i - 1]) 34 | dp[i][j] = Math.max(dp[i - 1][j],dp[i - 1][j - weight[i - 1]] + value[i - 1]); 35 | else { 36 | dp[i][j] = dp[i - 1][j]; 37 | } 38 | } 39 | } 40 | return dp[value.length][capacity]; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2018/Written/牛客模考/吃雪糕.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2018.Written.牛客模考; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/5/23. 7 | * 最近天气太热了,牛牛每天都要吃雪糕。雪糕有一盒一份、一盒两份、一盒三份这三种包装,牛牛一天可以吃多盒雪糕,但是只能吃六份,吃多了就会肚子疼,吃少了就会中暑。而且贪吃的牛牛一旦打开一盒雪糕,就一定会把它吃完。请问牛牛能健康地度过这段高温期么? 8 | 每个输入包含多个测试用例。 9 | 输入的第一行包括一个正整数,表示数据组数T(1<=T<=100)。 10 | 接下来N行,每行包含四个正整数,表示高温期持续的天数N(1<=N<=10000),一盒一份包装的雪糕数量A(1<=A<=100000),一盒两份包装的雪糕数量B(1<=B<=100000),一盒三份包装的雪糕数量C(1<=A<=100000)。 11 | 输出描述: 12 | 对于每个用例,在单独的一行中输出结果。如果牛牛可以健康地度过高温期则输出"Yes",否则输出"No"。 13 | 示例1 14 | 输入 15 | 4 16 | 1 1 1 1 17 | 2 0 0 4 18 | 3 0 2 5 19 | 4 24 0 0 20 | 输出 21 | Yes 22 | Yes 23 | No 24 | Yes 25 | */ 26 | public class 吃雪糕 { 27 | public static void main(String[] args) { 28 | Scanner scanner = new Scanner(System.in); 29 | while (scanner.hasNextInt()) { 30 | int T = scanner.nextInt(); 31 | for (int i = 0; i < T; i++) { 32 | int N = scanner.nextInt(); 33 | int A = scanner.nextInt(); 34 | int B = scanner.nextInt(); 35 | int C = scanner.nextInt(); 36 | health(N, A, B, C); 37 | } 38 | } 39 | } 40 | public static void health(int N, int A, int B, int C) { 41 | int sum = A + 2 * B + 3 * C; 42 | if (N * 6 <= sum){ 43 | System.out.println("Yes "); 44 | }else { 45 | System.out.println("No "); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/校招笔试/拼多多/第二波/拼词游戏.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.拼多多.第二波; 2 | 3 | import com.sun.deploy.util.StringUtils; 4 | 5 | import java.util.ArrayList; 6 | import java.util.Comparator; 7 | import java.util.List; 8 | import java.util.Scanner; 9 | 10 | /** 11 | * Created by 周杰伦 on 2018/8/30. 12 | */ 13 | public class 拼词游戏 { 14 | public static void main(String[] args) { 15 | Scanner scanner = new Scanner(System.in); 16 | int n = scanner.nextInt(); 17 | int len = scanner.nextInt(); 18 | String []ss = new String[n]; 19 | for (int i = 0;i < n;i ++) { 20 | ss[i] = scanner.next(); 21 | 22 | } 23 | word(len, ss); 24 | 25 | } 26 | static List list = new ArrayList<>(); 27 | 28 | public static void word(int len, String []ss) { 29 | dfs(ss, 0, ""); 30 | list.sort(new Comparator() { 31 | @Override 32 | public int compare(String o1, String o2) { 33 | return o1.compareTo(o2); 34 | } 35 | }); 36 | System.out.println(list.get(0)); 37 | } 38 | public static void dfs(String []ss, int cur, String word) { 39 | if (word.length() == ss[0].length()) { 40 | if (!list.contains(word)) { 41 | list.add(word); 42 | } 43 | return; 44 | } 45 | for (int i = 0;i < ss.length;i ++) { 46 | dfs(ss, cur + 1, word + ss[i].charAt(cur)); 47 | } 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/校招笔试/携程/查询满足区间的记录.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.携程; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | import java.util.Scanner; 7 | 8 | /** 9 | * Created by 周杰伦 on 2018/9/4. 10 | */ 11 | public class 查询满足区间的记录 { 12 | static class Time{ 13 | String id; 14 | String begin; 15 | String end; 16 | 17 | public Time(String id, String begin, String end) { 18 | this.id = id; 19 | this.begin = begin; 20 | this.end = end; 21 | } 22 | } 23 | public static void main(String[] args) { 24 | Scanner scanner = new Scanner(System.in); 25 | int n = scanner.nextInt(); 26 | String time = scanner.next(); 27 | List res = new ArrayList<>(); 28 | 29 | for (int i = 0;i < n;i ++) { 30 | String id = scanner.next(); 31 | String begin = scanner.next(); 32 | String end = scanner.next(); 33 | if (begin.compareTo(time) <= 0 && end.compareTo(time) >= 0) { 34 | res.add(id); 35 | } 36 | } 37 | find(res, time); 38 | } 39 | 40 | public static void find(List res, String time) { 41 | 42 | Collections.sort(res); 43 | if (res.isEmpty()) { 44 | System.out.println("null"); 45 | }else { 46 | for (String id : res) { 47 | System.out.println(id); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam/print.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam; 2 | 3 | import java.util.LinkedList; 4 | import java.util.Queue; 5 | 6 | /** 7 | * Created by 周杰伦 on 2017/3/1. 8 | */ 9 | public class print { 10 | static class TreeNode{ 11 | TreeNode left=null; 12 | TreeNode right=null; 13 | int val=0; 14 | TreeNode(int val){ 15 | this.val=val; 16 | } 17 | 18 | } 19 | 20 | public static void print(TreeNode t) { 21 | 22 | 23 | Queue queue=new LinkedList<>(); 24 | TreeNode temp; 25 | 26 | if (t!= null){ 27 | queue.offer(t); 28 | 29 | while (!queue.isEmpty()) { 30 | 31 | temp=queue.poll(); 32 | System.out.println(temp.val); 33 | 34 | if (temp.left != null) 35 | queue.offer(temp.left); 36 | 37 | if (temp.right != null) 38 | queue.offer(temp.right); 39 | } 40 | 41 | }} 42 | 43 | 44 | public static void initTree(TreeNode t){ 45 | TreeNode t1=new TreeNode(1); 46 | TreeNode t2=new TreeNode(2); 47 | TreeNode t3=new TreeNode(3); 48 | TreeNode t4=new TreeNode(4); 49 | t.left=t1; 50 | 51 | t.right=null; 52 | 53 | 54 | 55 | 56 | } 57 | 58 | public static void main(String args[]) 59 | { 60 | TreeNode t=new TreeNode(0); 61 | initTree(t); 62 | print(t); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/过去笔试记录/In2017/exam2/PoliceAndThief.java: -------------------------------------------------------------------------------- 1 | package 过去笔试记录.In2017.exam2; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2017/4/7. 7 | * 站队 8 | 时间限制:C/C++语言 2000MS;其他语言 4000MS 9 | 内存限制:C/C++语言 65536KB;其他语言 589824KB 10 | 题目描述: 11 | 有一条很长的队伍,队伍里面一共有n个人。所有的人分为三类:警察,小偷和普通人。将队伍里面的人从前到后由1到n编号,编号为i的人与编号为j的人的距离为i与j之差的绝对值。 12 | 每一个警察有一个能力值x,表示他能够监视与他距离不超过x的所有人,小偷被警察发现当且仅当他被一个或多个警察监视到。你知道在整条队伍中,一共有多少个小偷会被警察发现吗? 13 | */ 14 | public class PoliceAndThief { 15 | public static void main(String[] args) { 16 | Scanner input = new Scanner(System.in); 17 | String temp = input.nextLine(); 18 | String[] num = temp.trim().split(" "); 19 | int n = Integer.parseInt(num[0]); 20 | 21 | String str = input.nextLine(); 22 | char[] ss = str.toCharArray(); 23 | input.close(); 24 | int count=0; 25 | boolean flag=false; 26 | for(int i=0;i=Math.abs(j-i)){ 33 | flag=true; 34 | } 35 | } 36 | } 37 | if(flag)count++; 38 | } 39 | } 40 | System.out.println(count); 41 | 42 | 43 | 44 | 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/校招笔试/拼多多/复制可乐.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.拼多多; 2 | 3 | import java.util.LinkedList; 4 | import java.util.Queue; 5 | import java.util.Scanner; 6 | 7 | /** 8 | * Created by 周杰伦 on 2018/7/22. 9 | */ 10 | public class 复制可乐 { 11 | 12 | public static void main(String[] args) { 13 | Scanner sc = new Scanner(System.in); 14 | int n = sc.nextInt(); 15 | run(n); 16 | } 17 | public static void run(int n) { 18 | int cnt = 1; 19 | int base = 4; 20 | int sum = 4; 21 | while (sum < n) { 22 | sum += sum * 2; 23 | cnt *= 2; 24 | } 25 | int diff = sum - n; 26 | int res = diff / cnt; 27 | int rem = diff % cnt; 28 | res += rem; 29 | if (rem == 1) { 30 | System.out.println("Alice"); 31 | } else if (rem == 2) { 32 | System.out.println("Bob"); 33 | } else if (rem == 3) { 34 | System.out.println("Cathy"); 35 | } else if (rem == 4) { 36 | System.out.println("Dave"); 37 | } 38 | } 39 | public static String copy(Queue queue, int n) { 40 | queue.add("Alice"); 41 | queue.add("Bob"); 42 | queue.add("Cathy"); 43 | queue.add("Dave"); 44 | int cnt = 1; 45 | while (cnt < n) { 46 | String s = queue.poll(); 47 | cnt ++; 48 | queue.add(s); 49 | queue.add(s); 50 | } 51 | return queue.peek(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试16年/美团/直方图内最大矩形.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试16年.美团; 2 | 3 | /** 4 | * Created by 周杰伦 on 2018/6/26. 5 | */ 6 | public class 直方图内最大矩形 { 7 | public static void main(String[] args) { 8 | int []A = {2,7,9,4,1}; 9 | System.out.println(countArea(A, 5)); 10 | } 11 | public static int countArea(int[] A, int n) { 12 | // write code here 13 | int max = 0; 14 | for (int i = 0;i < n;i ++) { 15 | for (int j = i + 1;j < n;j ++ ) { 16 | int min = Integer.MAX_VALUE; 17 | for (int k = i;k <= j && k < n;k ++) { 18 | min = Math.min(min, A[k]); 19 | } 20 | max = Math.max(max, min * (j - i + 1)); 21 | } 22 | } 23 | return max; 24 | } 25 | 26 | //优化方案 27 | // 链接:https://www.nowcoder.com/questionTerminal/13ba51c3fec74b58bbc8fa8c3eedf877 28 | // 来源:牛客网 29 | // 30 | // int i,j,L1,L2; 31 | //    int max=0; 32 | //    for(i=0;i=A[i])L1++; 38 | //            else break; 39 | //                  40 | //        } 41 | //        for(j=i-1;j>=0;--j) 42 | //        { 43 | //            if(A[j]>=A[i])L2++; 44 | //            else break;     45 | //        } 46 | //        area=(L1+L2)*A[i]; 47 | //        if(area>max)max=area; 48 | //    } 49 | //    //printf("max area:%d\n",max); 50 | //     return max; 51 | } 52 | -------------------------------------------------------------------------------- /src/校招笔试/牛客模考/牛牛数星星.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.牛客模考; 2 | 3 | import java.util.Scanner; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/6/14. 7 | */ 8 | public class 牛牛数星星 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int n = scanner.nextInt(); 12 | int [][] star = new int[n][2]; 13 | for (int i = 0;i < n;i ++) { 14 | star[i][0] = scanner.nextInt(); 15 | star[i][1] = scanner.nextInt(); 16 | } 17 | int m = scanner.nextInt(); 18 | int [][]xy = new int[m][4]; 19 | for (int i = 0;i < m;i ++) { 20 | xy[i][0] = scanner.nextInt(); 21 | xy[i][1] = scanner.nextInt(); 22 | xy[i][2] = scanner.nextInt(); 23 | xy[i][3] = scanner.nextInt(); 24 | } 25 | 26 | for (int i = 0;i < m;i ++) { 27 | // System.out.println(Arrays.toString(xy[i])); 28 | int x1 = xy[i][0]; 29 | int y1 = xy[i][1]; 30 | int x2 = xy[i][2]; 31 | int y2 = xy[i][3]; 32 | System.out.println(sum(star, x1, y1, x2, y2)); 33 | } 34 | } 35 | 36 | public static int sum(int [][]star, int x1, int y1, int x2, int y2) { 37 | int cnt = 0; 38 | for (int []xy : star) { 39 | int x = xy[0]; 40 | int y = xy[1]; 41 | if ( x >= x1 && y >= y1 && x <= x2 && y <= y2 ) { 42 | cnt ++; 43 | } 44 | } 45 | return cnt; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/校招笔试/京东/对比.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.京东; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Comparator; 5 | import java.util.List; 6 | import java.util.Scanner; 7 | 8 | /** 9 | * Created by 周杰伦 on 2018/9/9. 10 | */ 11 | public class 对比 { 12 | public static class Box{ 13 | int a; 14 | int b; 15 | int c; 16 | 17 | public Box(int a, int b, int c) { 18 | this.a = a; 19 | this.b = b; 20 | this.c = c; 21 | } 22 | } 23 | public static void main(String[] args) { 24 | Scanner scanner = new Scanner(System.in); 25 | int n = scanner.nextInt(); 26 | List list = new ArrayList<>(); 27 | for (int i = 0;i < n;i ++) { 28 | int a = scanner.nextInt(); 29 | int b = scanner.nextInt(); 30 | int c = scanner.nextInt(); 31 | list.add(new Box(a,b,c)); 32 | } 33 | compare(list); 34 | } 35 | public static void compare(List list) { 36 | int cnt = 0; 37 | list.sort(new Comparator() { 38 | @Override 39 | public int compare(Box o1, Box o2) { 40 | return 0; 41 | } 42 | }); 43 | for (Box box : list) { 44 | for (Box cmp : list) { 45 | if (cmp.a > box.a && cmp.b > box.b && cmp.c > box.c) { 46 | cnt ++; 47 | break; 48 | } 49 | } 50 | } 51 | System.out.println(cnt); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/牛客往年真题/笔试17年/网易游戏/会话列表.java: -------------------------------------------------------------------------------- 1 | package 牛客往年真题.笔试17年.网易游戏; 2 | 3 | import java.util.*; 4 | 5 | /** 6 | * Created by 周杰伦 on 2018/8/9. 7 | */ 8 | public class 会话列表 { 9 | public static void main(String[] args) { 10 | Scanner scanner = new Scanner(System.in); 11 | int n = scanner.nextInt(); 12 | ArrayList[] arr = new ArrayList[n]; 13 | for (int i = 0;i < n;i ++) { 14 | int num = scanner.nextInt(); 15 | arr[i] = new ArrayList(); 16 | for (int j = 0;j < num;j ++) { 17 | int seq = scanner.nextInt(); 18 | arr[i].add(seq); 19 | } 20 | } 21 | for (int i = 0;i < n;i ++) { 22 | List list = arr[i]; 23 | sort(list); 24 | } 25 | } 26 | 27 | public static void sort(List list) { 28 | Map map = new LinkedHashMap(200, (float) 0.75, true); 29 | for (int i : list) { 30 | if (map.containsKey(i)) { 31 | map.get(i); 32 | }else { 33 | map.put(i, 1); 34 | } 35 | } 36 | 37 | ListIterator iterator = new ArrayList( 38 | map.entrySet()).listIterator(map.size()); 39 | 40 | while (iterator.hasPrevious()) { 41 | Map.Entry entry = iterator.previous(); 42 | System.out.print(entry.getKey() + " "); 43 | } 44 | System.out.println(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/校招笔试/头条/E.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.头条; 2 | 3 | import java.util.Arrays; 4 | import java.util.Comparator; 5 | import java.util.Scanner; 6 | 7 | /** 8 | * Created by 周杰伦 on 2018/8/12. 9 | 3 10 | 10 11 | 0 3 3 7 7 0 12 | 13 | 4 14 | 10 15 | 0 4 2 5 3 7 5 8 16 | */ 17 | public class E { 18 | public static void main(String[] args) { 19 | Scanner scanner = new Scanner(System.in); 20 | int n = scanner.nextInt(); 21 | int m = scanner.nextInt(); 22 | int [][]arr = new int[n][2]; 23 | for (int i = 0;i < n;i ++) { 24 | arr[i][0] = scanner.nextInt(); 25 | arr[i][1] = scanner.nextInt(); 26 | if (arr[i][1] < arr[i][0] ) { 27 | arr[i][1] = arr[i][1] + m; 28 | } 29 | } 30 | func(arr, m); 31 | } 32 | public static void func(int [][]arr, int m) { 33 | Arrays.sort(arr, new Comparator() { 34 | @Override 35 | public int compare(int[] o1, int[] o2) { 36 | return o1[1] - o2[1]; 37 | } 38 | }); 39 | int cnt = 1; 40 | for (int i = 0;i < arr.length - 1;) { 41 | int temp = i; 42 | for (int j = i + 1;j < arr.length;j ++) { 43 | if (arr[j][0] >= arr[i][1]) { 44 | cnt++; 45 | i = j; 46 | break; 47 | } 48 | } 49 | if (temp == i) { 50 | i++; 51 | } 52 | } 53 | System.out.println(cnt); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/校招笔试/拼多多/球王.java: -------------------------------------------------------------------------------- 1 | package 校招笔试.拼多多; 2 | 3 | import java.util.Arrays; 4 | import java.util.Scanner; 5 | 6 | /** 7 | * Created by 周杰伦 on 2018/7/22. 8 | */ 9 | public class 球王 { 10 | public static void main(String[] args) { 11 | Scanner scanner = new Scanner(System.in); 12 | int n = scanner.nextInt(); 13 | int m = scanner.nextInt(); 14 | String []goal = new String[n]; 15 | Arrays.fill(goal, ""); 16 | for (int i = 0;i < m;i ++) { 17 | String s = scanner.next(); 18 | for (int j = 0;j < s.length();j ++) { 19 | goal[j] += s.charAt(j); 20 | } 21 | } 22 | if (n == 1) { 23 | System.out.println(0); 24 | }else { 25 | System.out.println(king(goal)); 26 | } 27 | } 28 | public static int king(String []goal) { 29 | String []temp = Arrays.copyOf(goal, goal.length); 30 | Arrays.sort(goal); 31 | if (goal[0].equals(goal[1])) { 32 | return -1; 33 | } 34 | int diff = 0; 35 | for (int i = 0;i < goal[0].length();i ++) { 36 | if (goal[0].charAt(i) > goal[1].charAt(i)) { 37 | diff ++; 38 | }else { 39 | diff --; 40 | } 41 | } 42 | if (diff == 0) { 43 | return -1; 44 | } 45 | for (int i = 0;i < temp.length;i ++) { 46 | if (goal[0].equals(temp[i])){ 47 | return i; 48 | } 49 | } 50 | return -1; 51 | } 52 | } 53 | --------------------------------------------------------------------------------