题:https://leetcode.com/problems/delete-operation-for-two-strings/description/ 题目 Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 the same, where in
树的直径:一棵树中两个点间的最长距离。 Description The city consists of intersections and streets that connect them. Heavy snow covered the city so the mayor Milan gave to the winter-service a list of streets that ha
Given a string, find the length of the longest substring T that contains at most 2 distinct characters. For example,Given s = “eceba”, T is "ece" which its length is 3. 思路:同向双指针,跟Longest Substrin
一、原题 链接:Training on Two to One | Codewars Take 2 strings s1 and s2 including only letters from a to z. Return a new sorted string (alphabetical ascending), the longest possible, containing distinct
第一次在csdn上写备忘录,以前一直是在笔记本上写,主要是笔记本上可以随意写,只要自己能看懂,在网页上多少都受些限制,另外一方面也是想锻炼下写作能力,为以后的论文做基础吧!最近偶尔上leetcode练些题目,所以也就以这个为主题写一篇试试看,因为能力不足,理解或言辞上会有错误,还望访者不吝赐教,我定当万分感激。 好了,废话也说完了,现在进入正题: 题目: There are two sor
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 用归并排序的思想。 /*** Definition for singly-linked list.* str
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 该方法的核心是将原问题转变成一个寻找第k小数的问
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 解题分析: 对于此题目,应该先加一个头结点,然后依次比较两个有序的 list 然后将比较,将小的连接
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1->1->2->3->4->4
问题描述: Given an integer, write a function to determine if it is a power of two. 问题分析: 每一个2的幂,都是大于0的整数,且转换成二进制时,里面1的个数只有一个。 过程详见代码: class Solution {public:bool isPowerOfTwo(int n) {int cou
Description Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Solution 将两个有序链表合并成一个链表。(定义一个头结点,方便返回) /**
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 【算法思路】 搜了一下