随笔分类 - LeetCode
摘要:question: try: result: 22.58% conclusion: dm
阅读全文
摘要:question: try: result: conclusion: 对这个题无语。 一开始我在想暴力法,先找到所有substring,再找最长的那个。但是好复杂。 看了讨论区,一个人说这是愚人节的题目。。才找到思路。。
阅读全文
摘要:question: try: result: re-try: result: conclusion: 效率很低,n2. 看讨论区里的posts,发现主要问题在于对于n和n+1,我的方法是重新计算n+1是否good,浪费。如果使用dp,可以利用n是否good这个结论,从而降低复杂度。 讨论区里面还有一
阅读全文
摘要:question: 分析: 先根遍历 try: result: conclusion:
阅读全文
摘要:question: first: result: Submission Detail 46 / 46 test cases passed. Status: Accepted Runtime: 26 ms Submitted: 0 minutes ago 46 / 46 test cases pass
阅读全文
摘要:question: first: result: second: result: conclusion:
阅读全文
摘要:Problem: try: result: 想当然! second: result: 被这个stupid的问题卡了好久。。因为leetcode的编辑器没有数据类型的关键字高亮提示,所以把这个问题忽略了,int是不能作为变量名称使用的。 re-try: result: 分析: 用LinkedHashM
阅读全文
摘要:problem: 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 wh
阅读全文
摘要: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. E
阅读全文
摘要:problem: first: result: second try: result: 换成StringBuffer,效果竟然一样?? 3nd: result: 可见,用数组代替string和StringBuffer或StringBuilder会更快。 4th: result: conclusion
阅读全文
摘要:problem: first: result: Submission Result: Wrong Answer Input: "RLUURDDDLU" Output: false 2: result: 参考答案: result: retry: result: conclusion: 可见把Strin
阅读全文
摘要:problem: 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
阅读全文
摘要:问题: 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
阅读全文
摘要:问题: 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,
阅读全文
摘要:question: question: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Example 1 Ex
阅读全文
摘要: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 arr
阅读全文
摘要:Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements. Your t
阅读全文
摘要:问题: We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11
阅读全文
摘要:问题: 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 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.
阅读全文