摘要: 题目:Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The 阅读全文
posted @ 2018-05-27 22:28 pathjh 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题目:在两个排序数组中寻找第K小的数 举例: arr1=[1,2,3,4,5],arr2=[3,4,5],k=1 1是所有数中第一小的数,所以返回1 arr1=[1,2,3],arr2=[3,4,5,6],k=4 3是所有数中第4小的数,所以返回3 要求:如果arr1的长度为N,arr2的长度为M, 阅读全文
posted @ 2018-05-27 21:33 pathjh 阅读(4176) 评论(0) 推荐(1) 编辑
摘要: 题目:Longest Palindromic Substring Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. E 阅读全文
posted @ 2018-05-27 15:18 pathjh 阅读(113) 评论(0) 推荐(0) 编辑
摘要: 题目:Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Examples: Giv 阅读全文
posted @ 2018-05-26 22:33 pathjh 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 题目:Add Two Numbers You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of 阅读全文
posted @ 2018-05-26 17:02 pathjh 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 题目描述 Implement regular expression matching with support for'.'and'*'. '.' Matches any single character. '*' Matches zero or more of the preceding elem 阅读全文
posted @ 2018-05-16 01:07 pathjh 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 一个简单的题,复习一下KMP 对于两个字符串A,B。请设计一个高效算法,找到B在A中第一次出现的起始位置。若B未在A中出现,则返回-1。 给定两个字符串A和B,及它们的长度lena和lenb,请返回题目所求的答案。 测试样例: 总结一下,kmp算法的核心就在于next[]数组,如果不用next[]数 阅读全文
posted @ 2018-05-07 01:04 pathjh 阅读(375) 评论(0) 推荐(0) 编辑
摘要: 对于一个字符串,请设计一个高效算法,计算其中最长回文子串的长度。 给定字符串A以及它的长度n,请返回最长回文子串的长度。 测试样例: "abc1234321ab",12 返回:7 1 import java.util.*; 2 //法1:动态规划 时间复杂度O(n^2),空间复杂度O(n^2) 3 阅读全文
posted @ 2018-04-11 20:01 pathjh 阅读(420) 评论(0) 推荐(0) 编辑
摘要: 总结:对于二叉树的常见问题: 当涉及到按层序遍历,对二叉树进行各种操作时,常常采用栈或队列来对每一层数据进行保存 收获:对做题时常用的结构的方法进行了一下简要总结 1.Queue Queue: 基本上,一个队列就是一个先入先出(FIFO)的数据结构 Queue接口与List、Set同一级别,都是继承 阅读全文
posted @ 2018-03-31 00:47 pathjh 阅读(305) 评论(0) 推荐(0) 编辑
摘要: 1.构造器总是伴随着new操作符的执行而被调用,而不能对一个已经存在的对象调用构造器来达到重新设置实例域的目的。 2.静态域与静态方法 如果将类定义为static,每一个类只有一个这样的域。静态域是属于类的,而不属于任何独立的对象,其又被称为类域。 静态方法是一种不能向对象实施操作的方法,但是他可以 阅读全文
posted @ 2018-03-28 22:03 pathjh 阅读(305) 评论(0) 推荐(0) 编辑