
leetcode
文章平均质量分 64
二喵棒棒哒
算法 大数据 区块链 硕士在读
github:https://github.com/zslomo
展开
-
Combination Sum题解
题干: Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number原创 2016-02-01 22:46:21 · 509 阅读 · 0 评论 -
3Sum Closest题解
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly原创 2016-01-31 22:00:37 · 523 阅读 · 0 评论 -
Two sum题解
题干: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, whe原创 2016-01-31 21:20:45 · 391 阅读 · 0 评论 -
4 sum题解(K sum)
题干: Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: Elements in a原创 2016-02-01 21:30:37 · 829 阅读 · 0 评论 -
Implement Trie (Prefix Tree)
这里没有按照顺序更新,首先是因为做过了很多题,但是回头看看有些题解还是忘了,写博客是为了回顾,并且当初做题的时候有些题目自己不是很懂,网上找的要么乱七八糟要么是纯英文或者纯代码,看起来很费劲,所以想自己整理一下,也帮助后来者少走一些弯路 这道题是自己实现一个数据结构:trie,字典树,或者叫前缀树,很重要,并且在非中文的信息检索中应用广泛,但是大学期间却没有讲过,更不要提实现,而且可能很多同学跟我原创 2016-02-01 00:27:12 · 500 阅读 · 0 评论 -
3 sums题解
题干: Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: Elements in a triplet (a,b,c) must原创 2016-01-31 21:34:50 · 492 阅读 · 0 评论 -
Word Search II 题解
题目:Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those hori原创 2016-02-10 15:34:19 · 592 阅读 · 1 评论 -
Combination Sum III 题解
题目:Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Ensure that numbers with原创 2016-02-10 13:57:45 · 429 阅读 · 0 评论 -
Combination Sum II 题解
题目:Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the combinatio原创 2016-02-06 18:18:51 · 495 阅读 · 0 评论 -
N-Queens 题解
题目The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.Given an integer n, return all distinct solutions to the n-queens puzzle.Each sol原创 2016-02-06 00:26:46 · 829 阅读 · 0 评论 -
N-Queens II 经典问题:8皇后问题 题解
题目上一篇我们使用了回溯法,然而提到回溯法就不得不提一个1848年提出的经典题目:8皇后问题,这个问题描述非常简单,一个8*8的棋盘上,放置8个皇后,使得每个皇后都不行相互攻击,既每个皇后的所在行、所在列、所在斜线上都不能有其他皇后,问有多少种解法,题目初看非常像图论问题,实际上也确实是,对图论感兴趣的同学可以去看离散数学的相关内容,这里我们用一种更巧妙也更直观的方法来解决这个问题,那就是——回溯法原创 2016-02-06 00:15:24 · 2865 阅读 · 0 评论