随笔分类 - leetcode
https://leetcode.com/problemset/all/
摘要:Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column ind
阅读全文
摘要:Given an array A of integers, for each integer A[i] we may choose any x with K
阅读全文
摘要:On a 2 dimensional grid with R rows and C columns, we start at (r0, c0) facing east. Here, the north west corner of the grid is at the first row and c
阅读全文
摘要:Given a non empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 20 / \ 15 7 Outp
阅读全文
摘要:Given an n ary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example, given a 3 ary tree:
阅读全文
摘要:On a N N grid, we place some 1 1 1 cubes that are axis aligned with the x, y, and z axes. Each value v = grid[i][j] represents a tower of v cubes plac
阅读全文
摘要: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
阅读全文
摘要: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 num
阅读全文
摘要:Given a non empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input
阅读全文
摘要:Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R = L). You might
阅读全文
摘要:Given a directed, acyclic graph of N nodes. Find all possible paths from node 0 to node N 1, and return them in any order. The graph is given as follo
阅读全文
摘要:Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or
阅读全文
摘要:Implement a basic calculator to evaluate a simple expression string. The expression string contains only non negative integers, +, , , / operators and
阅读全文
摘要:Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix. Note that it is th
阅读全文
摘要: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.
阅读全文
摘要: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
阅读全文
摘要:Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solution = new Solution(nu
阅读全文
摘要:Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero. To make pro
阅读全文
摘要:Given a table salary, such as the one below, that has m=male and f=female values. Swap all f and m values (i.e., change all f values to m and vice ver
阅读全文
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating
阅读全文

浙公网安备 33010602011771号