Definition check every possible way to find answer.
Points No efficiency most intuitive way to solving problems increase exponential growth one of exhaustive search Example If you find password with brute force algorithm, n=password digits, let’s assume 4 k=each digit can contain numbers, let’s assume 0~9 Then, all possible ways are $k^n=10^4=10000$ The combination can be in 10000 ways.
When the passwords digits are more than 4, it will be exponential growth.
Problem Problem_Link
My Answer 1 hour limit no search on internet My result Compile Error Best Answer Search from internet and modify
class Solution { public int countBinarySubstrings(String s) { int curRun = 1; int preRun = 0; int count = 0; for (int i = 1; i < s.length(); i++) { if (s.charAt(i) == s.charAt(i - 1)) ++curRun; else { count += Math.min(curRun, preRun); preRun = curRun; curRun = 1; } } return count + Math.
Purpose Create personal blog with Hugo and hosting with github at Windows 10. For this purpose, you need knowledge of HTML, Markdown, and Hugo structure. If you knwo golang, css, js, that will be better. But you do not have to.
used tools install date : 03-31-2021 hugo version : hugo v0.82.0 git version : git version 2.31.1.windows.1 windows : 10 windows terminal: v1.7.572.0 Chocolatey : v0.10.15 install tools windows terminal Install and set up Windows Terminal
Problem Problem_Link
My Answer 1 hour limit no search on internet Overview input : int[] nums, int target output : int[] My code class Solution { public int[] twoSum(int[] nums, int target) { int temp[] = new int[nums.length]; int rtn[] = new int[2]; for (int i = 0; i < nums.length; i++) { temp[i] = target - nums[i]; for (int j = 0; j < i; j++) { if (temp[j] == nums[i]) { rtn[0] = j; rtn[1] = i; return rtn; } } } rtn[0] = 0; rtn[1] = 0; return rtn; } } Time complexity : $O(n^2)$ Space complexity : $O(1)$ My result Runtime: 76 ms, faster than 12.
kinds of Arithmetic Operation in Python Symbol explaination return + Addition depend on input type - Subtraction depend on input type * Multiplication depend on input type / Division real number // Division Integer % Remaineder real number ** power of depend on input type and and logic gare T or F or or logic gate T or F < less than T or F > greater than T or F <= less than or equal T or F >= greater than or equal T or F == equal T or F Result +, -, *, /, //, %, **, <, >, <=, >= table A B result int int int A+B result int float float A+B result int bool-T int A+1 result int bool-F int A+0 result int none TypeError int String TypeError float bool-T float A+1 result float bool-F float A+0 result float none TypeError float String TypeError bool none TypeError bool String TypeError none String TypeError When computer created and programming language started, 1 was true and 0 was false.
Basic Search Algorithm Linear Search Binary Search Hashing Linear Search Definition check all of the list one by one.
Time complexity O(n)
Points It does not matter about date type need memory space as total list n Binary Search Definition check middle of list first. if the number is smaller than what you are looking for, check right side only and doing this continuously. It will decrease search list in half.
Definition Saperate big problem into small repeated parts and solve the problem.
All Recursion can be converted to Loop.
Good and bad points Loop Recursion intuitive complicated Long codes short codes good readability bad readability use less stack memories use much stack memories very low possiblity to get Stack overflow Stack overflow if too mcuh call very low possiblity to get overhead issue overhead issue: call function repeatly will make program slow each level of variable state will not saved each level of variable state will saved because of stack Actual code We should write recursion because it is good for reading and fixing it.
Purpose Create personal blog with Hugo and hosting with github at Windows 10. For this purpose, you need knowledge of HTML, Markdown, and Hugo structure. If you knwo golang, css, js, that will be better. But you do not have to.
used tools install date : 03-31-2021 hugo version : hugo v0.82.0 git version : git version 2.31.1.windows.1 windows : 10 windows terminal: v1.7.572.0 Chocolatey : v0.10.15 Notions hugo?
Definition A method of recursion optimization
Principle When there is recursion, the recursive class remain in stack memory and it will cause overflow. The tail call elimination is created for fixing the overflow issue. If the reucursive class return everything at last, the class does need to remain in stack memory.
Other Names tail call elimination tail call optimization How to Change return part of recursion to call function only.
Kinds of Variables scalar and non-scalar both object
scalar int : integer float : real number bool : True or False none : Null non-scalar String : data values that are made up of ordered sequences of characters, such as “hello world” checking data type print(type(Variable)) Case-Sensitive a and A are different variable
Casting x = str(3) # "4" y = int(3) # 4 z = float(3) # 4.