07 2018 档案
摘要:[抄题]: Given a linked list, swap every two adjacent nodes and return its head. Example: Note: Your algorithm should use only constant extra space. You
阅读全文
摘要:[抄题]: Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Example 2: [暴力解法]: 时间分析: 空间分
阅读全文
摘要:[抄题]: Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You m
阅读全文
摘要:[抄题]: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 总算自己写出一道题来了。 [英文数据结构或算法,为什么不用别的数据结构或算法]: [一句话思路]: 总有case过不了,可以稍微调试一下,起
阅读全文
摘要:[抄题]: Given an input string, reverse the string word by word. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 打碎成数组
阅读全文
摘要:[抄题]: Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[
阅读全文
摘要:[抄题]: Given an input string , reverse the string word by word. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: [英文数
阅读全文
摘要:[抄题]: Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length of s is 1000. Example 1:Input:
阅读全文
摘要:[抄题]: Given a string, sort it in decreasing order based on the frequency of characters. Example 1: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇
阅读全文
摘要:[抄题]: Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. E
阅读全文
摘要:[抄题]: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析:
阅读全文
摘要:[抄题]: 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 tot
阅读全文
摘要:[抄题]: public MyHashMap() { 主函数里面是装非final变量的,如果没有,可以一个字都不写 } [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: put: 不论如何都要放。所以如果没有bucke
阅读全文
摘要:🔸《第周contest做出来了题》 🔸《第周contest做出来了题》 🔸《第周contest做出来了题》 🔸《第周contest做出来了题》 🔸《第周contest做出来了题》 🔸《第周contest做出来了题》 🔸《第周contest做出来了题》 🔸《第周contest做出来了题
阅读全文
摘要:[抄题]: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Example 2: [暴力解法]
阅读全文
摘要:[抄题]: Example 2: Example 3: Example 4: Example 5: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: 根本不知道应该怎么处理越界啊: 先设置一个bound
阅读全文
摘要:[抄题]: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set
阅读全文
摘要:[抄题]: Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. word1 and word2 may be th
阅读全文
摘要:[抄题]: Numbers can be regarded as product of its factors. For example, Write a function that takes an integer n and return all possible combinations of
阅读全文
摘要:[抄题]: Given a binary tree, collect a tree's nodes as if you were doing this: Collect and remove all leaves, repeat until the tree is empty. Example:Gi
阅读全文
摘要:[抄题]: Design a max stack that supports push, pop, top, peekMax and popMax. Example 1: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]
阅读全文
摘要:[抄题]: You need to find the largest value in each row of a binary tree. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问
阅读全文
摘要:[抄题]: Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a lis
阅读全文
摘要:[抄题]: Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip
阅读全文
摘要:[抄题]: Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into knon-empty subsets whose sums are
阅读全文
摘要:[抄题]: Design a class which receives a list of words in the constructor, and implements a method that takes two words word1 and word2 and return the sh
阅读全文
摘要:[抄题]: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes usef
阅读全文
摘要:[抄题]: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or ano
阅读全文
摘要:[抄题]: Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Exampl
阅读全文
摘要:[抄题]: Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => true Note: It is intended f
阅读全文
摘要:[抄题]: Given n points on a 2D plane, find the maximum number of points that lie on the same straight line. Example 1: Example 2: [暴力解法]: 时间分析: 空间分析: [优
阅读全文
摘要:[抄题]: Shuffle a set of numbers without duplicates. Example: [暴力解法]: 时间分析: 空间分析: [优化后]: 时间分析: 空间分析: [奇葩输出条件]: [奇葩corner case]: [思维问题]: [英文数据结构或算法,为什么不用
阅读全文
摘要:[抄题]: Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square bracket
阅读全文
摘要:[抄题]: Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of conn
阅读全文
摘要:Sum类的题目一般这样: input: nums[], target output: satisfied arrays/ lists/ number 拿到题目,首先分析: 1. 是几个数的sum 2. sum是要求等于target还是小于还是大于还是closest 3. 返回的是原数组下标还是其他
阅读全文
摘要:计算机的基本任务之一。 举例来说,有一个字符串"BBC ABCDAB ABCDABCDABDE",我想知道,里面是否包含另一个字符串"ABCDABD"? 许多算法可以完成这个任务,Knuth-Morris-Pratt算法(简称KMP)是最常用的之一。它以三个发明者命名,起头的那个K就是著名科学家Do
阅读全文

浙公网安备 33010602011771号