Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 142974

Recursion in computer science is a method of problem solving where the solution to a problem depends on solutions to smaller instances of the same problem.

10 votes
2 answers
4k views

Generate all valid combinations of n pair of parentheses

Implement an algorithm to print all valid (e.g. properly opened and closed) combinations of n pair of parentheses. Following is my implementation and I think it works. Is the algorithm efficien …
Stack crashed's user avatar
2 votes
1 answer
2k views

Given a binary tree, find the maximum path sum

This is a leetcode.com problem. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must …
Stack crashed's user avatar
5 votes
1 answer
595 views

Compute all valid configuration of eight queens on a 8x8 chess board

Write an algorithm to print all valid ways of arranging eight queens on an 8x8 chess board so that none of them attack any other. Following is my code for this. Do you see any performance or co …
Stack crashed's user avatar
1 vote
1 answer
838 views

Compute the number of ways a given amount (cents) can be changed

Given an infinite number of different coin types (such as pennies, nickels, dimes, quarters) find out how many ways n cents can be represented. My code appears to work (although I am curious …
Stack crashed's user avatar
1 vote

Generate all permutations of a list in Python

The algorithm as you have intended looks ok to me. However I have a few comments about the algorithm's efficiency. With the current approach you will regenerate the same permutation many times if th …
Stack crashed's user avatar