Processing math: 100%

Spurs

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  142 随笔 :: 0 文章 :: 6 评论 :: 64990 阅读
< 2025年2月 >
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 1
2 3 4 5 6 7 8

08 2017 档案

摘要:A robot is located at the top left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2017-08-31 17:25 英雄与侠义的化身 阅读(151) 评论(0) 推荐(0) 编辑

摘要:学DP, 从这里开始吧: http://mp.weixin.qq.com/s/0AgJmQNYAKzVOyigXiKQhA 阅读全文
posted @ 2017-08-31 11:36 英雄与侠义的化身 阅读(186) 评论(0) 推荐(0) 编辑

摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2017-08-29 23:13 英雄与侠义的化身 阅读(158) 评论(0) 推荐(0) 编辑

摘要:Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given , The longest consecutive elemen 阅读全文
posted @ 2017-08-28 23:04 英雄与侠义的化身 阅读(149) 评论(0) 推荐(0) 编辑

摘要:有一个升序排序的数组. For example, Given sorted array , Your function should return length = , with the first five elements of nums being . It doesn't matter wh 阅读全文
posted @ 2017-08-28 21:19 英雄与侠义的化身 阅读(109) 评论(0) 推荐(0) 编辑

摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., might become ). Write a function to determine if 阅读全文
posted @ 2017-08-28 16:51 英雄与侠义的化身 阅读(130) 评论(0) 推荐(0) 编辑

摘要:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For example, Given n = 3, You should return the f 阅读全文
posted @ 2017-08-27 11:14 英雄与侠义的化身 阅读(99) 评论(0) 推荐(0) 编辑

摘要:Given an array of non negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maxim 阅读全文
posted @ 2017-08-26 17:00 英雄与侠义的化身 阅读(116) 评论(0) 推荐(0) 编辑

摘要:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: You 阅读全文
posted @ 2017-08-26 15:38 英雄与侠义的化身 阅读(81) 评论(0) 推荐(0) 编辑

摘要:You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in place? 方阵顺时针旋转90度, 阅读全文
posted @ 2017-08-24 12:58 英雄与侠义的化身 阅读(94) 评论(0) 推荐(0) 编辑

摘要:Given an array of integers sorted in ascending order, find the starting and ending position of a given target value. Your algorithm's runtime complexi 阅读全文
posted @ 2017-08-22 19:05 英雄与侠义的化身 阅读(112) 评论(0) 推荐(0) 编辑

摘要:Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array whic 阅读全文
posted @ 2017-08-22 12:12 英雄与侠义的化身 阅读(96) 评论(0) 推荐(0) 编辑

摘要:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. 阅读全文
posted @ 2017-08-22 10:44 英雄与侠义的化身 阅读(105) 评论(0) 推荐(0) 编辑

摘要:Given an unsorted integer array, find the first missing positive integer. For example , Your algorithm should run in O(n) time and uses constant spa 阅读全文
posted @ 2017-08-21 18:19 英雄与侠义的化身 阅读(109) 评论(0) 推荐(0) 编辑

摘要:Given an array of integers, (n = size of array), some elements appear twice and others appear once . Find all the elements that appear twice in this a 阅读全文
posted @ 2017-08-21 11:55 英雄与侠义的化身 阅读(114) 评论(0) 推荐(0) 编辑

摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., might become ). You are given a target value to 阅读全文
posted @ 2017-08-20 12:10 英雄与侠义的化身 阅读(141) 评论(0) 推荐(0) 编辑

摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文
posted @ 2017-08-19 18:43 英雄与侠义的化身 阅读(138) 评论(0) 推荐(0) 编辑

摘要:Given a matrix, if an element is , set its entire row and column to . Do it in place. 重点是空间复杂度限制为常数. 人家想法: 用 matrix 的第0行和第0列的元素分别记录所对应的行和列是否有0. 比较特殊,我 阅读全文
posted @ 2017-08-19 12:19 英雄与侠义的化身 阅读(121) 评论(0) 推荐(0) 编辑

摘要:Given an array of integers, are there elements in such that ? Find all unique triplets in the array which gives the sum of zero. Note: The solution se 阅读全文
posted @ 2017-08-18 21:49 英雄与侠义的化身 阅读(124) 评论(0) 推荐(0) 编辑

摘要:给一个非负数组A,元素们是A[i], i=0,...,n 1. 索引i代表x坐标,值A[i]表示高度.索引i与A[i],既(i, A[i])表示了垂直于x轴的线段. 请找出两条线段,与x轴组成的桶最多能装多少水? 人家想法: 先从底最宽搜起.两个边找最矮的移动,计算容积,保留最大值,循环条件 lef 阅读全文
posted @ 2017-08-17 23:12 英雄与侠义的化身 阅读(97) 评论(0) 推荐(0) 编辑

摘要:Follow up for "153. Find Minimum in Rotated Sorted Array": What if duplicates are allowed? Would this affect the run time complexity? How and why? Sup 阅读全文
posted @ 2017-08-17 12:31 英雄与侠义的化身 阅读(90) 评论(0) 推荐(0) 编辑

摘要:Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e., might become ). Find the minimum element. You ma 阅读全文
posted @ 2017-08-16 18:23 英雄与侠义的化身 阅读(87) 评论(0) 推荐(0) 编辑

摘要:Suppose you have a long flowerbed in which some of the plots are planted and some are not. However, flowers cannot be planted in adjacent plots they w 阅读全文
posted @ 2017-08-16 16:44 英雄与侠义的化身 阅读(102) 评论(0) 推荐(0) 编辑

摘要:Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Example 2: Note: 1. The length of the g 阅读全文
posted @ 2017-08-15 17:42 英雄与侠义的化身 阅读(103) 评论(0) 推荐(0) 编辑

摘要:Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum average value. And you need to output 阅读全文
posted @ 2017-08-15 16:27 英雄与侠义的化身 阅读(85) 评论(0) 推荐(0) 编辑

摘要:In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. 阅读全文
posted @ 2017-08-15 00:00 英雄与侠义的化身 阅读(106) 评论(0) 推荐(0) 编辑

摘要:Given 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 阅读全文
posted @ 2017-08-14 23:00 英雄与侠义的化身 阅读(85) 评论(0) 推荐(0) 编辑

摘要:Given a binary array, find the maximum number of consecutive 1s in this array. Example 1 : Note : The input array will only contain and . The length o 阅读全文
posted @ 2017-08-14 20:35 英雄与侠义的化身 阅读(92) 评论(0) 推荐(0) 编辑

摘要:Given an array of integers where (n= size of array), some elements appear twice and others appear once. Find all the elements of inclusive that do 阅读全文
posted @ 2017-08-14 18:15 英雄与侠义的化身 阅读(105) 评论(0) 推荐(0) 编辑

摘要:Given a non empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexi 阅读全文
posted @ 2017-08-14 16:51 英雄与侠义的化身 阅读(95) 评论(0) 推荐(0) 编辑

摘要:java GUI === Date: Feb. 15th, 2017 Author: xiang 依据毕向东老师的授课, 我组织了本文内容. Graphical User Interface Java的GUI部件在java.awt(抽象窗口工具包,需调用本地系统方法实现功能,重量级组件,不同系统窗口 阅读全文
posted @ 2017-08-14 12:51 英雄与侠义的化身 阅读(241) 评论(0) 推荐(0) 编辑

摘要:这是半成品, 已完成了 部分, 形成了包含一棵完整树的 对象. 后续工作是需解析该 对象, 完成 工作. 阅读全文
posted @ 2017-08-14 12:46 英雄与侠义的化身 阅读(192) 评论(0) 推荐(0) 编辑

摘要:```python # !/usr/bin/python # -*- coding:utf-8 -*- """ Re-implement kNN algorithm as a practice 使用该 kNN re-implement 的前提: train data 的标签必须转成0,1,2,...的形式 """ # Author: 相忠良(Zhong-Liang Xiang) #... 阅读全文
posted @ 2017-08-14 12:42 英雄与侠义的化身 阅读(143) 评论(0) 推荐(0) 编辑

摘要:我仿照sk learn 中 GaussionNB 的结构, 重写了该算法的轮子,命名为 MyGaussionNB, 如下: 阅读全文
posted @ 2017-08-14 12:40 英雄与侠义的化身 阅读(180) 评论(0) 推荐(0) 编辑

摘要:Algorithm in Practice Author: Zhong Liang Xiang Date: Aug. 1st, 2017 不完整, 部分排序和查询算法, 需添加. Prerequisite 生成随机整数数组,打印数组, 元素交换. 1. Sorting 默认升序. 插入排序 直接插入 阅读全文
posted @ 2017-08-14 12:28 英雄与侠义的化身 阅读(199) 评论(0) 推荐(0) 编辑

摘要:```c vector v(10, -1); //10个-1 v.size(); v.empty(); //is empty? ``` 阅读全文
posted @ 2017-08-14 12:21 英雄与侠义的化身 阅读(127) 评论(0) 推荐(0) 编辑

摘要:2. struct A 和 typedef struct A 2.1 struct A 定义一个名为 的结构体. 下例定义了 同时,声明了两个变量(注意:不是类型别名) , . 2.2 typedef struct A 用来为 类型起 别名 (注意: 不是起变量名 ). 是类型名, 是指向 类型的指 阅读全文
posted @ 2017-08-14 12:20 英雄与侠义的化身 阅读(843) 评论(0) 推荐(0) 编辑

摘要:1. 函数 数组 指针相关 1.1 定义并简单使用指针 c++ // 函数声明 void swap(int &x, int &y); int main() { // 局部变量声明 int a = 100; int b = 200; cout 阅读全文
posted @ 2017-08-14 12:19 英雄与侠义的化身 阅读(175) 评论(0) 推荐(0) 编辑

摘要:0. 迷之 和 . 箭头( ):左边必须为指针; 点号(.):左边必须为实体。 e.g.1 class e.g.2 struct 阅读全文
posted @ 2017-08-14 12:18 英雄与侠义的化身 阅读(149) 评论(0) 推荐(0) 编辑

摘要:My Stuck in C++ Zhong Liang Xiang Oct. 1st, 2017 这个专题记录了对于我而言, c++迷一样的东西. 阅读全文
posted @ 2017-08-14 12:17 英雄与侠义的化身 阅读(89) 评论(0) 推荐(0) 编辑

摘要:Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] an 阅读全文
posted @ 2017-08-14 12:00 英雄与侠义的化身 阅读(83) 评论(0) 推荐(0) 编辑

摘要:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr 阅读全文
posted @ 2017-08-14 11:58 英雄与侠义的化身 阅读(103) 评论(0) 推荐(0) 编辑

摘要:189. Rotate Array Rotate an array of n elements to the right by k steps. For example, with n=7 and k=3, the array is rotated to . Related 阅读全文
posted @ 2017-08-14 11:57 英雄与侠义的化身 阅读(116) 评论(0) 推荐(0) 编辑

摘要:169. Majority Element Given an array of size n, find the majority element. The majority element is the element that appears more than times. You may 阅读全文
posted @ 2017-08-14 11:56 英雄与侠义的化身 阅读(99) 评论(0) 推荐(0) 编辑

摘要:122. Best Time to Buy and Sell Stock II 为获得最高收益而多次买卖,但只能像这样买卖: O(n) time, O(1) space. 自家代码: 阅读全文
posted @ 2017-08-14 11:55 英雄与侠义的化身 阅读(64) 评论(0) 推荐(0) 编辑

摘要:167. Two Sum II Input array is sorted Given an array of integers that is already sorted in ascending order , find two numbers such that they add up to 阅读全文
posted @ 2017-08-14 11:55 英雄与侠义的化身 阅读(89) 评论(0) 推荐(0) 编辑

摘要:121. Best Time to Buy and Sell Stock Example 1: Example 2: 同53题. The maximum (minimum) subarray problem. 用到DP. 这题是重点 : 就是序列从A[0]开始计算, 不符合条件就清0, 从断处继 阅读全文
posted @ 2017-08-14 11:54 英雄与侠义的化身 阅读(117) 评论(0) 推荐(0) 编辑

摘要:119. Pascal's Triangle II Given an index k, return the kth row of the Pascal's triangle. For example, given k=3, Return . 直接生成由0组成的数组,设定 ,迭 阅读全文
posted @ 2017-08-14 11:53 英雄与侠义的化身 阅读(74) 评论(0) 推荐(0) 编辑

摘要:88. Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 ha 阅读全文
posted @ 2017-08-14 11:52 英雄与侠义的化身 阅读(80) 评论(0) 推荐(0) 编辑

摘要:118. Pascal's Triangle Given numRows, generate the first numRows of Pascal's triangle. For example, given , Return 在每一行后面+1, 再更新该行. 另外学会向 容器中放 元素. 人家代 阅读全文
posted @ 2017-08-14 11:52 英雄与侠义的化身 阅读(111) 评论(0) 推荐(0) 编辑

摘要:66. Plus One Given a non negative integer represented as a non empty array of digits, plus one to the integer. 该题目要求:将一整数按位存储在vector中,对其实现+1操作,返回结果. 对 阅读全文
posted @ 2017-08-14 11:51 英雄与侠义的化身 阅读(103) 评论(0) 推荐(0) 编辑

摘要:53. Maximum Subarray 同121题. Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, give 阅读全文
posted @ 2017-08-14 11:50 英雄与侠义的化身 阅读(114) 评论(0) 推荐(0) 编辑

摘要:Given an array , write a function to move all 's to the end of it while maintaining the relative order of the non zero elements. For example, given , 阅读全文
posted @ 2017-08-14 11:47 英雄与侠义的化身 阅读(99) 评论(0) 推荐(0) 编辑

摘要:268. Missing Number Given an array containing n distinct numbers taken from , find the one that is missing from the array. For example, Given return 阅读全文
posted @ 2017-08-14 10:45 英雄与侠义的化身 阅读(98) 评论(0) 推荐(0) 编辑

摘要:1. Two Sum 人家媳妇: time O(n), space O(n) 方法中巧妙使用map,一次遍历完成任务. 遍历数组时,若未在map中找到想要的元素,则把数组中当前元素投入map.(注key=数组元素值,val=该元素indx) c++ vector twoSum(vector 阅读全文
posted @ 2017-08-13 13:49 英雄与侠义的化身 阅读(115) 评论(0) 推荐(0) 编辑

摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2017-08-13 13:40 英雄与侠义的化身 阅读(176) 评论(0) 推荐(0) 编辑

摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space fo 阅读全文
posted @ 2017-08-13 13:38 英雄与侠义的化身 阅读(105) 评论(0) 推荐(0) 编辑

摘要:Given input array , Your function should return length = 2, with the first two elements of nums being 2. 就是把不是3的元素往前移动至队首,再返回不是3的元素个数. O(n) time, $O 阅读全文
posted @ 2017-08-13 13:36 英雄与侠义的化身 阅读(94) 评论(0) 推荐(0) 编辑

摘要:Author: Zhong Liang Xiang Start from: August 7th, 2017 这个题为 连滚带爬的Leetcode填坑记录 就这么开始了. 网上看了看, 一堆小伙从2014年就开始弄这个东西了,可自己那时候也不知道整这个东西啊. 啥也不说了,开整吧. 本系列,就是我自 阅读全文
posted @ 2017-08-13 13:28 英雄与侠义的化身 阅读(107) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示