随笔分类 - LeetCode
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. For example, Given [10, 9, 2, 5, 3, 7, 101, 18], The longest i
阅读全文
摘要:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston
阅读全文
摘要: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, giv
阅读全文
摘要:Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12,
阅读全文
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. Note: Your algorithm should run
阅读全文
摘要:Write a program to find the n th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5,
阅读全文
摘要:Given a non negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the process is like:
阅读全文
摘要:Given a binary tree, return all root to leaf paths. Note: A leaf is a node with no children. Example:
阅读全文
摘要:Given two strings s and t, write a function to determine if t is an anagram of s. For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t
阅读全文
摘要:Invert a binary tree. Trivia: This problem was inspired by this "original tweet" by "Max Howell" : Google: 90% of our engineers use the software you w
阅读全文
摘要:Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area. For example, given the following ma
阅读全文
摘要: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
阅读全文
摘要:Reverse a singly linked list.
阅读全文
摘要:Note: This is an extension of "House Robber" . After robbing those houses on that street, the thief has found himself a new place for his thievery so
阅读全文
摘要:Write an algorithm to determine if a number is “happy”. A happy number is a number defined by the following process: Starting with any positive intege
阅读全文
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo
阅读全文
摘要:Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may comple
阅读全文
摘要:Related to question "Excel Sheet Column Title" Given a column title as appear in an Excel sheet, return its corresponding column number. For example:
阅读全文
摘要: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 the
阅读全文
摘要:Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example:
阅读全文

浙公网安备 33010602011771号