[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: maxresdefault.jpg (64 KB, 1280x720)
64 KB
64 KB JPG
>write high acceptance rate problems to get familiar with algo templates
>when you can write templates without much thinking, try harder problems
>make a list of problems with non-trivial special tricks and remember those tricks
is this the correct way to learn leetcode?
>>
>>106571870
I don't get it (the image)
>>
the correct way to learn leetcode is to make friends and get jacked in college so you can bypass HR humiliation rituals entirely
>>
>>106571990
this pretty much
>>
>>106571899
I believe what it's showing is:
>the first term contains the digits 2, 4, and 3
>the second term contains the digits 5, 6, and 4
>the sum contains the digits 7, 0, and 8
>the program should find the numbers containing those digits which would make the equation mathematically correct
>>
/g/ is so useless
>>
solve the questions in scheme
(define (add-two l r)
(let loop ((l l)
(r r)
(c 0))
(if (and (null? l) (null? r) (zero? c))
'()
(let ((carry (+ c
(if (not (null? l)) (car l) 0)
(if (not (null? r)) (car r) 0))))
(cons (modulo carry 10)
(loop (if (not (null? l)) (cdr l) '())
(if (not (null? l)) (cdr r) '())
(quotient carry 10)))))))
>>
>>106572795
>(if (not (null? l)) (cdr r) '())
should be
(if (not (null? r)) (cdr r) '())

did not proof read
>>
File: img-2025-09-13-11-20-49.png (167 KB, 2672x1496)
167 KB
167 KB PNG
impl Solution {
pub fn add_two_numbers(l1: Option<Box<ListNode>>, l2: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
Self::add_lists(&l1, &l2, 0)
}

fn add_lists(l1: &Option<Box<ListNode>>, l2: &Option<Box<ListNode>>, carry: i32) -> Option<Box<ListNode>> {
match (l1, l2, carry) {
(None, None, 0) => None,
(None, None, c) => Some(Box::new(ListNode::new(c))),
(Some(l), None, _) | (None, Some(l), _) => {
let sum = l.val+carry;
Some(Box::new(ListNode{val: sum%10, next: Self::add_lists(&l.next,&None,sum/10)}))},
(Some(l1), Some(l2), _) => {
let sum = l1.val+l2.val+carry;
Some(Box::new(ListNode{val: sum%10, next: Self::add_lists(&l1.next,&l2.next,sum/10)}))}
}
}
}
>>
>learn the basics of <thing> well enough that it becomes second nature and you can do it without thinking
>now you can do slightly more advanced things with the same amount of effort you used for the initial things
>such slightly more advanced things eventually become effortless
>move on to slightly more advanced things again, repeat ad infinitum
That's pretty much how all human learning works, basically. I got a rating of 2000 at chess doing this.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.