2018年3月10日

面试题—小算法20题

摘要: 1、IP转换成整数及整数转换成IP Java实现: package com.mian.demo; public class IpToInt { public static void main(String[] args) { String ip="192.168.12.90"; int ipInt= 阅读全文

posted @ 2018-03-10 23:30 lina2014 阅读(281) 评论(0) 推荐(0) 编辑

008 String to Integer (atoi) 字符串转换为整数

摘要: 详见:https://leetcode.com/problems/string-to-integer-atoi/description/ 实现语言:Java 实现语言:C++ 参考:http://www.cnblogs.com/grandyang/p/4125537.html 阅读全文

posted @ 2018-03-10 21:26 lina2014 阅读(116) 评论(0) 推荐(0) 编辑

LeetCode 233 Number of Digit One 某一范围内的整数包含1的数量

摘要: Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6 阅读全文

posted @ 2018-03-10 20:27 lina2014 阅读(128) 评论(0) 推荐(0) 编辑

KMP算法

摘要: 给定一个主串(以 S 代替)和模式串(以 P 代替),要求找出 P 在 S 中出现的位置,此即串的模式匹配问题。 1、暴力匹配,时间复杂度为 O(nm),其中 n 为 S 的长度,m 为 P 的长度。 2、KMP算法 KMP算法的时间复杂度还是很稳定的。平均时间复杂度为 Θ(m+n)。最好时间复杂度 阅读全文

posted @ 2018-03-10 16:03 lina2014 阅读(143) 评论(0) 推荐(0) 编辑

009 Palindrome Number 判断一个正整数是否是回文数

摘要: 详见:https://leetcode.com/problems/palindrome-number/description/ 实现语言:Java 方法一: 方法二: 实现语言:C++ 方法一: 方法二: 阅读全文

posted @ 2018-03-10 15:36 lina2014 阅读(141) 评论(0) 推荐(0) 编辑

导航