07 2015 档案
摘要:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.思路:首先想到的机试不断地减去一个数直到0为止,但是这样得复杂度为O(n),只得...
阅读全文
摘要:1,在Android.mk文件中加上LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llogLOCAL_PATH := $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE :=ndkdemoLOCAL_SRC_FILES :=c...
阅读全文
摘要:调试的时候会碰到总是自动打开avd太慢了,希望能够直接用真机,那么设置如下 Run As ->Run Configuration->target->选择 active device
阅读全文
摘要:在Eclipse中配置NDK自动编译环境buildersAndroid学习笔记——NDK中C++标准库、STL的配置;Include其他头文件 参考了百度经验里面的部分内容,发现里面还有些细节没有写出来,其中遇到不少问题,所以就在这里写出来和大家分享! 参考链接 Android NDK入门开发实...
阅读全文
摘要:1、windows中切换目录中有空格可以直接切换,但是Linux中需要使用转义例如要切换到/root/src test/命令:cd src\ test使用反斜杠转义后面再加上空格就可以啦2、如果执行$NDK/ndk-build出现/ndk-build: No such file or directo...
阅读全文
摘要:用javac 生成class文件后。假设class文件在源文件目录的包下,先将编译路径设置成源文件目录即可set classpath=G:\eclipse java\HelloWorld\src然后javah -jni com.example.helloworld.JNITest搞定
阅读全文
摘要:Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
阅读全文
摘要:Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:"((()))...
阅读全文
摘要:Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of digit ...
阅读全文
摘要:Given an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:Elemen...
阅读全文
摘要:之前在网上看到一个一种方法:public class BaseActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.o...
阅读全文
摘要:The connection to adb is down, and a severe error has occured.其实大家一直很困扰这个问题,就是其他软件占用了而已。很好解决的。1、点击window 选择 show views ->other->devices2、在window 添加一个D...
阅读全文
摘要:让多个Fragment 切换时不重新实例化在项目中需要进行Fragment的切换,一直都是用replace()方法来替换Fragment: public void switchContent(Fragment fragment) { if(mContent != fragment) ...
阅读全文
摘要:在使用PagerAdapter的时候,会有instantiateItem函数需要自己去重写。最后一句 假如写成((ViewPager) container).addView(v, position);会报错 :IndexOutOfBoundsException将position 改成 0 就可以啦...
阅读全文
摘要:近日,在做一个人人的第三方小项目。打算直接使用renren 的sdk 进行开发。因为renren的sdk是以android library project 形式发布的(关于这种project的内容可以参考android library project)。整个导入流程严格按照guide的内容操作,但是...
阅读全文
摘要:Question:Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, wher...
阅读全文
摘要:Question:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: ...
阅读全文
摘要:Question:Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the fa...
阅读全文
摘要:Question:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root...
阅读全文
摘要:Question:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which ...
阅读全文
摘要:Question: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 n...
阅读全文
摘要:Question: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 giv...
阅读全文
摘要:Question:GivennumRows, generate the firstnumRowsof Pascal's triangle.For example, givennumRows= 5,Return[ [1], [1,1], [1,2,1], [1,3,3,1], [1...
阅读全文
摘要:Question:Given an indexk, return thekthrow of the Pascal's triangle. For example, givenk= 3, Return[1,3,3,1].1、题型分类:2、思路:直接使用公式,第n行 第0个数是1,从第i个数开始一次...
阅读全文
摘要:Question:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a ca...
阅读全文
摘要:Question:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -...
阅读全文
摘要:Question:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: ...
阅读全文
摘要:Question:Compare two version numbersversion1andversion2.Ifversion1>version2return 1, ifversion1i2[i]) return 1; else if(i1[i...
阅读全文
摘要:在java.lang包中有String.split()方法,返回是一个数组我在应用中用到一些,给大家总结一下,仅供大家参考:1、如果用“.”作为分隔的话,必须是如下写法,String.split("\\."),这样才能正确的分隔开,不能用String.split(".");2、如果用“|”作为分隔的...
阅读全文
摘要:Question:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ......
阅读全文
摘要:Question:Given an array of sizen, find the majority element. The majority element is the element that appears more than⌊ n/2 ⌋times.You may assume tha...
阅读全文
摘要:Question:Related to questionExcel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For examp...
阅读全文
摘要:Question:Given an integern, return the number of trailing zeroes inn!.1、题型分类:2、思路:寻找n!后面的0的个数,即有多少个2*5,从而需要寻找里面总共有多少个2和多少个5,2肯定比5多,则只要找出5的个数即可。n/5是从n/...
阅读全文
摘要:Question:Rotate an array ofnelements to the right byksteps.For example, withn= 7 andk= 3, the array[1,2,3,4,5,6,7]is rotated to[5,6,7,1,2,3,4].1、题型分类:...
阅读全文
摘要:Question:Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as00000010100101000001111010011100)...
阅读全文
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming weight).For example, the 32-bit in...
阅读全文
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo...
阅读全文
摘要: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...
阅读全文
摘要:Remove all elements from a linked list of integers that have valueval.ExampleGiven:1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6,val= 6Return:1 --> 2 --> 3 --...
阅读全文
摘要:Description:Count the number of prime numbers less than a non-negative number,n.思路:一个一个判断,时间复杂度:O(n^2)代码:TLEpublic class Solution { public int coun...
阅读全文
摘要:Given two stringssandt, determine if they are isomorphic.Two strings are isomorphic if the characters inscan be replaced to gett.All occurrences of a ...
阅读全文
摘要:Reverse a singly linked list.思路:新建一个ListNode,最后返回这个ListNode.next。中间使用两个临时指针一个指向原来的链表头,一个指向新的链表的next.每次循环都往里面插入新的tempNode.时间复杂度:O(n)代码: public ListN...
阅读全文
摘要:Given an array of integers and an integerk, find out whether there there are two distinct indicesiandjin the array such thatnums[i] = nums[j]and the d...
阅读全文
摘要:Find the total area covered by tworectilinearrectangles in a2Dplane.Each rectangle is defined by its bottom left corner and top right corner as shown ...
阅读全文
摘要:Implement the following operations of a stack using queues.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top()...
阅读全文
摘要:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1思路:利用temp进行交换,采用递归从顶至下,终止条件本身为空或者是叶子节点。...
阅读全文
摘要:Given a sorted integer array without duplicates, return the summary of its ranges.For example, given[0,1,2,4,5,7], return["0->2","4->5","7"].思路:采用双指针 ...
阅读全文
摘要:Given an integer, write a function to determine if it is a power of two.判断一个数是不是2的幂。思路,找出该数中二进制位1的个数时间复杂度:O(n)代码: public boolean isPowerOfTwo(int n...
阅读全文
摘要:Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue.pop() -- Removes the element from in front o...
阅读全文
摘要:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ...
阅读全文
摘要:二叉树 在计算机科学中,二叉树是每个节点最多有两个子树的树结构。通常子树被称作“左子树”(left subtree)和“右子树”(right subtree)。二叉树常被用于实现二叉查找树和二叉堆。 二叉树的每个结点至多只有二棵子树(不存在度大于2的结点),二叉树的子树有左右之分,次序不能颠倒。二叉
阅读全文
摘要:Given a singly linked list, determine if it is a palindrome.该题是判断一个链表是不是回文链表。思路一:将该链表反转,然后从头开始对比节点值,时间复杂度O(n),空间复杂度O(N)思路二:利用runner pointer。很多的题目都可以利用...
阅读全文
摘要:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an...
阅读全文
摘要:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:You may assume thatnums1has enough space (size that is great...
阅读全文
摘要:public ListNode deleteDuplicates(ListNode head) { if(head==null || head.next==null) return head; ListNode pre=head;; ...
阅读全文
摘要:You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb...
阅读全文
摘要:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"tw...
阅读全文
摘要:Quest:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.合并两...
阅读全文
摘要:public ListNode removeNthFromEnd(ListNode head, int n) { if(head==null) return null; if(n==0)//如果n==0 return h...
阅读全文
摘要:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the correct ...
阅读全文
摘要:罗马数字 有几条须注意掌握; (1)基本数字Ⅰ、X 、C 中的任何一个,自身连用构成数目,或者放在大数的右边连用构成数目,都不能超过三个;放在大数的左边只能用一个。 (2)不能把基本数字 V 、L 、D 中的任何一个作为小数放在大数的左边采用相减的方法构成数目;放在大数的右边采用相加的方式构成数...
阅读全文
摘要:Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of ...
阅读全文
摘要:两种解法1、将字符串先拼成图 1 public String convert(String s, int numRows) { 2 int l=s.length(); 3 if(l0 && index<s.length();rowIndex--)19 ...
阅读全文
摘要:public static String findLongestOfTheSame(String s1,String s2) { char[] c1=s1.toCharArray(); char[] c2=s2.toCharArray(); int ...
阅读全文
摘要:当我们需要对代码有更深入的了解的时候,就需要去查看对应生成的字节码,下面是Eclipse 添加 javap功能的步骤 注:当要查看的类中包含内部类时,采用这种方法无法查看内部类,需要在命令行中查看。 1、RUN->External Tools->External Tools Configur...
阅读全文
摘要:Q:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters ...
阅读全文