自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(22)
  • 收藏
  • 关注

原创 Remove Duplicates from Sorted Array

Remove Duplicates from Sorted Array

2017-02-27 20:12:02 189

原创 Binary Tree Preorder Traversal

Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3].Note: Recursive solution is trivial,

2016-08-05 09:33:09 185

原创 Valid Anagram

Given two strings s and t, write a function to determine if t is an anagram of s.For example, s = “anagram”, t = “nagaram”, return true. s = “rat”, t = “car”, return false.Note: You may assume the s

2016-08-03 10:19:52 208

原创 Top K Frequent Element

Given a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].Note: You may assume k is always valid, 1 ≤ k ≤ number of unique ele

2016-08-01 06:27:28 172

原创 Same Tree

Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.利用递归便可轻松解决/** * De

2016-08-01 06:24:03 142

原创 Intersection of Two Arrays

Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: Each element in the result must be unique. The result can be in

2016-08-01 06:22:04 128

原创 Product of Array Except Self

Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n).For e

2016-08-01 06:16:49 205

原创 数据结构(java)----BinarySearchTree

写一个BST的java语言实现import org.omg.CORBA.UserException;public class BinarySearchTree<AnyType extends Comparable<? super AnyType>> { private static class BinaryNode<AnyType> { BinaryNode(Any

2016-08-01 06:11:42 261

原创 数据结构(java)---MyLinkedList

看着书自己写了一遍linkedlist,以及其中的迭代器的实现

2016-07-24 11:20:25 268

原创 数据结构(java)----MyArrayList

最近看的书叫“数据结构与算法分析,java语言描述”,里面有讲到各种数据结构的实现。今天先写出最简单的一部分,ArrayList的实现

2016-07-16 22:48:54 172

原创 最大的矩形

问题描述 在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ i ≤ n)个矩形的高度是hi。这n个矩形构成了一个直方图。例如,下图中六个矩形的高度就分别是3, 1, 6, 5, 2, 3。 输入格式 请找出能放在给定直方图里面积最大的矩形,它的边要与坐标轴平行。对于上面给出的例子,最大矩形如下图所示的阴影部分,面积是10。 第一行包含一个整数n,即矩形的数量(1 ≤ n ≤

2016-07-16 22:05:30 235

原创 ISBN号码

问题描述 每一本正式出版的图书都有一个ISBN号码与之对应,ISBN码包括9位数字、1位识别码和3位分隔符,其规定格式如“x-xxx-xxxxx-x”,其中符号“-”是分隔符(键盘上的减号),最后一位是识别码,例如0-670-82162-4就是一个标准的ISBN码。ISBN码的首位数字表示书籍的出版语言,例如0代表英语;第一个分隔符“-”之后的三位数字代表出版社,例如670代表维京出版社;第二个分

2016-07-16 21:51:47 301

原创 出现次数最多的数

问题描述 给定n个正整数,找出它们中出现次数最多的数。如果这样的数有多个,请输出其中最小的一个。 输入格式 输入的第一行只有一个正整数n(1 ≤ n ≤ 1000),表示数字的个数。 输入的第二行有n个整数s1, s2, …, sn (1 ≤ si ≤ 10000, 1 ≤ i ≤ n)。相邻的数用空格分隔。 输出格式 输出这n个次数中出现次数最多的数。如果这样的数有多个,输出其中最小的

2016-07-16 21:47:16 235

原创 Move Zeroes

Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements

2016-07-14 22:44:46 207

原创 Single Number III

Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.

2016-07-14 22:37:49 123

原创 Invert Binary Tree

Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9to4 / \ 7 2 / \ / \ 9 6 3 1

2016-07-14 22:34:50 223

原创 Intersection of Two Arrays

Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note: Each element in the result must be unique. The result can be in

2016-07-14 22:29:04 159

原创 Maximum Depth of Binary Tree

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Subscribe to see which companies asked this

2016-07-13 20:29:37 155

原创 Add Digits

Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r

2016-06-02 00:24:42 154

原创 Single Number

Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra me

2016-05-31 15:30:15 176 1

原创 Nim Game

开始刷起了LeetCode~~ 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 who removes

2016-05-31 15:06:03 138

原创 programming-challenges110201 jolly jumpers

programming-challenges里面的题 主要方法是利用标记数组和遍历 #include<stdio.h>#include"math.h"int main(){ int i,j,k,temp,cnt; int visit[5000]; bool flag; int num[5000]; int n; while(scanf("%d"

2015-07-17 15:54:37 195

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除