formatting source-code for 153fb7b8a5

This commit is contained in:
github-actions
2020-05-30 04:02:09 +00:00
parent 92fe9495ec
commit 8a2de9842b
175 changed files with 1671 additions and 3460 deletions

View File

@@ -22,8 +22,7 @@ int min(int x, int y, int z) { return min(min(x, y), z); }
* str1 to str2.
* O(3^m)
*/
int editDist(string str1, string str2, int m, int n)
{
int editDist(string str1, string str2, int m, int n) {
if (m == 0)
return n;
if (n == 0)
@@ -45,16 +44,13 @@ int editDist(string str1, string str2, int m, int n)
/* A DP based program
* O(m x n)
*/
int editDistDP(string str1, string str2, int m, int n)
{
int editDistDP(string str1, string str2, int m, int n) {
// Create Table for SubProblems
int dp[m + 1][n + 1];
// Fill d[][] in bottom up manner
for (int i = 0; i <= m; i++)
{
for (int j = 0; j <= n; j++)
{
for (int i = 0; i <= m; i++) {
for (int j = 0; j <= n; j++) {
// If str1 empty. Then add all of str2
if (i == 0)
dp[i][j] = j;
@@ -78,8 +74,7 @@ int editDistDP(string str1, string str2, int m, int n)
return dp[m][n];
}
int main()
{
int main() {
string str1 = "sunday";
string str2 = "saturday";