diff --git a/README.md b/README.md index 1219c20..a82f5b3 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,3 @@ * 建立自己的分支,按自己的姓名命名: 如 张三 * **请不要在master上进行提交答案** - diff --git "a/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\345\205\203\347\264\240.md" "b/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\345\205\203\347\264\240.md" new file mode 100644 index 0000000..a1a14bc --- /dev/null +++ "b/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\345\205\203\347\264\240.md" @@ -0,0 +1,52 @@ +## 删除链表中的元素 +删除链表中等于给定值val的所有节点。 + +**样例** +给出链表 1->2->3->3->4->5->3, 和 val = 3, 你需要返回删除3之后的链表:1->2->4->5。 + + +```java +/** + * Definition for singly-linked list. + * public class ListNode { + * int val; + * ListNode next; + * ListNode(int x) { val = x; } + * } + */ +public class Solution { + /** + * @param head a ListNode + * @param val an integer + * @return a ListNode + */ + public ListNode removeElements(ListNode head, int val) { + // Write your code here + ListNode l = head; + if(head==null) { + System.out.println("false"); + } + while (head.next!=null) + { + if(head.next.val == val) + { + head.next=head.next.next; + else + { + head.next=null; + break; + } + } + else + { + head=head.next; + } + + } + if(l.val==val) return l.next; + return l; + } + + } +} +``` diff --git "a/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\345\205\203\347\264\240.pdf" "b/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\345\205\203\347\264\240.pdf" new file mode 100644 index 0000000..0b29b0a Binary files /dev/null and "b/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\345\210\240\351\231\244\351\223\276\350\241\250\344\270\255\347\232\204\345\205\203\347\264\240.pdf" differ diff --git "a/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\346\226\220\346\263\242\347\272\263\345\245\221\346\225\260\345\210\227.md" "b/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\346\226\220\346\263\242\347\272\263\345\245\221\346\225\260\345\210\227.md" new file mode 100644 index 0000000..5cf472e --- /dev/null +++ "b/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\346\226\220\346\263\242\347\272\263\345\245\221\346\225\260\345\210\227.md" @@ -0,0 +1,33 @@ +## 斐波纳契数列 +查找斐波纳契数列中第 N 个数。 +所谓的斐波纳契数列是指: +前2个数是 0 和 1 。 +第 i 个数是第 i-1 个数和第i-2 个数的和。 +斐波纳契数列的前10个数字是: +0, 1, 1, 2, 3, 5, 8, 13, 21, 34 ... + +**样例** +给定 1,返回 0 +给定 2,返回 1 +给定 10,返回 34 + + +```java +class Solution { + /** + * @param n: an integer + * @return an integer f(n) + */ + public int fibonacci(int n) { + // write your code here + int []a=new int[2048]; + a[0]=0; + a[1]=1; + for(int i= 2;i<2048;i++){ + a[i]=a[i-1]+a[i-2]; + } + return a[n-1]; + } +} +``` +郭浩东 \ No newline at end of file diff --git "a/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\346\226\220\346\263\242\347\272\263\345\245\221\346\225\260\345\210\227.pdf" "b/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\346\226\220\346\263\242\347\272\263\345\245\221\346\225\260\345\210\227.pdf" new file mode 100644 index 0000000..a0fb807 Binary files /dev/null and "b/\347\254\254\344\270\200\345\221\250\344\275\234\344\270\232/\346\226\220\346\263\242\347\272\263\345\245\221\346\225\260\345\210\227.pdf" differ diff --git "a/\347\254\254\344\270\211\345\221\250\344\275\234\344\270\232/\345\217\246\347\261\273\345\212\240\346\263\225.md" "b/\347\254\254\344\270\211\345\221\250\344\275\234\344\270\232/\345\217\246\347\261\273\345\212\240\346\263\225.md" new file mode 100644 index 0000000..8d3a601 --- /dev/null +++ "b/\347\254\254\344\270\211\345\221\250\344\275\234\344\270\232/\345\217\246\347\261\273\345\212\240\346\263\225.md" @@ -0,0 +1,24 @@ +# 题目描述 +*** +**请编写一个函数,将两个数字相加。不得使用+或其他算数运算符。 +给定两个int A和B。请返回A+B的值** +*** +*测试样例:* + +>输入:1,2 +*** +>返回:3 +*** + +```java +import java.util.*; + +public class UnusualAdd { + public int addAB(int A, int B) { + // write code here + + } +} +``` +*** +**[在线测试地址](http://www.nowcoder.com/practice/e7e0d226f1e84ba7ab8b28efc6e1aebc?tpId=8&tqId=11065&rp=1&ru=/ta/cracking-the-coding-interview&qru=/ta/cracking-the-coding-interview/question-ranking)** diff --git "a/\347\254\254\344\270\211\345\221\250\344\275\234\344\270\232/\350\257\215\351\242\221\347\273\237\350\256\241.md" "b/\347\254\254\344\270\211\345\221\250\344\275\234\344\270\232/\350\257\215\351\242\221\347\273\237\350\256\241.md" new file mode 100644 index 0000000..a3b810a --- /dev/null +++ "b/\347\254\254\344\270\211\345\221\250\344\275\234\344\270\232/\350\257\215\351\242\221\347\273\237\350\256\241.md" @@ -0,0 +1,6 @@ +# 题目描述 +*** +请设计一个高效的方法,找出任意指定单词在一篇文章中的出现频数。 +给定一个string数组article和数组大小n及一个待统计单词word,请返回该单词在文章中的出现频数。保证文章的词数小于等于1000。 +*** +**[在线测试地址](http://www.nowcoder.com/practice/ebff2814640a48fdb0d9690677f7c7de?tpId=8&tqId=11062&rp=1&ru=/ta/cracking-the-coding-interview&qru=/ta/cracking-the-coding-interview/question-ranking)** \ No newline at end of file diff --git "a/\347\254\254\344\272\214\345\221\250\344\275\234\344\270\232/\344\272\225\345\255\227\346\243\213.PNG" "b/\347\254\254\344\272\214\345\221\250\344\275\234\344\270\232/\344\272\225\345\255\227\346\243\213.PNG" new file mode 100644 index 0000000..85fc169 Binary files /dev/null and "b/\347\254\254\344\272\214\345\221\250\344\275\234\344\270\232/\344\272\225\345\255\227\346\243\213.PNG" differ diff --git "a/\347\254\254\344\272\214\345\221\250\344\275\234\344\270\232/\346\227\240\345\210\244\346\226\255max.PNG" "b/\347\254\254\344\272\214\345\221\250\344\275\234\344\270\232/\346\227\240\345\210\244\346\226\255max.PNG" new file mode 100644 index 0000000..9a62520 Binary files /dev/null and "b/\347\254\254\344\272\214\345\221\250\344\275\234\344\270\232/\346\227\240\345\210\244\346\226\255max.PNG" differ