
leetcode
文章平均质量分 70
dongmeima_coder
这个作者很懒,什么都没留下…
展开
-
leetcode 219
import java.util.*;class Solution_TimeLimit { //使用两层for循环会导致超时。此时应该想到用其他方法。 public boolean containsNearbyDuplicate(int[] nums, int k) { for(int i=0;i<nums.length-1;i++) { for(int j=原创 2016-05-15 15:39:05 · 401 阅读 · 0 评论 -
leetcode-561(Array Partition I)
DecriptionGiven an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1原创 2017-06-02 10:58:27 · 943 阅读 · 0 评论 -
leetcode-461(Hamming Distance)
DescriptionThe Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.原创 2017-06-02 10:43:21 · 462 阅读 · 0 评论 -
字符串同构问题——leetcode205/leetcode290
205. Isomorphic Strings问题描述:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to gett.All occurrences of a cha原创 2016-12-20 20:50:32 · 1852 阅读 · 0 评论 -
leetcode299. Bulls and Cows
299. Bulls and Cows问题描述:You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend mak原创 2016-12-20 11:18:06 · 432 阅读 · 0 评论 -
字符串/hashtable——leetcode205
205. Isomorphic Strings问题描述:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to gett.All occurrences of a cha原创 2016-12-20 11:12:16 · 478 阅读 · 0 评论 -
二叉树——leetcode101/leetcode102/leetcode110/leetcode111/leetcode112/leetcode257
101. Symmetric Tree 问题描述:Total Accepted: 145790Total Submissions: 397211Difficulty: EasyContributors: Admin Given a binary tree, check whether it is a mirror of itsel原创 2016-12-20 10:52:27 · 370 阅读 · 0 评论 -
链表——leetcode19/leetcode141
19. Remove Nth Node From End of List问题描述:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. A原创 2016-12-20 10:07:12 · 319 阅读 · 0 评论 -
LeetCode459——Repeated Substring Pattern
题目:Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercas原创 2016-12-28 17:09:11 · 498 阅读 · 0 评论 -
二叉树的深度优先遍历和广度优先遍历
一、【二叉树是神马?】准载文章段落:关于树和二叉树的基本概念总结1.什么是(自由)树?树首先是无向图的一种,并且此无向图要满足下面两个特性:1)连通,即任何两对顶点之间都有路径相连。2)无回路,简单地说就是没有成环。2.什么是森林?当满足树特性2)而不满足1)时称为森林。可以简单地理解为,什么不满足连通性,所以森林中可含有多个(自由)树。3.树的特性原创 2016-10-31 13:13:48 · 916 阅读 · 0 评论 -
letcode 118
/*问题描述:Given numRows, generate the first numRows of Pascal's triangle.For example, given numRows = 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1]]*/import java.util原创 2016-05-16 16:49:05 · 349 阅读 · 0 评论 -
leetcode 119
/*杨辉三角:输入行数(从第零行开始),输出杨辉三角相应行数。例如:输入3,输出1,3,3,1注意规律:num=num*(rowIndex-i)/(i+1); List list=new ArrayList(); long num=1; for(int i=0;i<=rowIndex;i++) { list.add((int)num); num=num*(row原创 2016-05-15 20:59:35 · 397 阅读 · 0 评论 -
leetcode 121
class Solution_TimeLimit{ int maxprofit=0; if(prices.length==0) return 0; for(int i=0;i<prices.length-1;i++) { for(int j=i+1;j<prices.length;j++) { if(maxprofit<prices[j]-prices[i])原创 2016-05-15 20:19:23 · 389 阅读 · 0 评论 -
leetcode 169
import java.util.*;public class Solution { public int majorityElement(int[] nums) { HashMap hm=new HashMap(); int key=0; if(nums.length==1) return nums[0]; for(int i=0;i<nums原创 2016-05-15 17:00:09 · 370 阅读 · 0 评论 -
leetcode 189
import java.util.*;class Solution_TimeLimit { public void rotate(int[] nums, int k) { for(int i=0;i<k;i++) { int temp=nums[nums.length-1]; for(int j=nums.length-1;j>0;j--) { nums原创 2016-05-15 16:19:04 · 470 阅读 · 0 评论 -
leetcode 217
class Solution { public boolean containsDuplicate(int[] nums) { HashMap hm=new HashMap(); for(int i=0;i<nums.length;i++) { if(!(hm.containsKey(nums[i]))) hm.put(nums[i],0); e原创 2016-05-15 15:41:54 · 412 阅读 · 0 评论 -
leetcode整理
二刷了,一刷做完了easy部分,做了一点medium,再刷一遍做好总结。EasyNOTITLESOLUTION461Hamming Distance题解561Array Partition I题解原创 2017-06-02 21:29:59 · 438 阅读 · 0 评论