随笔分类 - leetcode
摘要:Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: (1)思想1:使用queue ,对二叉树进行层遍历。 C++:
阅读全文
摘要:Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo
阅读全文
摘要:Given a 32-bit signed integer, reverse digits of an integer. Example 1: Example 2: Example 3: Note:Assume we are dealing with an environment which cou
阅读全文
摘要:Determine whether an integer is a palindrome. Do this without extra space. Some hints: Could negative integers be palindromes? (ie, -1) If you are thi
阅读全文
摘要:Given a non-empty integer array, find the minimum number of moves required to make all array elements equal, where a move is incrementing a selected e
阅读全文
摘要:Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n
阅读全文
摘要:A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128
阅读全文
摘要:Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no such solution, return -1. For
阅读全文
摘要:Initially, there is a Robot at position (0, 0). Given a sequence of its moves, judge if this robot makes a circle, which means it moves back to the or
阅读全文
摘要:Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red,
阅读全文
摘要:Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [-2,1,-3,4,-1,2,
阅读全文
摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: You
阅读全文
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f
阅读全文
摘要:Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 给定一个m × n矩阵,如果一个元素为0,则将其整个行和列设置为0。 (1)思想1:用两个一维数组:flag_r
阅读全文
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). Write
阅读全文
摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You a
阅读全文

浙公网安备 33010602011771号