OJ
不识字的朔
这个作者很懒,什么都没留下…
展开
-
感觉好猛的一道异或题
题目描述给定整数m以及n各数字A1,A2,..An,将数列A中所有元素两两异或,共能得到n(n-1)/2个结果,请求出这些结果中大于m的有多少个。输入描述:第一行包含两个整数n,m. 第二行给出n个整数A1,A2,...,An。数据范围对于30%的数据,1 对于100%的数据,1 输出描述:输出仅包括一行,即所求的答案示例1输入原创 2017-08-17 14:46:46 · 266 阅读 · 0 评论 -
【贪心】最大的矩阵
题目描述Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.被这题虐的不轻快,感觉贪心也不总是那么简单的。我的思路是硬暴力求解,四重循环,着实垃圾。题解区大神的思路,参考leetcode L原创 2017-08-29 11:06:33 · 286 阅读 · 0 评论 -
【DP】格雷码
题目描述The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequ原创 2017-08-28 19:11:14 · 273 阅读 · 0 评论 -
【DP】编辑距离
题目描述Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations pe原创 2017-08-28 15:40:36 · 180 阅读 · 0 评论 -
【DP】交叉组合
题目描述Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 ="aabcc",s2 ="dbbca",When s3 ="aadbbcbcac", return true.When s3 ="aadbbbaccc", r原创 2017-08-28 11:20:23 · 443 阅读 · 0 评论 -
【DP】一共有多少种走法
题目描述A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is tr原创 2017-08-27 20:32:14 · 350 阅读 · 0 评论 -
【DP】子串的种类数
题目描述Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by del原创 2017-08-27 18:49:39 · 299 阅读 · 0 评论 -
【DP】三角形中的最短路径长度
题目描述Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,原创 2017-08-27 16:25:14 · 447 阅读 · 0 评论 -
【DP】回文的最小分割数2
要把DP练好!题目描述Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s ="aab",Return原创 2017-08-27 15:31:08 · 190 阅读 · 0 评论 -
单链表的归并排序
/** * Definition for singly-linked list. * class ListNode { * int val; * ListNode next; * ListNode(int x) { * val = x; * next = null; * } * } */public class原创 2017-08-22 22:56:06 · 179 阅读 · 0 评论 -
【DP】回文的最小分割数
题目描述Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For example, given s = "aab",原创 2017-08-24 19:38:56 · 551 阅读 · 0 评论 -
DFS解决组合题目
题目描述输入两个整数 n 和 m,从数列1,2,3.......n 中随意取几个数,使其和等于 m ,要求将其中所有的可能组合列出来输入描述:每个测试输入包含2个整数,n和m输出描述:按每个组合的字典序排列输出,每行输出一种组合示例1输入5 5输出1 42 35import java.util.*;原创 2017-08-18 20:25:27 · 310 阅读 · 0 评论 -
【DP】leetcode292 Nim Game
一段非常有趣的对于这道题目的版本演变过程....先上题目:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one w原创 2017-10-10 09:53:05 · 280 阅读 · 0 评论