随笔分类 - Leetcode解题报告
摘要:描述 Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1,
阅读全文
摘要:描述 In LLP world, there is a hero called Teemo and his attacking can make his enemy Ashe be in poisoned condition. Now, given the Teemo's attacking asc
阅读全文
摘要:描述 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. For e
阅读全文
摘要:描述 Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one
阅读全文
摘要:描述 You are given a string representing an attendance record for a student. The record only contains the following three characters: 'A' : Absent. 'L'
阅读全文
摘要:描述 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 分析 先构造一个链表结点 dummyH
阅读全文
摘要:描述 Reverse a singly linked list. 分析 一开始写的时候总感觉没抓到要点,然后想起上数据结构课的教材上有这道题,翻开书一看完就回忆起来了,感觉解法挺巧妙的,不比讨论区的答案差。 这道题是放在链栈后面的,用的也是链栈的思想: 依次将原来栈中的元素出栈,并插入到初值为空的另
阅读全文
摘要:描述 Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 分析 这道题没做出来。。 逛了评论区才写出来的,代码写得很简洁 http
阅读全文
摘要:描述 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
阅读全文
摘要:描述 Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. 分析 先构造了一个杨辉三角,然后返回这个杨辉三角的最后一组值,没超时就万事大吉了
阅读全文
摘要:描述 Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1
阅读全文
摘要:描述 Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The funct
阅读全文
摘要:描述 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
阅读全文
摘要:描述 Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].
阅读全文
摘要:描述 Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and t
阅读全文
摘要:描述 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
阅读全文
摘要:描述 Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0,
阅读全文
摘要:描述 Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non zero elements. For example,
阅读全文
摘要:描述 Given a non empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time compl
阅读全文
摘要:描述 Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two
阅读全文

浙公网安备 33010602011771号