题目: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2-&g…
分类:LeetCode
LeetCode算法题-Poor Pigs(Java实现)
这是悦乐书的第235次更新,第248篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第102题(顺位题号是455)。有1000个水桶,其中只有一个水桶含有毒药,其余的都没毒。它们看起来都一样。…
二刷257. Binary Tree Paths
Easy题 但是一开始不知为什么选择了StringBuilder没选String, 而且总觉得要backtracking. 要记得初始化一个string可以用String path = root.val + "", 就是…
[LeetCode] Reverse Words in a String III 翻转字符串中的单词之三
Given a string, you need to reverse the order of characters in each word within a sentence while still …
046 Permutations[M]
1 题目描述 Given a collection of distinct numbers, return all possible permutations. 难度:Medium 2 题目样例 For example,…
[LintCode] Number of Islands
Problem Given a boolean 2D matrix, find the number of islands. Notice 0 is represented as the sea, 1 is repres…
算法: Dungeon Game
Dungeon Game 计算出二维数组从0.0 点到 m.n 点的最小代价.. 并且每经过一个格子所剩余的代价必须是> 0 的 class Solution { public: int calculateMini…
2018-07-16
13. Roman to Integer 题目描述: 罗马数字包含以下七种字符:I, V, X, L,C,D 和 M。 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数…
[Leetcode]22. 括号生成
题目描述: 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合。 例如,给出 n = 3,生成结果为: [ “((()))”, “(()())…
Leetcode 127. Word Ladder
Given two words (beginWord and endWord), and a dictionary’s word list, find the length of shortest trans…
Leetcode 161. One Edit Distance
Given two strings S and T, determine if they are both one edit distance apart. 思路: 两个字符串是否只通过一步变换(替换、删除、增加)就变成…
[LeetCode By Go 56]504. Base 7
题目 Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: “202” …