-
Notifications
You must be signed in to change notification settings - Fork 0
1. Basics
Madhav Anand edited this page Nov 3, 2021
·
2 revisions
The best way to get started is by "Faith Based Learning"
Getting started with a language is learning Input-Output, Variable-Datatype, Condition-Loop
- Given two tools,
println
&print
- Try to print in single line.
You should name a variable using the same care with which you name a first-born child.
- A variable is a named location in memory.(Don't forget Diagram)
- Printing & appending values.
- Arithmetic Operations
* + /
- Priority is
Precedence
and Same Priority isAssociativity
- Controls the flow of statements execution.
- Program. If Even or Odd.
- Understand the flow of statements execution.
- To repeat some set of statements.
- Three elements
Initialization
,Condition
,Increment
- Visualize the box.
java.util.Scanner
- Only String
nextLine()
, Only IntnextInt()
- Together
Integer.parseInt(scn.nextLine())
,int-enter-string
- Without this
int-space-string
- Go with boolean function approach and ternary for result.
- Optimize for time complexity -
t x n = 10^4 x 10^9 = 10^13
but computers are generally 3 GHz -3 x 10^9
- At the end, optimization is
t x (n)^1/2 = 10^4 x 10^5 = 10^9
- Similar to above.
- See another approach along with visualization of moving(a, b) that down.
- Divide till 0 & count it.
- Default is reverse printing.