随笔分类 -  C++/java刷题笔记

leetcode等
摘要:如题,对于c来说<< 和 >> 是针对无符号整数,高位低位都是自动补0;而对java来说模糊了这个概念,Java如果直接>>右移,他的符号位不变,左边补上符号位,即正数补零,负数补1。只有>>>才是全部补0的,而对于左移都是低位补0,没有区别。 参考:java移位运算符:<<(左移)、>>(带符号右 阅读全文
posted @ 2019-04-11 20:58 jm_epiphany 阅读(421) 评论(0) 推荐(0)
摘要:题目来源:leetcode 题目描述: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on W 阅读全文
posted @ 2019-03-27 19:17 jm_epiphany 阅读(323) 评论(0) 推荐(0)
摘要:都是一些基础的,从别人那里听说或者看到的问题。带详解连接(下划线) equals,==,hashcode 在object类里面定义了equals方法,默认情况下,判断的是两个对象的地址是否相等,等价于“==”。可重写此方法:public boolean equals(Object obj){}自定义 阅读全文
posted @ 2019-03-19 15:41 jm_epiphany 阅读(164) 评论(0) 推荐(0)
摘要:deep copy的意思我觉得就是复制一个对象成为新的对象,和原来的对象有不同的内存地址,不是简单的引用复制。 题目来源:leetcode 题目描述: Copy List with Random Pointer A linked list is given such that each node c 阅读全文
posted @ 2019-03-17 15:44 jm_epiphany 阅读(132) 评论(0) 推荐(0)
摘要:问题来源:leetcode 问题描述: Given an input string, reverse the string word by word. 想法就是用split函数,但是你会发现数组是没有倒转函数的,要么用循环倒转。要么转化成list调用Collections.reverse 这个时候又 阅读全文
posted @ 2019-03-03 16:55 jm_epiphany 阅读(252) 评论(0) 推荐(0)
摘要:数组移步转载:https://blog.csdn.net/shijing_0214/article/details/53056943 题目来源:leetcode 2019-03-17 题目描述:Given a linked list, rotate the list to the right by 阅读全文
posted @ 2019-03-03 15:35 jm_epiphany 阅读(172) 评论(0) 推荐(0)
摘要:题目来源:leetcode 题目描述: Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum 阅读全文
posted @ 2019-03-03 14:39 jm_epiphany 阅读(667) 评论(0) 推荐(0)
摘要:法1:来源leetcode 法2:来源我 阅读全文
posted @ 2018-11-30 11:58 jm_epiphany 阅读(1103) 评论(0) 推荐(0)
摘要:题目来源:Leetcode 题目描述: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: 思路:不断合并两个链直到所有合并完成O(kN 阅读全文
posted @ 2018-11-11 15:33 jm_epiphany 阅读(716) 评论(0) 推荐(0)
摘要:问题描述:给定n个整数组成的序列,求其中子段和的最大值。当所有整数均为非负整数时定义其最大子段和为0 方法一:O(n²)用一个值存储最大和,用枚举所有和的方法,来与这个值比较并更新最大值。 方法二:O(nlogn)分治,分别求两边的最大子段和,再从中间分开的位置向两边拓展求最大和,三个值比较得最大子 阅读全文
posted @ 2018-10-16 19:37 jm_epiphany 阅读(624) 评论(0) 推荐(0)
摘要:题目描述: Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. 题目来 阅读全文
posted @ 2018-09-15 17:17 jm_epiphany 阅读(4099) 评论(0) 推荐(0)
摘要:容器操作可能使迭代器失效 向容器中添加或者删除元素的操作可能使指向容器的指针、引用、迭代器失效。一个失效的指针、引用、迭代器将不再表示任何元素。 在向容器添加元素后,如果储存空间未重新分配,指向插入位置之前的元素的迭代器、指针、引用有效,但指向插入位置之后的将会失效。 在从容器删除元素之后,指向被删 阅读全文
posted @ 2018-09-08 16:44 jm_epiphany 阅读(4107) 评论(0) 推荐(0)
摘要:题目:Valid Parentheses 题目来源:leetcode 题目描述: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string 阅读全文
posted @ 2018-09-07 16:54 jm_epiphany 阅读(1729) 评论(0) 推荐(0)
摘要:C题目来源:leetcode 题目描述: Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For example, two is written as II in Roman num 阅读全文
posted @ 2018-09-05 17:04 jm_epiphany 阅读(381) 评论(0) 推荐(0)
摘要:题目来源:leetcode Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Example 2: Example 3: Input: 123 Input: -123 Inp 阅读全文
posted @ 2018-09-04 20:27 jm_epiphany 阅读(795) 评论(0) 推荐(0)