![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
JeffCoding
热爱移动互联网,热爱安卓,热爱Java
展开
-
Leet Code OJ 7. Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321Have you thought about this? Here are some good questions to ask before coding. Bonus points for you if原创 2017-02-06 10:28:19 · 274 阅读 · 0 评论 -
LeetCode排列组合问题合集
78. SubsetsGiven a set of distinct integers, nums, return all possible subsets. 给定一组非重复数字,求出所有可能的子集解析:例如 [1,2,3],解法: 首先放[],然后往已有的[]中放1 1. 首先放1 此时已有[ [], 1 ] 2. 然后对[ [], 1 ] 放2 于是此时有 [ [], [1], [2原创 2017-07-16 15:11:43 · 1715 阅读 · 0 评论 -
Leetcode Linked List Problem 链表问题合集
1. Leet Code OJ 2. Add Two NumbersYou 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.原创 2017-02-07 22:45:07 · 3077 阅读 · 0 评论 -
Leetcode Tree Problem 树问题合集
树问题规律总结出现树问题,多数情况都是需要递归遍历(dfs和bfs),并且要根据题目要求,来思考相关的树的性质: 二叉树的一些性质问题汇总1. Leet Code OJ 101. Symmetric Tree程序:/** * Definition for a binary tree node. * public class TreeNode { * int val; * T原创 2017-02-28 17:06:09 · 1216 阅读 · 0 评论 -
设计一个ip网段黑名单过滤(网易面试题)
问题:给出一个网段,该网段的地址都属于黑名单,验证其他ip地址是否属于黑名单要想到通过二进制的位运算来实现:ip & 子网掩码 = 网段对于一个CIDR的ip地址,怎么得到子网掩码? 可以得到CIDR中的网络号位数netCount,然后:int mask = 0xFFFFFFFF << (32 - netCount);这样就能得到子网掩码public class IPFilter { /**原创 2017-05-31 21:38:32 · 10119 阅读 · 0 评论 -
校招算法题记录
1. 微信红包(2016腾讯)给定一个红包的金额数组gifts及它的大小n,请返回所求红包的金额。 若没有金额超过总数的一半,返回0输入: [1,2,3,2,2],5输出: 2解答:可以先把数组排序,如果一个数的出现次数超过一半,排序后必然出现在中间2. 删除重复字符(2016华为)每组数据一行,按字符串原有的字符顺序,输出字符集合,即重复出现并靠后的字母不输出。输入: abcqweracb原创 2017-04-28 12:50:33 · 739 阅读 · 0 评论 -
Leet Code OJ 70. Climbing Stairs(爬楼梯问题)
题目You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?这是一个爬楼梯问题,给定楼梯层数n,每一步只能走1层或者2层,问上到楼原创 2017-02-28 14:01:37 · 660 阅读 · 0 评论 -
Leet Code Stack Problem 栈问题合集
总结栈问题通常和对称联系起来,一个出现,必须和另一个出现才合法,例如,出现“(”,就要出现“)”才合法,当遇到对称的问题时,可以考虑是不是栈问题1. Leet Code Oj 20. Valid ParenthesesGiven a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if原创 2017-02-07 23:10:43 · 402 阅读 · 0 评论 -
Leet Code OJ 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.编写一个函数来查找字符串数组中最长的公共前缀字符串。代码public String longestCommonPrefix(String[] strs) { if(strs == null || strs.length =原创 2017-02-07 23:01:25 · 305 阅读 · 0 评论 -
Leet Code OJ 17. Letter Combinations of a Phone Number
Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string “23”原创 2017-02-07 22:50:08 · 422 阅读 · 0 评论 -
LeetCode Two Point & Array Problem 两点问题汇总
问题:Given n non-negative integers a1, a2, …, an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two原创 2017-02-07 20:35:03 · 662 阅读 · 0 评论 -
LeetCode位运算合集
344. Reverse StringWrite a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.最简单的做法new StringBuilder(s).reverse().toString();更高效的做法public原创 2017-03-15 10:53:43 · 495 阅读 · 0 评论