240
It works on my machine
摘要: 问题描述 给定一个链表,要求翻转其中从m到n位上的节点,返回新的头结点。 Example Input: 1 2 3 4 5 NULL, m = 2, n = 4 Output: 1 4 3 2 5 NULL 分析 这题解法比较直接,可以定义一个fakeNode, 首先拼接 1 到 m 1的节点, 然 阅读全文
posted @ 2019-11-26 14:29 禾码大叔 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 问题描述 给定一个整数数组,返回range sum 落在给定区间[lower, upper] (包含lower和upper)的个数。range sum S(i, j) 表示数组中第i 个元素到j 个元素之和。 Note : A naive algorithm of O(n2) is trivial. 阅读全文
posted @ 2019-11-24 09:54 禾码大叔 阅读(386) 评论(0) 推荐(0) 编辑
摘要: 问题 给定一个二叉树的root节点,二叉树中每个节点有node.val个coins,一种有N coins。 现在要求移动节点中的coins 使得二叉树最终每个节点的coins value都为1。每次移动,我们只能向相邻接点移动,也就是说coins 只能向父节点或者子节点移动,那么求最终需要移动多少步 阅读全文
posted @ 2019-11-17 12:40 禾码大叔 阅读(418) 评论(0) 推荐(0) 编辑
摘要: 问题描述 在一个班级里有N个同学, 有些同学是朋友,有些不是。他们之间的友谊是可以传递的比如A和B是朋友,B和C是朋友,那么A和C也是朋友。我们定义 friend circle为由直接或者间接都是朋友组成的group. 给定N N 数组 M 代表同学之间的关系. 如果M[i][j] = 1, 那么i 阅读全文
posted @ 2019-11-14 14:25 禾码大叔 阅读(386) 评论(0) 推荐(2) 编辑
摘要: 问题描述 在IT技术面试过程中,我们经常会遇到生产者消费者问题(Producer-consumer problem), 这是多线程并发协作问题的经典案例。场景中包含三个对象,生产者(Producer),消费者(Consumer)以及一个固定大小的缓冲区(Buffer)。生产者的主要作用是不断生成数据 阅读全文
posted @ 2019-11-12 17:16 禾码大叔 阅读(3020) 评论(1) 推荐(4) 编辑
摘要: 问题描述 给定一个数组,数组中的数不重复,且均大于1。要求使用数组中的数构建二叉树,每个数字可以被重复使用,除了叶子节点,每个节点的值等于其子节点的乘积,求构建二叉树的数量,返回的结果mod 10 9 + 7 Example 1: Input: Output: 3 Explanation: We c 阅读全文
posted @ 2019-11-12 17:08 禾码大叔 阅读(259) 评论(0) 推荐(1) 编辑
摘要: 问题描述 ~~~ Example1: x = 123, return 321 Example2: x = 123, return 321 ~~~ 原题链接: https://leetcode.com/problems/reverse integer/ 解决方案 ~~~ public int reve 阅读全文
posted @ 2017-05-29 05:03 禾码大叔 阅读(195) 评论(0) 推荐(0) 编辑
摘要: Given a string, find the length of the longest substring without repeating characters. Examples ~~~ Given "abcabcbb", the answer is "abc", which the l 阅读全文
posted @ 2017-05-29 04:57 禾码大叔 阅读(252) 评论(0) 推荐(1) 编辑
摘要: The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font 阅读全文
posted @ 2017-05-29 04:55 禾码大叔 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 问题描述 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see b 阅读全文
posted @ 2017-05-29 04:53 禾码大叔 阅读(377) 评论(0) 推荐(0) 编辑