- 博客(13)
- 收藏
- 关注
原创 SharedPreferences存储
SharedPreferences存储SharedPreferences是使用key-value的方式来存储数据的存储到SharedPreferences中步骤如下:获取到SharedPreferences对象,获取对象的方法: · 1、context类中的getSharedPreferences()方法,接收两个参数(文件名,MODE_PRIVATE)。
2017-08-10 22:12:58 359
原创 华为机试---识别有效的IP地址和掩码并进行分类统计
题目描述:请解析IP地址和对应的掩码,进行分类识别。要求按照A/B/C/D/E类地址归类,不合法的地址和掩码单独归类。所有的IP地址划分为 A,B,C,D,E五类A类地址1.0.0.0~126.255.255.255;B类地址128.0.0.0~191.255.255.255;C类地址192.0.0.0~2
2017-07-05 10:37:04 1272
原创 华为机试---最高分是多少
题目描述:老师想知道从某某同学当中,分数最高的是多少,现在请你编程模拟老师的询问。当然,老师有时候需要更新某位同学的成绩. 输入描述:输入包括多组测试数据。每组输入第一行是两个正整数N和M(0 < N <= 30000,0 < M < 5000),分别代表学生的数目和操作的数目。学生ID编号从1编到N。第二行包含N个整数,代表这N个学生的初始成绩,其中第i个数代表ID为i的学
2017-07-02 16:35:39 1152
原创 华为面试---字符个数统计
题目描述:编写一个函数,计算字符串中含有的不同字符的个数。字符在ACSII码范围内(0~127)。不在范围内的不作统计。输入描述:输入N个字符,字符在ACSII码范围内。输出描述:输出范围在(0~127)字符的个数。示例1输入abc输出3解题思路:方法一:创建一个i
2017-07-01 23:24:19 527
原创 华为面试---取近似值
题目描述:写出一个程序,接受一个正浮点数值,输出该数值的近似整数值。如果小数点后数值大于等于5,向上取整;小于5,则向下取整。解题思路:将输入的float值转化成字符,判断小数点后一位数值是否大于等于5,然后使用字符串的split函数去整数部分代码实现:import java.util.Scanner;public class Main{ public s
2017-06-30 22:58:10 301
原创 《剑指offer》栈的压入、弹出序列
题目描述:输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列。(注意:这两个序列的长度是相等的)解题思路:将入栈序列入栈,检查栈顶元素是否和出栈序列的元素相等,如果相等则出
2017-06-26 23:18:08 213
原创 Perfect Number【LeetCode】
题目:We define the Perfect Number is a positive integer that is equal to the sum of all its positive divisors except itself.Now, given an integer n, write a function that returns true when it
2017-05-19 14:01:47 603
原创 Array Partition I
题目:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n a
2017-05-19 11:16:49 433
原创 Two Sum【LeetCode】
题目:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use
2017-05-18 10:00:28 286
原创 Valid Anagram【LeetCode】
题目:Given two string s and t, write a function to determine if t is an anagram of s.For example,s ="anagram", t="nagaram", return true.s="rat", t="car", return false.Note:You may assume the
2017-05-17 23:28:30 317
原创 Integer to Roman【LeetCode】
题目:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question.Show TagsShow Similar Proble
2017-05-17 13:07:30 476
原创 Roman to Integer 【LeetCode】
题目:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Subscribe to see which companies asked this question解析思路:
2017-05-16 22:48:45 226
原创 Add Two Numbers【LeetCode】
题目:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and
2017-05-14 16:10:47 440
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人