随笔分类 - LeetCode
摘要:Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums =
阅读全文
摘要:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.
阅读全文
摘要:You need to construct a binary tree from a string consisting of parenthesis and integers. The whole input represents a binary tree. It contains an int
阅读全文
摘要:Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects
阅读全文
摘要:Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subt
阅读全文
摘要:Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of
阅读全文
摘要:Think about Zuma Game. You have a row of balls on the table, colored red(R), yellow(Y), blue(B), green(G), and white(W). You also have several balls i
阅读全文
摘要:Given a picture consisting of black and white pixels, and a positive integer N, find the number of black pixels located at some specific row R and col
阅读全文
摘要:Given a picture consisting of black and white pixels, find the number of black lonely pixels. The picture is represented by a 2D char array consisting
阅读全文
摘要:There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r), but it
阅读全文
摘要:You are given a string representing an attendance record for a student. The record only contains the following three characters: A student could be re
阅读全文
摘要:There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolling up, down, left or right, but it won't stop roll
阅读全文
摘要:Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is gre
阅读全文
摘要: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
阅读全文
摘要:There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. Yo
阅读全文
摘要:There are N students in a class. Some of them are friends, while some are not. Their friendship is transitive in nature. For example, if A is a direct
阅读全文
摘要:Given a list of strings, you need to find the longest uncommon subsequence among them. The longest uncommon subsequence is defined as the longest subs
阅读全文
摘要:In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring", and use the dial to s
阅读全文
摘要:Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defi
阅读全文
摘要:Given two strings representing two complex numbers. You need to return a string representing their multiplication. Note i2 = -1 according to the defin
阅读全文