
leetcode刷题记录
文章平均质量分 77
玦尘
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
汉明距离的求解
题目来源:点击打开链接题目描述:The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hammi原创 2017-04-11 16:47:27 · 478 阅读 · 0 评论 -
二叉树递归问题
题目来源:点击打开链接题目描述:Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and原创 2017-04-26 14:14:17 · 341 阅读 · 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.解决历程:这道题没有做出来,拿到题目的时候有点懵,不用转载 2017-04-25 17:09:22 · 376 阅读 · 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 a random positi原创 2017-04-24 20:21:20 · 874 阅读 · 0 评论 -
找二进制表示中1的数量的方法
题目来源:点击打开链接题目描述: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-bit integer ’11' ha原创 2017-05-24 14:59:24 · 463 阅读 · 0 评论 -
两道有意思的leetcode数学题
问题来源:点击打开链接问题描述:Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.转载 2017-05-03 15:30:23 · 432 阅读 · 0 评论 -
寻找数组中多余元素
题目来源:点击打开链接问题描述:Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this arra原创 2017-04-20 13:43:35 · 354 阅读 · 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 greed factor gi,原创 2017-05-02 17:02:26 · 605 阅读 · 0 评论 -
寻找数组中的缺失元素
题目来源:点击打开链接问题描述:Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that原创 2017-04-20 11:06:21 · 1173 阅读 · 0 评论 -
single number问题
问题来源:点击打开链接问题描述:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could yo原创 2017-04-19 14:42:33 · 313 阅读 · 0 评论 -
下一个大数的问题
问题来源:点击打开链接问题描述:You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in原创 2017-04-15 16:24:08 · 510 阅读 · 0 评论 -
string反转问题
问题来源:点击打开链接问题描述:Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".我的解决方案(2种):class Solution {public:原创 2017-04-14 14:29:47 · 255 阅读 · 0 评论 -
整型转换成string的问题
题目来源:点击打开链接题目描述:Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the m原创 2017-04-14 13:49:34 · 1021 阅读 · 0 评论 -
二维数组求周长的问题
问题来源:点击打开链接问题描述:You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diag原创 2017-04-18 17:18:33 · 463 阅读 · 0 评论 -
最大连续数字长度
问题来源:点击打开链接问题描述:Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the la原创 2017-04-18 15:30:20 · 496 阅读 · 0 评论 -
键盘行单词求解
题目来源:点击打开链接题目描述:Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below.Example 1:原创 2017-04-13 15:43:58 · 376 阅读 · 0 评论 -
部分反转string
题目来源:点击打开链接题目描述:Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example 1:In原创 2017-04-12 14:57:09 · 343 阅读 · 0 评论 -
按位反转的求解
题目来源:点击打开链接题目描述:Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note:The given integer is guarant原创 2017-04-11 19:26:54 · 848 阅读 · 0 评论 -
整型转string
本题是进制转换,本身是没啥难度,记录在这里主要是提醒自己记住一个C++的STL函数题目来源:点击打开链接问题描述:Given an integer, return its base 7 string representation.Example 1:Input: 100Output: "202"Example 2:原创 2017-05-19 17:18:04 · 465 阅读 · 0 评论