- 博客(10)
- 资源 (1)
- 收藏
- 关注
原创 leetcode 64. Minimum Path Sum记忆化搜索
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at
2017-05-23 14:38:30 261
原创 leetcode 373. Find K Pairs with Smallest Sums 优先队列
You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.Define a pair (u,v) which consists of one element from the first array and one element from the second a
2017-05-23 13:36:21 229
原创 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 adirect friend of B, and B is a direct friend of C, then
2017-05-23 08:55:00 385
原创 leetcode 131. Palindrome Partitioning回文子串+DFS
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return[ ["aa","b"],
2017-05-22 17:33:50 251
原创 leetcode 200. Number of Islands DFS
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assu
2017-05-22 16:27:33 184
原创 lleetcode 307. Range Sum Query - Mutable树状数组
Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at index i to val.Examp
2017-05-22 16:00:11 467
原创 leetcode 208. Implement Trie (Prefix Tree)字典树
Implement a trie with insert, search, and startsWith methods.Note:You may assume that all inputs are consist of lowercase letters a-z.class Node(): def __init__(self): se
2017-05-22 13:13:30 204
原创 leetcode 1. Two Sum排序+双指针
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 the sam
2017-05-22 10:10:36 809
原创 Regionals 2011 >> Asia - Shanghai 5711 - Revenge of Fibonacci
点击打开链接给定一个长度不超过40的数字串s,求斐波那契数列的前十万项中,最小的一个前缀为s的数的下标。import java.io.BufferedReader;import java.io.InputStream;import java.io.InputStreamReader;import java.io.PrintWriter;import java.math.BigI
2017-05-16 11:00:08 255
原创 CodeForces445C Civilization 带权并查集
n个点,m条边的森林,q次操作。1、询问x所在树的直径 2、合并x和y所在的树,使得合并后的直径最小合并的时候贪心处理,将两集合最长路的中心连接合并后的集合的权重为max( dis[v] , dis[u] , (dis[u]+1)/2 + (dis[v]+1)/2 + 1) ;import java.io.BufferedReader;import java.io.In
2017-05-04 08:46:31 281
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人