
leetcode
solejay
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode 腾讯精选练习(50 题)557.反转字符串中的单词 III
原题目 Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest...原创 2019-06-28 20:46:38 · 138 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)141.环形链表
原题目 Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tai...原创 2019-06-11 08:51:25 · 144 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)136.只出现一次的数字
原题目 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...原创 2019-06-09 23:43:23 · 188 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)124.二叉树中的最大路径和
原题目 Given a non-empty binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child conne...原创 2019-06-09 23:37:39 · 157 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)217.存在重复元素
原题目 Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every eleme...原创 2019-06-19 09:27:57 · 131 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)215.数组中的第K个最大元素
原题目 Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. Example 1: Input: [3,2,1,5,6,4] and k = 2 Output: 5 ...原创 2019-06-19 09:22:53 · 113 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)206.反转链表
原题目 Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up: A linked list can be reversed either iteratively or recursi...原创 2019-06-19 09:12:42 · 170 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)88.合并两个有序数组
原题目 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume ...原创 2019-06-03 09:29:23 · 271 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)78.子集
原题目 Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution set must not contain duplicate subsets. Example: Input: nums = [1,2,3] Output: [ [3], [...原创 2019-06-02 20:29:28 · 196 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)122.买卖股票的最佳时机 II
原题目 Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., bu...原创 2019-06-07 20:53:20 · 283 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)59.螺旋矩阵 II
原题目 Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. Example: Input: 3 Output: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ] 思路 第一遍解法 网上好的解法 ...原创 2019-05-29 16:16:43 · 141 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)89.格雷编码
原题目 The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence o...原创 2019-06-04 18:49:25 · 189 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)104.二叉树的最大深度
原题目 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 chil...原创 2019-06-04 19:15:30 · 172 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)155.最小栈
原题目 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...原创 2019-06-16 23:16:30 · 265 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)344.反转字符串
原题目 Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array i...原创 2019-06-28 20:42:29 · 130 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)292.Nim 游戏
原题目 You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will b...原创 2019-06-28 20:32:43 · 234 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)238.除自身以外数组的乘积
原题目 Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i]. Example: Input: [1,2,3,4] Output...原创 2019-06-28 20:28:14 · 184 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)237.删除链表中的节点
原题目 Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. Given linked list – head = [4,5,1,9], which looks like following: Example 1: Input: h...原创 2019-06-28 20:24:59 · 145 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)236.二叉树的最近公共祖先
原题目 Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two node...原创 2019-06-28 20:22:09 · 205 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)235.二叉搜索树的最近公共祖先
原题目 Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betw...原创 2019-06-28 20:19:32 · 162 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)231.2的幂
原题目 Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: Input: 16 Output: true Explanation: 24 = 16 Example 3: ...原创 2019-06-23 09:42:52 · 165 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)230.二叉搜索树中第K小的元素
原题目 Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST’s total elements. Example 1: Input: root = [3,...原创 2019-06-23 09:24:30 · 170 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)169.求众数
原题目 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 ...原创 2019-06-16 23:21:20 · 147 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)160.相交链表
原题目 Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to intersect at node c1. Example 1: Input: inter...原创 2019-06-16 23:18:46 · 166 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)70.爬楼梯
原题目 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 top? Note: Given n will be a posit...原创 2019-06-01 16:09:55 · 159 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)62.不同路径
原题目 A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach th...原创 2019-06-01 15:19:39 · 248 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)121.买卖股票的最佳时机
原题目 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 sto...原创 2019-06-06 16:45:14 · 220 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)43.字符串相乘
原题目 Given two non-negative integers num1 and num2represented as strings, return the product of num1 and num2, also represented as a string. Example 1: Input: num1 = "2", num2 = "3" Output: "6" Examp...原创 2019-05-25 21:16:54 · 153 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)21.合并两个有序链表
原题目 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->4 Output: ...原创 2019-05-21 21:05:32 · 142 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)2.寻找两个有序数组的中位数
原题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 an...原创 2019-05-11 20:40:00 · 142 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)33.搜索旋转排序数组
原题目 Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). You are given a target value to search. If fou...原创 2019-05-24 20:59:38 · 188 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)20.有效的括号
有效的括号 原题目 Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same...原创 2019-05-20 23:14:19 · 148 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)6.回文数
原题目 Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Expla...原创 2019-05-15 20:11:57 · 137 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)1. 两数相加
原题目 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 ret...原创 2019-05-10 17:32:02 · 231 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)5.字符串转换整数(atoi)
原题目 Implement atoi which converts a string to an integer. The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from...原创 2019-05-14 21:39:55 · 123 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)16.最接近的三数之和
原题目 Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input w...原创 2019-05-19 22:00:34 · 174 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)4.整数反转
原题目 Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing ...原创 2019-05-13 21:13:27 · 161 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)11. 盛最多水的容器
原题目 Given n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find ...原创 2019-05-16 21:42:13 · 160 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)46.全排列
原题目 Given a collection of distinct integers, return all possible permutations. Example: Input: [1,2,3] Output: [ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1] ] 思路 第一遍解法 网上好的解法 #...原创 2019-05-26 21:37:49 · 155 阅读 · 0 评论 -
leetcode 腾讯精选练习(50 题)148.排序链表
原题目 Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1-&...原创 2019-06-13 08:42:09 · 173 阅读 · 0 评论