leetcode
文章平均质量分 57
coderlong
钱能解决的事情,,,我都解决不了。
展开
-
Longest-Substring-Without-Repeating-Characters
title: Longest Substring Without Repeating Characters date: 2017-10-24 22:58:49 categories: - algorithm tags: - algorithm摘要:Brute Force 正文: Approach #1 Brute Force [Time Lim...原创 2018-03-16 14:22:06 · 150 阅读 · 0 评论 -
leetcode 785. Is Graph Bipartite?
Given an undirected graph, return true if and only if it is bipartite.Recall that a graph is bipartite if we can split it’s set of nodes into two independent subsets AandBsuch that every edge in the...原创 2018-05-09 12:35:56 · 529 阅读 · 0 评论 -
leetcode 529. Minesweeper
title: LeetCode529. Minesweeper date: 2018-05-05 20:01:47 categories: - Algorithm tags: - algorithm - javaDFS && BFS 原题目连接 Let’s play the minesweeper game (Wikiped...原创 2018-05-09 12:42:09 · 301 阅读 · 0 评论 -
leetcode 547. Friend Circles
There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct friend of B, and B is a direct friend of C, then ...原创 2018-05-03 10:39:58 · 274 阅读 · 0 评论 -
leetcode 93. Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations.Example:Input: “25525511135” Output: [“255.255.11.135”, “255.255.111.35”]package dgdf...原创 2018-05-10 17:36:00 · 220 阅读 · 0 评论 -
leetcode 165. Compare Version Numbers
Compare two version numbers version1 and version2. If version1 > version2 return1; if version1 < version2 return-1;otherwise return 0.You may assume that the version strings are non-empty and...原创 2018-05-17 10:22:19 · 298 阅读 · 0 评论 -
LeetCode 43. Multiply Strings
自己来实现字符串的 mul函数, 给定的字符串符合数字的要求,very simple Solution 考虑清楚中间的carry, index 就行了.class Solution { public String multiply(String num1, String num2) { if (num1.equals("0") || num2.equals("0"...原创 2018-04-26 17:03:40 · 151 阅读 · 0 评论 -
leetcode 227. Basic Calculator II
Implement a basic calculator to evaluate a simple expression string.The expression string contains only non-negative integers, +, -, *, /operators and empty spaces . The integer division should trun...原创 2018-05-17 23:02:50 · 198 阅读 · 0 评论 -
leetcode 417. Pacific Atlantic Water Flow
原题目: Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the “Pacific ocean” touches the left and top edges of the matrix and the “Atlantic ocean”...原创 2018-04-27 16:26:31 · 377 阅读 · 1 评论 -
leetcode 473. Matchsticks to Square
原题目: Remember the story of Little Match Girl? By now, you know exactly what matchsticks the little match girl has, please find out a way you can make one square by using up all those matchsticks. You...原创 2018-04-28 16:14:40 · 163 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyi...原创 2018-06-14 10:51:09 · 142 阅读 · 0 评论 -
863. All Nodes Distance K in Binary Tree
原题: We are given a binary tree (with root node root), a target node, and an integer value K.Return a list of the values of all nodes that have a distance K from the target node. The answer can be ...原创 2018-07-02 19:46:49 · 892 阅读 · 0 评论 -
leetcode 802. Find Eventual Safe States
fdfg原创 2018-05-09 12:24:36 · 287 阅读 · 0 评论 -
二叉树路径的最大值
Given a binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The pa...原创 2018-04-19 10:22:41 · 2306 阅读 · 1 评论 -
leetcode797_all_paths_from_source_to_target
title: leetcode797_all_paths_from_source_to_target date: 2018-1-11 14:48:38 categories: - leetcode tags: - leetcodeGiven a directed, acyclic graph of N nodes. Find all possible pat...原创 2018-03-16 14:25:12 · 605 阅读 · 0 评论 -
leetcode257_BinaryTreePaths
title: leetcode257_BinaryTreePaths date: 2018-3-11 14:18:40 categories: - leetcode tags: - leetcodeGiven a binary tree, return all root-to-leaf paths.For example, given the follow...原创 2018-03-16 14:25:29 · 168 阅读 · 0 评论 -
leetcode056_merge_intervals
Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18]. 先把给的list按照 start排序,之后遍历选择就行了。 /** * Definitio...原创 2018-03-16 15:21:02 · 141 阅读 · 0 评论 -
leetcode055_Jump_game
/*** @author 作者 : coderlong* @version 创建时间:2018年3月16日 下午12:56:08* 类说明: 愚蠢的解法, 还是要 贪心算法*/public class leetcode055_Jump_game { public static boolean canJump2(int[] nums) { if (nums ==...原创 2018-03-16 15:22:25 · 236 阅读 · 0 评论 -
Longest-Substring-Without-Repeating-Characters
title: Longest Substring Without Repeating Characters date: 2017-10-24 22:58:49 categories: - algorithm tags: - algorithm摘要:Brute Force 正文: Approach #1 Brute Force [Time Lim...原创 2018-03-05 19:55:25 · 519 阅读 · 0 评论 -
Lettter_Case_Permutation
title: 784. Letter Case Permutation date: 2018-3-4 21:18:40 categories: - Algorithm tags: - AlgorithmGiven a string S, we can transform every letter individually to be lowercase or...原创 2018-03-05 19:57:00 · 158 阅读 · 0 评论 -
leetcode801_Mininum_SwapMakesSequencesIncreasing
title: leetcode801_Mininum_SwapMakesSequencesIncreasing date: 2018-3-20 14:18:40 categories: - leetcode tags: - leetcodeWe have two integer sequences A and B of the same non-zero le...原创 2018-03-20 13:26:56 · 860 阅读 · 0 评论 -
leetocode213_House_Roubber2
前面写过一道,在一条街道上如何抢劫的最多,这道题是那道题的继承。关键之处在于,前面的那个街道,变成了环形的。 使用java写出DP方程,dp[0] = nums[0], dp[1] = Math.max(nums[0], nums[1]) dp[i] = math.max(dp[i-2] + nums[i], dp[i - 1]), 我是直接写出了一个DPHelper,同样可以解决一条街...原创 2018-04-02 16:37:17 · 136 阅读 · 0 评论 -
leetcode221_Maximal_Square
我们在来看一道DP问题, 原题是这样的: Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.For example, given the following matrix: 1 0 1 0 0 1 0 ...原创 2018-04-02 17:22:32 · 308 阅读 · 0 评论 -
357. Count Numbers with Unique Digits
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example: Given n = 2, return 91. (The answer should be the total numbers in the range of 0 ≤ x < 100...原创 2018-04-10 19:55:21 · 153 阅读 · 0 评论 -
非递归中序遍历的一点解释
递归形式的前序,中序,后序,便利大家应该都是比较熟悉的。但是,有时候,在针对一些对BST遍历过程中节点状态控制的时候,使用非递归形式的算法,往往更加有效,代码更加简洁。 1. 先把二叉树的非递归中序遍历贴出。leetcode题目public List<Integer> inorderTraversal(TreeNode root) { List<Integer>...原创 2018-04-16 16:54:30 · 625 阅读 · 0 评论 -
Leetcode Contest94
title: LeetcodeContest94 date: 2018-7-22 23:43:00 categories: - leetcode tags: - Algorithm摘要: 做的最简单的一次周比赛872 Leaf-Similar Trees左相似的树Consider all the leaves of a binary tree....原创 2018-07-23 11:38:54 · 508 阅读 · 0 评论