All Projects → XingxingHuang → Leetcode-for-Fun

XingxingHuang / Leetcode-for-Fun

Licence: other
Daily coding practice about data structure and algorithms. Leetcode, Lintcode, codeforces

Programming Languages

java
68154 projects - #9 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Leetcode-for-Fun

Leetcode
LeetCode Top 100 Liked Questions | Top Interview Questions | LeetCode 用户最喜欢的100题 | 面试最容易被问到的题
Stars: ✭ 312 (+1460%)
Mutual labels:  leetcode-java
Leetcode
leetcode 顺序刷题,详细通俗题解,with JAVA
Stars: ✭ 2,192 (+10860%)
Mutual labels:  leetcode-java
Interviews
Everything you need to know to get the job.
Stars: ✭ 54,875 (+274275%)
Mutual labels:  leetcode-java
Algorithms
Here is the my solutions for problems in {leetcode, hackerrank, geeksforgeeks}
Stars: ✭ 36 (+80%)
Mutual labels:  leetcode-java
Leetcode Solutions
This repository consists of solutions to the problem from LeetCode platform. Subscribe to our Channel for more updates
Stars: ✭ 128 (+540%)
Mutual labels:  leetcode-java
Windary
🎓 My solutions to LeetCode problems written in Go, Java, JavaScript, Kotlin, Python, Rust & Swift.
Stars: ✭ 189 (+845%)
Mutual labels:  leetcode-java
Leetcode
Leetcode solutions
Stars: ✭ 2,894 (+14370%)
Mutual labels:  leetcode-java
LeetCode-Solution-Well-Explained
My LeetCode solutions using Java. Sorted in different topics and add detailed comments for easy understanding.
Stars: ✭ 23 (+15%)
Mutual labels:  leetcode-java
Leetcode Java
LeetCode solutions written in Java
Stars: ✭ 134 (+570%)
Mutual labels:  leetcode-java
Leetcode
Solutions to LeetCode problems; updated daily. Subscribe to my YouTube channel for more.
Stars: ✭ 3,090 (+15350%)
Mutual labels:  leetcode-java
Algorithms And Data Structures
Algorithms and Data Structures implemented in Java
Stars: ✭ 41 (+105%)
Mutual labels:  leetcode-java
Awesome Java Leetcode
👑 LeetCode of algorithms with java solution(updating).
Stars: ✭ 8,297 (+41385%)
Mutual labels:  leetcode-java
Interviewguide
《大厂面试指北》——包括Java基础、JVM、数据库、mysql、redis、计算机网络、算法、数据结构、操作系统、设计模式、系统设计、框架原理。最佳阅读地址:http://notfound9.github.io/interviewGuide/
Stars: ✭ 3,117 (+15485%)
Mutual labels:  leetcode-java
Leetcode
LeetCode刷题记录与面试整理
Stars: ✭ 6,469 (+32245%)
Mutual labels:  leetcode-java
Leetcodeanimation
Demonstrate all the questions on LeetCode in the form of animation.(用动画的形式呈现解LeetCode题目的思路)
Stars: ✭ 68,143 (+340615%)
Mutual labels:  leetcode-java
Leetcode Solutions With Java And Kotlin
LeetCode 系列题解, 在线阅读 https://offer.hi-dhl.com
Stars: ✭ 266 (+1230%)
Mutual labels:  leetcode-java
Leetcode Java
leetcode-java,updating!
Stars: ✭ 170 (+750%)
Mutual labels:  leetcode-java
LeetCode-Book
《剑指 Offer》 Python, Java, C++ 解题代码,LeetBook《图解算法数据结构》配套代码仓。
Stars: ✭ 1,164 (+5720%)
Mutual labels:  leetcode-java
Leetcode-solutions
Leetcode Grinder.
Stars: ✭ 14 (-30%)
Mutual labels:  leetcode-java
Leetcode Java Solutions
Solutions to LeetCode Online Judge problems in Java
Stars: ✭ 194 (+870%)
Mutual labels:  leetcode-java

TIPs for coding

Practice is so helpful to improve one's coding skills. This github records the daily algorithm practice. In each directory, the java or python code and some tips are included. The following is some useful tips one would meet in these online coding.

common methods (must know):

brute force, dfs/bfs, sorting, dp, recursive, math, number theory, bit, probabilities, games, greedy, combinatorics, divide and conquer.

two pointer, Sweepline

string, tree, graph, hashing, matrices

  • dp: understand the optimization from brute force to memorization to dp, buttom-top method, top-buttom method.

  • gcd method to calculate greatest common divisor.

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }
  • Compare two tree, please first serialize and deserialize tree.
  • While using DP, we may modify the dp array with another non-linear way.
  • While use hashmap for char in string, use int[256] as HashMap instead.
  • bit
// exchange x, y 
	x = x + y;
	y = x - y;
	x = x - y; 
	
	x = x^y; // 只能对int,char. 存不一样的bit位
	y = x^y; 
	x = x^y;
	
// get the last 1.
// in bit, -diff is reverse every bit position and plus 1.
diff &= -diff;
	string minWindow(string s, string t) {
        vector<int> map(128,0);
        for(auto c: t) map[c]++;
        int counter=t.size(), begin=0, end=0, d=INT_MAX, head=0;
        while(end<s.size()){
            if(map[s[end++]]-->0) counter--; //in t
            while(counter==0){ //valid
                if(end-begin<d)  d=end-(head=begin);
                if(map[s[begin++]]++==0) counter++;  //make it invalid
            }  
        }
        return d==INT_MAX? "":s.substr(head, d);
    }
  • to find the one different char or int, use bit manipulation like 389

  • segment tree (307)

summarry

动态规划,九章总结

Recodes for some "Hard" questions

30 Substring with Concatenation of All Words. Two different method, the fast one is hard.

32 Longest Valid Parentheses DP, stack. hard problem but with many smart idea.

134 very good practice. Not so straightforward.

137 Single Number II, bit manipunation. very hard

146 LRU Cache LinkedHashMap

166 Fraction to Recurring Decimal, Math, corner cases.

218 The skyline problem. Use Sweepline method.

220 Contains Duplicate III, TreeSet

363 matrix sum, binary search, DP, TreeSet

368 DP, need some thought, have fun.

479 Largest Palindrome Product. Math

564 Find the Closest Palindrome. Hard. Becareful for corner cases.

649, 495. greedy

650, 651 DP

659 Remove 9, Math,

Recodes for some "must do" questions

1 167 Two Sum and related two sum and other N sum questions. Must do!

11 42 Container With Most Water. Trapping Rain Water. Two pointers.

34 Search for a Range. very good practice for binary search.

Subsets, Permutations, Combination Sum, Palindrome Partioning backtrack problems

44 Wildcard Matching basic DP method

46 47 Very common question. Check discussion for a summary.

54 Spiral Matrix. Print maxtix problem. Practice the basic coding skill with edges.

72 Edit Distance. You will learn memorization and dp from this "hard" (actually easy) question.

76 Minimum Window Substring. hard, good practice for two pointers.

97 InterLeaving String. brute force > memorization > 2D dp > 1D dp

98 Binary search tree. Please practice with different methods. recursive with and without global variation, non recursive.

105 Tree preorder inorder. Very interesting and useful practice for backtrack.

116 Very good exercise for trees.

189 Easy but interesting, use as many methods as you can to rotate array. Must know the reverse method by two reverses.

202 Happy Number. Interesting problem with two solutions. One solution is similiar to the cycle detetion in linkedlist.

307 Range Sum Query - Mutable. Studey how to use segment tree

373 Find K Pairs with Smallest Sums. Use priority queue for questions about "Top K". This is a hard problem.

401 easy question. Attention: think more about each question. Every question has its own method.

404 Sum of Left Leaves. Many tree problems can be solved with iterative and recursive methods.

458 Poor Pigs.

581 Shortest Unsorted Continuous Subarray. Interesting easy problem with several kinds of solutions.

609 Find Duplicate File in System. Interesting, BFS/DFS for the follow up question about big files.

--

http://wiki.jikexueyuan.com/project/for-offer/question-three.html

Resources

www.glassdoor.ca www.careercup.com www.geeksforgeeks.com www.leetcode.com www.hackerrank.com www.topcoder.com

Mock Interviews

  • groups of 2 or 3(max)
  • Interviewee, ask questions, discuss approach, though as code
  • Interviewer, pick question, guide if lost

刷题经历

  • coursera Algorithm I, 学习java,看了大神如何分析。花了不少时间。
  • (曲折)听了不少讲座,然而收效甚微
  • 牛客网 直通BAT。从而建立基本的数据结构的概念
  • cc150或者剑指offer。从lintcode上刷,建立起各种问题分析方法。于此同时查看cc150后面的OOD的几个经典内容
  • 总结各种方法。(豁然开朗)
  • leetcode一遍。(Not possible)。200 题之后应该快速过,保持速度与量,多思考,多总结。
  • leetcode contest 强制自己思考和总结,认识不足,看牛人代码。

基础数据结构

数组

链表

堆栈

队列

HashTable

字符串

算法思想

贪心算法

动态规划

二分法

分治算法

双指针

滑动窗口

其他主题

位运算

大数据

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].