随笔分类 -  LeetCode

摘要:题目:求数组子集 Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example,I 阅读全文
posted @ 2016-08-17 20:01 zhangbaochong 阅读(236) 评论(0) 推荐(0) 编辑
摘要:题目: Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ B 阅读全文
posted @ 2016-08-16 13:03 zhangbaochong 阅读(239) 评论(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 阅读全文
posted @ 2016-08-16 11:48 zhangbaochong 阅读(239) 评论(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 neare 阅读全文
posted @ 2016-08-16 11:14 zhangbaochong 阅读(175) 评论(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 tre 阅读全文
posted @ 2016-08-16 10:55 zhangbaochong 阅读(181) 评论(0) 推荐(0) 编辑
摘要:题目: Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32- 阅读全文
posted @ 2016-08-15 18:18 zhangbaochong 阅读(133) 评论(0) 推荐(0) 编辑
摘要:题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 分类:Tree Depth-first Search 代码: 阅读全文
posted @ 2016-08-15 11:16 zhangbaochong 阅读(225) 评论(0) 推荐(0) 编辑
摘要:题目: Given an integer, write a function to determine if it is a power of three. Follow up:Could you do it without using any loop / recursion? 分类:Math 代 阅读全文
posted @ 2016-08-14 22:29 zhangbaochong 阅读(150) 评论(0) 推荐(0) 编辑
摘要:题目: Given an integer, write a function to determine if it is a power of two. 判断是否是2的次方数 分类:Math Bit Manipulation 代码: 阅读全文
posted @ 2016-08-14 21:46 zhangbaochong 阅读(145) 评论(0) 推荐(0) 编辑
摘要:题目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can yo 阅读全文
posted @ 2016-08-14 19:53 zhangbaochong 阅读(204) 评论(0) 推荐(0) 编辑
摘要:题目: Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order r 阅读全文
posted @ 2016-08-12 18:57 zhangbaochong 阅读(165) 评论(0) 推荐(0) 编辑
摘要:题目: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last 阅读全文
posted @ 2016-08-11 10:33 zhangbaochong 阅读(189) 评论(0) 推荐(0) 编辑
摘要:题目:字符串匹配 Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 分类:String Two P 阅读全文
posted @ 2016-08-10 23:19 zhangbaochong 阅读(181) 评论(0) 推荐(0) 编辑
摘要:题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: 阅读全文
posted @ 2016-08-10 16:48 zhangbaochong 阅读(153) 评论(0) 推荐(0) 编辑
摘要:题目: Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may a 阅读全文
posted @ 2016-08-10 16:29 zhangbaochong 阅读(218) 评论(0) 推荐(0) 编辑
摘要:题目: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read 阅读全文
posted @ 2016-08-09 23:31 zhangbaochong 阅读(178) 评论(0) 推荐(0) 编辑
摘要:题目: Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Given s = "hello", return "holle". Example 2:Give 阅读全文
posted @ 2016-08-09 23:05 zhangbaochong 阅读(152) 评论(0) 推荐(0) 编辑
摘要:题目: Given two binary strings, return their sum (also a binary string). For example,a = "11"b = "1"Return "100". 分类:String Math 代码: 阅读全文
posted @ 2016-08-09 22:30 zhangbaochong 阅读(212) 评论(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 el 阅读全文
posted @ 2016-08-06 12:52 zhangbaochong 阅读(199) 评论(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 eleme 阅读全文
posted @ 2016-08-06 11:51 zhangbaochong 阅读(151) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示