LeetCode 1323. Maximum 69 Number

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
static auto x = []()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    return 0;
}();
class Solution {
public:
    int maximum69Number (int num) {
        stack<int> s;
        int now=num;
        while(now!=0){
            s.push(now%10);
            now/=10;
        }
       
        bool changed=false;
        int ret=0;
        while(!s.empty()){
            if(changed){
                ret=ret*10+s.top();
                s.pop();
            }
            else{
                if(s.top()==6){
                    changed=true;
                }
                ret=ret*10+9;
                s.pop();
            }
        }
        return ret;
    }
};



17 Replies to “LeetCode 1323. Maximum 69 Number”

  1. May I simply just say what a comfort to discover somebody who truly knows what they are talking about online.
    You definitely understand how to bring a problem to light and make it important.
    More people have to read this and understand this side of
    your story. It’s surprising you aren’t more popular given that you definitely have the gift.

  2. This design is wicked! You obviously know how to keep a reader amused.
    Between your wit and your videos, I was almost moved to start
    my own blog (well, almost…HaHa!) Wonderful job. I really loved what you had to
    say, and more than that, how you presented it. Too cool!

  3. Hey there this is somewhat of off topic but I was wondering if blogs
    use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding experience so I wanted
    to get guidance from someone with experience. Any help would be greatly appreciated!

  4. Heya this is somewhat of off topic but I was wondering
    if blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding
    knowledge so I wanted to get guidance from someone with experience.
    Any help would be greatly appreciated!

  5. Hey there! Someone in my Myspace group shared this site with us so I came to take a look.
    I’m definitely enjoying the information. I’m bookmarking
    and will be tweeting this to my followers! Excellent blog and fantastic style and design.

Leave a Reply to campbell465.deleverthai.com Cancel reply

Your email address will not be published. Required fields are marked *