Leetcode刷刷刷
Cecilia-Casper
这个作者很懒,什么都没留下…
展开
-
【每日一题Leetcode】101Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the...原创 2018-06-29 14:47:33 · 135 阅读 · 0 评论 -
【每日一题Leetcode】-136. Single Number
Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using ...原创 2018-07-12 16:34:15 · 203 阅读 · 0 评论 -
【每日一题Leetcode】9. Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -121Output: falseExpl...原创 2018-07-19 22:37:06 · 114 阅读 · 0 评论 -
【每日一题Leetcode】-2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return i...原创 2018-07-25 16:07:10 · 205 阅读 · 0 评论 -
【每日一题Leetcode】155. 最小 Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Ge...原创 2018-07-31 23:29:46 · 138 阅读 · 0 评论 -
【每日一题Leetcode】160. Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists:A: a1 → a2 ↘ ...原创 2018-08-23 12:29:13 · 113 阅读 · 0 评论 -
【每日一题Leetcode】-169. Majority Element
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element alwa...原创 2018-08-24 12:31:01 · 127 阅读 · 0 评论 -
【leetcode】13. Roman to Integer-levle:simple
描述:将罗马数字转成整数原创 2019-03-30 21:42:17 · 101 阅读 · 0 评论 -
【leetcode】14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Input: ["flower","flow","flight"]Output:...原创 2019-04-01 18:08:47 · 128 阅读 · 0 评论 -
【每日一题Leetcode】7. Reverse Integer
不太喜欢这个题,主要考虑的点是溢出问题。Given a 32-bit signed integer, reverse digits of an integer.Example 1:Input: 123Output: 321Example 2:Input: -123Output: -321Example 3:Input: 120Output: 21N...原创 2018-07-18 12:25:58 · 95 阅读 · 0 评论 -
【每日一题leetcode】-141 Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?由于最开始没有弄清楚链表中循环可以从任何位置开始,判断条件是是否tail的值等于head。但是这个题是判断一个链表中是否存在有环,因此这个循环的起始位置是未知的。所以改变了思...原创 2018-07-23 15:00:00 · 110 阅读 · 0 评论 -
【每日一题Leedcode】121. Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), d...原创 2018-07-04 16:33:47 · 132 阅读 · 0 评论 -
【每日一题Leetcode】LeetCode-3. Longest Substring Without Repeating Characters
给刷题日常换个窝 搬自https://zhuanlan.zhihu.com/p/36340355今天的题目是给定一个字符串,返回无重复字符的最长子串Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "b", with the length of 1....原创 2018-06-25 14:33:36 · 76 阅读 · 0 评论 -
【每日一题Leetcode】Valid Parentheses
继续搬https://zhuanlan.zhihu.com/p/36414513Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets ...原创 2018-06-25 14:38:17 · 101 阅读 · 0 评论 -
【每日一题leetcode】Search Insert Position
继续把知乎发的挪到这里https://zhuanlan.zhihu.com/p/38404527题目:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in o...原创 2018-06-25 14:40:01 · 84 阅读 · 0 评论 -
【每日一题leetcode】Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1->1...原创 2018-06-25 14:40:39 · 135 阅读 · 0 评论 -
【每日一题leetcode】53. Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Explan...原创 2018-06-25 17:54:54 · 200 阅读 · 0 评论 -
【每日一题Leetcode】104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no children.Ex...原创 2018-07-02 13:35:32 · 91 阅读 · 0 评论 -
【每日一题leetcode】70 Climbing Stairs
这道题花了蛮久时间,刚开始接触DP,需要多一些思维训练。 题目: **You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the t...原创 2018-06-27 17:18:56 · 647 阅读 · 0 评论 -
【每日一题Leetcode】100. Same Tree
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value.Example 1:In...原创 2018-06-28 16:39:34 · 101 阅读 · 0 评论 -
【leetcode】26. Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyi...原创 2019-04-01 21:23:34 · 125 阅读 · 0 评论