摘要: 题目: 小明同学学习了不同的进制之后,拿起了一些数字做起了游戏。小明同学知道,在日常生活中我们最常用的是十进制数,而在计算机中,二进制数也很常用。现在对于一个数字x,小明同学定义出了两个函数f(x)和g(x)。 f(x)表示把x这个数用十进制写出后各个数位上的数字之和。如f(123)=1+2+3=6 阅读全文
posted @ 2018-03-05 16:04 zlz099 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 题目: 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: “水仙花数”是指一个三位数,它的各位数字的立方和等于其本身,比如:153=1^3+5^3+3^3。 现在要求输出所有在m和n范围内的水仙花数。输入描述:输入数据有多组,每组占一行,包括两个整数m和n(100 阅读全文
posted @ 2018-03-05 16:03 zlz099 阅读(977) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others 阅读全文
posted @ 2018-03-05 11:23 zlz099 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot * makes a circle, which means it moves back t 阅读全文
posted @ 2018-03-05 10:24 zlz099 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 思路: 判断一个链表是否有环。 * 同个时间Faster走的比Slo 阅读全文
posted @ 2018-03-05 10:10 zlz099 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 分治算法 一、基本概念 在计算机科学中,分治法是一种很重要的算法。字面上的解释是“分而治之”,就是把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题……直到最后子问题可以简单的直接求解,原问题的解即子问题的解的合并。这个技巧是很多高效算法的基础,如排序算法(快速排序,归并 阅读全文
posted @ 2018-03-04 16:52 zlz099 阅读(810) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" ret 阅读全文
posted @ 2018-01-09 16:19 zlz099 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = "hello", return "holle". Example 2: 阅读全文
posted @ 2018-01-09 15:39 zlz099 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Write a function that takes a string as input and returns the string reversed. 思路: 逆序输出一个字符串第一种方法:从尾到头遍历原字符串,返回到result中。但提交提示超时了,给了一个巨长无比的测试用例。第 阅读全文
posted @ 2018-01-09 11:21 zlz099 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 题目描述: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive 阅读全文
posted @ 2018-01-09 09:55 zlz099 阅读(132) 评论(0) 推荐(0) 编辑