随笔分类 -  LeetCode

上一页 1 ··· 37 38 39 40 41 42 43 44 45 ··· 61 下一页
摘要:Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used. Note: Example 1: Example 2: 阅读全文
posted @ 2016-10-01 23:53 Grandyang 阅读(8639) 评论(7) 推荐(0) 编辑
摘要:Find the sum of all left leaves in a given binary tree. Example: 这道题让我们求一棵二叉树的所有左子叶的和,那么看到这道题我们知道这肯定是考二叉树的遍历问题,那么最简洁的写法肯定是用递归,由于我们只需要累加左子叶之和,那么我们在进入递归 阅读全文
posted @ 2016-09-30 13:40 Grandyang 阅读(9875) 评论(1) 推荐(0) 编辑
摘要: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 @ 2016-09-22 15:10 Grandyang 阅读(11216) 评论(6) 推荐(0) 编辑
摘要:Given an integer n, return the nth digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]. Example 1: Input: n = 3 Output: 3 阅读全文
posted @ 2016-09-21 10:59 Grandyang 阅读(13699) 评论(1) 推荐(1) 编辑
摘要:A frog is crossing a river. The river is divided into x units and at each unit there may or may not exist a stone. The frog can jump on a stone, but i 阅读全文
posted @ 2016-09-20 13:16 Grandyang 阅读(18683) 评论(13) 推荐(0) 编辑
摘要:Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The l 阅读全文
posted @ 2016-09-19 04:04 Grandyang 阅读(18238) 评论(4) 推荐(3) 编辑
摘要:Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given 阅读全文
posted @ 2016-09-17 23:59 Grandyang 阅读(18281) 评论(10) 推荐(2) 编辑
摘要:Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number m 阅读全文
posted @ 2016-09-15 21:45 Grandyang 阅读(14557) 评论(7) 推荐(0) 编辑
摘要:Given a positive integer n and you can do operations as follow: What is the minimum number of replacements needed for n to become 1? Example 1: Exampl 阅读全文
posted @ 2016-09-14 20:57 Grandyang 阅读(9108) 评论(6) 推荐(0) 编辑
摘要:Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a 阅读全文
posted @ 2016-09-13 21:02 Grandyang 阅读(8721) 评论(4) 推荐(2) 编辑
摘要:There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you reach 阅读全文
posted @ 2016-09-10 23:36 Grandyang 阅读(10355) 评论(3) 推荐(0) 编辑
摘要:Find the length of the longest substring T of a given string (consists of lowercase letters only) such that every character in T appears no less than 阅读全文
posted @ 2016-09-08 11:13 Grandyang 阅读(19324) 评论(19) 推荐(1) 编辑
摘要:Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is be 阅读全文
posted @ 2016-09-07 13:01 Grandyang 阅读(30250) 评论(12) 推荐(1) 编辑
摘要:A character in UTF8 can be from 1 to 4 bytes long, subjected to the following rules: This is how the UTF-8 encoding would work: Given an array of inte 阅读全文
posted @ 2016-09-06 23:22 Grandyang 阅读(13195) 评论(7) 推荐(1) 编辑
摘要: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 @ 2016-09-05 13:57 Grandyang 阅读(13533) 评论(3) 推荐(0) 编辑
摘要:Given N axis-aligned rectangles where N > 0, determine if they all together form an exact cover of a rectangular region. Each rectangle is represented 阅读全文
posted @ 2016-08-31 13:51 Grandyang 阅读(10134) 评论(8) 推荐(2) 编辑
摘要: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 @ 2016-08-28 23:57 Grandyang 阅读(10460) 评论(0) 推荐(0) 编辑
摘要:Suppose we abstract our file system by a string in the following manner: The string "dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext" represents: The director 阅读全文
posted @ 2016-08-25 13:55 Grandyang 阅读(14634) 评论(5) 推荐(1) 编辑
摘要: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 @ 2016-08-24 11:13 Grandyang 阅读(12790) 评论(5) 推荐(0) 编辑
摘要:Given an integer n, return 1 - n in lexicographical order. For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9]. Please optimize your algori 阅读全文
posted @ 2016-08-23 10:30 Grandyang 阅读(13403) 评论(2) 推荐(0) 编辑

上一页 1 ··· 37 38 39 40 41 42 43 44 45 ··· 61 下一页
Fork me on GitHub