Skip to content

Commit

Permalink
Create BIGGER_IS_GREATER.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyanshiguptaaa authored Dec 4, 2020
1 parent dc0e552 commit 920b3c0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Strings/BIGGER_IS_GREATER.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
string biggerIsGreater(string w)
{
for (int i = w.length() - 2; i >= 0; i--)
{
for (int j = w.length() - 1; j > i; j--)
{
if (w[j] > w[i])
{
string result = "";
for (int k = 0; k < i; k++)
{
result += w[k];
}
result += w[j];
for (int t = w.length() - 1; t > i; t--)
{
if (t != j) result += w[t];
else result+= w[i];
}
return result;
}
}
}
return "no answer";
}

0 comments on commit 920b3c0

Please sign in to comment.