LeetCode practice】的更多相关文章

子集和问题:给定一组数和一个值,从这组数中选出若干个数使其和为给定的值.这是个NPC问题. 1.https://leetcode.com/problems/counting-bits/#/solutions 给定一非负Integer num,求[0,num]每个数的二进制形式中1的个数  f[num+1]. 解法:可用最朴素的方法逐个求,但其实有规律: f[i] = f[i / ] + i % 或  f[i] = f[i&(i-)] + ; 2.Single Number:一组Integer类型…
目录 Leetcode题目解答 1. 删除最外层的括号 2. 两数之和 3. 宝石与石头 4. 移除元素 5.删除排序数组中的重复项 6.寻找两个有序数组的中位数 7.盛最多水的容器 8.存在重复元素 Leetcode题目解答 1. 删除最外层的括号 有效括号字符串为空("")."(" + A + ")" 或 A + B,其中 A 和 B 都是有效的括号字符串,+ 代表字符串的连接.例如,"","()",&…
1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: /** * Note: The returned array must be malloced, assume call…
Sept. 13, 2015 Spent more than a few hours to work on the leetcode problem, and my favorite blogs about this problems: 1. http://siddontang.gitbooks.io/leetcode-solution/content/tree/construct_binary_tree.html 2.http://blog.csdn.net/linhuanmars/artic…
This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as word2. Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. word1 and word2 may be…
This is a follow up of Shortest Word Distance. The only difference is now you are given the list of words and your method will be called repeatedly many times with different parameters. How would you optimize it? Design a class which receives a list…
Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list. For example,Assume that words = ["practice", "makes", "perfect", "coding", "makes"]. G…
August 7, 2015 周日玩这个算法, 看到Javascript Array模拟Deque, 非常喜欢, 想用C#数组也模拟; 看有什么新的经历. 试了四五种方法, 花时间研究C# SortedList class. Try to get some workout on the C# programming practice. 我的体会是代码写得太少,  要多读不同的代码, 多调试, 开阔对一个问题思考的思路和深度, 准确度, 实现能力. 1. Blog to read: http://…
June 22, 2015 Given a number represented as an array of digits, plus one to the number. Leetcode: plus one, 喜欢这道题, 看看有哪些解法; 一个个试过来. (6种方法) Read the web blogs, and then, try different solutions. practice using C#, the source code on github: https://gi…
July 19, 2015 Problem statement: Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be only one unique solution. Solution 1:  Great blog to read: http://…