自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Genius

- Code

  • 博客(85)
  • 收藏
  • 关注

原创 数据结构之链表的实现以及各种应用

#include <stdio.h>#include <malloc.h>#include <stdlib.h> //the max and the min.typedef struct LNode{ int data; struct LNode *next;}LNode;//初始化一个链表LNode* in...

2018-08-22 17:31:18 1794

原创 数据结构之顺序栈的实现与符号匹配和进制转换

#include <stdio.h>#include <stdlib.h>#define maxSize 100//顺序栈 固定分配typedef struct{ int data[maxSize]; int top;}SqStack;//初始化一个链表void initStack(SqStack &stack){ stac...

2018-08-22 17:29:09 694

原创 数据结构之链栈的实现

链栈的进栈出栈操作#include <stdio.h>#include <malloc.h>typedef struct LNode{ int data; struct LNode *next;}LNode;LNode* initStack(LNode *&stack){ stack = (LNode*)malloc(sizeo...

2018-08-22 17:25:50 426

原创 递归实现全排列

public class EG02 { //全排列 //k当前关注点 public static void f2(char[] data,int k) { if (k==data.length) { for (int i = 0; i < data.length; i++) { System.out.

2018-02-07 13:43:22 292

原创 如何自定义安装office 2016(通过configuration.xml文件来指定安装内容和路径)

office2016在安装的时候并不像之前的版本有选择性的安装,安装器会安装一个office全家桶。 那么如何自主选择安装自己需要的工具呢?微软在下载中心中提供了Office2016部署工具(Office 2016 Deployment Tool),通过该工具可实现上述目的。具体操作方法如下:1、下载Office2016部署工具,点此下载。2、双击打开工具,该工具会释放两个我们需要的文件(setu

2017-12-21 11:54:03 20944 1

原创 Leetcode:191. Number of 1 Bits(返回一个数字对应二进制中1的个数)

Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 0000000000000

2017-12-19 20:37:40 275

原创 lettcode:540. Single Element in a Sorted Array(已排序数组中出现一次的数字,其他数字出现两次)

Given a sorted array consisting of only integers where every element appears twice except for one element which appears once. Find this single element that appears only once.Example 1:Input: [1,1,2,3,

2017-12-19 20:12:12 261

原创 Leetcode:19 Remove Nth Node From End of List(在链表中删除倒数第n个数)

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. After removing the second node from the end, the linked l

2017-12-13 11:28:21 226

原创 Leetcode:48. Rotate Image(数组选择90度)

You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the image in-place, which means you have to modify the input 2D matrix directl

2017-12-12 19:03:53 323

原创 Leetcode:454. 4Sum II (解决时间和空间复杂度是关键)

Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same length o

2017-12-06 20:18:02 584

原创 Leetcode:219. Contains Duplicate II(数组是否含有重复元素)

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] and the absolute difference between i and j is at most k.

2017-12-06 19:11:42 656

原创 Leetcode:453. Minimum Moves to Equal Array Elements

Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1. Example:Input: [1,2,3]Output:

2017-12-05 21:06:23 227

原创 Leetcode:383.Ransom Note(统计每个字符串每个字母的个数)

Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; oth

2017-12-04 17:49:02 423

原创 Leetcode:169. Majority Element(找到数组中出现次数最多的元素)

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 that the array is non-empty and the majority element always

2017-12-04 11:46:06 2253

原创 Leetcode: 217. Contains Duplicate(数组是否包含重复数字)

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 array, and it should return false if every element is

2017-12-03 20:49:44 505

原创 Leetcode:263. Ugly Number(factors是否只包含2 3 5)

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it in

2017-11-29 12:07:15 316 1

原创 Leetcode:728. Self Dividing Numbers(是否为分裂数字)

A self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.Also, a self-dividing num

2017-11-29 11:39:37 288

原创 Leetcode:73.Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.public void setZeroes(int[][] matrix) { int col0 = 1, rows = matrix.length, cols = matrix[0].length;

2017-11-29 10:50:26 160

原创 Leetcode: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 get t.All occurrences of a character must be replaced with another chara

2017-11-27 20:27:17 321

原创 Leetcode:204. Count Primes 求素数的优化问题

Description:Count the number of prime numbers less than a non-negative number, n.Credits: Special thanks to @mithmatt for adding this problem and creating all test cases.最常见的一种代码。int count = 0;

2017-11-27 11:54:42 212

原创 Leetcode:203 Remove Linked List Elements(删除链表中的某个元素))

Remove all elements from a linked list of integers that have value val.Example Given: 1 –> 2 –> 6 –> 3 –> 4 –> 5 –> 6, val = 6 Return: 1 –> 2 –> 3 –> 4 –> 5Credits: Special thanks to @mithmatt for a

2017-11-27 11:01:15 389

原创 Leetcode:202. Happy Number

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 integer, replace the number by the sum of the squares of i

2017-11-27 10:27:27 191

原创 Leetcode:628. Maximum Product of Three Numbers

Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1: Input: [1,2,3] Output: 6 Example 2: Input: [1,2,3,4] Output: 24 Note: The length of

2017-11-12 11:48:59 202

原创 Leetcode:367 Valid Perfect Square(是否为平方数)

Given a positive integer num, write a function which returns True if num is a perfect square else False.Note: Do not use any built-in library function such as sqrt.Example 1:Input: 16 Returns: True E

2017-11-11 15:29:59 214

原创 Leetcode: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 a specific target number.The function twoSum should return indices of the two numbers suc

2017-11-11 15:06:25 261

原创 Leetcode:475. Heaters (利用二分binary search)

题目: Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses.Now, you are given positions of houses and heaters on a horizontal

2017-11-11 14:41:30 575

原创 Leetcode:350. Intersection of Two Arrays II 求两个数组的交集

Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note: Each element in the result should appear as many times as it

2017-11-11 13:12:43 186

原创 Leetcode:111. Minimum Depth of Binary Tree(求Tree的最小的深度)

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 给定一个二叉树,找到它的最小深度。 最小深度是沿着从根节点到最近的叶节点的最短路

2017-11-10 21:42:14 152

原创 Leetcode:112. Path Sum (求Tree中是否存在路径的和等于给定值)

Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. For example: Given the below binary tree and sum =

2017-11-10 21:04:23 175

原创 Java数组无法动态分配数组长度

哇哇哇好气啊 今天做一个题,我不知道怎么初始化数组的长度,由于我不知道初始化为多少,到最后我输出的时候,显而易见,会输出一些0如果你在java里面想用数组,但是你不知道数组的长度那么请你用Set ArrayList 等等。。。。。。。。

2017-11-10 20:37:16 979

原创 Leetcode:349. 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

2017-11-10 20:32:59 182

原创 Leetcode:36.Valid Sudoku 初始化数独数组是否合法判断

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’. 分析:乍一看这个题感觉很难,但是其实只要分三种情况讨论即可、

2017-11-06 11:04:58 403

原创 Leetcode:27.Remove Element

题目:Given an array and a value, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-plac

2017-11-06 10:34:13 227

原创 Leetcode:121. Best Time to Buy and Sell Stock

题目: Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2017-11-05 11:41:37 160

原创 Leetcode:713.Subarray Product Less Than K

题目描述: 题目:Your are given an array of positive integers nums.Count and print the number of (contiguous) subarrays where the product of all the elements in the subarray is less than k.Example 1:Input: nu

2017-11-04 11:00:22 627

原创 Leetcode:513. Find Bottom Left Tree Value

Given a binary tree, find the leftmost value in the last row of the tree.Example 1: Input:2/ \ 1 3Output: 1 Example 2: Input: 1 / \ 2 3 / / \4 5 6 / 7Output: 7 Note

2017-11-03 11:33:08 357

原创 Leetcode:442. Find All Duplicates in an Array 找数组中的重复数字

Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra space

2017-11-03 11:08:55 372

原创 Leetcode:171. Excel Sheet Column Number 求Excel表字母对应的行号

描述: Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28

2017-11-01 19:27:12 268

原创 Leetcode:283. Move Zeroes 把数组中为0的元素移到最后

描述: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.For example, given nums = [0, 1, 0, 3, 12], after calling your fu

2017-11-01 14:57:57 521

原创 Leetcode:485. Max Consecutive Ones 找二进制串连续1最多是多少

Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s.

2017-11-01 11:35:35 298

空空如也

空空如也

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

TA关注的人

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