LeetCode
文章平均质量分 94
擦肩的阳光
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Relative Ranks问题的两种实现
本文的题目是一道基础题(506题),基于排序问题,借此熟悉一下快排和冒泡及其使用,同时也能很明显地看出快排的优势。 题目内容 Description: Given scores of N athletes, find their relative ranks and the people with the top three highest scores, who will be原创 2017-02-19 19:56:43 · 493 阅读 · 0 评论 -
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 (ie, buy one and sell one share of the stock), d原创 2017-09-06 22:22:10 · 388 阅读 · 0 评论 -
1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same原创 2017-09-06 23:30:45 · 317 阅读 · 0 评论 -
643. Maximum Average Subarray I
Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output the maximum average value. Example 1: Input:原创 2017-09-07 22:11:51 · 300 阅读 · 0 评论 -
661. Image Smoother
class Solution { public int[][] imageSmoother(int[][] M) { int[][] ave = new int[M.length][M[0].length]; for (int i = 0; i < M.length; i++) { for (int j = 0; j < M[i]原创 2017-09-07 22:14:47 · 325 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Given a sorted array, 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 in place with原创 2017-09-08 14:38:44 · 233 阅读 · 0 评论 -
27. Remove Element
Given an array and a value, remove all instances of that value in place and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory.原创 2017-09-08 15:22:14 · 255 阅读 · 0 评论 -
605. Can Place Flowers
Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots - they would compete for water and both would die. Gi原创 2017-09-08 16:04:32 · 257 阅读 · 0 评论 -
581. Shortest Unsorted Continuous Subarray
Given an integer array, you need to find one continuous subarray that if you only sort this subarray in ascending order, then the whole array will be sorted in ascending order, too. You need to fin原创 2017-09-08 21:07:36 · 309 阅读 · 0 评论 -
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-原创 2018-01-11 11:16:55 · 211 阅读 · 0 评论 -
109. Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in which th原创 2018-01-09 18:49:54 · 475 阅读 · 0 评论 -
409. Longest Palindrome
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters. This is case sensitive, for example "Aa" is not con原创 2017-05-10 22:43:38 · 275 阅读 · 0 评论 -
242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = "anagram", t = "nagaram", return true. s = "rat", t = "car", return false. Note: You may ass原创 2017-05-10 22:23:25 · 315 阅读 · 0 评论 -
530. Minimum Absolute Difference in BST
//本文内容来自StarSight,欢迎访问。 Given a binary search tree with non-negative values, find the minimum absolute difference between values of any two nodes. Example: Input: 1 \ 3原创 2017-03-01 22:38:11 · 581 阅读 · 0 评论 -
504. Base 7
Given an integer, return its base 7 string representation. Example 1: Input: 100 Output: "202" Example 2: Input: -7 Output: "-10" Note: The input will be in range of [-1e7, 1e原创 2017-03-01 22:07:36 · 644 阅读 · 0 评论 -
349. Intersection of Two Arrays
//本文内容来自StarSight,欢迎访问。 Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: Each element in原创 2017-03-02 13:13:23 · 393 阅读 · 0 评论 -
387. First Unique Character in a String
//本文内容来自StarSight,欢迎访问。 Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "lovele原创 2017-03-02 14:48:05 · 299 阅读 · 0 评论 -
100. Same Tree
//本文内容来自StarSight,欢迎访问。 Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical and the nodes原创 2017-03-03 20:33:47 · 325 阅读 · 0 评论 -
237. Delete Node in a Linked List
//本文内容来自StarSight,欢迎访问。 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 ar原创 2017-03-03 20:36:42 · 394 阅读 · 0 评论 -
171. Excel Sheet Column Number
//本文内容来自StarSight,欢迎访问。 Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1原创 2017-03-03 20:55:16 · 283 阅读 · 0 评论 -
404. Sum of Left Leaves
Find the sum of all left leaves in a given binary tree. Example: 3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24原创 2017-03-03 21:12:34 · 460 阅读 · 0 评论 -
563. Binary Tree Tilt
Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtre原创 2017-05-10 21:43:35 · 423 阅读 · 0 评论 -
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原创 2017-05-10 22:08:12 · 284 阅读 · 0 评论 -
美团点评2018 CodeM资格赛(Java语言)
题目一 美团在吃喝玩乐等很多方面都给大家提供了便利。最近又增加了一项新业务:小象生鲜。这是新零售超市,你既可以在线下超市门店选购生鲜食品,也可以在手机App上下单,最快30分钟就配送到家。 新店开张免不了大优惠。我们要在小象生鲜超市里采购n个物品,每个物品价格为ai,有一些物品可以选择八折优惠(称为特价优惠)。 有m种满减优惠方式,满减优惠方式只有在所有物品都不选择特价优惠时才能使用,且最多...原创 2018-05-28 23:51:52 · 1070 阅读 · 0 评论
分享