August 28, 2016
Problem statement:
https://www.hackerrank.com/contests/world-codesprint-6/challenges/bonetrousle
Julia was naive on planning, management of time, tried to solve this algorithm, without any hesitation. She tried to score any point above 0, found the idea to write code using stack, but with additional 2+ hours to review code, stayed overnight, from 12:00am - 2:45am, a brute force solution. She did not make any (over 10 test cases: 5+ wrong answer, 4+ time out). So, she wrote down the experience to celebrate her weekend, over middle night struggling with an algorithm.
Share some statistics of world code sprint #6 workout:
Current Rank: 1112 - score 100/ 380 (score first 4 algorithms full score)
First practice:
Use stack, brute force, each box has two choice, join or skip. She tried to implement the brute force solution first, and then, she recalled the previous work on algorithm Leetcode: phone number:
https://gist.github.com/jianminchen/872bf70039fa8c61ff208b34a591c8ec
Only pass the test cases provided in the problem description.
https://gist.github.com/jianminchen/e3fc7d23a62274b207ddc41a06030cd4
Statistics:
score 0 out of 50 points.
Brute facts:
A brute force solution does not score any points - even pass the basic test case - test case 1.
Actionable Item:
Write a blog about this algorithm, document the importance of time complexity analysis; how to plan to spend time to work on a solution.
http://juliachencoding.blogspot.ca/2016/08/bonetrousle-hackerrank-world-code_75.html
From January 2015, she started to practice leetcode questions; she trains herself to stay focus, develops "muscle" memory when she practices those questions one by one. 2015年初, Julia开始参与做Leetcode, 开通自己第一个博客. 刷Leet code的题目, 她看了很多的代码, 每个人那学一点, 也开通Github, 发表自己的代码, 尝试写自己的一些体会. She learns from her favorite sports – tennis, 10,000 serves practice builds up good memory for a great serve. Just keep going. Hard work beats talent when talent fails to work hard.
Showing posts with label brute force. Show all posts
Showing posts with label brute force. Show all posts
Sunday, August 28, 2016
Wednesday, February 3, 2016
Algorithm: Count the number of palindromes in a string
Count the number of
palindromes in a string
January 28, 2016
Write down ideas:
1. First of all, do not count duplicate.
2. Brute force solution:
any substring of O(N^2) substrings to see if it is a palindrome;
Add the substring of palindrome to a hashset if it is not in the hashset.
And return the length of hashset
3. Use recursive solution - using subproblem to solve. Cannot filter out duplicate - not good
4. Better solution - use center point of string - 2n + 1, and then, go over each one, add all palindromes substring.
Requirement: write a C# code in 10 minutes for the solution, using brute force one.
https://github.com/jianminchen/AlgorithmsPractice/blob/master/NumberOfDistinctPalindromes.cs
Saturday, January 16, 2016
Leetcode 5: Longest substring palindrome
January 13, 2016
Read the blog:
http://blog.csdn.net/linhuanmars/article/details/20888595http://blog.csdn.net/linhuanmars/article/details/22777711
Please read 5-6 solution about this leetcode question, and then, collect all the wisdom. Try to have nice memory about the solution, some fun experience; therefore, it will be a quick and fun time to solve the similar problems in the future.
Do not rush to finish more leetcode questions. Try to focus on simple problems.
There are 5 solutions discussed in the following blog, most important is to give overview of 5 analysis, what is brute force solution - time, space complexity.
One way to make review more fun is to read more than 10 - 20 solutions, and know all the ideas out there, and then, write some code; Reading is most important to help understand algorithms, through a simple problem, common interview question.
http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-i.html
4 solutions in the above blog
one optimal solution - linear time solution in the following blog:
http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-ii.html
This blog is in Chinese. Excellent! Try to summary a few tips to come out linear time optimal solution! Do something to get more involved.
http://www.felix021.com/blog/read.php?2040
spent 10 minutes to read the article, enjoyed the reading; a good article with very well explained brute force solution, how good is to work on linear solution in time complexity.
https://www.akalin.com/longest-palindrome-linear-time
Read the blog:
http://www.acmerblog.com/leetcode-longest-palindromic-substring-5356.html
6th solution, a suffix tree solution:
http://www.allisons.org/ll/AlgDS/Tree/Suffix/
First blog about this leetcode question:
http://juliachencoding.blogspot.ca/2015/06/leetcode-longest-palndromic-substring.html
Another palindrome algorithm #9
https://github.com/jianminchen/Leetcode_C-/blob/master/9palindromeNumber.cs
Monday, June 15, 2015
Leetcode 5: longest palindromic substring
Problem statement:
Given a string S, find the longest palindromic substring in S.
June 15, 2015
Websites to read:
题目分析很透彻, 很有帮助!
https://leetcodenotes.wordpress.com/tag/palindrome/
C# code on github:
https://github.com/jianminchen/Leetcode_C-/blob/master/5LongestPalindromicSubstring.cs
https://github.com/jianminchen/Leetcode_C-/blob/master/5LongestPalindromic_B.cs
https://github.com/jianminchen/Leetcode_C-/blob/master/5LongestPalindromic_B.cs
January 2, 2016
Review the algorithm.
Leetcode question: 5. Longest Palindromic Substring
https://github.com/jianminchen/Leetcode_C-/blob/master/5LongestPalindromicSubstring.cs
January 13, 2016
Read the blog:
http://blog.csdn.net/linhuanmars/article/details/20888595http://blog.csdn.net/linhuanmars/article/details/22777711
Please read 5-6 solution about this leetcode question, and then, collect all the wisdom. Try to have nice memory about the solution, some fun experience; therefore, it will be a quick and fun time to solve the similar problems in the future.
Do not rush to finish more leetcode questions. Try to focus on simple problems.
There are 5 solutions discussed in the following blog, most important is to give overview of 5 analysis, what is brute force solution - time, space complexity.
One way to make review more fun is to read more than 10 - 20 solutions, and know all the ideas out there, and then, write some code; Reading is most important to help understand algorithms, through a simple problem, common interview question.
http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-i.html
4 solutions in the above blog
one optimal solution - linear time solution in the following blog:
http://articles.leetcode.com/2011/11/longest-palindromic-substring-part-ii.html
This blog is in Chinese. Excellent! Try to summary a few tips to come out linear time optimal solution! Do something to get more involved.
http://www.felix021.com/blog/read.php?2040
spent 10 minutes to read the article,
https://www.akalin.com/longest-palindrome-linear-time
Read the blog:
http://www.acmerblog.com/leetcode-longest-palindromic-substring-5356.html
6th solution, a suffix tree solution:
http://www.allisons.org/ll/AlgDS/Tree/Suffix/
January 7, 2017
3 code reviews:
Longest palindrome string - best review - no raw loop.
Labels:
2WayDp,
brute force,
brute force (center of string),
center of string,
DP,
palindrome,
recursive,
string,
Time analysis O(N^3->N),
time O(N^3),
time O(NxN),
回文
Location:
Vancouver, BC, Canada
Subscribe to:
Posts (Atom)