http://www.cnblogs.com/charlesblc/p/6384132.html

继续过Hard模式的题目吧。

  # Title Editorial Acceptance Difficulty Frequency 
 。 65 Valid Number     12.6% Hard  
 。 126 Word Ladder II     13.6% Hard  
 。 149 Max Points on a Line     15.6% Hard  
 。 146 LRU Cache     16.0% Hard  
 。 68 Text Justification     18.1% Hard  
 。 460 LFU Cache     19.0% Hard  
 。 44 Wildcard Matching     19.0% Hard  
 。 308 Range Sum Query 2D - Mutable     19.8% Hard  
 。 4 Median of Two Sorted Arrays     20.8% Hard  
 。 420 Strong Password Checker     21.0% Hard  
 。 273 Integer to English Words     21.1% Hard  
 。 30 Substring with Concatenation of All Words     21.7% Hard  
 。 440 K-th Smallest in Lexicographical Order     22.1% Hard  
 。 140 Word Break II     22.2% Hard  
 。 212 Word Search II     22.2% Hard  
 。 269 Alien Dictionary     22.3% Hard  
 。 174 Dungeon Game     22.9% Hard  
 。 214 Shortest Palindrome     23.0% Hard  
 。 446 Arithmetic Slices II - Subsequence     23.0% Hard  
 。 32 Longest Valid Parentheses     23.1% Hard  
 。 295 Find Median from Data Stream     23.3% Hard  
 。 132 Palindrome Partitioning II     23.4% Hard  
 。 10 Regular Expression Matching     23.6% Hard  
 。 76 Minimum Window Substring     23.8% Hard  
 。 188 Best Time to Buy and Sell Stock IV     23.8% Hard  
 。 321 Create Maximum Number     23.9% Hard  
 。 135 Candy     23.9% Hard  
 。 335 Self Crossing     23.9% Hard  
 。 97 Interleaving String     23.9% Hard  
 。 391 Perfect Rectangle     24.2% Hard  
  158 Read N Characters Given Read4 II - Call multiple times     24.4% Hard  
  466 Count The Repetitions     24.6% Hard  
  336 Palindrome Pairs     24.7% Hard  
  41 First Missing Positive     24.9% Hard  
  124 Binary Tree Maximum Path Sum     25.0% Hard  
  224 Basic Calculator     25.5% Hard  
  218 The Skyline Problem     25.5% Hard  
  84 Largest Rectangle in Histogram     25.6% Hard  
  23 Merge k Sorted Lists     25.9% Hard  
  45 Jump Game II     26.0% Hard  
  85 Maximal Rectangle     26.1% Hard  
  57 Insert Interval     26.3% Hard  
  138 Copy List with Random Pointer     26.6% Hard  
  233 Number of Digit One     27.3% Hard  
  381 Insert Delete GetRandom O(1) - Duplicates allowed     28.0% Hard  
  37 Sudoku Solver     28.1% Hard  
  432 All O`one Data Structure     28.2% Hard  
  87 Scramble String     28.3% Hard  
  123 Best Time to Buy and Sell Stock III     28.3% Hard  
  56 Merge Intervals     28.4% Hard  
  282 Expression Add Operators     28.5% Hard  
  316 Remove Duplicate Letters     28.6% Hard  
  164 Maximum Gap     28.6% Hard  
  99 Recover Binary Search Tree     28.7% Hard  
  327 Count of Range Sum     28.9% Hard  
  51 N-Queens     29.0% Hard  
  25 Reverse Nodes in k-Group     29.7% Hard  
  472 Concatenated Words     30.1% Hard  
  465 Optimal Account Balancing     30.1% Hard  
  248 Strobogrammatic Number III     30.5% Hard  
  72 Edit Distance     30.6% Hard  
  115 Distinct Subsequences     30.6% Hard  
  403 Frog Jump     30.9% Hard  
  411 Minimum Unique Word Abbreviation     31.1% Hard  
  239 Sliding Window Maximum     31.4% Hard  
  330 Patching Array     31.5% Hard  
  297 Serialize and Deserialize Binary Tree     31.6% Hard  
  354 Russian Doll Envelopes     31.8% Hard  
  358 Rearrange String k Distance Apart     31.8% Hard  
  33 Search in Rotated Sorted Array     31.9% Hard  
  363 Max Sum of Rectangle No Larger Than K     32.1% Hard  
  410 Split Array Largest Sum     32.2% Hard  
  480 Sliding Window Median     33.1% Hard  
  317 Shortest Distance from All Buildings     33.3% Hard  
  117 Populating Next Right Pointers in Each Node II     33.5% Hard  
  315 Count of Smaller Numbers After Self     33.5% Hard  
  301 Remove Invalid Parentheses     34.5% Hard  
  42 Trapping Rain Water     35.3% Hard  
  128 Longest Consecutive Sequence     35.3% Hard  
  329 Longest Increasing Path in a Matrix     35.4% Hard  
  407 Trapping Rain Water II     35.6% Hard  
  154 Find Minimum in Rotated Sorted Array II     36.2% Hard  
  265 Paint House II     37.1% Hard  
  272 Closest Binary Search Tree Value II     37.6% Hard  
  291 Word Pattern II     37.7% Hard  
  305 Number of Islands II     38.1% Hard  
  380 Insert Delete GetRandom O(1)     38.4% Hard  
  145 Binary Tree Postorder Traversal     38.4% Hard  
  340 Longest Substring with At Most K Distinct Characters     38.6% Hard  
  352 Data Stream as Disjoint Intervals     38.9% Hard  
  159 Longest Substring with At Most Two Distinct Characters     39.7% Hard  
  312 Burst Balloons     41.6% Hard  
  287 Find the Duplicate Number     41.8% Hard  
  425 Word Squares     41.9% Hard  
  52 N-Queens II     42.8% Hard  
  302 Smallest Rectangle Enclosing Black Pixels     44.0% Hard  
  471 Encode String with Shortest Length     44.2% Hard  
  296 Best Meeting Point     50.4% Hard
97 Interleaving String     23.9% Hard

这道题目很好,是使用DP的典型方案。可惜我开始还是没能做出来。Discuss的解法非常好。好好学习。

bool isInterleave(string s1, string s2, string s3) {

    if(s3.length() != s1.length() + s2.length())
return false; bool table[s1.length()+][s2.length()+]; for(int i=; i<s1.length()+; i++)
for(int j=; j< s2.length()+; j++){
if(i== && j==)
table[i][j] = true;
else if(i == )
table[i][j] = ( table[i][j-] && s2[j-] == s3[i+j-]);
else if(j == )
table[i][j] = ( table[i-][j] && s1[i-] == s3[i+j-]);
else
table[i][j] = (table[i-][j] && s1[i-] == s3[i+j-] ) || (table[i][j-] && s2[j-] == s3[i+j-] );
} return table[s1.length()][s2.length()];
}
391 Perfect Rectangle     24.2% Hard

这道题目很难。而这个解法,真是太巧了。

两个基本点:一是总面积等于各个区域面积之和;另一个是所有的点出现偶数次,除了四个角上面的点。

												

练练脑,继续过Hard题目的更多相关文章

  1. 练练脑javascript写直接插入排序和冒泡排序

    function insertionSort(array) { if (Object.prototype.toString.call(array).slice(8, -1) === 'Array') ...

  2. 新手入门JUnit单元测试

    首先将JUnit插件安装到Eclipse或myeclipse里面,编写完一个模块或者实体类的时候,直接右击,new一个JUnit项目,选择你想测试的实体类(模块),然后会自动生成一个类,这个类,我们将 ...

  3. [codevs 1995]黑魔法师之门(并查集)

    题目:http://codevs.cn/problem/1995/ 分析:脑补一下满足题目要求的子图肯定就是环……于是题目就变成了不断加边求环的个数.看起来有点麻烦……但是环的实质是几个小环组合起来的 ...

  4. leetcode面试准备:Reverse Words in a String

    leetcode面试准备:Reverse Words in a String 1 题目 Given an input string, reverse the string word by word. ...

  5. HDU 1010Tempter of the Bone(奇偶剪枝回溯dfs)

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  6. luogu P3565 [POI2014]HOT-Hotels

    传送门 无脑暴力+O2=AC 题目要统计距离两两相等的三个点的组数,这三个点之间显然有一个点,并且这三个点到这个点的距离都相同.所以枚举中间这个点作为根,然后bfs整棵树,对于每一层,把以根的某个儿子 ...

  7. leetcode的Hot100系列--序

    小白程序猿,练练手,做做题目,分享下经验, 有不对的,还请大家能够指出,多多包涵!谢谢!! 先简单,后复杂,循序渐进,希望能够坚持下来, 大家一起进步~~

  8. 《剑指offer》算法题第三天

    今日题目: 斐波那契数列 青蛙跳台阶问题(及其变种:变态跳台阶) 矩形覆盖 旋转数组的最小数字 矩阵中的路径 机器人的运动范围 细心的同学会发现,第1,2,3题其实对应的是<剑指>书上的同 ...

  9. 【动态规划】DP搬运工3

    UPD:修了点锅(啊昨天居然写脑抽了) 题目内容 给定两个长度为 \(n\) 的序列,定义 \(magic(A,B)=\sum\limits_{i=1}^n \max(A_i,B_i)\). 现在给定 ...

随机推荐

  1. six.moves的用法

    six是用来兼容python 2 和 3的,我猜名字就是用的2和3的最小公倍数. six.moves 是用来处理那些在2 和 3里面函数的位置有变化的,直接用six.moves就可以屏蔽掉这些变化 P ...

  2. 继续过Hard题目.0209

    http://www.cnblogs.com/charlesblc/p/6372971.html 继续过Hard模式的题目吧.   # Title Editorial Acceptance Diffi ...

  3. android AppWidget的使用以及利用TimerTask实现widget的定时更新

    第一步:首先是Widget的定义声明: 在资源文件下的xml目录中建立文件example_appwidget_info.xml: <?xml version="1.0" en ...

  4. _DataStructure_C_Impl:AOE网的关键路径

    //_DataStructure_C_Impl:CriticalPath #include<stdio.h> #include<stdlib.h> #include<st ...

  5. 例说Linux内核链表(三)

    经常使用的linux内核双向链表API介绍 linux link list结构图例如以下: 内核双向链表的在linux内核中的位置:/include/linux/list.h 使用双向链表的过程,主要 ...

  6. page template in kentico

    Ad-hoc templates are used for one page only, for which they were created - this is why they are not ...

  7. hdoj--2579--Dating with girls(2)(搜索+三维标记)

    Dating with girls(2) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  8. xBIM 学习与应用系列目录

        xBIM 实战04 在WinForm窗体中实现IFC模型的加载与浏览   xBIM 实战03 使用WPF技术实现IFC模型的加载与浏览   xBIM 实战02 在浏览器中加载IFC模型文件并设 ...

  9. python 3.x 学习笔记17(协程以及I/O模式)

    1.协程(微线程)协程是一种用户态的轻量级线程.协程拥有自己的寄存器上下文和栈.协程调度切换时,将寄存器上下文和栈保存到其他地方,在切回来的时候,恢复先前保存的寄存器上下文和栈.因此: 协程能保留上一 ...

  10. 新手配置vux

    1.首先跟平常一样创建一个vue的项目 2.开始配置vux 第一步 安装vux npm install vux --save 第二步  安装vux-loader npm install vux-loa ...