03 2019 档案

摘要:Given an integer, write a function to determine if it is a power of two. Example 1: Example 2: Example 3: 相关题 二进制中1的个数 LeetCode191 https://www.cnblogs 阅读全文
posted @ 2019-03-31 16:48 月半榨菜 阅读(103) 评论(0) 推荐(0)
摘要:Write a function that takes an unsigned integer and return the number of '1' bits it has (also known as the Hamming weight). Example 1: Example 2: Exa 阅读全文
posted @ 2019-03-31 16:38 月半榨菜 阅读(139) 评论(0) 推荐(0)
摘要:Given a positive integer num, write a function which returns True if num is a perfect square else False. Note: Do not use any built-in library functio 阅读全文
posted @ 2019-03-31 15:53 月半榨菜 阅读(135) 评论(0) 推荐(0)
摘要:Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an in 阅读全文
posted @ 2019-03-31 15:32 月半榨菜 阅读(135) 评论(0) 推荐(0)
摘要:Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Empty cells are indica 阅读全文
posted @ 2019-03-29 17:39 月半榨菜 阅读(162) 评论(0) 推荐(0)
摘要:Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: A partially filled sudoku which 阅读全文
posted @ 2019-03-29 17:36 月半榨菜 阅读(79) 评论(0) 推荐(0)
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the 阅读全文
posted @ 2019-03-29 15:08 月半榨菜 阅读(105) 评论(0) 推荐(0)
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all 阅读全文
posted @ 2019-03-29 14:59 月半榨菜 阅读(122) 评论(0) 推荐(0)
摘要:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: 相 阅读全文
posted @ 2019-03-26 11:44 月半榨菜 阅读(87) 评论(0) 推荐(0)
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2019-03-26 11:02 月半榨菜 阅读(115) 评论(0) 推荐(0)
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3 阅读全文
posted @ 2019-03-26 10:37 月半榨菜 阅读(81) 评论(0) 推荐(0)
摘要:At a lemonade stand, each lemonade costs $5. Customers are standing in a queue to buy from you, and order one at a time (in the order specified by bil 阅读全文
posted @ 2019-03-25 21:36 月半榨菜 阅读(74) 评论(0) 推荐(0)
摘要:Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a g 阅读全文
posted @ 2019-03-25 21:13 月半榨菜 阅读(80) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2019-03-25 21:00 月半榨菜 阅读(152) 评论(0) 推荐(0)
摘要:Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. Strings consists of lowercase English letters only and the 阅读全文
posted @ 2019-03-25 20:17 月半榨菜 阅读(326) 评论(0) 推荐(0)
摘要:Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Example 2: Example 3: Note: -100.0 < x < 100.0 n is a 32-bit signed int 阅读全文
posted @ 2019-03-25 15:46 月半榨菜 阅读(119) 评论(0) 推荐(0)
摘要:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes 阅读全文
posted @ 2019-03-25 11:32 月半榨菜 阅读(127) 评论(0) 推荐(0)
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia 阅读全文
posted @ 2019-03-25 10:56 月半榨菜 阅读(140) 评论(0) 推荐(0)
摘要:Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文
posted @ 2019-03-25 10:31 月半榨菜 阅读(138) 评论(0) 推荐(0)
摘要:Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique q 阅读全文
posted @ 2019-03-22 18:59 月半榨菜 阅读(124) 评论(0) 推荐(0)
摘要:Given an array nums of n integers, are there elements a, b, c in nums such that a + b+ c = 0? Find all unique triplets in the array which gives the su 阅读全文
posted @ 2019-03-22 17:12 月半榨菜 阅读(147) 评论(0) 推荐(0)
摘要:Given an array of strings, group anagrams together. Example: Note: All inputs will be in lowercase. The order of your output does not matter. 针对每个字符串, 阅读全文
posted @ 2019-03-22 10:26 月半榨菜 阅读(139) 评论(0) 推荐(0)
摘要:Given two strings s and t , write a function to determine if t is an anagram of s. Example 1: Example 2: Note:You may assume the string contains only 阅读全文
posted @ 2019-03-21 21:09 月半榨菜 阅读(145) 评论(0) 推荐(0)
摘要:Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k num 阅读全文
posted @ 2019-03-20 21:18 月半榨菜 阅读(135) 评论(0) 推荐(0)
摘要:Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. 阅读全文
posted @ 2019-03-20 17:24 月半榨菜 阅读(122) 评论(0) 推荐(0)
摘要:Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. to 阅读全文
posted @ 2019-03-20 15:26 月半榨菜 阅读(111) 评论(0) 推荐(0)
摘要:Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front 阅读全文
posted @ 2019-03-20 15:20 月半榨菜 阅读(134) 评论(0) 推荐(0)
摘要:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k is a positive integer and is less than or equal to 阅读全文
posted @ 2019-03-20 10:45 月半榨菜 阅读(98) 评论(0) 推荐(0)
摘要:Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use 阅读全文
posted @ 2019-03-19 20:37 月半榨菜 阅读(152) 评论(0) 推荐(0)
摘要:Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer pos which represents the posi 阅读全文
posted @ 2019-03-19 19:45 月半榨菜 阅读(150) 评论(0) 推荐(0)
摘要:Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be ch 阅读全文
posted @ 2019-03-19 16:03 月半榨菜 阅读(120) 评论(0) 推荐(0)