首页
题库
公司真题
专项练习
面试题库
在线编程
面试
面试经验
AI 模拟面试
简历
求职
学习
课程
专栏·文章
竞赛
搜索
我要招人
发布职位
发布职位、邀约牛人
更多企业解决方案
在线笔面试、雇主品牌宣传
登录
/
注册
只为刷题
字节跳动_资深前端开发工程师
获赞
126
粉丝
29
关注
7
看过 TA
4
男
华中科技大学
2018
前端工程师
IP属地:湖北
无
私信
关注
拉黑
举报
举报
确定要拉黑只为刷题吗?
发布(94)
刷题
只为刷题
2021-05-18 21:02
字节跳动_资深前端开发工程师
题解 | #求int型正整数在内存中存储时1的个数#
/**把一个整数减去1和原来的整数做位与运算,得到的结果相当于把整数的二进制位的最右边的1变成0.1的二进制位是01, 其他的位补0,与运算规则 0**/ import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); int n = in.nextInt(); int count =0; while(n!=0){ n ...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:56
已编辑
字节跳动_资深前端开发工程师
题解 | #字符串排序#
//JAVA 原谅我的条件反射,看到这种字符按照字典排序的 首先想到tree相关的数据结构 //解法一:利用TreeMap自动为key进行字典排序的性质//解法二:直接字符串比较大小,字符串的比较也是按照字典排序。 import java.util.*; import java.lang.*; //解法一: public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:47
字节跳动_资深前端开发工程师
题解 | #句子逆序#
//JAVA 简单明了 import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String inStr = sc.nextLine(); String[] wordArr = inStr.split(" "); for(int i = wordArr.length-1; i>=0; i--){ System.out...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:46
字节跳动_资深前端开发工程师
题解 | #字符串反转#
//JAVA import java.util.*; //str.charAt(i) 解法 遍历字符串的获取每个字符。 public class Main{ public static void main(String[] args){ Scanner in = new Scanner(System.in); String str = in.nextLine(); for(int i = str.length()-1; i>=0 ;i--){ System.out.print(str.charAt(i)); ...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:44
字节跳动_资深前端开发工程师
题解 | #数字颠倒#
/* JAVA 两种解法: 1,对这个整数取模,依次得到个位数的值,拼接成字符串 2,把整数转成字符串,反向遍历。 */ import java.util.Scanner; //解法1 public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); int a = in.nextInt(); StringBuffer sb = new StringBuffer(); String result = "";...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:42
字节跳动_资深前端开发工程师
题解 | #字符个数统计#
import java.util.*; //JAVA //利用hashset去重,最后读取set的长度。 public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ Set outputSet = new HashSet(); String inputStr = sc.nextLine(); for(int i = 0...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:40
字节跳动_资深前端开发工程师
题解 | #提取不重复的整数#
import java.util.*; //从末尾遍历,去重放进list public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int indata = scanner.nextInt(); String indataStr = indata + ""; List<Character> outdataList = new ArrayList<Charac...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:39
字节跳动_资深前端开发工程师
题解 | #合并表记录#
//放入map, 对map的key进行判断,key有重复的就重新put进map更新对应的value的值、 //重点是数据结构的选择, //这里没用hashmap, 而是用的TreeMap ,因为hashmap是无序的,TreeMap是有序的, //当key的数量非常多的时候,TreeMap可以保证有序。 import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); TreeMap<...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:37
字节跳动_资深前端开发工程师
题解 | #取近似值#
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner in = new Scanner(System.in); double a = in.nextDouble(); int b = (int)a; if(a-b>=0.5){ b = (int)(a + 0.5); } System.out.print(b); } }
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:35
已编辑
字节跳动_资深前端开发工程师
题解 | #质数因子#
//思路:一个正整数的质因子是不大于其平方根的 import java.util.*; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); long num = scanner.nextLong(); //求取平方根 long k = (long) Math.sqrt(num); //这里用到了一个规律:一个正整数的质因子是不大于其平方根的 ...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:17
字节跳动_资深前端开发工程师
题解 | #进制转换#
/* 以下三个点: ----------------------------------------- ①、16进制的表示 0x(0x是固定写法)数字或者字母(A-F)可以是小写,英文字母A,B,C,D,E,F分别表示数字10~15。 冯16进1, 例如:0xAF=175 的十进制如下: 相当于 10*16¹ + 15*16º = 160 +15 =175 ----------------------------------------- ②、字符减'0'可以到相应的整数,在ASCII表中对应的数值换算运算。 -------------------------------------...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:15
字节跳动_资深前端开发工程师
题解 | #字符串分隔#
/* 思路: 先拼接所有输入字符串, 对8取模,不够的补0, 再字符串分割输出, 要点: substring(int beginIndex) ,从指定的索引开始截取直到最未 substring(int beginIndex, int endIndex) ,截取的包含beginIndex,但不包含endIndex。 */ import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); wh...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:13
字节跳动_资深前端开发工程师
题解 | #明明的随机数#
//题目要去重排序 //数据结构想到TreeSet, Tree有序的,set去重 import java.util.*; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); while(scanner.hasNext()){ int num =scanner.nextInt(); //创建TreeSet进行去重排序 TreeSet ...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:08
已编辑
字节跳动_资深前端开发工程师
题解 | #字符串最后一个单词的长度#
import java.util.*; //把句子反转,截取到空格的长度 得到第一个单词的长度 //用str.indexof()方法获取某个特定字符第一次出现的位置。 public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String str = sc.nextLine(); int lastWordLenth; if(str.length()>=5000){ ...
0
点赞
评论
收藏
转发
只为刷题
2021-05-18 20:02
已编辑
字节跳动_资深前端开发工程师
题解 | #用两个栈实现队列#
//思想:动态规划+递归//用递归去处理最小事件,这里的最小事件用函数表达为 f(m,n) = f(m-n,n) + f(m,n-1)// 放苹果分为两种情况,一种是有盘子为空,一种是每个盘子上都有苹果。// 令(m,n)表示将m个苹果放入n个盘子中的摆放方法总数。// 1.假设有一个盘子为空,则(m,n)问题转化为将m个苹果放在n-1个盘子上,即求得(m,n-1)即可// 2.假设所有盘子都装有苹果,则每个盘子上至少有一个苹果,即最多剩下m-n个苹果,问题转化为将m-n个苹果放到n个盘子上// 即求(m-n,n) import java.util.Scanner; public class ...
0
点赞
评论
收藏
转发
1
2
3
4
5
6
7
工具箱
TA的圈子
暂未加入圈子
TA的圈子
TA的笔记
暂无笔记
TA的笔记
登录
0
天
已登录
0
天
连续登录
0
人
今日访客
牛客网
牛客企业服务