随笔分类 -  算法设计与分析

摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1-... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(154) 评论(0) 推荐(0)
摘要:Maximum Depth of Binary Tree Total Accepted: 63668 Total Submissions: 141121 My Submissions Question Solution Given a binary tree, find it... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(183) 评论(0) 推荐(0)
摘要:Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers.Have you thought about this?... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(137) 评论(0) 推荐(0)
摘要:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. • push(x) – Push element x onto stack. • p... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(185) 评论(0) 推荐(0)
摘要:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: ... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(151) 评论(0) 推荐(0)
摘要:Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 22; return 1.Example2: version1==”11.22.33”,... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(189) 评论(0) 推荐(0)
摘要:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume t... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(114) 评论(0) 推荐(0)
摘要:Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.解决思路: 决定阶乘末尾零的个数其实... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(124) 评论(0) 推荐(0)
摘要:Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(128) 评论(0) 推荐(0)
摘要:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100)... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(123) 评论(0) 推荐(0)
摘要:今天看了一个华为西安研究院的一个女生代码大神的总结很有感悟,下面这句话送给大家:只有好的程序员才能写出人类可以理解的代码You are a professional robber planning to rob houses along a street. Each house ha... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(158) 评论(0) 推荐(0)
摘要:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occ... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(125) 评论(0) 推荐(0)
摘要:Climbing Stairs You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(94) 评论(0) 推荐(0)
摘要:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive intege... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(194) 评论(0) 推荐(0)
摘要:Remove all elements from a linked list of integers that have valueval.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(104) 评论(0) 推荐(0)
摘要:Description:Count the number of prime numbers less than a non-negative number, n 提示晒数法:http://en.wikipedia.org/wiki/Sieve_of_Eratostheneshttps://p... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(118) 评论(0) 推荐(0)
摘要:概述排序有内部排序和外部排序,内部排序是数据记录在内存中进行排序,而外部排序是因排序的数据很大,一次不能容纳全部的排序记录,在排序过程中需要访问外存。我们这里说说八大排序就是内部排序。 当n较大,则应采用时间复杂度为O(nlog2n)的排序方法:快速排序、堆排序或归并排序序。 快速排序:... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(333) 评论(0) 推荐(0)
摘要:http://www.cnblogs.com/sleepwalker/p/3676600.html?utm_source=tuicoolhttp://blog.csdn.net/carson2005/article/details/9502053 Retinex理论Retinex理论始于Lan... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(275) 评论(0) 推荐(0)
摘要:题目:输入一个正整数,若该数能用几个连续正整数之和表示,则输出所有可能的正整数序列。一个正整数有可能可以被表示为n(n>=2)个连续正整数之和,如: 15=1+2+3+4+5 15=4+5+6 15=7+8有些数可以写成连续N(>1)个自然数之和,比如14=2+3+4+5;有些不能,比如8.那么如何... 阅读全文
posted @ 2017-11-17 22:28 wangyaning 阅读(1236) 评论(0) 推荐(0)