
笔记
TwoLine
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode第一题Two Sum
一开始没想到HashMap,看了别人的答案之后才知道用hashmap更快捷,第一次的代码如下:class Solution { public int[] twoSum(int[] nums, int target) { int[] result = new int[2]; Map<Integer,Integer> map = new HashMa...原创 2018-04-12 10:09:06 · 155 阅读 · 0 评论 -
leetcode657(java) Judge Route Circle
public boolean judgeCircle(String moves) { boolean result = false; char l='L'; char r='R'; char u='U'; char d='D'; int unumber=0; int dnumber=0;...原创 2018-04-17 08:52:40 · 211 阅读 · 0 评论 -
leetcode771(java) Jewels and Stones
public int numJewelsInStones(String J, String S) { int result = 0; char[] j = J.toCharArray(); char[] s = S.toCharArray(); for(int a=0;a<j.length;a++){ f...原创 2018-04-17 08:50:38 · 310 阅读 · 0 评论 -
leetcode461(java) Hamming distance
public int hammingDistance(int x, int y) { return Integer.bitCount(x^y); }用异或运算,比较简便Integer.bitCount()统计二进制中1的个数原创 2018-04-17 08:48:20 · 204 阅读 · 0 评论 -
leetcode第五题(Java)Longest Palindromic Substring
本篇非原创,我想了很久想不到简单的方法,观摩了一下运行最快的范例,在此贴出,以供日后复习。class Solution { public String longestPalindrome(String s) { if (s.length()<=1) return s; //开始和结束位置 int[] range= new int[]{0...原创 2018-04-15 02:06:11 · 230 阅读 · 0 评论 -
leetcode第三题(Java)
Longest Substring Without Repeating Charactersclass Solution { public int lengthOfLongestSubstring(String s) { int result=0; int front=0; int after=0; char[] chars ...原创 2018-04-14 11:57:54 · 887 阅读 · 0 评论 -
LeetCode 第二题 (Java)Add Two Numbers
链表操作 // public class ListNode { // int val; // ListNode next; // ListNode(int x) { val = x; } // }class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) {...原创 2018-04-13 00:43:34 · 211 阅读 · 0 评论 -
idea:pom.xml中已填写但libraries中并未导入包
右键项目,maven-->Reimport即可原创 2018-03-21 09:46:47 · 7134 阅读 · 5 评论 -
c语言 指针
#include int array_set[4] = {1,2,3,4};int main(int argc,char** argv){ double p; p=10.0; int b = 123; int* ptr=NULL; ptr = &p; int* ptr2 = NULL; ptr2 = &b; printf("%d\n %d\n %f\n",ptr,*p原创 2017-08-26 21:27:12 · 219 阅读 · 0 评论 -
关于c语言中const的用法
int i;const int* p1 = &i;int const* p2 = &i;int *const p3 = &i;//const在*的前面表示p所指的int不可改变//const子*的后面表示p指针不可改变原创 2017-08-13 16:08:55 · 350 阅读 · 2 评论 -
leetcode292 java
这道题目中有一个假设“都有最佳得游戏策略”,这个假设如果不能理解的话,那么这道题是很难写的。这个假设的意思就是:选取的时候带一定的策略,比如5块石头,第一个取的人不会傻到取2块或者3块石头,让对方直接取剩下的石头并赢得胜利。所以,我们只需要考虑最后剩下几块石头即可,题目中给的数字4很关键,余下4块石头的话,先取石头的人是无论如何都赢得不了胜利的,那么如果余下的石头是5,6,7块的话,那么先取的一方...原创 2018-04-19 16:31:25 · 338 阅读 · 0 评论