E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
leedCode
C++中的位运算
基本知识 最近博主在刷
Leedcode
题,很多人都是采用位运算来解题的,看的我满脸雾水,所以上网收集了一下c++中关于位运算的知识,为此总结一下,有不妥的地方还望指正。
HachiLin
·
2018-03-24 23:01
C++
leedcode
前50道题总结
12summap结构存储每个数的下标,每遍历一个nums[i],找出map中target-nums[i]对应的下标,即返回i和该下标。2AddTwoNumbers两个链表表示两个倒序的整数,相加后得一整数并倒序形成链表。就是把两个链表从头结点开始相加,注意进位3LongestSubstringWithoutRepeatingCharacters用vector初始化每个字符出现的位置为-1,如若重复
漂亮的程序媛
·
2017-08-08 09:37
leedcode
——判断单链表是否有环及寻找环的入口点
题目:Givenalinkedlist,determineifithasacycleinit.Givenalinkedlist,returnthenodewherethecyclebegins.Ifthereisnocycle,returnnull.思路:链表有环判断:设置快慢指针,如果快慢指针相遇,则证明有环。(1)设置快慢指针,因为链表中有环,所以最终会相遇,相遇点为C(2)两个指针分别放在链
ZH_learningblog
·
2017-03-27 15:31
算法
leedcode
4. Median of Two Sorted Arrays
1、MedianofTwoSortedArrays——这是
leedcode
的第四题:Therearetwosortedarraysnums1andnums2ofsizemandnrespectively.Findthemedianofthetwosortedarrays.TheoverallruntimecomplexityshouldbeO
BuptZhengChaoJie
·
2016-05-10 19:00
3. Longest Substring Without Repeating Characters
1、LongestSubstringWithoutRepeatingCharacters——这是
leedcode
的第三题:Givenastring,findthelengthofthelongestsubstringwithoutrepeatingcharacters.Examples
BuptZhengChaoJie
·
2016-05-09 21:00
6. ZigZag Conversion
1、ZigZagConversion——这是
leedcode
的第六题:Thestring“PAYPALISHIRING”iswritteninazigzagpatternonagivennumberofrowslikethis
BuptZhengChaoJie
·
2016-05-09 19:00
2、Add Two Numbers
1、AddTwoNumbers——这是
leedcode
的第二题:Youaregiventwolinkedlistsrepresentingtwonon-negativenumbers.Thedigitsarestoredinreverseorderandeachoftheirnodescontainasingledigit.Addthetwonumbersandreturnitasalinkedl
BuptZhengChaoJie
·
2016-05-08 21:00
1、Two Sum
1、twosum——这是
leedcode
的第一题:Givenanarrayofintegers,returnindicesofthetwonumberssuchthattheyadduptoaspecifictarget.Youmayassumethateachinputwouldhaveexactlyonesolution.Example
BuptZhengChaoJie
·
2016-05-08 13:00
leetcode---Merge Two Sorted Lists
Mergetwosortedlinkedlistsandreturnitasanewlist.Thenewlistshouldbemadebysplicingtogetherthenodesofthefirsttwolists.package
leedcode
a1b2c3d4123456
·
2016-04-21 13:00
LeetCode
合并
leetcode----Merge Sorted Array
package
leedcode
; importjava.lang.reflect.Array; importjava.util.ArrayList; importjavax.crypto.spec.IvParameterSpec
a1b2c3d4123456
·
2016-04-21 13:00
LeetCode
leedcode
79. Word Search
leedcode
79.WordSearchGivena2Dboardandaword,findifthewordexistsinthegrid.Thewordcanbeconstructedfromlettersofsequentiallyadjacentcell
FireEmissary
·
2016-03-26 18:00
leedcode
--Excel Sheet Column Number
RelatedtoquestionExcelSheetColumnTitleGivenacolumntitleasappearinanExcelsheet,returnitscorrespondingcolumnnumber.解题思路:进制的转换,26进制转10进制,注意点就是A-Z不是以0开头,所以要记得加1。java版:publicclassSolution{publicinttitleToN
大号小白兔
·
2016-03-22 13:33
Leedcode
leedcode
--Excel Sheet Column Number
RelatedtoquestionExcelSheetColumnTitleGivenacolumntitleasappearinanExcelsheet,returnitscorrespondingcolumnnumber.解题思路:进制的转换,26进制转10进制,注意点就是A-Z不是以0开头,所以要记得加1。java版:publicclassSolution{ publicinttitleTo
a1b2c3d4123456
·
2016-03-22 13:00
leedcode
java入门---类,构造函数,对象。
package
leedcode
; publicclasstest{ inthisage;//定义一个全局变量 //构造函数,必须和类名字一致 publictest(Stringname){ //这个构造器仅有一个参数
a1b2c3d4123456
·
2016-03-18 14:00
java
[
leedcode
146] LRU Cache
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the value (will always be positi
·
2015-11-12 13:19
cache
[
leedcode
145] Binary Tree Postorder Traversal
Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. /
·
2015-11-07 12:41
binary
LeedCode
OJ --- Binary Tree Inorder Traversal
点击打开题目链接 今天只是写了递归的版本,因为还没想好怎么用迭代来实现,可以写的过程中,有一点是有疑问的,虽然我的代码可以AC。 问题是:主调函数是可以使用子函数中返回的在子函数中定义的vector. 我认为在被调函数执行结束之后,其分配的空间是应该被释放的,所以在被调函数中定义的变量也是不可以被主调函数中使用的...可能是C++的基础知识又给忘了,有空要拾起来了。 附上代码(递归版)
·
2015-10-31 10:34
binary
LeedCode
OJ -- String to Integer (atoi)
点击打开题目链接 题目意思就是自己实现一个atoi函数,也就是将字符串转换成int型。 关于INT_MAX和INT_MIN, 只是在<limits.h>文件中定义的宏..分别是int型可以表示的最大值和最小值 还有就是定义大整数常量的时候,会出现这种警告:warning: this decimal constant is unsigned only in ISO C90 c的标
·
2015-10-31 10:33
Integer
LeedCode
--- Best Time to Buy and Sell Stock
题目链接 题意: find the maximum positive difference between the price on the ith day and the jth day 附上代码: 1 class Solution { 2 public: 3 int maxProfit(vector<int> &prices) { 4
·
2015-10-31 09:28
code
[
leedcode
52] N-Queens II
Follow up for N-Queens problem. Now, instead outputting board configurations, return the total number of distinct solutions. public class Solution { //本题类似于N-Queens,这个更简单一些,只需要求出解法的个数即可,因此没有
·
2015-10-31 08:41
code
[
leedcode
51] N-Queens
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct so
·
2015-10-31 08:41
code
[
leedcode
48] Rotate Image
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? In order to fulfill the follow
·
2015-10-31 08:41
image
[
leedcode
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 '.'. A partially fil
·
2015-10-31 08:40
code
[
leedcode
41] First Missing Positive
Given an unsorted integer array, find the first missing positive integer. For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2. Your algorithm should run in
·
2015-10-31 08:40
first
[
leedcode
42] Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. For example, Given [0,1,0,2,
·
2015-10-31 08:40
water
leedcode
_153题——Find Minimum in Rotated Sorted Array(二分查找)
Find Minimum in Rotated Sorted Array Total Accepted: 44929 Total Submissions: 135513 My Submissions Question Solution Suppose a sorted array is rotated
·
2015-10-30 13:04
array
[
leedcode
142] Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up:Can you solve it without using extra space? 因为fast的速度是slow的两倍,所以fast走的距离是slow的两倍,有 2(
·
2015-10-30 12:42
list
[
leedcode
86] Partition List
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the original relative order of th
·
2015-10-30 12:41
partition
[
leedcode
84] Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where wid
·
2015-10-30 12:41
code
[
leedcode
62] Unique Paths
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 point in time. The robot is tr
·
2015-10-30 12:40
unique
[
leedcode
219]Contains Duplicate II
Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the differenc
·
2015-10-23 09:49
contains
[
leedcode
]Remove Linked List Elements
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */ public class Solution { public ListNo
·
2015-10-23 09:47
element
[
leedcode
] Count Primes
Description: Count the number of prime numbers less than a non-negative number, n public class Solution { public int countPrimes(int n) { if(n<3) return 0; int res=0;
·
2015-10-23 09:45
count
[
leedcode
49] Anagrams
Given an array of strings, return all groups of strings that are anagrams. Note: All inputs will be in lower-case. public class Solution { public List<String> anagrams(String[] strs) {
·
2015-10-23 09:05
code
[
leedcode
55] Jump Game
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 maximum jump length at that position. Determine if yo
·
2015-10-23 09:05
code
[
leedcode
50] Pow(x, n)
public class Solution { public double myPow(double x, int n) { //利用二分法,通过递归加速计算 //注意:1.判断n是否为负 // 2.递归结束条件,n==1和n==0 // 3.n的奇偶不同处理方式 if(n<
·
2015-10-23 09:05
code
[
leedcode
47] Permutations II
Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [
·
2015-10-23 09:03
code
[
leedcode
43] Multiply Strings
Straight forward idea. Just like the way we multiply numbers. Don't forget considering the carry and be careful. e.g. 123*456,what we usually do is: 123* 456----
·
2015-10-23 09:02
String
[
leedcode
46] Permutations
Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,
·
2015-10-23 09:02
code
[
leedcode
45] Jump Game II
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 maximum jump length at that position. Your goal is to
·
2015-10-23 09:02
code
[
leedcode
40] Combination Sum II
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be use
·
2015-10-23 09:02
code
[
leedcode
38] Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11.11 is read off as "
·
2015-10-23 09:01
count
[
leedcode
35] Search Insert Position
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 order. You may assume no duplicates in the array.
·
2015-10-23 09:01
position
[
leedcode
39] Combination Sum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may be chosen
·
2015-10-23 09:01
code
[
leedcode
32] Longest Valid Parentheses
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parenth
·
2015-10-23 09:59
code
[
leedcode
34] Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If the target is not
·
2015-10-23 09:59
search
[
leedcode
33] Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand. (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). You are given a target value to search. If found in the ar
·
2015-10-23 09:59
search
[
leedcode
30] Substring with Concatenation of All Words
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in
·
2015-10-23 09:58
substring
[
leedcode
31] Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as the lowest possible o
·
2015-10-23 09:58
code
[
leedcode
26] Remove Duplicates from Sorted Array
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 for another array, you must do this in pl
·
2015-10-23 09:56
remove
上一页
3
4
5
6
7
8
9
10
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他