代码: 1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 bool isValid(string s) { 8 map smap; 9 smap.insert(make_pair('(', ')'));10...
分类:
其他好文 时间:
2015-04-15 11:19:22
阅读次数:
159
Write a method anagram(s,t) to decide if two strings are anagrams or not.ExampleGiven s="abcd", t="dcab", return trueO(N)time, O(1) space 1 public cla...
分类:
其他好文 时间:
2015-04-15 07:12:54
阅读次数:
104
题目链接:Validate Binary Search Tree
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 only nodes with ...
分类:
其他好文 时间:
2015-04-14 21:41:20
阅读次数:
118
/*给一个不完整的数独,'.'代表为空判断数独是否合法*/public class Solution { public boolean check1(char[][] board){ for(int i = 0 ; i < 9 ; i ++){ int[] ...
分类:
其他好文 时间:
2015-04-14 16:13:00
阅读次数:
108
Given a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses substring.For"(()", the longest...
分类:
其他好文 时间:
2015-04-14 14:35:10
阅读次数:
121
Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ...
分类:
其他好文 时间:
2015-04-14 14:15:23
阅读次数:
108
Valid Pattern LockTime Limit:2 Seconds Memory Limit:65536 KBPattern lock security is generally used in Android handsets instead of a password. The pat...
分类:
其他好文 时间:
2015-04-13 22:51:31
阅读次数:
144
这道题目是队友写的,貌似是用暴力枚举出来。题意:给出一组数,要求这组数在解锁的界面可能的滑动序列。思路:按照是否能够直接到达建图,如1可以直接到2,但是1不能直接到3,因为中间必须经过一个2。要注意的假如2已结访问过,那么1就可以直接到2。建图DFS,图要更新。Source Code:#includ...
分类:
其他好文 时间:
2015-04-13 22:22:32
阅读次数:
140
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3861题意:给出一组数,要求这组数在解锁的界面可能的滑动序列。思路:按照是否能够直接到达建图,如1可以直接到2,但是1不能直接到3,因为中间必须经过一个2。要注意的假...
分类:
其他好文 时间:
2015-04-13 20:45:24
阅读次数:
126
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
分类:
其他好文 时间:
2015-04-13 18:23:52
阅读次数:
105