摘要: A binary watch has 4 LEDs on the top which represent the hours (0 11), and the 6 LEDs on the bottom represent the minutes (0 59). Each LED represents 阅读全文
posted @ 2018-12-03 22:12 A-Little-Nut 阅读(136) 评论(0) 推荐(0)
摘要: Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case English letters in both s and t. t is po 阅读全文
posted @ 2018-12-03 22:10 A-Little-Nut 阅读(83) 评论(0) 推荐(0)
摘要: Given two strings s and t which consist of only lowercase letters. String t is generated by random shuffling string s and then add one more letter at 阅读全文
posted @ 2018-12-03 22:09 A-Little-Nut 阅读(127) 评论(0) 推荐(0)
摘要: Given a string, find the first non repeating character in it and return it’s index. If it doesn’t exist, return 1. Examples: Note: You may assume the 阅读全文
posted @ 2018-12-03 22:08 A-Little-Nut 阅读(141) 评论(0) 推荐(0)
摘要: Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the rans 阅读全文
posted @ 2018-12-03 22:07 A-Little-Nut 阅读(120) 评论(0) 推荐(0)
摘要: You are given a list of non negative integers, a1, a2, …, an, and a target, S. Now you have 2 symbols + and . For each integer, you should choose one 阅读全文
posted @ 2018-12-03 22:05 A-Little-Nut 阅读(158) 评论(0) 推荐(0)
摘要: Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive integer target. 阅读全文
posted @ 2018-12-03 22:04 A-Little-Nut 阅读(100) 评论(0) 推荐(0)
摘要: A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文
posted @ 2018-12-03 22:02 A-Little-Nut 阅读(123) 评论(0) 推荐(0)
摘要: We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wron 阅读全文
posted @ 2018-12-03 22:00 A-Little-Nut 阅读(157) 评论(0) 推荐(0)
摘要: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and . Example: Given a = 1 and b = 2, return 3. 阅读全文
posted @ 2018-12-03 21:52 A-Little-Nut 阅读(67) 评论(0) 推荐(0)
摘要: Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or 阅读全文
posted @ 2018-12-03 21:50 A-Little-Nut 阅读(102) 评论(0) 推荐(0)
摘要: Given a non negative integer n, count all numbers with unique digits, x, where 0 ≤ x Given n = 2, return 91. (The answer should be the total numbers i 阅读全文
posted @ 2018-12-03 21:46 A-Little-Nut 阅读(102) 评论(0) 推荐(0)
摘要: Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: + Each ele 阅读全文
posted @ 2018-12-03 21:45 A-Little-Nut 阅读(93) 评论(0) 推荐(0)
摘要: Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]. Note: + Each elemen 阅读全文
posted @ 2018-12-03 21:43 A-Little-Nut 阅读(79) 评论(0) 推荐(0)
摘要: Write a function that takes a string as input and returns the string reversed. Example: Given s = “hello”, return “olleh”. 分析 Easy 阅读全文
posted @ 2018-12-03 21:42 A-Little-Nut 阅读(102) 评论(0) 推荐(0)
摘要: Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum pro 阅读全文
posted @ 2018-12-03 21:41 A-Little-Nut 阅读(108) 评论(0) 推荐(0)
摘要: Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and r 阅读全文
posted @ 2018-12-03 21:39 A-Little-Nut 阅读(99) 评论(0) 推荐(0)
摘要: You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee 阅读全文
posted @ 2018-12-03 21:38 A-Little-Nut 阅读(170) 评论(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 @ 2018-12-03 21:37 A-Little-Nut 阅读(128) 评论(0) 推荐(0)
摘要: Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2 阅读全文
posted @ 2018-12-03 21:36 A-Little-Nut 阅读(135) 评论(0) 推荐(0)
摘要: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Note: 1: You may assume that the array 阅读全文
posted @ 2018-12-03 21:34 A-Little-Nut 阅读(103) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 21:33 A-Little-Nut 阅读(129) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 21:31 A-Little-Nut 阅读(104) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:21 A-Little-Nut 阅读(129) 评论(0) 推荐(0)
摘要: 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, 阅读全文
posted @ 2018-12-03 15:20 A-Little-Nut 阅读(124) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:19 A-Little-Nut 阅读(119) 评论(0) 推荐(0)
摘要: 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, 阅读全文
posted @ 2018-12-03 15:17 A-Little-Nut 阅读(120) 评论(0) 推荐(0)
摘要: 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: 阅读全文
posted @ 2018-12-03 15:16 A-Little-Nut 阅读(110) 评论(0) 推荐(0)
摘要: Given a binary tree, return all root to leaf paths. Note: A leaf is a node with no children. Example: 阅读全文
posted @ 2018-12-03 15:15 A-Little-Nut 阅读(93) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:12 A-Little-Nut 阅读(112) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:11 A-Little-Nut 阅读(103) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:09 A-Little-Nut 阅读(135) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:08 A-Little-Nut 阅读(142) 评论(0) 推荐(0)
摘要: Reverse a singly linked list. 阅读全文
posted @ 2018-12-03 15:07 A-Little-Nut 阅读(100) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:06 A-Little-Nut 阅读(106) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:04 A-Little-Nut 阅读(207) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2018-12-03 15:02 A-Little-Nut 阅读(149) 评论(0) 推荐(0)