
leetcode
海的来信
这个作者很懒,什么都没留下…
展开
-
Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array. 问题描述:给两个有序的整型数组A和B,A数组长度为m,B数组长度为n,前提假设A有足够大的空间去容纳B。 解决思路:分别给A和B两个指针i和j,当前指向A数组的指针指向的数值大于当前指向B数组的指针的情况下,让A整个数组往后移,将B指原创 2013-11-28 18:54:41 · 4369 阅读 · 0 评论 -
Merge Two Sorted Lists
题目描述: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. 首先拿到这道题目的时候,我觉得挺简单的,严蔚敏那本数据结构里面有这样的一个例题,我原创 2013-11-28 14:26:31 · 5374 阅读 · 2 评论 -
Remove Element
Given an array and a value, remove all instances of that value in place and return the new length. The order of elements can be changed. It doesn't matter what you leave beyond the new length. 问原创 2013-12-14 20:08:23 · 616 阅读 · 0 评论 -
leetcode Sort Colors java实现
描述:给一个数组,数组由三种颜色对象组成,分别为红、白、蓝,对数组进行排序,使相同颜色的对象相邻,按照先红再白最后蓝的顺序进行排列。 在这里,我们使用整数0、1、2来分别代表红白蓝三种颜色。(不要使用库函数) 在这里我介绍一种方法不是很普及,但是这种方法的时间复杂度是0(n)。public class Solution { public void sortColors(int[] A)原创 2014-03-06 15:00:29 · 2023 阅读 · 0 评论 -
leetcode Length of Last Word java实现
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string. If the last word does not exist, return 0. Note: A word is defin原创 2014-03-06 14:26:49 · 2184 阅读 · 1 评论 -
leetcode Swap Nodes in Pairs java实现
描述:Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1->2->3->4, you should return the list as 2->1->4->3. Your algorithm原创 2014-03-07 12:17:26 · 2481 阅读 · 0 评论 -
ReOrder List java实现
Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do this in-place without altering the nodes' values. For example, Given {1,2,3,4}, reorder it to转载 2014-03-18 16:23:07 · 1583 阅读 · 0 评论 -
771. 宝石与石头
题目要求: 给定字符串J 代表石头中宝石的类型,和字符串 S代表你拥有的石头。 S 中每个字符代表了一种你拥有的石头的类型,你想知道你拥有的石头中有多少是宝石。 J 中的字母不重复,J 和 S中的所有字符都是字母。字母区分大小写,因此"a"和"A"是不同类型的石头。 注意: S 和 J 最多含有50个字母。 J 中的字符不重复。 题目很简单,需要考虑边界问题: 第一,判断字符串J和S...原创 2018-09-12 11:55:47 · 241 阅读 · 0 评论