![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
抱着嫦娥烤月兔
面朝大海,春暖花开
展开
-
Leetcode 203. Remove Linked List Elements
Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5题意:删除给定值的链表元素。 题解:简单题,唯一值得注意的是给定值分别出现在head原创 2016-10-21 11:35:31 · 411 阅读 · 0 评论 -
Leetcode 82. Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1->1->2原创 2016-10-21 11:39:21 · 292 阅读 · 0 评论 -
Leetcode 94. Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], 1 \ 2 / 3 return [1,3,2]. 题意:中序遍历二叉树 题解:用递归的方法很容易求解,但是对于大原创 2016-11-04 17:04:34 · 368 阅读 · 0 评论 -
Leetcode 263-264 ugly number
Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it in原创 2016-10-25 21:58:55 · 278 阅读 · 0 评论 -
Leetcode 338. Counting Bits
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.Example: For num = 5 you sh原创 2016-10-27 21:58:11 · 321 阅读 · 0 评论 -
Leetcode 237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, t原创 2016-10-21 10:57:39 · 275 阅读 · 0 评论 -
算法之美
算法之美 标签(空格分隔): Leetcode 算法 时间复杂度 过完年刚回实验室,回归状态之余,随便在Leetcode上选了道简单的算法题目,accept虽然容易,但是如果考虑到时间复杂度的话,还是值得小酌一二,在这里与诸君分享。 题目选自Leetcode第441题, Arrange coins。题目概述如下,给你n枚硬币,你要堆积起k层,使得每一层的硬币数量为k枚,给出的例子...原创 2018-03-01 16:36:12 · 492 阅读 · 0 评论 -
Next Greater Element--关于栈的妙用
Next Greater Element–关于栈的妙用 标签(空格分隔): Leetcode 数据结构 近来在复习Leetcode上的经典题目时,发现有些题目借助栈这个简单的数据结构,能有非常巧妙地解法,直接让时间复杂度从O(n2)O(n2)O(n^2)下降到O(n)O(n)O(n),让人惊叹不已,算法的世界真是太奇妙了!废话少说,直接上题,这里直接给出Next Greater Ele...原创 2018-03-05 22:19:43 · 260 阅读 · 0 评论