Java solution for this one and 1405
\n\tclass Solution {\n    public String strWithout3a3b(int a, int b) {\n        return longestDiverseString(a, b, 0);\n    }\n    \n    public String longestDiv
```\n\tclass Solution {\n    public String strWithout3a3b(int a, int b) {\n        return longestDiverseString(a, b, 0);\n    }\n    \n    public String longestDiverseString(int a, int b, int c) {\n        PriorityQueue<Pair> pq = new PriorityQueue<>(\n            (x, y) -> Integer.compare(y.freq, x.freq)\n        );\n        \n        if(a != 0) {\n            Pair pa = new Pair(\'a\', a);\n            pq.offer(pa);\n        }\n        \n        if(b != 0) {\n            Pair pb = new Pair(\'b\', b);\n            pq.offer(pb);\n        }\n        \n        if(c != 0) {\n            Pair pc = new Pair(\'c\', c);\n            pq.offer(pc);\n        }\n        \n        StringBuilder sb = new StringBuilder();\n        \n        while(!pq.isEmpty()) {\n            if(pq.size() == 1) {\n                int k = Math.min(pq.peek().freq, 2);\n                for(int i = 0; i < k; i++) {\n                    sb.append(pq.peek().ch);\n                }    \n                return sb.toString();\n            }\n            \n            Pair p1 = pq.poll();\n            Pair p2 = pq.poll();\n            \n            int k = Math.min(1 + p1.freq - p2.freq, 2);\n            \n            for(int i = 0; i < k; i++) {\n                sb.append(p1.ch);\n            }\n            \n            sb.append(p2.ch);\n            \n            p1.freq -= k;\n            p2.freq -= 1;\n            \n            if(p1.freq > 0) pq.offer(p1);\n            if(p2.freq > 0) pq.offer(p2);\n        }\n        \n        return sb.toString();\n    }\n    \n    private class Pair {\n        char ch;\n        int freq;\n        \n        Pair(char ch, int freq) {\n            this.ch = ch;\n            this.freq = freq;\n        }\n    }\n}\n```
[]